text
stringlengths
28
935k
meta
stringlengths
137
139
red_pajama_subset
stringclasses
1 value
\section{Introduction} Estimating 3D human pose from RGB images is a long-standing problem in computer vision, with broad applications in e.g. action recognition, 3D content production, the game industry and human-robot interaction. While recent approaches have shown impressive results, most of them are focused on images containing a single person~\cite{li20143d,tekin2016structured,mehta2017vnect,Zhou_2017_ICCV,pavlakos2017coarse,pavlakos_learning_2018,Sun_2018_ECCV,yang20183d,Zhao_2019_CVPR,MorenoCVPR2017,Martinez_2017_ICCV,pavllo:2019,Zhao_2019_CVPR,zhou2016sparseness,Chen_2017_CVPR}. The problem of multi-person 3D pose estimation, introduces additional challenges to the single person setup, mostly due to the fact that inter-person occlusions are inevitable and absolute pose of each person w.r.t the camera is important. In order to tackle the problem, sequential~\cite{zanfir_cvpr_2018_multiple,TDBU_cheng_2021_CVPR} or multi-camera systems~\cite{Dong2019,Lin2021,Tu2020,Wu2021} images have been exploited. In this paper we aim at addressing the most constricting version of the problem, in which multi-person 3D pose estimation is to be solved from one single view. This has been indirectly tackled by treating different people independently, and applying single-person reasoning~\cite{lcr,lcr++,Moon_2019_ICCV_3DMPPE}. Nevertheless, these approaches are prone to deliver gross errors, specially in scenes where people are in close interaction. Very few recent works have proposed different strategies to better exploit multi-person relations. For instance,~\cite{HMOR2020} encodes interaction information as ordinal relations of depths. CRMH~\cite{jiang2020_multiperson} devised a depth-aware loss to resolve the overlapping problem. In any event, these methods still reason about multi-people in a local neighborhood or in a strict pairwise manner and do not model the fact that human interactions can occur at large ranges and/or among all people in the scene. For instance, in sports, the team formation is correlated as a whole and not at local regions of the pitch. In order to capture more global person relations, Pi-Net~\cite{guo2021pi} leverages on a self-attention module that enables to simultaneously reason for all people in the image. However, this approach requires defining one of the individuals as a reference, and the output of the model is very sensitive to the selection of that reference. \input{rr_figure01_example_teaser} In order to overcome the limitations of previous approaches we propose a novel scheme to model people interactions in a holistic and permutation-invariant fashion. In our approach, we assume we are given an initial set of 3D poses, potentially noisy, estimated by an off-the-shelf algorithm~\cite{Moon_2019_ICCV_3DMPPE}. These poses are understood as elemenents of a set, and are fed into a a Set Transformer architecture~\cite{set_transformer_lee2019} that simultaneously processes all of them, and yields an output encoding which does not change under any permutation of the elements in the input set. This global encoding is then used to estimated a correction residual of the the initial 3D poses. A thorough evaluation on the MuPoTS-3D~\cite{singleshot}, Panoptic~\cite{panoptic} and NBA2K~\cite{zhu_2020_eccv_nba} multi-person datasets shows that the proposed approach consistently improves the SOTA Pi-Net~\cite{guo2021pi} even when initial 3D poses estimated by the off-the-shelf~\cite{Moon_2019_ICCV_3DMPPE} network are noisy, corrupted by occlusions or contain truncated body joints. Interestengly, the proposed approach is very efficient, and could be used as a post-processing module on top of any pose estimation method with negligible computation overhead. In summary, our key contributions are the following: \begin{itemize} \setlength{\itemsep}{0pt} \item We introduce a novel approach to model the relationship among the 3D poses of multiple persons. \item Our approach is permutation invariant, and can handle an arbitrarily large number of people. \item We use the representation provided by our model in the multi-person 3D pose estimation from a single image problem, to refine the initial 3D poses of an off-the-shelf 3D detector. \item The proposed module is efficient and can be used with any 3D pose detector. \end{itemize} \section{Related work}\label{sec:sota} \subsubsection{Single-Person 3D Human Pose Estimation.} Estimating the 3D pose of human joints has received growing interest mostly for its importance in real-world applications and by the release of large-scale public MoCap and multi-camera datasets~\cite{ionescu_human3.6m:_2014,MPI-INF-3DHP,panoptic}. A lot of important studies have been done on this topic for single-person, where two major types of methods can be found: regressing the 3D joints directly from the image~\cite{li20143d,tekin2016structured,Bogo:ECCV:2016,mehta2017vnect,Zhou_2017_ICCV,pavlakos2017coarse,pavlakos_learning_2018,Simo_ijcv2017,Sun_2018_ECCV,yang20183d,Zhao_2019_CVPR} or lifting 2D joints to 3D joints~\cite{MorenoCVPR2017,Martinez_2017_ICCV,pavllo:2019,Zhao_2019_CVPR,zhou2016sparseness,Chen_2017_CVPR}. \vspace{-0.3cm} \subsubsection{Multi-person 3D Human Pose Estimation.} Approaches to multi-person 3D human pose estimation can be categorized either in single-view or multi-view reconstruction. In this paper, we focus on the single-view part of this problem. Although, multi-person 3D pose estimation is an important problem, its was not until recent that more attention have been given to it. The broadest category for these is either top-down or bottom-up approaches. Top-down approaches focus on estimating first the pose of each person individually and then placing them in the scene in a spatially coherent and correct manner. Some works in this category are~\cite{lcr,lcr++,Moon_2019_ICCV_3DMPPE,hdnet_2020,HMOR2020,darval_multi_2019,zanfir_cvpr_2018_multiple,jiang2020_multiperson}. Some of these works only deal with person-centric pose~\cite{lcr,lcr++} recovery whilst others recover the absolute camera-centric pose of the persons in the scene~\cite{Moon_2019_ICCV_3DMPPE,hdnet_2020,darval_multi_2019,zanfir_cvpr_2018_multiple,jiang2020_multiperson}. In general terms, top-down approaches have lead to results with better pose precision. However, these approaches are more sensitive to inter-person occlusions and truncation and suffer from a lack of global context as they usually discard this information and focus individually on each person in the scene. To counter these effects, \cite{HMOR2020} proposes a novel hierarchical supervision by designing an \ti{integrated top-down} model by capturing the relationships of depth and angles at instance (person), body parts and joints levels. Going even further, Cheng \ti{et al.}~\cite{TDBU_cheng_2021_CVPR} propose an integrated top-down bottom-up model which integrates estimations from both types of approaches in a learning-driven fashion, leading to very interesting results. However, they additionally use temporal information from video which escapes the scope of this paper. Bottom-down approaches, in contrast, are able to consider multiple persons in the image simultaneously and, thus, are more robust to occlusions and truncation but suffer scale variations and the pose estimation accuracy is compromised. Example of bottom up approaches are~\cite{mehta2017vnect,singleshot,mehta2017monocular,zanfir_multipeople_nips18,xnect_mehta_2020,smap_eccv2020,ROMP,BMP_2021_CVPR}. \vspace{-0.3cm} \subsubsection{Human-Human Interaction and Context.} Though the idea of using human-human interactions information and scene context to improve 3D human pose estimation of multiple people is not new and has been proposed several years ago~\cite{andriluka2012human_context}, it was not until recently that the community has focused more in figuring how to better exploit this information. First, Jiang~\et~\cite{jiang2020_multiperson} considered depth ordering-aware and interpenetration losses to exploit spatial relationships between people. In a similar fashion~\cite{HMOR2020} aim to encode interaction information between people as ordinal relations in a hierarchical manner. ~\cite{TDBU_cheng_2021_CVPR} propose a two-person pose discriminator that enforces two-person natural interactions. \cite{Fieraru_2020_CVPR} proposed to exploit interactions involving close contact with a framework based on contact detection over model surface regions. Finally, closest to our approach, Guo~\et~\cite{guo2021pi} propose a pose interacting network (PI-Net) to capture and exploit human-to-human interaction contextual information. \vspace{-0.3cm} \subsubsection{Multi-person with 3D human pose datasets.} Over the years there have appeared different datasets on which works regarding 3D joint estimation rely on. However, less datasets are available for the multi-person counterpart of this problem. ~\cite{singleshot} presents two datasets, MuCo-3DHP for training and MuPoTS-3D,usually used for testing. We find however, that the former is a synthetic dataset compose of individuals performing random actions. While this dataset is useful for learning how to deal with inter-person occlusions, it does not provide real information about human interactions. Therefore, we focus on the use of MuPoTS-3D dataset which contains rich interactions and a mix of indoor/outdoor scenes. CMU Panoptic dataset~\cite{panoptic} contains videos of several people interacting with each other and it has been used a lot by the community. 3DPW~\cite{3DPW} is an interesting dataset capturing people in the wild containing 3D annotations. However, this dataset has at most annotations for only two people. \cite{fabbri2018learning} introduce a systentic dataset based on GTA game, as it is very cheap to capture 3D human pose information in this manner. Although, this dataset presents several people in each scene, the pose variaty is not large enough as most people are only walking most of the time. In contrast, \cite{zhu_2020_eccv_nba} present a dataset also captured from a videogame (NBA2K19) but containing 1000 varing poses over 28 different characters. Other real multi-person dataset for 3D human pose estimation are~\cite{belagian14_3dpictorial,marconi_dataset_2015}, however, these are small having only few examples and usually used as test datasets. \vspace{-0.3cm} \subsubsection{Permutation invariant models} In our work we aim at modeling the interaction between people present in the scene. In problems where the order should not matter, typically sets are used. Therefore, we aim at modeling the interaction of a group of people in a scene viewed as a set. \cite{santoro2017simple} propose the relational network a simple architecture that sum-pools all pairwise interactions of elements in a given set. However, we want to model higher-order interactions. ~\cite{ma2018attend} use the Transformer to model interactions between the objects in a video. They use mean-pooling to obtain aggregated features, however, interaction information maybe loss in the mean-pooling. More suited to our problem, we choose~\cite{set_transformer_lee2019} as our base architecture. \section{Method}\label{sec:method} The idea of our method is to implicitly capture the interaction information between all human body poses in a particular scene in the form of an \textit{interaction-based embedding} and use it to refine an initial set of 3D pose estimations. The main insight is that people present in a scene are usually involved in some kind of interaction between them and that constrains the range of possible poses. Thus, learning these correlations is essential to improve initial noisy estimations. Inspired by the effectiveness of Transformers~\cite{attention_is_all_2017} to capture correlations, we use a variation of them called the Set Transformer~\cite{set_transformer_lee2019} which is not affected by the input order. We introduce it later in sec.~\ref{subsec:set_transformer}. In short, we obtain a rich information, permutation-invariant interaction embedding that captures all human-to-human interactions in the scene and use it to improve multi-people 3D pose estimation. \subsection{Problem formulation} \label{subsec:formulation} Let an input RGB image ${\bf I} \in \mathbb{R}^{H \times W \times 3} $ with $N$ people interacting in the same scene and ${\posevect}^{1:N}$ to be the set of 3D joints, corresponding to each person, where $\posevect^{n} \in \jointsDims$ and $J$ is the number of estimated joints obtained from an initial estimation using an off-the-shelf 3D pose estimator, such as~\cite{Moon_2019_ICCV_3DMPPE}. All the $N$ poses are assumed to be represented in absolute camera coordinates. Given the previous definitions, our goal is to improve the initial pose estimations~$\posevect$ taking into account the pose of other people present in the same scene. These initial estimations could be wrong as they are affected by truncation, inter-person occlusion, self occlusion and scale/depth ambiguity. Thus, we have the following relation: \begin{equation} \posevectRef^{1:N}=\ourNet(\posevect^{1:N}), \label{eq:problem_form} \end{equation} where $\posevectRef$ refers to the set of refined poses that considers the interaction information. $\ourNet$ is a network capable of extracting the interaction information of the input poses~$\posevect$ (which we call the interaction embedding) and refine them. To do this, we divide the problem into two parts: (1) obtaining an embedding capable of capturing the interactions of the scene and, (2) using it to refine the initial poses. The interaction-based embedding~$\featureVect$ is a $d$-dimensional vector embedding, being this dimension an hyperparameter of our model. The embedding~$\featureVect$ globally captures the interactions between the people in a scene. It is obtained via the Set Transformer and used to improve the initial pose estimates. This interaction-based embedding is learned from the initial estimations~$\posevect$ which are not perfect but provide useful information about the relationship between people and their joints: \begin{equation} \featureVect =\featureNet(\posevect^{1:N}), \label{eq:feature} \end{equation} where $\featureVect$ is the the interaction-based embedding and $\featureNet$ is the Set Transformer described in the next section. Ideally, we are looking for a function $\featureNet$ that is able to capture the interaction-based embedding regardless the input order and the number of people present in the scene. Once we have this embedding, we want to use it to refine our initial 3D human pose estimations by means of a function~$\rfineNet$ such as: \begin{equation} \posevectRef^{1:N}=\rfineNet(\featureVect,\posevect^{1:N}), \label{eq:goal} \end{equation} where $\posevectRef^n \in \jointsDims$ denotes the pose of the $n$-th person that was improved with the captured information of the interaction of poses in the scene and~$\rfineNet$ is our model described in more detail in Sec.~\ref{subsec:model} and depicted in Figure~\ref{fig:model}. \subsection{Computing interacion embeddings with Set Transformers} \label{subsec:set_transformer} As it was stated before, our interaction-based embedding~$\featureVect$ should comply with two key requirements to model the interactions information: (1) be independent of the order we input each person's body joints and (2) be able to process input scenes containing any number of people. Requirement (1) comes from the fact that we do not want the input order to affect the pose refinement. We only want information regarding interaction between body poses to influence this refinement. Both requirements are not easily satisfied by classical feed-forward neural networks and recursive neural networks (RNNs) are sensitive to input order~\cite{vinyals2015order}. Recently, Lee~\et~\cite{set_transformer_lee2019} proposed a neural network architecture that fulfils both requirements. Thus, to get the desired interaction-based embedding, we use an attention-based permutation-invariant neural network, namely, a Set Transformer~\cite{set_transformer_lee2019}. The Set Transformer uses self-attention to process every element from the set of inputs which allows the model to naturally encode pairwise or higher-order interactions between input elements. In this manner, we are able to attend to any of the people's input poses and obtain a rich permutation-invariant embedding that captures the interaction in the scene. We then use this feature to guide the pose refinement process. The Set Transformer is based on two key components: (1) an attention-based neural network that is designed to process elements in a set and (2) a parameterized aggregating (pooling) function. This aggregating function is also attention-based and, therefore, it is naturally designed to learn relevant aggregation parameters. In our context, we treat all the initial pose estimations~$\posevect^{1:N}$ as a set (b in Figure~\ref{fig:model}). This attention-based neural network (see SAB bellow) attends to each person's joints and generates an embedding for each person. This alone captures the interaction information for each person in separate embeddings. However, we want an embedding that is capable of giving a summary of all the interactions of all involved people. This is where (2) comes handy, aggregating all these individual embeddings in a learned fashion to provide our interaction-based embedding~$\featureVect$. The primary building block of the Set Transformer is the Set Attention Block (SAB) module. This module uses self-attention to concurrently encode the input set. This gives the Set Transformer the ability to compute pairwise as well as higher-order interactions among instances during the encoding process. The SAB is built by a Multihead Attention Block (MAB) which is an adaptation of the encoder block of the Transformer~\cite{attention_is_all_2017} but without positional encoding and without dropout. This is an important feature to make~$\featureVect$ permutation-invariant. This block is defined as follows. Given matrices $\vec{X}, \vec{Y} \in \reals^{l\times m}$ representing two sets with $l$ elements with dimension $m$, the Multihead Attention Block (MAB) with parameters $\omega$ is defined as: \begin{equation} \textrm{MAB}(\vec{X}, \vec{Y}) = \textrm{LayerNorm}(\vec{H} + \textrm{rFF}(\vec{H})), \label{eq:MAB} \end{equation} where: \begin{equation} \vec{H} = \textrm{LayerNorm}(\vec{X} + \textrm{MHA}(\vec{X},\vec{Y},\vec{Y};\omega)), \label{eq:MAB_h} \end{equation} with \textrm{MHA}$(q,k,v)$ a multi-head attention with query $q$, key $k$ and value $v$ introduced in~\cite{attention_is_all_2017}. \textrm{rFF} is any row-wise feedforward layer (i.e., it processes each instance independently and identically). Using the $\textrm{MAB}$, the SAB can be defined as: \begin{equation} \textrm{SAB}(\vec{X}) := \textrm{MAB}(\vec{X}, \vec{X}), \label{eq:SAB} \end{equation} where, in our context, $\vec{X}$ is composed by the set of initial pose estimations~$\posevect^{1:N}$ with dimensions $l$ equals to the number of people in the scene and $m=3\cdot J$. Therefore, we would have the following relation $\vec{X} = \{\posevect^{1:N}\}$. Since the output of SAB contains information about pairwise interactions among the elements in the input set $\vec{X}$, we can stack multiple SABs to encode higher order interactions. To complete the permutation-invariant architecture, a Pooling by Multihead Attention (PMA) operation is used in order to aggregate the features obtained by the SAB. PMA aggregates the features by applying multi-head attention on a learnable set of $k$ seed vectors $\vec{S} \in \reals^{k \times d}$. In our case, $k=1$, as we only have one embedding to represent the whole scene. Let $\vec{Z} \in \reals^{l \times d}$ be a set of features generated by the encoder (recall that $d$ is also the dimension of $\featureVect$), then, PMA with $k$ seed vectors is defined as: \begin{equation} \textrm{PMA}_k(\vec{Z}) = \textrm{MAB}(\vec{S},\textrm{rFF}(\vec{Z})), \label{eq:PMA} \end{equation} Finally, the output of the \textrm{PMA} block is the desired interaction-based embedding. In our case, under the context of the Set Transformer, our embedding is defined in the following manner: \begin{equation} \featureVect = \textrm{PMA}_1(\textrm{SAB}(\posevect^{1:N}))\;. \label{eq:embedding_pma} \end{equation} It is worth underscoring that here the $\textrm{SAB}$ module can be seamlessly replaced by a stack of $\textrm{SAB}$ modules in order to capture higher than pairwise interactions. \subsection{Interaction-based pose refinement} \label{subsec:model} Once we have the features $\featureVect$, we use them to refine the initial 3D human pose estimations. To do this, we employ a simple MLP-based network that has as input the features $\featureVect$ concatenated with a projection of each person's joints into a $d$-dimensional vector and outputs the change needed to correct each of the initial joints locations in 3D space. Formally, our goal is to find a vector ($\diffVect$) containing all the correction values that added to the initial pose will result into better joints locations. Where the correction vector is defined as $\diffVect^{1:N}=\rfineNet'(\featureVect,\posevect^{1:N})$. Adding this vector to our initial estimations and taking into account Eq.~(\ref{eq:feature}), we now can compute the refined joints by: \begin{equation} \posevectRef^{1:N}=\posevect^{1:N} + \rfineNet'(\featureVect,\posevect^{1:N})\;, \label{eq:refine_net} \end{equation} where $\featureNet$ is the Set Transformer and $\rfineNet'$ is our MPL-based network in charge of decoding the interaction-based embedding and integrating it to the initial estimation to refine them. An overview of our model can be seen in Fig.~\ref{fig:model}. In order to guide the learning process, we optimize the whole network parameters including the ones coming from the Set Transformer by minimizing an $L_2$ loss over the final refined 3D joints and the ground truth joints: \begin{equation} L(\posevect^{1:N})=\frac{1}{N}\sum_{i=1}^{N}||\posevectRef^i - \posevect_{GT}^i||^2. \label{eq:refine_net2} \end{equation} where $\posevect_{GT}$ denotes the 3D human pose ground truth. For more details of the architecture, please refer to the supplementary material of this paper. \section{Experiments}\label{sec:experiments} \subsection{Datasets} \label{sec:datasets} \subsubsection{MuPoTS-3D.} Introduced by Mehta \textit{et al.}~\cite{singleshot} MuPoTS-3D is presented and used as a test set. Along with this dataset, a training set, MuCo-3DHP, was also introduced. MuCo-3DHP is a composite dataset which merges randomly sampled 3D poses from single-person 3D human pose dataset MPI-INF-3DHP~\cite{MPI-INF-3DHP}, making it a synthetic multi-person dataset. MuPoTS-3D is a markerless motion captured multi-person dataset which includes both indoor and outdoor scenes. While MuCo-3DHP dataset has been typically used for training and MuPoTS-3D dataset, for testing models, we argue that due to its synthetic nature, we cannot use MuCo-3DHP dataset to learn interactions between people as it contains no real information about multiple people in a scene, it is merely a composition of random single-person 3D human poses. Therefore, we discard the use of this dataset and focus on MuPoTS-3D. Due to the lack of large scale real multi-person 3D human pose datasets with rich interactions between people, we use MuPoTS-3D dataset as both train and test set. In order to evaluate our model in a fair manner, we resource to k-fold cross-validation dividing the dataset into 10 folds where each fold contains 10\% of the data, yielding to roughly 800 images per fold. \vspace{-10pt} \subsubsection{Panoptic.} Introduced by Joo \ti{et al.}~\cite{panoptic}, CMU Panoptic is a large-scale multi-person dataset that contains various indoor social activities, captured by multiple cameras. Following [41], we choose two cameras (16 and 30), 9600 images from four activities (Haggling, Mafia, Ultimatum, Pizza) as our test set, and 16k images from different sequences as our training set. \vspace{-10pt} \subsubsection{NBA2K dataset.} This dataset was introduced by~\cite{zhu_2020_eccv_nba}, it consists of body mesh data for several NBA players, each in around 1000 widely varying poses. For each mesh the authors of the paper also provide its 3D pose and the corresponding RGB images. The data was collected by playing the NBA2K19 game using a specialized software. Originally, the dataset consists of images of scenes with at most 10 people playing basketball. Each of this images uses the same player character to represent all the people in a given scene. In total, there are 28 players that compose the dataset and around 54 images per player, making up a total of 1500 hi-resolution images. In total, 20 player images are used for training, 4 for validation and 4 for testing. Given that there is a good amount of players in each image and that they are hi-resolution images, we augment the train split by making crops in the original images by making each person in the scene the center of the crop and eliminating all the 3D human pose ground truth of all people that are left out of the scene. By augmenting the data we get 16,092 images for training, 240 for validation and 240 for testing. \subsection{Evaluation Metrics.} \subsubsection{MPJPE.} MPJPE measures the accuracy of the 3D root-relative pose. It calculates the Euclidean distance between the predicted and the ground-truth joint locations averaged over all joints. We report results with and without rigid alignment or procrusters analisys (PA). \subsubsection{3DPCK.} The 3DPCK metric, introduced by~\cite{mehta_monocular_2016} as an alternative to MPJPE, is the percentage of correct keypoints. A keypoint is declared correct if the Euclidean distance between predicted and ground-truth coordinates is smaller than a threshold (15cm in our experiments). \subsection{Comparison with state-of-the-art methods} \subsubsection{MuPoTS-3D.} To compare our method in this dataset against the state-of-the-art (SOTA) we use the three standard protocols related to 3DPCK (from now on refered to as PCK). PCK\textsubscript{rel} and AUC\textsubscript{rel} used to evaluate root-relative 3D poses (after root alignment). Additionally, PCK\textsubscript{abs}, used to evaluate absolute camera-centered coordinates of 3D poses. The quantitative results for this dataset are reported in Table~\ref{tab:mupots}. Here we present a direct comparison with the method that is closest to ours, PI-Net~\cite{guo2021pi} and show other SOTA methods that also deal with the multi-person 3D pose estimation task. Note that these latter are presented as mere reference as they use different datasets for training. However, they compare with the same dataset. Note that we train and test with MuPoTS due to the reasons explained in Sec.~\ref{sec:datasets}. In Table~\ref{tab:mupots}, we first show results of the method used to initialize both PI-Net and our model. We present, two rows referencing PI-Net. The first one, shows the results when training the model with MuCo dataset, as reported in their work. For a fair comparison, we fine-tune the model (second PI-Net row). As it can be seen, our method shows a 3\% improvement over this method when estimating the root-relative pose, 2.2 for AUC\textsubscript{rel} for all people and 2.1 for only matched people. Also, it is worth noticing that we remarkably outperform RootNet~\cite{Moon_2019_ICCV_3DMPPE}, the baseline we use for initialization, in all metrics. Comparing to the rest of the methods, our model outperforms the best PCK\textsubscript{rel} metric from HDNet by 3.3, the best AUC\textsubscript{rel} from HMOR by 2.6, and the best PCK\textsubscript{abs} from HMOR. \input{table_mupots_results} \subsubsection{CMU Panoptic.} The results for the CMU Panoptic dataset are shown in Table~\ref{tab:panoptic}. Following previous works~\cite{zanfir_cvpr_2018_multiple,zanfir_multipeople_nips18}, we evaluate our method under MPJPE after root alignment and after Procrustes alignment (MPJPE-PA). The dataset presents a challenging scenario as the majority of images contain several people at a time in a closed environment, thus, severely affected by the occlusion problem. Our method successfully reduces the interference of occlusion and improves by a very large amount the initial estimation, by 72.5 mm (Ours(1)) accounting for 45.8\% relative improvement and 34.2 mm. (31.1\% relative improvement, with Ours(2)). For qualitative comparisons in the Panoptic dataset, please refer to the supplementary material. In Table~\ref{tab:panoptic} we divide the methods into two categories: joint refinement and end-to-end. We refer as end-to-end those methods that estimate 3D joints directly from an image and as joint refinement those that improve over an initial estimation. We show only comparative results with other type of methods (end-to-end). See how we make significant improvements over the methods used for initial estimation and Pi-Net. \input{table_panoptic} \subsubsection{NBA2K dataset.} For evaluating over the NBA2K dataset we use both MPJPE and 3DPCK metrics. The results for the MPJPE metric are shown in Table~\ref{tab:nba}. It can be seen that our method outperforms the baseline (PI-Net) which we fine-tune with this dataset and the initial method. The results with the 3DPCK metric are shown in Table~\ref{tab:nba_pck}. Also here, we can see and important improvement over the other methods: 2.6 PCK\textsubscript{rel} w.r.t. the baseline and 6,1\% more over the initial estimation. See how both methods that use interaction information from the scene are able to improve the results over the initial estimations. Moreover, our method shows to be superior than the baseline at capturing interactions and refining the 3D pose of multiple people. This are particularly interesting results as the dataset contains several people in each scene with high levels of interaction. \input{table_nba} \input{table_NBA_PCK} \input{rr_figure04_exp} \subsection{Ablation Study} Table~\ref{tab:ablation} shows how the level at which we enforce the interaction to be learned in our methods affects the performance with respect to the initial estimations. We define three different levels of interaction: (1) no interaction, (2) scene interaction, and (3) people interaction, the latter corresponds to our final method. For all the cases we use the same Set-Transformer architecture. However, we change the interaction levels by changing what we input to our method. To eliminate learning interactions, we do not input a set of body poses but each person's pose individually. In this manner, it is impossible for the model to build an interaction-based embedding. At most, the model is restricted to capture self-joint interactions. To enforce learning what we refer to as \ti{scene interaction}, we make each joint in the scene a set by itself. Having instead the joints and not the whole person as sets, we enforce learning a representation that can learn interaction between joints but without the notion of knowing which joint corresponds to each person. Thus, loosing the sense of person as an entity. The results from Table~\ref{tab:ablation} show that our method based on people interaction is clearly superior to other levels of interaction. This is reported in both MPJPE and 3DPCK metrics. \input{table_ablation} \subsection{Effects of the refinement over initial estimations} In Figure~\ref{fig:explain}, we show how our model acts over the initial estimations in order to improve the pose. As observed in the results presented above, our method is able to improve both the absolute and the root-relative pose. We show the effect of both types of improvements. In the two middle columns, we can see the initial estimation and the refined poses from a slightly rotated camera view and, also, a bird-view. In the first column, in the bottom, we have the ground truth poses from a bird-view. From these views, we can appreciate the interactions between person 1 (P\textsubscript{1}) and person 2 (P\textsubscript{2}). The initial estimation does not take into account interactions, therefore, it does not know the relationship between two close bodies and, thus, that they should be further away without overlapping. Our model is able to capture these interactions and, therefore, estimate a more realistic scene. The rightmost picture shows the initial, refined and ground truth root-relative poses of person 1. See how our estimations correct the initial the joint positions getting closer to the ground truth (highlighted in red arrows). \subsection{Qualitative Results} We present qualitative results in Figure~\ref{fig:qualitative}. Here, we show two cases we our method successfully refines the initial pose estimations. Our final result is depicted in strong colors while the initial estimation has a degree of transparency, we also include the ground truth as a reference. As it can be seen, our method is able to counter the effect of inter-person occlusions, exactly where the method used for initialization fails. As depicted in the right image from Figure~\ref{fig:qualitative}, the improvement is more notorious as the occlusion worsens. This is reasonable because it is where the initial method~\cite{Moon_2019_ICCV_3DMPPE} fails the most. In these cases it is very difficult to output a perfect pose due to a bad initialization, nevertheless, our method improves substantially given a very noisy initial estimation. Moreover, as our reasoning is done solely in the 3D coordinate space and not at image pixel level is that we can face this type of occlusions. \section{Conclusions}\label{sec:conclusion} In this paper we have proposed a novel algorithm to tackle the challenging problem of multi-person 3D pose estimation from one single image. Building on the Set Transformers paradigm, we have introduced a holistic encoding of the entire scene, given an initial set of potentially noisy input 3D body poses. This encoding captures multi-person relationships, is permutation invariant and can take an arbitrarily large number of inputs. It is used to refine the initial poses in a residual manner. A thorough evaluation shows that our approach is able to provide competitive results, even when initialized with highly perturbed 3D poses far from the ground truth. Additionally, the proposed module is computationally efficient and can be used as a post-processing step for any 3D pose detector in multi-people scenes. \section{More Qualitative results} \input{supp_fig_qualitatives} \input{supp_fig_qualitative_inter} \input{supp_fig_qualitative_inter} Estimating 3D human pose from RGB images \section*{Acknowledgments} This work is supported by the Spanish government with the projects MoHuCo PID2020-120049RB-I00 and the María de Maeztu Seal of Excellence MDM-2016- 0656. We also thank Nvidia for hardware donation under the Academic Hardware Grant Program. \clearpage \bibliographystyle{splncs04}
{'timestamp': '2022-04-12T02:34:07', 'yymm': '2204', 'arxiv_id': '2204.04913', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04913'}
arxiv
\section{Introduction} With the evolution of multimedia technology, the next-generation display technologies aim at revolutionizing the way of interactions between users and their surrounding environment rather than limiting to flat panels that are just placed in front of users (\textit{i.e.}, mobile phone, computer, \textit{etc.}) \cite{cakmakci2006head,zhan2020augmented}. These technologies, including Virtual Reality (VR), Augmented Reality (AR), and Mixed Reality (MR), \textit{etc.}, have been developing rapidly in recent years. Among them, AR pursues high-quality see-through performance and enriches the real world by superimposing digital contents on it, which is promising to become next-generation mobile platform. With advanced experience, AR shows great potential in several attractive application scenarios, including but not limited to communication, entertainment, health care, education, engineering design, \textit{etc.} \FigMotivationI On account of the complex application scenes, it is important to consider the perceptual Quality of Experience (QoE) of AR, which includes measuring the perceptual quality and better improving the experience of AR. Lately, some works have been presented to study the quality effects of typical degradations that affect digital contents in AR \cite{guo2016subjective,su2019perceptual,alexiou2018point,zhang2014subjective,zerman2019subjective}. These studies have performed subjective/objective tests on screen displays showing videos of 3D meshes or point clouds with various distortions. Moreover, with the development of Head Mounted Displays (HMDs) for AR applications, some studies have considered evaluating the QoE of 3D objects using these devices. For instance, Alexiou \textit{et al.} \cite{alexiou2017towards} have studied geometry degradations of point clouds and have conducted a subjective quality assessment study in a MR HMD system. Zhang \textit{et al.} \cite{zhang2018towards} have conducted a study towards the QoE model of AR applications using Microsoft HoloLens, which mainly focused on the perceptual factors related to the usability of AR systems. Gutierrez \textit{et al.} \cite{gutierrez2020quality} have proposed several guidelines and recommendations for subjective testing of QoE in AR scenarios. However, all these studies only focus on the degradations of geometry and texture of 3D meshes and point clouds inside AR, \textit{e.g.,} noise, compression \textit{etc.}, their see-through scenes are either blank or simple texture, or even without see-through scenes (opaque images/objects). The studies discussing the relationship between augmented view and see-through view are lacking. To address the above issues, in this paper, we consider AR technology as the \textit{superimposition} of digital contents and see-through contents, and introduce \textit{\textbf{visual confusion}} \cite{woods2010extended,peli2017multiplexing} as its basic theory. Fig. \ref{fig:1_visual_conf} demonstrates the concept of the visual confusion in AR. ``B'', ``A'' and ``S'' in Fig. \ref{fig:1_visual_conf} represent background (BG) view, augmented view and superimposed view, respectively. If both ``B'' and ``A'' are views with blank/simple textures, there is nothing important in the superimposed view. If one of ``B'' or ``A'' has a complex texture, but another view has a simple texture, there is also no confusion in the superimposed view. If both ``B'' and ``A'' have complex textures, visual confusion is introduced. We assume that without introducing specific distortions that has been widely studied in the current QoE studies, visual confusion itself is a type of distortion, and it significantly influences the AR QoE. Thus, we argue that it is important to study the assessment of the visual confusion towards better improving the QoE of AR. Note that it does not mean that no confusion is better than with confusion, since the objective of AR is promoting the fusion between virtual world and real world. Instead, the balance between them is more important. To this end, in this work, we first propose a more general problem, which is evaluating the perceptual quality of visual confusion. A ConFusing Image Quality Assessment (CFIQA) dataset is established to make up for the absence of relevant research. Specifically, we first collect 600 reference images and mix them in pairs, which generates 300 distorted images. We then design and conduct a comprehensive subjective quality assessment experiment among 17 subjects, which produces 600 mean opinion scores (MOSs), \textit{i.e.}, for each distorted image, two MOSs are obtained for two references respectively. The distorted and reference images, as well as subjective quality ratings together constitute the ConFusing Image Quality Assessment (CFIQA) dataset. Based on the dataset, we analyze several visual characteristics of visual confusion and propose an attention based deep feature fusion method towards better evaluating the quality of confusing images. A specialized learning strategy for this purpose is proposed. We then compare the proposed method with several state-of-the-art IQA metrics and conduct a benchmark study. Moreover, considering the field-of-view (FOV) of the AR image and the background image are usually different in real application scenarios, we further establish an ARIQA dataset for better understanding the perception of visual confusion in real world. The ARIQA dataset is comprised of 20 raw AR images, 20 background images, and 560 distorted versions produced from them, each of which is quality-rated by 23 subjects. Besides the visual confusion distortion as mentioned above, we further introduce three types of distortions: JPEG compression, image scaling and contrast adjustment to AR contents. Four levels of the visual confusion distortion are applied to mix the AR images and the background images. Two levels of other types of distortions are applied to the AR contents. To better simulate the real AR scenarios and control the experiment environment, the ARIQA experiment is conducted in VR environment. We also design three types of objective AR-IQA models, which can be differentiated according to the inputs of the classical IQA models, to study whether and how the visual confusion should be considered when designing corresponding IQA metrics. An ARIQA model is finally proposed to better evaluate the perceptual quality of AR images. Overall, the main contributions of this paper are summarized as follows. 1) We discuss the visual confusion theory of AR and argue that evaluating the visual confusion is one of the most important problem of evaluating the QoE of AR. 2) We establish the first ConFusing IQA (CFIQA) dataset, which can facilitate further objective visual confusion assessment studies. 3) To better simulate the real application scenarios, we establish an ARIQA dataset and conduct a subjective quality assessment experiment in VR environment. 4) Two objective model evaluation studies are conducted on the two datasets, respectively. 5) A CFIQA model and an ARIQA model are proposed for better evaluating the perceptual quality in these two application scenarios. Our data collection software, datasets, benchmark studies, as well as objective metrics will be released to facilitate future research. We hope this study will motivate other researchers to consider both the see-through view and the augmented view when conducting AR QoE studies. The rest of the paper is organized as follows. In Section \ref{sec:II}, we give an overview of the related backgrounds and works. Section \ref{sec:III} describes the construction process of CFIQA dataset. The proposed CFIQA model is then introduced in Section \ref{sec:IV}. The experimental results of objective CFIQA evaluation are given in Section \ref{sec:V}. Then an extended subjective \& objective ARIQA study is presented in Section \ref{sec:VI}. Section \ref{sec:VII} concludes the paper and discusses several future issues. \vspace{-5pt} \section{Related Work \label{sec:II}} \vspace{-2pt} In this section, we shortly review two topics related to this work, including Augmented Reality and its perceptual theory basis, as well as image quality assessment. \vspace{-6pt} \subsection{Augmented Reality and Visual Confusion Basis \label{sec:2.1_AR}} \vspace{-2pt} This work mainly concerns head-mounted AR application rather than mobile phone based AR application. Considering rendering methods, there are two main aspects of works in the field of AR visualization, including 2D displaying and 3D rendering. Considering the theory basis of AR devices, there are two vision theories underlying the AR technologies, including binocular visual confusion and monocular visual confusion. We discuss the relationship between these four aspects and this work as follows. \textit{\textbf{2D displaying.}} The most basic application of AR is displaying digital contents in a 2D virtual plane \cite{ahn2018real}. These digital contents include images, videos, texts, shapes, and even 3D objects in 2D format, \textit{etc.} To display 2D digital contents, a real world plane is needed to attach the virtual plane. The real world plane and virtual plane are usually in one same \textit{Vieth–Müller} circle (\textit{a.k.a,} isovergence circle), which may cause visual confusion. This situation is the main consideration of this paper. \textit{\textbf{3D rendering.}} In contrast to 2D displaying, 3D rendering aims at providing 3D depth cues of virtual objects (note that this depth cue is a little bit different from the depth of the above mentioned virtual plane) \cite{kalkofen2013adaptive}. Although the 3D depth cues will cause the real world scenes and virtual objects to be located in different \textit{Vieth–Müller} circles, the visual confusion basis still exists, which makes this situation more complex (see Section \ref{sec:VII} for more details). \textit{\textbf{Binocular visual confusion.}} The superimposition of two views of the visual scene (\textit{i.e.}, two images in this paper) allows people to see two different things in one direction, which may result in visual confusion \cite{apfelbaum2015tunnel}. The visual confusion caused by two views superimposed binocularly (within two eye respectively) is \textit{binocular} visual confusion, which may lead to binocular rivalry \cite{blake2002visual,peli2017multiplexing}. Previous AR devices such as Google Glass \cite{googleglass}, are mainly constructed based on binocular visual confusion to avoid the barrage produced by AR devices. However, the binocular rivalry caused by binocular visual confusion may strongly affect the QoE. \textit{\textbf{Monocular visual confusion.}} The visual confusion caused by two views superimposed monocularly (within one eye) is \textit{monocular} visual confusion \cite{peli2017multiplexing}, which may lead to monocular rivalry \cite{blake2002visual,peli2017multiplexing}. Since monocular rivalry is much weaker than binocular rivalry \cite{o2009monocular} and it possibly occurs only with extended attention \cite{peli2017multiplexing}, most of recent AR technologies are built based on monocular visual confusion to avoid occluding, such as Microsoft HoloLens \cite{hololens}, Magic Leap \cite{magicleap}, Epson AR \cite{epson}, \textit{etc.} However, the QoE of monocular visual confusion still lacks thorough discussion, which is mainly considered in this paper. \FigDatasetI \vspace{-6pt} \subsection{Image Quality Assessment} \vspace{-1pt} Many IQA methods have been proposed in the past decades \cite{wang2015patch,yu2019predicting}, which can be roughly grouped into three categories, including full reference (FR) IQA, reduced reference (RR) IQA, and no reference (NR) IQA. Considering the possible application scene (where the digital contents and real environment scene can be easily obtained), in this paper, we mainly focus on the FR-IQA metric. \textit{\textbf{Classical IQA index.}} In terms of FR IQA methods, many classical metrics have been proposed and widely used, including mean squared error (MSE), peak signal-to-noise ratio (PSNR), structural similarity (SSIM) index, feature similarity (FSIM) index, \textit{etc.} Regarding NR IQA indexes, there are also many related works such as natural image quality evaluator (NIQE) \cite{mittal2012making}, blind quality assessment based on pseudo-reference image (BPRI) \cite{min2017blind}, and NR free-energy based robust metric (NFERM) \cite{gu2014using}, \textit{etc.} \textit{\textbf{Learnable IQA.}} Driven by the rapid development of deep neural networks recently, some learning based IQA algorithms have been proposed. Kang \textit{et al.} \cite{kang2015simultaneous} proposed to use multi-task convolutional neural networks to evaluate the image quality and use $32 \times 32$ patches for training. Bosse \textit{et al.} \cite{bosse2017deep} proposed both FR and NR IQA metrics by joint learning of local quality and local weights. Some studies located specific distortions by using convolutional sparse coding and then evaluated the image quality \cite{yuan2015image}. Recently, some studies also demonstrated the effectiveness of pre-trained deep neural network (DNN) features on calculating visual similarity \cite{johnson2016perceptual,zhang2018unreasonable}. \textit{\textbf{AR/VR IQA.}} As discussed above, most previous AR/VR IQA studies have focused on the degradations of geometry and texture of 3D meshes and point clouds inside AR/VR. Unlike AR, many works towards VR IQA have also studied omnidirectional (\textit{a.k.a, equirectangular}) images' quality \cite{duan2018perceptual,zhou2021no}, since the format of these images is different with traditional images. In this paper, we propose that in AR technology, confusing image is its special ``image format", and confusing image quality assessment is equally important with 3D meshes or point clouds quality assessment, since it is not only related to 2D displaying but also associated with 3D rendering effects. Moreover, it significantly influences the QoE of AR. \FigDatasetII \FigDatasetIII \FigDatasetIV \section{Study I: Subjective CFIQA \label{sec:III}} \subsection{Confusing Image Collection} To address the problem of subjective confusing IQA data absence, we first build a novel ConFusing Image Quality Assessment (CFIQA) dataset. Since this paper is the first work to study confusing IQA, we consider the visual confusion as the only distortion type in this section to study whether and how the visual confusion can influence the perceptual quality. We collect 600 images from Pascal VOC dataset \cite{everingham2010pascal} as reference images and split them into two groups. Then we randomly select two reference images from these two groups and mixed them in pair with a blending parameter $\lambda$ to generate a distorted image. This can be formulated as: \begin{equation} I_D = \lambda \circ I_{R_1} + (1-\lambda) \circ I_{R_2}~, \end{equation} where $I_{R_1}$ is the reference image from the first group, $I_{R_2}$ is the reference image from the second group, $\lambda \in [0,1]$ represents the degradation value of mixing, $I_D$ denotes the generated distorted image. All reference images are resized to the size of $512 \times 512$ and then superimposed. A total of 300 distorted images are finally generated. Obviously, $\lambda$ value near 0 or 1 will cause one image to be unnoticeable while closer to the center (\textit{i.e.,} 0.5) will cause near confusion for both views. Since visual confusion is the main consideration in this section, it is unreasonable to randomly sample $\lambda$ from $[0,1]$. In this work, to make the $\lambda$ value to be closer to the center values in range $[0,1]$, we sampled $\lambda$ value from a Beta distribution, \textit{i.e.,} $\lambda \sim \mathbf{Beta}(\alpha,\alpha)$. The parameter $\alpha$ is set as 5 in this dataset. Fig. \ref{fig:2_lambda} demonstrates the distribution of $\lambda$ values in our dataset. \vspace{-2pt} \subsection{Subjective Experiment Methodology \label{sec:subjective_I}} \quad\textit{\textbf{Experiment setup.}} A subjective experiment is conducted on the dataset. There are several subjective assessment methodologies recommended by the ITU \cite{series2012methodology}, for instance, single-stimulus (SS), double-stimulus impairment scale (DSIS) and paired comparison (PC). Since the reference images are available, we adopted a paired comparison continuous quality evaluation (PCCQE) strategy to obtain the subjective quality ratings. As shown in Fig. \ref{fig:3_interface}, for each distorted image, we display its two reference images simultaneously and instruct the subjects to give two opinion scores of the perceptual quality of two layer views (\textit{i.e.,} two reference images) in the distorted image, respectively. We suggest the subjects to only view the distorted image in the center, and two reference images are just used to determine the quality of which layer is being given. Two continuous quality rating bars were presented to the subject. The quality bar is labeled with five Likert adjectives: Bad, Poor, Fair, Good and Excellent, allowing subjects to smoothly drag a slider (initially centered) along the continuous quality bar to select their ratings. They are seated at a distance of about 2 feet from the monitor, and this viewing distance is roughly maintained during each session. All images are shown in their raw sizes, \textit{i.e.,} $512 \times 512$ with random sequence during the experiment. \textit{\textbf{Testing procedure.}} As suggested by ITU \cite{series2012methodology}, at least 15 subjects are required to conduct subjective IQA experiment. A total of 17 subjects are recruited to participate in the study. Before participating in the test, each subject read and signed a consent form which explained the human study. All subjects are determined to have normal or corrected-to-normal vision. General information about the study is supplied in printed form to the subjects, along with instructions on how to participate in the task. Each subject then experiences a short training session where 20 confusing images (not included in the formal test) are shown, allowing them to become familiar with the user interface and the general visual confusion distortions which may occur. During the experiment, subjects have enough rest time every 10 minutes to avoid fatigue. \FigMethodI \vspace{-10pt} \subsection{Subjective Data Processing and Analysis \label{sec:analysis}} We follow the suggestions given in \cite{series2012methodology} to conduct the outlier detection and subject rejection. Specifically, the raw score for an image is considered to be an outlier if it is outside 2 standard deviations (stds) about the mean score of that image for the Gaussian case or outside $\sqrt{20}$ stds for the non-Gaussian case. A subject is removed if more than 5\% of his/her evaluations are outliers. As a result, only 1 subject is rejected, and each image is rated by 16 valid subjects. Among all scores given by the remaining valid subjects, about 2.77\% of the total subjective evaluations are identified as outliers and are subsequently removed. For the remaining 16 valid subjects, we convert the raw ratings into Z-scores, which are then linearly scaled to the range $[0, 100]$ and averaged over subjects to obtain the final mean opinion scores (MOSs) as follows: \vspace{-5pt} \begin{equation} z_{ij}=\frac{m_{ij}-\mu_{i}}{\sigma_{i}},\quad z_{ij}'=\frac{100(z_{ij}+3)}{6}, \end{equation} \vspace{-5pt} \begin{equation} MOS_{j}=\frac{1}{N}\sum_{i=1}^{N}z_{ij}', \end{equation} where $m_{ij}$ is the raw rating given by the $i$-th subject to the $j$-th image, $\mu_{i}$ is the mean rating given by subject $i$, $\sigma_{i}$ is the standard deviation, and $N$ is the total number of subjects. Fig. \ref{fig:4_subjective} plots the histograms of MOSs over the entire database as well as within different $\lambda$ value ranges, showing a wide range of perceptual quality scores. We also plot the Gaussian curve fitting for the histogram. It can be observed that when $\lambda$ is closer to 0.5, the MOSs tend to be more centered (illustrated by the smaller $\sigma$ value), but still have a wide range of perceptual quality scores. Based on the constructed dataset, we further qualitatively analyze the characteristic of the visual confusion. As shown in Fig. \ref{fig:5_example}, we roughly classify the visual confusion into three categories. The first category is ``strong confusion'', which means that the mixing of two reference layers will cause strong confusion and may affect the quality rating of the superimposed image (distorted image). The second category is ``confusion but acceptable'', which represents that the visual confusion caused by the superimposition of two reference layers is acceptable, or uninfluenced, or the perceptual quality is even improved. The third category is ``suppression'', which denotes that in the superimposed image, one reference layer will suppress another reference layer. This results in the situation that the perceptual quality of one layer is much better than another layer. First of all, as a general observation from Fig. \ref{fig:5_example}, we notice that the MOS values (\textit{i.e.,} subjective quality scores) are commonly sorted in descending order as: 1) the activated layer in the ``suppression'' category (\textit{i.e.,} the clearer layer), 2) two image layers in the ``confusion but acceptable'' category, 3) two image layers in the ``strong confusion'' category, and 4) the suppressed layer in the ``suppression'' category (\textit{i.e.,} the fainter layer). Furthermore, with thorough observation, we notice that the saliency relation between two layers of the superimposed image are important to the perceptual quality, which are demonstrated by several IQA metrics in Section \ref{sec:V}. We conclude that without introducing other distortions, visual confusion itself can significantly influence the quality of confusing images. \section{Attention Based Deep Feature Fusion Method \label{sec:IV}} As shown in Fig. \ref{fig:5_example}, the classical SSIM index and FSIM index are inconsistent with human perception in some cases (see Section \ref{sec:V} for more quantitative comparison). From the above analysis, we suppose that the assessment of visual confusion is related to both low-level visual characteristics and high-level visual semantic features, since the visual confusion may disturb semantic information and affect the perceptual quality. This may cause the failure of the classical metrics, since most of them only consider low-level visual features. As discussed in \cite{johnson2016perceptual,zhang2018unreasonable}, deep features also demonstrate great effectiveness as perceptual metrics. Moreover, DNN can extract both low-level and high-level features. Therefore, in this paper, we propose an attention based deep feature fusion metric to measure the visual confusion, which is shown in Fig. \ref{fig:6_model}. \textit{\textbf{Deep feature extraction.}} We first employ several state-of-the-art pre-trained DNNs to extract both low-level and high-level features, which include SqueezeNet \cite{iandola2016squeezenet}, AlexNet \cite{krizhevsky2012imagenet}, VGG Net \cite{simonyan2014very}, and ResNet \cite{he2016deep}. SqueezeNet is an extremely lightweight DNN with comparable performance on classification benchmark. The features from the first $conv$ layer and subsequent ``$fire$'' modules in SqueezeNet are extracted and used. We also use a shallow AlexNet network which may more closely match the architecture of the human visual cortex \cite{yamins2016using}, and we extract the features from the $conv1-conv5$ layers in AlexNet. Furthermore, 5 \textit{conv} layers labeled $conv1\_2$, $conv2\_2$, $conv3\_3/conv3\_4$, $conv4\_3/conv4\_4$, $conv5\_3/conv5\_4$ are extracted from two VGG networks (VGG-16 and VGG-19), respectively. We also compare the correlation between each feature layer and the MOS (see Section \ref{sec:V} for more details), and analyze if the features extracted from different layers would influence the results. Finally, considering the effectiveness of ResNet in a large amount of computer-vision (CV) tasks, we also explore the utility of features extracted by ResNet in this task. Three ResNet architectures including ResNet-18, ResNet-34, as well as ResNet-50 are considered. We use the features extracted from the first $conv$ layer and subsequent ``$BasicBlock$'' or ``$Bottleneck$'' modules for all of these architectures. \textit{\textbf{Computing feature distance.}} As discussed above, for a distorted image $I_D$ and corresponding two reference images $I_{R_1}$, $I_{R_2}$, we extract feature stacks $f_D$, $f_{R_1}$, and $f_{R_2}$ from $L$ layers of a network $\mathcal{F}$, respectively. Then we follow the method in \cite{zhang2018unreasonable} and calculate the feature distance between the distorted image and the reference image by subtracting normalized feature stacks. This can be expressed as: \begin{equation} f^l_{d_i} = \left \|~ f^l_D - f^l_{R_i} ~\right \|^2_2~, \end{equation} where $l \in [1,L]$ represents the $l$-th layer, $i \in \{1,2\}$ denotes the reference category, $f^l_{d_i}$ is the calculated feature distance. \textit{\textbf{Channel attention for learning feature significance.}} Since the significance of each channel of the feature distance vector is uncertain for this task, it is important to learn the weights of the channels for each feature distance vector and re-organize them. We adopt a widely used channel attention \cite{hu2018squeeze} method as shown in Fig. \ref{fig:6_model} to learn and re-organize features. After the channel attention, two down-sampling convolutional layers are followed. The kernel size of all convolutional layers is 1. Through this manipulation, a 2D feature stack $d_i$ which represents the distance map can be obtained for $f_{d_i}$, where $i \in \{1,2\}$. \textit{\textbf{Spatial attention.}} As discussed in Section \ref{sec:analysis}, high-level visual features such as saliency may influence the perceptual quality of visual confusion. Since it is hard to optimize spatial attention with a relatively small dataset, in this work, we calculate spatial attention by a saliency prediction method. A state-of-the-art saliency prediction method \cite{droste2020unified} is used to to calculate the spatial attention map $W_i$ for a reference image $I_{R_i}$. By weighting the distance map $d_i$ with a scaled spatial attention map $W_i$, the final quality score can be predicted as: \begin{equation} s_i = \texttt{Avg}_{_l}(\frac{\sum_{h,w}{W_i^l}_{hw} \odot {d_i^l}_{hw}}{\sum_{h,w}{W_i^l}_{hw}})~. \end{equation} \textit{\textbf{Loss function.}} Different with \cite{zhang2018unreasonable}, which aims at two alternative forced choice (2AFC) test, our work focuses on more general quality assessment task (\textit{i.e.,} mean opinion score (MOS) prediction). Moreover, different from traditional IQA condition, in our dataset, one distorted image corresponds to two reference images. Thus, the loss function needs to be carefully designed. An intuitive loss function is to compare (rank) the perceptual qualities of two layers in the distorted image. Therefore, a \textit{\textbf{ranking loss}} $\mathcal{L}_R$ is adopted to predict the probability that one layer suppress another layer, which is based on the cross-entropy loss function. Although the above ranking loss can predict the relative perceptual quality of two layers in a distorted image, the overall qualities of different images across the whole dataset are not normalized and compared. Therefore, another \textit{\textbf{score regression loss}} $\mathcal{L}_S$ is introduced to regress the probability of the quality being bad or excellent, which is also built based on the cross-entropy loss function. Two linear layers and a sigmoid layer are used to project the predicted value to the ground-truth space. The overall loss function can be formulated as: \begin{equation} \mathcal{L} = \mathcal{L}_{S_1} + \mathcal{L}_{S_2} + \lambda\mathcal{L}_R, \end{equation} where $\lambda$ is empirically set as 2. \textit{\textbf{Edge feature integration.}} The edges of objects can help identify their categories \cite{liu2019richer}. However, when two images are superimposed together, the intersection of the edges of two image layers may strongly influence the perceptual quality. Therefore, we further extract the features from an edge detection model \cite{liu2019richer} and concatenate them with the features extracted from one of the aforementioned classification backbones as an enhanced model, which is named CFIQA+. \TabExperimentI \section{Study II: Objective CFIQA \label{sec:V}} \subsection{Experimental Protocol} \quad\textit{\textbf{Experimental settings.}} As mentioned in Section \ref{sec:IV}, our proposed method needs some samples to train the feature fusion module. Therefore, the CFIQA dataset is split into two parts at a ratio of 1:1, \textit{i.e.}, each part has 150 distorted images and corresponding 300 reference images. A two-fold cross-validation experiment is conducted. The two splits of the dataset are used as the training set and the test set respectively in each cross-validation fold. During training, the feature extraction network is frozen, and we only train the feature fusion part. We use Adam as the optimizer \cite{kingma2014adam}. The network is trained for 100 epoch with a learning rate of 0.0001, and additional 50 epoch with decayed learning rate from 0.0001 to 0. The batch size is set as 10 during training. \textit{\textbf{Traditional evaluation metrics.}} To evaluate the various quality predictors, we use a five-parameter logistic function to fit the quality scores: \begin{equation} Q'=\beta_{1}(\frac{1}{2}-\frac{1}{1+e^{\beta_{2}(Q-\beta_{3})}})+\beta_{4}Q+\beta_{5}, \end{equation} where $Q$ and $Q'$ are the objective and best-fitting quality, $\beta_{i}(i=1,2,3,4,5)$ are the parameters to be fitted during the evaluation. Four evaluation metrics are adopted to measure the consistency between the ground-truth subjective ratings and the fitted quality scores, including Spearman Rank-order Correlation Coefficient (SRCC), Kendall Rank-order Correlation Coefficient (KRCC), Pearson Linear Correlation Coefficient (PLCC), and Root Mean Square Error (RMSE). The evaluation is conducted on the entire database and 2 sub-datasets within different $\lambda$ ranges. Note that evaluating the performance in the range that the $\lambda$ value is near 0.5 is significant, since it is near the essence of visual confusion and is more common in AR applications, while the poor cases in this situation may strongly influence the QoE. However, most FR-IQA metrics cannot perform well in this range, which may limit their practicality on CFIQA. \textit{\textbf{New evaluation methodology.}} As a complementary, the receiver operating characteristic (ROC) analysis methodology \cite{krasula2016accuracy,krasula2017quality} is also adopted for metric evaluation, which is based on two aspects, \textit{i.e.}, \textit{whether two stimuli are qualitatively different and if they are, which of them is of higher quality}. The Fig. 1. in the \textit{supplementary material} illustrates the framework of this evaluation methodology. We first conduct pair-wise comparison for all possible image pairs, and then classify them into pairs with and without significant quality differences. Then the ROC analysis is used to determine whether various objective metrics can discriminate images with and without significant differences, termed ``\textit{Different vs. Similar ROC Analysis}''. Next, the image pairs with significant differences are classified into pairs with positive and negative differences, and the ROC analysis is used to test if various objective metrics can distinguish images with positive and negative differences, termed ``\textit{Better vs. Worse ROC Analysis}''. The area under the ROC curve (AUC) values of two analysis are mainly reported in this paper, of which the higher values indicate better performance. \vspace{-5pt} \subsection{Comparisons with State-of-the-arts} We conduct a large-scale benchmark study based on our dataset to further discuss the perceptual quality of visual confusion. The performance comparison results are shown in Table \ref{tab:1_all}. \textit{\textbf{Classical FR-IQA metrics.}} The first intuitive idea is that if the $\lambda$ value can act as the metric for visual confusion since it is directly related to the generation of distorted images. We test its performance and show the results in Table \ref{tab:1_all}. We also test 16 state-of-the-art classical FR on this dataset, including MSE, PSNR, NQM \cite{damera2000image}, SSIM \cite{wang2004image}, IFC \cite{sheikh2005information}, VIF \cite{sheikh2006image}, IW-MSE \cite{wang2010information}, IW-PSNR \cite{wang2010information}, IW-SSIM \cite{wang2010information}, FSIM \cite{zhang2011fsim}, GSI \cite{liu2011image}, GMSD \cite{xue2013gradient}, GMSM \cite{xue2013gradient}, PAMSE \cite{xue2013perceptual}, LTG \cite{gu2014efficient}, and VSI \cite{zhang2014vsi}. Since visual attention is important in this task as discussed above, we further select 3 widely used and well-performed metrics (SSIM, FSIM, and GMSM), and incorporate saliency weights into the quality pooling as new metrics. The results are denoted as ``+ saliency'' in Table \ref{tab:1_all}. \TabExperimentII \FigNewCriterionI \textit{\textbf{Deep feature based IQA metrics.}} Recently, many works demonstrate the consistence between DNN and human perception \cite{johnson2016perceptual,heusel2017gans,zhang2018unreasonable}. In the benchmark study, we first build several baseline models with several state-of-the-art neural networks, including SqueezeNet \cite{iandola2016squeezenet}, AlexNet \cite{krizhevsky2012imagenet}, VGG (VGG-16 and VGG-19) \cite{simonyan2014very}, and ResNet (ResNet-18, ResNet-34, and ResNet-50) \cite{he2016deep}. These baseline models are constructed by averaging the features of selected layers as mentioned in Section \ref{sec:IV}. Considering the features extracted from the last layer of each ``component'' of these networks may not well reflect the overall performance, in this work, we propose a method to improve the baseline, which is conducted based on VGG-16 (denoted as ``VGG-16 (baseline+)'' in Table \ref{tab:1_all}). We analyze the SRCC between all 30 layers of VGG-16 and the MOSs, then extract 5 most correlated layers and compute their average score as the ``baseline+''. Furthermore, we also compute the predicted score of two widely used metrics based on deep feature fusion \cite{zhang2018unreasonable,ding2020image}, which are denoted as LPIPS and DISTS in Table \ref{tab:1_all}. \vspace{-9pt} \subsection{Performance Analysis} \vspace{-3pt} \quad\textit{\textbf{Results analysis.}} First of all, it is important to analyze the performance of all IQA models within different $\lambda$ ranges. We notice that with $\lambda$ values closer to 0.5 (\textit{i.e.,} the probability of causing strong visual confusion increases), nearly all metrics tend to perform worse. This indicates that the assessment of strong visual confusion is a difficult task for most models. As shown in Table \ref{tab:1_all}, $\lambda$ can perform as the metric for confusion evaluation, and even acts better than MSE and PSNR, though the performance is still limited. Among classical IQA indexes, IW-SSIM and VIF show the top performances, which denotes that visual information weighting possibly helps the assessment of visual confusion. The improvements of introducing saliency into SSIM, FSIM, as well as GMSM demonstrate the importance of visual attention in visual confusion, which is worth further and deeper research. Surprisingly, the baseline deep features show good consistence with human perceiving on the entire dataset, though they are not well performed on either of the two sub-datasets. Unexpectedly, the widely used deep metric LPIPS \cite{zhang2018unreasonable} performs even worse than the baseline methods, which may indicate that visual confusion is a different type of degradation compared to other distortions. Finally, our method gets relative better results and different backbone architectures show different optimization trends, which denotes that the feature extraction network is also important. Future studies on exploring different feature extraction methods are also needed. Fig. \ref{fig:new_evaluation_cfiqa} illustrates the performance evaluated by the new criteria on the CFIQA database. First, we observe that the proposed CFIQA model significantly outperforms other state-of-the-art models on \textit{Different vs. Similar Analysis} and \textit{Better vs. Worse Analysis} by a large margin. Furthermore, we notice the AUC values of the CFIQA metric on the \textit{Better vs. Worse} classification task are higher than the \textit{Different vs. Similar} classification task, which indicates that the \textit{Different vs. Similar} classification is a more hard task and there is still room for improvement in this classification task. \textit{\textbf{Impact of different components.}} We further verify the impact of each component in our method. The analysis is conducted based on VGG-16 and the results are shown in Table \ref{tab:2_ablation}. We first remove all components including channel attention, spatial attention and projection components (two-layer MLP), and only regress the weighting layers for feature fusion. The results shown in the first row in Table \ref{tab:2_ablation} demonstrate that the performance of this method is similar to the baseline in Table \ref{tab:1_all}. Then we compare the impacts of channel attention and spatial attention modules for feature fusion. It can be observed that spatial attention takes the most contribution to the final score and channel attention contributes less. Furthermore, we compare the contributions of two loss functions. It can be observed that ranking loss contributes most for constraining the optimization process. Though contributing less, score regression loss still introduces improvement to the final score. \FigARI \FigARII \vspace{-9pt} \section{Study III: Subjective \& Objective ARIQA \label{sec:VI}} \vspace{-4pt} In the above Study I and Study II, we have discussed a relatively more basic and more general problem, \textit{i.e.}, visual confusion and its influence on the perceptual QoE. As aforementioned, visual confusion has significant influence on the QoE of human vision. However, the situation in the above studies is quite different with the real AR applications, which is mainly attributed to the fact that in actual AR applications, the FOV of the AR scenes is usually smaller than the FOV of the real scenes \cite{kruijff2010perceptual}. Thus, we further conduct another subjective and objective IQA study towards evaluating the perceptual quality of AR contents in real-world AR applications. \subsection{Subjective ARIQA \label{sec:VI-A}} \textit{\textbf{Subjective experiment methodology.}} An intuitive way to conduct subjective AR experiment is wearing AR devices in various environments and then collecting subjective scores. However, this way suffers from uncontrollable experimental environments and limited experimental scenarios \cite{gutierrez2020quality}, \textit{e.g.}, the head movement may cause different collected background images for different users, and it is hard to introduce various background scenarios in lab environment. Therefore, we adopt the method of conducting subjective AR-IQA studies in VR environment for controllable experimental environments and diverse experimental scenarios. \FigARIII \FigARIV Fig. \ref{fig:7_ar_simulation} illustrates the methodology of the subjective experiment in this ARIQA study. First of all, 20 omnidirectional images are collected as the background scenes including 10 indoor scenarios and 10 outdoor scenarios. Considering the real applications of AR, we further collect 20 images as the reference AR contents, which include 8 web page images, 8 natural images, and 4 graphic images. The resolution of all raw AR images is $1440 \times 900$. We generate a much larger set of distorted AR contents by applying quality degradation processes that would occur in AR applications. Three distortion types including image compression, image scaling, image contrast adjustment, are introduced as follows. 1) \textit{JPEG compression} is a widely used method in image compression, and have been introduced into many quality assessment databases \cite{yang2015perceptual}. We set the quality level of the JPEG compression at the two levels with quality parameters 7 and 3. 2) \textit{Image scaling} is widely used in modern video streaming systems, where videos are often spatially downsampled prior to transmission, and then upscaled prior to display \cite{min2020study}. Such image scaling can also simulate the distortions introduced by various resolutions of AR devices. We create distorted images by downsclaing original images to 1/5 and 1/10 of the original resolution, then spatially upscaling them back to the original resolution. 3) \textit{Image contrast adjustment} is also an important factor affecting the human visual perception and has been commonly introduced into natural IQA \cite{gu2015analysis} and screen content IQA \cite{yang2015perceptual}. We also use the gamma transfer function \cite{gu2015analysis} to adjust the contrast, which is defined as $y=[x \cdot 255^{((1/n)-1)}]^n$, where $n=[1/4,4]$ ($n<1$ is negative gamma transfer, $n>1$ is positive gamma transfer). Hence, for each AR image, we generate 6 degraded images. Since the visual confusion strongly influence the human visual perception as aforementioned, we further introduce the superimposition degradation. We design a program using Unity \cite{Unity} to perform the experimental procedure, including stimuli display, data collection, \textit{etc}. We first randomly match the 20 AR images and 20 omnidirectional images in pairs to generate 20 scenarios. Hence, for each omnidirectional image, we have 7 AR images superimposed on it (1 reference image + 6 distorted images). During the experiment, the perceptual viewport can be formulated as: \begin{equation} I_S = \lambda \circ I_A + (1-\lambda) \circ I_O~, \end{equation} where $I_S$ denotes the perceptual viewport, \textit{i.e.}, the superimposed image, $I_A$ represents the AR image, $I_O$ indicates the omnidirectional image, and $\lambda \in [0.26, 0.42, 0.58, 0.74]$ denotes the mixing value used in the experiment, \textit{i.e.}, we have four superimposing levels in this subjective experiment. Overall, 560 experimental stimuli are generated for conducting the subjective experiment ($20~scenarios \times 7~levels \times 4~mixing~ values$). As demonstrated in Fig. \ref{fig:7_ar_simulation} (a), the omnidirectional image is displayed in 360 degrees as the background scenarios, the AR image is superimposed on the omnidirectional image which is perceived as the perceptual viewport. Fig. \ref{fig:7_ar_simulation} (b), (c) and (d) present the examples of the omnidirectional images, the AR images, and the perceptual viewport images, respectively. A total of 23 subjects participate in the experiment, who are not included in the aforementioned CFIQA study. All subjects are recruited through standard procedures similar to that described in Section \ref{sec:subjective_I}. Before the formal test, each subject experiences a short training session where 28 stimuli are shown. The same distortion generation procedure is conducted for the training stimuli as for the test stimuli, and these training stimuli are not included in the test session. Since the experiment is conducted under VR-HMD environment, the single-stimulus (SS) strategy is adopted to collect the subjective quality ratings of AR images. A 10-point numerical categorical rating method is used to facilitate the subjective rating in HMD \cite{duan2018perceptual}. We use HTC VIVE Pro Eye \cite{HTC} as the HMD on account of its excellent graphics display technology and high precision tracking ability. During the formal test, all 560 experimental stimuli are displayed in a random order for each subject. \TabExperimentIII \textit{\textbf{Subjective data processing and analysis.}} Similar to the procedure in Section \ref{sec:analysis}, we first process the collected subjective scores to obtain the MOSs. Only 1 subject is rejected, and each image is rated by 22 valid subjects. Among all scores given by the remaining valid subjects, about 3.21\% of the total subjective evaluations are identified as outliers and removed. Fig. \ref{fig:8_ariqa_dataset} plots the histogram of MOSs over the entire ARIQA database, showing a wide range of perceptual quality scores. We further analyze the distribution of MOS values across different mixing values and various distortions. Fig. \ref{fig:9_ariqa_dataset_analysis1} shows the MOS distribution of the images with the degradations of JPEG compression and image scaling under different mixing values. We notice that as the $\lambda$ value increases, the MOS value also shows an overall upward trend, of which the reason is apparent since larger $\lambda$ value means clearer AR content. Specifically, for the superimposition of raw AR images and background images, we find that graphic images provide better QoE than web page images, and web page images provide better QoE than natural images in general. It may reveal that relatively simple AR contents can provide better QoE than complex AR contents. Moreover, for the superimposed AR images with JPEG compression and scaling, we notice that when the mixing value $\lambda$ is relatively smaller, the MOSs of these images are closer to that of superimposed raw images, though the overall MOSs are smaller than that of the larger $\lambda$ values. It may reveal that the superimposition degradation is a more influential quality factor compared to other distortions when the $\lambda$ value is relatively small. However, it also means that the superimposition degradation can hide other distortions. Fig. \ref{fig:10_ariqa_dataset_analysis2} plots several examples of the MOS values of raw images and contrast adjusted images superimposed on the omnidirectional backgrounds with different mixing values, which shows that appropriate contrast adjustment may even improve the perceptual quality of AR contents. \TabExperimentIV \vspace{-12pt} \subsection{Objective ARIQA} \vspace{-4pt} \textit{\textbf{Benchmark.}} We first conduct an objective IQA benchmark study on the ARIQA dataset. As discussed in Section \ref{sec:III} and Section \ref{sec:VI-A}, the visual confusion may affect the human visual perception and may degrade the QoE. However, whether the IQA metrics should consider the superimposed image, the AR image, and the background image together still needs to be discussed. Therefore, three variants are introduced in this benchmark study. We assume the background image, the AR image, as well as the mixing value are known, which can be acquired in real applications, and the superimposed image can be correspondingly calculated. Let $I_{A_D}$ denotes the AR image with distortions, $I_{A_R}$ denotes the raw reference AR image, $I_B$ indicates the background image, $\lambda$ represents the mixing value, hence, the displayed AR image $I_A$ and the perceptual viewport image (superimposed image) $I_S$ can be correspondingly expressed as: $I_A = \lambda \cdot I_{A_D}$, and $I_S = \lambda \cdot I_{A_D} + (1-\lambda) \cdot I_B$, respectively. Then, three FR-IQA variants of AR IQA metrics are defined as: Type I, the similarity between the displayed AR image $I_A$ and the reference AR image $I_{A_R}$; Type II, the similarity between the perceptual viewport image $I_S$ and the reference AR image $I_{A_R}$; Type III, the SVR fusion \cite{chang2011libsvm} of the similarity between the perceptual viewport image $I_S$ and the reference AR image $I_{A_R}$, and the similarity between the perceptual viewport image $I_S$ and the background image $I_B$. These three variant types can be expressed as: \vspace{-6pt} \begin{equation} Q_\text{Type I} = \text{FR}(I_A,I_{A_R}), \end{equation} \vspace{-14pt} \begin{equation} Q_\text{Type II} = \text{FR}(I_S,I_{A_R}), \end{equation} \vspace{-14pt} \begin{equation} Q_\text{Type III} = \text{SVR}(\text{FR}(I_S,I_{A_R}), \text{FR}(I_S,I_B)), \end{equation} where $Q_\text{Type I}$, $Q_\text{Type II}$, and $Q_\text{Type III}$ denote the quality predictions of the three variants, SVR indicates the support vector regression deployment. In terms of our ARIQA dataset, the background image $I_B$ (\textit{i.e.}, viewport of the omnidirectional image $I_O$) and the superimposed image $I_S$ are captured in Unity, then the benchmark results are calculated using the aforementioned methods. Table \ref{tab:3_AR_base} presents the performance of the three AR-IQA metric variants derived from the state-of-the-art FR-IQA models on the ARIQA dataset. Comparing Type I and Type II, we notice that for most FR-IQA metrics, using superimposed images as distorted images can improve the performance of the algorithm. In addition, as shown in the comparison between Type III and Type I, when superimposed images, AR images, as well as background images are jointly considered, the performance of almost all FR-IQA metrics can be further improved. \FigMethodII \FigNewCriterionII \textit{\textbf{ARIQA.}} Based on the aforementioned analysis, using superimposed images as the perceptual distorted image, and considering their similarity with both AR references and background references may be more effective for evaluating the perceptual quality of the AR layers. Hence, as demonstrated in Figure \ref{fig:11_modelII}, we further modify the CFIQA model to an ARIQA model for better evaluating the perceptual quality of AR contents. Different from CFIQA, the goal for the ARIQA is to predict the perceptual quality of AR contents rather than both two views, therefore, the two output results of CFIQA are fused to predict the AR image quality. Considering the effectiveness of the training objectives of the LPIPS \cite{zhang2018unreasonable} and our CFIQA, during the training process, two pathways are introduced to ARIQA for comparing the perceptual quality of different distorted images of the one AR and background reference pair. For fair comparison, we further re-train the LPIPS and CFIQA models only using AR image as the reference image, which is similar to the concept of Type II described above. Note that the CFIQA model here is a modified version, since the original CFIQA aims to compare the similarity between two reference images for one superimposed image, while here we focus on comparing two superimposed images for one AR reference, which is more similar to the concept of LPIPS. We also improve the ARIQA by incorporating the features from the RCF net \cite{liu2019richer} as the ARIQA+, which is similar to the way of the aforementioned CFIQA+. We conduct a five-fold cross validation experiment on the ARIQA dataset. For each fold, we split the 560 samples into 280 training samples and 280 testing samples without scene repeating, \textit{i.e.}, 280 training samples and 280 testing samples corresponding to different 10 AR/BG pairs, respectively. Table \ref{tab:4_ARIQA} shows the averaged performance of these four models after five-fold cross validation. It can be observed that the ARIQA model achieves better performance than the LPIPS model and the CFIQA model, and the ARIQA+ achieves the best performance compared to other models. Fig. \ref{fig:new_evaluation_ariqa} illustrates the performance evaluated by the new criteria on the ARIQA database. We notice that the proposed ARIQA model significantly outperforms other state-of-the-art models on \textit{Different vs. Similar Analysis} and \textit{Better vs. Worse Analysis} by a large margin. \vspace{-8pt} \section{Conclusion \label{sec:VII}} \vspace{-4pt} In this paper, we discuss several AR devices and applications (see Section \ref{sec:2.1_AR}), and clarify the essential theory underlying AR, \textit{i.e.,} visual confusion. A more general problem underlying AR QoE assessment is first proposed, which is evaluating the perceptual quality of superimposed images, \textit{i.e.}, confusion image quality assessment. To this end, we build a confusing image quality assessment (CFIQA) dataset, and conduct subjective and objective image quality assessment studies based on it. A CFIQA model is also proposed for better evaluating the perceptual quality of visual confusion. The results show that without extra degradation, the visual confusion itself can significantly influence the perceptual quality of the superimposed images, and state-of-the-art FR-IQA metrics are not well performed, especially when the mixing value is closer to 0.5. The proposed CFIQA model performs better on this task. Moreover, in order to better study the influence of visual confusion on the perceptual quality of AR images in real application scenarios, an ARIQA study is further conducted, which includes the construction of an ARIQA dataset, an objective model evaluation experiment for ARIQA, as well as an ARIQA model proposed to solve this problem. The results show that it is beneficial to consider visual confusion when designing IQA models for AR, and our proposed ARIQA model achieves better performance compared to other state-of-the-art methods. We hope this work can help other researchers have a better understanding of the visual confusion mechanism underlying AR technology. There are many issues related to visual confusion or AR QoE assessment that need to be explored in the future. Several key aspects are discussed in the \textit{supplementary material}. \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:33:41', 'yymm': '2204', 'arxiv_id': '2204.04900', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04900'}
arxiv
\section{Introduction} Recently, ``metaverse" has attracted many people's attention for its unlimited possibilities in the future. Compared with current 2D display techniques, ``metaverse" additionally utilizes binocular disparity~\cite{didyk2011perceptual} that refers to the slight difference between the left and right retina images, making people enjoy more realistic and immersive experience. Therefore, disparity estimation plays a basic role in the techniques of ``metaverse". Since we have plenty of available stereoscopic content (such as 3D movies), there is a clear need for methods that can estimate disparity from such stereo pairs. Given a position $\mathbf{p}$ in the 3D world space, if its projections into the rectified left and right views are $\mathbf{p}\textsuperscript{L}$ and $\mathbf{p}\textsuperscript{R}$, then their disparity is defined as $\boldsymbol{D}\textsuperscript{L}(\mathbf{p}\textsuperscript{L})=\boldsymbol{D}\textsuperscript{R}(\mathbf{p}\textsuperscript{R})=\mathbf{p}^\text{L}_x-\mathbf{p}^\text{R}_x$ where $\mathbf{p}^\text{L}_x$ and $\mathbf{p}^\text{R}_x$ denote the horizontal components of $\mathbf{p}\textsuperscript{L}$ and $\mathbf{p}\textsuperscript{R}$. Current state-of-the-art stereo matching methods are designed and trained to match only over positive disparity ranges because the prior methods 1) mainly focused on the applications of autonomous driving and robot navigation that only require positive disparities; 2) need plenty of data to supervise the network, but there is not enough labeled data for the scenes containing both positive and negative disparities; 3) usually have poor generalization performance, so these methods have difficulties in utilizing large amounts of labeled data from known datasets. In this paper, we explore the above challenges and present a new stereo matching pipeline: first computing semi-dense disparity maps based on binocular disparity, and then estimating the rest based on monocular cues. In contrast, the traditional stereo matching pipeline~\cite{scharstein2002taxonomy} usually contains four steps: matching cost computation, cost aggregation, disparity computation, and refinement. Recent learning-based stereo matching methods also follow the traditional pipeline and design various network architectures. Here we review matching cost computation and cost aggregation that prior methods mainly involve. Matching costs are calculated based on hand-crafted or learning-based feature maps extracted from the left and right images, which expresses how well a pixel in the reference image matches its candidates in the other. Feature descriptors in traditional stereo matching methods are hand-crafted, usually based on gradients~\cite{klaus2006segment,hosni2012fast} and mutual information~\cite{hirschmuller2007stereo}. The early deep-learning-based methods focus on designing feature extraction networks to characterize the left and right images~\cite{zbontar2016stereo,luo2016efficient}, and then utilize non-learned cost aggregation and refinement to determine the final disparity map. The recent end-to-end methods also design various Siamese-like networks to extract features, such as GCNet~\cite{kendall2017end}, StereoNet~\cite{khamis2018stereonet}, PSMNet~\cite{chang2018pyramid}, and GANet~\cite{zhang2019ga}, and their feature extractors are integrated into the whole network and trained in an end-to-end manner. After obtaining matching costs, we intuitively want to take the candidate with the smallest matching cost (or the largest similarity) as the best-matched pixel, but researchers generally do not adopt the intuitive operation for the following reasons: 1) the left and right features have poor ability to characterize the texture-less or repetitive regions; 2) the single-visible pixels do not have corresponding pixels in the other image. Therefore, for these ticklish pixels, the prior methods usually estimate their disparities from their neighboring tractable pixels, which is the job of cost aggregation. Cost aggregation denotes we aggregate space context information in the cost volume, so that we can compute more reliable disparities. Most traditional and some learning-based methods aggregate matching costs in a 3D cost volume (\emph{disparity$\times$height$\times$width}). Cost aggregation in a 3D cost colume, including SGM~\cite{hirschmuller2007stereo}, CostFilter~\cite{hosni2012fast}, DispNet~\cite{mayer2016large}, and AANet~\cite{xu2020aanet}, resembles the votes of neighboring pixels. Recent learning-based methods, such as PSMNet~\cite{chang2018pyramid}, GANet~\cite{zhang2019ga}, and CFNet~\cite{shen2021cfnet} execute cost aggregation in a 4D cost volume (\emph{feature$\times$disparity$\times$height$\times$width}), because researchers believe that 4D cost volumes contain more information than the 3D form. Motivated by the neuroscience fact that binocular disparity is a low-level, pre-attentive cue of human depth cues, we propose a new stereo matching pipeline that highlights the role of feature extractors. Different from the traditional stereo matching pipeline~\cite{scharstein2002taxonomy}, our proposed pipeline no longer needs cost aggregation: It first computes accurate semi-dense disparity maps directly from feature maps, and then generates the final disparity maps by disparity completion networks. In summary, our proposed stereo matching pipeline has the following advantages: 1) It has better generalization performance than most state-of-the-art stereo matching methods; 2) It relaxes the limitation of a fixed disparity search range; 3) It can handle the scenes that involves both positive and negative disparities, whereas prior learning-based methods can only deal with the scenes with positive disparities; 4 It does not store and process cost volumes at the inference time, so it needs less GPU memory. \begin{figure*}[t!] \centering \includegraphics[width=0.95\linewidth]{./figs/overview.pdf} \caption{Overview of our proposed stereo matching pipeline at the inference time. The pipeline contains two stages: first computing semi-dense disparity maps directly from feature maps; then generating final disparity maps by two disparity completion networks. At the training time, we first train the first stage using the loss functions in Sec. \ref{sec:semi_loss}, and then the second stage. } \label{fig:overview} \end{figure*} \section{Method} Our goal is to compute the disparity map from a known rectified stereo pair. As mentioned above and shown in Figure \ref{fig:overview}, here we introduce the two steps of our stereo matching pipeline in detail. \begin{figure}[t!] \centering \includegraphics[width=0.8\linewidth]{./figs/w_function.pdf} \caption{An example of weights of the double-visible-region loss. } \label{fig:w_function} \end{figure} \subsection{Computing Semi-dense Disparity Maps directly from Feature Maps} Like prior methods, we adopt a shared feature extractor to extract the feature maps from the left and right images. Each feature map is a tensor with the size of $\alpha h\times\alpha w\times n$ where $h, w, n, \alpha$ represent image height, width, feature channels and the down-scaled scale. Here we introduce the symbol $\alpha$ to emphasize that current feature extractors generally extract feature maps at smaller resolution than the original image. Like AANet~\cite{xu2020aanet}, we utilize a full correlation to generate a 3D cost volume $\boldsymbol{C}=(c_{i,j}^{(d)})$ for pre-defined disparity candidates $\mathcal{D}=\{d\in\mathbb{Z}~|~\alpha d_\text{min}\leqslant d\leqslant \alpha d_\text{max}\}$. The 3D cost volume $\boldsymbol{C}$ is a tensor with the size of $\alpha h\times \alpha w\times m$ where $m=\alpha(d_\text{max}-d_\text{min})+1$, and each element $c_{i,j}^{(d)}$ records how well the position $(i/\alpha,j/\alpha)$ in the left image matches its disparity candidate $(i/\alpha,j/\alpha-d/\alpha)$ in the right image. After building a 3D cost volume, prior methods usually execute cost aggregation on the cost volume, so they need to store the volume at the whole inference process. In contrast, we generate an initial disparity map $D^\text{init}=(d_{i,j}^\text{init})\in[\alpha d_{\rm min},\alpha d_{\rm max}]^{\alpha h\times\alpha w}$ and the corresponding reliability map $R=(r_{i,j})\in[0,1]^{\alpha h\times\alpha w}$ directly from the cost volume, and thus there is no need to store the volume at the subsequent steps. The reliability map records how reliable a predicted disparity is, so we can obtain semi-dense disparity maps from initial disparity maps and reliability maps. We take the computation of disparity at the position $(i,j)$ as an example. We first convert the 3D cost volume $\boldsymbol{C}$ into the 3D probability volume $\boldsymbol{P}=(p_{i,j}^{(d)})$ by executing the softmax operation along the disparity dimension. Like the sub-pixel maximum a posteriori (MAP) ~\cite{tulyakov2018practical,nuanes2021soft}, we compute the initial disparity map according to \begin{equation} d_{i,j}^\text{init}=\hat{d}_{i,j}+o_{i,j} \label{eq:disparity} \end{equation} where $\hat{d}_{i,j}=\mathop{\operatornamewithlimits{argmax}\limits}_{d\in\mathcal{D}}p_{i,j}^{(d)}$ denotes we chose the disparity candidate with the largest probability and $o_{i,j}$ is a refinement term to achieve sub-pixel precision. The refinement term $o_{i,j}$ is computed according to the possibilities at $\hat{d}_{i,j}-1$ and $\hat{d}_{i,j}+1$: \begin{equation} o_{i,j}= \left.\sum_{\delta=-1}^{1}\delta\cdot p_{i,j}^{(\hat{d}_{i,j}+\delta)}\middle/\sum_{\delta=-1}^{1} p_{i,j}^{(\hat{d}_{i,j}+\delta)}\right. \label{eq:refinement} \end{equation} where we regard $\sum_{\delta=-1}^{1} p_{i,j}^{(\hat{d}_{i,j}+\delta)}$ as the reliability $r_{i,j}$ of the initial disparity $d_{i,j}^\text{init}$. Finally, we filter the initial disparity map $D^\text{init}$ to obtain a semi-dense disparity map by left-right consistency checking~\cite{hosni2012fast} and reliability checking (see Figure~\ref{fig:overview}). The latter checking refers to that the reliability of a predicted disparity has to be larger than the reliability threshold $\tau$. \subsubsection{Loss Function} \label{sec:semi_loss} Unlike prior stereo matching methods that train the feature extractor and rest modules in an end-to-end way, our method first trains the feature extractor since we have been highlighting its importance. The loss function contains three components: $\ell^\text{dvr}+\ell^\text{ur}+\ell^\text{trr}$. \textbf{Double-visible-region loss} $\ell^\text{dvr}$. For the position $(i,j)$ in the probability volume $\boldsymbol{P}$, we hope its maximal probability along the disparity dimension occurs at the ground truth disparity. Moreover, if the position $(i,j)$ is located in the occluded region, we cannot compute its disparity directly from feature maps since it has no corresponding pixel in the other. Therefore, we only execute this loss function in the double-visible region that can be derived from the ground-truth disparity map $D^\text{gt}=(d_{i,j}^\text{gt})$. Formally, the double-visible-region loss is defined as \begin{eqnarray} \ell\textsuperscript{dvr}=\frac{1}{|\mathcal{V}|}\sum_{(i,j)\in\mathcal{V}}\left(\sum_{\delta=-1,0,1}w_{i,j}^{(t+\delta)}\cdot p_{i,j}^{(t+\delta)}\right) \label{eq:double_loss} \end{eqnarray} where $t=[d_{i,j}^\text{gt}]$ indicates the integral disparity closest to the ground truth and the set $\mathcal{V}$ denotes all the pixels in the double-visible region. The coefficient $w^{(t+\delta)}_{i,j}$ is a weight function, and the closer to the ground truth a disparity is, the larger its weight will be (see Figure \ref{fig:w_function}). We give its detailed definition in the supplementary material. \textbf{Unreliable-region loss} $\ell^\text{ur}$. We hope that a predicted disparity has as low reliability as possible if it is located in the occluded region or its value diverges from the ground truth ($\geqslant 1$). Such the region is called the unreliable region $\mathcal{U}$. The unreliable-region loss is defined as follows: \begin{equation} \ell\textsuperscript{ur}=-\frac{1}{|\mathcal{U}|}\sum_{(i,j)\in\mathcal{U}}\log(1-r_{i,j}). \end{equation} \textbf{To-refine-region loss} $\ell^\text{trr}$. If a predicted disparity $d_{i,j}^\text{init}$ is close to the ground truth, then we use this loss function to make the predicted disparity achieve more accurate sub-pixel precision. Formally, the loss function is \begin{equation} \ell^\text{trr}=\frac{1}{|\mathcal{T}|}\sum_{(i,j)\in\mathcal{T}}|d_{i,j}^\text{init}-d_{i,j}^\text{gt}| \end{equation} where $\mathcal{T}=\{(i,j)\in\mathcal{V}\big||d_{i,j}^\text{init}-d_{i,j}^\text{gt}|\leqslant 1\}$. \subsection{Generating Final Disparity Maps by Disparity Completion Networks} In the last subsection, we obtain a semi-dense disparity map, an initial disparity map, and a reliability map. As shown in Figure \ref{fig:overview}, we utilize two disparity completion networks to complete hierarchically the semi-dense disparity and then acquire the final disparity map. The first disparity completion network is similar to the monocular depth estimation network~\cite{monodepth17}. It takes the initial disparity map, the semi-dense disparity map, the reliability map, and the reference color image as inputs, and outputs a full disparity map with the $1/2$ resolution. The second disparity completion network is similar to the refinement module in AANet~\cite{xu2020aanet}. It takes the full disparity map from the first network and the left image as inputs and outputs the final disparity map. At the training time, the first disparity completion network also outputs the disparity maps with the resolution $1/4,1/8,1/16$. We train the two networks by supervising the five disparity maps with different resolutions. The corresponding loss function is the smooth L1 loss \cite{chang2018pyramid} that measures the difference between output disparity maps and the ground truths. More details are provided in the supplementary material. \section{Experiments} \subsection{Datasets} We train the networks only in SceneFlow \cite{mayer2016large}, and evaluate them qualitatively and quantitatively on the training sets of KITTI2012 \cite{geiger2012we}, KITTI2015 \cite{menze2015object}, Middlebury \cite{scharstein2014high}, which only contain positive disparities. We also use the dataset 3D Movie that includes negative disparities besides positive ones. \noindent\textbf{SceneFlow.} SceneFlow is a large synthetic dataset containing 35,454 training and 4,370 test images with a resolution of $960\times540$, which have dense ground truth disparity maps. \noindent\textbf{KITTI2012\&2015.} KITTI2012 and KITTI2015 are real-world datasets with street views captured from a driving car, providing 394 stereo pairs of outdoor driving scenes with sparse ground-truth disparities for training, and 395 pairs for testing. \noindent\textbf{Middlebury.} Middlebury is a small indoor dataset containing less than 50 stereo pairs with three different resolutions. Here we use its half version. \noindent\textbf{3D Movie.} We chose stereo images that contain both negative and positive disparities from the 3D movie "Big Buck Bunny" \copyright by Blender Foundation (https://peach.blender.org/). Their resolution is $1080\times1920$. The dataset does not have available ground truth disparities, so we just give a qualitative evaluation and visualized results. \subsection{Implementation Details} We implemented the feature extractors in PyTorch and using Adam ($\beta_1=0.9,\beta_2=0.999$) as optimizer. At training time we set the minimum disparity $d_{\text{min}}=0$ and the maximum disparity $d_{\text{max}}=320$, whereas at test time we adaptively adjusted the minimum and maximum disparity for different datasets. Specifically, we set $d_{\text{min}}=0,d_{\text{max}}=192$ for KITTI2012 and KITTI2015, $d_{\text{min}}=0,d_{\text{max}}=320$ for Middlebury, and set $d_{\text{min}}=-100,d_{\text{max}}=100$ for 3D Movie. We performed color normalization with ImageNet mean and standard deviation. During training, images were randomly cropped to the size $288\times576$, and their color was randomly augmented. We also used asymmetric data augmentation \cite{li2021revisiting}. We first trained the feature extractor for 18 epochs with a batch size $4$, and the learning rate started at 0.0005 and was decreased by half every 3 epochs after 6 epochs. After training the feature extractor, we then trained the rest module networks for 24 epochs, and the learning rate started at 0.001 and was decreased by half every 4 epochs after 8 epochs. All the models are trained and tested on one NVIDIA Tesla-P100 GPU. \begin{figure}[t!] \centering \includegraphics[width=\linewidth]{./figs/ablation.pdf} \caption{Ablation study results for left-right consistency checking, sub-pixel precision, and different reliability threshold values for reliability checking. ``StereoNet-Ours" denotes we utilized the feature extractor of StereoNet~\cite{khamis2018stereonet} in our proposed stereo matching pipeline. ``PSMNet-Ours" denotes we utilized the feature extractor of PSMNet~\cite{chang2018pyramid} in our proposed stereo matching pipeline. ``w/o sub-pixel precision" means we just use $\hat{d}_{i,j}$ in Eq.(2) as the initial disparity map. } \label{fig:ablation} \end{figure} \subsection{Ablation Study} We conducted experiments with several settings to evaluate our proposed stereo matching pipeline, including the usage of left-right consistency checking, sub-pixel precision, different reliability threshold values for reliability checking, and different feature extractors (StereoNet~\cite{khamis2018stereonet} and PSMNet~\cite{chang2018pyramid}). Left-right consistency checking and reliability checking work together to filter possibly-wrong disparities in the initial disparity map. Higher reliability threshold $\tau$ means more strict reliability checking. As shown in Figure \ref{fig:ablation}, if $\tau$ is lower than about 0.4, left-right consistency checking has a significant effect on the final result; otherwise, left-right consistency checking no longer work. Removing the sub-pixel precision module leads to a slight performance drop. For the methods ``StereoNet-Ours" and ``PSMNet-Ours", we get the best result when using left-right consistency checking, reliability checking with $\tau=0.3$, and sub-pixel precision module. If we do not adopt left-right consistency checking, we can also obtain competitive results just depending on sub-pixel precision and reliability checking with $\tau=0.5$ (the blue dot v.s. the orange dot in Figure \ref{fig:ablation}). \subsection{Evaluation} \subsubsection{Cross-domain generalization performance} \begin{table}[t!] \centering \footnotesize \begin{tabular}{c|ccc|c}\hlineB{2} \multirow{2}{*}{\makecell{Method}}& KITTI2012 & KITTI2015 & Middlebury & Time \\ & D1\_all(\%)$\downarrow$ & D1\_all(\%)$\downarrow$ & bad2.0(\%)$\downarrow$ & (s)$\downarrow$ \\\hline \multicolumn{5}{c}{Traditional Methods}\\\hline CostFilter~\cite{hosni2012fast} & 21.7 & 18.9 & 40.5&$240^*$ \\ SGM~\cite{hirschmuller2007stereo} & 7.1 & 7.6 & 25.2&$3.7^*$ \\ \hline \multicolumn{5}{c}{Domain-specific Methods}\\\hline PSMNet~\cite{chang2018pyramid}& 15.1&16.3 &25.1&0.337 \\ GWCNet~\cite{guo2019group} & 20.2 & 22.7 & 34.2&$0.32^*$ \\ AANet~\cite{xu2020aanet} & 18.3 & 12.2 & 31.0&0.123 \\\hline \multicolumn{5}{c}{Domain-invariant Methods}\\\hline DSMNet~\cite{zhang2020domain} &6.2 &6.5&\textbf{13.8}&$1.6^*$ \\ STTR~\cite{li2021revisiting} &8.4 &7.7&oom&1.416 \\\hline \multicolumn{5}{c}{Our new stereo matching pipeline}\\\hline StereoNet-Ours& 6.5& 6.8& 22.8&\textbf{0.095}\\ PSMNet-Ours& \textbf{6.0}& \textbf{6.4}& 21.2&0.198\\ \hlineB{2} \end{tabular} \caption{Generalization performance evaluation. ``oom" denotes ``out of memory". We tested the running time on a NVIDIA P100 GPU for the KITTI resolution $384\times1344$. The symbol ``*" in Time denotes that the running time value is taken from the stereo evaluation system of KITTI. } \label{tab:genelization} \end{table} Current state-of-the-art methods can achieve impressive performance in some special datasets, but usually have poor generalization performance. Here we evaluate the generalization performance of our stereo matching pipeline. Specifically, all the methods are trained in the synthesized dataset SceneFlow~\cite{mayer2016large}, and tested in three real-world datasets KITTI2012 \cite{geiger2012we}, KITTI2015 \cite{menze2015object}, and Middlebury \cite{scharstein2014high}. As shown in Table \ref{tab:genelization}, our method outperforms traditional methods ~\cite{hosni2012fast,hirschmuller2007stereo}, and the learning-based domain-specific methods \cite{chang2018pyramid,guo2019group,xu2020aanet} on three datasets. STTR~\cite{li2021revisiting} adopts the prevailing \emph{transformer} architecture and is designed for cross-domain generalization. Our method outperforms STTR on two datasets. Note that STTR failed in the half-resolution version of Middlebury, because it requires too much GPU memory. DSMNet~\cite{zhang2020domain} is also designed for cross-domain generalization, and our method can surpass it in two datasets. Besides, our method is far faster than the two domain-invariant methods STTR~\cite{li2021revisiting} and DSMNet~\cite{zhang2020domain}. \begin{table}[t!] \centering \footnotesize \begin{tabular}{ccccc}\toprule \multirow{2}{*}{\makecell{Method}}& Unfixed & Sub-pixel & Negative & \multirow{2}{*}{\makecell{Robust}} \\ & Range & Precision & Disparities & \\\midrule CostFilter~\cite{hosni2012fast} & {\color{ForestGreen}\ding{51}} & {\color{Maroon}\ding{55}} & {\color{ForestGreen}\ding{51}} & {\color{Maroon}\ding{55}} \\ SGM~\cite{hirschmuller2007stereo} & {\color{ForestGreen}\ding{51}} & {\color{Maroon}\ding{55}} & {\color{ForestGreen}\ding{51}} & {\color{ForestGreen}\ding{51}} \\ \midrule PSMNet~\cite{chang2018pyramid}& {\color{YellowOrange}\ding{51}\ding{55}} & {\color{ForestGreen}\ding{51}} & {\color{Maroon}\ding{55}} & {\color{Maroon}\ding{55}} \\ AANet~\cite{xu2020aanet} & {\color{Maroon}\ding{55}} & {\color{ForestGreen}\ding{51}} & {\color{Maroon}\ding{55}} & {\color{Maroon}\ding{55}} \\\midrule DSMNet~\cite{zhang2020domain} & {\color{YellowOrange}\ding{51}\ding{55}} & {\color{ForestGreen}\ding{51}} & {\color{Maroon}\ding{55}} & {\color{ForestGreen}\ding{51}} \\ STTR~\cite{li2021revisiting} & {\color{ForestGreen}\ding{51}} & {\color{ForestGreen}\ding{51}} & {\color{Maroon}\ding{55}} & {\color{ForestGreen}\ding{51}} \\\midrule Ours& {\color{ForestGreen}\ding{51}} & {\color{ForestGreen}\ding{51}} & {\color{ForestGreen}\ding{51}} & {\color{ForestGreen}\ding{51}}\\\bottomrule \end{tabular} \caption{Qualitative evaluation of our method and prior methods. The symbol {\color{YellowOrange}\ding{51}\ding{55}} denotes in the column ``Unfixed Range" denotes that the performance will be unstable if we change their disparity search range~\cite{tulyakov2018practical}. } \label{tab:qualitative} \end{table} \begin{figure}[t!] \centering \includegraphics[width=0.9\linewidth]{./figs/visualization.pdf} \caption{Visualized results. In reliability maps, bright colors means high reliability, whereas dark colors denotes low reliability. } \label{fig:visualization} \end{figure} Table \ref{tab:qualitative} lists the qualitative evaluation results of our method and prior methods. For traditional methods, they cannot generate sub-pixel disparity maps because they use the scheme ``winner takes all". For learning-based methods, 1) if a method (such as AANet~\cite{xu2020aanet}) adopt cost aggregation on a 3D cost volume, its disparity search range is fixed and cannot be changed; 2) if a method (such as PSMNet~\cite{chang2018pyramid} and DSMNet~\cite{zhang2020domain}) executes cost aggregation on a 4D cost volume, its disparity range can be changed, but the performance is unstable if the range is changed. These learning-based methods are limited to supporting the scenes with only positive disparities, whereas our stereo matching pipeline can also support the scenes with both negative and positive disparities. \subsubsection{Visualized Results} We give an illustration of our method on KITTI2012 and 3D Movie. As Figure \ref{fig:visualization} shows, although our method is only trained in a synthesized dataset and over positive disparities, it still has a satisfying visualized result. Note that the stereo images of 3D Movie contain both positive and negative disparity, but it does not matter for our method. Figure \ref{fig:visualization} also shows reliability maps and semi-dense disparity maps. Surprisingly, the disparities of more than 80\% pixels can be computed accurately just depending on feature extractors, and most unknown disparities occur in the occluded region. For more visualized results, please see the supplementary material. \section{Conclusion} In this paper, we have presented a new stereo matching pipeline that highlights binocular disparity of human depth cues, and no longer needs cost aggregation: It first computes accurate semi-dense disparity maps directly from feature maps, and then generates the final disparity maps by disparity completion networks. The new stereo matching pipeline 1) has superior generalization performance, 2) avoids the need to pre-specify a fixed disparity search range, and 3) can handle the scenes with both positive and negative disparities. We experimentally demonstrate that our stereo matching pipeline generalizes to different domains without fine-tuning and give visualized results on the scenes with both negative and positive disparities. \bibliographystyle{IEEEbib}
{'timestamp': '2022-04-12T02:32:14', 'yymm': '2204', 'arxiv_id': '2204.04865', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04865'}
arxiv
\section{Preliminaries} \label{sec:prelim} \iffalse We suppose we are given $n$ points (also known as \emph{clients}) $\mathcal{D} = \{x_1, \dots, x_n\} \in \mathbb R^d$. Formally, the goal of the Euclidean $k$-means problem is to find a set of $k$ centers $\mathcal{Y} = \{y_1, y_2, \dots, y_k\} \subset \mathbb R^d$ to minimize \[\sum_{i = 1}^{n} d(x_i, \mathcal{Y})^2,\] where $d(x, S) := \min_{s \in S} d(x, s) = \min_{s \in S} \|x-s\|_2$ for any set $S$ and point $x$. Likewise, the goal of the Euclidean $k$-median problem is the same, except we wish to minimize the sum of $d(x_i, \mathcal{Y})$ instead of $d(x_i, \mathcal{Y})^2$. To avoid redefining everything for both $k$-means and $k$-median, we define $c(x, y) := \|x-y\|_2^2$ in the context of $k$-means and $c(x, y) := \|x-y\|_2$ in the context of $k$-means. We also define $c(x, S) := \min_{s \in S} c(x, s)$ for any $S \subset \mathbb R^d$. We say that algorithm obtains a $\rho$-approximation if for any set of $n$ input points $x_1, \dots, x_n$, the algorithm returns a set of points $\mathcal{Y} = \{y_1, y_2, \dots, y_k\} \subset \mathbb R^d$ that satisfies \[\sum_{i = 1}^{n} c(x_i, \mathcal{Y}) \le \rho \cdot \min_{\mathcal{Z} = \{z_1, \dots, z_k\} \subset \mathbb R^d} c(x_i, \mathcal{Z}).\] \fi Our goal is to provide approximation algorithms for either the $k$-means or $k$-median problem in Euclidean space on a set $\mathcal{D}$ of \textit{clients} of size $n$. For the entirety of this paper, we consider the discrete $k$-means and $k$-median problems, where rather than having the $k$ centers allowed to be anywhere, we are given a fixed set of facilities $\mathcal{F}$ of size $m$ which is polynomial in $n$, from which the $k$ centers must be chosen from. It is well-known (e.g., \cite{Mat00}) that a polynomial-time algorithm providing a $\rho$-approximation for discrete $k$-means (resp., median) implies a polynomial-time $\rho+\varepsilon$-approximation for standard $k$-means (resp., median) for an arbitrarily small constant $\varepsilon$. For two points $x, y$ in Euclidean space, we define $d(x, y)$ as the Euclidean distance (a.k.a. $\ell_2$-distance) between $x$ and $y$. In addition, to avoid redefining everything or restating identical results for both $k$-means and $k$-median, we define $c(x, y) := d(x, y)^2$ in the context of $k$-means and $c(x, y) := d(x, y)$ in the context of $k$-means. For a subset $S$ of Euclidean space, we define $d(x, S) := \min_{s \in S} d(x, s)$ and $c(x, S) := \min_{s \in S} c(x, s)$. For the $k$-means (or $k$-median) problem, for a subset $S \subset \mathcal{F}$, we define $\text{cost}(\mathcal{D}, S) := \sum_{j \in \mathcal{D}} c(j, S)$. In addition, we define $\text{OPT}_k$ to be the optimum $k$-means (or $k$-median) cost for a set $\mathcal{D}$ and a set of facilities $\mathcal{F}$, i.e., $\text{OPT}_k = \min_{S \subset \mathcal{F}, |S| = k} \text{cost}(\mathcal{D}, S)$. Recall that a $\rho$-approximation algorithm is an algorithm that produces a subset of $k$ facilities $S \subset \mathcal{F}$ with $\text{cost}(\mathcal{D}, S) \le \rho \cdot \text{OPT}_k$ in the worst-case. \subsection{The Lagrangian LP Relaxation and LMP Solutions} \label{subsec:lagrangian_lp} We first look at the standard LP formulation for $k$-means/medians. The variables of the LP include a variable $y_i$ for each facility $i \in \mathcal{F}$ and a variable $x_{i, j}$ for each pair $(i, j)$ for $i \in \mathcal{F}$ and $j \in \mathcal{D}$. The standard LP relaxation is the following: \begin{alignat}{5} \text{minimize } & \sum_{i \in \mathcal{F}, j \in \mathcal{D}} x_{i, j} \cdot c(j, i) \hspace{0.5cm} && && && \label{eq:lp_A}\\ \text{such that } & && \sum_{i \in \mathcal{F}} x_{i, j} && \ge 1 &&\qquad \forall j \in \mathcal{D} \label{eq:lp_B} \\ & && \quad \sum_{i \in \mathcal{F}} y_i && \le k && \label{eq:lp_C}\\ & && 0 \le x_{i, j} && \le y_i &&\qquad \forall j \in \mathcal{D}, i \in \mathcal{F} \label{eq:lp_D} \end{alignat} The intuition behind this linear program is that we can think of $x_{i, j}$ as the indicator variable of client $j$ being assigned to facility $i$, and $y_i$ as the indicator variable of facility $i$ being opened. We need every facility $j \in \mathcal{D}$ to be assigned to at least one client, that at most $k$ facilities $i$ are opened, and that $x_{i, j}$ is $1$ only if $y_i = 1$ (since clients can only be assigned to open facilities). We also ensure a nonnegativity constraint on $x_{i, j}$ and $y_i$ by ensuring that $0 \le x_{i, j}$. Finally, our goal is to minimize the sum of distances (for $k$-median) or the sum of squared distances (for $k$-means) from each client to its closest facility -- or simply the facility it is assigned to, and if exactly one of the $x_{i, j}$ values is $1$ for a fixed client $j$ and the rest are $0$, then $\sum_{i \in \mathcal{F}} x_{i, j} c(j, i)$ is precisely the distance (or squared distance) from $j$ to its corresponding facility. By relaxing the linear program to have real variables, we can only decrease the optimum, so if we let $L$ be the optimum value of the LP relaxation, then $L \le \text{OPT}_k$. Jain and Vazirani \cite{jain2001lagrangian} considered the \emph{Lagrangian relaxation} of this linear program, by relaxing the constraint \eqref{eq:lp_C} and adding a dependence on a Lagrangian parameter $\lambda \ge 0$. By doing this, the number of facilities no longer has to be at most $k$ in the relaxed linear program but the objective function penalizes for opening more than $k$ centers. Namely, the goal becomes to minimize \begin{equation} \label{eq:lp_A'} \sum_{i \in \mathcal{F}, j \in \mathcal{D}} x_{i, j} \cdot c(j, i) + \lambda \cdot \left(\sum_{i \in \mathcal{F}} y_i - k\right) \end{equation} subject to Constraints \eqref{eq:lp_B} and \eqref{eq:lp_D}. Indeed, for $\lambda \ge 0$, the objective only decreases from \eqref{eq:lp_A} to \eqref{eq:lp_A'} for any feasible solution to the original LP. Therefore, this new linear program, which we will call $\text{LP}(\lambda)$, has optimum $L(\lambda) \le L$. Now, it is known that the Dual linear program to this Lagrangian relaxation of the original linear program can be written as the following, which has variables $\alpha = \{\alpha_j\}_{j \in \mathcal{D}}$: \begin{alignat}{5} \text{maximize } & \left(\sum_{j \in \mathcal{D}} \alpha_j\right) - \lambda \cdot k \hspace{0.5cm} && && && \label{eq:lp_E} \\ \text{such that} & && \sum_{j \in \mathcal{D}} \max(\alpha_j-c(j, i), 0) && \le \lambda && \qquad \forall i \in \mathcal{F} \label{eq:lp_F}\\ & && \hspace{3.6cm} \alpha &&\ge 0 && \label{eq:lp_G} \end{alignat} We call this linear program $\text{DUAL}(\lambda)$. Because the optimum to $\text{DUAL}(\lambda)$ equals the optimum to the primal $\text{LP}(\lambda)$ by strong duality, this means that for any $\alpha = \{\alpha_j\}_{j \in \mathcal{D}}$ satisfying Conditions \eqref{eq:lp_F} and \eqref{eq:lp_G}, we have that $\left(\sum_{j \in \mathcal{D}} \alpha_j\right) - \lambda \cdot k \le L(\lambda) \le L \le \text{OPT}_{k}$. For a fixed $\lambda$, we say that $\alpha$ is \emph{feasible} if it satisfies both \eqref{eq:lp_F} and \eqref{eq:lp_G}. Thus, to provide a $\rho$-approximation to $k$-means (or $k$-median), it suffices to provide both a feasible $\alpha$ and a subset $S \subset \mathcal{F}$ of size $k$ such that $\text{cost}(\mathcal{D}, S)$ is at most $\rho \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \lambda \cdot |S|\right).$ \medskip In both the work of Jain and Vazirani~\cite{jain2001lagrangian} and the work of Ahmadian et al.~\cite{ahmadian2017better}, they start with a weaker type of algorithm, called a \emph{Lagrangian Multiplier Preserving} (LMP) approximation algorithm. To explain this notion, let $\text{OPT}(\lambda)$ represent the optimum (minimum) for the modified linear program $\text{LP}'(\lambda)$, which is the same as $\text{LP}(\lambda)$ except without the subtraction of $\lambda \cdot k$ in the objective function \eqref{eq:lp_A'}. (So, $\text{LP}'(\lambda)$ has no dependence on $k$). Note that this is also the optimum (maximum) for $\text{DUAL}'(\lambda)$, which is the same as $\text{DUAL}(\lambda)$ except without the subtraction of $\lambda \cdot k$ in the objective function \eqref{eq:lp_E}. Then, for some fixed $\lambda \ge 0$, we say that a $\rho$-approximation algorithm is \emph{LMP} if it returns a solution $S \subset \mathcal{F}$ satisfying \[\sum_{j \in \mathcal{D}} c(j, S) \le \rho \cdot \left(\text{OPT}(\lambda) - \lambda \cdot |S|\right).\] Indeed, if we could find a choice of $\lambda$ and an LMP $\rho$-approximate solution $S$ with size $|S| = k$, we would have found a $\rho$-approximation for $k$-means (or $k$-median) clustering. \subsection{Witnesses and Conflict Graphs} \label{subsec:witness_and_conflict} Jain and Vazirani \cite{jain2001lagrangian} proposed a simple primal-dual approach to create a feasible solution $\alpha$ of $\text{DUAL}(\lambda)$ with certain additional properties that are useful for providing an efficient solution to the original $k$-median (or $k$-means) problem efficiently. We describe it briefly as follows, based on the exposition of Ahmadian et al.~\cite[Subsection 3.1]{ahmadian2017better}. Start with $\alpha = \textbf{0}$, i.e., $\alpha_j = 0$ for all $j \in \mathcal{D}$. We increase all $\alpha_j$'s continuously at a uniform rate, but stop growing each $\alpha_j$ once one of the following two events occurs: \begin{enumerate} \item For some $i \in \mathcal{F}$, a dual constraint $\sum_{j \in \mathcal{D}} \max(\alpha_j-c(j, i), 0) \le \lambda$ becomes tight (i.e., reaches equality). Once this happens, we stop growing $\alpha_j$, and declare that facility $i$ is \emph{tight} for all $i$ such that the constraint became equality. In addition, we will say that $i$ is the \emph{witness} of $j$. \item For some already tight facility $i$, we grow $\alpha_j$ until $\alpha_j = c(j, i)$. In this case, we also say that $i$ is the \emph{witness} of $j$. \end{enumerate} We note that this process must eventually terminate for all $j$ (e.g., once $\alpha_j$ reaches $\min_{i \in \mathcal{F}} c(j, i)+\lambda$). This completes our creation of the dual solution $\alpha$ (it is simple to see that $\alpha$ is feasible). For any client $j$, we define $N(j) := \{i \in \mathcal{F}: \alpha_j > c(j, i)\}$, and likewise, for any client $i$, we define $N(i) := \{j \in \mathcal{D}: \alpha_j > c(j, i)\}$. For any tight facility $i$, we will define $t_i := \max_{j \in N(i)} \alpha_j$, where $t_i = 0$ by default if $N(i) = \emptyset$. For each client $j$, its witness $i$ will have the useful properties that $t_{i} \le \alpha_j$ and $c(j, i) \le \alpha_j$. We have already created our dual solution $\alpha$: to create our set of $k$ facilities, we will choose a subset of the tight facilities. First, we define the \textit{conflict graph} on the set of tight facilities. Indeed, Jain and Vazirani \cite{jain2001lagrangian}, Ahmadian et al. \cite{ahmadian2017better}, and we all have slightly different definitions: so we contrast the three. \begin{itemize} \item \cite{jain2001lagrangian} Here, we say that $(i, i')$ forms an edge in the conflict graph $H$ if there exists a client $j$ such that $i, i' \in N(j)$ (or equivalently, $\alpha_j \ge c(j, i)$ and $\alpha_j \ge c(j, i')$). \item \cite{ahmadian2017better} Here, we say that $(i, i')$ forms an edge in the conflict graph $H(\delta)$ (where $\delta > 0$ is some parameter) if $c(i, i') \le \delta \cdot \min(t_i, t_{i'})$ and there exists a client $j$ such that $i, i' \in N(j)$. \item In our definition, we completely drop the condition from \cite{jain2001lagrangian}, and just say that $(i, i')$ forms an edge in the conflict graph $H(\delta)$ if $c(i, i') \le \delta \cdot \min(t_i, t_{i'})$. \end{itemize} It turns out that in the algorithm of Ahmadian et al.~\cite{ahmadian2017better}, the approximation factor is not affected by whether they use their definition or our definition. But in our case, it turns out that dropping the condition from \cite{jain2001lagrangian} in fact allows us to obtain a better approximation. To provide an LMP approximation, both Jain and Vazirani~\cite{jain2001lagrangian} and Ahmadian et al.~\cite{ahmadian2017better} constructed a maximal independent set $I$ of the conflict graph $H$ (or $H(\delta)$ for an appropriate choice of $\delta > 0$) and used $I = S$ as the set of centers. For Jain and Vazirani's definition, the independent set $I$ obtains an LMP $9$-approximation for metric $k$-means. For Ahmadian et al.'s definition, the independent set $I$ obtains an LMP $6.1291$-approximation for Euclidean $k$-means if $\delta$ is chosen properly. (We note that Ahmadian et al. only proved a factor of $6.3574$, though their argument can be improved to show a $6.1291$-approximation factor as proven by Grandoni et al.~\cite{Grandoni21}). While we will not explicitly prove it, our definition of $H(\delta)$ also obtains the same bound with the same choice of $\delta$. For the Euclidean $k$-median problem, using either Ahmadian et al.'s or our definition, one can obtain an LMP $(1+\sqrt{2})$-approximation: Ahmadian et al.~\cite{ahmadian2017better} only proved it for the weaker $1+\sqrt{8/3}$ approximation factor, but we prove the improved approximation in Subsection \ref{subsec:lmp_k_median_easy}. We then show how to obtain a better LMP solution and then a better approximation bound. \section{Technical Overview} \label{sec:overview} The algorithms of both Jain and Vazirani \cite{jain2001lagrangian} and Ahmadian et al \cite{ahmadian2017better} begin by constructing an LMP approximation. Their approximation follows two phases: a \emph{growing} phase and a \emph{pruning} phase. In the growing phase, as described in Subsection \ref{subsec:witness_and_conflict}, they grow the solution $\alpha$ starting from $\alpha = \textbf{0}$, until they obtain a suitable dual solution $\alpha$ for $\text{DUAL}(\lambda)$. In addition, they have a list of \emph{tight} facilities $i$, which we think of as our candidate centers. The pruning phase removes unnecessary facilities: as described in Subsection \ref{subsec:witness_and_conflict}, we create a conflict graph $H(\delta)$ over the tight facilities, and only choose a maximal independent set $I$. Hence, we are pruning out tight facilities to make sure we do not have too many nearby facilities. This way we ensure that the total number of centers is not unnecessarily large. Our main contributions are to improve the pruning phase with a new algorithm and several new geometric insights, and to show how our LMP approximation can be extended to improved algorithms for standard Euclidean $k$-means (and $k$-median) clustering. \paragraph{Improved LMP Approximation:} To simplify the exposition, we focus on Euclidean $k$-means. To analyze the approximation, Ahmadian et al.~\cite{ahmadian2017better} compare the cost of each client $j$ in the final solution to its contribution to the dual objective function. The cost of a client $j$ is simply $c(j, I)$ where $I$ is our set of centers, and $j$'s contribution to the dual is $\alpha_j - \sum_{i \in N(j) \cap I} (\alpha_j-c(j, i))$, where we recall the definition of $N(j)$ from Subsection \ref{subsec:witness_and_conflict}. One can show that the sum of the individual dual contributions equals the dual objective \eqref{eq:lp_E}. By casework on the size $a = |N(j) \cap I|$, \cite{Grandoni21} (by modifying the work of \cite{ahmadian2017better}) shows that $c(j, I) \le \rho \cdot \left[\alpha_j - \sum_{i \in N(j) \cap I} (\alpha_j-c(j, i))\right],$ where $\rho \approx 6.1291$ if $\delta \approx 2.1777$ is chosen appropriately (in general, we think of $\delta$ as slightly greater than $2$). The only bottlenecks (i.e., where the cost-dual ratio could equal $\rho$) are when $a \in \{0, 2\}$. Our LMP approximation improves the pruning phase by reducing the cost-dual ratio in these cases. Due to the disjointed nature of the bottleneck cases, our first observation was that averaging between two or more independent sets may be beneficial. This way, if for some client $j$, the first independent set $I_1$ had $a = 0$ and the second set $I_2$ had $a = 2$, perhaps by taking a weighted average of $I_1$ and $I_2$ we can obtain a set $I$ where $a = 1$ with reasonable probability. Hence, the expected cost-dual ratio of $j$ will be below $\rho$. The second useful observation comes from the fact that $t_{i^*} \le \alpha_j$ and $c(j, i^*) \le \alpha_j$, if $i^*$ is the witness of $j$. In the $a=0$ case, \cite{ahmadian2017better} applies this to show that $d(j, i^*) \le \sqrt{\alpha_j}$ and $d(i^*, I) \le \sqrt{\delta \cdot t_{i^*}} \le \sqrt{\delta \cdot \alpha_j}$, which follows by the definition of conflict graph. Hence, the bottleneck occurs when $i^*$ has distance exactly $\sqrt{\alpha_j}$ from $j$, and the nearest point $i \in I$ has distance exactly $\sqrt{\delta \cdot \alpha_j}$ from $i^*$, in the direction opposite $j$. This causes $c(j, I)$ to be $(1+\sqrt{\delta})^2 \cdot \alpha_j$ in the worst case, whereas $j$'s contribution to the dual is merely $\alpha_j$. To reduce this ratio, we either need to make sure that the distance from $i^*$ to either $j$ or $i$ is smaller, or that $j, i^*, i$ do not lie in a line in that order. A reasonable first attempt is to select two choices $\delta_1 \ge \delta \ge \delta_2$, and consider the nested conflict graphs $H(\delta_1) \supset H(\delta_2)$. We can then create nested independent sets by first creating $I_1$ as a maximal independent set of $H(\delta_1)$, then extending it to $(I_1 \cup I_2) \supset I_1$ for $H(\delta_2)$. Our final set $S$ will be an average of $I_1$ and $(I_1 \cup I_2)$: we include all of $I_1$ and each point in $I_2$ with some probability. The motivation behind this attempt is that if both $N(j) \cap I_1$ and $N(j) \cap I_2$ are empty, the witness $i^*$ of $j$ should be adjacent in $H(\delta_1)$ to some point $i_1 \in I_1$, and adjacent in $H(\delta_2)$ to some point $i_2 \in (I_1 \cup I_2)$. Hence, either $i_1 = i_2$, in which case the distance from $j$ to $I_1$ is now only $(1+\sqrt{\delta_2}) \cdot \sqrt{\alpha_j}$ instead of $(1+\sqrt{\delta_1}) \cdot \sqrt{\alpha_j}$ (see Figure \ref{fig:1a}), or $i_1 \neq i_2$, in which case $i_1, i_2$ must be far apart because $i_1, i_2$ are both in the independent set $I_1 \cup I_2$ (see Figure \ref{fig:1b}). In the latter case, we cannot have the bottleneck case for both $i_1$ and $i_2$, as that would imply $j, i^*, i_2, i_1$ are collinear in that order with $d(i^*, i_2) = \sqrt{\delta_2 \cdot \alpha_j}$ and $d(i^*, i_1) = \sqrt{\delta_1 \cdot \alpha_j}$, so $i_2, i_1$ are too close. Hence, it appears that we have improved one of the main bottlenecks. Unfortunately, we run into a new issue, if $i_2 = j$ and no other points in $I_1 \cup I_2$ were in $N(j)$. While this case may look good because $|N(j) \cap I_2| = 1$ which is not a bottleneck, it is only not a bottleneck because the contribution of $j$ to the clustering cost and the dual both equal $0$ in this case. So, if we condition on $i_2 \in S$, the cost and dual are not affected by $j$, but if we condition on $i_2 \not\in S$, the cost-dual ratio of $j$ could be $(1+\sqrt{\delta_1})^2$ -- hence, we have again made no improvement. While one could attempt to fix this by creating a series of nested independent sets, this approach also fails to work for the same reasons. Hence, we have a new main bottleneck case, where $i_2 = j$, and $j, i^*, i_1$ are collinear in that order with $d(j, i^*) = \sqrt{\alpha_j}$ and $d(i^*, i_1) = \sqrt{\delta_1 \cdot \alpha_j}$ (see Figure \ref{fig:1c}). We now explain the intuition for fixing this. In the main bottleneck case, if we could add the witness $i^*$ of $j$ to $S$, this would reduce $c(j, S)$ significantly if $i_2 \not\in S$, yet does not affect $j$'s contribution to the dual. Unfortunately, adding $i^*$ to $S$ reduces the dual nonetheless, due to other clients. Instead, we will consider a subset of tight facilities that are close, but not too close, to exactly one tight facility in $I_2$ but not close to any other facilities in $I_1 \cup I_2$. In the main bottleneck cases, the witnesses $i^*$ precisely satisfy the condition, as may some additional points. We again prune these points by creating a conflict graph just on these vertices, and pick another maximal independent set $I_3$. Finally, with some probability we will replace each point $i_2 \in I_2$ with the points in $I_3$ that are close to $i_2$. In our main bottleneck case, we will either pick $i^* \in I_3$, or pick another point $i_3$ that is within distance $\sqrt{\delta_1 \cdot \alpha_j}$ of $i^*$, but now must be far from all points in $I_1 \cup I_2$ and therefore will not have distance $(1+\sqrt{\delta_1}) \cdot \sqrt{\alpha_j}$ from $j$ (see Figure \ref{fig:1c}). In addition, $i_3$ might be close, but is not allowed to be too close to $i_2 = j$, so if we replace $i_2$ with $i_3$, we do not run into the issue of $j$'s contribution being $0$ for both the clustering cost and the dual solution. Given $I_1, I_2, I_3$, our overall procedure for generating $S$ is to include all of $I_1$, and include points in $I_2$ and $I_3$ with some probability. In addition, each point $i_3 \in I_3$ is close to a unique point $i_2 \in I_2$, and we anti-correlate them being in $S$. We call the triple $(I_1, I_2, I_3)$ a \emph{nested quasi-independent set}, since $I_1$ and $I_1 \cup I_2$ are independent sets and $I_1 \cup I_2 \cup I_3$ has similar properties, and these sets $I_1, I_1 \cup I_2, I_1 \cup I_2 \cup I_3$ are nested. We remark that the anti-correlation between selecting $i_2$ and points $i_3$ that are close to $i_2$ is reminiscent of a step of the rounding of bipoint solution of Li and Svensson~\cite{LiS16} (there the authors combine two solutions by building a collection of stars where the center of the star belongs to a solution, while the leaves belong to another, and choose to open either the center, or the leaves at random). In this context, we will also allow our algorithm to open slightly $k + C$ centers (instead of $k$) for some absolute constant $C$. Similar to Li and Svensson~\cite{LiS16} and Byrka et al.~\cite{ByrkaPRST17}, we show (Lemma~\ref{lem:center-reduction}) that this is without loss of generality (such an algorithm can be used to obtain an approximation algorithm opening at most $k$ centers). The analysis of the approximation bound is very casework heavy, depending on the values of $a=|N(j) \cap I_1|,$ $b=|N(j) \cap I_2|$, and $c=|N(j) \cap I_3|$ for each $j$, and requiring many geometric insights that heavily exploit the structure of the Euclidean metric. \begin{figure}[htbp] \centering \subfigure[]{ \begin{tikzpicture}[scale=2.0] \node[circle, scale=0.7, fill=gray!50] (1) at (0.0, 0) {$j$}; \node[circle, scale=0.7, fill=gray!50] (2) at (0.0, -1) {$i^*$}; \node[circle, scale=0.7, fill=gray!50] (3) at (0.0, -2.4) {$i_1$}; \node[scale=0.7] at (0.3,-2.4) {$=i_2$}; \draw (1) -- (2); \draw (2) -- (3); \draw[dotted] (1) to [bend right] (3); \node[scale=0.8] at (0.1,-0.5) {$\sqrt{\alpha_j}$}; \node[scale=0.8] at (0.2,-1.7) {$\sqrt{\delta_2 \cdot \alpha_j}$}; \label{fig:1a} \end{tikzpicture} } \hspace{2cm} \subfigure[]{ \begin{tikzpicture}[scale=2.0] \node[circle, scale=0.7, fill=gray!50] (1) at (0, 0) {$j$}; \node[circle, scale=0.7, fill=gray!50] (2) at (0, -1) {$i^*$}; \node[circle, scale=0.7, fill=gray!50] (3) at (0.7, -2.3) {$i_1$}; \node[circle, scale=0.7, fill=gray!50] (4) at (-0.7, -2.1) {$i_2$}; \draw (1) -- (2); \draw (2) -- (3); \draw (2) -- (4); \draw (3) -- (4); \draw[dotted] (1) -- (3); \draw[dotted] (1) -- (4); \node[scale=0.8] at (0.1,-0.5) {$\sqrt{\alpha_j}$}; \node[rotate=58, scale=0.8] at (-0.43,-1.5) {$\sqrt{\delta_2 \cdot \alpha_j}$}; \node[rotate=-61, scale=0.8] at (0.42,-1.56) {$\sqrt{\delta_1 \cdot \alpha_j}$}; \node[rotate=-8, scale=0.8] at (-0.02,-2.34) {$\sqrt{\delta_2 \cdot \alpha_j}$}; \label{fig:1b} \end{tikzpicture} } \hspace{2cm} \subfigure[]{ \begin{tikzpicture}[scale=2.0] \node[circle, scale=0.7, fill=gray!50] (1) at (0.0, 0) {$j$}; \node[circle, scale=0.7, fill=gray!50] (2) at (0.0, -1) {$i^*$}; \node[circle, scale=0.7, fill=gray!50] (3) at (0.0, -2.6) {$i_1$}; \node[scale=0.7] at (0.3,0) {$=i_2$}; \node[circle, scale=0.7, fill=blue!30] (4) at (0.5, -0.4) {$i_3$}; \draw (1) -- (2); \draw (2) -- (3); \draw[dotted] (1) -- (4); \draw[dotted] (1) to [bend right] (3); \node[scale=0.8] at (0.1,-0.5) {$\sqrt{\alpha_j}$}; \node[scale=0.8] at (0.2,-1.8) {$\sqrt{\delta_1 \cdot \alpha_j}$}; \label{fig:1c} \end{tikzpicture} } \label{fig:euclidean} \caption{Subfigures (a) and (b) represent the cases when $N(j) \cap I_1, N(j) \cap I_2$ are both empty. In (a), we can bound $d(i^*, i_1)$ as $\sqrt{\delta_2 \cdot \alpha_j} < \sqrt{\delta_1 \cdot \alpha_j}$, and in (b), we can obtain better bounds for $d(j, i_1)$ and $d(j, i_2)$ than by just the triangle inequality. Subfigure (c) represents the problem with having nested two independent sets, when $N(j) \cap I_1 = \emptyset$ but $N(j) \cap I_2$ has a unique point $i_2 = j$. If we replace $i_2 = j$ with the blue node $i_3$ with some probability, the cost-to-dual ratio improves.} \end{figure} Finally, we remark that this method of generating a set $S$ of centers also can be used to provide an LMP approximation below $1+\sqrt{2}$ for Euclidean $k$-median. However, due to the differing nature of what the bottleneck cases are, the choices of $\delta_1, \delta_2$, and the construction of the final set $I_3$ will differ. Both to obtain and break the $1+\sqrt{2}$-approximation for Euclidean $k$-median, one must understand how the sum of distances from a facility $j$ to its close facilities $i_1, \dots, i_a \in N(j) \cap S$ relates to the pairwise distances between $i_1, \dots, i_a$. In the $k$-means case, the squared distances make this straightfoward, but the $k$-median case requires more geometric insights (see Lemma \ref{lem:geometric_median}) to improve the $1+\sqrt{8/3}$-approximation of Ahmadian et al.~\cite{ahmadian2017better} to a $1+\sqrt{2}$-approximation, even with the same algorithm. \paragraph{Polynomial-Time Algorithm:} While we can successfully obtain an LMP $(3+2\sqrt{2})$-approximation for Euclidean $k$-means, this does not imply a $(3+2\sqrt{2})$-approximation for the overall Euclidean $k$-means problem, since our LMP approximation may not produce the right number of cluster centers. To address this issue, Ahmadian et al.~\cite{ahmadian2017better} developed a method of slowly raising the parameter $\lambda$ and generating a series of dual solutions $\alpha^{(0)}, \alpha^{(1)}, \alpha^{(2)}, \dots$, where each pair of consecutive solutions $\alpha^{(j)}$ and $\alpha^{(j+1)}$ are sufficiently similar. The procedure of generating dual solutions $\alpha^{(j)}$ in~\cite{ahmadian2017better} is very complicated, but will not change significantly from their result to ours. Given these dual solutions, \cite{ahmadian2017better} shows how to interpolate between consecutive dual solutions $\alpha^{(j)}$ and $\alpha^{(j+1)}$, creating a series of conflict graphs where the subsequent graph removes at most one facility at a time (but occasionally adds many facilities). This property of removing at most one facility ensures that the maximal independent set decreases by at most 1 at each step (but could increase by a large number if the removed vertex allows for more points to be added). Using an intermediate-value theorem, they could ensure that at some point, there is an independent set $I$ of the conflict graph with size exactly $k$. Hence, they apply the LMP technique to obtain the same approximation ratio. In our setting, we are not so lucky, because we are dealing with nested independent sets (and even more complicated versions of them). Even if the size of the first part $I_1$ never decreases by more than $1$ at a time, $I_1$ could increase which could potentially make the sizes of $I_2$ or $I_3$ decrease rapidly, even if we only remove one facility from the conflict graph. To deal with this, we instead consider the first time that the expected size of $S$ drops below $k$ (where we recall that all points in $I_1$ are in $S$, but points in $I_2$ and $I_3$ are inserted into our final set $S$ with some probability). Let $(I_1, I_2, I_3)$ represent the set of chosen facilities right before the expected size of $S$ drops below $k$ for the first time, and $(I_1', I_2', I_3')$ represent the set of chosen facilities right after. To obtain size exactly $k$, we show that one can always do one of the following: either (i) modify the probabilities of selecting points in $I_2$ and $I_3$ so that the size is exactly $k$, or (ii) use submodularity properties of the $k$-means objective function to interpolate between the set $S$ generated by $(I_1, I_2, I_3)$ and the set $S'$ generated by $(I_1', I_2', I_3')$. While $|S| \ge k$ and $|S'| < k$, we do not necessarily have that $S' \subset S$, and in fact we will interpolate between $S'$ and $S \cup S'$ instead by adding random points from $S \backslash S'$ to $S'$. These procedures are relatively computational and require a good understanding of how the dual objective behaves as we modify the probabilities of selecting elements. In addition, because we modify the probabilities to make the size exactly $k$ and because we interpolate between $S'$ and $S \cup S'$ instead of $S'$ and $S$ to obtain our final set of centers, we lose a slight approximation factor from the LMP approximation, but we still significantly improve over the old bound. In addition, this procedure works well for the Euclidean $k$-means \emph{and} $k$-median problems. One minor problem that we will run into is that a point $i_2$ may have many points in $I_3$ that are all ``close'' to it. As a result, even if the expected size of $S$ is exactly $k$, the variance may be large because we are either selecting $i_2$ or all of the points that are close to $i_2$. In this case, we can use the submodularity properties of the $k$-means objective and coupling methods from probability theory to show that if $i_2$ has too many close points in $I_3$, we could instead include $i_2$ and include an average number of these close points from $I_3$, without increasing the expected cost. \section{LMP Approximation for Euclidean $k$-means} \label{sec:lmp_k_means} In this section, we provide a $(3+2\sqrt{2})$ LMP approximation algorithm (in expectation) for the Euclidean $k$-means problem. Our algorithm will be parameterized by four parameters, $\delta_1, \delta_2, \delta_3$, and $p$. We fix $\delta_1, \delta_2, \delta_3$ and allow $p$ to vary, and obtain an approximation constant $\rho(p)$ that is a function of $p$: for appropriate choices of $p$, $\rho(p)$ will equal $3+2\sqrt{2}$. In Subsection \ref{subsec:k_means_alg}, we describe the LMP algorithm, which is based on the LMP approximation algorithms by Jain and Vazirani~\cite{jain2001lagrangian} and Ahmadian et al.~\cite{ahmadian2017better}, but using our technique of generating what we call a nested quasi-independent set. In Subsection \ref{subsec:lmp_k_means_bash}, we analyze the approximation ratio, which spans a large amount of casework. \subsection{The algorithm and setup} \label{subsec:k_means_alg} Recall the conflict graph $H := H(\delta)$, where we define two tight facilities $(i, i')$ to be connected if $c(i, i') \le \delta \cdot \min(t_i, t_{i'}).$ We set parameters $\delta_1 \ge \delta_2 \ge 2 \ge \delta_3$ and $0 < p < 1$, and define $V_1$ to be the set of all tight facilities. Given the set of tight facilities $V_1$ and conflict graphs $H(\delta)$ over $V_1$ for all $\delta > 0$, our algorithm works by applying the procedure described in Algorithm \ref{alg:lmp} (on the next page) to $V_1$, with parameters $\delta_1, \delta_2, \delta_3$, and $p$. \begin{figure}[htbp] \centering \begin{algorithm}[H] \caption{Generate a Nested Quasi-Independent Set of $V_1$, as well as a set of centers $S$ providing an LMP approximation for Euclidean $k$-means}\label{alg:lmp} \Call{LMP}{$V_1, \{H(\delta)\}, \delta_1, \delta_2, \delta_3, p$}: \begin{algorithmic}[1] \State Create a maximal independent set $I_1$ of $H(\delta_1)$. \label{step:I1} \State Let $V_2$ be the set of points in $V_1 \backslash I_1$ that are not adjacent to $I_1$ in $H(\delta_2)$. \label{step:V2} \State Create a maximal independent set $I_2$ of the induced subgraph $H(\delta_2)[V_2]$. \label{step:I2} \State Let $V_3$ be the set of points $i$ in $V_2 \backslash I_2$ such that there is exactly one point in $I_2$ that is a neighbor of $i$ in $H(\delta_2)$, there are no points in $I_1$ that are neighbors of $i$ in $H(\delta_2)$, and there are no points in $I_2$ that are neighbors of $i$ in $H(\delta_3)$. \label{step:V3} \State Create a maximal independent set $I_3$ of the induced subgraph $H(\delta_2)[V_3]$. \label{step:I3} \State Note that every point $i \in I_3$ has a unique adjacent neighbor $q(i) \in I_2$ in $H(\delta_2)$. We create the final set $S$ as follows: \label{step:S} \begin{itemize} \item Include every point $i \in I_1$. \item For each point $i \in I_2$, flip a fair coin. If the coin lands heads, include $i$ with probability $2p$. Otherwise, include each point in $q^{-1}(i)$ independently with probability $2p$. \end{itemize} \end{algorithmic} \end{algorithm} \end{figure} \iffalse \begin{enumerate} \item Create a maximal independent set $I_1$ of $H(\delta_1)$. \label{step:I1} \item Let $V_2$ be the set of points in $V_1 \backslash I_1$ that are not adjacent to $I_1$ in $H(\delta_2)$. \label{step:V2} \item Create a maximal independent set $I_2$ of the induced subgraph $H(\delta_2)[V_2]$. \label{step:I2} \item Let $V_3$ be the set of points $i$ in $V_2 \backslash I_2$ such that there is exactly one point in $I_2$ that is a neighbor of $i$ in $H(\delta_2)$, there are no points in $I_1$ that are neighbors of $i$ in $H(\delta_2)$, and there are no points in $I_2$ that are neighbors of $i$ in $H(\delta_3)$. \label{step:V3} \item Create a maximal independent set $I_3$ of the induced subgraph $H(\delta_2)[V_3]$. \label{step:I3} \item Note that every point $i \in I_3$ has a unique adjacent neighbor $q(i) \in I_2$ in $H(\delta_2)$. We create the final set $S$ as follows: \label{step:S} \begin{itemize} \item Include every point $i \in I_1$. \item For each point $i \in I_2$, flip a fair coin. If the coin lands heads, include $i$ with probability $2p$. Otherwise, include each point in $q^{-1}(i)$ independently with probability $2p$. \end{itemize} \end{enumerate} \fi We will call the triple $(I_1, I_2, I_3)$ generated by Algorithm \ref{alg:lmp} a \textbf{nested quasi-independent set}. Although $I_1, I_2, I_3$ are disjoint, we call it a nested quasi-independent set since $I_1 \subset I_1 \cup I_2 \subset I_1 \cup I_2 \cup I_3$ are nested, and $I_1$ is a maximal independent set for $H(\delta_1)$ and $I_1 \cup I_2$ is a maximal independent set for $H(\delta_2)$. While $I_1 \cup I_2 \cup I_3$ is not an independent set, it shares similar properties. As described in the technical overview (and in Algorithm \ref{alg:lmp}), the LMP approximation algorithm uses $(I_1, I_2, I_3)$ to create our output set of centers $S$. $S$ contains all of $I_1$ and each point in $I_2 \cup I_3$ with probability $p$, but the choices of which points in $I_2 \cup I_3$ are in $S$ are not fully independent. \iffalse We have the following result regarding witnesses. \begin{proposition} For every client $j \in \mathcal{D}$, there exists a tight facility $w(j)$ such that $t_{w(j)} \le \alpha_j$. In addition, $c(j, w(j)) \le \alpha_j$. \end{proposition} Finally, we also have the following result regarding neighbors. \begin{proposition} For every client $j$ and tight facility $i$ such that $c(j, i) < \alpha_j$, we have that $t_i \ge \alpha_j$. \end{proposition} \fi For the dual solution $\alpha = \{\alpha_j\}_{j \in \mathcal{D}}$ and values $t_i$ for tight $i$ as generated as in Subsection \ref{subsec:witness_and_conflict}, we note the following simple yet crucial facts. \begin{proposition} \label{prop:t_bounds} \cite{ahmadian2017better} The following hold. \begin{enumerate} \item For any client $j$ and its witness $i$, $i$ is tight and $\alpha_j \ge t_i$. \item For any client $j$ and its witness $i$, $\alpha_j \ge c(j, i)$. \item For any tight facility $i$ and any client $j' \in N(i)$, $t_i \ge \alpha_{j'}$. \end{enumerate} \end{proposition} These will essentially be the only facts relating witnesses and clients that we will need to use. \subsection{Main lemma} \label{subsec:lmp_k_means_bash} We consider a more general setup, as it will be required when converting the LMP approximation to a full polynomial-time algorithm. Let $\mathcal{V} \subset \mathcal{F}$ be a subset of facilities (for instance, this may represent the set of tight facilities) and let $\mathcal{D}$ be the full set of clients. For each $j \in \mathcal{D},$ let $\alpha_j \ge 0$ be some real number, and for each $i \in \mathcal{V}$, let $t_i \ge 0$ be some real number. For each client $j \in \mathcal{D}$, we associate with it a set $N(j) \subset \mathcal{V}$. (For instance, this could be the set $N(j) = \{i \in \mathcal{V}: \alpha_j > c(j, i)\}$). In addition, suppose that for each client $j \in \mathcal{D},$ there exists a ``witness'' facility $w(j) \in \mathcal{V}$. Finally, suppose that we have the following assumptions. (These assumptions will hold by Proposition \ref{prop:t_bounds} when $\alpha = \{\alpha_j\}$ is generated by the procedure in Subsection \ref{subsec:witness_and_conflict}, $\mathcal{V}$ is the set of tight facilities, and $N(j) = \{i \in \mathcal{V}: \alpha_j > c(j, i)\}.$) \begin{enumerate} \item For any client $j \in \mathcal{D}$, the witness $w(j) \in \mathcal{V}$ satisfies $\alpha_j \ge t_{w(j)}$ and $\alpha_j \ge c(j, w(j))$. \item For any client $j \in \mathcal{D}$ and any facility $i \in N(j)$, $t_i \ge \alpha_{j} > c(j, i)$. \end{enumerate} For the Euclidean k-means problem with the above assumptions, we will show the following: \begin{lemma} \label{lem:main_lmp} Consider the set of conflict graphs $\{H(\delta)\}_{\delta > 0}$ created on the vertices $\mathcal{V}$, where $(i, i')$ is an edge in $H(\delta)$ if $c(i, i') \le \delta \cdot \min(t_i, t_{i'})$. Fix $\delta_1 = \frac{4+8\sqrt{2}}{7} \approx 2.1877, \delta_2 = 2, \delta_3 = 6-4\sqrt{2} \approx 0.3432,$ and let $p < 0.5$ be variable. Now, let $S$ be the randomized set created by applying Algorithm \ref{alg:lmp} on $V_1 = \mathcal{V}$. Then, for any $j \in \mathcal{D}$, \begin{equation} \mathbb E[c(j, S)] \le \rho(p) \cdot \mathbb E\left[\alpha_j - \sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right], \label{eq:main_lmp} \end{equation} where $\rho(p)$ is some constant that only depends on $p$ (since $\delta_1, \delta_2, \delta_3$ are fixed). \end{lemma} \begin{remark} While we have not defined $\rho(p)$, we will implicitly define it through our cases. We provide detailed visualizations of the bounds we obtain for each of our cases in Desmos (see Appendix \ref{app:files} for the links). Importantly, we show that we can set $p$ such that $\rho(p) \le 3+2\sqrt{2}$. \end{remark} To see why Lemma \ref{lem:main_lmp} implies an LMP approximation (in expectation), fix some $\lambda \ge 0$. Then, we perform the procedure in Subsection \ref{subsec:witness_and_conflict} and let $\mathcal{V}$ be the set of tight facilities, $N(j) = \{i \in \mathcal{V}: \alpha_j > c(j, i)\}$, and $N(i) = \{j \in \mathcal{D}: \alpha_j > c(j, i)\}$. Then, by adding \eqref{eq:main_lmp} over all $j \in \mathcal{D}$, we have that \begin{align*} \mathbb E[\text{cost}(\mathcal{D}, S)] &\le \rho(p) \cdot \mathbb E\left[\sum_{j \in \mathcal{D}} \alpha_j - \sum_{j \in \mathcal{D}} \sum_{i \in N(j) \cap S} (\alpha_j-c(j,i))\right] \\ &= \rho(p) \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \mathbb E\left[\sum_{i \in S} \sum_{j \in N(i)} (\alpha_j-c(j, i))\right]\right) \\ &= \rho(p) \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \lambda \cdot \mathbb E[|S|]\right). \end{align*} Above, the final line follows because $\sum_{j \in N(i)} (\alpha_j-c(j, i)) = \sum_{j \in \mathcal{D}} \max(\alpha_j-c(j, i), 0) = \lambda$, since $i$ is assumed to be tight. Thus, we obtain an LMP approximation with approximation factor $\rho(p)$ for any choice of $p$. Given this, we now prove Lemma \ref{lem:main_lmp}. \begin{proof}[Proof of Lemma \ref{lem:main_lmp}] We fix $j$ and do casework based on the sizes $a = |N(j) \cap I_1|$, $b = |N(j) \cap I_2|,$ and $c = |N(j) \cap I_3|$. We show that $\mathbb E[c(j, S)] \le \rho(p) \cdot \mathbb E\left[\alpha_j - \sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right]$ for each case of $a, b, c.$ We will call $\mathbb E[c(j, S)]$ the numerator and $\mathbb E\left[\alpha_j - \sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right]$ the denominator, and attempt to show this fraction is at most $\rho(p).$ By scaling all distances (and all $\alpha_j, t_i$ values accordingly), we will assume WLOG that $\alpha_j = 1$, so $d(j, w(j)), t_{w(j)} \le 1$. First, we have the following basic proposition. \begin{proposition} \label{prop:crude_distance} $d(j, S) \le d(j, I_1) \le 1+\sqrt{\delta_1}$. \end{proposition} \begin{proof} Note that $d(j, I_1) \le d(j, w(j)) + d(w(j), I_1)$. But $d(j, w(j)) \le 1$ and by properties of the independent set $I_1$, there exists $i_1 \in I_1$ such that $d(w(j), i_1) \le \sqrt{\delta_1 \cdot \min(t_{w(j)}, t_{i_1})} \le \sqrt{\delta_1}$, since $t_{w(j)} \le 1$. So, $d(j, I_1) \le 1 + \sqrt{\delta_1}$, as desired. \end{proof} In addition, we have the following simple proposition about Euclidean space, the proof of which is deferred to Appendix \ref{app:bash}. \begin{proposition} \label{prop:triangle} Suppose that we have $4$ points $A, B, C, D$ in Euclidean space and parameters $\nu_1, \nu_2, \nu_3, \sigma_1, \sigma_2, \sigma_3 \ge 0$ such that $d(A, B)^2 \le 1$, $d(B, C)^2 \le \nu_1 \cdot \min(\sigma_1, \sigma_2)$, $d(B, D)^2 \le \nu_2 \cdot \min(\sigma_1, \sigma_3)$, and $d(C, D)^2 \ge \nu_3 \cdot \min(\sigma_2, \sigma_3)$. Moreover, assume that $\sigma_1 \le 1$ and that $\nu_1, \nu_2 \ge \nu_3$. Then, \[p \cdot \|C-A\|_2^2 + (1-p) \cdot \|D-A\|_2^2 \le 1 + p \cdot \nu_1 + (1-p) \cdot \nu_2 + 2\sqrt{p \cdot \nu_1 + (1-p) \cdot \nu_2 - p(1-p) \cdot \nu_3}.\] \end{proposition} Finally, we will also make frequent use of the well-known fact that for any set of $h \ge 1$ points $I = \{i_1, \dots, i_h\}$ and any $j$ in Euclidean space, $\frac{1}{2h} \sum_{i, i' \in I} \|i-i'\|_2^2 \le \sum_{i \in I} \|i-j\|_2^2.$ As a direct result of this, if $c(j, i) \le 1$ for all $i \in I$ but $c(i, i') \ge 2$ for all $i \neq i' \in I$, then $\sum_{i \in I} (1-c(j, i)) \le 1$. \medskip We are now ready to investigate the several cases needed to prove Lemma \ref{lem:main_lmp}. \paragraph{Case 1: $\boldsymbol{a=0, b=1, c=0}$.} Let $i_2$ be the unique point in $I_2 \cap N(j),$ and let $i^* = w(j)$ be the witness of $j$. Recall that $i^*$ is tight, so $i^* \in \mathcal{V}_1$. Note that $d(j, i^*) \le 1$ and $t_{i^*} \le 1$. There are numerous sub-cases to consider, which we enumerate. \begin{enumerate}[label=\alph*)] \item $\boldsymbol{i^* \not\in V_2}$. In this case, either $i^* \in I_1$ so $d(i^*, I_1) = 0$, or there exists $i_1 \in I_1$ such that $d(i^*, i_1) \le \sqrt{\delta_2 \cdot \min(t_{i^*}, t_{i_1})} \le \sqrt{\delta_2}$. So, $d(j, I_1) \le 1+\sqrt{\delta_2}$. In addition, we have that $i_2 \in S$ with probability $p$. So, if we let $t := d(j, i_2)$, we can bound the fraction by \[\frac{p \cdot t^2 + (1-p) \cdot (1+\sqrt{\delta_2})^2}{1-p(1-t^2)} = \frac{p \cdot t^2 + (1-p) \cdot (1+\sqrt{\delta_2})^2}{p \cdot t^2 + (1-p)}.\] Note that $0 \le t < 1$ since $i_2 \in N(j),$ and the above fraction is maximized for $t = 0$, in which case we get that the fraction is at most \begin{equation} \tag{1.a}\label{eq:1.a} (1+\sqrt{\delta_2})^2. \end{equation} \item $\boldsymbol{i^* \in V_3}.$ In this case, there exists $i_3 \in I_3$ (possibly $i_3 = i^*$) such that $d(i^*, i_3) \le \sqrt{\delta_2 \cdot \min(t_{i^*}, t_{i_3})}.$ In addition, there exists $i_1 \in I_1$ such that $d(i^*, i_1) \le \sqrt{\delta_1 \cdot \min(t_{i^*}, t_{i_1})}$. Finally, since $I_3 \subset V_2$, we must have that $d(i_1, i_3) \ge \sqrt{\delta_2 \cdot \min(t_{i_1}, t_{i_3})}$. If we condition on $i_2 \in S$, then the numerator and denominator both equal $c(j, i_2)$, so the fraction is $1$ (or $0/0$). Else, if we condition on $i_2 \not\in S$, then the denominator is $1$, and the numerator is at most $p \cdot \|i_3-j\|_2^2 + (1-p) \cdot \|i_1-j\|_2^2$, since $i_1 \in S$ always, and either $q(i_3) \neq i_2$, in which case $\mathbb P(i_3 \in S|i_2 \not\in S) = p$, or $q(i_3) = i_2$, in which case $\mathbb P(i_3 \in S|i_2 \not\in S) = \frac{p}{1-p} \ge p$. Note that $d(j, i^*) \le 1$, that $t_{i^*} \le 1$, and that $\delta_2, \delta_1 \ge \delta_2$. So, we may apply Proposition \ref{prop:triangle} with $A=j, B=i^*, C=i_3, D=i_1$ and $\nu_1 = \nu_3 = \delta_2, \nu_2 = \delta_1, \sigma_1=t_{i^*}, \sigma_2=t_{i_3}, \sigma_3=t_{i_1}$ to bound numerator (and thus the overall fraction since the denominator equals $1$) by \begin{equation} \tag{1.b}\label{eq:1.b} 1 + p \cdot \delta_2 + (1-p) \cdot \delta_1 + 2\sqrt{p^2 \cdot \delta_2 + (1-p) \cdot \delta_1}. \end{equation} \end{enumerate} In the remaining cases, we may assume that $i^*\in V_2 \backslash V_3$. Then, one of the following must occur: \begin{enumerate}[label=\alph*)] \setcounter{enumi}{2} \item $\boldsymbol{i^* = i_2}$. In this case, define $t = d(j, i^*) \in [0, 1]$, and note that $d(j, I_1) \le d(j, i^*)+d(i^*, I_1) \le t + \sqrt{\delta_1}$. So, with probability $p$, we have that $d(j, S) \le d(j, i^*) = t$, and otherwise, we have that $d(j, S) \le d(j, I_1) = t + \sqrt{\delta_1}$. So, we can bound the ratio by \begin{equation} \tag{1.c}\label{eq:1.c} \max_{0 \le t \le 1} \frac{p \cdot t^2 + (1-p) \cdot (t + \sqrt{\delta_1})^2}{1-p \cdot (1-t^2)} \le \max\left((\sqrt{0.75}+\sqrt{\delta_1})^2, \frac{(1-p) \cdot (1+\sqrt{\delta_1})^2 + 3p/4}{1-p/4}\right). \end{equation} We prove this final inequality in Appendix \ref{app:bash}. \item $\boldsymbol{i^* \in I_2}$ \textbf{but} $\boldsymbol{i^* \neq i_2}$. First, we recall that $d(j, i^*) \le 1$. Now, let $t = d(j, i_2)$. In this case, with probability $p$, $d(j, S) \le t$ (if we select $i_2$ to be in $S$), with probability $p(1-p)$, $d(j, S) \le 1$ (if we select $i^*$ but not $i_2$ to be in $S$), and in the remaining event of $(1-p)^2$ probability, we still have that $d(j, S) \le d(j, I_1) \le 1 + \sqrt{\delta_1}$ by Proposition \ref{prop:crude_distance}. So, we can bound the ratio by \[\max_{0 \le t \le 1} \frac{p \cdot t^2 + p(1-p) \cdot 1 + (1-p)^2 \cdot (1+\sqrt{\delta_1})^2}{1-p \cdot (1-t^2)}.\] Note that this is maximized when $t = 0$ (since the numerator and denominator increase at the same rate when $t$ increases), so we can bound the ratio by \begin{equation} \tag{1.d} \label{eq:1.d} \frac{p(1-p) + (1-p)^2 \cdot (1+\sqrt{\delta_1})^2}{1-p} = p+(1-p) \cdot (1+\sqrt{\delta_1})^2. \end{equation} \item \textbf{There is more than one neighbor of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_2)}$ \textbf{that is in} $\boldsymbol{I_2}$. In this case, there is some other point $i_2' \in I_2$ not in $N(j)$ such that $d(i^*, i_2') \le \sqrt{\delta_2 \cdot \min(t_{i^*}, t_{i_2'})}.$ So, we have four points $j, i^*, i_1 \in I_1, i_2' \in I_2$ such that $d(j, i^*) \le 1,$ $d(i^*, i_2') \le \sqrt{\delta_2 \cdot \min(t_{i^*}, t_{i_2'})},$ $d(i^*, i_1) \le \sqrt{\delta_1 \cdot \min(t_{i^*}, t_{i_1})},$ and $d(i_1, i_2') \ge \sqrt{\delta_2 \cdot \min(t_{i_1}, t_{i_2'})}.$ If we condition on $i_2 \in S$, then the denominator equals $c(j, i_2)$ and the numerator is at most $c(j, i_2)$, so the fraction is $1$ (or $0/0$). Else, if we condition on $i_2 \not\in S$, then the denominator is $1$, and the numerator is at most $p \cdot \|i_2'-j\|_2^2 + (1-p) \cdot \|i_1-j\|_2^2$. Note that $d(j, i^*) \le 1$, that $t_{i^*} \le 1$, and that $\delta_2, \delta_1 \ge \delta_2$. So, as in \ref{eq:1.b}, we may apply Proposition \ref{prop:triangle} to bound the ratio by \begin{equation} \tag{1.e} \label{eq:1.e} 1 + p \cdot \delta_2 + (1-p) \cdot \delta_1 + 2\sqrt{p^2 \cdot \delta_2 + (1-p) \cdot \delta_1}. \end{equation} \item \textbf{There are no neighbors of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_2)}$ \textbf{that are in} $\boldsymbol{I_2}$. In this case, we would actually have that $i^* \in I_2,$ because we defined $I_2$ to be a maximal independent set in the induced subgraph $H(\delta_2)[V_2].$ So, if there were no such neighbors and $i^* \in V_2$, then we could add $i^*$ to $I_2$, contradicting the maximality of $I_2$. Having $i^* \in I_2$ was already covered by subcases c) and d). \item \textbf{There is a neighbor of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_3)}$ \textbf{that is also in} $\boldsymbol{I_2}$, which means that either $d(i^*, i_2) \le \sqrt{\delta_3 \cdot t_{i^*}}$ so $d(i_2, j) \ge \max(0, d(j, i^*)-\sqrt{\delta_3 \cdot t_{i^*}})$, or there is some other point $i_2' \in I_2$ not in $N(j)$ such that $d(i^*, i_2') \le \sqrt{\delta_3 \cdot \min(t_{i^*}, t_{i_2'})}.$ If $d(i^*, i_2) \le \sqrt{\delta_3 \cdot t_{i^*}}$, then define $t = t_{i^*}$ and $u = d(j, i^*)$. In this case, $d(j, I_1) \le u + \sqrt{\delta_1 \cdot t},$ and $d(j, i_2) \ge \max(0, u-\sqrt{\delta_3 \cdot t}).$ Since $t = t_{i^*} \le 1$ and $u = d(j, i^*) \le 1$, we can bound the overall fraction as at most \begin{align} &\hspace{0.5cm} \max_{0 \le t \le 1} \max_{0 \le u \le 1} \max_{d(j, i_2) \ge \max(0, u-\sqrt{\delta_3 \cdot t})} \frac{(1-p) \cdot (u+\sqrt{\delta_1 \cdot t})^2+p \cdot d(j, i_2)^2}{1-p+p \cdot d(j, i_2)^2} \nonumber \\ &\le \max\left((\sqrt{\delta_1}+\sqrt{\delta_3})^2, \frac{(1-p) \cdot (1+\sqrt{\delta_1})^2 + p \cdot (1-\sqrt{\delta_3})^2}{1-p+p \cdot (1-\sqrt{\delta_3})^2}\right). \tag{1.g.i} \label{eq:1.g.i} \end{align} We derive the final inequality in Appendix \ref{app:bash}. Alternatively, if $d(i^*, i_2') \le \sqrt{\delta_3 \cdot \min(t_{i^*}, t_{i_2'})},$ then if we condition on $i_2 \in S,$ the fraction is $1$ (or $0/0$), and if we condition on $i_2 \not\in S$, the denominator is $1$ and the numerator is at most $p \cdot d(j, i_2')^2 + (1-p) \cdot d(j, i_1)^2 \le p \cdot (1+\sqrt{\delta_3})^2+(1-p) \cdot (1+\sqrt{\delta_1})^2.$ (Note that $i_2 \in S$ and $i_2' \in S$ are independent.) Therefore, we can also bound the overall fraction by \begin{equation} \tag{1.g.ii} \label{eq:1.g.ii} p \cdot (1+\sqrt{\delta_3})^2+(1-p) \cdot (1+\sqrt{\delta_1})^2. \end{equation} \item \textbf{There is a neighbor of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_2)}$ \textbf{that is also in} $\boldsymbol{I_1}$. In this case, $i^*$ would not be in $V_2$, so we are back to sub-case 1.a. \end{enumerate} \iffalse \paragraph{Case 2: $(a, b, c) = (0, 1, 1)$.} Let $i_2$ be the unique point in $I_2 \cap N(j)$ and let $i_3$ be the unique point in $I_3 \cap N(j)$. Finally, let $i^* = w(j)$ be the witness of $j$. First, suppose that $i_2, i_3$ are neighbors in $H(\delta_2)$. Then, since $i_3$ has a unique adjacent neighbor in $H(\delta_2) \cap I_2$, we have that $q(i_3) = i_2$. Finally, we still have that $i_2, i_3$ are not connected in $H(\delta_3)$. So, there are two options: \begin{enumerate} \item $q(i_3) = i_2$ and $d(i_2, i_3) \ge \sqrt{\delta_3 \cdot \min(t_{i_2}, t_{i_3})}.$ \item $d(i_2, i_3) \ge \sqrt{\delta_2 \cdot \min(t_{i_2}, t_{i_3})}$. \end{enumerate} Now, note that since $i_2, i_3$ are not in $I_1$, we either have that the witness $i^*$ is in $I_1$, in which case $d(j, I_1) = 1$, or all of $i_2, i_3, i^*$ are adjacent to $I_1$ in $H(\delta_1)$ since $I_1$ was a maximal independent set in $H(\delta_1)$. Therefore, if we define $\beta = d(j, i_2)$ and $\gamma = d(j, i_3)$, this means that $d(j, I_1) \le \min\left(1+\sqrt{\delta_1}, \beta+\sqrt{\delta_1 \cdot t_{i_2}}, \gamma+\sqrt{\delta_1 \cdot t_{i_3}}\right),$ and $d(i_2, i_3) \le \beta+\gamma.$ Overall, we will bound the ratio by $$\frac{(1-2p) \cdot \min(1+\sqrt{\delta_1}, \beta+\sqrt{\delta_1 \cdot t_{i_2}}, \gamma +\sqrt{\delta_1+t_{i_3}})^2 + p \cdot \beta^2 + p \cdot \gamma^2}{1-p (1-\beta^2) - p (1-\gamma^2)}$$ in the first case, where $\beta+\gamma \ge \sqrt{\delta_3 \cdot \min(t_{i_2}, t_{i_3})}$, and by $$\frac{(1-p)^2 \cdot \min(1+\sqrt{\delta_1}, \beta+\sqrt{\delta_1 \cdot t_{i_2}}, \gamma +\sqrt{\delta_1+t_{i_3}})^2 + p(1-p) \cdot \beta^2 + p(1-p) \cdot \gamma^2 + p^2 \cdot \min(\beta, \gamma)^2}{1-p (1-\beta^2) - p (1-\gamma^2)}$$ in the second case, where $\beta+\gamma \ge \sqrt{\delta_2 \cdot \min(t_{i_2}, t_{i_3})}$. Letting $t = \min(t_{i_2}, t_{i_3})$, we have that $\min\left(\beta+\sqrt{\delta_1 \cdot t_{i_2}}, \gamma + \sqrt{\delta_1+t_{i_3}}\right) \le \max(\beta, \gamma) + \sqrt{\delta_1 \cdot t}$. Therefore, we can bound the ratio by $$\frac{(1-2p) \cdot \min(1+\sqrt{\delta_1}, \max(\beta, \gamma)+\sqrt{\delta_1 \cdot t})^2 + p \cdot \beta^2 + p \cdot \gamma^2}{1-p (1-\beta^2) - p (1-\gamma^2)}$$ in the first case, where $\beta+\gamma \ge \sqrt{\delta_3 \cdot t}$ and $\beta, \gamma \le 1$, and by $$\frac{(1-p)^2 \cdot \min(1+\sqrt{\delta_1}, \max(\beta, \gamma)+\sqrt{\delta_1 \cdot t})^2 + p(1-p) \cdot \beta^2 + p(1-p) \cdot \gamma^2 + p^2 \cdot \min(\beta, \gamma)^2}{1-p (1-\beta^2) - p (1-\gamma^2)}$$ in the second case, where $\beta+\gamma \ge \sqrt{\delta_2 \cdot t}$ and $\beta, \gamma \le 1$. \fi \paragraph{Case 2: $\boldsymbol{a = 0, b = 1, c \ge 1}$.} Let $i_2$ be the unique point in $N(j) \cap I_2,$ and let $i_3^{(1)}, \dots, i_3^{(c)}$ represent the points in $N(j) \cap I_3$. Let $c_1$ be the number of points in $N(j) \cap I_3$ that are in $q^{-1}(i_2)$, and let $c_2 = c-c_1$ be the number of points in $N(j) \cap I_3$ not in $q^{-1}(i_2).$ We will have four subcases. For simplicity, in this case we keep $\delta_2 = 2.$ Before delving into the subcases, we first prove the following propositions regarding the probability of some point in $I_3$ being selected. \begin{proposition} \label{prop:anticor_1} Let $c = |N(j) \cap I_3|$. Then, the probability that no point in $N(j) \cap I_3$ is in $S$ is at most $\frac{1}{2} + \frac{1}{2} (1-2p)^c$. \end{proposition} \begin{proof} First, note that $\left(\frac{1}{2} + \frac{1}{2} x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} y\right) + \left(\frac{1}{2} - \frac{1}{2} x\right) \cdot \left(\frac{1}{2} - \frac{1}{2} y\right) = \frac{1}{2} + \frac{1}{2} xy$. Therefore, if $0 \le x, y \le 1$, then $\left(\frac{1}{2} + \frac{1}{2} x\right) \cdot \left(\frac{1}{2} + \frac{1}{2} y\right) \le \frac{1}{2} + \frac{1}{2} xy.$ In general, through induction we have that for any $0 \le x_1, \dots, x_r \le 1,$ that $\prod_{s = 1}^{r} \left(\frac{1}{2} + \frac{1}{2} x_s\right) \le \frac{1}{2} + \frac{1}{2} x_1 \cdots x_r$. Now, group the points $i_3^{(1)}, \dots, i_3^{(c)} \in N(j) \cap I_3$ into $r \le c$ groups of sizes $c_1, \dots, c_r$, where each group is points that map to the same point in $I_2$ under $q$. Then, for each group $s$, the probability that no point in the group is in $S$ is precisely $\frac{1}{2} + \frac{1}{2} (1-2p)^{c_s}$, because with probability $\frac{1}{2}$ we will only consider picking the point $q(i)$ (for $i$ in group $s$), and otherwise each point in the group will still not be in $S$ with probability $1-2p$. So, the overall probability is \[\prod_{s = 1}^{r} \left(\frac{1}{2} + \frac{1}{2} (1-2p)^{c_s}\right) \le \frac{1}{2} + \frac{1}{2} (1-2p)^{c_1+\cdots+c_r} = \frac{1}{2} + \frac{1}{2} (1-2p)^c. \qedhere\] \end{proof} We also note the following related proposition. \begin{proposition} \label{prop:anticor_2} Let $c = |N(j) \cap I_3|$, and $i' = q(i)$ for some arbitrary $i \in N(j) \cap I_3$. Then, the probability that no point in $N(j) \cap I_3$ nor $i'$ is in $S$ is at most $\frac{1}{2} (1-2p) + \frac{1}{2} (1-2p)^c$. \end{proposition} \begin{proof} Similar to the previous proposition, we group the points $i_3^{(1)}, \dots, i_3^{(c)} \in N(j) \cap I_3$ into $r \le c$ groups of sizes $c_1, \dots, c_r$. Assume WLOG that $i$ is in the first group. Then, the probability that no point in the first group nor $i'$ is in $S$ is $\frac{1}{2} (1-2p) + \frac{1}{2} (1-2p)^{c_1} = (1-2p) \cdot \left(\frac{1}{2} + \frac{1}{2} (1-2p)^{c_1-1}\right)$. So, the overall probability is \begin{align*} (1-2p) \cdot \left(\frac{1}{2} + \frac{1}{2} (1-2p)^{c_1-1}\right) \cdot \prod_{s = 2}^{r} \left(\frac{1}{2} + \frac{1}{2} (1-2p)^{c_s}\right) &\le (1-2p) \cdot \left(\frac{1}{2} + \frac{1}{2} (1-2p)^{(c_1-1)+c_2+\cdots+c_r}\right) \\ &= \frac{1}{2} (1-2p) + \frac{1}{2} (1-2p)^c. \qedhere \end{align*} \end{proof} \begin{enumerate}[label=\alph*)] \item $\boldsymbol{c_1 = 0}$. In this case, we have that no pair of points in $N(j) \cap (I_2 \cup I_3)$ are connected in $H(\delta_2)$, which means that they have pairwise distances at least $\sqrt{\delta_2}$ from each other (since $t_i \ge 1$ if $i \in N(j)$). So, $\sum_{i \in N(j) \cap (I_2 \cup I_3)} c(j, i) \ge \frac{1}{2(c+1)} \cdot c(c+1)(\sqrt{\delta_2})^2 = c$ since $|N(j) \cap (I_2 \cup I_3)| = c+1$ and $\delta_2 = 2$. Consequently, $\sum_{i \in N(j) \cap (I_2 \cup I_3)} (1-c(j, i)) \le (c+1)-c = 1$. Therefore, the denominator is at least $1-p$. To bound the numerator, we note that the probability of none of the points in $I_2 \cup I_3$ being in $S$ is at most $(1-p) \cdot \left(\frac{1}{2} + \frac{1}{2}(1-2p)^{c_2}\right)$. This is because $i_2 \not\in S$ with probability $1-p$, no point in $N(j) \cap I_3$ is in $S$ with probability at most $\frac{1}{2} + \frac{1}{2} (1-2p)^{c_2}$ by Proposition \ref{prop:anticor_1}, and these two events are independent since $c_1 = 0$. If some point in $N(j) \cap (I_2 \cup I_3)$ is in $S$, then $c(j, S) \le 1$, and otherwise, $c(j, S) \le (1+\sqrt{\delta_1})^2$. Therefore, we can bound the numerator as at most $(1-p) \cdot \left(\frac{1}{2} + \frac{1}{2}(1-2p)^{c_2}\right) \cdot (1+\sqrt{\delta_1})^2 + \left(1 - (1-p) \cdot \left(\frac{1}{2} + \frac{1}{2}(1-2p)^{c_2}\right)\right).$ Overall, we have that the fraction is at most \begin{equation} \tag{2.a} \label{eq:2.a} \frac{(1-p) \cdot \left(\frac{1}{2} + \frac{1}{2}(1-2p)^{c_2}\right) \cdot (1+\sqrt{\delta_1})^2 + \left(1 - (1-p) \cdot \left(\frac{1}{2} + \frac{1}{2}(1-2p)^{c_2}\right)\right)}{1-p}. \end{equation} \item $\boldsymbol{c_2 = 0}$ \textbf{and} $\boldsymbol{c \ge 2}$. In this case, we have that $q(i_3^{(k)}) = i_2$ for all $k \in [c]$ (note that $c = c_1$). Since the points $i_3^{(k)}$ for all $k \in [c]$ have pairwise distance at least $\sqrt{2}$ from each other, we have that $\sum_{i \in N(j) \cap I_3} (1-c(j, i)) \le 1$. Letting $t$ be such that $1-t = \sum_{i \in N(j) \cap I_3} (1-c(j, i)),$ we have that $\mathbb E_{i \sim N(j) \cap I_3} c(j, i) = \frac{c-1}{c} +\frac{t}{c}$. In addition, let $u = d(j, i_2).$ In this case, the denominator of our fraction is $1-p(1-u^2)-p(1-t) = p \cdot u^2 + p \cdot t + (1-2p).$ To bound the numerator, with probability $p$ we have that $i_2 \in S$, in which case $c(j, S) \le u^2$. In addition, there is a disjoint $\frac{1}{2} \cdot \left(1-(1-2p)^c\right)$-probability event where some $i_3^{(k)} \in S$, and conditioned on this event, $\mathbb E[c(j, S)] \le \frac{c-1}{c} + \frac{t}{c}$. Otherwise, we still have that $c(j, S) \le c(j, I_1) \le (1+\sqrt{\delta_1})^2$. So, overall we have that the fraction is at most \[\frac{p \cdot u^2 + \frac{1}{2} \cdot \left(1-(1-2p)^c\right) \cdot \left(\frac{c-1}{c}+\frac{t}{c}\right) + \left(1-p-\frac{1}{2} \cdot \left(1-(1-2p)^c\right)\right) \cdot (1+\sqrt{\delta_1})^2}{p \cdot u^2 + p \cdot t + (1-2p)}.\] This function clearly decreases as $u$ increases (since the numerator and denominator increase at the same rate). In addition, since $\frac{1}{2} \cdot (1-(1-2p)^c) \cdot \frac{1}{c} < p$ (whenever $0 < p < \frac{1}{2}$), we have that the numerator increases at a slower rate than the denominator when $t$ increases, so this function also decreases as $t$ increases. So, we may assume that $t = u = 0$ to get that the fraction is at most \begin{equation} \tag{2.b} \label{eq:2.b} \frac{\frac{1}{2} \cdot (1-(1-2p)^c) \cdot \frac{c-1}{c} + (1-p-\frac{1}{2} \cdot (1-(1-2p)^c)) \cdot (1+\sqrt{\delta_1})^2}{1-2p}. \end{equation} \item $\boldsymbol{c_1, c_2 \ge 1}$. In this case, we have that there exists a point $i_3^{(k)} \in N(j) \cap I_3$ not in $q^{-1}(i_2)$, so it has distance at least $\sqrt{\delta_2}$ from $i_2$. Therefore, by the triangle inequality, $d(i_2, j) \ge \sqrt{\delta_2}-1.$ Let $t = d(i_2, j)$. Next, since all of the points in $N(j) \cap I_3$ have pairwise distance at least $\sqrt{2}$ from each other, $\sum_{i \in N(j) \cap I_3}(1-c(j, i)) \le 1$. Therefore, the denominator of the fraction is at most $1-p(1-t^2)-p \le 1-2p+t^2 p$. We now bound the numerator. First, by Proposition \ref{prop:anticor_2} and since $c \ge 2$, the probability that no point in $N(j) \cap (I_2 \cup I_3)$ is in $S$ is some $p'$, where $p' \le \frac{1}{2} (1-2p)+\frac{1}{2} (1-2p)^c \le (1-2p)(1-p)$. In this event, we have that $c(j, S) \le (1+\sqrt{\delta_1})^2$. In addition, there is a $p$ probability that $i_2 \in S$, in which case $c(j, S) \le t^2$. Finally, with $1-p-p'$ probability, we have that $i_2 \not\in S$ but there is some $i_3^{(k)} \in S$, so $c(j, S) \le 1$. Overall, the fraction is at most \[\frac{p \cdot t^2 + p' \cdot (1+\sqrt{\delta_1})^2 + (1-p-p')}{1-2p+t^2 p}.\] This function clearly decreases as $t$ increases (since the numerator and denominator increase at the same rate), so we may assume that $t = \sqrt{2}-1$ as this is our lower bound on $t$. So, the fraction is at most \begin{equation} \tag{2.c} \label{eq:2.c} \frac{p \cdot (\sqrt{2}-1)^2 + p' \cdot (1+\sqrt{\delta_1})^2 + (1-p-p')}{1-2p+(\sqrt{2}-1)^2 p} \le \frac{1-p(2\sqrt{2}-2) + (1-2p)(1-p) \cdot \left((1+\sqrt{\delta_1})^{2}-1\right)}{1-p(2\sqrt{2}-1)}. \end{equation} \item $\boldsymbol{c_1 = 1}$ \textbf{and} $\boldsymbol{c_2 = 0}$. In this case, $c = 1$, so we simply write $i_3$ as the unique point in $I_3 \cap N(j)$. Let $i^* = w(j)$ be the witness of $j$. Since $c_1 = 1$, this means that $i_2, i_3$ are neighbors in $H(\delta_2)$ and $q(i_3) = i_2$. Finally, we have that $i_2, i_3$ are not connected in $H(\delta_3)$. So, $d(i_2, i_3) \ge \sqrt{\delta_3 \cdot \min(t_{i_2}, t_{i_3})}.$ Now, note that since $i_2, i_3$ are not in $I_1$, we either have that the witness $i^*$ is in $I_1$, in which case $d(j, I_1) = 1$, or all of $i_2, i_3, i^*$ are adjacent to $I_1$ in $H(\delta_1)$ since $I_1$ was a maximal independent set in $H(\delta_1)$. Therefore, if we define $\beta = d(j, i_2)$ and $\gamma = d(j, i_3)$, this means that $d(j, I_1) \le \min\left(1+\sqrt{\delta_1}, \beta+\sqrt{\delta_1 \cdot t_{i_2}}, \gamma+\sqrt{\delta_1 \cdot t_{i_3}}\right),$ and $d(i_2, i_3) \le \beta+\gamma$ by triangle inequality. Note that the denominator equals $1-p(1-\beta^2)-p(1-\gamma^2)$. To bound the numerator, note that with probability $p$, $i_2 \in S$ in which case $d(j, S) \le \beta$ and with probability $p$, $i_3 \in S$ in which case $d(j, S) \le \gamma$. Also, these two events are disjoint since $q(i_3) = i_2$. Finally, in the remaining $1-2p$ probability event, $d(j, S) \le d(j, I_1) \le \min(1+\sqrt{\delta_1}, \beta+\sqrt{\delta_1 \cdot t_{i_2}}, \gamma+\sqrt{\delta_1 \cdot t_{i_3}})$. Letting $t = \min(t_{i_2}, t_{i_3}) \ge 1$, we have that $\min\left(\beta+\sqrt{\delta_1 \cdot t_{i_2}}, \gamma + \sqrt{\delta_1 \cdot t_{i_3}}\right) \le \max(\beta, \gamma) + \sqrt{\delta_1 \cdot t}$. We also know that $\sqrt{\delta_3 \cdot t} \le d(i_2, i_3) \le \beta+\gamma$. Therefore, we can bound the ratio by \begin{align} &\hspace{0.5cm}\max_{\substack{t \ge 1 \\ \beta+\gamma \ge \sqrt{\delta_3 \cdot t}}}\frac{(1-2p) \cdot \min(1+\sqrt{\delta_1}, \max(\beta, \gamma)+\sqrt{\delta_1 \cdot t})^2 + p \cdot \beta^2 + p \cdot \gamma^2}{1-p (1-\beta^2) - p (1-\gamma^2)} \nonumber \\ &= \frac{\left(1-2p\right)\cdot\left(1+\sqrt{\delta_1}\right)^{2}\cdot\left(\delta_1+\left(\sqrt{\delta_1}+\sqrt{\delta_3}\right)^{2}\right)+p\cdot\left(1+\sqrt{\delta_1}\right)^{2}\cdot \delta_3}{\left(1-2p\right)\cdot\left(\delta_1+\left(\sqrt{\delta_1}+\sqrt{\delta_3}\right)^{2}\right)+p\cdot\left(1+\sqrt{\delta_1}\right)^{2}\cdot \delta_3}. \tag{2.d} \label{eq:2.d} \end{align} We prove the final equality in Appendix \ref{app:bash}. \iffalse For simplicity, I use a lazier bound by ignoring the $\max(\beta, \gamma)+\sqrt{\delta_1 \cdot t}$. In this case, we can rewrite the ratio as \[\frac{(1-2p) \cdot (1+\sqrt{\delta_1})^2 + p \cdot (\beta^2+\gamma^2)}{1-2p+p \cdot (\beta^2+\gamma^2)}.\] This function is clearly decreasing as $\beta^2+\gamma^2$ increases, so we wish to minimize $\beta^2+\gamma^2$. This is done when $t = 1$ and $\beta = \gamma = \frac{\sqrt{\delta_3}}{2},$ so we can bound the ratio by \begin{equation} \tag{2.d} \label{eq:2.d} \frac{(1-2p) \cdot (1+\sqrt{\delta_1})^2+p \cdot \frac{\delta_3}{2}}{1-2p+p \cdot \frac{\delta_3}{2}}. \end{equation} \fi \end{enumerate} \paragraph{Case 3: $\boldsymbol{a = 0, b \ge 2}$.} We split this case into three cases. First, we recall that each point $i \in I_3$ corresponds to some point $q(i) \in I_2$. Let $c_1$ represent the number of points such $i \in N(j) \cap I_3$ such that $q(i) \in N(j) \cap I_2$, and let $c_2 = c-c_1$. Note that if $c = 0$, then $c_1 = c_2 = 0$. \begin{enumerate}[label=\alph*)] \item $\boldsymbol{c_1 = 0}$. In this case, all of the points in $N(j) \cap (I_2 \cup I_3)$ must not be connected in $H(\delta_2)$. Therefore, $\sum_{i \in N(j) \cap (I_2 \cup I_3)} (1-c(j, i)) \le 1$ and since $a = 0$, this means that the denominator is at least $1-p$ in expectation. In addition, since $b \ge 2,$ the probability of no point in $N(j) \cap I_2$ being in $S$ is at most $(1-p)^2$, in which case $d(j, S) \le (1+\sqrt{\delta_1})^2$. If there is some point in $N(j) \cap I_2$ in $S$, then $d(j, S) \le 1.$ Therefore, the numerator is at most $(1-p)^2 \cdot (1+\sqrt{\delta_1})^2 + (1-(1-p)^2).$ So, we can bound the fraction by \begin{equation} \tag{3.a} \label{eq:3.a} \frac{(1-p)^2 \cdot (1+\sqrt{\delta_1})^2 + (1-(1-p)^2)}{1-p}. \end{equation} \item $\boldsymbol{c_1 = 1, c_2 = 0}$. In this case, the probability of there being a point in $N(j) \cap (I_2 \cup I_3)$ that is part of $S$ is $(1-2p) \cdot (1-p)^{b-1}$. Conditioned on this event, $c(j, S) \le 1$, and otherwise, $c(j, S) \le (1+\sqrt{\delta_1})^2$. So, the numerator is at most $(1-2p) \cdot (1-p)^{b-1} \cdot (1+\sqrt{\delta_1})^2 + \left(1-(1-2p) \cdot (1-p)^{b-1}\right) \cdot 1.$ Finally, we have that all of the points in $N(j) \cap (I_2 \cup I_3)$ are separated by at least $\sqrt{2}$, except for the unique point $i_3 \in N(j) \cap I_3$ and $q(i_3)$, which are separated by at least $\sqrt{\delta_3}$. So, $\sum_{N(j) \cap (I_2 \cup I_3)} c(j, i) \ge \frac{1}{b+1} \cdot \left(\frac{b(b+1)}{2} \cdot 2 + (\delta_3-2)\right) = b + \frac{\delta_3-2}{b+1},$ which means that $\sum_{N(j) \cap (I_2 \cup I_3)} (1-c(j, i)) \le 1 + \frac{2-\delta_3}{b+1}.$ Therefore, the denominator is at least $1-p \cdot \left(1 + \frac{2-\delta_3}{b+1}\right).$ Overall, the fraction is at most \begin{equation} \tag{3.b} \label{eq:3.b} \frac{(1-p)^{b-1}\cdot(1-2p)\cdot(1+\sqrt{\delta_1})^2+\left(1-(1-p)^{b-1}(1-2p)\right)}{1-\left(1+\frac{2-\delta_3}{b+1}\right) \cdot p} \end{equation} \item $\boldsymbol{c_1 \ge 2}$ \textbf{or} $\boldsymbol{c_1 = 1, c_2 \ge 1}$. In this case, we first note that since all of the points in $N(j) \cap I_2$ have distance at least $\sqrt{2}$ from each other and all of the points in $N(j) \cap I_3$ have distance at least $\sqrt{2}$ from each other, both $\sum_{i \in N(j) \cap I_2} (1-c(j, i))$ and $\sum_{i \in N(j) \cap I_3} (1-c(j, i))$ are at most $1$. Let $t$ be such that $1-t = \sum_{i \in N(j) \cap I_2} (1-c(j, i)).$ Then, the denominator is at least $1-p(2-t)$. In addition, with probability $1-(1-p)^b$, at least one of the points in $N(j) \cap I_2$ will be in $S$, conditioned on which the expected value of $c(j, S)$ is at most $\frac{1}{b} \cdot \sum_{i \in N(j) \cap I_2} c(j, i) = \frac{b-1}{b} + \frac{t}{b}.$ Next, note that the probability of no point in $N(j) \cap (I_2 \cup I_3)$ being in $S$ is maximized when all points $i \in N(j) \cap I_3$ with $q(i) \in N(j)$ map to a single point $i_2 \in N(j) \cap I_2$, and all other points in $N(j) \cap I_3$ map to a single point $i_2' \in I_2 \backslash N(j)$. In this case, the probability that no point in $N(j) \cap (I_2 \cup I_3)$ is in $S$ is at most $p' := (1-p)^{b-1} \cdot \left(\frac{1}{2}(1-2p)+\frac{1}{2}(1-2p)^{c_1}\right) \cdot \left(\frac{1}{2} + \frac{1}{2}(1-2p)^{c_2}\right).$ Overall, we have that with probability $1-(1-p)^b$, some point in $I_2 \cap N(j)$ is in $S$, conditioned on which $\mathbb E[c(j, S)] \le \frac{b-1}{b} + \frac{t}{b}$, with probability at most $p',$ no point in $N(j) \cap (I_2 \cup I_3)$ is in $S$, conditioned on which $c(j, S) \le (1+\sqrt{\delta_1})^2,$ and otherwise, some point in $N(j) \cap I_3$ is in $S$, which means $c(j, S) \le 1.$ So, we can bound this fraction overall by \[\frac{(1-(1-p)^b) \cdot \left(\frac{b-1}{b}+\frac{t}{b}\right)+p' \cdot (\sqrt{\delta_1})^2 + ((1-p)^b-p') \cdot 1}{1-2p+p \cdot t}.\] Noting that $(1-(1-p)^b) \cdot \frac{1}{b} \le p$, we have that the numerator increases at a slower rate than the denominator as $t$ increases. Therefore, this fraction is maximized when $t = 0$. So, we can bound the fraction by \begin{align} &\hspace{0.5cm} \frac{(1-(1-p)^b) \cdot \frac{b-1}{b} + p' \cdot (1+\sqrt{\delta_1})^2 + ((1-p)^b-p')}{1-2p} \nonumber \\ \tag{3.c} \label{eq:3.c} &= \frac{\frac{b-1}{b}+\frac{(1-p)^b}{b}+(1-p)^{b-1} \cdot \left(\frac{1}{2}(1-2p)+\frac{1}{2}(1-2p)^{c_1}\right) \cdot \left(\frac{1}{2} + \frac{1}{2}(1-2p)^{c_2}\right) \cdot \left((1+\sqrt{\delta_1})^2-1\right)}{1-2p}. \end{align} \end{enumerate} \paragraph{Case 4: $\boldsymbol{a=0, b=0}$.} We split this case into three subcases. \begin{enumerate}[label=\alph*)] \item $\boldsymbol{c = 0}.$ In this case, $N(j) \cap S$ is always empty, so the denominator is $1$. To bound the numerator, we consider the witness $i^*$ of $j$. If $i^* \in I_1$, the numerator is at most $c(j, i^*) \le 1$ so we can bound the fraction by $1$. Else, if $i^* \not\in V_2,$ then there exists $i_1 \in I_1$ such that $d(i^*, i_1) \le \sqrt{\delta_2 \cdot \min(t_{i^*}, t_{i_2})} \le \sqrt{\delta_2}$, and since $d(j, i^*) \le 1,$ we have that $d(j, I_1) \le 1+\sqrt{\delta_2})$. Thus, the fraction in the case where $i \in I_1$ or $i^* \not\in V_2$ is at most \begin{equation} \tag{4.a.i} \label{eq:4.a.i} (1+\sqrt{\delta_2})^2. \end{equation} Otherwise, there is some $i_1 \in I_1$ of distance at most $\sqrt{\delta_1 \cdot \min(t_{i^*}, t_{i_1})} \le \sqrt{\delta_1}$ away from $i^*$. Next, if $i^* \in I_2,$ the numerator is at most $p \cdot 1 + (1-p) \cdot (1+\sqrt{\delta_1})^2$. Otherwise, there is some $i_2 \in I_2$ of distance at most $\sqrt{\delta_2 \cdot \min(t_{i^*}, t_{i_2})}$ away from $i^*$. Finally, $d(i_1, i_2) \ge \sqrt{\delta_2 \cdot \min(t_{i_1}, t_{i_2})}$. Therefore, as in \ref{eq:1.b}, we can apply Proposition \ref{prop:triangle} to obtain that the numerator, and therefore, the fraction is at most \begin{equation} \tag{4.a.ii} \label{eq:4.a.ii} 1+p \cdot \delta_2 + (1-p) \cdot \delta_1 + 2\sqrt{p^2 \cdot \delta_2 + (1-p) \cdot \delta_1}, \end{equation} since the above \eqref{eq:4.a.ii} is greater than both $1$ and $p + (1-p) \cdot (1+\sqrt{\delta_1})^2$ for any $0 < p < 1.$ \item $\boldsymbol{c=1}.$ In this case, let $i_3$ be the unique element in $N(j) \cap I_3$. Conditioned in $i_3 \in S$, the denominator equals $c(j, i_3)$ and the numerator is at most $c(j, i_3)$. Otherwise, the denominator is $1$, and the numerator can again be bounded in an identical way to the previous case, since the probability of $i_2 \in S$ is either $p$ (if $q(i_3) \neq i_2$) or $\frac{p}{1-p} > p$ (if $q(i_3) = i_2$). Therefore, the fraction is again at most \begin{equation} \tag{4.b.i} \label{eq:4.b.i} (1+\sqrt{\delta_2})^2 \end{equation} if the witness $i^*$ of $j$ satisfies $i^* \in I_1$ or $i^* \not\in V_2$, and is at most \begin{equation} \tag{4.b.ii} \label{eq:4.b.ii} 1+p \cdot \delta_2 + (1-p) \cdot \delta_1 + 2\sqrt{p^2 \cdot \delta_2 + (1-p) \cdot \delta_1} \end{equation} otherwise. \item $\boldsymbol{c \ge 2}$. In this case, note that all points in $N(j) \cap I_3$ are separated by at least $\sqrt{2}$, which means that $\sum_{i \in N(j) \cap I_3} (1-c(j, i)) \le 1$. Letting $t$ be such that $1-t = \sum_{i \in N(j) \cap I_3} (1-c(j, i)),$ we have that $\sum_{i \in N(j) \cap I_3} c(j, i) = c-1+t$, so there exists $i_3 \in N(j) \cap I_3$ such that $c(j, i_3) \le \frac{c-1+t}{c}$. In addition, we know that $c(j, I_1) \le (1+\sqrt{\delta_1})^2$. Finally, we also note the denominator equals $1-p(1-t) = 1-p+pt$. Next, note that \begin{align*} \sum_{i, i' \in N(j) \cap I_3} c(i, i') &= \sum_{i, i' \in N(j) \cap I_3} \left[\|i-j\|^2 + \|i'-j\|^2 - 2 \langle i-j, i'-j \rangle\right] \\ &= 2 c \cdot \left[\sum_{i \in N(j) \cap I_3} c(j, i)\right] - 2 \left\langle \sum_{i \in N(j) \cap I_3} (i-j), \sum_{i' \in N(j) \cap I_3} (i'-j)\right\rangle \\ &\le 2 c \cdot \left[\sum_{i \in N(j) \cap I_3} c(j, i)\right] \\ &= 2c \cdot (c-1+t). \end{align*} Since $c(i, i) = 0$, this means there exists $i \neq i'$ such that $c(i, i') \le \frac{2(c-1+t)}{c-1},$ and since $c(i, i') \ge 2 \cdot \min(t_i, t_{i'})$ for any $i, i' \in I_3$, this means that $\min_{i \in N(j) \cap I_3} t_i \le \frac{c-1+t}{c-1}.$ Let $i = \arg\min_{i \in N(j) \cap I_3} t_i$, and let $i_2 = q(i) \in I_2$. Let $\mathcal{E}_1$ be the event that no point in $N(j) \cap I_3$ nor $i_2$ is in $S$, let $\mathcal{E}_2$ be the event that no point in $N(j) \cap I_3$ is in $S$, and let $\mathcal{E}_3$ be the event that $i_3$ is not in $S$. Note that $\mathcal{E}_1$ implies $\mathcal{E}_2$, which implies $\mathcal{E}_3$. Now, by Proposition \ref{prop:anticor_2}, $\mathbb P(\mathcal{E}_1)$ equals some $p_1 \le \frac{1}{2} (1-2p) + \frac{1}{2} (1-2p)^c$. Likewise, By Proposition \ref{prop:anticor_1}, $\mathbb P(\mathcal{E}_2)$ equals some $p_2 \le \frac{1}{2} + \frac{1}{2} (1-2p)^c$. In addition, $\mathbb P(\mathcal{E}_3) = p_3 = 1-p$. Under the event $\mathcal{E}_3^c$, we have that $c(j, S) \le c(j, i_3) \le \frac{c-1+t}{c}$. Next, under the event $\mathcal{E}_3 \backslash \mathcal{E}_2,$ we have that some point in $N(j) \cap I_3$ is in $S$, so $c(j, S) \le 1$. Under the event $\mathcal{E}_2 \backslash \mathcal{E}_1$, we know that $i_2 \in S$, so $c(j, S) \le d(j, i_2)^2 \le (c(j, i) + \sqrt{\delta_2 \cdot t_i})^2 \le \left(1 + \sqrt{2 \cdot \frac{c-1+t}{c-1}}\right)^2$. Finally, we always have that $c(j, S) \le (1+\sqrt{\delta_1})^2$. Therefore, we can bound the overall fraction by \[\frac{p_1 \cdot (1+\sqrt{\delta_1})^2 + (p_2-p_1) \cdot \min\left(1+\sqrt{\delta_1}, 1+\sqrt{2 \cdot \frac{c-1+t}{c-1}}\right)^2 + (p_3-p_2) \cdot 1 + (1-p_3) \cdot \frac{c-1+t}{c}}{1-p+pt}.\] Since $(1+\sqrt{\delta_1})^2 \ge \min\left(1+\sqrt{\delta_1}, 1+\sqrt{2 \cdot \frac{c-1+t}{c-1}}\right)^2 \ge 1 \ge \frac{c-1+t}{c},$ the above fraction is an increasing function in the variables $p_1, p_2, p_3$. So, we can upper bound this fraction by replacing $p_1, p_2, p_3$ with their respective upper bounds $\frac{1}{2} (1-2p) + \frac{1}{2} (1-2p)^c,$ $\frac{1}{2} + \frac{1}{2} (1-2p)^c$, and $1-p$, as well as replacing $\min\left(1+\sqrt{\delta_1}, 1+\sqrt{2 \cdot \frac{c-1+t}{c-1}}\right)$ with simply $1+\sqrt{2 \cdot \frac{c-1+t}{c-1}}$. % Next, since $p_2-p_1 = p$ and $1-p_3 = p$, the derivative of the numerator with respect to $t$ is $p \cdot \left(\frac{2}{c-1} + \sqrt{\frac{2}{(c-1)(c-1+t)}}\right) + p \cdot \frac{1}{c} \le p \cdot (2.5 + \sqrt{2})$, and the derivative of the denominator with respect to $t$ is $p t$. Hence, this fraction decreases as $t$ increases, unless the fraction is less than $2.5+\sqrt{2}$. Therefore, we can bound the fraction by \begin{align} \nonumber &\hspace{0.5cm} \max\left(2.5+\sqrt{2}, \frac{p_1 \cdot (1+\sqrt{\delta_1})^2 + (p_2-p_1) \cdot (1+\sqrt{2})^2 + (p_3-p_2) \cdot 1 + (1-p_3) \cdot \frac{c-1}{c}}{1-p}\right) \\ \nonumber &=\max\left(2.5+\sqrt{2}, \frac{p_1 \cdot (1+\sqrt{\delta_1})^2 + p \cdot (1+\sqrt{2})^2 + (1-p-p_2) \cdot 1 + p \cdot \frac{c-1}{c}}{1-p}\right) \\ \nonumber &= \max\left(2.5+\sqrt{2}, \frac{\left(\frac{1}{2}(1-2p)+\frac{1}{2}(1-2p)^c\right) \cdot (1+\sqrt{\delta_1})^2 - \left(\frac{1}{2} + \frac{1}{2}(1-2p)^c\right) +p(1+\sqrt{2})^2+1-\frac{p}{c}}{1-p}\right), \tag{4.c} \label{eq:4.c} \end{align} where we used the facts that $p_3 = 1-p$ and $p_2-p_1 = p$. \end{enumerate} \paragraph{Case 5: $\boldsymbol{a \ge 1}$.} In this case, note that $\mathbb E[c(j, S)] \le \mathbb E[c(j, I_1)] \le 1$ deterministically, since $a = |I_1 \cap N(j)| \ge 1$. However, we can improve upon this, since we may have some points in $I_1 \cap N(j)$ much closer to $j$, or we may have some points in $(I_2 \cup I_3) \cap N(j)$ which are closer and appear with some probability. Recall that in our algorithm, we flip a coin for each $i \in I_2$ to decide whether we include $i \in S$ with probability $2p$ or include each $q^{-1}(i)$ in $S$ independently with probability $2p$. Let us condition on all of these fair coin flips, and say that a point $i \in I_2 \cup I_3$ \emph{survives} the coin flips if they could be in the set $S$ with probability $2p$ afterwards. For simplicity, we replace $p$ with $\bar{p} := 2p$. We also let $\bar{I}$ represent the points in $I_2 \cup I_3$ that survive the fair coin flips. Let the squared distances from $j$ to each of the points in $I_1 \cap N(j)$ be $r_1, \dots, r_a$, and the squared distances from $j$ to each of the points in $\bar{I} \cap N(j)$ be $s_1, \dots, s_h$, where $h = |\bar{I} \cap N(j)|$. It is trivial to see that $\mathbb E[c(j, S)] \le \min_{1 \le i \le a} r_i \le \frac{r_1+\cdots+r_a}{a},$ and conditioned on at least one of the points in $\bar{I} \cap N(j)$ being selected, we have that $c(j, S)$ in expectation is at most $\frac{s_1 + \cdots + s_h}{h}.$ The probability of at least one of the points in $\bar{I} \cap N(j)$ being selected in $S$ is $$1-(1-\bar{p})^h \ge 1-\frac{1}{(1+\bar{p})^h} \ge 1-\frac{1}{1+\bar{p} \cdot h} = \frac{\bar{p} \cdot h}{1+\bar{p} \cdot h} \ge \frac{\bar{p} \cdot h}{a+\bar{p} \cdot h},$$ since conditioned on the initial coin flips, each surviving point in $(\bar{I_2} \cup \bar{I_3})$ is included in $S$ independently with probability $\bar{p}$. Therefore, we can say that \[\mathbb E[c(j, S)] \le \frac{r_1+\cdots+r_a}{a} \cdot \frac{a}{a+\bar{p} \cdot h} + \frac{s_1+\cdots+s_h}{h} \cdot \frac{\bar{p} \cdot h}{a+\bar{p} \cdot h} = \frac{(r_1+\cdots+r_a)+\bar{p} \cdot (s_1+\cdots+s_h)}{a+\bar{p} \cdot h}.\] Next, we have that \begin{align*} \mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] &= \alpha_j - (a \cdot \alpha_j -(r_1+\cdots+r_a))-\bar{p} \cdot (h \cdot \alpha_j-(s_1+\cdots+s_h))\\ &= \alpha_j \cdot (1-(a+\bar{p} \cdot h)) + [(r_1+\cdots+r_a)+\bar{p} \cdot (s_1+\cdots+s_h)]. \end{align*} Now, we provide a lower bound for $(r_1+\cdots+r_a)+\bar{p}(s_1+\cdots+s_h).$ To do so, we use the fact that all the points in $N(j) \cap I_1$ are separated by at least $\delta_1 \cdot \alpha_j$ in squared distance, and all the surviving points in $N(j) \cap (I_1 \cup \bar{I_2} \cup \bar{I_3})$ are separated by at least $\delta_2 \cdot \alpha_j$ in squared distance, to get \[(r_1+\cdots+r_a)+\bar{p}(s_1+\cdots+s_h) \ge \frac{1}{a+\bar{p} \cdot h} \cdot \alpha_j \cdot \left( \delta_1 \cdot \frac{a(a-1)}{2} + \delta_2 \cdot \bar{p} \cdot a \cdot h + \delta_2 \cdot \bar{p}^2 \cdot \frac{h(h-1)}{2}\right).\] So, if $a \ge 1$ and $(a, h) \neq (1, 0)$, then if we let $T_1 = a+\bar{p} \cdot h,$ $T_3 = \delta_1 \cdot \frac{a(a-1)}{2} + \delta_2 \cdot \bar{p} \cdot a \cdot h + \delta_2 \cdot \bar{p}^2 \cdot \frac{h(h-1)}{2},$ and $T_2 = T_3/T_1$, then the ratio is at most \begin{equation} \tag{5.a} \label{eq:5.a} \frac{T_2/T_1}{1-T_1+T_2} = \frac{T_3}{T_1(T_1-T_1^2+T_3)} = \frac{1}{T_1} + \frac{T_1-1}{T_1-T_1^2+T_3}. \end{equation} In the case where $a = 1, h = 0,$ this fraction is undefined. However, we note that in this case, $N(j) \cap S$ deterministically contains a unique center $i^*$ and nothing else, so $\mathbb E[c(j, S)] \le c(j, i^*)$ and $\mathbb E\left[\alpha_j - \sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] = \alpha_j - (\alpha_j - c(j, i^*)) = c(j, i^*).$ Therefore, the fraction is $1$. \end{proof} Therefore, we have the LMP approximation is at most $\rho(p)$, where $\rho(p)$ is determined via the numerous cases in the proof of Lemma \ref{lem:main_lmp}. The final step is to actually bound $\rho(p)$ based on the cases. Indeed, by casework one can show the following proposition. \begin{proposition} \label{prop:more_bash} For $p \in [0.096, 0.402]$ and $\delta_1 = \frac{4+8\sqrt{2}}{7}, \delta_2 = 2$, and $\delta_3 = 0.265$, we have that \begin{multline*} \rho(p) \le \max\bigg(3+2\sqrt{2}, 1 + 2p + (1-p) \cdot \delta_1 + 2 \sqrt{2 p^2 + (1-p) \cdot \delta_1}, \frac{(1-p)\cdot(1+\sqrt{\delta_1})^2+p\cdot(1-\sqrt{\delta_3})^2}{1-p+p (1-\sqrt{\delta_3})^2}, \\ \frac{(1-2p)\cdot(1+\sqrt{\delta_1})^{2}\cdot(\delta_1+(\sqrt{\delta_1}+\sqrt{\delta_3})^{2})+p\cdot\left(1+\sqrt{\delta_1}\right)^2\cdot \delta_3}{(1-2p)\cdot(\delta_1+(\sqrt{\delta_1}+\sqrt{\delta_3})^{2})+p\cdot(1+\sqrt{\delta_1})^2\cdot \delta_3}\bigg). \end{multline*} As a consequence, for $p_1 := 0.402$, $\rho(p_1) \le 3+2\sqrt{2}$. \end{proposition} We defer the casework to Lemma \ref{lem:more_bash}, and the above proposition follows immediately from it. Therefore, we get a $(3+2\sqrt{2}) \approx 5.828$ LMP approximation for the Euclidean $k$-means problem. \section{Polynomial-time Approximation Algorithm for Euclidean $k$-means} \label{sec:poly_time_alg} In this section, we describe how we improve the LMP approximation for Euclidean $k$-means to a polynomial-time approximation algorithm. Unfortunately, we will lose a slight factor in our approximation, but we still obtain a significant improvement over the previous state-of-the-art approximation factor. While we focus on the $k$-means problem, we note that this improvement can also be applied to the $k$-median problem as well, with some small modifications that we will make note of. In Section \ref{sec:k_median}, we will provide an LMP approximation for $k$-median, and explain how we can use the same techniques in this section to also obtain an improved polynomial-time algorithm for $k$-median as well. In Subsection \ref{subsec:k_means_alg_prelim}, we describe the polynomial-time algorithm to generate two nested quasi-independent sets $I$ and $I'$, which will be crucial in developing our final set of centers of size $k$ with low clustering cost. This procedure is based on a similar algorithm of Ahmadian et al.~\cite{ahmadian2017better}, but with some important changes in how we update our graphs and independent sets. In Subsection \ref{subsec:more_prelims}, we describe and state a few additional preliminary results. In Subsection \ref{subsec:k_means_analysis}, we analyze the algorithm and show how we can use $I$ and $I'$ to generate our final set of centers, to obtain a $6.013$-approximation algorithm. Finally, in Subsection \ref{subsec:k_means_improved}, we show that our analysis in Subsection \ref{subsec:k_means_analysis} can be further improved, to obtain a $(5.912+\varepsilon)$-approximation guarantee. We remark that our approximation guarantee of $(5.912+\varepsilon)$ is only \emph{in expectation}. However, this can be made to be with exponential failure probability, as with probability $\varepsilon$ the approximation ratio will be $(5.912+O(\varepsilon))$. So, by running the algorithm $\varepsilon^{-1} \cdot \text{poly}(n)$ times in parallel, and outputting the best solution of these, we obtain a $(5.912+\varepsilon)$-approximation ratio with probability at least $1-(1-\varepsilon)^{\varepsilon^{-1} \cdot \text{poly}(n)} \ge 1-e^{-\text{poly}(n)}$. \subsection{The algorithm and setup} \label{subsec:k_means_alg_prelim} First, we make some assumptions on the clients and facilities. We first assume that the number of facilities, $m = |\mathcal{F}|$, is at most polynomial in the number of clients $n = |\mathcal{D}|$. In addition, we also assume that the distances between clients and facilities are all in the range $[1, n^6]$. Indeed, both of these assumptions can be made via standard discretization techniques, and we only lose an $1+o(1)$-approximation factor by removing these assumptions~\cite{ahmadian2017better}. Note that this means the optimal clustering cost, which we call $\text{OPT}_k$, is at least $n$ for both $k$-means and $k$-medians. Finally, we assume that $k \le n-1$ (else this problem is trivial in polynomial time). Next, we describe the setup relating to dual solutions. Consider the tuple $(\alpha, z, \mathcal{F}_S, \mathcal{D}_S)$, where $\alpha \in \mathbb R^{\mathcal{D}}$, $z \in \mathbb R^{\mathcal{F}}$, $\mathcal{F}_S \subset \mathcal{F}$, and $\mathcal{D}_S: \mathcal{F}_S \to \{0, 1\}^{\mathcal{D}}$. Here, $\alpha$ represents the set $\{\alpha_j\}_{j \in \mathcal{D}}$ which will be a solution to the dual linear program, $z$ represents $\{z_i\}_{i \in \mathcal{F}}$, where each $z_i \in \{\lambda, \lambda+\frac{1}{n}\}$ will be a modified value representing the threshold for tightness of facility $i$, $\mathcal{F}_S$ represents a subset of facilities that we deem ``special'', and $\mathcal{D}_S$ is a function that maps each special facility to a subset of the clients that we deem special clients for that facility. When talking about a single solution $(\alpha, z, \mathcal{F}_S, \mathcal{D}_S)$, we define $\beta_{ij} = \max(0, \alpha_j-c(j, i))$ for any $i \in \mathcal{F}, j \in \mathcal{D}$, and define $N(i) = \{j \in \mathcal{D}: \beta_{ij} > 0\}$. We say that a facility $i$ is tight if $\sum_{j \in \mathcal{D}} \beta_{ij} = z_i$. Now, we define $\tau_i$ for each $i$ that is either tight or special (i.e., in $\mathcal{F}_S$). For each tight facility, we define $\tau_i = \max_{j \in N(i)} \alpha_j$, and for each special facility, we define $\tau_i = \max_{j \in N(i) \cap \mathcal{D}_S(i)} \alpha_j$. We default the maximum of an empty set to be $0$. We also consider a modified conflict graph $H := H(\delta)$ on the set of tight or special facilities, with an edge between $i$ and $i'$ if $c(i, i') \le \delta \cdot \min(\tau_i, \tau_{i'})$. \medskip We can now define the notion of \emph{roundable} solutions: our definition is slightly modified from \cite[Definition 5.1]{ahmadian2017better}. \begin{defn} \label{def:roundable} Let $\alpha \in \mathbb R^\mathcal{D},$ $z \in \mathbb R^\mathcal{F},$ $\mathcal{F}_S \subset \mathcal{F}$ be the set of special facilities, and $\mathcal{D}_S: \mathcal{F}_S \to \{0, 1\}^{\mathcal{D}}$ be the function assigning each special facility $i \in \mathcal{F}_S$ to a subset of special clients $\mathcal{D}_S(i)$. Then, the tuple $(\alpha, z, \mathcal{F}_S, \mathcal{D}_S)$ is \emph{$(\lambda, k')$-roundable} if \begin{enumerate} \item $\alpha$ is a feasible solution of $\text{DUAL}(\lambda + \frac{1}{n})$ and $\alpha_j \ge 1$ for all $j$. \item For all $i \in \mathcal{F},$ $\lambda \le z_i \le \lambda + \frac{1}{n}.$ \item There exists a subset $\mathcal{D}_B$ of ``bad'' clients so that for all $j \in \mathcal{D}$, there is a facility $w(j)$ that is either tight or in $\mathcal{F}_S$, such that: \begin{enumerate}[label=(\alph*)] \item For all $j \in \mathcal{D} \backslash \mathcal{D}_B$, $(1+\varepsilon) \cdot \alpha_j \ge c(j, w(j))$ \item For all $j \in \mathcal{D} \backslash \mathcal{D}_B$, $(1+\varepsilon) \cdot \alpha_j \ge \tau_{w(j)}$ \item $\gamma \cdot \text{OPT}_{k'} \ge \sum_{j \in \mathcal{D}_B} \left(c(j, w(j)) + \tau_{w(j)}\right)$ \end{enumerate} \item $\sum_{i \in \mathcal{F}_S} \sum_{j \in \mathcal{D}_S(i)} \max(0, \alpha_{j}-c(j, i)) \ge \lambda \cdot |\mathcal{F}_S| - \gamma \cdot \text{OPT}_{k'}$, and $|\mathcal{F}_S| \le n.$ \label{cond:4} \end{enumerate} Here, $\gamma \ll \varepsilon \ll 1$ are arbitrarily small constants, which are implicit parameters in the definition. Finally, we say that $(\alpha, z, \mathcal{F}_S, \mathcal{D}_S)$ is $k'$-roundable if it is $(\lambda, k')$-roundable for some choice of $\lambda \ge 0$. \end{defn} \begin{figure} \centering \begin{algorithm}[H] \caption{Generate Sequence of Nested Quasi-Independent Sets}\label{alg:main} \begin{algorithmic}[1] \State Initialize $\mathcal{S}^{(0)} = (\alpha^{(0)}, z^{(0)}, \mathcal{F}_S^{(0)}, \mathcal{D}_S^{(0)})$, and set $\lambda \leftarrow 0$, $I_1^{(0)} \leftarrow \mathcal{F}$, $I_2^{(0)} \leftarrow \emptyset$, $I_3^{(0)} \leftarrow \emptyset$ \State Set $I^{(0)} = (I_1^{(0)}, I_2^{(0)}, I_3^{(0)})$, $\varepsilon_z \leftarrow n^{-\text{poly}(\gamma^{-1})}$, $L \leftarrow 4n^7 \cdot \varepsilon_z^{-1}$, $k' \leftarrow \min(k, |I_1^{(0)}|),$ and $p_1 = 0.402$. \For{$\lambda = 0, \varepsilon_z, \dots, L \cdot \varepsilon_z$} \For{$i \in \mathcal{F}$} \State Call \Call{RaisePrice}{$\alpha^{(0)}, z^{(0)}, I_1^{(0)}, i$} to generate a polynomial-size sequence $\mathcal{S}^{(1)}, \dots, \mathcal{S}^{(q)}$ of close, $k'$-roundable solutions \For{$\ell = 0$ to $q-1$} \State Call \Call{GraphUpdate}{$\mathcal{S}^{(\ell)}, \mathcal{S}^{(\ell+1)}, I^{(\ell)}$} to produce a sequence $\{I^{(\ell, r)}\}_{r = 0}^{p_\ell}$ \For{$r = 1$ to $p_\ell$} \If{$|I_1^{(\ell, r)}|+p_1|I_2^{(\ell, r)} \cup I_3^{(\ell, r)}| < k$} \State Let $I = (I_1^{(\ell, r-1)}, I_2^{(\ell, r-1)}, I_3^{(\ell, r-1)})$, $I' = (I_1^{(\ell, r)}, I_2^{(\ell, r)}, I_3^{(\ell, r)})$, and \textbf{return} $(I, I')$ \Else \State $I^{(\ell+1)} \leftarrow I^{(\ell, p_{\ell})}$ \EndIf \EndFor \EndFor \State $\mathcal{S}^{(0)} \leftarrow \mathcal{S}^{(q)}$, $I^{(0)} \leftarrow I^{(q)}$ \State $k' \leftarrow \min(k', |I_1^{(0)}|)$ \EndFor \EndFor \end{algorithmic} \end{algorithm} \end{figure} Our main algorithm is described in Figure~\ref{alg:main}. This algorithm outputs two nested quasi-independent sets $I$ and $I'$. The final set $S$ will be obtained either from one of these two sets, or from some hybridization of them. We will defer the actual construction of $S$ to Theorem \ref{thm:main}. The method of \Call{RaisePrice}{} comes from \cite{ahmadian2017better}, and will not be of importance, apart from the results that they give us for the overall algorithm (see Theorem \ref{thm:ahmadian_roundable}). We will make some important definitions and set up the overall algorithm, and then describe the method of \Call{GraphUpdate}{}, which is slightly modified from \cite{ahmadian2017better}. First, we describe the initialization phase of Algorithm \ref{alg:main} to generate $\mathcal{S}^{(0)}$, which is almost identical to that of Ahmadian et al.~\cite[P. 22-23 of journal version]{ahmadian2017better}. The main difference is that we parameterized the procedure by $1+\kappa, 1/\kappa$ (instead of 2 and 6 in Ahmadian et al.) Start by setting $\lambda = 0$, $z_i^{(0)} = 0$ for all $i \in \mathcal{F}$, and $\mathcal{F}_S^{(0)} = \emptyset$ (so $\mathcal{D}_S^{(0)}$ has empty domain). We then set $\alpha_j^{(0)} = 0$ for all $j \in \mathcal{D}$. Now, we increase all of the $\alpha_j^{(0)}$ values simultaneously at a uniform rate, and for each $j$, we stop increasing $\alpha_j^{(0)}$ once one of the following $2$ events occur: \begin{enumerate} \item $\alpha_j^{(0)} = c(j, i)$ for some $i$. \item $(1+\kappa) \cdot \sqrt{\alpha_j} \ge d(j, j')+\frac{1}{\kappa} \cdot \sqrt{\alpha_{j'}}$ for some $j' \neq j$ (or $(1+\kappa) \cdot \alpha_j \ge d(j, j')+\frac{1}{\kappa} \cdot \alpha_{j'}$ in the $k$-median case). Here, $\kappa$ will be a fixed small constant (see Appendix \ref{app:why_am_i_doing_this} for details on how to set $\kappa$). \end{enumerate} In the initial solution, $\alpha_j^{(0)} \le \min_{i \in \mathcal{F}} c(j, i)$ for all $i \in \mathcal{F}$, which means that $N(i)$ is empty for all $i \in \mathcal{F}$, so $\tau_i = 0$. In addition, since every $z_i = 0$, every facility is tight. This means that the conflict graph $H(\delta)$ on the set of tight facilities for the initial solution we construct is just an empty graph on the full set of facilities, since $c(i, i') > 0 = \delta \cdot \min(\tau_i, \tau_{i'}).$ So, this means that if we apply Algorithm \ref{alg:lmp} to $V_1 = \mathcal{F}$, we will obtain that $I_1^{(0)} = \mathcal{F}$ and $I_2^{(0)} = I_3^{(0)} = \emptyset$. \medskip We now set up some definitions that will be important for the remainder of the algorithm and analysis. Define two dual solutions $\alpha = \{\alpha_j\}$ and $\alpha' = \{\alpha_j'\}$ to be \emph{close} if $\max_{j \in \mathcal{D}} |\alpha_j-\alpha_j'| \le \frac{1}{n^2}$. Consider two solutions $\mathcal{S}^{(\ell)} = (\alpha^{(\ell)}, z^{(\ell)}, \mathcal{F}_S^{(\ell)}, \mathcal{D}_S^{(\ell)})$ and $\mathcal{S}^{(\ell+1)} = (\alpha^{(\ell+1)}, z^{(\ell+1)}, \mathcal{F}_S^{(\ell+1)}, \mathcal{D}_S^{(\ell+1)})$ that are each $(\lambda, k')$-roundable for some choice of $\lambda$, such that $\alpha^{(\ell)}$ and $\alpha^{(\ell+1)}$ are close. This means that $|\alpha_j^{(\ell)}-\alpha_j^{(\ell+1)}| \le \frac{1}{n^2}$ for all $j \in \mathcal{D},$ and that $\lambda \le z_i^{(\ell)}, z_i^{(\ell+1)} \le \lambda+\frac{1}{n}$ for all $i \in \mathcal{F}$, even if $i$ is not tight. Let $\mathcal{V}^{(\ell)}$ represent the set of tight or special facilities in $\mathcal{S}^{(\ell)}$ and define $\mathcal{V}^{(\ell+1)}$ likewise. Let $\sqcup$ denote the disjoint union, i.e., $S \sqcup T$ is a set consisting of a copy of each element in $S$ and a distinct copy of each element in $T$. For each point $i \in \mathcal{V}^{(\ell)} \sqcup \mathcal{V}^{(\ell+1)}$, we define $\mathcal{D}_S(i)$ (if $i$ were a special facility), $\tau_i$, and $z_i$ based on whether $i$ came from $\mathcal{V}^{(\ell)}$ or from $\mathcal{V}^{(\ell+1)}$. This means that for $i \in \mathcal{V}^{(\ell)}$, $\mathcal{D}_S(i) = \mathcal{D}^{(\ell)}_S(i)$, $z_i = z_i^{(\ell)}$, and $\tau_i = \tau_i^{(\ell)} = \max_{j: \alpha_j^{(\ell)} > c(j, i)} \alpha_j^{(\ell)}$ if $i$ is tight and $\tau_i = \tau_i^{(\ell)} = \max_{j: \alpha_j^{(\ell)} > c(j, i), j \in \mathcal{D}_S^{(\ell)}(i)} \alpha_j^{(\ell)}$ if $i$ is special (and likewise for $i \in \mathcal{V}^{(\ell+1)}$). In addition, for each client $j \in \mathcal{D}$, we define $\alpha_j = \min(\alpha_j^{(\ell)}, \alpha_j^{(\ell+1)})$; for each $j \in \mathcal{D}$ and $i \in \mathcal{V}^{(\ell)} \sqcup \mathcal{V}^{(\ell+1)}$, we define $\beta_{ij} = \max(0, \alpha_j-c(j, i))$; and for each $i \in \mathcal{F}$, we let $N(i) = \{j \in \mathcal{D}: \alpha_j-c(j, i) > 0\}$. Since $\alpha_j = \min(\alpha_j^{(\ell)}, \alpha_j^{(\ell+1)}),$ this means $N(i) \subset N^{(\ell)}(i)$ if $i \in \mathcal{V}^{(\ell)}$ and $N(i) \subset N^{(\ell+1)}(i)$ if $i \in \mathcal{V}^{(\ell+1)}.$ We create a \emph{hybrid conflict graph} on a subset of the disjoint union $\mathcal{V}^{(\ell)} \sqcup \mathcal{V}^{(\ell+1)}$. First, we let $H^{(\ell, 0)}(\delta)$ represent the conflict graph on $\mathcal{V}^{(\ell, 0)} := \mathcal{V}^{(\ell)}$. The conflict graph on a set of facilities means there is an edge between two vertices $(i, i')$ if $c(i, i') \le \delta \cdot \min(\tau_i, \tau_{i'})$. Next, we choose some ordering of the vertices in $\mathcal{V}^{(\ell)}$, and for each $1 \le r \le p_\ell := |\mathcal{V}^{(\ell)}|+1$, we let $V^{(\ell, r)}$ represent the vertices of the so-called \emph{merged vertex set} defined as $\mathcal{V}^{(\ell)} \sqcup \mathcal{V}^{(\ell+1)}$ after we removed the first $r-1$ vertices in $\mathcal{V}^{(\ell)}$, and let $H^{(\ell, r)}(\delta)$ represent the conflict graph on $\mathcal{V}^{(\ell, r)}$, where again the conflict graph means that $i, i' \in \mathcal{V}^{(\ell, r)}$ share an edge if $c(i, i') \le \delta \cdot \min(\tau_i, \tau_{i'})$. Note that $\mathcal{V}^{(\ell, 1)} = \mathcal{V}^{(\ell)} \sqcup \mathcal{V}^{(\ell+1)}$. For simplicity of notation, we may abbreviate $\mathcal{V}^{(\ell, r)}$ as $\mathcal{V}$ and $H^{(\ell, r)}(\delta)$ as $H(\delta)$ if the context is clear. In the context of a hybrid conflict graph $\mathcal{V}^{(\ell, r)}$, for any client $j$, let $\bar{N}(j)$ be the subset of $\mathcal{V}^{(\ell, r)}$ consisting of all tight facilities $i$ such that $j \in N(i)$ and all special facilities $i$ such that $j \in N(i) \cap \mathcal{D}_S(i)$. We also define $w(j)$ as the witness for $j$ in the solution $\mathcal{S}^{(\ell+1)}$, and $\mathcal{D}_B$ as the set of bad clients from the solution $\mathcal{S}^{(\ell+1)}$. Finally, to describe the actual \Call{GraphUpdate}{} procedure, it works as follows. First, we note that $I^{(0, 0)} = I^{(0)}$ which has already been decided, either by the first initialized solution or from the previous solution $I^{(q)}$ before we reset $I^{(0)} = I^{(q)}$. Otherwise, $I^{(\ell+1, 0)} = I^{(\ell, p_\ell)}$ since the set of vertices $\mathcal{V}^{(\ell+1, 0)} = \mathcal{V}^{(\ell+1)} = \mathcal{V}^{(\ell, p_\ell)}$. Finally, we note that $|\mathcal{V}^{(\ell, r)} \backslash \mathcal{V}^{(\ell, r+1)}| \le 1,$ since for $r = 0$ $\mathcal{V}^{(\ell, r)} \subset \mathcal{V}^{(\ell, r+1)}$ and otherwise, $\mathcal{V}^{(\ell, r+1)}$ is created by simply removing one element from $\mathcal{V}^{(\ell, r)}$. So, the maximal independent set $I_1^{(\ell, r)}$ of $H^{(\ell, r)}(\delta_1)$ can easily be extended to a maximal independent set $I_1^{(\ell, r+1)}$ of $H^{(\ell, r+1)}(\delta_1)$ by deleting at most $1$ element and then possibly extending the independent set. We then extend $I_1^{(\ell, r+1)}$ arbitrarily based on Steps \ref{step:V2} to \ref{step:I3} to create $I_2^{(\ell, r+1)}$ and $I_3^{(\ell, r+1)}$, where $I_2^{(\ell, r+1)}$ and $I_3^{(\ell, r+1)}$ may have no relation to $I_2^{(\ell, r)}$ and $I_3^{(\ell, r)}$. So, we inductively create $I^{(\ell, r+1)} = (I_1^{(\ell, r+1)}, I_2^{(\ell, r+1)}, I_3^{(\ell, r+1)})$ from $I^{(\ell, r)} = (I_1^{(\ell, r)}, I_2^{(\ell, r)}, I_3^{(\ell, r)})$, where importantly $|I_1^{(\ell, r)} \backslash I_1^{(\ell, r+1)}| \le 1$. \input{reducing_num_centers} \subsection{Analysis} \label{subsec:k_means_analysis} The following theorem relating to the above algorithm was (essentially) proven by Ahmadian et al.~\cite{ahmadian2017better}, and will be very important in our analysis. \begin{theorem} \label{thm:ahmadian_roundable} Algorithm \ref{alg:main} runs in $n^{O(1)}$ time (where the $O(1)$ may depend on $\varepsilon$ and $\gamma$), and the following conditions hold. \begin{enumerate} \item Let $k'$ be the minimum of $k$ and the sizes of all sets that become $I_1^{(0)}$ (i.e., the first part of each nested quasi-independent set $I^{(q)}$ that becomes $I^{(0)}$, as done in line 13 of the pseudocode). Then, every solution $\mathcal{S}^{(\ell)}$ that is generated when $\lambda$ is a certain value is $(\lambda, k')$-roundable. \label{cond:roundable} \item For any solution $\mathcal{S}$ that becomes $\mathcal{S}^{(0)}$, $\mathcal{F}_S^{(0)} = \emptyset$ (and so $\mathcal{D}_S^{(0)}$ is an empty function). In addition, $\mathcal{S} = \mathcal{S}^{(0)}$ has no corresponding bad clients, i.e., $\mathcal{D}_B = \emptyset$. \label{cond:no_special_or_bad} \item For any two consecutive solutions $\mathcal{S}^{(\ell)}$ and $\mathcal{S}^{(\ell+1)}$, we have that $\alpha^{(\ell)}$ and $\alpha^{(\ell+1)}$ are close. \label{cond:close} \item Every $I^{(\ell, r)}=(I_1^{(\ell, r)}, I_2^{(\ell, r)}, I_3^{(\ell, r)})$ is a nested quasi-independent set for the set of facilities $\mathcal{V}^{(\ell, r)}$. In addition, for every $1 \le r \le p_\ell$, $|I_1^{(\ell, r-1)} \backslash I_1^{(\ell, r)}| \le 1.$ \end{enumerate} \end{theorem} This theorem is technically stronger than what was proven in \cite{ahmadian2017better}, but follows from a nearly identical analysis to their paper, with a very minor tweak to the algorithm. We explain why Theorem \ref{thm:ahmadian_roundable} follows from their analysis in Appendix \ref{app:why_am_i_doing_this}. \medskip For the following lemmas (Lemmas \ref{lem:tau_bigger_than_alpha} until Proposition \ref{prop:duality_bound}), we consider a fixed family of conflict graphs $\{H(\delta)\}_{\delta > 0} = \{H^{(\ell, r)}(\delta)\}_{\delta > 0}$ on a hybrid set $\mathcal{V}=\mathcal{V}^{(\ell, r)}$, for some $r \ge 1$, where both $\mathcal{S}^{(\ell)}$ and $\mathcal{S}^{(\ell+1)}$ are $(\lambda, k')$-roundable. For some fixed $\delta_1 \ge \delta_2 \ge 2 \ge \delta_3,$ we let $(I_1, I_2, I_3)$ be a nested quasi-independent set of $\{H(\delta)\}$, i.e., the output of running all but the final step of Algorithm \ref{alg:lmp} with $V_1 = \mathcal{V}$, and treat it as fixed. However, we will let $p$ (required in the final step \ref{step:S}) be variable, though we may consider $p$ as initialized to some fixed $p_1$. Many of these results apply for both $k$-means and $k$-median. While we focus on $k$-means, we later explain how to make simple modifications to apply our results to the $k$-median problem. In addition, we will treat $\delta_1, \delta_2, \delta_3$ as fixed but $p$ as potentially variable. We let $\rho(p)$ represent the approximation constant from the LMP algorithm (i.e., in Lemma \ref{lem:main_lmp}) with probability $p$ (either for $k$-means or $k$-median, depending on constant). We first show some crucial preliminary claims relating to the hybrid graph $\mathcal{V}^{(\ell, r)}$, where $r \ge 1.$ \begin{lemma} \label{lem:tau_bigger_than_alpha} For any client $j \in \mathcal{D}$ and any facility $i \in \bar{N}(j)$, $\tau_i \ge \alpha_j > c(j, i)$. \end{lemma} \begin{proof} Note that if $i \in \mathcal{V}^{(\ell)}$, then $\tau_i$ is the maximum $\alpha_{j'}^{(\ell)}$ over $j'$ such that $\alpha_{j'}^{(\ell)} > c(j', i)$ and $j' \in \mathcal{D}_S^{(\ell)}(i)$ if $i$ is special. Since $\alpha_{j'}^{(\ell)} > \alpha_{j'}$, this is at least the maximum $\alpha_{j'}$ over $j'$ such that $\alpha_{j'} > c(j', i)$ and $j' \in \mathcal{D}_S^{(\ell)}(i)$ if $i$ is special. But if $i \in \bar{N}(j)$, then indeed $\alpha_j > c(j, i)$ and $j \in \mathcal{D}_S^{(\ell)}(i)$ if $i$ is special (recall that $\mathcal{D}_S$ was defined based on whether $i$ is in $\mathcal{V}^{(\ell)}$ or $\mathcal{V}^{(\ell+1)}$). So, $\tau_i \ge \alpha_j$. By an identical argument, the same holds if $i \in \mathcal{V}^{(\ell+1)}$. Finally, note that we defined $\bar{N}(j)$ to precisely be the set of tight facilities $i$ in $\mathcal{V}$ with $\alpha_j > c(j, i)$, or special facilities $i$ in $\mathcal{V}$ with $\alpha_j > c(j, i)$ and $j \in \mathcal{D}_S(i)$. So, we always have $\alpha_j > c(j, i)$. \end{proof} \begin{lemma} \label{lem:RHS_positive_1/2} Suppose that $S \subset I_1 \cup I_2 \cup I_3$ contains every point in $I_1$, and each point in $I_2$ and each point in $I_3$ with probability $p \le 0.5$ (not necessarily independently). Then, for any point $j$, \[\mathbb E\left[\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right] \ge 0.\] \end{lemma} \begin{remark} We note that this lemma holds even for bad clients $j \in \mathcal{D}_B$. In addition, we remark that we will be applying this lemma on $S$ as a nested quasi-independent set or something similar. Finally, we note that this lemma (and the following lemma, Lemma \ref{lem:cost_j_upper_bound}) are the only results where we directly use the fact that we are studying the $k$-means as opposed to the $k$-median problem. \end{remark} \begin{proof}[Proof of Lemma \ref{lem:RHS_positive_1/2}] Note that every point $i \in \bar{N}(j) \cap S$ satisfies $\tau_i \ge \alpha_j$ and $\alpha_j-c(j, i) > 0$, by Lemma \ref{lem:tau_bigger_than_alpha}. So, by linearity of expectation, it suffices to show that \begin{equation} \label{eq:I2I3_bound} \alpha_j \ge \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i)) + \frac{1}{2} \cdot \sum_{i \in \bar{N}(j) \cap I_2} (\alpha_j-c(j, i)) + \frac{1}{2} \cdot \sum_{i \in \bar{N}(j) \cap I_3} (\alpha_j-c(j, i)). \end{equation} Now, note that by the definition of $I_2$, every pair of points $(i, i')$ in $(I_1 \cup I_2) \cap \bar{N}(j)$ are separated by at least $\sqrt{\delta_2 \cdot \min(\tau_i, \tau_{i'})}$ distance. But since $i, i' \in \bar{N}(j)$, $\min(\tau_i, \tau_{i'}) \ge \alpha_j$ by Lemma \ref{lem:tau_bigger_than_alpha}. So, $d(i, i') \ge \sqrt{2 \cdot \alpha_j}$. Therefore, \begin{align} \sum_{i \in \bar{N}(j) \cap (I_1 \cup I_2)} (\alpha_j-c(j, i)) \nonumber &\le |I_1 \cup I_2| \cdot \alpha_j - \frac{1}{2 \cdot |I_1 \cup I_2|} \cdot \sum_{i, i' \in \bar{N}(j) \cap (I_1 \cup I_2)} d(i, i')^2 \nonumber \\ &\le |I_1 \cup I_2| \cdot \alpha_j - \frac{1}{2 \cdot |I_1 \cup I_2|} \cdot (|I_1 \cup I_2|) \cdot (|I_1 \cup I_2|-1) \cdot 2 \cdot \alpha_j \nonumber \\ &= \alpha_j. \label{eq:I2_bound} \end{align} Likewise, every pair of points $(i, i')$ in $(I_1 \cup I_3) \cap \bar{N}(j)$ are also separated by at least $\sqrt{\delta_2 \cdot \min(\tau_i, \tau_{i'})} \ge \sqrt{2 \cdot \alpha_j}$ distance. Therefore, the same calculations as in \eqref{eq:I2_bound} give us \begin{equation} \label{eq:I3_bound} \sum_{i \in \bar{N}(j) \cap (I_1 \cup I_3)} (\alpha_j-c(j, i)) \le \alpha_j. \end{equation} Averaging Equations \eqref{eq:I2_bound} and \eqref{eq:I3_bound} gives us Equation \eqref{eq:I2I3_bound}, which finishes the lemma. \end{proof} We next have the following lemma, which bounds the cost for clients that are not bad. \begin{lemma} \label{lem:cost_j_upper_bound} Let $p < 0.5$ and $S$ be generated by applying Step \ref{step:S} to $(I_1, I_2, I_3)$. Then, for every client $j \not\in \mathcal{D}_B$, \[\mathbb E[c(j, S)] \le \rho(p) \cdot (1+O(\varepsilon)) \cdot \mathbb E\left[\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right],\] where $\rho(p)$ represents the constant from Lemma \ref{lem:main_lmp}. \end{lemma} \begin{proof} By Lemma \ref{lem:tau_bigger_than_alpha}, we have that $\tau_i \ge \alpha_j$ for all $i \in \bar{N}(j)$. In addition, for every $j \not\in \mathcal{D}_B$, there exists a point $w(j)$ in $\mathcal{V}^{(\ell+1)}$ (so it has not been removed, i.e., it is still in $\mathcal{V} = \mathcal{V}^{(\ell, r)}$) such that $(1+\varepsilon) \cdot \alpha_j^{(\ell+1)} \ge c(j, w(j))$ and $(1+\varepsilon) \cdot \alpha_j^{(\ell+1)} \ge \tau_{w(j)}$. Since $\alpha_j^{(\ell+1)} \ge 1$ for all $j$ and $|\alpha_j-\alpha_j^{(\ell+1)}| \le \frac{1}{n^2},$ this means that $(1+O(\varepsilon)) \cdot \alpha_j \ge c(j, w(j)), \tau_{w(j)}$. These pieces of information are sufficient for all of our calculations from Lemma \ref{lem:main_lmp} to go through. \end{proof} We note that the expression $\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))$ may be somewhat unwieldy. Therefore, we provide an upper bound on its sum over $j \in \mathcal{D}.$ \begin{lemma} \label{lem:ugly_upper_bound} Let $S$ be any subset of $\mathcal{V} = \mathcal{V}^{(\ell, r)}$. Then, \[\sum_{j \in \mathcal{D}} \left(\alpha_j-\sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right) \le \sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot |S| + 4 \gamma \cdot \text{OPT}_{k'}.\] \end{lemma} \begin{remark} We note that this lemma holds even when $\lambda < \frac{1}{n}$, i.e., $\lambda-\frac{1}{n} < 0$. \end{remark} \begin{proof} First, by splitting the sum based on tight and special facilities, we have that \begin{align} &\hspace{0.5cm} \sum_{j \in \mathcal{D}}\left(\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right) \nonumber \\ &= \sum_{j \in \mathcal{D}} \alpha_j - \sum_{\substack{i \in S \\ i \text{ tight}}} \sum_{j \in N(i)} (\alpha_j-c(j, i)) - \sum_{\substack{i \in S \\ i \text{ special}}} \sum_{j \in N(i) \cap \mathcal{D}_S(i)} (\alpha_j-c(j, i)). \label{eq:alpha_j_1} \end{align} Now, we note that for any tight facility $i$, either $\sum_{j \in \mathcal{D}} \max(0, \alpha_j^{(\ell)}-c(j, i)) = z_i^{(\ell)} \in [\lambda, \lambda+\frac{1}{n}]$ or $\sum_{j \in \mathcal{D}} \max(0, \alpha_j^{(\ell+1)}-c(j, i)) = z_i^{(\ell+1)} \in [\lambda, \lambda+\frac{1}{n}]$. Since $\alpha^{(\ell)}$ and $\alpha^{(\ell+1)}$ are close, this means $0 \le \alpha_j^{(\ell)}-\alpha_j, \alpha_j^{(\ell+1)}-\alpha_j \le \frac{1}{n^2}$, and since there are $n$ clients in $\mathcal{D}$, this means that \begin{equation} \sum_{j \in N(i)} (\alpha_j-c(j, i)) = \sum_{j \in \mathcal{D}} \max(\alpha_j-c(j, i), 0) \ge \sum_{j \in \mathcal{D}} \max\left(\alpha_j^{(\ell')}-c(j, i)-\frac{1}{n^2}, 0\right) \ge \lambda-\frac{1}{n}, \label{eq:alpha_j_2} \end{equation} for some choice of $\ell'$ in $\{\ell, \ell+1\}$. In addition, we know that both $\alpha^{(\ell)}$ and $\alpha^{(\ell+1)}$ are feasible solutions of $\text{DUAL}(\lambda+\frac{1}{n})$, and that $\alpha_j \le \alpha_j^{(\ell)}, \alpha_j^{(\ell+1)}$. Therefore, for any special facility $i \in \mathcal{F}_S^{(\ell)} \sqcup \mathcal{F}_S^{(\ell+1)}$, $\sum_{j \in N(i) \cap \mathcal{D}_S(i)} (\alpha_j-c(j, i)) \le \sum_{j \in \mathcal{D}} \max(0, \alpha_j-c(j, i)) \le \lambda+\frac{1}{n}$. But, we have that \begin{align*} \sum_{i \in \mathcal{F}_S^{(\ell')}} \sum_{j \in N(i) \cap \mathcal{D}_S^{(\ell')}(i)} (\alpha_j-c(j, i)) &\ge \sum_{i \in \mathcal{F}_S^{(\ell')}} \sum_{j \in \mathcal{D}_S^{(\ell')}(i)} \max\left(0, \alpha_j^{(\ell')}-\frac{1}{n^2}-c(j, i)\right) \\ &\ge \lambda \cdot |\mathcal{F}_S^{(\ell')}| - \gamma \cdot \text{OPT}_{k'} - \frac{|\mathcal{F}_S^{(\ell')}|}{n}, \end{align*} for both $\ell' = \ell$ and $\ell' = \ell+1$ (the last inequality follows by Condition \ref{cond:4} of Definition \ref{def:roundable}). So, if we let $e_i$ represent $\lambda+\frac{1}{n} - \sum_{j \in N(i) \cap \mathcal{D}_S(i)} ( \alpha_j-c(j, i))$ for each special facility $i$, we have that $e_i \ge 0$ but $\sum_{i \in \mathcal{F}_S^{(\ell)}} e_i \le \frac{2}{n} \cdot |\mathcal{F}_S^{(\ell)}| + \gamma \cdot \text{OPT}_{k'} \le 2 \gamma \cdot \text{OPT}_{k'}$, since $|\mathcal{F}_S^{(\ell)}| \le n$ and $\text{OPT}_{k'} \ge n \ge \frac{2}{\gamma}$. Similarly, $\sum_{i \in \mathcal{F}_S^{(\ell+1)}} e_i \le 2 \gamma \cdot \text{OPT}_{k'}.$ So, this means that \[\sum_{\substack{i \in S \\ i \text{ special}}} e_i \le 4 \gamma \cdot \text{OPT}_{k'},\] which means that \begin{align} \sum_{\substack{i \in S \\ i \text{ special}}} \sum_{j \in N(i) \cap \mathcal{D}_S(i)} (\alpha_j-c(j, i)) &\ge \sum_{\substack{i \in S \\ i \text{ special}}} \left(\lambda + \frac{1}{n} - e_i\right) \nonumber \\ &\ge \left(\lambda+\frac{1}{n}\right) \cdot |\{i \in S: i \text{ special}\}|-4 \gamma \cdot \text{OPT}_{k'}. \label{eq:alpha_j_3} \end{align} Thus, by combining Equations \eqref{eq:alpha_j_1}, \eqref{eq:alpha_j_2}, and \eqref{eq:alpha_j_3}, we get \begin{align*} \sum_{j \in \mathcal{D}} \left(\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right) &\le \sum_{j \in \mathcal{D}} \alpha_j - \sum_{\substack{i \in S \\ i \text{ tight}}} \left(\lambda-\frac{1}{n}\right) - \left(\lambda+\frac{1}{n}\right) \cdot |\{i \in S: i \text{ special}\}|+4 \gamma \cdot \text{OPT}_{k'} \\ &\le \sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot |S| + 4 \gamma \cdot \text{OPT}_{k'}. \qedhere \end{align*} \end{proof} Next, we show that the bad clients do not contribute much to the total cost. \begin{lemma} \label{lem:cost_bad_upper_bound} Let $S$ be a subset of $\mathcal{V}$ containing $I_1$. Then, we have that \[\sum_{j \in \mathcal{D}_B} c(j, S) \le O(\gamma) \cdot \text{OPT}_{k'}.\] \end{lemma} \begin{proof} Note that for every point $j \in \mathcal{D}_B$, there exists a facility $w(j) \in \mathcal{V}^{(\ell+1)}$ such that \[\sum_{j \in \mathcal{D}_B} \left(c(j, w(j)) + \tau_{w(j)}\right) \le O(\gamma) \cdot \text{OPT}_{k'},\] because $\mathcal{S}^{(\ell+1)}$ is $(\lambda, k')$-roundable. Now, note that $d(j, S) \le d(j, I_1) \le d(j, w(j)) + d(w(j), I_1)$, so $c(j, S) \le 2 [c(j, w(j)) + c(w(j), I_1)]$. But since $w(j) \in \mathcal{V}^{(\ell+1)} \subset \mathcal{V}$, $c(w(j), I_1) \le \delta_1 \cdot \tau_{w(j)}$, and therefore, \[\sum_{j \in \mathcal{D}_B} c(j, S) \le 2 \cdot \sum_{j \in \mathcal{D}_B} \left(c(j, w(j)) + \delta_1 \cdot \tau_{w(j)}\right) \le O(\gamma) \cdot \text{OPT}_{k'},\] where the final inequality follows by Condition 3c) of Definition \ref{def:roundable}. \end{proof} We now combine our previous lemmas to obtain the following bound on the expected cost of $S$, giving a result that bounds the overall expected cost in terms of the dual solution. \begin{lemma} \label{lem:expected_cost_S} Suppose that $S$ is generated by applying Step \ref{step:S} to $(I_1, I_2, I_3)$ with the probability set to $p < 0.5$. Then, the expected cost $\mathbb E[\text{cost}(\mathcal{D}, S)]$ is at most \[\rho(p) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot \mathbb E[|S|]\right] + O(\gamma) \cdot \text{OPT}_{k'},\] where $\rho(p)$ represents the constant from Lemma \ref{lem:main_lmp}. \end{lemma} \begin{proof} We will abbreviate $\rho := \rho(p)$. We can split up the cost based on good (i.e., not in $\mathcal{D}_B$) points $j$ and bad points $j$. Indeed, doing this, we get \begin{align*} \mathbb E[\text{cost}(\mathcal{D}, S)] &= \sum_{j \not\in \mathcal{D}_B} \mathbb E[c(j, S)] + \sum_{j \in \mathcal{D}_B} \mathbb E[c(j, S)] \\ &\le \rho \cdot (1+O(\varepsilon)) \cdot \sum_{j \not\in \mathcal{D}_B} \mathbb E\left[\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right] + O(\gamma) \cdot \text{OPT}_{k'} \\ &\le \rho \cdot (1+O(\varepsilon)) \cdot \sum_{j \in \mathcal{D}} \mathbb E\left[\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right] + O(\gamma) \cdot \text{OPT}_{k'} \\ &\le \rho \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot \mathbb E[|S|]\right] + O(\gamma) \cdot \text{OPT}_{k'}. \end{align*} In the above equation, the second line follows from Lemmas \ref{lem:cost_j_upper_bound} and \ref{lem:cost_bad_upper_bound}. The third line is true since $\mathbb E\left[\alpha_j-\sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right] \ge 0$ for all $j$, even in $\mathcal{D}_B$, by Lemma \ref{lem:RHS_positive_1/2}. Finally, the fourth line is true because of Lemma \ref{lem:ugly_upper_bound}. \end{proof} Next, we show that under certain circumstances, we can find a solution $S$ of size at most $k$ satisfying a similar condition to Lemma \ref{lem:expected_cost_S}, with high probability. \begin{lemma} \label{lem:cost_bound} Suppose that $|I_1|+p \cdot |I_2 \cup I_3| = k$ for some integer $k$ (which may be larger than $n$) and some $p \in [0.01, 0.49]$. Then, for any sufficiently large integer $C$, if $|I_2 \cup I_3| \ge 100 \cdot C^{4}$, then there exists a polynomial-time randomized algorithm that outputs a set $S$ such that $I_1 \subset S \subset I_1 \cup I_2 \cup I_3$, and with probability at least $9/10$, $|S| \le k$ and $$\text{cost}(\mathcal{D}, S) \le \rho\left(p-\frac{2}{C}\right) \cdot \left(1+\frac{300}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k\right] + O(\gamma) \cdot \text{OPT}_{k'}.$$ \end{lemma} \begin{remark} By repeating this randomized algorithm polynomially many times and outputting the lowest-cost solution $S$ with $|S| \le k$, we can make the failure probability exponentially small. \end{remark} \begin{proof} Let $r = |I_2|$, and partition $I_2 \cup I_3$ into $T_1, \dots, T_r$, where each $T_\ell$ consists of a point $i_2 \in I_2$ and $q^{-1}(i_2)$, i.e., $i_2$'s preimage under the map $q$. We assume WLOG that the $T_\ell$'s are sorted in non-increasing order of size, and write $x_\ell$ as the unique point in $T_\ell \cap I_2$. Define $s$ such that $|T_1| \ge \dots \ge |T_s| \ge C > |T_{s+1}| \ge \dots \ge |T_r|$ (note that $s$ may be $0$ or $r$). Note that $s \le \frac{|I_2 \cup I_3|}{C}$ so $\frac{s}{|I_2 \cup I_3|} \le \frac{1}{C}$. Now, set $p' = p-\frac{2}{C}$, and consider creating the following set $S$: \begin{itemize} \item For each $i \in I_1,$ include $i \in S$. \item For each $\ell \le s,$ include $x_\ell \in S$, and for each $i$ in $T_\ell \backslash \{x_\ell\}$, include $i \in S$ independently with probability $p'$. \item For each $\ell > s,$ flip a fair coin. If it lands heads, include $x_\ell$ with probability $2p'$, and if it lands tails, include each point in $T_\ell \backslash \{x_\ell\}$ independently with probability $2p'$. \end{itemize} The expected size of $S$ is $|I_1| + s + (|T_1| + \cdots + |T_s| - s) \cdot p' + (|T_{s+1}|+\cdots+|T_r|) \cdot p' = |I_1| + p' \cdot |I_2 \cup I_3| + (1-p') \cdot s \le |I_1|+p' \cdot |I_2 \cup I_3| + s.$ Therefore, since $p' = p-\frac{2}{C},$ the expected size of $S$ as at most $|I_1|+(p-\frac{2}{C}) \cdot |I_2 \cup I_3| + \frac{|I_2 \cup I_3|}{C} = |I_1| + (p-\frac{1}{C}) \cdot |I_2 \cup I_3|.$ To bound the variance of $S$, we note that each point in $I_1$ and each $x_\ell$ for $\ell \le s$ is deterministically in $S$, each point in $T_\ell \backslash \{x_\ell\}$ for $\ell \le s$ is independently selected with probability $p'$, and the number of points from each $T_\ell$ for $\ell > s$ is some independent random variable bounded by $|T_\ell| \le C$. So, the variance can be bounded by $(|T_1|+\cdots+|T_s|) + \sum_{\ell = s+1}^{r} |T_\ell|^2 \le \max_{s+1 \le \ell \le r} |T_\ell| \cdot \left(|T_1|+\cdots+|T_r|\right) \le C \cdot |I_2 \cup I_3|$. So, by Chebyshev's inequality, with probability at least $1-\frac{1}{10C}$, \begin{align*} |S| &\le |I_1|+(p-\frac{1}{C}) \cdot |I_2 \cup I_3| + \sqrt{10 C \cdot C \cdot |I_2 \cup I_3|} \\ &\le |I_1|+p|I_2 \cup I_3| - \frac{1}{C} |I_2 \cup I_3| + \sqrt{10} C \cdot \sqrt{|I_2 \cup I_3|} \\ &\le |I_1|+p|I_2 \cup I_3| = k, \end{align*} where the final inequality is true since $|I_2 \cup I_3| \ge 100 C^4$. Next, we bound the expected cost of $S$. First, consider running the final step \ref{step:S} of the LMP algorithm on $(I_1, I_2, I_3)$ using probability $p'$. This would produce a set $S_0$ such that \begin{align} \mathbb E\left[\text{cost}(\mathcal{D}, S_0)\right] &\le \rho(p') \cdot (1+O(\varepsilon)) \cdot \mathbb E\left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot \mathbb E[|S_0|]\right] + O(\gamma) \cdot \text{OPT}_{k'} \nonumber\\ &= \rho\left(p-\frac{2}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot \left(|I_1|+\left(p-\frac{2}{C}\right) \cdot |I_2 \cup I_3|\right)\right] + O(\gamma) \cdot \text{OPT}_{k'} \nonumber\\ &= \rho\left(p-\frac{2}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k + \frac{2}{C} \cdot \left(\lambda-\frac{1}{n}\right) \cdot |I_2 \cup I_3|\right] + O(\gamma) \cdot \text{OPT}_{k'}. \label{eq:cost_D_S0} \end{align} Above, the first line follows by Lemma \ref{lem:expected_cost_S}, the second line follows by definition of $p'$ and $S_0$, and the third line follows from the fact that $|I_1| + p|I_2 \cup I_3| = k$. Now, note that if we had performed the final step of the LMP algorithm on $(I_1, I_2, I_3)$ using probability $1/2$ instead of $p'$, the set (call it $S_1$) would have satisfied \[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot \left(|I_1|+\frac{1}{2}(|I_2|+|I_3|)\right) + 4 \gamma \cdot \text{OPT}_{k'} \ge \mathbb E\left[\sum_{j \in \mathcal{D}} \left(\alpha_j - \sum_{i \in \bar{N}(j) \cap S} (\alpha_j-c(j, i))\right)\right] \ge 0\] by Lemmas \ref{lem:ugly_upper_bound} and \ref{lem:RHS_positive_1/2}. This means that $\sum_{j \in \mathcal{D}} \alpha_j \ge (\lambda-\frac{1}{n}) \cdot (|I_1|+1/2 \cdot |I_2 \cup I_3|) - 4 \gamma \cdot \text{OPT}_{k'}.$ Therefore, again using the fact that $|I_1|+p \cdot |I_2 \cup I_3| = k$, we have that \[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k \ge \left(\lambda-\frac{1}{n}\right) \cdot \left(\frac{1}{2}-p\right) \cdot |I_2 \cup I_3| - 4\gamma \cdot \text{OPT}_{k'}.\] We can rewrite this to obtain \begin{equation} \label{eq:remainder_bound} \left(\lambda-\frac{1}{n}\right) \cdot |I_2 \cup I_3| \le \frac{1}{1/2-p} \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k\right) + O(\gamma) \cdot \text{OPT}_{k'}, \end{equation} since $p \in [0.01, 0.49]$. In this and the next paragraph, we prove that $\mathbb E[\text{cost}(\mathcal{D}, S)] \le \mathbb E[\text{cost}(\mathcal{D}, S_0)]$. To see why, we consider a coupling of the randomness to generate a sequence of sets $S_0, S_1, \dots, S_s = S$. To do so, for each point $i \in I_1$, we automatically include $i \in S = S_s$ and $i \in S_h$ for all $0 \le h < s$. Now, for each $1 \le \ell \le r$, we first create a temporary set $\tilde{T}_{\ell} \subset T_\ell \backslash \{x_{\ell}\}$ by including each point $i \in T_\ell \backslash \{x_{\ell}\}$ to be in $\tilde{T}_\ell$ independently with probability $2p$. Then, we create two sets $T_\ell^{(0)} \subset T_\ell$ and $T_{\ell}^{(1)} \subset T_\ell$ as follows. For $T_\ell^{(0)}$, we include each point in $\tilde{T}_\ell$ independently, with probability $1/2$, and always include $x_\ell \in T_\ell^{(0)}$. For $T_\ell^{(1)}$, we flip a fair coin: if the coin lands heads, we only include $x_\ell$, but if the coin lands tails, we do not include $x_\ell$ but include all of $\tilde{T}_\ell$. We remark that overall, $T_\ell^{(0)}$ includes each point in $T_\ell \backslash \{x_\ell\}$ independently with probability $p$. Now, for each $0 \le h \le s$, we define $S_h := \left(\bigcup_{1 \le \ell \le h} T_\ell^{(0)}\right) \cup \left(\bigcup_{h < \ell \le r} T_\ell^{(1)}\right)$. One can verify that $S$ and $S_0$ have the desired distribution, since $S_0 = \bigcup_{1 \le \ell \le r} T_\ell^{(1)}$ is precisely the distribution obtained after applying step \ref{step:S} of the LMP algorithm on $(I_1, I_2, I_3)$, but $S$ takes $T_\ell^{(0)}$ instead of $T_\ell^{(1)}$ for each $\ell \le s$, which is precisely the desired distribution for $S$ (as we defined $S$ at the beginning of this lemma's proof). To show that $\mathbb E[\text{cost}(\mathcal{D}, S)] \le \mathbb E[\text{cost}(\mathcal{D}, S_0)]$, it suffices to show that $\mathbb E[\text{cost}(\mathcal{D}, S_h)] \le \mathbb E[\text{cost}(\mathcal{D}, S_{h-1})]$ for all $1 \le h \le s$. However, note that because of our coupling, the only difference between $S_h$ and $S_{h-1}$ relates to points in $T_h$. If we let $S_{h-1}' = S_{h-1} \cup \{x_\ell\}$ be the set that always includes $x_\ell$ but includes the entirety of $\tilde{T}_h$ with probability $1/2$, then clearly $\mathbb E[\text{cost}(\mathcal{D}, S_{h-1}')] \le \mathbb E[\text{cost}(\mathcal{D}, S_{h-1})]$. In addition, if we condition on the set $\tilde{T}_h$, the only difference between $S_{h-1}'$ and $S_h$ is that $S_h$ includes each point in $\tilde{T}_h$ with $1/2$ probability, whereas $S_{h-1}$ either includes the entirety of $\tilde{T}_h$ with $1/2$ probability or includes none of $\tilde{T}_h$. Therefore, by Proposition \ref{prop:submodular_2}, using the negative-submodularity of $k$-means~\cite{cohenaddad2019fpt}, we have that $\mathbb E[\text{cost}(\mathcal{D}, S_h)] \le \mathbb E[\text{cost}(\mathcal{D}, S_{h-1}')]$. So, we have that $\mathbb E[\text{cost}(\mathcal{D}, S_h)] \le \mathbb E[\text{cost}(\mathcal{D}, S_{h-1}')] \le \mathbb E[\text{cost}(\mathcal{D}, S_{h-1})]$, which means that \begin{equation} \label{eq:cost_S0_S_inequality} \mathbb E[\text{cost}(\mathcal{D}, S)] = \mathbb E[\text{cost}(\mathcal{D}, S_s)] \le \mathbb E[\text{cost}(\mathcal{D}, S_{s-1})] \le \cdots \le \mathbb E[\text{cost}(\mathcal{D}, S_1)] \le \mathbb E[\text{cost}(\mathcal{D}, S_0)]. \end{equation} In summary, \begin{align*} \mathbb E[\text{cost}(\mathcal{D}, S)] &\le \mathbb E[\text{cost}(\mathcal{D}, S_0)] \\ &\le \rho\left(p-\frac{2}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k + \frac{2}{C} \cdot \left(\lambda-\frac{1}{n}\right) \cdot |I_2 \cup I_3|\right] + O(\gamma) \cdot \text{OPT}_{k'} \\ &\le \rho\left(p-\frac{2}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left(1 + \frac{2/C}{1/2 - p}\right) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k\right] + O(\gamma) \cdot \text{OPT}_{k'} \\ &\le \rho\left(p-\frac{2}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left(1 + \frac{200}{C}\right) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k\right] + O(\gamma) \cdot \text{OPT}_{k'}. \end{align*} Above, the first line follows from Equation \eqref{eq:cost_S0_S_inequality}, the second line follows from Equation \eqref{eq:cost_D_S0}, the third line follows from Equation \eqref{eq:remainder_bound}, and the fourth line follows since $1/2-p \ge 0.01.$ So, with probability at least $1-\frac{1}{10C}$, $|S| \le k$, and by Markov's inequality, \[\text{cost}(\mathcal{D}, S) \le \rho\left(p-\frac{2}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left(1 + \frac{300}{C}\right) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k\right] + O(\gamma) \cdot \text{OPT}_{k'}\] with probability at least $\frac{10}{C}$. So, both of these hold simultaneously with probability at least $\frac{9}{C},$ and by repeating the procedure $O(C)$ times, we will find our desired set $S$ with probability $9/10$. \end{proof} Our upper bound on the cost has so far been based on terms of the form $\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k.$ We note that this value is at most roughly $\text{OPT}_k$. Specifically, we note the following: \begin{proposition} \label{prop:duality_bound} If $\alpha^{(\ell+1)}$ is a feasible solution to $\text{DUAL}(\lambda),$ then $\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda+\frac{1}{n}\right) \cdot k \le \text{OPT}_k.$ \end{proposition} \begin{proof} Recall that $\alpha_j = \min(\alpha_j^{(\ell)}, \alpha_j^{(\ell+1)}),$ and that $\{\alpha_j^{(\ell+1)}\}$ is a feasible solution to $\text{DUAL}(\lambda+\frac{1}{n})$. Therefore, by duality, we have that \[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda+\frac{1}{n}\right) \cdot k \le \sum_{j \in \mathcal{D}} \alpha_j^{(\ell+1)} - \left(\lambda+\frac{1}{n}\right) \cdot k \le \text{OPT}_k. \qedhere\] \end{proof} One potential issue is that if our goal is to obtain a good approximation to optimal $k$-means, the $\gamma \cdot \text{OPT}_{k'}$ error, which should be negligible, may appear too large if $k'$ is smaller than $k$. To fix this, we show that $\text{OPT}_{k'} = O(\text{OPT}_k)$ in certain cases, which we later show we will satisfy. For the following lemma, we return to considering a single roundable solution $\mathcal{S} = (\alpha, z, \mathcal{F}_S, \mathcal{D}_S)$, and let $\mathcal{V}$ represent the corresponding set of tight or special facilities corresponding to $\mathcal{S}.$ \begin{lemma} \label{lem:opt_k'_opt_k} Let $(\alpha, z, \mathcal{F}_S, \mathcal{D}_S)$ be $(\lambda', k')$-roundable for some $\lambda' \ge 0$, where $\mathcal{F}_S = \emptyset$ and the set of corresponding bad clients is $\mathcal{D}_B = \emptyset$. Define $\{H(\delta)\}$ as the corresponding family of conflict graphs, with some fixed nested quasi-independent set $(I_1, I_2, I_3)$. Suppose that $k \le \min\left(n-1, |I_1|+p \cdot |I_2 \cup I_3|\right)$ for some $p \le 0.49$, and that $k' = \min(k, |I_1|)$. Then, $\text{OPT}_{k'} = O\left(\text{OPT}_k\right)$. \end{lemma} \begin{proof} If $k' = k$, the result is trivial. So, we assume that $k' = |I_1|$. Since $\mathcal{D}_B$ is empty, we have that every client $j$ has a tight witness $w(j)$ (since there are no special facilities) such that $(1+\varepsilon) \cdot \alpha_j \ge c(j, w(j))$ and $(1+\varepsilon) \cdot \alpha_j \ge \tau_{w(j)}$. In addition, we have that for any $i \in I_1 \cup I_2 \cup I_3$, $i$ is tight which means $\sum_{j \in N(i)} (\alpha_j-c(j, i)) = z_i \in [\lambda', \lambda'+\frac{1}{n}]$. Therefore, \[\sum_{j \in \mathcal{D}} \left[\alpha_j-\sum_{i \in N(j) \cap I_1} (\alpha_j-c(j, i))\right] = \sum_{j \in \mathcal{D}} \alpha_j - \sum_{i \in I_1} \sum_{j \in N(i)} (\alpha_j-c(j, i)) \le \sum_{j \in \mathcal{D}} \alpha_j - \lambda' \cdot |I_1|.\] Then, we can use the LMP approximation to get that \[\sum_{j \in \mathcal{D}} c(j, I_1) \le \rho_1 \cdot (1+O(\varepsilon)) \cdot \sum_{j \in \mathcal{D}} \left(\alpha_j - \sum_{i \in N(j) \cap I_1} (\alpha_j-c(j, i))\right) \le \rho_1 \cdot (1+O(\varepsilon)) \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \lambda' \cdot |I_1|\right),\] where $\rho_1 = \rho(0)$, i.e., assuming that no point in $I_2$ or $I_3$ is included as part of the set. In addition, we know that if $S$ is created by including all of $I_1$ and each point in $I_2 \cup I_3$ with probability $\frac{1}{2}$, then \begin{align*} \sum_{j \in \mathcal{D}} \alpha_j - \lambda' \cdot \left(|I_1| + \frac{1}{2} |I_2 \cup I_3|\right) &\ge \mathbb E\left[\sum_{j \in \mathcal{D}} \alpha_j - \sum_{i \in S} \sum_{j \in N(i)} (\alpha_j-c(j, i))\right] \\ &= \sum_{j \in \mathcal{D}} \mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] \\ &\ge 0. \end{align*} Above, the first inequality follows since $\sum_{j \in N(i)} (\alpha_j-c(j, i)) = z_i \ge \lambda'$ for any tight $i$, and the final inequality follows because of Lemma \ref{lem:RHS_positive_1/2}. To summarize, we have that there exists a constant $\theta = \frac{1}{\rho_1 \cdot (1+O(\varepsilon))}$ such that \begin{align} \theta \cdot \sum_{j \in \mathcal{D}} c(j, I_1) &\le \sum_{j \in \mathcal{D}} \alpha_j - |I_1| \cdot \lambda' \label{eq:IS_1} \intertext{and} 0 &\le \sum_{j \in \mathcal{D}} \alpha_j-\left(|I_1|+\frac{1}{2} \cdot |I_2 \cup I_3|\right) \cdot \lambda'. \label{eq:IS_2} \end{align} Therefore, by taking a weighted average of Equations \eqref{eq:IS_1} and \eqref{eq:IS_2}, we get \[(1-2p) \cdot \theta \cdot \text{OPT}_{k'} \le (1-2p) \cdot \theta \cdot \sum_{j \in \mathcal{D}} c(j, I_1) \le \sum_{j \in \mathcal{D}} \alpha_j - \left(|I_1| + p \cdot |I_2 \cup I_3|\right) \cdot \lambda' \le \sum_{j \in \mathcal{D}} \alpha_j - k \cdot \lambda',\] where the first inequality is true since $k' = |I_1|$ and the last inequality is true since $|I_1|+p \cdot |I_2 \cup I_3| \ge k.$ Thus, since $p \le 0.49$ and since $\rho_1 = O(1)$, we have that $\text{OPT}_{k'} = O\left(\sum_{j \in \mathcal{D}} \alpha_j - k \cdot \lambda'\right)$. Finally, since $\{\alpha_j\}$ is a feasible solution to $\text{DUAL}(\lambda'+\frac{1}{n})$, this means that $\sum_{j \in \mathcal{D}} \alpha_j - k \cdot \lambda' = \sum_{j \in \mathcal{D}} \alpha_j - k \cdot (\lambda'+\frac{1}{n}) + \frac{k}{n} \le \text{OPT}_{k} + \frac{k}{n}.$ However, if $k \le n-1$, then $\frac{k}{n} \le 1 \le \text{OPT}_k$. So, $\text{OPT}_{k'} = O(\text{OPT}_k)$. \end{proof} Recall that $H(\delta)$ represents the conflict graph $H^{(\ell, r)}(\delta)$. We will also let $H'(\delta)$ represent the conflict graph $H^{(\ell, r+1)}(\delta)$. In that case, $H'(\delta)$ is the same as $H(\delta)$ except with one vertex removed. Recall $(I_1, I_2, I_3)$ was a nested quasi-independent set of $\{H(\delta)\}$, and let $(I_1', I_2', I_3')$ be a nested quasi-independent set of $\{H'(\delta)\}$, such that $|I_1 \backslash I_1'| \le 1$ and $|I_1|+p_1|I_2 \cup I_3| \ge k > |I_1'|+p_1|I_2' \cup I_3'|$. \begin{theorem} \label{thm:main} Let $C > 0$ be an arbitrarily large constant, and $\varepsilon < 0$ be an arbitrarily small constant. Given the sets $(I, I')$ obtained in Algorithm \ref{alg:main}, in polynomial time we can obtain a solution for Euclidean $k$-means with approximation factor at most \begin{equation} \label{eq:approximation} \left(1+\varepsilon\right) \cdot \max_{r \ge 1} \min\left(\rho\left(\frac{p_1}{r}\right), \rho(p_1) \cdot \left(1+\frac{1}{4r \cdot \left(\frac{r}{2p_1}-1\right)}\right)\right). \end{equation} \end{theorem} \begin{proof} First, we remark that it suffices to obtain a set of facilities of size at most $k+c_0 \cdot C^4$ with cost at most $K \cdot \text{OPT}_{k-c_0 \cdot C^4}$ for any fixed constant $c_0$ (for all $1 \le k \le n-1$), where $K$ is the value in Equation \eqref{eq:approximation}. Indeed, we can apply Lemma \ref{lem:center-reduction} to obtain a solution of size $k-c_0 \cdot C^4$ and cost $(1+\varepsilon) \cdot K \cdot \text{OPT}_{k-c_0 \cdot C^4}$ in polynomial time, hence obtaining a $(1+\varepsilon) \cdot K$-approximate solution for $(k-c_0 \cdot C^4)$ means clustering for all $1 \le k \le n-1$. Thus, we get the desired approximation ratio for all $k \le n-c_0 C^4-1$, but for $k \ge n-c_0 C^4-1$, we can enumerate all the $(2n)^{c_0 C^{4}-1}$ different clusterings of the input that have at most $c_0 C^{4}-1$ non-singleton parts and solve $k$-clustering exactly in $n^{O(C^4)}$ time. Algorithm \ref{alg:main} stops once we have found the first hybrid conflict graph $\mathcal{V}^{(\ell, r)}$ for some $r \ge 1$ where the corresponding nested quasi-independent set $(I_1^{(\ell, r)}, I_2^{(\ell, r)}, I_3^{(\ell, r)})$ satisfies $|I_1^{(\ell, r)}|+p_1 \cdot |I_2^{(\ell, r)} \cup I_3^{(\ell, r)}| < k$. Let $\mathcal{V}' := \mathcal{V}^{(\ell, r)}$ and let $(I_1', I_2', I_3') := (I_1^{(\ell, r)}, I_2^{(\ell, r)}, I_3^{(\ell, r)})$. In addition, let $\mathcal{V} := \mathcal{V}^{(\ell, r-1)}$ and $(I_1, I_2, I_3) := (I_1^{(\ell, r-1)}, I_2^{(\ell, r-1)}, I_3^{(\ell, r-1)})$. If $r = 1$ then $r-1 = 0$, which may be problematic since our previous lemmas can only be used for $r \ge 1$. However, we note that $I^{(\ell, 0)} = I^{(\ell)} = I^{(\ell-1, p_{\ell-1})}$ if $\ell \ge 1$, and that $I^{(0, 0)} = I^{(0)}$ was previously labeled as $I^{(q)} = I^{(q-1, p_{q-1})}.$ The only exception to this is the case when $\ell = 0, r = 1$, and $I^{(0, 0)}$ is the initialized solution created in the first line of the algorithm. In this case, however, recall from our initialization that $I_1^{(0, 0)} = \mathcal{F}$ is the full set of facilities, and $I_1^{(0, 1)}$ will just be an extension of this set, so $|I_1^{(0, 1)}| \ge |\mathcal{F}| \ge k$. Therefore, $I = (I_1, I_2, I_3)$ and $I' = (I_1', I_2', I_3')$ are both expressible as nested quasi-independent sets of merged conflict graphs. However, if $I = I^{(0, 1)}$ and $I' = I^{(0, 0)}$, then we may need to express $I' = I^{(q-1, p_{q-1}+1)}$ based on a previous labeling, so it is possible that $I$ comes from a $(\lambda+\frac{1}{n}, k')$-roundable solution and $I'$ comes from a $(\lambda, k')$-roundable solution, rather than both nested quasi-independent sets coming from $(\lambda, k')$-roundable solutions. First, we show that for the value of $k'$ at the end of the algorithm (which means all solutions found are $(\lambda', k')$-roundable for some $\lambda'$), that $\text{OPT}_{k'} = O(\text{OPT}_k)$. To see why this is the case, note that either $k' = k$, so the claim is trivial, or $k' = |I_1^{(0)}|$ for some $I_1^{(0)}$ that corresponds to a solution that was at some point labeled as $\mathcal{S}^{(0)}$. Note that the corresponding nested quasi-independent set $(I_1^{(0)}, I_2^{(0)}, I_3^{(0)})$ is not the final set $(I_1', I_2', I_3')$, because if so we would have stopped the algorithm before we decided to label $\mathcal{S}^{(0)}$ as such. Therefore, $k \le |I_1^{(0)}|+p_1 \cdot |I_2^{(0)} \cup I_3^{(0)}|$ and we are assuming that $k \le n-1.$ Finally, since $(I_1^{(0)}, I_2^{(0)}, I_3^{(0)})$ arises from a $(\lambda', k')$-roundable solution with no special facilities or bad clients (by Condition \ref{cond:no_special_or_bad}), we may apply Lemma \ref{lem:opt_k'_opt_k} to obtain that $\text{OPT}_{k'} = O(\text{OPT}_k)$. Note that $|I_1'| \ge |I_1|-1$, and that $|I_1'| \le |I_1'| + p_1|I_2' \cup I_3'| < k$, which means that $|I_1| < k+1$ so $|I_1| \le k$. First, suppose that $|I_1| \ge k - 100C^4$, where we recall that $C$ is an arbitrarily large but fixed constant. In this case, this means that $|I_1'| \ge k-100 C^4 - 1$ and $p_1 \cdot |I_2' \cup I_3'| \le 100C^4+1$ so $|I_2' \cup I_3'| = O(C^4).$ In this case, we can apply Lemma \ref{lem:expected_cost_S} to find a randomized set $I_1' \subset S \subset I_1' \cup I_2' \cup I_3'$ such that \[\mathbb E[\text{cost}(\mathcal{D}, S)] \le \rho(p_1) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j' - \left(\lambda-\frac{1}{n}\right) \cdot \mathbb E[|S|]\right] + O(\gamma) \cdot \text{OPT}_{k'},\] where $\{\alpha_j'\}_{j \in \mathcal{D}}$ corresponds to the merged solution that produces $(I_1', I_2', I_3')$. Since $|I_2' \cup I_3'| = O(C^4)$, we can try every possible $I_1' \subset S \subset I_1' \cup I_2' \cup I_3'$ to get a deterministic set $S$ of size at most $|I_1'|+|I_2' \cup I_3'| \le k + O(C^4)$ and size at least $|I_1'| \ge k-O(C^4)$ such that \begin{align*} \text{cost}(\mathcal{D}, S) &\le \rho(p_1) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j' - \left(\lambda-\frac{1}{n}\right) \cdot |S|\right] + O(\gamma) \cdot \text{OPT}_{k'} \\ &\le \rho(p_1) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j' - \left(\lambda+\frac{2}{n}\right) \cdot |S|\right] + O(1/n) \cdot |S| + O(\gamma) \cdot \text{OPT}_{k'} \\ &\le \rho(p_1) \cdot (1+O(\varepsilon)) \cdot \text{OPT}_{|S|} + O(\gamma) \cdot \text{OPT}_{k}. \end{align*} The final line follows by Proposition \ref{prop:duality_bound}, since $\text{OPT}_{k'} = O(\text{OPT}_k)$, and since $|S| \le k + O(C^4) \le O(k)$ so $O(1/n) \cdot |S| = O(1) \le O(\gamma) \cdot \text{OPT}_{k}$. Therefore, there exists an absolute constant $c_0$ such that we have a set of size at most $|I_1' \cup I_2' \cup I_3'| \le k+c_0 \cdot C^4$ with cost at most $\rho(p_1) \cdot (1+O(\varepsilon)) \cdot \text{OPT}_{|S|} + O(\gamma) \cdot \text{OPT}_{k} \le \rho(p_1) \cdot (1+O(\varepsilon)) \cdot \text{OPT}_{k-c_0 \cdot C^4}$. As argued in the first paragraph of this proof, this is sufficient since we can apply Lemma~\ref{lem:center-reduction}. Otherwise, namely when $|I_1| \le k-100 C^4$, we have $|I_2 \cup I_3| \ge 100 C^4$ since $|I_1|+p_1|I_2 \cup I_3| \ge k$. Then, recall that $|I_1 \backslash I_1'| \le 1,$ so let $\kappa = |I_1 \backslash I_1'| \in \{0, 1\}$. Set $t > 0$ and $c \ge 0$ such that $|I_1|+p_1|I_2 \cup I_3| = k + c \cdot t$ and $|I_1'|+p_1|I_2' \cup I_3'| = k-t.$ Then, $|I_1 \cap I_1'| = k-(1+d) t$ for some $d \ge 0$, so $|I_1| = k-(1+d)t + \kappa$. In this case, $p_1|I_2 \cup I_3| = (1+c+d) t-\kappa$, so if we set $p = p_1 \cdot \frac{(1+d)t-\kappa}{(1+c+d)t-\kappa}$, then $|I_1|+p |I_2 \cup I_3| = k$. Also, since $|I_2 \cup I_3| \ge 100 C^4$, we have that $(1+c+d) t \ge p_1 \cdot 100 C^4 \ge C$, so $p = p_1 \cdot \frac{1+d}{1+c+d} - \eta$ for some $\eta \le 1/C$. In this case, assuming that $p > 0.01,$ we can use Lemma \ref{lem:cost_bound} to obtain a solution of size at most $k$ with cost at most \[\rho\left(p_1 \cdot \frac{1+d}{1+c+d}-\eta-\frac{2}{C}\right) \cdot \left(1+\frac{300}{C}\right) \cdot (1+O(\varepsilon)) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k\right] + O(\gamma) \cdot \text{OPT}_{k'}.\] Now, since $p_1 \cdot \frac{1+d}{1+c+d} \le p_1 =.402$, it is straightforward to verify that $\rho$ has bounded derivative. (Indeed, each case produces a function that is continuously differentiable on $[0, 0.5)$, so has bounded derivative on $[0, 0.402]$.) Therefore, since $\eta \le \frac{1}{C}$, the solution in fact has cost at most \[\rho\left(p_1 \cdot \frac{1+d}{1+c+d}\right) \cdot \left(1+O\left(\frac{1}{C}+\varepsilon\right)\right) \cdot \left[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k\right] + O(\gamma) \cdot \text{OPT}_{k'}.\] But since $\text{OPT}_{k'} = O(\text{OPT}_k)$, and since $$\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k = \sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda+\frac{2}{n}\right) \cdot k + \frac{3k}{n} \le \text{OPT}_k + 3 \le (1+O(\gamma)) \cdot \text{OPT}_k,$$ we obtain a solution of cost at most \begin{equation} \label{eq:main_bound_1} \rho\left(p_1 \cdot \frac{1+d}{1+c+d}\right) \cdot \left(1+O\left(\frac{1}{C}+\varepsilon+\gamma\right)\right) \cdot \text{OPT}_k. \end{equation} In addition, note that we can use Lemma \ref{lem:cost_bound} to obtain a solution $S$ for $(k+ct)$-means and $S'$ for $(k-t)$-means. Also, $|S \cup S'| = |S|+|S'|-|S \cap S'| \le |S|+|S'|-|I_1 \cap I_1'| = k+(c+d)t.$ So, if we define $\rho' := \max_{0 \le \eta \le 1/C} \rho(p_1-\eta-\frac{2}{C}) \cdot (1+\frac{300}{C}) \cdot (1+O(\varepsilon)) = \rho(p_1) \cdot (1+O(\frac{1}{C}+\varepsilon))$, then \begin{equation} \label{eq:Sprime_bound} \text{cost}(\mathcal{D},S') \le \rho' \cdot \left(\sum_{j \in D} \alpha_j - \left(\lambda - \frac{1}{n}\right) \cdot (k-t)\right) + O(\gamma) \cdot \text{OPT}_{k'} \end{equation} and \begin{equation} \label{eq:S_Sprime_bound} \text{cost}(\mathcal{D}, S \cup S') \le \text{cost}(\mathcal{D}, S) \le \rho' \cdot \left(\sum_{j \in D} \alpha_j - \left(\lambda - \frac{1}{n}\right) \cdot (k+ct)\right) + O(\gamma) \cdot \text{OPT}_{k'}. \end{equation} Therefore, by Proposition \ref{prop:submodular_3}, if we randomly add $t$ of the items in $S \backslash S'$, we will get a set $S''$ of size $k$ with expected cost \begin{align} \mathbb E[\text{cost}(\mathcal{D}, S'')] &\le \rho' \cdot \Bigg(\frac{c+d}{1+c+d} \cdot \Bigg(\sum_{j \in D} \alpha_j - \left(\lambda - \frac{1}{n}\right) \cdot (k-t)\Bigg) \nonumber \\ &\hspace{3.4cm}+ \frac{1}{1+c+d} \cdot \Bigg(\sum_{j \in D} \alpha_j - \left(\lambda - \frac{1}{n}\right) \cdot (k+ct)\Bigg)\Bigg) + O(\gamma) \cdot \text{OPT}_{k'} \nonumber \\ &= \rho' \cdot \Bigg(\sum_{j \in D} \alpha_j - \left(\lambda - \frac{1}{n}\right) \cdot k + \frac{d}{1+c+d} \cdot \left(\lambda-\frac{1}{n}\right) \cdot t \Bigg) + O(\gamma) \cdot \text{OPT}_k. \label{eq:i_ran_out_of_names} \end{align} Note that if $\lambda-\frac{1}{n} \le 0$, then this means that $\mathbb E[\text{cost}(\mathcal{D}, S'')] \le \rho' \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j\right) + O(\gamma) \cdot \text{OPT}_k,$ and Proposition \ref{prop:duality_bound} tells us that $\sum_{j \in \mathcal{D}} \alpha_j \le \text{OPT}_k + O(k/n) \le (1+O(\gamma)) \cdot \text{OPT}_k$, so the expected cost is at most $\rho(p_1) \cdot (1+O(\frac{1}{C}+\varepsilon+\gamma)) \cdot \text{OPT}_k.$ Alternatively, we may assume that $\lambda-\frac{1}{n} > 0$. In this case, note that by Lemmas \ref{lem:RHS_positive_1/2} and \ref{lem:ugly_upper_bound}, we have that \[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot \left(|I_1|+\frac{1}{2}|I_2 \cup I_3|\right) + 4\gamma \cdot \text{OPT}_{k'} \ge 0.\] We can rewrite $|I_1|+\frac{1}{2}|I_2 \cup I_3|$ as $(k-(1+d)t+\kappa)+\frac{1}{2p_1} \cdot ((1+c+d)t-\kappa) = k +t \cdot \left(\frac{1}{2p_1}(1+c+d) - (1+d)\right) - O(1) \ge k + t \cdot \left(\frac{1}{2p_1}(1+c+d)-(1+d)\right) \cdot \left(1-\frac{O(1)}{C^4}\right)$, where the last inequality is true since $t \cdot \left[\frac{1}{2p_1}(1+c+d)-(1+d)\right] \ge \Omega(t \cdot (1+c+d)) \ge \Omega(|I_2 \cup I_3|) \ge 100 C^4$. Thus, we have that \[\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k + 4 \gamma \cdot \text{OPT}_{k'} \ge \left(\lambda-\frac{1}{n}\right) \cdot t \cdot \left(\frac{1}{2p_1} (1+c+d)-(1+d)\right) \cdot \left(1-\frac{O(1)}{C^4}\right).\] Therefore, combining the above equation with \eqref{eq:i_ran_out_of_names}, we have that \begin{align} \mathbb E[\text{cost}(\mathcal{D}, S'')] &\le \rho' \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k + O(\gamma) \cdot \text{OPT}_{k'}\right) \cdot \left(1 + \frac{\frac{d}{1+c+d}}{\frac{1}{2p_1}(1+c+d)-(1+d)} \cdot \left(1+\frac{O(1)}{C^4}\right)\right) \nonumber \\ &\le \rho' \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda+\frac{2}{n}\right) \cdot k + O(\gamma) \cdot \text{OPT}_k\right) \cdot \left(1 + \frac{\frac{d}{1+c+d}}{\frac{1}{2p_1}(1+c+d)-(1+d)} \cdot \left(1+\frac{O(1)}{C^4}\right)\right) \nonumber \\ &\le \rho' \cdot \left(1+O(\frac{1}{C}+\gamma)\right) \cdot \left(1 + \frac{\frac{d}{1+c+d}}{\frac{1}{2p_1}(1+c+d)-(1+d)}\right) \cdot \text{OPT}_k. \label{eq:main_bound_2} \end{align} If we set $r \ge 1$ such that $c = (r-1)(1+d)$, then $\frac{1+d}{1+c+d} = \frac{1}{r}$ and $$\frac{\frac{d}{1+c+d}}{\frac{1}{2p_1}(1+c+d)-(1+d)} = \frac{d}{r(1+d)} \cdot \frac{1}{(\frac{r}{2p_1}-1) \cdot (1+d)} = \frac{d}{(1+d)^2} \cdot \frac{1}{r \cdot (\frac{r}{2p_1}-1)} \le \frac{1}{4r \cdot (\frac{r}{2p_1}-1)}.$$ So, by combining Equations \eqref{eq:main_bound_1} and \eqref{eq:main_bound_2}, we can always guarantee an approximation factor of at most \begin{equation} \label{eq:main_bound} \left(1+O(\frac{1}{C}+\varepsilon+\gamma)\right) \cdot \max_{r \ge 1} \min\left(\rho\left(\frac{p_1}{r}\right), \rho(p_1) \cdot \left(1+\frac{1}{4r \cdot \left(\frac{r}{2p_1}-1\right)}\right)\right). \end{equation} This approximation factor also holds in the case when $\lambda-\frac{1}{n} \le 0$, by setting $r = 1$. So, by letting $C$ be an arbitrarily large constant and $\gamma \ll \varepsilon \ll 1$ be arbitrarily small constants, the result follows. \end{proof} Since we have set $p_1 = 0.402$ and $\delta_1 = \frac{4+8\sqrt{2}}{7}, \delta_2 = 2, \delta_3 = 0.265$, by Proposition \ref{prop:more_bash} we have $\rho(p_1) = 3+2\sqrt{2}$. If $r \ge 3.221,$ one can verify that $(3+2\sqrt{2}) \cdot \left(1+\frac{1}{4r \cdot (\frac{r}{2p_1} - 1)}\right) \le 5.979$. Alternatively, if $1 \le r \le 3.221,$ then $\frac{p_1}{r} \ge \frac{.402}{3.221} \ge .1248,$ and it is straightfoward to verify that $\rho(p) \le 5.979$ for all $p \in [.1248, .402]$ using Proposition \ref{prop:more_bash}.\footnote{We remark that while Proposition \ref{prop:more_bash} follows from Lemma \ref{lem:more_bash}, Lemma \ref{lem:more_bash} only depends on Lemma \ref{lem:main_lmp}, so there is no circular reasoning.} Hence, we have a $\boxed{5.979}$-approximation to $k$-means. \iffalse In addition, for $p \in [0.096, 0.402]$, $\rho(p) \le \max\left(3+2\sqrt{2}, \frac{p\cdot(\sqrt{2}-1)^2+(1-p)\cdot\left(1+\sqrt{\delta_1}\right)^2}{p\cdot\left(\sqrt{2}-1\right)^2+1-p}\right)$, which follows by Proposition \ref{prop:more_bash} and checking the Subcases \ref{eq:1.b}, \ref{eq:1.e}, \ref{eq:1.g.i}, \ref{eq:2.d}, \ref{eq:4.a.ii}, and \ref{eq:4.b.ii} individually. Therefore, $\rho\left(\frac{p_1}{r}\right)$ is a nondecreasing function over $r \in [1, 3.86]$ and $\rho(p_1) \cdot \left(1+\frac{1}{4r \cdot (r/(2p_1)-1)}\right)$ is a decreasing function over $r \in [1, \infty)$. The approximation constant can be determined by where these two functions intersect, at $r_0 \approx 2.855$, and the function values are both slightly under $6.013$. Indeed, for $r > r_0$, we can use the bound $\rho(p_1) \cdot \left(1 + \frac{1}{4r \cdot (r/(2p_1)-1)}\right)$ and for $1 \le r \le r_0$, we can use the bound $\rho\left(\frac{p_1}{r}\right)$, so the approximation ratio is slightly less than $\boxed{6.013}$. \fi \subsection{Improving the approximation further} \label{subsec:k_means_improved} First, we define some important quantities. For any client $j$, we define $A_j := \alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i))$, and we define $B_j := \sum_{i \in \bar{N}(j) \cap (I_2 \cup I_3)} (\alpha_j-c(j, i))$. Note that $B_j \ge 0$ always. We split the clients into $5$ groups. Let $\mathcal{D}_1$ be the set of all clients $j \not\in \mathcal{D}_B$ corresponding to subcases \ref{eq:1.a}, \ref{eq:1.c}, \ref{eq:1.d}, \ref{eq:1.g.ii}, 1.h, \ref{eq:2.a}, \ref{eq:3.a}, \ref{eq:4.a.i}, \ref{eq:4.b.i}, and \ref{eq:4.c}, as well as the clients in \ref{eq:5.a} where there do not exist $i_2 \in \bar{N}(j) \cap I_2$ and $i_3 \in \bar{N}(j) \cap I_3$ such that $q(i_3) = i_2$. (In the casework, our choice of $a$ is $|\bar{N}(j) \cap S|$ rather than $N(j) \cap S$, similar for $b$ and $c$.) Let $Q_1$ be the sum of $A_j$ for these clients, and $R_1$ be the sum of $B_j$ for these clients. Next, let $\mathcal{D}_2$ be the set of all clients $j \not\in \mathcal{D}_B$ corresponding to subcases \ref{eq:1.b}, \ref{eq:1.e}, \ref{eq:4.a.ii}, and \ref{eq:4.b.ii}. Let $\mathcal{D}_3$ be the set of all clients $j \not\in \mathcal{D}_B$ corresponding to subcase \ref{eq:1.g.i}. Let $\mathcal{D}_4$ be the set of all clients $j \not\in \mathcal{D}_B$ corresponding to subcase \ref{eq:2.d}, further restricted to $c(j, i_2) + c(j, i_3) \ge 0.25 \cdot \alpha_j$ (or equivalently in the language of Case \ref{eq:2.d} in Lemma \ref{lem:main_lmp}, $\beta^2+\gamma^2 \ge 0.25$). Finally, let $\mathcal{D}_5$ be the set of all bad clients $j \in \mathcal{D}_B$, as well as all remaining subcases (\ref{eq:2.b}, \ref{eq:2.c}, \ref{eq:2.d} when $\beta^2+\gamma^2 < 0.25$, \ref{eq:3.b}, \ref{eq:3.c}, and the clients in \ref{eq:5.a} not covered by $\mathcal{D}_1$). Note these cover all cases (recall that 1.f is a non-existent case). Finally, we define $Q_2, Q_3, Q_4, Q_5, R_2, R_3, R_4, R_5$ similarly to how we defined $Q_1$ and $R_1.$ Now, we have the following result, which improves over Lemma \ref{lem:RHS_positive_1/2}. \begin{lemma} \label{lem:RHS_positive_1/2_improved} For any client $j$, $A_j-\frac{1}{2} B_j \ge 0$. In addition, if the client $j$ corresponds to any of the subcases in case $1$ or case $4$, or to subcases $2.a$ or $3.a$, then $A_j-B_j \ge 0$. Also, if the client $j$ corresponds to subcase $2.d$ where $\beta^2+\gamma^2 \ge 0.25$, then $A_j-\frac{4}{7}B_j \ge 0$. \end{lemma} \begin{remark} As in Lemma \ref{lem:RHS_positive_1/2}, this lemma holds even for bad clients $j \in \mathcal{D}_B$. \end{remark} \begin{proof} The proof that $A_j-\frac{1}{2} B_j \ge 0$ for any client $j$ is identical to that of Lemma \ref{lem:RHS_positive_1/2}. So, we focus on the next two claims. For the subcases in Case 1, note that $\bar{N}(j) \cap I_3 = \emptyset$, so we just need to show that $\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i)) \ge \sum_{i \in \bar{N}(j) \cap I_2} (\alpha_j-c(j, i))$, which is implied by Equation \eqref{eq:I2_bound}. Likewise, for the subcases in Case 4, note that $\bar{N}(j) \cap I_2 = \emptyset$, so we just need to show that $\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i)) \ge \sum_{i \in \bar{N}(j) \cap I_3} (\alpha_j-c(j, i))$, which is implied by Equation \eqref{eq:I3_bound}. We recall that in subcases 2.a and 3.a, we noted in both cases that the points in $\bar{N}(j) \cap I_2$ and $\bar{N}(j) \cap I_3$ were all separated in $H(\delta_2)$, and that $\bar{N}(j) \cap I_1 = \emptyset$ since $a = 0$. So, we have that $\alpha_j-\sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i)) = \alpha_j \ge \sum_{i \in \bar{N}(j) \cap (I_2 \cup I_3)} (\alpha_j-c(j, i))$ in both cases. Finally, we consider subcase 2.d when $\beta^2+\gamma^2 \ge 0.25.$ In this case, we have (when $\alpha_j = 1$) that $1-\sum_{i \in \bar{N}(j) \cap I_1} = 1$, and $\sum_{i \in \bar{N}(j) \cap (I_2 \cup I_3)} (1-c(j, i)) = (1-c(j, i_2))+(1-c(j, i_3)) = 2-\beta^2-\gamma^2$, which is at most $1.75$ if $\beta^2+\gamma^2 \ge 0.25.$ So, for general $\alpha_j$, we have that $\alpha_j-\sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i)) = \alpha_j \ge \frac{4}{7} \cdot \sum_{i \in \bar{N}(j) \cap (I_2 \cup I_3)} (\alpha_j-c(j, i)).$ \end{proof} Therefore, we have that \begin{equation} \label{eq:S_i_bound} R_1 \le Q_1, \hspace{1cm} R_2 \le Q_2, \hspace{1cm} R_3 \le Q_3, \hspace{1cm} R_4 \le 1.75 \cdot Q_4, \hspace{0.5cm} \text{and} \hspace{0.5cm} R_5 \le 2 Q_5. \end{equation} Next, we define $\rho^{(i)}(p)$ to be the maximum fraction $\rho(p)$ obtained from the casework corresponding to the (not bad) clients in $\mathcal{D}_i$. (Note that $\rho(p) = \max\left(\rho^{(1)}(p), \rho^{(2)}(p), \rho^{(3)}(p), \rho^{(4)}(p), \rho^{(5)}(p)\right)$.) We have the following result: \begin{lemma} \label{lem:more_bash} Let $\delta_1 = \frac{4+8\sqrt{2}}{7},$ $\delta_2 = 2$, and $\delta_3 = 0.265$. Then, for all $p \in [0.096, 0.402],$ we have that $\rho^{(1)}(p) \le 3+2\sqrt{2}$, $\rho^{(2)}(p) \le 1+2p+(1-p)\cdot \delta_1+2\sqrt{2p^2 +(1-p)\cdot \delta_1}$, and $\rho^{(5)}(p) \le 5.68$. \end{lemma} \begin{proof} We start by considering $\rho^{(1)}(p)$, covered by subcases \ref{eq:1.a}, \ref{eq:1.c}, \ref{eq:1.d}, \ref{eq:1.g.ii}, 1.h, \ref{eq:2.a}, \ref{eq:3.a}, \ref{eq:4.a.i}, \ref{eq:4.b.i}, and \ref{eq:4.c}, and certain subcases of \ref{eq:5.a}. All subcases except \ref{eq:2.a}, \ref{eq:4.c}, and \ref{eq:5.a} can easily be verified (see our Desmos file for K-means Case 1, the link is in Appendix \ref{app:files}). For subcase \ref{eq:2.a}, we have to verify it for all choices of $c \ge 1$. However, it is simple to see that the numerator of the fraction decreases as $c_2$ increases whenever $p \in [0, 0.5]$, so in fact we just have to verify it for $c = c_2 = 1$, which is straightforward. For subcase \ref{eq:4.c}, we have to verify it for all choices of $c \ge 2$. For $c = 2$ it is straightforward to verify. For $c \ge 3,$ since $2.5+\sqrt{2} \le 3+2\sqrt{2},$ it suffices to show \[\frac{\left(\frac{1}{2}(1-2p)+\frac{1}{2}(1-2p)^c\right) \cdot (1+\sqrt{\delta_1})^2 - \left(\frac{1}{2} + \frac{1}{2}(1-2p)^c\right) +p(1+\sqrt{2})^2+1}{1-p} \le 3+2\sqrt{2},\] where we have taken the fraction from \ref{eq:4.c} and added back a $\frac{p}{c}$ term to the numerator. Now, this fraction is decreasing as $c$ increases, so it suffices to verify it for $c = 3$, which is straightforward. The last case for $\rho^{(1)}(p)$ is Case \ref{eq:5.a}. We show that in all cases the fraction is bounded by $3+2\sqrt{2}$ for $p \in [0.096, 0.402]$, and if $h \ge 1$ then the fraction can further be bounded by $5.68$. This is clearly sufficient for bounding $\rho^{(1)}(p)$. It will also be important in bounding $\rho^{(5)}(p)$ - indeed, if there exist $i_2 \in \bar{N}(j) \cap I_2$ and $i_3 \in \bar{N}(j) \cap I_3$ such that $q(i_3) = i_2,$ then regardless of the outcomes of the initial fair coins, $h \ge 1$ since exactly one of $i_3$ or $q(i_3) = i_2$ will contribute to the value of $h$. First, we note that $T_1-T_1^2+T_3$ can be rewritten as \[a+2ph-(a^2+4aph+4p^2h^2) + \frac{\delta_1}{2} \cdot (a^2-a) + 4pah + 4p^2 \cdot h(h-1) = \left(\frac{\delta_1}{2}-1\right) \cdot a(a-1) + 2p(1-2p) \cdot h.\] In the case where $a=1$ and $h \ge 1$, we can therefore simplify the fraction in \eqref{eq:5.a} to $\frac{1}{a+2ph} + \frac{2ph}{2p(1-2p) \cdot h} = \frac{1}{a+2ph} + \frac{1}{1-2p} \le \frac{1}{1+2p}+\frac{1}{1-2p} = \frac{2}{1-4p^2}.$ This is at most $5.68$ for any $p \le 0.402$. When $a \ge 2$, we can write the fraction as \begin{equation} \label{eq:5a_simplified} \frac{1}{a+2ph} + \frac{(a-1)+(2p)h}{\left(\frac{\delta_1}{2}-1\right) \cdot a(a-1) + (2p)h \cdot (1-2p)}. \end{equation} When $a \ge 2$ and $h = 0$, \eqref{eq:5a_simplified} can be simplified as \[\frac{1}{a} + \frac{1}{a \cdot \left(\frac{\delta_1}{2}-1\right)} \le \frac{1}{2} \left(1 + \frac{1}{\frac{\delta_1}{2}-1}\right) = 3+2\sqrt{2}.\] \begin{align*} \frac{1}{a+2ph} + \frac{(a-1)+(2p)h}{\left(\frac{\delta_1}{2}-1\right) \cdot a(a-1) + (2p)h \cdot (1-2p)} &= \frac{1}{2+2ph} + \frac{[1+2p]+2p(h-1)}{\left[\left(\frac{\delta_1}{2}-1\right) \cdot 2+2p\right] + 2p(h-1) \cdot (1-2p)}\\ &\le \frac{1}{a+2p} + \max\left(\frac{1}{\left(\frac{\delta_1}{2}-1\right) \cdot a}, \frac{1}{1-2p}\right). \end{align*} When $a = 2$ and $h \ge 1$, we can rewrite \eqref{eq:5a_simplified} as \begin{align*} \frac{1}{2+2ph} + \frac{1+2ph}{\delta_1-2 + 2ph(1-2p)} &= \frac{1}{2+2ph} + \frac{1+2p + 2p(h-1)}{\delta_1-2 + 2p(1-2p) + 2p(1-2p)(h-1)} \\ &\le \frac{1}{2+2p} + \max\left(\frac{1+2p}{\delta_1-2+2p(1-2p)}, \frac{1}{1-2p}\right), \end{align*} which is easily verifiable to be at most $5.68$ for $p\in [0.096, 0.402]$. When $a \ge 3$ and $h \ge 1$, \eqref{eq:5a_simplified} is at most \[\frac{1}{3} + \max\left(\frac{1}{3 \cdot \left(\frac{\delta_1}{2}-1\right)}, \frac{1}{1-2p}\right),\] which is easily verifiable to be at most $5.68$ for $p\in [0.096, 0.402]$. The final case is when $a = 1, h = 0$, but here we saw in our analysis of \ref{eq:5.a} that the fraction is at most $1$, or that the numerator and denominator are both $0$. Next, consider $\rho^{(2)}(p)$, which is covered by subcases \ref{eq:1.b}, \ref{eq:1.e}, \ref{eq:4.a.ii}, and \ref{eq:4.b.ii}. Indeed, since $\delta_2 = 2$, these all have the exact same bound of $1+2p+(1-p)\delta_1 + 2\sqrt{2p^2+(1-p)\delta_1}$. Finally, we deal with $\rho^{(5)}(p)$, which deals with subcases \ref{eq:2.b}, \ref{eq:2.c}, \ref{eq:3.b}, \ref{eq:3.c}, and \ref{eq:5.a}, along with \ref{eq:2.d} when $\beta^2+\gamma^2 < 0.25$. Subcase \ref{eq:2.b} can be easily verified to be at most $5.664$ in the range $p \in [0.096, 0.402]$ when $c_2 = 0$ and $c = c_1$ is between $2$ and $5$. Beyond this, we assume that $c_1 \ge 6$, so we can apply the crude bound that the fraction is at most \[\frac{\frac{1}{2}+\left(1-p-\frac{1}{2}\cdot\left(1-(1-2p)^{6}\right)\right)\cdot\left(1+\sqrt{\delta_1}\right)^{2}}{1-2p},\] which is at most $5.68$ for $p \in [0.096, 0.402]$. It is easy to verify that the fraction in Subcase \ref{eq:2.c} is at most $5.68$ for $p \in [0.096, 0.402]$. Subcase \ref{eq:3.b} is easy to verify for $2 \le b \le 5.$ For $b \ge 6$, we can apply the crude bound that the fraction is at most \[\frac{(1-p)^{5}\cdot(1-2p)\cdot\left(1+\sqrt{\delta_1}\right)^2+1}{1-\left(1+\frac{2-\delta_3}{7}\right)p},\] which trivially satisfies the desired bounds. Finally, we note that in Subcase \ref{eq:3.c}, the fraction decreases as $c_1$ and $c_2$ increase, so we may assume that either $c_1=c_2 = 1$ or $c_1 = 2$ and $c_2 = 0$. These are easy to verify for $2 \le b \le 5$, and for $b \ge 6$, we may apply a crude bound to say the fraction is at most \[\frac{1+(1-p)^5\cdot (1-2p) \cdot \left((1+\sqrt{\delta_1})^2-1\right)}{1-2p}\] as long as $c_1 \ge 1$ and $c_2 \ge 0.$ This is at most $5.68$ in the range $[0.096, 0.402]$. Subcase \ref{eq:5.a} was dealt with previously (as we only have to consider when $h \ge 1$), so the final case is \ref{eq:2.d} when $\beta^2+\gamma^2 < 0.25$. In this case, we recall the fraction is \[\frac{(1-2p) \cdot \min(1+\sqrt{\delta_1}, \max(\beta, \gamma)+\sqrt{\delta_1 \cdot t})^2 + p \cdot (\beta^2+\gamma^2)}{1-(2-\beta^2-\gamma^2) \cdot p},\] where $t \ge 1$, $\beta+\gamma \ge \sqrt{\delta_3 \cdot t}$, and also $\beta^2+\gamma^2 \le 0.25$. By the symmetry of $\beta$ and $\gamma$, we may replace $\max(\beta, \gamma)$ with $\beta$. So, by defining $\zeta = \beta^2+\gamma^2,$ we can upperbound the above expression by \[\frac{(1-2p) \cdot (\beta+\sqrt{\delta_1 \cdot t})^2 + p \cdot \zeta}{1-2p + p \cdot \zeta} \le \frac{(1-2p) \cdot (\beta+\sqrt{\delta_1/\delta_3} \cdot(\beta+\gamma))^2 + p \cdot \zeta}{1-2p + p \cdot \zeta},\] since $\zeta \le 0.25$ and since $\beta+\gamma \ge \sqrt{\delta_3 \cdot t}$. By Cauchy-Schwarz, $\left(\beta \cdot x + \gamma \cdot y\right)^2 \le (\beta^2+\gamma^2) \cdot(x^2+y^2) \le \zeta \cdot (x^2+y^2)$. So, we can bound the above expression by \[\frac{(1-2p) \cdot \zeta \cdot \left((1+\sqrt{\delta_1/\delta_3})^2 + \delta_1/\delta_3\right) + p \cdot \zeta}{1-2p + p \cdot \zeta} = \frac{(1-2p) \cdot \left((1+\sqrt{\delta_1/\delta_3})^2 + \delta_1/\delta_3\right) + p}{\frac{1-2p}{\zeta} + p}.\] For $p \le 0.5,$ this fraction clearly increases with $\zeta$, so we maximize this when $\zeta = 0.25$. When setting $\zeta = 0.25$, this can easily be verified to be at most $5.68$ for all $p \in [0.096, 0.5]$. This concludes all cases, thus proving the proposition. \end{proof} Next, we recall Lemma \ref{lem:ugly_upper_bound}. First, by setting $S$ to be $I_1$ in Lemma \ref{lem:ugly_upper_bound}, we obtain that \begin{equation} \label{eq:Qi_sum_upper_bound} \sum_{i = 1}^{5} Q_i = \sum_{j \in \mathcal{D}} \left(\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i))\right) \le \sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot |I_1| + 4\gamma \cdot \text{OPT}_{k'}. \end{equation} Next, by setting $S$ to be $I_2 \cup I_3$ in Lemma \ref{lem:ugly_upper_bound}, we obtain that \begin{equation} \label{eq:Ri_sum_lower_bound} \sum_{i = 1}^{5} R_i = \sum_{j \in \mathcal{D}} \sum_{i \in \bar{N}(j) \cap (I_2 \cup I_3)} (\alpha_j-c(j, i)) \ge \left(\lambda-\frac{1}{n}\right) \cdot |I_2 \cup I_3| - 4\gamma \cdot \text{OPT}_{k'}. \end{equation} Next, we recall Lemma \ref{lem:expected_cost_S}. By splitting $\mathbb E[\text{cost}(\mathcal{D}, S)]$ based on whether $j$ is in $\mathcal{D}_1$, $\mathcal{D}_2$, $\mathcal{D}_3$, $\mathcal{D}_4$, $\mathcal{D}_5 \backslash \mathcal{D}_B$, or $\mathcal{D}_B$, we obtain that \[\mathbb E[\text{cost}(\mathcal{D}, S)] \le (1+O(\varepsilon)) \cdot \left[\sum_{i = 1}^{5} \rho^{(i)}(p) \cdot (Q_i - p \cdot R_i)\right] + O(\gamma) \cdot \text{OPT}_{k'}.\] Therefore, the argument of Lemma \ref{lem:cost_bound} implies that if $|I_1|+p \cdot |I_2 \cup I_3| = k$, if $p \in [0.01, 0.49]$, and if $|I_2 \cup I_3| \ge 100 C^4$, then we can choose a set $I_1 \subset S \subset I_1 \cup I_2 \cup I_3$ such that $|S| \le k$ and \begin{align} \text{cost}(\mathcal{D}, S) &\le \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \left[\sum_{i = 1}^{5} \rho^{(i)}\left(p-\frac{2}{C}\right) \cdot \left(Q_i-\left(p-\frac{2}{C}\right) \cdot R_i\right)\right] + O(\gamma) \cdot \text{OPT}_{k'} \nonumber \\ &\le \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \left[\sum_{i = 1}^{5} \rho^{(i)}\left(p\right) \cdot(Q_i-p \cdot R_i)\right] + O(\gamma) \cdot \text{OPT}_{k}. \label{eq:cost_bound_improved} \end{align} To explain the second line, note that $\rho^{(i)}$ has bounded derivative on $[0.01, 0.49]$ and that $Q_i \ge 0.5 \cdot R_i$. Therefore, since $p \in [0.01, 0.49]$, $\rho^{(i)}\left(p-\frac{2}{C}\right) = \rho^{(i)}(p) \cdot \left(1+O(1/C)\right)$, and $Q_i-p \cdot R_i = \Omega(R_i)$ which means $Q_i-\left(p-\frac{2}{C}\right) \cdot R_i = (Q_i-p \cdot R_i) \cdot \left(1+O(1/C)\right)$. In addition, we still have that $\text{OPT}_{k'} = O(\text{OPT}_k)$, as in our proof of Theorem \ref{thm:main}. We now return to the setup of Theorem \ref{thm:main}, where we have $(I_1, I_2, I_3)$ and $(I_1', I_2', I_3')$. Suppose that $|I_1|+p_1|I_2 \cup I_3| = k+ct$, $|I_1'|+p_1|I_2' \cup I_3'| = k-t$, $|I_1 \cap I_1'| = k-(1+d) t$, and $|I_1 \backslash I_1'| = \kappa \in \{0, 1\}$. In addition, suppose that $|I_1| \ge k-100 C^4,$ which means that $|I_1'| \ge k-100 C^4-1$. In this case, we may follow the same approach as in our Theorem \ref{thm:main} to obtain a $\rho(p_1) \cdot (1+O(\varepsilon))$-approximation to $k$-means. Alternatively, we may suppose that $|I_1| \le k-100 C^4$, which implies that $|I_2 \cup I_3| \ge 100 C^4$. Then, defining $r \ge 1$ such that $c=(r-1) \cdot (1+d)$, we can use Equation \eqref{eq:cost_bound_improved} to find a solution of size at most $k$ with cost at most \begin{equation} \label{eq:cost1_improved} \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \left[\sum_{i = 1}^{5} \rho^{(i)}\left(\frac{p_1}{r}\right) \cdot \left(Q_i - \frac{p_1}{r} \cdot R_i\right)\right] + O(\gamma) \cdot \text{OPT}_{k}, \end{equation} in the same manner as \eqref{eq:cost_bound_improved}, by setting $p = p_1 \cdot \frac{(1+d)t-\kappa}{(1+c+d)t-\kappa} = \frac{p_1}{r} - O(1/C)$. Alternatively, we can obtain two separate solutions $I_1 \subset S \subset I_1 \cup I_2 \cup I_3$ of size $k+ct$, and a solution $I_1' \subset S' \subset I_1' \cup I_2' \cup I_3'$ of size $k-t$, such that $|S \cup S'| = k+(c+d) t$. We have that \[\text{cost}(\mathcal{D}, S \cup S') \le \text{cost}(\mathcal{D}, S) \le \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \left[\sum_{i = 1}^{5} \rho^{(i)}\left(p_1\right) \cdot (Q_i-p_1 \cdot R_i)\right]+O(\gamma) \cdot \text{OPT}_{k}.\] Finally, using the bound \eqref{eq:Sprime_bound} for the cost of $S'$, we have \[\text{cost}(\mathcal{D}, S') \le \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \rho(p_1) \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot (k-t)\right) + O(\gamma) \cdot \text{OPT}_{k}.\] Note that we are not able to use a more sophisticated bound for $\text{cost}(\mathcal{D}, S')$, because our values of $\{Q_i\}$ and $\{R_i\}$ only apply to $(I_1, I_2, I_3)$ and not to $(I_1', I_2', I_3')$. By combining the solutions $S \cup S'$ and $S'$, by adding $t$ random points from $S \backslash S'$ to $S'$, and using Proposition \ref{prop:submodular_3}, we obtain a solution $S''$ with expected cost \begin{multline} \mathbb E[\text{cost}(\mathcal{D}, S'')] \le \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \Biggr[\frac{1}{r(1+d)} \cdot \sum_{i = 1}^5 \rho^{(i)}(p_1) \cdot (Q_i-p_1 \cdot R_i) \\ + \left(1-\frac{1}{r(1+d)}\right) \cdot \rho(p_1) \cdot \Biggr(\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot (k-t)\Biggr)\Biggr] + O(\gamma) \cdot \text{OPT}_k. \label{eq:cost2_improved} \end{multline} This is because we combine the solution $S \cup S'$, which has size $k+(c+d)t$, with the solution $S'$, which has size $k-t,$ so we assign the first solution relative weight $\frac{1}{1+c+d} = \frac{1}{r(1+d)}$ and the second solution relative weight $\frac{c+d}{1+c+d} = 1-\frac{1}{r(1+d)}$. Now, let $\mathfrak{D}$ equal $\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k$. Then, since $|I_1|+\frac{p_1}{r} |I_2 \cup I_3| \ge k$, we can combine Equations \eqref{eq:Qi_sum_upper_bound} and \eqref{eq:Ri_sum_lower_bound} to get that \begin{align} \sum_{i = 1}^{5} \left(Q_i-\frac{p_1}{r} R_i\right) &\le \sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot \left(|I_1|+\frac{p_1}{r} |I_2 \cup I_3|\right) + O(\gamma) \cdot \text{OPT}_k \nonumber \\ &\le \mathfrak{D} + O(\gamma) \cdot \text{OPT}_k. \label{eq:bound_1} \end{align} Next, recall (by Equation \eqref{eq:cost1_improved}) that we have a solution of size at most $k$ with cost at most \begin{equation} \label{eq:bound_1.5} \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \left[\sum_{i = 1}^{5} \rho^{(i)}\left(\frac{p_1}{r}\right) \cdot \left(Q_i - \frac{p_1}{r} \cdot R_i\right)\right] + O(\gamma) \cdot \text{OPT}_k. \end{equation} Finally, we note that since $|I_2 \cup I_3| = \frac{r(1+d)t-\kappa}{p_1} \ge (1-O(1/C)) \cdot \frac{r(1+d) t}{p_1},$ we have that \[\sum_{i = 1}^{5} R_i + O(\gamma) \cdot \text{OPT}_k \ge \left(\lambda-\frac{1}{n}\right) \cdot |I_2 \cup I_3| \ge \left(1-O(\frac{1}{C})\right) \cdot \frac{r(1+d)}{p_1} \cdot \left(\lambda-\frac{1}{n}\right) \cdot t.\] Therefore, we can bound the expected cost of $S''$ by \begin{multline} \left(1+O(\varepsilon+\frac{1}{C})\right) \cdot \Biggr[\frac{1}{r(1+d)} \cdot \sum_{i = 1}^{5} \rho^{(i)}(p_1) \cdot (Q_i-p_1 \cdot R_i) \\ + \left(1-\frac{1}{r(1+d)}\right) \cdot \rho(p_1) \cdot \left(\mathfrak{D}+\frac{p_1}{r(1+d)} \cdot \sum_{i = 1}^{5} R_i\right)\Biggr] + O(\gamma) \cdot \text{OPT}_k. \label{eq:bound_2} \end{multline} Now, we have that $r \ge 1$, and if we let $\theta = \frac{1}{1+d}$, we have that $\theta \in [0, 1]$. Hence, to show that we obtain an approximation $\rho + O(\varepsilon + \gamma + 1/C)$, it suffices to show that for all choices of $\theta \in [0, 1]$ and $r \ge 1,$ that if we let $\mathfrak{D}' = \mathfrak{D}+O(\gamma) \cdot \text{OPT}_k$, one cannot simultaneously satisfy \begin{align} \mathfrak{D}' &\ge \sum_{i = 1}^{5} \left(Q_i-\frac{p_1}{r} R_i\right) \label{eq:bound_3}\\ \rho \cdot \mathfrak{D}' &< \frac{\theta}{r} \sum_{i = 1}^{5} \rho^{(i)}(p_1) \cdot (Q_i-p_1 \cdot R_i) + \left(1-\frac{\theta}{r}\right) \cdot \rho(p_1) \cdot \left(\mathfrak{D}' + p_1 \cdot \frac{\theta}{r} \sum_{i = 1}^{5} R_i\right) \label{eq:bound_4} \\ \rho \cdot \mathfrak{D}' &< \sum_{i = 1}^{5} \rho^{(i)}\left(\frac{p_1}{r}\right) \cdot \left(Q_i-\frac{p_1}{r} \cdot R_i\right) \label{eq:bound_5} \end{align} and \begin{equation} R_1 \le Q_1, \hspace{1cm} R_2 \le Q_2, \hspace{1cm} R_3 \le Q_3, \hspace{1cm} R_4 \le 1.75 Q_4, \hspace{1cm} R_5 \le 2 Q_5. \label{eq:bound_6} \end{equation} Indeed, we already know that \eqref{eq:bound_3} is true (same as \eqref{eq:bound_1}) and that \eqref{eq:bound_6} is true (same as \eqref{eq:S_i_bound}). So if we can show we can't simultaneously satisfy all of \eqref{eq:bound_3}, \eqref{eq:bound_4}, \eqref{eq:bound_5}, and \eqref{eq:bound_6}, then either \eqref{eq:bound_4} or \eqref{eq:bound_5} is false. But we have a clustering with at most $k$ centers and cost at most the right hand sides of each of \eqref{eq:bound_4} and \eqref{eq:bound_5} up to a $1+O(1/C + \varepsilon + \gamma)$ multiplicative factor, due to \eqref{eq:bound_2} and \eqref{eq:bound_1.5}, respectively. Therefore, we successfully obtain a solution of cost at most $\rho \cdot \left(1 + O(1/C + \varepsilon + \gamma)\right) \cdot \mathfrak{D}'$. Moreover, $\mathfrak{D}' \le \sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda-\frac{1}{n}\right) \cdot k + O(\gamma) \cdot \text{OPT}_k \le (1+O(\gamma)) \cdot \text{OPT}_k$, since $\sum_{j \in \mathcal{D}} \alpha_j - \left(\lambda+\frac{2}{n}\right) \cdot k \le \text{OPT}_k$ by Proposition \ref{prop:duality_bound} as both $\alpha^{(\ell)}, \alpha^{(\ell+1)}$ are solutions to $\text{DUAL}(\lambda+\frac{1}{n})$, and since $\frac{3k}{n} \le 3 \le O(\gamma) \cdot \text{OPT}_k$. Therefore, $\mathfrak{D}' \le (1+O(\gamma)) \cdot \text{OPT}_k$, which means that we have found a $\rho \cdot (1+O(1/C+\varepsilon+\gamma))$ approximation to $k$-means clustering. Indeed, by numerical analysis of these linear constraints and based on the functions $\rho^{(i)}$, we obtain a $\boxed{5.912}$-approximation algorithm for Euclidean $k$-means clustering. We defer the details to Appendix \ref{app:k_means_numerical_analysis}. \section{Improved Approximation Algorithm for $k$-median} \label{sec:k_median} \subsection{Improvement to $1+\sqrt{2}$-approximation} \label{subsec:lmp_k_median_easy} In this subsection, we show that a $1+\sqrt{2}+\varepsilon$-approximation can be obtained by a simple modification of the Ahmadian et al. \cite{ahmadian2017better} analysis. Because we use the same algorithm as \cite{ahmadian2017better}, the reduction from an LMP algorithm to a full polynomial-time algorithm is identical, so it suffices to improve the analysis of their LMP algorithm to a $1+\sqrt{2}$-approximation. The main difficulty in this subsection will be obtaining a tight bound on the norms (as opposed to squared norms) of points that are pairwise separated, which we prove in Lemma \ref{lem:geometric_median}. In the next subsection, we show how to break the $1+\sqrt{2}$ barrier that this algorithm runs into, which will follow a similar approach to our improved $k$-means algorithm. We first recall the setup of the LMP approximation of \cite{ahmadian2017better}. Let $c(j, i) = d(j, i)$ be the distance between a client $j \in \mathcal{D}$ and a facility $i \in \mathcal{F}$. Suppose we have a solution $\alpha$ to $\text{DUAL}(\lambda)$, such that every client $j$ has a tight witness $w(j) \in \mathcal{F}$ with $\alpha_j \ge t_{w(j)}$ and $\alpha_j \ge c(j, w(j)).$ Recall that $t_i = \max_{j \in N(i)} \alpha_j$, where $N(i) = \{j \in \mathcal{D}: \alpha_j > c(j, i)\}$, and likewise, $N(j) = \{i \in \mathcal{F}: \alpha_j > c(j, i)\}$. Now, we let the conflict graph $H(\delta)$ on tight facilities (i.e., facilities $i$ with $\sum_{j \in N(i)} (\alpha_j-c(j, i)) = \lambda$) have an edge $(i, i')$ if $c(i, i') \le \delta \cdot \min(t_i, t_{i'})$. We let $\delta = \sqrt{2}$ and return a maximal independent set $I$ of $H(\delta)$ as our LMP-approximation. It suffices to show that for each client $j \in \mathcal{D},$ that $c(j, I) \le (1+\sqrt{2}) \cdot \left(\alpha_j-\sum_{i \in N(j) \cap I} (\alpha_j-c(j, i))\right).$ To see why, by adding over all clients $j$, we obtain that \[\text{cost}(\mathcal{D}, I) \le (1+\sqrt{2}) \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \sum_{i \in I} \sum_{j \in N(i)} (\alpha_j-c(j, i))\right) = (1+\sqrt{2}) \cdot \left(\sum_{j \in \mathcal{D}} \alpha_j - \lambda \cdot |I|\right).\] Finally, since $\alpha$ is a feasible solution to $\text{DUAL}(\lambda),$ this implies that $\text{cost}(\mathcal{D}, I) \le (1+\sqrt{2}) \cdot \text{OPT}_{|I|}.$ Before we verify the LMP approximation, we need the following lemma about points in Euclidean space. \begin{lemma} \label{lem:geometric_median} Let $h \ge 2$ and suppose that $x_1, \dots, x_h$ are points in Euclidean space $\mathbb R^d$ (for some $d$) such that $\|x_i-x_j\|_2^2 \ge 2$ for all $i \neq j$. Then, $\sum_{i=1}^{h} \|x_i\|_2 \ge \sqrt{h \cdot (h-1)}$. \end{lemma} \begin{proof} Note that for any positive real numbers $t_1, t_2, \dots, t_h$ that add to $1$, we have that \[\sum_{i = 1}^{h} t_i \cdot \|x_i\|_2^2 \ge \sum_{i=1}^{h} t_i \cdot \|x_i\|_2^2 - \left\|\sum t_i x_i\right\|_2^2 = \sum_{i < j} t_i t_j \|x_i-x_j\|_2^2 \ge 2 \cdot \sum_{i < j} t_i t_j.\] Then, by setting $a_i = \|x_i\|_2$ for each $i$ and scaling by $t_1+\cdots+t_h$ accordingly to remove the assumption that $t_1+\cdots+t_h = 1$, we have that \[\left(\sum_{i = 1}^{h} t_i \cdot a_i^2\right) \cdot \left(\sum_{i=1}^{h} t_i\right) \ge 2 \cdot \sum_{i < j} t_it_j\] for all $t_1, \dots, t_h \ge 0$. Now, if some $a_i = 0$, then $\|x_j\|_2 = \|x_i-x_j\|_2 \ge \sqrt{2}$, which means that $\sum_{i=1}^{h} \|x_j\|_2 \ge (h-1) \cdot \sqrt{2} \ge \sqrt{h(h-1)}$ for all $h \ge 2$. Alternatively, $a_i \neq 0$ for any $i$, so we can set $t_i = \frac{1}{a_i}$, to obtain that \begin{equation} \label{eq:sym_ineq_1} \left(\sum_{i=1}^{h} a_i\right) \cdot \left(\sum_{i=1}^{h} \frac{1}{a_i}\right) \ge 2 \cdot \sum_{i < j} \frac{1}{a_ia_j}. \end{equation} From now on, for any polynomial $P(a_1, \dots, a_h)$, we denote $\sum_{\text{sym}} P(a_1, \dots, a_h)$ to be the sum of all distinct terms of the form $P(a_{\pi(1)}, \dots, a_{\pi(h)})$ over all permutations of $[h]$. For instance, $\sum_{\text{sym}} a_1a_2a_3 = \sum_{1 \le i < j < k \le h} a_ia_ja_k$ and $\sum_{\text{sym}} a_1^2 a_2 = \sum_{1 \le i < j \le h} a_i^2 a_j + \sum_{1 \le j < i \le h} a_i^2 a_j$. In the case when $h = 2$, this means that $(a_1+a_2) \cdot \frac{a_1+a_2}{a_1a_2} \ge \frac{2}{a_1a_2},$ so $a_1+a_2 \ge \sqrt{2} = \sqrt{h(h-1)}.$ Alternatively, we assume that $h \ge 3$. When $h \ge 3$, note that \begin{align} \left(\sum_{\text{sym}} a_1 \cdots a_{h-2}\right) \cdot \left(\sum a_i\right) &= (h-1) \cdot \sum_{\text{sym}} a_1 \cdots a_{h-1} + \sum_{\text{sym}} a_1^2 a_2 \cdots a_{h-2} \nonumber \\ &\ge \left[(h-1) + \frac{h(h-1)(h-2)/2}{h}\right] \cdot \sum_{\text{sym}} a_1 \cdots a_{h-1} \nonumber \\ &= \frac{h(h-1)}{2} \cdot \sum_{\text{sym}} a_1 \cdots a_{h-1}, \label{eq:sym_ineq_2} \end{align} where the second line above follows by Muirhead's inequality. Therefore, we have that \begin{align*} \left(\sum_{i=1}^{h} a_i\right)^2 &\ge \left(\sum_{i=1}^{h} a_i\right) \cdot \frac{h(h-1)}{2} \cdot \frac{\sum_{\text{sym}} a_1 \cdots a_{h-1}}{\sum_{\text{sym}} a_1 \cdots a_{h-2}} \\ &= \left(\sum_{i=1}^{h} a_i\right) \cdot \frac{h(h-1)}{2} \cdot \frac{\sum_{\text{sym}} \frac{1}{a_i}}{\sum_{\text{sym}} \frac{1}{a_ia_j}} \\ &\ge 2 \cdot \frac{h(h-1)}{2} \\ &= h(h-1), \end{align*} where the first line follows from \eqref{eq:sym_ineq_2} and the third line follows from \eqref{eq:sym_ineq_1}. Therefore, we indeed have that $\sum_{i=1}^{h} \|x_i\|_2 \ge \sqrt{h(h-1)}$. \end{proof} To verify the LMP approximation, it suffices to show that for every $j$, $c(j, I) \le (1+\sqrt{2}) \cdot \left(\alpha_j-\sum_{i \in N(j) \cap I} (\alpha_j-c(j, i))\right).$ We split this up into $3$ cases. \paragraph{Case 1: $\boldsymbol{|I \cap N(j)| = 0}$.} In this case, $d(j, I) \le d(j, w(j))+d(w(j), I)$ by the Triangle Inequality. But we know that $d(j, w(j)) \le \alpha_j$, and that $d(w(j), I) \le \sqrt{2} \cdot t_{w(j)} \le \sqrt{2} \cdot \alpha_j$, using the fact that $I$ is a maximal independent set so $w(j)$ has some neighbor of $I$ in the conflict graph. Thus, $d(j, I) \le (1+\sqrt{2}) \cdot \alpha_j$. However, since $N(j) \cap I = \emptyset$, this means that $\left(\alpha_j-\sum_{i \in N(j) \cap I} (\alpha_j-c(j, i))\right) = \alpha_j$. So, the desired inequality holds. \paragraph{Case 2: $\boldsymbol{|I \cap N(j)| = 1}$.} In this case, let $i_1$ be the unique point in $N(j) \cap I$. Then, $d(j, I) \le d(j, i_1)$. In addition, $\left(\alpha_j-\sum_{i \in N(j) \cap I} (\alpha_j-c(j, i))\right) = \alpha_j-(\alpha_j-c(j, i_1)) = c(j, i_1) = d(j, i_1)$. Since $d(j, i_1) \ge 0$, the desired inequality holds (even with a ratio of $1 < 1+\sqrt{2}$). \paragraph{Case 3: $\boldsymbol{|I \cap N(j)| = s \ge 2}$.} In this case, let $i_1, \dots, i_s$ be the set of points in $N(j) \cap I$. Then, we know that $d(i_r, i_{r'}) \ge \delta \cdot \min(t_{i_r}, t_{i_{r'}})$ for any $r \neq r'$. But $t_{i_r}, t_{i_{r'}} \ge \alpha_j$ by definition of $t_i$ (since $i_r, i_{r'} \in N(j)$), so this means that $d(i_r, i_{r'}) \ge \sqrt{2} \cdot \alpha_j$ for every $r \neq r'$. Now, by applying Lemma \ref{lem:geometric_median}, we have that $\sum_{r=1}^{s} d(j, i_r) \ge \sqrt{s \cdot (s-1)} \cdot \alpha_j$. Now, let $t = \frac{1}{\alpha_j} \cdot \sum_{r=1}^{s} d(j, i_r)$, so $t \ge \sqrt{s \cdot (s-1)}$. Then, $d(j, I) \le \min_{1 \le r \le s} d(j, i_r) \le \frac{1}{s} \cdot \sum_{r=1}^{s} d(j, i_r) = \frac{T}{s} \cdot \alpha_j$. Ina ddition, we have that $\alpha_j-\sum_{i \in N(j) \cap I} (\alpha_j-c(j, i)) = \alpha_j-s \cdot \alpha_j + T \cdot \alpha_j = (T-(s-1)) \cdot \alpha_j$. So, the ratio is \[\frac{T/s}{T-(s-1)} \le \frac{\sqrt{s \cdot s-1}/s}{\sqrt{s(s-1)}-(s-1)} = \frac{1}{s-\sqrt{s(s-1)}} \le 2.\] Above, the first inequality follows because as $T$ increases, the numerator increases at a slower rate than the denominator, so assuming that the fraction is at least $1$, we wish for $T$ to be as small as possible to maximize the fraction. The final inequality holds because $s-\sqrt{s(s-1)} \ge \frac{1}{2}$ for all $s \ge 2$. Therefore, the desired inequality holds (even with a ratio of $2 < 1+\sqrt{2}$). \medskip So in fact, there is a simple improvement from the $1+\sqrt{8/3} \approx 2.633$ approximation algorithm to a $1+\sqrt{2} \approx 2.414$ algorithm. A natural question is whether this can be improved further without any significant changes to the algorithm or analysis. Indeed, there only seems to be one bottleneck, when $|I \cap N(j)| = 0$, so naturally one may assume that by slightly reducing $\delta=\sqrt{2}$, the approximation from Case 1 should improve below $1+\sqrt{2}$ and the approximation from Case 3 should become worse than $2$, but can still be below $1+\sqrt{2}$. Unfortunately, such a hope cannot be realized. Indeed, if we replace $\delta=\sqrt{2}$ with some $\delta < \sqrt{2}$, we may have that $d(j, i_1) = d(j, i_2) = \cdots = d(j, i_s) = \delta \cdot \sqrt{\frac{s-1}{2s}} \cdot \alpha_j$ and the pairwise distances are all exactly $\delta \cdot \alpha_j$ between each $i_r, i_{r'}$. However, in this case, $\alpha_j-\sum_{i \in N(j) \cap I} (\alpha_j-c(j,i)) = \alpha_j \cdot \left(1-s+\delta \cdot \sqrt{s(s-1)/2}\right),$ which for $\delta < \sqrt{2}$ is in fact negative for sufficiently large $s$. Hence, even for $\delta = \sqrt{2}-\varepsilon$ for a very small choice of $\varepsilon > 0$, we cannot even guarantee a constant factor approximation with this analysis approach. So, this approach gets stuck at a $1+\sqrt{2}$ approximation. In the following subsection, we show how an improved LMP approximation algorithm for Euclidean $k$-median, breaking the $1+\sqrt{2}$ approximation barrier. We will then show that we can also break this barrier for a polynomial-time $k$-median algorithm as well. \subsection{An improved LMP algorithm for Euclidean $k$-median} Recall the conflict graph $H := H(\delta)$, where we define two tight facilities $(i, i')$ to be connected if $c(i, i') \le \delta \cdot \min(t_i, t_{i'}).$ We set parameters $\delta_1 \ge \delta_2 \ge \delta_3$ and $0 < p < 1$, and define $V_1$ to be the set of all tight facilities. Given the set of tight facilities $V_1$ and conflict graphs $H(\delta)$ for all $\delta > 0$, our algorithm works by applying the procedure described in Algorithm \ref{alg:lmp_k_median} to $V_1$. \begin{figure} \centering \begin{algorithm}[H] \caption{ Generate a Nested Quasi-Independent Set of $V_1$, as well as a set of centers $S$ providing an LMP approximation for Euclidean $k$-median }\label{alg:lmp_k_median} \Call{LMPMedian}{$V_1, \{H(\delta)\}, \delta_1, \delta_2, \delta_3, p$}: \begin{algorithmic}[1] \item Create a maximal independent set $I_1$ of $H(\delta_1)$. \label{step:I1_median} \item Let $V_2$ be the set of points in $V_1 \backslash I_1$ that are not adjacent to $I_1$ in $H(\delta_2)$. \label{step:V2_median} \item Create a maximal independent set $I_2$ of the induced subgraph $H(\delta_1)[V_2]$. \label{step:I2_median} \item Let $V_3$ be the set of points $i$ in $V_2 \backslash I_2$ such that there is exactly one point in $I_2$ that is a neighbor of $i$ in $H(\delta_1)$, there are no points in $I_1$ that are neighbors of $i$ in $H(\delta_2)$, and there are no points in $I_2$ that are neighbors of $i$ in $H(\delta_3)$. \label{step:V3_median} \item Create a maximal independent set $I_3$ of the induced subgraph $H(\delta_1)[V_3]$. \label{step:I3_median} \item Note that every point $i \in I_3$ has a unique adjacent neighbor $q(i) \in I_2$ in $H(\delta_1)$. We create the final set $S$ as follows: \label{step:S_median} \begin{itemize} \item Include every point $i \in I_1$. \item For each point $i \in I_2$, flip a fair coin. If the coin lands heads, include $i$ with probability $2p$. Otherwise, include each point in $q^{-1}(i)$ independently with probability $2p$. \end{itemize} \end{algorithmic} \end{algorithm} \end{figure} As in the $k$-means case, we consider a more general setup, so that we can convert the LMP approximation to a full polynomial-time algorithm. Instead of $V_1,$ let $\mathcal{V} \subset \mathcal{F}$ be a subset of facilities and let $\mathcal{D}$ be the full set of clients. For each $j \in \mathcal{D},$ let $\alpha_j \ge 0$ be some real number, and for each $i \in \mathcal{V}$, let $t_i \ge 0$ be some real number. In addition, for each client $j \in \mathcal{D}$, we associate with it a set $N(j) \subset \mathcal{V}$ and a ``witness'' facility $w(j) \in \mathcal{V}$. Finally, suppose that we have the following assumptions: \begin{enumerate} \item For any client $j \in \mathcal{D}$, the witness $w(j) \in \mathcal{V}$ satisfies $\alpha_j \ge t_{w(j)}$ and $\alpha_j \ge c(j, w(j))$. \item For any client $j \in \mathcal{D}$ and any facility $i \in N(j)$, $t_i \ge \alpha_{j} > c(j, i)$. \end{enumerate} Then, for the graph $H(\delta)$ on $\mathcal{V}$ where $i, i' \in \mathcal{V}$ are connected if and only if $c(i, i') \le \delta \cdot \min(t_i, t_{i'})$ (recall that now, $c(i, i') = d(i, i')$ instead of $d(i, i')^2$), we have the following main lemma. \begin{lemma} \label{lem:main_lmp_median} Fix $\delta_1 = \sqrt{2}$, $\delta_2 = 1.395$, and $\delta_3 = 2-\sqrt{2} \approx 0.5858,$ and let $p < 0.337$ be variable. Now, let $S$ be the randomized set created by applying Algorithm \ref{alg:lmp_k_median} on $V_1 = \mathcal{V}$. Then, for any $j \in \mathcal{D}$, \[\mathbb E[c(j, S)] \le \rho(p) \cdot \mathbb E\left[\alpha_j - \sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right],\] where $\rho(p)$ is some constant that only depends on $p$ (since $\delta_1, \delta_2, \delta_3$ are fixed). \end{lemma} \begin{proof} As in the $k$-means case, we fix $j \in \mathcal{D}$, and we do casework based on the sizes of $a=|I_1 \cap N(j)|$, $b=|I_2 \cap N(j)|$, and $c=|I_3 \cap N(j)|$. \paragraph{Case 1: $\boldsymbol{a=0, b=1, c=0}$.} Let $i_2$ be the unique point in $I_2 \cap N(j),$ and let $i^* = w(j)$ be the witness of $j$. We have the following subcases: \begin{enumerate}[label=\alph*)] \item $\boldsymbol{i^* \not\in V_2}$. In this case, either $i^* \in I_1$ so $d(i^*, I_1) = 0$, or there exists $i_1 \in I_1$ such that $d(i^*, i_1) \le \delta_2 \cdot \min(t_{i^*}, t_{i_1}) \le \delta_2$. So, $d(j, I_1) \le 1+\delta_2$. In addition, we have that $i_2 \in S$ with probability $p$. So, if we let $t := d(j, i_2)$, we can bound the ratio by \begin{equation} \tag{1.a'}\label{eq:1.a'} \frac{p \cdot t + (1-p) \cdot (1+\delta_2)}{1-p(1-t)} = \frac{p \cdot t + (1-p) \cdot (1+\delta_2)}{p \cdot t + (1-p)} \le 1+\delta_2, \end{equation} since $t \ge 0$. \item $\boldsymbol{i^* \in V_3}.$ In this case, there exists $i_3 \in I_3$ (possibly $i_3 = i^*$) such that $d(i^*, i_3) \le \delta_1 \cdot \min(t_{i^*}, t_{i_3}).$ In addition, there exists $i_1 \in I_1$ such that $d(i^*, i_1) \le \delta_1 \cdot \min(t_{i^*}, t_{i_1})$. In addition, we have that $t_{i^*} \le \alpha_j = 1$. Finally, since $I_3 \subset V_2$, we must have that $d(i_1, i_3) \ge \delta_2 \cdot \min(t_{i_1}, t_{i_3})$. If we condition on $i_2 \in S$, then the numerator and denominator both equal $c(j, i_2)$, so the fraction is $1$ (or $0/0$). Else, if we condition on $i_2 \not\in S$, then the denominator is $1$, and $i_3 \in S$ with probability either $p$ or $\frac{p}{1-p} > p$. Therefore, $\mathbb E[d(j, S)|i_2 \not\in S] \le p \cdot \|i_3-j\|_2 + (1-p) \cdot \|i_1-j\|_2$. We can bound this (we defer the details to Appendix \ref{app:bash}) by \begin{equation} \tag{1.b'}\label{eq:1.b'} \inf_{T > 0} \sqrt{3\left(X+Y\right)+2\sqrt{2\left(X+Y\right)^{2}-\delta_2^2 \cdot XY}}, \end{equation} where $X = p^2+p(1-p) \cdot T$ and $Y = (1-p)^2 + \frac{p(1-p)}{T}.$ \end{enumerate} In the remaining cases, we may assume that $i^*\in V_2 \backslash V_3$. Then, one of the following must occur: \begin{enumerate}[label=\alph*)] \setcounter{enumi}{2} \item $\boldsymbol{i^* = i_2}$. In this case, define $t = d(j, i^*) \in [0, 1]$, and note that $d(j, I_1) \le d(j, i^*)+d(i^*, I_1) \le t + \delta_1$. So, with probability $p$, we have that $d(j, S) \le d(j, i^*) = t$, and otherwise, we have that $d(j, S) \le d(j, I_1) = t + \delta_1$. So, we can bound the ratio by \[\max_{0 \le t \le 1} \frac{p \cdot t + (1-p) \cdot (t + \delta_1)}{1-p \cdot (1-t)} = \max_{0 \le t \le 1} \frac{t + (1-p)\delta_1}{p \cdot t + (1-p)}.\] For $p$ such that $1/p > \delta_1,$ it is clear that this function increases as $t$ increases, so it is maximized when $t = 1$, which means we can bound the ratio by \begin{equation} \tag{1.c'}\label{eq:1.c'} 1 + (1-p) \cdot \delta_1. \end{equation} \item $\boldsymbol{i^* \in I_2}$ \textbf{but} $\boldsymbol{i^* \neq i_2}$. First, we recall that $d(j, i^*) \le 1$. Now, let $t = d(j, i_2)$. In this case, with probability $p$, $d(j, S) = t$ (if we select $i_2$ to be in $S$), with probability $p(1-p)$, $d(j, S) \le 1$ (if we select $i^*$ but not $i_2$ to be in $S$), and in the remaining event of $(1-p)^2$ probability, we still have that $d(j, S) \le d(j, I_1) \le d(j, i^*) + d(i^*, I_1) \le 1 + \delta_1.$ So, we can bound the ratio by \[\max_{0 \le t \le 1} \frac{p \cdot t + p(1-p) \cdot 1 + (1-p)^2 \cdot (1+\delta_1)}{1-p \cdot (1-t)}.\] Note that this is maximized when $t = 0$ (since the numerator and denominator increase at the same rate when $t$ increases), so we can bound the ratio by \begin{equation} \tag{1.d'} \label{eq:1.d'} \frac{p(1-p) + (1-p)^2 \cdot (1+\delta_1)}{1-p} = 1 + (1-p) \cdot \delta_1. \end{equation} \item \textbf{There is more than one neighbor of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_1)}$ \textbf{that is in} $\boldsymbol{I_2}$. In this case, there is some other point $i_2' \in I_2$ not in $N(j)$ such that $d(i^*, i_2') \le \delta_1 \cdot \min(t_{i^*}, t_{i_2'}).$ So, we have four points $j, i^*, i_1 \in I_1, i_2' \in I_2$ such that $d(j, i^*) \le 1,$ $d(i^*, i_2') \le \delta_1 \cdot \min(t_{i^*}, t_{i_2'}),$ $d(i^*, i_1) \le \delta_1 \cdot \min(t_{i^*}, t_{i_1}),$ and $d(i_1, i_2') \ge \delta_2 \cdot \min(t_{i_1}, t_{i_2'}).$ If we condition on $i_2 \in S$, then the denominator equals $c(j, i_2)$ and the numerator is at most $c(j, i_2)$, so the fraction is $1$ (or $0/0$). Else, if we condition on $i_2 \not\in S$, then the denominator is $1$, and the numerator is at most $p \cdot \|i_2'-j\|_2^2 + (1-p) \cdot \|i_1-j\|_2^2$. Note that $d(j, i^*) \le 1$, that $t_{i^*} \le 1$, and that $\delta_2, \delta_1 \ge \delta_2$. So, as in case b), the overall fraction is at most \begin{equation} \tag{1.e'} \label{eq:1.e'} \inf_{T > 0} \sqrt{3\left(X+Y\right)+2\sqrt{2\left(X+Y\right)^{2}-\delta_2^2 \cdot XY}}, \end{equation} where $X = p^2+p(1-p) \cdot T$ and $Y = (1-p)^2 + \frac{p(1-p)}{T}.$ \item \textbf{There are no neighbors of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_1)}$ \textbf{that are in} $\boldsymbol{I_2}$. In this case, $d(i^*, i_2) \ge \delta_1 \cdot \min(t_{i^*}, t_{i_2}).$ Define $t = \min(t_{i^*}, t_{i_2})$. Since $d(j, i^*) \le 1,$ by the triangle inequality we have that $d(j, i_2) \ge \max\left(0, \delta_1 \cdot t-1\right)$. In addition, we still have that $d(j, I_1) \le d(j, i^*) + d(i^*, I_1) \le 1 + \delta_1 \cdot t_{i^*},$ and $d(j, I_1) \le d(j, i_2) + d(i_2, I_1) \le 1 + \delta_1 \cdot t_{i_2}$, so together we have that $d(j, I_1) \le 1+\delta_1 \cdot t$. Since $i_2 \in S$ with probability $p$, the ratio is at most \begin{align*} &\hspace{0.5cm}\max_{0 \le t \le 1} \max_{d(j, i_2) \ge \delta_1 \cdot t - 1} \frac{p \cdot d(j, i_2) + (1-p) \cdot (1+\delta_1 \cdot t)}{1-p(1-d(j, i_2))} \\ &= \max_{0 \le t \le 1} \max_{d(j, i_2) \ge \delta_1 \cdot t - 1} \frac{p \cdot d(j, i_2) + (1-p) \cdot (1+\delta_1 \cdot t)}{p \cdot d(j, i_2) + (1-p)}. \end{align*} It is clear that this function is decreasing as $d(j, i_2)$ is increasing (and nonnegative). So, we may assume WLOG that $d(j, i_2) = \max(0, \sqrt{\delta_2 \cdot t}-1)$ to bound this ratio by \begin{equation*} \max_{0 \le t \le 1} \frac{p \cdot \max(0, \delta_1 \cdot t-1) + (1-p) \cdot (1+\delta_1 \cdot t)}{p \cdot \max(0, \delta_1 \cdot t-1) + (1-p)} \end{equation*} If $\delta_1 \cdot t - 1 \le 0$, then $\delta_1 \cdot t + 1 \le 2,$ so we can bound the above equation by $2$. Otherwise, the above fraction can be rewritten as $\frac{\delta_1 \cdot t + (1-2p)}{p \cdot \delta_1 \cdot t + (1-2p)}$. For $p < 0.5,$ this is maximized when $t = 1$ over the range $t \in [0, 1]$, so we can bound the ratio by \begin{equation} \tag{1.f'} \label{eq:1.f'} \frac{1-2p + \delta_1}{1-2p + p \cdot \delta_1}. \end{equation} \item \textbf{There is a neighbor of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_3)}$ \textbf{that is also in} $\boldsymbol{I_2}$. In this case, either $d(i^*, i_2) \le \delta_3 \cdot t_{i^*}$ so $d(i_2, j) \ge \max(0, d(j, i^*)-\delta_3 \cdot t_{i^*})$, or there is some other point $i_2' \in I_2$ not in $N(j)$ such that $d(i^*, i_2') \le \delta_3 \cdot \min(t_{i^*}, t_{i_2'}).$ If $d(i^*, i_2) \le \delta_3 \cdot t_{i^*}$, then define $t = t_{i^*}$ and $u = d(j, i^*)$. In this case, $d(j, I_1) \le u + \delta_1 \cdot t,$ and $d(j, i_2) \ge \max(0, u-\delta_3 \cdot t).$ So, the fraction is at most \[\frac{(1-p) \cdot (u+\delta_1 \cdot t)+p \cdot d(j, i_2)}{1-p+p \cdot d(j, i_2)} \le \frac{(1-p) \cdot (u+\delta_1 \cdot t)+p \cdot \max(0, u-t \cdot \delta_3)}{1-p+p \cdot \max(0, u-t \cdot \delta_3)}.\] Since $t = t_{i^*} \le 1$ and $d(j, i^*) \le 1$, we can bound the overall fraction as at most \begin{align} &\hspace{0.5cm}\max_{0 \le t \le 1} \max_{0 \le u \le 1} \frac{(1-p) \cdot (u+\delta_1 \cdot t)+p \cdot \max(0, u-t \cdot \delta_3)}{1-p+p \cdot \max(0, u-t \cdot \delta_3)} \nonumber \\ &\le \max\left(\delta_1+\delta_3, \frac{1 + \delta_1 - p(\delta_1+\delta_3)}{1-p \cdot \delta_3}\right) \tag{1.g.i'} \label{eq:1.g.i'} \end{align} We derive the final equality in Appendix \ref{app:bash}. Alternatively, if $d(i^*, i_2') \le \delta_3 \cdot \min(t_{i^*}, t_{i_2'}),$ then if we condition on $i_2 \in S,$ the fraction is $1$ (or $0/0$), and if we condition on $i_2 \not\in S$, the denominator is $1$ and the numerator is at most $p \cdot d(j, i_2') + (1-p) \cdot d(j, i_1) \le p \cdot (1+\delta_3)+(1-p) \cdot (1+\delta_1).$ (Note that $i_2 \in S$ and $i_2' \in S$ are independent.) Therefore, we can also bound the overall fraction by \begin{equation} \tag{1.g.ii'} \label{eq:1.g.ii'} p \cdot (1+\delta_3)+(1-p) \cdot (1+\delta_1). \end{equation} \item \textbf{There is a neighbor of} $\boldsymbol{i^*}$ \textbf{in} $\boldsymbol{H(\delta_2)}$ \textbf{that is also in} $\boldsymbol{I_1}$. In this case, $i^*$ would not be in $V_2$, so we are back to sub-case 1.a'. \end{enumerate} \paragraph{Case 2: $\boldsymbol{a = 0, b = 0, c \le 1}$.} We again let $i^*$ be the witness of $j$. In this case, if $i \not\in V_2$, then there exists $i_1 \in I_1$ such that $d(i^*, i_1) \le \delta_2 \cdot \min(t_{i^*}, t_{i_1}) \le \delta_2$, in which case $d(j, I_1) \le 1+\delta_2.$ Otherwise, there exists $i_1 \in I_1$ such that $d(i^*, i_1) \le \delta_1 \cdot \min(t_{i^*}, t_{i_1})$, and there exists $i_2 \in I_2$ such that $d(i^*, i_2) \le \delta_1 \cdot \min(t_{i^*}, t_{i_2})$. Finally, in this case we also have that $d(i_1, i_2) \ge \delta_2 \cdot \min(t_{i_1}, t_{i_2})$. Now, we consider two subcases, either $c = 0$ or $c = 1$. \begin{enumerate}[label=\alph*)] \item $\boldsymbol{c=0.}$ In this case, we have that the denominator is $1$, and the numerator is either at most $1+\delta_2$, or is at most $p \cdot \|j-i_2\|_2 + (1-p) \cdot \|j-i_1\|_2$, where $d(j, i^*) \le 1$, $d(i^*, i_1) \le \delta_1 \cdot \min(t_{i^*}, t_{i_1})$, $d(i^*, i_2) \le \delta_1 \cdot \min(t_{i^*}, t_{i_2})$, and $d(i_1, i_2) \ge \delta_2 \cdot \min(t_{i_1}, t_{i_2})$. Hence, we can bound the overall fraction, by the same computation as in the $k$-median subcase 1.b), as \begin{equation} \tag{2.a'} \label{eq:2.a'} \max\left(1+\delta_2, \inf_{T > 0} \sqrt{3\left(X+Y\right)+2\sqrt{2\left(X+Y\right)^{2}-\delta_2^2 \cdot XY}}\right), \end{equation} where $X = p^2+p(1-p) \cdot T$ and $Y = (1-p)^2 + \frac{p(1-p)}{T}.$ \item $\boldsymbol{c=1.}$ In this case, let $i_3$ be the unique point in $N(j) \cap I_3.$ Then, conditioned on $i_3$ being in $S$, the numerator and denominator both equal $d(j, i_3)$. Otherwise, the denominator is $1$ and we can bound the numerator the same way as in subcase 2a), since the probability of $i_2 \in S$ is either $p$ (if $q(i_3) \neq i_2$) or $\frac{p}{1-p} \ge p$ (if $q(i_3) = i_2$). So, we can bound the overall fraction again as \begin{equation} \tag{2.b'} \label{eq:2.b'} \max\left(1+\delta_2, \inf_{T > 0} \sqrt{3\left(X+Y\right)+2\sqrt{2\left(X+Y\right)^{2}-\delta_2^2 \cdot XY}}\right), \end{equation} where $X = p^2+p(1-p) \cdot T$ and $Y = (1-p)^2 + \frac{p(1-p)}{T}.$ \end{enumerate} \paragraph{Case 3: $\boldsymbol{a = 0}$, all other cases.} Note that in this case, we may assume $b+c = |N(j) \cap (I_2 \cup I_3)| \ge 2$, since we already took care of all cases when $a = 0$ and $b+c \le 1$. We split into two main subcases. \begin{enumerate}[label=\alph*)] \item \textbf{Every point} $\boldsymbol{i}$ \textbf{in} $\boldsymbol{N(j) \cap (I_2 \cup I_3)}$ \textbf{satisfies} $\boldsymbol{d(j, i) \ge \delta_1-1.}$ In this case, let $\bar{I} \subset I_2 \cup I_3$ represent the set of points selected to be in $S$. Note that $\bar{I}$ is a random set. Note that with probability at least $2p-2p^2$, $|N(j) \cap \bar{I}| \ge 1$. (Since $N(j) \cap (I_2 \cup I_3)$ has size at least $2$, the probability of $\bar{I} \cap N(j)$ being nonempty is minimized when $b = 0, c = 2$, and the two points in $N(j) \cap I_3$ map to the same point under $q$.) In this event, let $h = |N(j) \cap \bar{I}|$, and let $r_1, \dots, r_h$ represent the distances from $j$ to each of the points in $N(j) \cap \bar{I}$. Then, by Lemma \ref{lem:geometric_median}, $\frac{r_1+\cdots+r_h}{h} \ge \sqrt{\frac{h-1}{h}}.$ So, if we set $r= \frac{r_1+\cdots+r_h}{h},$ then $r \le 2\left[r \cdot h - (h-1)\right]$ for any $h \ge 1$ and $r \ge \sqrt{\frac{h-1}{h}},$ which means that $\min r_i \le \frac{r_1+\cdots+r_h}{h} \le 2 \cdot \left(1 - \sum_{i=1}^{h} (1-r_i)\right)$. In addition, if $|\bar{I}| = 1$, then $1-\sum (1-r_i) = r_1 \ge \delta_1-1 = \sqrt{2}-1$, and otherwise, because every point in $\bar{I}$ is separated by at least $\delta_1 = \sqrt{2}$ distance, $1 - \sum (1-r_i) \ge \sqrt{h(h-1)}-(h-1) \ge \sqrt{2}-1$ by Lemma \ref{lem:geometric_median}. Overall, this means that whenever $h = |N(j) \cap \bar{I}| \ge 1,$ $\min r_i \le 2 \cdot \left(1 - \sum (1-r_i)\right)$ and $1 - \sum (1-r_i) \ge \sqrt{2}-1$. In addition, if $\bar{I} = \emptyset$, then the denominator is $1$ and the numerator is at most $d(j, w(j)) + d(w(j), I_1) \le 1+\sqrt{2}$. Therefore, if we let $q$ be the probability that $|\bar{I}| \ge 1$ and $t$ be the expectation of $1-\sum(1-r_i)$ conditioned on $|\bar{I}| \ge 1$, the overall fraction is at most \begin{align} \frac{(1+\sqrt{2}) \cdot (1-q) + 2 \cdot t \cdot q}{(1-q) + t \cdot q} &\le \frac{(1+\sqrt{2}) \cdot (1-q) + 2 \cdot (\sqrt{2}-1) \cdot q}{(1-q) + (\sqrt{2}-1) q} \nonumber \\ &\le \frac{(1+\sqrt{2})-(3-\sqrt{2}) \cdot (2p-2p^2)}{1-(2-\sqrt{2}) \cdot (2p-2p^2)}. \tag{3.a'} \label{eq:3.a'} \end{align} \item \textbf{There exists a point} $\boldsymbol{i \in N(j) \cap (I_2 \cup I_3)}$ \textbf{such that} $\boldsymbol{d(j, i) < \delta_1-1.}$ In this case, note that $d(i, i') < \delta_1$ for all points $i' \in N(j) \cap (I_2 \cup I_3)$. Assuming $b+c \ge 2$, this is only possible if either: \begin{enumerate}[i)] \item $b=1,c=1$ and the unique points $i_2 \in N(j) \cap I_2$ and $i_3 \in N(j) \cap I_3$ satisfy $q(i_3) = i_2$, or \label{case:i} \item $b=1, c\ge 2$, the unique point $i_2 \in N(j) \cap I_2$ is the only point with $d(j, i) < \delta_1-1$, and every point in $N(j) \cap I_3$ maps to $i_2$ under $q$. \label{case:ii} \end{enumerate} First, assume Case \ref{case:i}. Let $r=d(j, i_2)$ and $s=d(j, i_3)$. Then, $\mathbb E \left[1-\sum_{i \in N(j) \cap S} (1-d(j, i))\right]$ $= (1-2p) \cdot 1 + p \cdot r + p \cdot s$, and the expected distance $d(j, S)$ is at most $p \cdot r + p \cdot s + (1-2p) \cdot (1+\sqrt{2})$. Since $d(r, s) \ge \delta_3$, this means that $r+s \ge \delta_3,$ so the overall fraction is at most \begin{equation} \label{eq:3.b.i'} \tag{3.b.i'} \frac{(1+\sqrt{2}) \cdot (1-2p) + \delta_3 \cdot p}{(1-2p) + \delta_3 \cdot p}. \end{equation} Next, assume Case \ref{case:ii}. Let $r=d(j, i_2)$, and let $s_1, \dots, s_c$ be the distances from $j$ to each of the $c$ points in $N(j) \cap I_3$. Let $s = \frac{s_ 1+\cdots+s_c}{c}$ Then, $\mathbb E\left[1-\sum_{i \in N(j) \cap S} (1-d(j,i))\right]=1-p(1-r)-\sum_{i=1}^{c}p(1-s_i) \ge 1-p(1+c)+p \cdot (r+s \cdot c).$ In addition, $\mathbb E[c(j, S)]$ is at most $(1+\sqrt{2}) \cdot (\frac{1}{2}-p) + (1+\sqrt{2}) \cdot \frac{1}{2}(1-2p)^c + p \cdot r + \frac{1}{2}\left(1-(1-2p)^c\right) \cdot s$. Since the numerator and denominator grow at the same rate with respect to $r$, and the numerator grows slower with respect to $s$ than the denominator, we wish to minimize $r$ and $s$ to maximize the fraction. So, we set $r=0$, and $s=\sqrt{\frac{c-1}{c}}$ by Lemma \ref{lem:geometric_median}. Therefore, the fraction is at most \begin{equation} \label{eq:3.b.ii'} \tag{3.b.ii'} \frac{(1+\sqrt{2}) \cdot \left(\frac{1}{2}(1-2p)+\frac{1}{2}(1-2p)^c\right) + \frac{1}{2}\left(1-(1-2p)^c\right) \cdot \sqrt{\frac{c-1}{c}}}{1-p(1+c-\sqrt{c(c-1)})} \end{equation} \end{enumerate} \paragraph{Case 4: $\boldsymbol{a \ge 1}$.} First, we will condition on the fair coin flips, and let $\bar{I} \subset N(j) \cap (I_2 \cup I_3)$ be the set of ``surviving'' points, i.e., the points that will be included in $S$ with probability $2p$. Note all points in $\bar{I}$ have pairwise distance at least $\delta_1 = \sqrt{2}$ from each other, and all points in $N(j) \cap I_1$ have pairwise distance at least $\delta_1$ from each other also. However, the points in $N(j) \cap I_1$ and $\bar{I}$ are only guaranteed to have pairwise distance at least $\delta_2$ from each other. Let $h$ represent the size $|\bar{I}|$. We consider several subcases. \begin{enumerate}[label=\alph*)] \item $\boldsymbol{h = 0.}$ In this case, we can use the same bounds as Cases 2 and 3 of the simpler $1+\sqrt{2}$-approximation, since we only have to worry about points in $I_1 \cap N(j).$ Indeed, the same bounds on the numerator and denominator still hold, so the ratio is at most \begin{equation} \label{eq:4.a'} \tag{4.a'} 2. \end{equation} \item $\boldsymbol{a=1,h=1.}$ In this case, let $i_1$ be the unique point in $N(j) \cap I_1$, and let $i_2$ be the unique point in $\bar{I}$. Then, $d(i_1, i_2) \ge \delta_2,$ so if $t = d(j, i_1)$ and $u = d(j, i_2)$, then the denominator in expectation is $1-(1-t)-2p(1-u) = t-2p(1-u) \ge t\cdot (1-2p)$, since $1-u \le t$. But, the numerator $\mathbb E[c(j, S)]$ is at most $t$, so the overall fraction is at most \begin{equation} \label{eq:4.b'} \tag{4.b'} \frac{1}{1-2p}. \end{equation} \item $\boldsymbol{a = 1, h \ge 2.}$ Let $i_1$ be the unique point in $N(j) \cap I_1.$ Then, we must have that $d(j, i_1) \ge \delta_2-1.$ Letting $t = d(j, i_1)$, we have that $d(j, S) \le t$, but $\mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] \ge t - 2p \cdot \sum_{i \in \bar{I}} (1-c(j, i)).$ However, we know that $\sum_{i \in \bar{I}} (1-c(j, i)) \ge h-\sqrt{h(h-1)} \ge 2-\sqrt{2}$ by Lemma \ref{lem:geometric_median}, so the denominator is at least $t-(2-\sqrt{2}) \cdot 2p$. So, the ratio is at most $\frac{t}{t-2(2-\sqrt{2})p},$ which is maximized when $t$ is as small as possible, namely $t = \delta_2-1$. So, the ratio is at most \begin{equation} \label{eq:4.c'} \tag{4.c'} \frac{\delta_2-1}{(\delta_2-1)-2(2-\sqrt{2})p}. \end{equation} \item $\boldsymbol{a \ge 2, h = 1.}$ In this case, let $i_2$ be the unique point in $\bar{I}$, and let $t=d(j, i_2)$. Note that $d(j, i_2) \ge \delta_2-1$, so $1-d(j, i_2) \le 2-\delta_2$. In addition, if the distances from $j$ to the points in $N(j) \cap I_1$ are $r_1, \dots, r_a$, then $d(j, S) \le \frac{r_1+\cdots+r_a}{a}.$ If we let $r = \frac{r_1+\cdots+r_a}{a}$, then $\mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] = 1-a(1-r)-2p(1-t) \ge 1-a(1-r)-(2-\delta_2) \cdot 2p.$ So, the overall fraction is at most $\frac{r}{1-a(1-r)-(2-\delta_2) \cdot 2p}.$ It is clear that this function decreases as $r$ increases, so we want to set $r$ as small as possible. However, we know that $r \ge \sqrt{\frac{a-1}{a}}$ by Lemma \ref{lem:geometric_median}, so the overall fraction is at most $$\frac{\sqrt{\frac{a-1}{a}}}{\sqrt{a(a-1)}-(a-1)-(2-\delta_2) \cdot 2p} = \frac{1}{(a-\sqrt{a(a-1)})-(2-\delta_2) \cdot 2p \cdot \sqrt{\frac{a-1}{a}}}.$$ The denominator clearly decreases as $a \to \infty$, so the overall fraction is at most the limit of the above as $a \to \infty$, which is \begin{equation} \label{eq:4.d'} \tag{4.d'} \frac{1}{\frac{1}{2}-(2-\delta_2) \cdot 2p}. \end{equation} \item $\boldsymbol{a, h \ge 2.}$ In this case, let the distances from $j$ to the points in $N(j) \cap I_1$ be $r_1, \dots, r_a$, and let the distances from the points from $j$ to the points in $\bar{I}$ be $s_1, \dots, s_h$. Also, let $r = \frac{r_1+\cdots+r_a}{a},$ and let $s = \frac{s_1+\cdots+s_h}{h}.$ Then, we have that the numerator is at most $r$, and the denominator is at least $1-a \cdot (1-r) - 2p \cdot h \cdot (1-s)$. Next, note that by Lemma \ref{lem:geometric_median}, $s \ge \sqrt{\frac{h-1}{h}}$, so $h \cdot (1-s) \ge h \cdot \left(1-\sqrt{\frac{h-1}{h}}\right) \ge h-\sqrt{h-1} \ge 2-\sqrt{2}$. So, the fraction is at most $\frac{r}{1-a(1-r)-2p \cdot (2-\sqrt{2})}$. This is exactly the same as in subcase 4d), except there the denominator was $1-a(1-r)-(2-\delta_2) \cdot 2p,$ i.e., we just replaced $\delta_2$ with $\sqrt{2}$. So, the same calculations give us that we can bound the overall fraction by at most \begin{equation} \label{eq:4.e'} \tag{4.e'} \frac{1}{\frac{1}{2}-(2-\sqrt{2}) \cdot 2p}. \end{equation} \end{enumerate} \end{proof} Finally, we bound the actual LMP approximation constant, similar to Proposition \ref{prop:more_bash} for the $k$-means case. We have the following proposition, which will immediately follow from analyzing all subases carefully (see Lemma \ref{lem:more_bash_median}). \begin{proposition} \label{prop:more_bash_2} For $p = 0.068,$ $\rho(p) \le 2.395$. Hence, we can obtain a $2.395$-LMP approximation. \end{proposition} \subsection{Improved $k$-median approximation} In this section, we explain how our LMP approximation for $k$-median implies an improved polynomial time $k$-median approximation for any fixed $k$. We set $p_1 = 0.068$ and $\delta_1 = \sqrt{2}, \delta_2 = 1.395$, and $\delta_3 = 2-\sqrt{2}$. In this case, we have that $\rho(\delta_1) \le 2.395$ by Proposition \ref{prop:more_bash_2}. Next, we have that all of the results in Subsections \ref{subsec:k_means_alg_prelim} and \ref{subsec:k_means_analysis} hold in the $k$-median context, with two changes. The first, more obvious, change is that Lemma \ref{lem:cost_j_upper_bound} (and all subsequent results in Section \ref{subsec:k_means_analysis}) needs to use the function $\rho$ associated with $k$-median as opposed to the function associated with $k$-means. The second change is that Lemma \ref{lem:RHS_positive_1/2} no longer holds for $p \le 0.5$, but still holds for $p \le p_0$ for some fixed choice $p_0$. Indeed, for Cases 1, 2, and 3 (i.e., when $a = 0$), we have that $\mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] \ge 0$ for any $p \le 0.5$, since $I_1 = \emptyset$, and $\sum_{i \in N(j) \cap I_2} (\alpha_j - c(j, i)) \le (b-\sqrt{b(b-1)}) \cdot \alpha_j \le \alpha_j$ if $|N(j) \cap I_2| = b$, and likewise $\sum_{i \in N(j) \cap I_3} (\alpha_j - c(j, i)) \le (c-\sqrt{c(c-1)}) \cdot \alpha_j \le \alpha_j$ if $|N(j) \cap I_3| = c$. So, $\mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] \ge (1-2p) \cdot \alpha_j \ge 0$ for $p \le 0.5$. For case $4$ of $k$-median, we verify that $\mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] \ge 0$ after conditioning on $\bar{I}$. Indeed, if $\bar{I} = 0$ (i.e., subcase 4.a), then this just equals $\alpha_j-\sum_{i \in N(j) \cap I_1} (\alpha_j-c(j, i)) \ge \alpha_j \cdot (\sqrt{a(a-1)}-(a-1)) \ge 0$. In the remaining subcases, the value $\mathbb E\left[\alpha_j-\sum_{i \in N(j) \cap S} (\alpha_j-c(j, i))\right] \ge 0$ is always nonnegative as long as the denominator of our final fractions are also nonnegative. So, we just need that $1-2p \ge 0$, $(\delta_2-1)-2(2-\sqrt{2})p \ge 0$, $\frac{1}{2}-(2-\delta_2) \cdot 2p \ge 0$, and $\frac{1}{2}-(2-\sqrt{2}) \cdot 2p \ge 0$. These are all true as long as $p \le \frac{\delta_2-1}{2(2-\sqrt{2})} \le 0.337$. Thus, we replace $0.5$ with $p_0 = 0.337$. Overall, the rest of Subsection \ref{subsec:k_means_analysis} goes through, except that our final bound will be \begin{equation} \label{eq:main_bound_median} \left(1+O(\frac{1}{C}+\varepsilon+\gamma)\right) \cdot \max_{r \ge 1} \min\left(\rho\left(\frac{p_1}{r}\right), \rho(p_1) \cdot \left(1+\frac{1}{4r \cdot \left(\frac{p_0 \cdot r}{p_1}-1\right)}\right)\right), \end{equation} where $p_1 = 0.068$ and $p_0 = 0.337$. The main replacement here is that we replaced $\frac{r}{2p_1} = \frac{0.5 \cdot r}{p_1}$ with $\frac{0.337 \cdot r}{p_1}.$ We can use this to obtain a $2.408$-approximation, improving over $1+\sqrt{2}$. We will not elaborate on this, however, as we will see that using the method in Subsection \ref{subsec:k_means_improved}, we can further improve this to $2.406$. \medskip We split the clients this time into $3$ groups. We let $\mathcal{D}_1$ be the set of clients $j \not\in \mathcal{D}_B$ corresponding to all subcases in Cases 1 and 2, $\mathcal{D}_2$ be the set of clients $j \not\in \mathcal{D}_B$ corresponding to all subcases in Case 3, and $\mathcal{D}_3$ be the set of clients corresponding to all subcases in Case 4, and all bad clients $j \in \mathcal{D}_B.$ For any client $j$, as in Subsection \ref{subsec:k_means_improved}, we define $A_j := \alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j-c(j, i))$ and $B_j := \sum_{i \in \bar{N}(j) \cap (I_2 \cup I_3)} (\alpha_j-c(j, i))$. We also define $Q_1, Q_2, Q_3, R_1, R_2, R_3$ similar to how we did for the $k$-means case. Similar to Lemma \ref{lem:RHS_positive_1/2_improved} in the $k$-means case, we have the following result for the $k$-median case. \begin{lemma} Let $\delta_1 = \sqrt{2}$, $\delta_2 = 1.395$, and $\delta_3 = 2-\sqrt{2}$. For any client $j \in \mathcal{D}_1$, $A_j \ge B_j$. For any client $j \in \mathcal{D}_2$, $A_j \ge \frac{1}{2} B_j$. Finally, for any client $j \in \mathcal{D}_3,$ $A_j \ge \frac{\delta_2-1}{2(2-\sqrt{2})} \cdot B_j.$ \end{lemma} \begin{proof} Recall that $a = |\bar{N}(j) \cap I_1|$, $b = |\bar{N}(j) \cap I_2|$, and $c = |\bar{N}(j) \cap I_3|$. In case $1$ or $2$, we have that $a = 0$ and $b+c \le 1$, so $\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} = \alpha_j$, and the sum of $\sum_{i \in \bar{N}(j) \cap (I_1 \cup I_2)} (\alpha_j - c(j, i))$ is merely over a single point, so is at most $\alpha_j$. Thus, if $j \in \mathcal{D}_1,$ $A_j \ge B_j$. (Note that this even holds for bad clients $j \in \mathcal{D}_B$.) In case $3$, we have that $a = 0$, so $\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} = \alpha_j$. In addition, all points $i, i'$ in $\bar{N}(j) \cap I_2$ are separated by at least $\sqrt{2} \cdot \min(\tau_i, \tau_{i'}) \ge \sqrt{2} \cdot \alpha_j$. Hence, by Lemma \ref{lem:geometric_median}, $\sum_{i \in \bar{N}(j) \cap I_2} (\alpha_j - c(j, i)) \le \alpha_j \cdot (b-\sqrt{b(b-1)}) \le \alpha_j$. Likewise, $\sum_{i \in \bar{N}(j) \cap I_3} (\alpha_j - c(j, i)) \le \alpha_j \cdot (c-\sqrt{c(c-1)}) \le \alpha_j$. So, $\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} = \alpha_j \ge \frac{1}{2} \sum_{i \in \bar{N}(j) \cap (I_2 \cup I_3)} (\alpha_j - c(j, i)).$ Thus, if $j \in \mathcal{D}_2,$ $A_j \ge B_j$. In case $4$, we have that $a \ge 1$. We claim that in this case, $\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j - c(j, i)) \ge \frac{\delta_2-1}{2-\sqrt{2}} \cdot \sum_{i \in \bar{N}(j) \cap I_2} (\alpha_j - c(j, i))$. This will follow from the fact that all points in $\bar{N}(j) \cap I_1$ are separated by at least $\sqrt{2} \cdot \alpha_j$, all points in $\bar{N}(j) \cap I_2$ are also separated by at least $\sqrt{2} \cdot \alpha_j$, and all points in $\bar{N}(j) \cap I_1$ are separated by at least $\delta_2 \cdot \alpha_j$ from all points in $\bar{N}(j) \cap I_2$. In fact, this immediately follows from the bounding of the denominators in subcases \ref{eq:4.a'}, \ref{eq:4.b'}, \ref{eq:4.c'}, \ref{eq:4.d'}, and \ref{eq:4.e'}, where we replace $h$ with $b$. Likewise, $\alpha_j - \sum_{i \in \bar{N}(j) \cap I_1} (\alpha_j - c(j, i)) \ge \frac{\delta_2-1}{2-\sqrt{2}} \cdot \sum_{i \in \bar{N}(j) \cap I_3} (\alpha_j - c(j, i))$. Overall, we have that for all clients in case $4$, $A_j \ge \frac{\delta_2-1}{2(2-\sqrt{2})} \cdot B_j$. Since $A_j \ge \frac{\delta_2-1}{2(2-\sqrt{2})} \cdot B_j$ in all cases, it also holds for the bad clients $j \in \mathcal{D}_B$ as well. \end{proof} As a direct corollary, we have that \begin{equation} \label{eq:S_i_bound_median} R_1 \le Q_1, \hspace{1cm} R_2 \le 2Q_2, \hspace{0.5cm} \text{and} \hspace{0.5cm} R_3 \le \frac{2(2-\sqrt{2})}{\delta_2-1} Q_3. \end{equation} Next, similar to Lemma \ref{lem:more_bash} in the $k$-means case, we have the following result. \begin{lemma} \label{lem:more_bash_median} Let $\delta_1 = \sqrt{2},$ $\delta_2 = 1.395$, and $\delta_3 = 2-\sqrt{2}$. Then, for all $p \in [0.01, 0.068],$ we have that $\rho^{(1)}(p) \le \max\left(1+\delta_2, \sqrt{3\left(X+Y\right)+2\sqrt{2\left(X+Y\right)^{2}-\delta_2^2 \cdot XY}}\right),$ where $X = p^2+p(1-p) \cdot 1.1$ and $Y = (1-p)^2 + \frac{p(1-p)}{1.1}.$ In addition, for all $p \in [0.01, 0.068]$, we have that $\rho^{(2)}(p) \le \frac{(1+\sqrt{2})-(3-\sqrt{2})\cdot(2p-2p^2)}{1-(2-\sqrt{2})\cdot(2p-2p^2)},$ and that $\rho^{(3)}(p) \le \frac{1}{\frac{1}{2}-2\cdot(2-d_2)\cdot p}$. \end{lemma} \begin{proof} To bound $\rho^{(1)}(p)$, we simply analyze all subcases in Case 1 and Case 2 and set $T = 1.1$. This is straightfoward to verify (see, for instance, our Desmos files on $k$-median in Appendix \ref{app:files}). To bound $\rho^{(2)}(p)$, we analyze all subcases in Case 3. Subcase \ref{eq:3.a'} and \ref{eq:3.b.i'} are straightfoward to verify. For subcase \ref{eq:3.b.ii'}, we have to verify for all choices of $c \ge 2$. For $c = 2$, we can verify manually. For $c \ge 3$, it is easy to see that the numerator of \ref{eq:3.b.ii'} is at most \begin{align*} \frac{1}{2}\left[(1+\sqrt{2}) \cdot \left((1-2p)+(1-2p)^c\right) + 1-(1-2p)^c\right] &= \frac{1}{2}\left[1 + (1+\sqrt{2}) \cdot (1-2p) + \sqrt{2} \cdot (1-2p)^c\right] \\ &\le \frac{1}{2}\left[1 + (1+\sqrt{2}) \cdot (1-2p) + \sqrt{2} \cdot (1-2p)^3\right], \end{align*} and the denominator is at least $1-2p$. So, the fraction is at most \[\frac{\frac{1}{2} \cdot \left[1 + (1+\sqrt{2}) \cdot (1-2p) + \sqrt{2} \cdot (1-2p)^3\right]}{1-2p},\] which is at most $\frac{(1+\sqrt{2})-(3-\sqrt{2})\cdot(2p-2p^{2})}{1-(2-\sqrt{2})\cdot(2p-2p^{2})}$ for all $p \in [0.01, 0.068]$. Finally, it is straightfoward to check that all $5$ subcases in Case $4$ are at most $\frac{1}{\frac{1}{2}-2\cdot(2-d_2)\cdot p}$ for all $p \in [0.1, 0.068]$. \end{proof} One can modify the remainder of the proof analogously to as in the $k$-means case in Section \ref{subsec:k_means_improved}. Hence, to show that we obtain an approximation $\rho + O(\varepsilon + \gamma + 1/C)$, it suffices to show that for all choices of $\theta \in [0, 1]$ and $r \ge 1,$ that if we let $\mathfrak{D}' = \mathfrak{D}+O(\gamma) \cdot \text{OPT}_k$, one cannot simultaneously satisfy \begin{align} \mathfrak{D}' &\ge \sum_{i = 1}^{3} \left(Q_i-\frac{p_1}{r} R_i\right) \label{eq:bound_3_kmedian}\\ \rho \cdot \mathfrak{D}' &< \frac{\theta}{r} \sum_{i = 1}^{3} \rho^{(i)}(p_1) \cdot (Q_i-p_1 \cdot R_i) + \left(1-\frac{\theta}{r}\right) \cdot \rho(p_1) \cdot \left(\mathfrak{D}' + p_1 \cdot \frac{\theta}{r} \sum_{i = 1}^{4} R_i\right) \label{eq:bound_4_kmedian} \\ \rho \cdot \mathfrak{D}' &< \sum_{i = 1}^{3} \rho^{(i)}\left(\frac{p_1}{r}\right) \cdot \left(Q_i-\frac{p_1}{r} \cdot R_i\right) \label{eq:bound_5_kmedian} \end{align} and \begin{equation} R_1 \le Q_1, \hspace{1cm} R_2 \le 2 Q_2, \hspace{1cm} R_3 \le \frac{2(2-\sqrt{2})}{\delta_2-1} Q_3. \label{eq:bound_6_kmedian} \end{equation} By numerical analysis of these linear constraints and based on the functions $\rho^{(i)}$, we obtain a $\boxed{2.406}$-approximation algorithm for Euclidean $k$-median clustering. We defer the details to Appendix \ref{app:k_means_numerical_analysis}. \section*{Acknowledgments} The authors thank Ashkan Norouzi-Fard for helpful discussions relating to modifying the previous results on roundable solutions. The authors also thank Fabrizio Grandoni, Piotr Indyk, Euiwoong Lee, and Chris Schwiegelshohn for helpful conversations. Finally, we would like to thank an anonymous reviewer for providing a useful suggestion in removing one of the cases for $k$-means. \section{Introduction} The $k$-means and $k$-median problems are among the oldest and most fundamental clustering problems. Originally motivated by operations research and statistics problems when they first appeared in the late 50s~\cite{zbMATH03129892,lloyd1957least,hakimi1964optimum} they are now at the heart of several unsupervised and semi-supervised machine learning models and data mining techniques and are thus a main part of the toolbox of modern data analysis techniques in a variety of fields. In addition to their practical relevance, these two problems exhibit strong ties with some classic optimization problems, such as set cover, and understanding their complexity has thus been a long standing problem which has inspired several breakthrough techniques. Given two sets $\mathcal{D}$, $\mathcal{F}$ of points in a metric space and an integer $k$, the goal of the $k$-median problem is to find a set $S$ of $k$ points in $\mathcal{F}$, called \emph{centers}, minimizing the sum of distances from each point in $\mathcal{D}$ to the closest point in $S$. The goal of the $k$-means problem is to minimize the sum of distances squared. The complexity of the $k$-median or $k$-means problems heavily depends on the underlying metric space. In general metric spaces, namely when the distances only need to obey the triangle inequality, the $k$-median and $k$-means problem are known to admit a 2.675-approximation~\cite{ByrkaPRST17} and a 9-approximation~\cite{ahmadian2017better}, respectively, and cannot be approximated better than $1+2/e \sim 1.736$ for $k$-median and $1+8/e \sim 3.943$ for $k$-means assuming P $\neq$ NP. We know that the upper and lower bounds are tight when we allow a running time of $f(k) n^{O(1)}$ (i.e.: in the fixed-parameter tractability setting) for arbitrary computable functions $f$~\cite{cohenaddad2019fpt}, suggesting that the lower bounds cannot be improved for the general case either. When we turn to slightly more structured metric spaces such as Euclidean metrics the picture changes drastically. While the problem remains NP-hard when the dimension $d = 2$ (and $k$ is large)~\cite{megiddo1984complexity} or $k=2$ (and $d$ is large)~\cite{dasgupta2008hardness}, both problems admit $(1+\varepsilon)$-approximation algorithms with running times $f(k,\varepsilon) n d$~\cite{KumarSS10}, with an exponential dependency in $k$, and $f(d, \varepsilon) n \log^{O(1)} n$~\cite{cohen2019near,Cohen-Addad18}, with a doubly exponential dependency in $d$ (the latter extends to doubling metrics), a prohibitive running time in practice. Arguably, the most practically important setting is when the input points lie in Euclidean space of large dimension and the number of clusters is non-constant, namely when both $k$ and $d$ are part of the input~\footnote{Note here that $d$ can always be assumed to be of $O(\log k/\varepsilon^{-2})$ using dimensionality reduction techniques~\cite{MakarychevMR19} (see also~\cite{BecchettiBC0S19} for a slightly worse bound)}. Unfortunately, the complexity of the problem in this regime is far from being understood. Recent results have proven new inapproximability results: respectively 1.17 and 1.07 for the Euclidean k-means and k-median problems assuming P $\neq$ NP and 1.73 and 1.27 assuming the Johnson Coverage hypothesis of~\cite{Cohen-AddadS19,Cohen-AddadLS22}. For the continuous case, the same series of papers show a hardness of 1.06 and 1.015 for Euclidean $k$-means and $k$-median respectively assuming P $\neq $ NP and 1.36 and 1.08 assuming the Johnson-Coverage hypothesis (see also~\cite{CKL21} for further related work on continuous $k$-median and $k$-means in other metric spaces). Interestingly, the above hardness results implies that there is no algorithmic benefit that could be gained from the $\ell_1$-metric: Assuming the Johnson Coverage hypothesis the hardness bounds for $k$-median and $k$-means are the same in the $\ell_1$-metric that in general metrics~\cite{Cohen-AddadLS22}. However, it seems plausible to leverage the structure of the $\ell_2$-metric to obtain approximation algorithms bypassing the lower bounds for the general metric or $\ell_1$ case (e.g.: obtaining an approximation ratio better than $1+2/e$ for $k$-median). In a breakthrough result, Ahmadian et al.~\cite{ahmadian2017better} were the first to exploit the structure of high-dimensional Euclidean metrics to obtain better bounds than the current best-known bounds for the general metric case. Concretely, they showed how to obtain a 6.3574-approximation for $k$-means (improving upon the 9-approximation of Kanungo et al.~\cite{KanungoMNPSW04}) and a $1+\sqrt{8/3}+\varepsilon \approx 2.633$-approximation for $k$-median (improving upon the 2.675-approximation for general metrics~\cite{ByrkaPRST17}). The bound for $k$-means was recently improved to a 6.1291-approximation (or more precisely, the unique real root to $4x^3-24x^2-3x-1 = 0$) by \cite{Grandoni21}, by tweaking the analysis of Ahmadian et al.~\cite{ahmadian2017better}, and no progress has been made for Euclidean $k$-median after \cite{ahmadian2017better}. This very active line of research mixes both new hardness of approximation results and approximation algorithms and aims at answering a very fundamental question: How much can we leverage the Euclidean geometry to obtain better approximation algorithms? And conversely, what do we learn about Euclidean geometry when studying basic computational problems? Our results aim at making progress toward answering the above questions. \subsection{Our Results} Our main result consists of better approximation algorithms for both $k$-median and $k$-means, with ratio $2.406$ for $k$-median and $5.912$ for $k$-means, improving the 2.633-approximation of Ahmadian et al.~\cite{ahmadian2017better} for $k$-median and $6.1291$-approximation of \cite{Grandoni21} for $k$-means. \begin{theorem} \label{thm:main:approxratio} For any $\varepsilon > 0$, there exists a polynomial-time algorithm that returns a solution to the Euclidean $k$-median problem whose cost is at most $2.406+\varepsilon$ times the optimum. For any $\varepsilon > 0$, there exists a polynomial-time algorithm that returns a solution to the Euclidean $k$-means problem whose cost is at most $5.912+\varepsilon$ times the optimum. \end{theorem} Our approximation ratio for $k$-median breaks the natural barrier of $1+\sqrt{2} > 2.41$ and our approximation ratio for $k$-means is the first below 6. The approximation bound of $1+\sqrt{2}$ for Euclidean $k$-median is indeed a natural barrier for the state-of-the-art approach of Ahmadian et al.~\cite{ahmadian2017better} that relies on using the primal-dual approach of Jain and Vazirani~\cite{jain2001lagrangian}. At a high level, the approximation bound of 3 for general metrics for the algorithm of Jain and Vazirani can be interpreted as an approximation bound of 1+2, where 1 is the optimum service cost and an additional cost of 2 times the optimum is added for input clients poorly served by the solution. Since general metrics are only required to satisfy the triangle inequality, the 2 naturally arises from bounding the distance from a client to its center in the solution output and an application of the triangle inequality to bound this distance. Therefore, one can hope to then obtain a substantial gain when working in Euclidean spaces: The triangle inequality is rarely tight (unless points are aligned) and this leads to the hope of replacing the 2 by $\sqrt{1+1}$ in the above the bound, making the approximation ratio of $1+\sqrt 2$ a natural target for $k$-median. In fact, this high-level discussion can be made slightly more formal: we show that the analysis of the result of Ahmadian et al.~\cite{ahmadian2017better} cannot be improved below $1+\sqrt{2}$ for $k$-median, exhibiting a limit of the state-of-the-art approaches. In this paper, we take one step further, similar to the result of Li and Svensson~\cite{LiS16} for the general metric case who improved for the first below the approximation ratio of 3, we show how to bypass $1+\sqrt 2$ for Euclidean $k$-median (and the bound of 6.129 for $k$-means). Furthermore, one of our main contributions is to obtain better Lagrangian Multiplier Preserving (LMP) approximations for the Lagrangian relaxations of both problems. To understand this, we need to give a little more background on previous work and how previous approximation algorithms were derived. A natural approach to the $k$-median and $k$-means problem is to (1) relax the constraint on the number of centers $k$ in the solution, (2) find an approximate solution for the relaxed problem, and (3) derive an approximate solution that satisfies the constraint on the number of centers. Roughly, an LMP approximate solution $S$ is a solution where we bound the ratio of the cost of $S$ to the optimum cost, but pay a penalty proportional to some $\lambda \ge 0$ for each center in $S$. Importantly, if $|S| = k$, an LMP $\rho$-approximation that outputs $S$ is a $\rho$-approximation for $k$-means (or $k$-median). We formally define an LMP approximation in Section \ref{sec:prelim}. LMP solutions have played a central role in obtaining better approximation algorithms for $k$-median in general metrics and more recently in high-dimensional Euclidean metrics. Thus obtaining better LMP solutions for the Lagrangian relaxation of $k$-median and $k$-means has been an important problem. A byproduct of our approach is a new 2.395-LMP for Euclidean $k$-median and $3+2\sqrt{2}$-LMP for Euclidean $k$-means. Our techniques may be of use in other clustering and combinatorial optimization problems over Euclidean space as well, such as Facility Location. In addition, by exploiting the geometric structure similarly, these techniques likely extend to $\ell_p$-metric spaces (for $p > 1$). \subsection{Related Work} \label{sec:related-work} The first $O(1)$-approximation for the $k$-median problem in general metrics is due to Charikar et al.~\cite{CharikarGTS02}. The $k$-median problem has then been a testbed for a variety of powerful approaches such as the primal-dual schema~\cite{jain2001lagrangian,CharikarG99}, greedy algorithms (and dual fitting)~\cite{JainMMSV03}, improved LP rounding~\cite{CharikarL12}, local-search~\cite{AryaGKMMP04,CohenAddadGHOS22}, and LMP-based-approximation~\cite{LiS16}. The current best approximation guarantee is 2.675~\cite{ByrkaPRST17} and the best hardness result is $(1+2/e)$~\cite{GuK99}. For $k$-means in general metrics, the current best approximation guarantee is 9~\cite{ahmadian2017better} and the current best hardness result is $(1+8/e)$ (which implicitly follows from~\cite{GuK99}, as noted in \cite{ahmadian2017better}). We have already covered in the introduction the history of algorithms for high-dimensional Euclidean $k$-median and $k$-means with running time polynomial in both $k$ and the dimension and that leverage the properties of the Euclidean metrics (\cite{KanungoMNPSW04,ahmadian2017better,Grandoni21}). In terms of lower bounds, the first to show that the high-dimensional $k$-median and $k$-means problems were APX-hard were Guruswami and Indyk~\cite{GI03}, and later Awasthi et al.~\cite{AwasthiCKS15} showed that the APX-hardness holds even if the centers can be placed arbitrarily in $\mathbb{R}^d$. The inapproximability bound was later slightly improved by Lee et al.~\cite{DBLP:journals/ipl/LeeSW17} until the recent best known bounds of~\cite{Cohen-AddadS19,Cohen-AddadLS22}. From a more practical point of view, Arthur and Vassilvitskii showed that the widely-used popular heuristic of Lloyd~\cite{lloyd1957least} can lead to solutions with arbitrarily bad approximation guarantees~\cite{ArV09}, but can be improved by a simple seeding strategy, called $k$-means++, so as to guarantee that the output is within an $O(\log k)$ factor of the optimum~\cite{ArV07}. For fixed $k$, there are several known approximation schemes, typically using small coresets \cite{BecchettiBC0S19,FL11,KumarSS10} There also exists a large body of bicriteria approximations (namely outputting a solution with $(1+c)k$ centers for some constant $c > 0$): see, e.g.,~\cite{BaV15,CharikarG05,CoM15,KPR00,MakarychevMSW16}. There has also been a long line or work on the metric facility location problem, culminating with the result of Li~\cite{Li13} who gave a 1.488-approximation algorithm, almost matching the lower bound of 1.463 of Guha and Khuller~\cite{GuK99}. Note that no better bound is known for high-dimensional Euclidean facility location. \subsection{Roadmap} In Section \ref{sec:prelim}, we describe some preliminary definitions. We also formally define the LMP approximation and introduce the LMP framework of Jain and Vazirani~\cite{jain2001lagrangian} and Ahmadian et al.~\cite{ahmadian2017better}. In Section \ref{sec:overview}, we provide an overview of the new technical results we developed to obtain the improved bounds. In Section \ref{sec:lmp_k_means}, we obtain a $3+2\sqrt{2} \approx 5.828$ LMP approximation for the Euclidean $k$-means problem. In Section \ref{sec:poly_time_alg}, extend our LMP approximation to a $5.912$-approximation for standard Euclidean $k$-means. Finally, in Section \ref{sec:k_median}, we obtain a $2.395$ LMP approximation for Euclidean $k$-median that can be extended to a $2.406$-approximation for standard Euclidean $k$-median. In Appendix \ref{app:limit}, we briefly show that the result of \cite{ahmadian2017better} cannot be extended beyond $1+\sqrt{2}$ for Euclidean $k$-median: this demonstrates the need of our new techniques for breaking this barrier. \subsection{From $k+C$ to $k$ centers} \subsection{Additional preliminaries} \label{subsec:more_prelims} For our approximation guarantees, we require two additional preliminaries. The first is to show a rough equivalence between solving $k$-means (resp., $k$-median) clustering and solving $k$-means (resp., $k$-median) clustering if allowed $O(1)$ additional clusters. The second is to define the notion of negative-submodularity and its application for $k$-means and $k$-median. First, we show that for any constant $C$ and parameter $\varepsilon$, if there exists a polynomial-time $\alpha$-approximation algorithm for $k$-means or $k$-median in any metric space that uses $k+C$ centers, then for any constant $\varepsilon>0$, there exists a polynomial-time $\alpha(1+\varepsilon)$-approximation algorithm that opens exactly $k$ centers. More formally, the statement we prove is the following. Note that a similar statement was proven in~\cite{LiS16}. \begin{lemma} \label{lem:center-reduction} Let $C,\alpha$ be some absolute constants. Let $\mathcal{A}$ be an $\alpha$-approximation algorithm with running time $T$ for $k$-median (resp. $k$-means) that open $k+C$ centers. Then, for any $1/3 > \varepsilon>0$, there exists an $\alpha(1+\varepsilon)$-approximation for $k$-median (resp. $k$-means) with running time $O(T+n^{\text{poly}(C/\varepsilon)})$. \end{lemma} \begin{proof} We give the proof of the $k$-median problem, the proof for the $k$-means problem is identical, up to adjustment of the constants. To proceed, we need the following notion (due to~\cite{ORSS12}): A $k$-median instance is said to be \emph{$(1+\alpha)$-ORSS-separable} if the ratio of the cost of the optimum solution with $k-1$ centers to the cost of the optimum solution with $k$ centers is at least $1+\alpha$. We can now present our algorithm; For any $k$, the algorithm is as follows. Compute an $\alpha$-approximate solution $S_C$ (with $k+C-C=k$ centers) to the $(k-C)$-median instance using $\mathcal{A}$. Then, for any $i=1,\ldots,C$, compute a solution $S_{i-1}$ with $k-i$ centers using the algorithms for $(1+\nicefrac{\varepsilon}{C})^{\varepsilon/10}$-ORSS-separable instances of~\cite{awasthi2010stability,Cohen-AddadS17} to obtain a $(1+\varepsilon/3)$-approximate solution in time $n^{\text{poly}(C/\varepsilon)}$. Output the solution $S^*$ of $S_0,\ldots, S_C$ with minimum $k$-median cost. We now turn to the analysis of the above algorithm. The running time follows immediately from its definition and the results of~\cite{awasthi2010stability,Cohen-AddadS17}. Let's then consider the approximation guarantee of the solution produced. For $0 \le i \le C$, let $\text{OPT}_i$ be the solution to $(k-i)$-median, i.e.: the $k$-median problem with $k-i$ centers. Our goal is thus to show that the solution $S^*$ output by the above algorithm is an $\alpha(1+\varepsilon)$-approximate solution to the $\text{OPT}_0$. If the cost of $\text{OPT}_C$ is within a $(1+\varepsilon)$-factor of the cost of $\text{OPT}_0$, then the cost of the solution output by the algorithm is no larger than the cost of solution $S_C$ whose total cost is thus at most $\alpha \text{cost}(\text{OPT}_C) \le \alpha(1+\varepsilon)\text{cost}(\text{OPT}_0)$, as desired. Otherwise, since $\varepsilon < 1/3$ we have that there exists a $i>0$ such that $\text{cost}(\text{OPT}_i) \ge (1+\nicefrac{\varepsilon}{C})^{\varepsilon/10} \text{cost}(\text{OPT}_{i-1})$. Let $i^*$ be the smallest $i$ such that the above holds. In which case, we have both that $\text{cost}(\text{OPT}_{i^*-1}) \le (1+\varepsilon/3)\text{cost}(\text{OPT}_{0})$ and that the $(k-(i^* - 1))$-median instance is $(1+\nicefrac{\varepsilon}{C})^{\varepsilon/10}$-ORSS-separable. Therefore, by the results of~\cite{awasthi2010stability,Cohen-AddadS17}, the cost of the solution output by our algorithm is no larger than $(1+\varepsilon/3) \text{cost}(\text{OPT}_{i^* - 1})$ and so at most $(1+\varepsilon/3)^2 \text{cost}(\text{OPT}_{0}) \le (1+\varepsilon)\text{cost}(\text{OPT}_0)$ by our choice of $\varepsilon$, hence the lemma. \end{proof} Next, we describe the definition of submodular and negative-submodular set functions. \begin{defn} Let $\Omega$ be a finite set, and let $f$ be a function from the set of subsets of $\Omega$, $\mathcal{P}(\Omega)$, to the real numbers $\mathbb R$. Then, $f$ is \emph{submodular} over $\Omega$ if for any $X \subset Y \subsetneq \Omega$ and any $x \in \Omega \backslash Y$, we have that $f(X \cup \{x\}) - f(X) \ge f(Y \cup \{x\}) - f(Y)$. Likewise, $f$ is \emph{negative-submodular} over $\Omega$ if $-f$ is a submodular function: equivalently, if for any $X \subset Y \subsetneq \Omega$ and any $x \in \Omega \backslash Y$, we have that $f(X \cup \{x\}) - f(X) \le f(Y \cup \{x\}) - f(Y)$. \end{defn} The following claim, proven in \cite{cohenaddad2019fpt}, proves that the $k$-means and $k$-median objective functions are both negative-submodular functions. \begin{proposition} \cite[Claim 10]{cohenaddad2019fpt} \label{prop:submodular_1} Fix $\mathcal{F}$ and $\mathcal{D}$, and let $f: \mathcal{P}(\mathcal{F}) \to \mathbb R$ be the function sending each subset $S \subset \mathcal{F}$ to $\text{cost}(\mathcal{D}, S)$. Then, $f$ is a negative-submodular function over $\mathcal{F}$, either if the cost is the $k$-median cost or if the cost is the $k$-means cost. \end{proposition} Given Proposition \ref{prop:submodular_1}, we can use standard properties of submodular functions to infer the following claims. \begin{proposition} \label{prop:submodular_2} Let $S_0 \subset S_1$ be sets of facilities, where $S_0$ has size $k_0$ and $S_1$ has size $k_0+k_1$. Then, for any $0 \le p \le 1$, if $S: S_0 \subset S \subset S_1$ is a set created including all of $S_0$ and then independently including each element in $S_1 \backslash S_0$ with probability $p$, then $\mathbb E[\text{cost}(\mathcal{D}, S)] \le p \cdot \text{cost}(\mathcal{D}, S_1) + (1-p) \cdot \text{cost}(\mathcal{D}, S_0)$. \end{proposition} \begin{proposition} \label{prop:submodular_3} Let $S_0 \subset S_1$ be sets of facilities, where $S_0$ has size $k_0$ and $S_1$ has size $k_0+k_1$. Then, if $S: S_0 \subset S \subset S_1$ is a set created by randomly adding exactly $k_2$ items from $S_1 \backslash S_0$ to $S_0$, for some fixed $0 \le k_2 \le k_1$, then we have $\mathbb E[\text{cost}(\mathcal{D}, S)] \le \frac{k_2}{k_1} \cdot \text{cost}(\mathcal{D}, S_1) + (1-\frac{k_2}{k_1}) \cdot \text{cost}(\mathcal{D}, S_0)$. \end{proposition}
{'timestamp': '2022-04-13T02:09:17', 'yymm': '2204', 'arxiv_id': '2204.04828', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04828'}
arxiv
\section{Introduction} Human-Object Interaction (HOI) detection is a holistic visual recognition task that includes detecting individual objects as \texttt{<human, object>}, while properly classifying the type of \texttt{<interaction>}. Previous HOI detectors~\cite{gkioxari2018detecting,wang2020learning,li2020pastanet,ulutan2020vsgnet} were mainly built on object detection models. They commonly extend CNN-based object detectors~\cite{ren2016faster,lin2017feature,newell2016stacked} with an additional head for interaction classification, \eg, humans and objects are detected first, and their interaction is associated subsequently. To alleviate the high computation cost of such two-stage HOI detection methods, one-stage models~\cite{wang2020learning,Kim2020UnionDet,liao2019ppdm} have been proposed for faster detection. These models perform interaction prediction and object detection in parallel. They compensate for their lower performance with auxiliary predictions for the HOI subsets, \ie, auxiliary predictions for subset \texttt{<human, interaction>} or \texttt{<object, interaction>} may help HOI prediction through post-processing. However, these works demand different network architectures for each auxiliary prediction, due to strict disciplines for each network's input. Hence, to introduce flexibility, transformer-based architectures~\cite{kim2021hotr, tamura2021qpic, chen2021reformulating, touvron2021training} have recently been adopted for HOI detection. They reformulate the HOI detection problem as a direct set prediction building on DETR~\cite{carion2020end}. \input{Figure_caption/figure1} Motivated by various inference paths in HOI detectors, we propose a simple yet effective method to train HOI transformers. We augment the decoding paths with respect to the possible prediction sequences of HOI triplets. Then, with the cascade structure of transformers, an input query is sequentially decoded into auxiliary sub-task outputs and the final output. The stage of each augmented paths stage shares a decoder, in a multi-task learning fashion. We further improve our method to leverage the augmented decoding paths by enforcing the outputs from the various paths to be consistent. Accordingly, we propose \textbf{Cross-Path Consistency (CPC) Learning}, which aims to predict HOI triplets regardless of inference sequences. Similar to cross-\textit{task} consistency~\cite{zamir2020robust}, cross-\textit{path} consistency retains \textit{inference path invariance}. However, cross-path consistency learning does not require additional pre-trained networks. In contrast to cross-task consistency, which demands an auxiliary network to train the main task $\mathcal{X} \rightarrow \mathcal{Y}$ (Figure~\ref{fig:consistency variants}-(b)), cross-path consistency defines an auxiliary domain $\mathcal{Y}_s$ in between $\mathcal{X}$ and $\mathcal{Y}$ (Figure~\ref{fig:consistency variants}-(c)). In other words, the main task $\mathcal{X} \rightarrow \mathcal{Y}$ (\ie, Image$\rightarrow$HOI) is divided into subtasks $\mathcal{X} \rightarrow \mathcal{Y}_s$ and $\mathcal{Y}_s \rightarrow \mathcal{Y}$ (\eg, Image$\rightarrow$HO$\rightarrow$I). The main task function $f_{\mathcal{X}\mathcal{Y}}$ is then trained by enforcing its output and the composition of sub-task predictions to be consistent. Moreover, cross-path consistency learning is temporarily adopted for training only. Our training strategy can be generalized to any transformer based architecture, and can be applied in an end-to-end method. Extensive experiments show that HOI transformers trained with CPC learning strategy achieves substantial improvements in two popular HOI detection benchmarks: V-COCO and HICO-DET. The contribution of this work can be \jhprev{summarized as the followings}: \begin{itemize} \jhprev{ \item We propose \textbf{Cross-Path Consistency} (CPC) learning, which is a novel end-to-end learning strategy to improve transformers for HOI detection leveraging various inference paths. In this learning scheme, we use \textbf{Decoding-Path Augmentation} to generate various inference paths which are compositions of subtasks with a shared decoder for effective training. } \item Our training scheme achieves substantial improvements on V-COCO and HICO-DET without increasing \textit{model capacity} and \textit{inference time}. \end{itemize} \subsection{Transformers in Computer Vision} \label{section2.2} Transformer has become the state-of-the-art method in many computer vision tasks. In image classification, ~\cite{dosovitskiy2020image} has shown competitive performance on ImageNet without any convolution layers. DeiT~\cite{touvron2021training} applied knowledge distillation to data-efficiently train the vision transformer. To extract multi-scale image features, Swin Transformer~\cite{Liu_2021_ICCV} proposed shifted window based self-attention modules that effectively aggregate small patches to increase the receptive field. In the object detection task, DETR~\cite{carion2020end} has proposed an end-to-end framework eliminating the need for hand-designed components. DETR's bipartite matching loss between the predicted set and the ground truth labels enables direct set prediction at inference. Recently, DETR's late convergence problem has been tackled in~\cite{zhu2020deformable,meng2021conditional,Gao_2021_ICCV}. Inspired by DETR, transformer-based HOI (Human-Object Interaction) detectors~\cite{kim2021hotr,tamura2021qpic,chen2021reformulating,zou2021end,dong2021visual} have been recently proposed. HOI transformer models have two types of structure, one decoder model and the two decoder model. The one-decoder model which follows the structure of DETR~\cite{carion2020end} predicts triplets from the output of a single decoder. QPIC~\cite{tamura2021qpic} and HoiT~\cite{zou2021end} are one-decoder models that output \texttt{<human, object, interaction>} triplets directly with multiple interaction detection heads. Two-decoder models use two transformer decoders to output distinctive targets. For instance, HOTR~\cite{kim2021hotr} and AS-NET~\cite{chen2021reformulating} are composed of an instance decoder that outputs object and an interaction decoder that outputs interaction. In contrast to previous works that are trained with a single inference path, our model learns with the augmented decoding paths. Also, our framework can be applied to any transformer-based model. More explanation of HOI transformers are in Section~\ref{section3.1}. \subsection{Consistency Learning in Vision} \label{section2.3} Consistency constraints applied to many computer vision topics have been extensively studied. In semi-supervised learning, consistency regularization is widely used to train the model to be invariant to input noise. Label consistency methods~\cite{laine2016temporal,xie2020unsupervised,miyato2018virtual,tarvainen2017mean} augment or perturb an input image and apply consistency loss between model predictions. CDS~\cite{NEURIPS2019_d0f4dae8} explored object detection in a semi-supervised setting with classification and localization consistency regularization. Also, consistency regularization in cyclic form is commonly used in generative models~\cite{zhu2017unpaired}, image matching~\cite{7298723,zhou2016learning}, temporal correspondence~\cite{dwibedi2019temporal}, and in many other domains. \paragraph{Comparison with Consistency Learning} Our consistency training scheme is relevant to cross-task consistency learning~\cite{zamir2020robust}. Cross-task consistency learning is based on inference-path invariance, where the predictions should be consistent regardless of the inference paths. As shown in Figure~\ref{fig:consistency variants} (b), cross-\textit{task} consistency learning uses an auxiliary task $\mathcal{Y}\rightarrow \mathcal{Y}_a$ to train the main task function $f_{\mathcal{X}\mathcal{Y}}$, \ie, given $x$ from the query domain, and $y$ from target domain $\mathcal{Y}$, predictions of $f_{\mathcal{Y}\mathcal{Y}_a}\circ f_{\mathcal{X}\mathcal{Y}}(x)$ and $f_{\mathcal{Y}\mathcal{Y}_a}(y)$ are expected to be consistent. Different from cross-\textit{task} consistency, our cross-\textit{path} consistency learning (Figure~\ref{fig:consistency variants} (c)) trains the main task function $f_{\mathcal{X}\mathcal{Y}}$ by enforcing the prediction of target domain $\mathcal{Y}$ of $f_{\mathcal{X}\mathcal{Y}}$ and $f_{\mathcal{Y}_s\mathcal{Y}}\circ f_{\mathcal{X}\mathcal{Y}_s}$, where auxiliary domain $\mathcal{Y}_s$ is decomposed from the target domain $\mathcal{Y}$, to be consistent. Also, while cross-\textit{task} consistency learning requires the mapping function $f_{\mathcal{Y}\mathcal{Y}_a}$ to be pretrained to avoid suboptimal training with the noisy estimator, cross-\textit{path} consistency learning does not demand any task-specific pre-trained networks since the auxiliary domain $\mathcal{Y}_s$ is part of the target domain $\mathcal{Y}$. Details for our framework is described in section~\ref{section3.2}. \section{Related Works} \subsection{Human Object Interaction Detection} \label{section2.1} Human-Object Interaction (HOI) detection has been proposed in ~\cite{gupta2015visual}. Later, human-object detectors have been improved using human or instance appearance and their spatial relationship~\cite{gkioxari2018detecting, kolesnikov2018detecting, gao2018ican}. On the other hand, graph-based approaches~\cite{qi2018learning, ulutan2020vsgnet, Gao2020DRG, Wang2020Hetero} have been proposed to clarify the action between the \texttt{<human, object>} pair. HOI detection models based on only visual cues often suffer from the lack of contextual information. Thus, recent works utilize external knowledge to improve the quality of HOI detection. Human pose information extracted from external models~\cite{cao2017realtime,chen2018cascaded,he2017mask, li2019crowdpose} or linguistic priors and knowledge graph models show meaningful improvement in performance~\cite{zhou2019relation, Liu2020FCMNet, peyre2018detecting,xu2019learning,gupta2017aligned,gkanatsios2019deeply,li2020pastanet, Xubin2020PDNet, Liu2020ConsNet}. Since the majority of the previous works are based on two-stage methods with slower inference time, attempts for faster HOI detection by introducing simple end-to-end multi-layer perceptrons~\cite{gupta2019no}, or directly detecting interaction points~\cite{wang2020learning,liao2019ppdm}, or union regions~\cite{Kim2020UnionDet, Hou2020VCL, yonglu2020idn} have been suggested. \section{Method} In this section, we \hwan{describe our novel end-to-end training strategy for transformers with \textbf{cross-path consistency} in Human-Object Interaction Detection.} The training strategy includes 1) augmenting the decoding path and 2) consistency regularization between predictions of multiple paths. \hwan{In Section~\ref{section3.1}, we explain two general types of transformer in Human-Object Interaction detection. Then, we describe how our two training strategies, decoding-path augmentation and cross-path consistency learning, in Section~\ref{section3.2} and Section~\ref{section3.3}.} \subsection{Revisit Transformer in HOI detection} \label{section3.1} \hkc{ HOI transformers are commonly extended upon DETR~\cite{carion2020end}, which is composed of a CNN backbone followed by the encoder-decoder architecture of Transformer~\cite{Vaswani17transformer}. The CNN backbone first extracts \textit{locally} aggregated feature from input image $x \in \mathbb R^{H \times W \times 3}$. Then, the extracted feature map $X\in \mathbb{R}^{H'\times W'\times D}$ are passed into the encoder to \textit{globally} aggregate features via the self-attention mechanism. } \jhp{In a decoding stage, learnable query embeddings $p\in \mathbb{R}^{N\times D}$ are fed into 6-layer decoder and updated into $e\in\mathbb{R}^{N\times D}$ by interacting with encoded feature map $X$ through cross-attention. Basically at the end of each layer, feed-forward networks for each HOI triplet element is attached to localize human and object regression, and predict interaction classes. At the training phase, Hungarian algorithm is used to match between ground truth labels and predictions from the decoder, and calculate the loss between them. The predictions unmatched with ground truth labels are considered as no object and interactions. In the localizing part, simple extention from DETR~\cite{tamura2021qpic,zou2021end} is to directly regress the box coordinates of humans and objects. This brings out the problem that human or object can be redundantly predicted with multiple query embeddings since the ground truth set is composed of HOI triplets. Other variants~\cite{kim2021hotr,chen2021reformulating} overcome this issue to construct extra branch for instance detection and use matching scheme for binding the relevant instances from instance decoder outputs in interaction decoder outputs. } \paragraph{Single Decoder HOI Transformer.} \hwan{The single-decoder HOI transformers~\cite{tamura2021qpic,zou2021end} directly infer HOI triplets in the decoding stage. They extend DETR with an additional readout function for action classification in the decoder head. The decoding stage of single decoder models can be written as \begin{equation} \label{eq:single_dec} \begin{split} e &= {\text{Dec}}(p,\ X), \end{split} \end{equation} where $e$ denotes the output embeddings, and $p$ denotes the learnable position encoding for the query input. Then, the output embeddings are passed into feed-forward networks (FFN) for bounding box regression and action classification, as shown below. \begin{equation} \label{eq:single_ffn} \begin{split} \hat{b}_h &= \text{FFN}_{h}\left(e\right), \\ \hat{b}_o &= \text{FFN}_{o}\left(e\right), \\ \hat{c}_{act} &= \text{FFN}_{act}\left(e\right), \end{split} \end{equation} where $\hat{b}_h,\hat{b}_o$ denotes predicted bounding boxes for the detected human or object, and $\hat{c}_{act}$ denotes the corresponding action logit. The overall loss consists of binary cross entropy for multi-label action classification, softmax cross entropy for object classification, and $L_1$ and GIoU loss for regression. \paragraph{Two Decoder HOI Transformer.} \hwan{ Despite the simple extension of single decoder HOI transformers, its architecture poses a problem that same human or objects can be redundantly inferred from different queries. Therefore, two-decoder HOI transformers~\cite{kim2021hotr,chen2021reformulating} include two different parallel decoders: \jhp{ one for instance detection and the other for interaction detection.} \jhp{The instance decoder, which is only responsible for object detection, is frozen during training so that the quality of object detection does not affect HOI detection. The interaction decoder infers interactions and creates semantic information for human and object, so that each interaction is matched to the relevant human and object derived from the instance decoder.} The output embeddings can be obtained by \begin{equation} \label{eq:two_dec} \begin{split} e_{\text{ins}} &= {\text{Dec}_\text{ins}}(p,\ X), \\ e_{\text{int}} &= {\text{Dec}_\text{int}}(p,\ X), \end{split} \end{equation} where $e_{\text{ins}}$, $e_{\text{int}}$ denotes output embeddings of instance decoder and interaction decoder respectively. \jhp{For the final predictions of HOI triplets, similarity matching (dot-product for HOTR~\cite{kim2021hotr} and $L_1$ distance for AS-NET ~\cite{chen2021reformulating}) is used between projected interaction embeddings and instance embeddings to predict \texttt{human} and \texttt{object}, and multi-label classification is done for \texttt{interaction}.} \jhp{ Final predictions can be written as \begin{equation} \label{eq:two_ffn} \begin{split} \hat{b}_h &= \text{sim}\big(\text{FFN}_{h}\left(e_{\text{ins}}\right),\text{FFN}\left(e_{\text{int}}\right)\big), \\ \hat{b}_o &= \text{sim}\big(\text{FFN}_{o}\left(e_{\text{ins}}\right),\text{FFN}\left(e_{\text{int}}\right)\big), \\ \hat{c}_{act} &= \text{FFN}_{act}\left(e_{\text{int}}\right) \end{split} \end{equation} $\text{FFN}_h$ and $\text{FFN}_o$ are the projection networks that keep the dimensionality of the output queries consistent. Since two decoder architectures freeze parameters related to instance detection, no regression loss is used. HOTR and AS-NET use cross-entropy and $L_1$ distance for instance prediction ($\hat{b}_h,\hat{b}_o$) respectively, and for multi-label action classification, binary cross entropy is used.} } \subsection{Decoding-Path Augmentation} \label{section3.2} \input{Figure_caption/fig1_extension} \input{Figure_caption/fig2} We observe that HOI detection can be achieved by various sequences of predictions. For instance, CNN-based HOI detection models~\cite{gkioxari2018detecting, chao2018learning, Gao2020DRG, gupta2019no} first detect instances (human and object) and then predict interactions between the instances, \ie, $x \rightarrow \text{HO} \rightarrow \text{I}$, where $x$ is an input image and H, O, I are predictions for human, object, interaction, respectively. On the other hand, the HOI Transformers by \cite{kim2021hotr,tamura2021qpic, chen2021reformulating, zou2021end} directly predict HOI triplets, \ie, $x \rightarrow \text{HOI}$. Inspired by Cross-Task Consistency \cite{zhang2018deep} and this observation, we propose \textbf{decoding-path augmentation} to generate various decoding paths (or prediction paths) and impose consistency regularization. Decoding-path augmentation for Transformers in HOI detection can be easily achieved by partially decoded HOI predictions. Furthermore, sharing decoders across paths is beneficial in terms of knowledge sharing. In our experiments, we consider four decoding paths as follows: \begin{equation} \begin{split} \label{eq:all_path} &\;\mathcal{P}_1 = x \rightarrow \text{HOI} \\ &\begin{rcases*} \mathcal{P}_2 =x \rightarrow \text{HO} \rightarrow \text{I} \\ \mathcal{P}_3 = x\rightarrow \text{HI} \ \rightarrow \text{O} \\ \mathcal{P}_4 =x \rightarrow \text{OI} \ \rightarrow \text{H} \end{rcases*} Augmented. \end{split} \end{equation} Each decoding stage of path $\mathcal{P}_k$ can be written as: \begin{equation} \label{eq:path_decoding} \begin{split} e_{{k,1}} &= f(e_{k,0}+ q_{k,1}, \ X), \\ e_{{k,2}} &= f(e_{k,1} + q_{k,2}, \ X), \end{split} \end{equation} where ${q}_{k,j}, \ e_{k,j}$ denote learnable query and output embeddings on $k^{\text{th}}$ path at $j^{\text{th}}$ decoding stage. The decoder $f$ is shared across all paths and stages. The $e_{k,0}$ above is dummy output embeddings set to zeros since there is no 0-th stage, see Figure \ref{fig:pipeline}. Each decoding stage and path use a separate readout function $\text{FFN}$ to translate the output embeddings into HOI instance predictions. For example, on $\mathcal{P}_2: x \rightarrow \text{HO} \rightarrow \text{I}$, at stage 1 $e_{2,1}$ is read out by $\text{FFN}^{\mathcal{P}_2}_{h}$ and $\text{FFN}_{o}^{\mathcal{P}_2}$ to predict bounding boxes of human and object respectively. Prediction for HOI element \jhprev{$m \in \{h,o,act \}$} in each $k^{th}$ path at $j^{th}$ decoding stage can be written as $\hat{y}_{k}^m=\text{FFN}^{\mathcal{P}_k}_m\left(e_{k,j}\right)$. \subsection{Cross-Path Consistency Learning \label{section3.3} \hjk{We now present our Cross-Path Consistency Learning framework (CPC) that imposes consistency regularization between predictions from different decoding paths as shown in Figure~\ref{fig:consistency for HOI}. Learning with CPC leads better generalization without any additional data or labels. \paragraph{Cross-Path Consistency.} We explain our consistency learning scheme with an exemplary case of main path $\mathcal{P}_1$ and augmented path $\mathcal{P}_2$ given as \begin{equation} \label{eq:path} \begin{split} &\mathcal{P}_1 : x \rightarrow \text{HOI} \\ &\mathcal{P}_2 : x \rightarrow \text{HO} \rightarrow \text{I}. \end{split} \end{equation} Here, the main path $\mathcal{P}_1$ is the HOI transformers' original inference path. In path $\mathcal{P}_2$, human and object detection logits $\hat{y}^h_2$ and $\hat{y}^o_2$ are obtained reading out $e_{2,1}$, which is the output embeddings on path 2 at stage 1. Then, the interaction logit $\hat{y}^{act}_2$ is obtained after another subsequent decoder pass defined as $f_{2,2}$. The corresponding inference scheme of $\mathcal{P}_2$ can be written in more formal terms: \begin{equation} \begin{split} \label{eq:out2} \hat{y}_2^{h}&=\text{FFN}_h^{\mathcal{P}_2}(f_{2,1}(X)) \\ \hat{y}_2^{o}&=\text{FFN}_o^{\mathcal{P}_2}(f_{2,1}(X)) \\ \hat{y}_2^{act}&=\text{FFN}_{act}^{\mathcal{P}_2}(f_{2,2}\circ f_{2,1}(X)) \\ \end{split} \end{equation} In ~\eqref{eq:out2}, input arrays for $f$ other than feature map $X$ were omitted for simplicity. With the predictions, we impose regularization to make the outputs from path $\mathcal{P}_1$ and path $\mathcal{P}_2$ consistent. Note that HOI detections from $\mathcal{P}_2$ consist of both final and intermediate decoder outputs. To this end, we define the loss function $\mathcal{L}_{\mathcal{P}_{1}\mathcal{P}_2}$ by aggregating losses from multiple augmented paths to enforce consistency. The loss function is given as: \begin{equation} \begin{split} \mathcal{L}_{\mathcal{P}_{1}\mathcal{P}_2}=\lambda_h\cdot\mathcal{L}_{h}\big(\hat{y}_1^{h},\hat{y}_2^{h}\big) +\lambda_o\cdot \mathcal{L}_{o}\big(\hat{y}_1^{o},\hat{y}_2^{o}\big) \\ +\lambda_{act}\cdot\mathcal{L}_{act}\big(\hat{y}_1^{act},\hat{y}_2^{act}\big), \end{split} \end{equation} where $\hat{y}^h_1$, $\hat{y}^o_1$ and $\hat{y}^{act}_1$ are the output from the main path $\mathcal{P}_1$ and $\lambda$ are the loss weights. In our experiments, softmax-type outputs use Jensen-Shannon divergence (JSD) for consistency loss to give loss to each path symmetrically, while outputs followed by sigmoid, \eg, box regression, multi-label action classes, take the Mean-Squared Error loss. More details on type-specific loss functions are in the supplement. In the case of other path pairs, loss is computed in the same manner. The final loss should thus incorporate all possible pairs. Then, the cross-path consistency (CPC) loss can be written as: \begin{equation} \label{eq:cpcloss} \mathcal{L}_\textbf{CPC}=\frac{1}{S}\sum_{(k,k')\in \mathcal{K}}\mathcal{L}_{\mathcal{P}_k\mathcal{P}_{k'}} \end{equation} where $\mathcal{K}$ denotes the set of all possible path pairs, and $S$ refers to the size of set $\mathcal{K}$, \ie the number of path combinations.} \paragraph{Cross Matching.} \hjk{ Cross-path consistency learning encourages outputs from different paths to be consistent. However, since the outputs from a path are given as a set, we first need to resolve correspondence to specify the pairs of predictions to enforce consistency. We present \textbf{cross matching}, a simple method that tags each instance with its corresponding ground truth label. The instances tagged with the same label are paired to compute consistency loss. On the other hand, if an instance is not matched with any of the paths' output, we simply exclude the instance from consistency learning treating it as \textit{no object} or \textit{no interaction}. Our cross-path consistency loss is introduced below. } Let $\sigma_k(i)$ denote the index of the ground truth label that matches the $i^{th}$ query in the $k^{th}$ path. We define $\sigma_{k}^{-1}\left(n\right)$ as the query index of path $\mathcal{P}_k$ which is matched with the ground truth index $n$. To avoid clutter, we use $\tilde\sigma_{k,n}$ as a shorthand notation for $\sigma_{k}^{-1}\left(n\right)$. The outputs from different paths with the same ground-truth label should be consistent. For example, $\hat y^m_{k, {\tilde{\sigma}_{k,n}}}$ and $\hat y^m_{k, {\tilde{\sigma}_{k^\prime,n}}}$ which are predictions for $m$ from $\mathcal{P}_k$ and $\mathcal{P}_{k^\prime}$ with the same ground-truth index $n$ should be consistent. Cross-path consistency loss between output predictions from $\mathcal{P}_k$ and $\mathcal{P}_{k'}$ with the same ground-truth with index $n$ is defined as follows: \begin{equation} \begin{split} \mathcal{L}_{\mathcal{P}_{k}\mathcal{P}_{k'}}^n = &\hspace{2mm} \lambda_h\cdot\mathcal{L}_{h}\big(\hat{y}^{h}_{k,\tilde\sigma_{k,n}},\hat{y}^{h}_{k',\tilde\sigma_{k',n}}\big) \\ & + \lambda_o\cdot\mathcal{L}_{o}\big(\hat{y}^{o}_{k,\tilde\sigma_{k,n}},\hat{y}^{o}_{k',\tilde\sigma_{k',n}}\big) \\ & + \lambda_{act}\cdot \mathcal{L}_{act}\big(\hat{y}^{act}_{k,\tilde\sigma_{k,n}},\hat{y}^{act}_{k',\tilde\sigma_{k',n}}\big) \end{split} \end{equation} \paragraph{Final Loss} The final cross-path consistency loss for all $\mathcal{P}_k$ is derived as, \begin{equation} \mathcal{L}_{\textbf{CPC}}=\frac{1}{{S}\cdot\mathcal{N}}\sum_{n=1}^\mathcal{N}\sum_{(k,k')\in \mathcal{K}}\mathcal{L}_{\mathcal{P}_{k}\mathcal{P}_{k'}}^n \end{equation} where $\mathcal{N}$ is the number of ground truth labels. Then, the final form of our training loss $\mathcal{L}$ is defined by \begin{equation} \mathcal{L}=\sum_k\mathcal{L}_{\mathbf{sup}}^k+w(t)\cdot\mathcal{L}_{\textbf{CPC}}, \end{equation} where $\mathcal{L}_\mathbf{sup}^k$ is the supervision loss for each path $\mathcal{P}_k$ and $w(t)$ is a ramp-up function~\cite{laine2016temporal,berthelot2019mixmatch,tarvainen2017mean} for stable training. Our overall framework is illustrated in Figure ~\ref{fig1}. \subsection{Overall Architecure} \section{Method} In this section, we present our novel end-to-end training strategy for Transformers with \textbf{cross-path consistency} in Human-Object Interaction Detection. The training strategy includes 1) augmenting the decoding path and 2) consistency regularization between predictions of multiple decoding paths. Before discussing our training strategy, we briefly summarize transformers in Human-Object Interaction detection. \subsection{Transformer in HOI detection} \label{section3.1} HOI transformers are commonly extended upon DETR~\cite{carion2020end}, which is composed of a CNN backbone followed by the encoder-decoder architecture of Transformer~\cite{Vaswani17transformer}. \jhprev{The CNN backbone first extracts a \textit{locally} aggregated feature map $f\in\mathbb{R}^{H'\times W' \times D}$ from input image $x \in \mathbb R^{H \times W \times 3}$. Then, the feature map $f$ is passed into the encoder to \textit{globally} aggregate features via the self-attention mechanism, resulting in the encoded feature map $X\in\mathbb{R}^{H'\times W' \times D}.$ } At a decoding stage, a decoder takes learnable query embeddings $\jhprev{q}\in \mathbb{R}^{N\times D}$ and outputs $e\in\mathbb{R}^{N\times D}$ by interacting with encoded feature map $X$ through cross-attention. The outputs are converted to final HOI predictions (\ie, human, object, interaction) by read-out functions, which are generally feed-forward networks. Training Transformers for detection entails matching between predictions and ground truth labels since Transformers provide detections as set predictions. To compute losses, the Hungarian algorithm~\cite{kuhn1955hungarian} is used to associate detections with ground truth labels. The predictions unmatched with ground truth labels are considered as no object or no interactions. In general, HOI transformers can be categorized into two groups based on human/object localization schemes. \cite{tamura2021qpic,zou2021end} directly predict the box coordinates of human and object from an HOI prediction. But this causes problems that human or object can be redundantly predicted by multiple query embeddings and the localizations of the same object often differ across HOI triplet predictions. To address these problems, ~\cite{kim2021hotr,chen2021reformulating} propose parallel architectures to perform interaction detection separately from object detection. \section{Experiments} In this section, we empirically evaluate the effectiveness of our cross-path consistency learning with HOI transformers. Our experiments are conducted on public HOI detection benchmark datasets: \textbf{V-COCO} and \textbf{HICO-DET}. We first briefly introduce the datasets and provide implementation details. Our extensive experiments demonstrate that our training strategy renders significant improvement on the baseline models without additional parameters or inference time. \subsection{Dataset} \paragraph{V-COCO}~\cite{gupta2015visual} is a subset of the COCO dataset~\cite{lin2014mscoco} which contains 5,400 \texttt{trainval} images and 4,946 \texttt{test} images. V-COCO is annotated with 29 common action classes. For evaluation of the V-COCO dataset, we report the mAP metric over 25 interactions for two scenarios, The first scenario includes a prediction of occluded objects and is evaluated with respect to {AP}${}^{}_{\text{role1}}$. On the other hand, the second scenario does not contain such cases, and performance is measured in {AP}${}^{}_{\text{role2}}$. \paragraph{HICO-DET}~\cite{chao2018learning} is a subset of the HICO dataset which has more than 150K annotated instances of human-object pairs in 47,051 images (37,536 for training and 9,515 for testing). It is annotated with 600 $\texttt{<interaction, object>}$ instances. There are 80 unique object types, identical to the COCO object categories, and 117 unique interaction verbs. For evaluation of the HICO-DET, we report the mAP over three different set categories: (1) all 600 HOI categories in HICO (Full), (2) 138 HOI categories with less than 10 training samples (Rare), and (3) 462 HOI categories with more than 10 training samples (Non-Rare). \subsection{Implementation Details} \paragraph{Training} In our experiment, QPIC~\cite{tamura2021qpic} and HOTR~\cite{kim2021hotr} were used as the baseline for the HOI transformer respectively. During training, we initialize the network with pretrained DETR~\cite{carion2020end} on MS-COCO with a Resnet-50 backbone. For all decoding paths, parameters of the model are shared except for stage-wise queries and feedforward networks. All our experiments using consistency regularization are trained for 90 epochs and the learning rate is decayed at the 60-th epoch by a factor of 0.1. As an exception, HOTR is trained up to 50 epochs and the learning rate is decayed at epoch 30 by a factor of 0.1 for HICO-DET. Following the original training schemes in QPIC and HOTR, we freeze the encoder and backbone for HOTR, whereas unfreeze those for QPIC. We use the AdamW~\cite{loshchilov2017decoupled} optimizer with a batch size of 16, and the initial learning rates for the transformer and backbone parameters are set to $10^{-4}$ and $10^{-5}$ respectively, and weight decay is set to $10^{-4}$. All experiments are trained on 8 V100 GPUs. We re-implement the result of QPIC and HOTR on V-COCO~\cite{gupta2015visual} since our reproduction results are quite different from the official ones in the paper. For a fair comparison, all the loss coefficients overlapping between baselines and our training strategy are identical to the ones reported in the paper~\cite{kim2021hotr,tamura2021qpic}. Details for hyperparameters relevant to our training strategy are reported in the supplementary material. \paragraph{Inference} % We mainly use $\mathcal{P}_1$ ( $x\rightarrow \text{HOI}$ ) for inference to compare with the baseline models without increasing the number of parameters. Also, we report the results of other inference paths in our ablation studies. \subsection{Comparison with State-of-the-Art Methods} In Table~\ref{tab:V-COCO} and Table~\ref{tab:HICO-DET}, we compare previous HOI detection methods with ours. As demonstrated in the tables, our training strategy achieves the best performance among its peers. Table~\ref{tab:V-COCO} shows the result on V-COCO dataset in both {AP}${}^{}_{\text{role1}}$ and {AP}${}^{}_{\text{role2}}$. In the V-COCO dataset, our method achieves outstanding performance of 63.1 mAP in {AP}${}^{}_{\text{role1}}$ and 66.8 mAP in {AP}${}^{}_{\text{role2}}$. Also, the results on the HICO-DET dataset in Table~\ref{tab:HICO-DET} show that our CPC further improves the state-of-the-art models (\eg, HOTR, and QPIC) in the default setting achieving 26.16 mAP and 29.63 mAP, respectively. \subsection{Ablation Study} We further discuss the effectiveness of our framework through a series of ablation studies. We first provide a path-wise analysis for our cross-path consistency learning method. The effect of our training technique components was tested on each path to validate our method. Subsequently, we analyze the impact of the number of augmented paths on the main task performance. We experimentally prove the validity of our method by demonstrating the correlation between the number of paths and performance. \paragraph{Efficiency of CPC.} Table~\ref{table:abl} presents ablation experiment results for all inference paths, $\mathcal{P}_1$, $\mathcal{P}_2$, $\mathcal{P}_3$, and $\mathcal{P}_4$. Path $\mathcal{P}_1$ is the main path, which we aim to boost performance with the rest of the augmented paths. We try ablating decoder sharing or cross-path consistency regularization one at a time to confirm each component's contribution to our training strategy. Note that all of our experiments are conducted with the encoder block shared across paths. When our CPC training strategies are applied, QPIC and HOTR achieve an mAP of 63.1, and 61.6 on main path $\mathcal{P}_1$. When the decoder parameters are not shared, performance degradation in path $\mathcal{P}_1$ was observed for both baselines; a 0.7 mAP drop for QPIC, and 0.4 mAP drop for HOTR. On the other hand, when CPC regularization is left out while decoder parameters are shared, performance of QPIC and HOTR decreased by a large margin of 2.4 mAP and 1.0 mAP each. In terms of overall performance across all paths, the average mAP showed a similar trend for each experiment condition. The overall results support that our learning strategy improves generalization of base architectures, and boosts performance by sharing knowledge throughout paths and stages. Interestingly, the standard deviation of all performances dramatically increases without both components. With unshared decoders, deviation increases by 1.33 for QPIC and 0.35 for HOTR. Also, when CPC regularization is removed, deviation increases by 1.01 for QPIC and 0.11 for HOTR. This implies that our training strategy with shared decoder and CPC leads to more stable training as well as consistent representations. \subsection{Comparison with HOI transformer} We evaluate the effectiveness of our method compared to the existing HOI transformers. All experiments are reported with the main path $\mathcal{P}_1$ that infers HOI triplets by a single decoding stage ($x\rightarrow\text{HOI}$) which is identical to the original HOI transformer. As shown in Table~\ref{table:comp}, our CPC training strategy significantly outperforms on two baselines, HOTR~\cite{kim2021hotr} and QPIC~\cite{tamura2021qpic}. In the V-COCO dataset, the experiment shows improvement in performance by a considerable margin of 0.9 mAP for QPIC in {AP}${}^{}_{\text{role1}}$, and 1.8 mAP for HOTR. For {AP}${}^{}_{\text{role2}}$, QPIC and HOTR gain improvement by 0.9 mAP and 1.9 mAP respectively, similar to that of AP$_\text{role1}$. In the HICO-DET dataset, our CPC learning with HOTR and QPIC outperforms all the evaluation categories of HICO-DET, except negligible degradation in the Non-Rare category on HOTR. Results on rare class on the HICO-DET are improved by a significant margin of 1.29 mAP and 5.5 mAP for QPIC and HOTR respectively. In both models, we observe a more prominent performance improvement in the Rare category. This supports that our training strategy performs well on rarely seen examples. Our strategy improves the conventional HOI transformer models. \input{Table/main_short} \input{Table/Vcoco} \input{Table/HICO_new} \input{Table/ablation_pathwise_noS2} \section{Conclusion} We propose end-to-end Cross-Path Consistency learning for Human-Object Interaction detection. Through decoding-path augmentation, various decoder paths are generated which predict HOI triplets in permuted sequences. Then, consistency regularization is applied across paths to enforce the predictions to be consistent. Parameter sharing and cross-matching were introduced as well to enhance learning. Our method is conceptually simple, and can be applied to a wide range of transformer architectures. Also, it does not require additional model capacity nor inference time. The substantial improvements on V-COCO and HICO-DET support our method's efficacy in various HOI detection tasks. Through further empirical studies, its capabilities to improve generalization and to encourage consistent representations are approved. \input{5_Conclusion/Acknowledgments} \subsection{Conclusion and Limitations} In this paper, we introduced Cross-Path Consistency Learning, novel end-to-end training strategy for general transformer architecture using consistency regularization in Human-Object Interaction detection. Our learning scheme leverages inference paths of difference sequence by augmenting the decoding path and imposes their predictions to be consistent, which leads to better generalization without increasing model capacity. In the future work, we aim to apply our learning strategy for the general task, not limited to HOI, and more diverse transformer architecture. We \section{Conclusion} We proposed Cross-Path Consistency learning for Human-Object Interaction detection. Through decoding-path augmentation, various decoder paths are generated which predict HOI instances in permuted sequences. Then, consistency regularization is applied path-wise to impose consistency in the predicted HOI triplets, enforcing the predictions to be inference-path invariant. Key techniques as parameter sharing and cross matching were introduced as well to enhance learning. Our method is conceptually simple, and can be applied to a wide range of transformer architectures. Also, it does not require additional model capacity nor inference time. The state-of-the-art results on V-COCO and HICO-DET supports our method's efficacy in various HOI detection tasks, and its robustness is approved through further empirical studies. However, our work's limitation lies in the task on which our method was experimented. HOI detection being an intricate vision task, it is yet relatively minor. That is, our method's feasibility in simpler and more general vision tasks was not thoroughly discussed in our work. Future work is called for. \section*{\refname}}{}{}{} \newcommand{\hjk}[1]{{\color{black}#1}} \newcommand{\jhp}[1]{{\color{black}#1}} \usepackage[pagebackref,breaklinks,colorlinks,bookmarks=false]{hyperref} \usepackage[capitalize]{cleveref} \crefname{section}{Sec.}{Secs.} \Crefname{section}{Section}{Sections} \Crefname{table}{Table}{Tables} \crefname{table}{Tab.}{Tabs.} \def\cvprPaperID{*****} \defCVPR{CVPR} \def2022{2022} \input{def} \begin{document} \title{Consistency Learning via Decoding Path Augmentation \\for Transformers in Human Object Interaction Detection} \maketitle \thispagestyle{empty} \section*{\refname}}{}{}{} \newcommand{\hjk}[1]{{\color{black}#1}} \newcommand{\jhp}[1]{{\color{black}#1}} \usepackage[pagebackref,breaklinks,colorlinks,bookmarks=false]{hyperref} \usepackage[capitalize]{cleveref} \crefname{section}{Sec.}{Secs.} \Crefname{section}{Section}{Sections} \Crefname{table}{Table}{Tables} \crefname{table}{Tab.}{Tabs.} \def\cvprPaperID{*****} \defCVPR{CVPR} \def2022{2022} \input{def} \begin{document} \title{Consistency Learning via Decoding Path Augmentation \\for Transformers in Human Object Interaction Detection} \maketitle \thispagestyle{empty} \section{Introduction} Human-Object Interaction (HOI) detection is a holistic visual recognition task that includes detecting individual objects as \texttt{<human, object>}, while properly classifying the type of \texttt{<interaction>}. Previous HOI detectors~\cite{gkioxari2018detecting,wang2020learning,li2020pastanet,ulutan2020vsgnet} were mainly built on object detection models. They commonly extend CNN-based object detectors~\cite{ren2016faster,lin2017feature,newell2016stacked} with an additional head for interaction classification, \eg, humans and objects are detected first, and their interaction is associated subsequently. To alleviate the high computation cost of such two-stage HOI detection methods, one-stage models~\cite{wang2020learning,Kim2020UnionDet,liao2019ppdm} have been proposed for faster detection. These models perform interaction prediction and object detection in parallel. They compensate for their lower performance with auxiliary predictions for the HOI subsets, \ie, auxiliary predictions for subset \texttt{<human, interaction>} or \texttt{<object, interaction>} may help HOI prediction through post-processing. However, these works demand different network architectures for each auxiliary prediction, due to strict disciplines for each network's input. Hence, to introduce flexibility, transformer-based architectures~\cite{kim2021hotr, tamura2021qpic, chen2021reformulating, touvron2021training} have recently been adopted for HOI detection. They reformulate the HOI detection problem as a direct set prediction building on DETR~\cite{carion2020end}. \input{Figure_caption/figure1} Motivated by various inference paths in HOI detectors, we propose a simple yet effective method to train HOI transformers. We augment the decoding paths with respect to the possible prediction sequences of HOI triplets. Then, with the cascade structure of transformers, an input query is sequentially decoded into auxiliary sub-task outputs and the final output. The stage of each augmented paths stage shares a decoder, in a multi-task learning fashion. We further improve our method to leverage the augmented decoding paths by enforcing the outputs from the various paths to be consistent. Accordingly, we propose \textbf{Cross-Path Consistency (CPC) Learning}, which aims to predict HOI triplets regardless of inference sequences. Similar to cross-\textit{task} consistency~\cite{zamir2020robust}, cross-\textit{path} consistency retains \textit{inference path invariance}. However, cross-path consistency learning does not require additional pre-trained networks. In contrast to cross-task consistency, which demands an auxiliary network to train the main task $\mathcal{X} \rightarrow \mathcal{Y}$ (Figure~\ref{fig:consistency variants}-(b)), cross-path consistency defines an auxiliary domain $\mathcal{Y}_s$ in between $\mathcal{X}$ and $\mathcal{Y}$ (Figure~\ref{fig:consistency variants}-(c)). In other words, the main task $\mathcal{X} \rightarrow \mathcal{Y}$ (\ie, Image$\rightarrow$HOI) is divided into subtasks $\mathcal{X} \rightarrow \mathcal{Y}_s$ and $\mathcal{Y}_s \rightarrow \mathcal{Y}$ (\eg, Image$\rightarrow$HO$\rightarrow$I). The main task function $f_{\mathcal{X}\mathcal{Y}}$ is then trained by enforcing its output and the composition of sub-task predictions to be consistent. Moreover, cross-path consistency learning is temporarily adopted for training only. Our training strategy can be generalized to any transformer based architecture, and can be applied in an end-to-end method. Extensive experiments show that HOI transformers trained with CPC learning strategy achieves substantial improvements in two popular HOI detection benchmarks: V-COCO and HICO-DET. The contribution of this work can be \jhprev{summarized as the followings}: \begin{itemize} \jhprev{ \item We propose \textbf{Cross-Path Consistency} (CPC) learning, which is a novel end-to-end learning strategy to improve transformers for HOI detection leveraging various inference paths. In this learning scheme, we use \textbf{Decoding-Path Augmentation} to generate various inference paths which are compositions of subtasks with a shared decoder for effective training. } \item Our training scheme achieves substantial improvements on V-COCO and HICO-DET without increasing \textit{model capacity} and \textit{inference time}. \end{itemize} \subsection{Transformers in Computer Vision} \label{section2.2} Transformer has become the state-of-the-art method in many computer vision tasks. In image classification, ~\cite{dosovitskiy2020image} has shown competitive performance on ImageNet without any convolution layers. DeiT~\cite{touvron2021training} applied knowledge distillation to data-efficiently train the vision transformer. To extract multi-scale image features, Swin Transformer~\cite{Liu_2021_ICCV} proposed shifted window based self-attention modules that effectively aggregate small patches to increase the receptive field. In the object detection task, DETR~\cite{carion2020end} has proposed an end-to-end framework eliminating the need for hand-designed components. DETR's bipartite matching loss between the predicted set and the ground truth labels enables direct set prediction at inference. Recently, DETR's late convergence problem has been tackled in~\cite{zhu2020deformable,meng2021conditional,Gao_2021_ICCV}. Inspired by DETR, transformer-based HOI (Human-Object Interaction) detectors~\cite{kim2021hotr,tamura2021qpic,chen2021reformulating,zou2021end,dong2021visual} have been recently proposed. HOI transformer models have two types of structure, one decoder model and the two decoder model. The one-decoder model which follows the structure of DETR~\cite{carion2020end} predicts triplets from the output of a single decoder. QPIC~\cite{tamura2021qpic} and HoiT~\cite{zou2021end} are one-decoder models that output \texttt{<human, object, interaction>} triplets directly with multiple interaction detection heads. Two-decoder models use two transformer decoders to output distinctive targets. For instance, HOTR~\cite{kim2021hotr} and AS-NET~\cite{chen2021reformulating} are composed of an instance decoder that outputs object and an interaction decoder that outputs interaction. In contrast to previous works that are trained with a single inference path, our model learns with the augmented decoding paths. Also, our framework can be applied to any transformer-based model. More explanation of HOI transformers are in Section~\ref{section3.1}. \subsection{Consistency Learning in Vision} \label{section2.3} Consistency constraints applied to many computer vision topics have been extensively studied. In semi-supervised learning, consistency regularization is widely used to train the model to be invariant to input noise. Label consistency methods~\cite{laine2016temporal,xie2020unsupervised,miyato2018virtual,tarvainen2017mean} augment or perturb an input image and apply consistency loss between model predictions. CDS~\cite{NEURIPS2019_d0f4dae8} explored object detection in a semi-supervised setting with classification and localization consistency regularization. Also, consistency regularization in cyclic form is commonly used in generative models~\cite{zhu2017unpaired}, image matching~\cite{7298723,zhou2016learning}, temporal correspondence~\cite{dwibedi2019temporal}, and in many other domains. \paragraph{Comparison with Consistency Learning} Our consistency training scheme is relevant to cross-task consistency learning~\cite{zamir2020robust}. Cross-task consistency learning is based on inference-path invariance, where the predictions should be consistent regardless of the inference paths. As shown in Figure~\ref{fig:consistency variants} (b), cross-\textit{task} consistency learning uses an auxiliary task $\mathcal{Y}\rightarrow \mathcal{Y}_a$ to train the main task function $f_{\mathcal{X}\mathcal{Y}}$, \ie, given $x$ from the query domain, and $y$ from target domain $\mathcal{Y}$, predictions of $f_{\mathcal{Y}\mathcal{Y}_a}\circ f_{\mathcal{X}\mathcal{Y}}(x)$ and $f_{\mathcal{Y}\mathcal{Y}_a}(y)$ are expected to be consistent. Different from cross-\textit{task} consistency, our cross-\textit{path} consistency learning (Figure~\ref{fig:consistency variants} (c)) trains the main task function $f_{\mathcal{X}\mathcal{Y}}$ by enforcing the prediction of target domain $\mathcal{Y}$ of $f_{\mathcal{X}\mathcal{Y}}$ and $f_{\mathcal{Y}_s\mathcal{Y}}\circ f_{\mathcal{X}\mathcal{Y}_s}$, where auxiliary domain $\mathcal{Y}_s$ is decomposed from the target domain $\mathcal{Y}$, to be consistent. Also, while cross-\textit{task} consistency learning requires the mapping function $f_{\mathcal{Y}\mathcal{Y}_a}$ to be pretrained to avoid suboptimal training with the noisy estimator, cross-\textit{path} consistency learning does not demand any task-specific pre-trained networks since the auxiliary domain $\mathcal{Y}_s$ is part of the target domain $\mathcal{Y}$. Details for our framework is described in section~\ref{section3.2}. \section{Related Works} \subsection{Human Object Interaction Detection} \label{section2.1} Human-Object Interaction (HOI) detection has been proposed in ~\cite{gupta2015visual}. Later, human-object detectors have been improved using human or instance appearance and their spatial relationship~\cite{gkioxari2018detecting, kolesnikov2018detecting, gao2018ican}. On the other hand, graph-based approaches~\cite{qi2018learning, ulutan2020vsgnet, Gao2020DRG, Wang2020Hetero} have been proposed to clarify the action between the \texttt{<human, object>} pair. HOI detection models based on only visual cues often suffer from the lack of contextual information. Thus, recent works utilize external knowledge to improve the quality of HOI detection. Human pose information extracted from external models~\cite{cao2017realtime,chen2018cascaded,he2017mask, li2019crowdpose} or linguistic priors and knowledge graph models show meaningful improvement in performance~\cite{zhou2019relation, Liu2020FCMNet, peyre2018detecting,xu2019learning,gupta2017aligned,gkanatsios2019deeply,li2020pastanet, Xubin2020PDNet, Liu2020ConsNet}. Since the majority of the previous works are based on two-stage methods with slower inference time, attempts for faster HOI detection by introducing simple end-to-end multi-layer perceptrons~\cite{gupta2019no}, or directly detecting interaction points~\cite{wang2020learning,liao2019ppdm}, or union regions~\cite{Kim2020UnionDet, Hou2020VCL, yonglu2020idn} have been suggested. \section{Method} In this section, we \hwan{describe our novel end-to-end training strategy for transformers with \textbf{cross-path consistency} in Human-Object Interaction Detection.} The training strategy includes 1) augmenting the decoding path and 2) consistency regularization between predictions of multiple paths. \hwan{In Section~\ref{section3.1}, we explain two general types of transformer in Human-Object Interaction detection. Then, we describe how our two training strategies, decoding-path augmentation and cross-path consistency learning, in Section~\ref{section3.2} and Section~\ref{section3.3}.} \subsection{Revisit Transformer in HOI detection} \label{section3.1} \hkc{ HOI transformers are commonly extended upon DETR~\cite{carion2020end}, which is composed of a CNN backbone followed by the encoder-decoder architecture of Transformer~\cite{Vaswani17transformer}. The CNN backbone first extracts \textit{locally} aggregated feature from input image $x \in \mathbb R^{H \times W \times 3}$. Then, the extracted feature map $X\in \mathbb{R}^{H'\times W'\times D}$ are passed into the encoder to \textit{globally} aggregate features via the self-attention mechanism. } \jhp{In a decoding stage, learnable query embeddings $p\in \mathbb{R}^{N\times D}$ are fed into 6-layer decoder and updated into $e\in\mathbb{R}^{N\times D}$ by interacting with encoded feature map $X$ through cross-attention. Basically at the end of each layer, feed-forward networks for each HOI triplet element is attached to localize human and object regression, and predict interaction classes. At the training phase, Hungarian algorithm is used to match between ground truth labels and predictions from the decoder, and calculate the loss between them. The predictions unmatched with ground truth labels are considered as no object and interactions. In the localizing part, simple extention from DETR~\cite{tamura2021qpic,zou2021end} is to directly regress the box coordinates of humans and objects. This brings out the problem that human or object can be redundantly predicted with multiple query embeddings since the ground truth set is composed of HOI triplets. Other variants~\cite{kim2021hotr,chen2021reformulating} overcome this issue to construct extra branch for instance detection and use matching scheme for binding the relevant instances from instance decoder outputs in interaction decoder outputs. } \paragraph{Single Decoder HOI Transformer.} \hwan{The single-decoder HOI transformers~\cite{tamura2021qpic,zou2021end} directly infer HOI triplets in the decoding stage. They extend DETR with an additional readout function for action classification in the decoder head. The decoding stage of single decoder models can be written as \begin{equation} \label{eq:single_dec} \begin{split} e &= {\text{Dec}}(p,\ X), \end{split} \end{equation} where $e$ denotes the output embeddings, and $p$ denotes the learnable position encoding for the query input. Then, the output embeddings are passed into feed-forward networks (FFN) for bounding box regression and action classification, as shown below. \begin{equation} \label{eq:single_ffn} \begin{split} \hat{b}_h &= \text{FFN}_{h}\left(e\right), \\ \hat{b}_o &= \text{FFN}_{o}\left(e\right), \\ \hat{c}_{act} &= \text{FFN}_{act}\left(e\right), \end{split} \end{equation} where $\hat{b}_h,\hat{b}_o$ denotes predicted bounding boxes for the detected human or object, and $\hat{c}_{act}$ denotes the corresponding action logit. The overall loss consists of binary cross entropy for multi-label action classification, softmax cross entropy for object classification, and $L_1$ and GIoU loss for regression. \paragraph{Two Decoder HOI Transformer.} \hwan{ Despite the simple extension of single decoder HOI transformers, its architecture poses a problem that same human or objects can be redundantly inferred from different queries. Therefore, two-decoder HOI transformers~\cite{kim2021hotr,chen2021reformulating} include two different parallel decoders: \jhp{ one for instance detection and the other for interaction detection.} \jhp{The instance decoder, which is only responsible for object detection, is frozen during training so that the quality of object detection does not affect HOI detection. The interaction decoder infers interactions and creates semantic information for human and object, so that each interaction is matched to the relevant human and object derived from the instance decoder.} The output embeddings can be obtained by \begin{equation} \label{eq:two_dec} \begin{split} e_{\text{ins}} &= {\text{Dec}_\text{ins}}(p,\ X), \\ e_{\text{int}} &= {\text{Dec}_\text{int}}(p,\ X), \end{split} \end{equation} where $e_{\text{ins}}$, $e_{\text{int}}$ denotes output embeddings of instance decoder and interaction decoder respectively. \jhp{For the final predictions of HOI triplets, similarity matching (dot-product for HOTR~\cite{kim2021hotr} and $L_1$ distance for AS-NET ~\cite{chen2021reformulating}) is used between projected interaction embeddings and instance embeddings to predict \texttt{human} and \texttt{object}, and multi-label classification is done for \texttt{interaction}.} \jhp{ Final predictions can be written as \begin{equation} \label{eq:two_ffn} \begin{split} \hat{b}_h &= \text{sim}\big(\text{FFN}_{h}\left(e_{\text{ins}}\right),\text{FFN}\left(e_{\text{int}}\right)\big), \\ \hat{b}_o &= \text{sim}\big(\text{FFN}_{o}\left(e_{\text{ins}}\right),\text{FFN}\left(e_{\text{int}}\right)\big), \\ \hat{c}_{act} &= \text{FFN}_{act}\left(e_{\text{int}}\right) \end{split} \end{equation} $\text{FFN}_h$ and $\text{FFN}_o$ are the projection networks that keep the dimensionality of the output queries consistent. Since two decoder architectures freeze parameters related to instance detection, no regression loss is used. HOTR and AS-NET use cross-entropy and $L_1$ distance for instance prediction ($\hat{b}_h,\hat{b}_o$) respectively, and for multi-label action classification, binary cross entropy is used.} } \subsection{Decoding-Path Augmentation} \label{section3.2} \input{Figure_caption/fig1_extension} \input{Figure_caption/fig2} We observe that HOI detection can be achieved by various sequences of predictions. For instance, CNN-based HOI detection models~\cite{gkioxari2018detecting, chao2018learning, Gao2020DRG, gupta2019no} first detect instances (human and object) and then predict interactions between the instances, \ie, $x \rightarrow \text{HO} \rightarrow \text{I}$, where $x$ is an input image and H, O, I are predictions for human, object, interaction, respectively. On the other hand, the HOI Transformers by \cite{kim2021hotr,tamura2021qpic, chen2021reformulating, zou2021end} directly predict HOI triplets, \ie, $x \rightarrow \text{HOI}$. Inspired by Cross-Task Consistency \cite{zhang2018deep} and this observation, we propose \textbf{decoding-path augmentation} to generate various decoding paths (or prediction paths) and impose consistency regularization. Decoding-path augmentation for Transformers in HOI detection can be easily achieved by partially decoded HOI predictions. Furthermore, sharing decoders across paths is beneficial in terms of knowledge sharing. In our experiments, we consider four decoding paths as follows: \begin{equation} \begin{split} \label{eq:all_path} &\;\mathcal{P}_1 = x \rightarrow \text{HOI} \\ &\begin{rcases*} \mathcal{P}_2 =x \rightarrow \text{HO} \rightarrow \text{I} \\ \mathcal{P}_3 = x\rightarrow \text{HI} \ \rightarrow \text{O} \\ \mathcal{P}_4 =x \rightarrow \text{OI} \ \rightarrow \text{H} \end{rcases*} Augmented. \end{split} \end{equation} Each decoding stage of path $\mathcal{P}_k$ can be written as: \begin{equation} \label{eq:path_decoding} \begin{split} e_{{k,1}} &= f(e_{k,0}+ q_{k,1}, \ X), \\ e_{{k,2}} &= f(e_{k,1} + q_{k,2}, \ X), \end{split} \end{equation} where ${q}_{k,j}, \ e_{k,j}$ denote learnable query and output embeddings on $k^{\text{th}}$ path at $j^{\text{th}}$ decoding stage. The decoder $f$ is shared across all paths and stages. The $e_{k,0}$ above is dummy output embeddings set to zeros since there is no 0-th stage, see Figure \ref{fig:pipeline}. Each decoding stage and path use a separate readout function $\text{FFN}$ to translate the output embeddings into HOI instance predictions. For example, on $\mathcal{P}_2: x \rightarrow \text{HO} \rightarrow \text{I}$, at stage 1 $e_{2,1}$ is read out by $\text{FFN}^{\mathcal{P}_2}_{h}$ and $\text{FFN}_{o}^{\mathcal{P}_2}$ to predict bounding boxes of human and object respectively. Prediction for HOI element \jhprev{$m \in \{h,o,act \}$} in each $k^{th}$ path at $j^{th}$ decoding stage can be written as $\hat{y}_{k}^m=\text{FFN}^{\mathcal{P}_k}_m\left(e_{k,j}\right)$. \subsection{Cross-Path Consistency Learning \label{section3.3} \hjk{We now present our Cross-Path Consistency Learning framework (CPC) that imposes consistency regularization between predictions from different decoding paths as shown in Figure~\ref{fig:consistency for HOI}. Learning with CPC leads better generalization without any additional data or labels. \paragraph{Cross-Path Consistency.} We explain our consistency learning scheme with an exemplary case of main path $\mathcal{P}_1$ and augmented path $\mathcal{P}_2$ given as \begin{equation} \label{eq:path} \begin{split} &\mathcal{P}_1 : x \rightarrow \text{HOI} \\ &\mathcal{P}_2 : x \rightarrow \text{HO} \rightarrow \text{I}. \end{split} \end{equation} Here, the main path $\mathcal{P}_1$ is the HOI transformers' original inference path. In path $\mathcal{P}_2$, human and object detection logits $\hat{y}^h_2$ and $\hat{y}^o_2$ are obtained reading out $e_{2,1}$, which is the output embeddings on path 2 at stage 1. Then, the interaction logit $\hat{y}^{act}_2$ is obtained after another subsequent decoder pass defined as $f_{2,2}$. The corresponding inference scheme of $\mathcal{P}_2$ can be written in more formal terms: \begin{equation} \begin{split} \label{eq:out2} \hat{y}_2^{h}&=\text{FFN}_h^{\mathcal{P}_2}(f_{2,1}(X)) \\ \hat{y}_2^{o}&=\text{FFN}_o^{\mathcal{P}_2}(f_{2,1}(X)) \\ \hat{y}_2^{act}&=\text{FFN}_{act}^{\mathcal{P}_2}(f_{2,2}\circ f_{2,1}(X)) \\ \end{split} \end{equation} In ~\eqref{eq:out2}, input arrays for $f$ other than feature map $X$ were omitted for simplicity. With the predictions, we impose regularization to make the outputs from path $\mathcal{P}_1$ and path $\mathcal{P}_2$ consistent. Note that HOI detections from $\mathcal{P}_2$ consist of both final and intermediate decoder outputs. To this end, we define the loss function $\mathcal{L}_{\mathcal{P}_{1}\mathcal{P}_2}$ by aggregating losses from multiple augmented paths to enforce consistency. The loss function is given as: \begin{equation} \begin{split} \mathcal{L}_{\mathcal{P}_{1}\mathcal{P}_2}=\lambda_h\cdot\mathcal{L}_{h}\big(\hat{y}_1^{h},\hat{y}_2^{h}\big) +\lambda_o\cdot \mathcal{L}_{o}\big(\hat{y}_1^{o},\hat{y}_2^{o}\big) \\ +\lambda_{act}\cdot\mathcal{L}_{act}\big(\hat{y}_1^{act},\hat{y}_2^{act}\big), \end{split} \end{equation} where $\hat{y}^h_1$, $\hat{y}^o_1$ and $\hat{y}^{act}_1$ are the output from the main path $\mathcal{P}_1$ and $\lambda$ are the loss weights. In our experiments, softmax-type outputs use Jensen-Shannon divergence (JSD) for consistency loss to give loss to each path symmetrically, while outputs followed by sigmoid, \eg, box regression, multi-label action classes, take the Mean-Squared Error loss. More details on type-specific loss functions are in the supplement. In the case of other path pairs, loss is computed in the same manner. The final loss should thus incorporate all possible pairs. Then, the cross-path consistency (CPC) loss can be written as: \begin{equation} \label{eq:cpcloss} \mathcal{L}_\textbf{CPC}=\frac{1}{S}\sum_{(k,k')\in \mathcal{K}}\mathcal{L}_{\mathcal{P}_k\mathcal{P}_{k'}} \end{equation} where $\mathcal{K}$ denotes the set of all possible path pairs, and $S$ refers to the size of set $\mathcal{K}$, \ie the number of path combinations.} \paragraph{Cross Matching.} \hjk{ Cross-path consistency learning encourages outputs from different paths to be consistent. However, since the outputs from a path are given as a set, we first need to resolve correspondence to specify the pairs of predictions to enforce consistency. We present \textbf{cross matching}, a simple method that tags each instance with its corresponding ground truth label. The instances tagged with the same label are paired to compute consistency loss. On the other hand, if an instance is not matched with any of the paths' output, we simply exclude the instance from consistency learning treating it as \textit{no object} or \textit{no interaction}. Our cross-path consistency loss is introduced below. } Let $\sigma_k(i)$ denote the index of the ground truth label that matches the $i^{th}$ query in the $k^{th}$ path. We define $\sigma_{k}^{-1}\left(n\right)$ as the query index of path $\mathcal{P}_k$ which is matched with the ground truth index $n$. To avoid clutter, we use $\tilde\sigma_{k,n}$ as a shorthand notation for $\sigma_{k}^{-1}\left(n\right)$. The outputs from different paths with the same ground-truth label should be consistent. For example, $\hat y^m_{k, {\tilde{\sigma}_{k,n}}}$ and $\hat y^m_{k, {\tilde{\sigma}_{k^\prime,n}}}$ which are predictions for $m$ from $\mathcal{P}_k$ and $\mathcal{P}_{k^\prime}$ with the same ground-truth index $n$ should be consistent. Cross-path consistency loss between output predictions from $\mathcal{P}_k$ and $\mathcal{P}_{k'}$ with the same ground-truth with index $n$ is defined as follows: \begin{equation} \begin{split} \mathcal{L}_{\mathcal{P}_{k}\mathcal{P}_{k'}}^n = &\hspace{2mm} \lambda_h\cdot\mathcal{L}_{h}\big(\hat{y}^{h}_{k,\tilde\sigma_{k,n}},\hat{y}^{h}_{k',\tilde\sigma_{k',n}}\big) \\ & + \lambda_o\cdot\mathcal{L}_{o}\big(\hat{y}^{o}_{k,\tilde\sigma_{k,n}},\hat{y}^{o}_{k',\tilde\sigma_{k',n}}\big) \\ & + \lambda_{act}\cdot \mathcal{L}_{act}\big(\hat{y}^{act}_{k,\tilde\sigma_{k,n}},\hat{y}^{act}_{k',\tilde\sigma_{k',n}}\big) \end{split} \end{equation} \paragraph{Final Loss} The final cross-path consistency loss for all $\mathcal{P}_k$ is derived as, \begin{equation} \mathcal{L}_{\textbf{CPC}}=\frac{1}{{S}\cdot\mathcal{N}}\sum_{n=1}^\mathcal{N}\sum_{(k,k')\in \mathcal{K}}\mathcal{L}_{\mathcal{P}_{k}\mathcal{P}_{k'}}^n \end{equation} where $\mathcal{N}$ is the number of ground truth labels. Then, the final form of our training loss $\mathcal{L}$ is defined by \begin{equation} \mathcal{L}=\sum_k\mathcal{L}_{\mathbf{sup}}^k+w(t)\cdot\mathcal{L}_{\textbf{CPC}}, \end{equation} where $\mathcal{L}_\mathbf{sup}^k$ is the supervision loss for each path $\mathcal{P}_k$ and $w(t)$ is a ramp-up function~\cite{laine2016temporal,berthelot2019mixmatch,tarvainen2017mean} for stable training. Our overall framework is illustrated in Figure ~\ref{fig1}. \subsection{Overall Architecure} \section{Method} In this section, we present our novel end-to-end training strategy for Transformers with \textbf{cross-path consistency} in Human-Object Interaction Detection. The training strategy includes 1) augmenting the decoding path and 2) consistency regularization between predictions of multiple decoding paths. Before discussing our training strategy, we briefly summarize transformers in Human-Object Interaction detection. \subsection{Transformer in HOI detection} \label{section3.1} HOI transformers are commonly extended upon DETR~\cite{carion2020end}, which is composed of a CNN backbone followed by the encoder-decoder architecture of Transformer~\cite{Vaswani17transformer}. \jhprev{The CNN backbone first extracts a \textit{locally} aggregated feature map $f\in\mathbb{R}^{H'\times W' \times D}$ from input image $x \in \mathbb R^{H \times W \times 3}$. Then, the feature map $f$ is passed into the encoder to \textit{globally} aggregate features via the self-attention mechanism, resulting in the encoded feature map $X\in\mathbb{R}^{H'\times W' \times D}.$ } At a decoding stage, a decoder takes learnable query embeddings $\jhprev{q}\in \mathbb{R}^{N\times D}$ and outputs $e\in\mathbb{R}^{N\times D}$ by interacting with encoded feature map $X$ through cross-attention. The outputs are converted to final HOI predictions (\ie, human, object, interaction) by read-out functions, which are generally feed-forward networks. Training Transformers for detection entails matching between predictions and ground truth labels since Transformers provide detections as set predictions. To compute losses, the Hungarian algorithm~\cite{kuhn1955hungarian} is used to associate detections with ground truth labels. The predictions unmatched with ground truth labels are considered as no object or no interactions. In general, HOI transformers can be categorized into two groups based on human/object localization schemes. \cite{tamura2021qpic,zou2021end} directly predict the box coordinates of human and object from an HOI prediction. But this causes problems that human or object can be redundantly predicted by multiple query embeddings and the localizations of the same object often differ across HOI triplet predictions. To address these problems, ~\cite{kim2021hotr,chen2021reformulating} propose parallel architectures to perform interaction detection separately from object detection. \section{Experiments} In this section, we empirically evaluate the effectiveness of our cross-path consistency learning with HOI transformers. Our experiments are conducted on public HOI detection benchmark datasets: \textbf{V-COCO} and \textbf{HICO-DET}. We first briefly introduce the datasets and provide implementation details. Our extensive experiments demonstrate that our training strategy renders significant improvement on the baseline models without additional parameters or inference time. \subsection{Dataset} \paragraph{V-COCO}~\cite{gupta2015visual} is a subset of the COCO dataset~\cite{lin2014mscoco} which contains 5,400 \texttt{trainval} images and 4,946 \texttt{test} images. V-COCO is annotated with 29 common action classes. For evaluation of the V-COCO dataset, we report the mAP metric over 25 interactions for two scenarios, The first scenario includes a prediction of occluded objects and is evaluated with respect to {AP}${}^{}_{\text{role1}}$. On the other hand, the second scenario does not contain such cases, and performance is measured in {AP}${}^{}_{\text{role2}}$. \paragraph{HICO-DET}~\cite{chao2018learning} is a subset of the HICO dataset which has more than 150K annotated instances of human-object pairs in 47,051 images (37,536 for training and 9,515 for testing). It is annotated with 600 $\texttt{<interaction, object>}$ instances. There are 80 unique object types, identical to the COCO object categories, and 117 unique interaction verbs. For evaluation of the HICO-DET, we report the mAP over three different set categories: (1) all 600 HOI categories in HICO (Full), (2) 138 HOI categories with less than 10 training samples (Rare), and (3) 462 HOI categories with more than 10 training samples (Non-Rare). \subsection{Implementation Details} \paragraph{Training} In our experiment, QPIC~\cite{tamura2021qpic} and HOTR~\cite{kim2021hotr} were used as the baseline for the HOI transformer respectively. During training, we initialize the network with pretrained DETR~\cite{carion2020end} on MS-COCO with a Resnet-50 backbone. For all decoding paths, parameters of the model are shared except for stage-wise queries and feedforward networks. All our experiments using consistency regularization are trained for 90 epochs and the learning rate is decayed at the 60-th epoch by a factor of 0.1. As an exception, HOTR is trained up to 50 epochs and the learning rate is decayed at epoch 30 by a factor of 0.1 for HICO-DET. Following the original training schemes in QPIC and HOTR, we freeze the encoder and backbone for HOTR, whereas unfreeze those for QPIC. We use the AdamW~\cite{loshchilov2017decoupled} optimizer with a batch size of 16, and the initial learning rates for the transformer and backbone parameters are set to $10^{-4}$ and $10^{-5}$ respectively, and weight decay is set to $10^{-4}$. All experiments are trained on 8 V100 GPUs. We re-implement the result of QPIC and HOTR on V-COCO~\cite{gupta2015visual} since our reproduction results are quite different from the official ones in the paper. For a fair comparison, all the loss coefficients overlapping between baselines and our training strategy are identical to the ones reported in the paper~\cite{kim2021hotr,tamura2021qpic}. Details for hyperparameters relevant to our training strategy are reported in the supplementary material. \paragraph{Inference} % We mainly use $\mathcal{P}_1$ ( $x\rightarrow \text{HOI}$ ) for inference to compare with the baseline models without increasing the number of parameters. Also, we report the results of other inference paths in our ablation studies. \subsection{Comparison with State-of-the-Art Methods} In Table~\ref{tab:V-COCO} and Table~\ref{tab:HICO-DET}, we compare previous HOI detection methods with ours. As demonstrated in the tables, our training strategy achieves the best performance among its peers. Table~\ref{tab:V-COCO} shows the result on V-COCO dataset in both {AP}${}^{}_{\text{role1}}$ and {AP}${}^{}_{\text{role2}}$. In the V-COCO dataset, our method achieves outstanding performance of 63.1 mAP in {AP}${}^{}_{\text{role1}}$ and 66.8 mAP in {AP}${}^{}_{\text{role2}}$. Also, the results on the HICO-DET dataset in Table~\ref{tab:HICO-DET} show that our CPC further improves the state-of-the-art models (\eg, HOTR, and QPIC) in the default setting achieving 26.16 mAP and 29.63 mAP, respectively. \subsection{Ablation Study} We further discuss the effectiveness of our framework through a series of ablation studies. We first provide a path-wise analysis for our cross-path consistency learning method. The effect of our training technique components was tested on each path to validate our method. Subsequently, we analyze the impact of the number of augmented paths on the main task performance. We experimentally prove the validity of our method by demonstrating the correlation between the number of paths and performance. \paragraph{Efficiency of CPC.} Table~\ref{table:abl} presents ablation experiment results for all inference paths, $\mathcal{P}_1$, $\mathcal{P}_2$, $\mathcal{P}_3$, and $\mathcal{P}_4$. Path $\mathcal{P}_1$ is the main path, which we aim to boost performance with the rest of the augmented paths. We try ablating decoder sharing or cross-path consistency regularization one at a time to confirm each component's contribution to our training strategy. Note that all of our experiments are conducted with the encoder block shared across paths. When our CPC training strategies are applied, QPIC and HOTR achieve an mAP of 63.1, and 61.6 on main path $\mathcal{P}_1$. When the decoder parameters are not shared, performance degradation in path $\mathcal{P}_1$ was observed for both baselines; a 0.7 mAP drop for QPIC, and 0.4 mAP drop for HOTR. On the other hand, when CPC regularization is left out while decoder parameters are shared, performance of QPIC and HOTR decreased by a large margin of 2.4 mAP and 1.0 mAP each. In terms of overall performance across all paths, the average mAP showed a similar trend for each experiment condition. The overall results support that our learning strategy improves generalization of base architectures, and boosts performance by sharing knowledge throughout paths and stages. Interestingly, the standard deviation of all performances dramatically increases without both components. With unshared decoders, deviation increases by 1.33 for QPIC and 0.35 for HOTR. Also, when CPC regularization is removed, deviation increases by 1.01 for QPIC and 0.11 for HOTR. This implies that our training strategy with shared decoder and CPC leads to more stable training as well as consistent representations. \subsection{Comparison with HOI transformer} We evaluate the effectiveness of our method compared to the existing HOI transformers. All experiments are reported with the main path $\mathcal{P}_1$ that infers HOI triplets by a single decoding stage ($x\rightarrow\text{HOI}$) which is identical to the original HOI transformer. As shown in Table~\ref{table:comp}, our CPC training strategy significantly outperforms on two baselines, HOTR~\cite{kim2021hotr} and QPIC~\cite{tamura2021qpic}. In the V-COCO dataset, the experiment shows improvement in performance by a considerable margin of 0.9 mAP for QPIC in {AP}${}^{}_{\text{role1}}$, and 1.8 mAP for HOTR. For {AP}${}^{}_{\text{role2}}$, QPIC and HOTR gain improvement by 0.9 mAP and 1.9 mAP respectively, similar to that of AP$_\text{role1}$. In the HICO-DET dataset, our CPC learning with HOTR and QPIC outperforms all the evaluation categories of HICO-DET, except negligible degradation in the Non-Rare category on HOTR. Results on rare class on the HICO-DET are improved by a significant margin of 1.29 mAP and 5.5 mAP for QPIC and HOTR respectively. In both models, we observe a more prominent performance improvement in the Rare category. This supports that our training strategy performs well on rarely seen examples. Our strategy improves the conventional HOI transformer models. \input{Table/main_short} \input{Table/Vcoco} \input{Table/HICO_new} \input{Table/ablation_pathwise_noS2} \section{Conclusion} We propose end-to-end Cross-Path Consistency learning for Human-Object Interaction detection. Through decoding-path augmentation, various decoder paths are generated which predict HOI triplets in permuted sequences. Then, consistency regularization is applied across paths to enforce the predictions to be consistent. Parameter sharing and cross-matching were introduced as well to enhance learning. Our method is conceptually simple, and can be applied to a wide range of transformer architectures. Also, it does not require additional model capacity nor inference time. The substantial improvements on V-COCO and HICO-DET support our method's efficacy in various HOI detection tasks. Through further empirical studies, its capabilities to improve generalization and to encourage consistent representations are approved. \input{5_Conclusion/Acknowledgments} \subsection{Conclusion and Limitations} In this paper, we introduced Cross-Path Consistency Learning, novel end-to-end training strategy for general transformer architecture using consistency regularization in Human-Object Interaction detection. Our learning scheme leverages inference paths of difference sequence by augmenting the decoding path and imposes their predictions to be consistent, which leads to better generalization without increasing model capacity. In the future work, we aim to apply our learning strategy for the general task, not limited to HOI, and more diverse transformer architecture. We \section{Conclusion} We proposed Cross-Path Consistency learning for Human-Object Interaction detection. Through decoding-path augmentation, various decoder paths are generated which predict HOI instances in permuted sequences. Then, consistency regularization is applied path-wise to impose consistency in the predicted HOI triplets, enforcing the predictions to be inference-path invariant. Key techniques as parameter sharing and cross matching were introduced as well to enhance learning. Our method is conceptually simple, and can be applied to a wide range of transformer architectures. Also, it does not require additional model capacity nor inference time. The state-of-the-art results on V-COCO and HICO-DET supports our method's efficacy in various HOI detection tasks, and its robustness is approved through further empirical studies. However, our work's limitation lies in the task on which our method was experimented. HOI detection being an intricate vision task, it is yet relatively minor. That is, our method's feasibility in simpler and more general vision tasks was not thoroughly discussed in our work. Future work is called for.
{'timestamp': '2022-04-12T02:30:25', 'yymm': '2204', 'arxiv_id': '2204.04836', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04836'}
arxiv
\section{Introduction} \looseness=-1 Constructing algorithms that efficiently converge to equilibria is one of the central goals of computational game theory. In recent years, regret minimization techniques for approximating equilibria via self play have led to a number of major successes in games like poker~\citep{bowling2015heads,moravvcik2017deepstack,brown2018superhuman,brown2019superhuman}, Avalon \citep{serrino2019finding}, and Diplomacy \citep{gray2021human}. Regret minimization is now the state-of-the-art approach for computing equilibria in large games, especially those with a large number of actions or in settings where queries to the payoff matrix are too expensive to compute an exact solution via linear programming. Classical usage of regret minimization algorithms for learning equilibria in games has typically weighted each iteration equally. In this paper, we demonstrate empirically faster convergence, while still guaranteeing the same worst-case regret bound, by greedily weighing each new iteration to minimize the regret minimizer's potential function: a measure the current distance to the set of desired equilibria. Recent work such as CFR+~\cite{tammelin2014solving} and Linear CFR~\cite{brown2019solving} have also shown that faster performance is achievable by weighing iterates non-uniformly. However, in all previous algorithms, iterates were weighed according to a fixed, pre-determined schedule. In contrast, we introduce \textbf{greedy weights}, the first equilibrium-finding regret minimization algorithm where iterates are weighed \emph{dynamically} using information available at \emph{runtime}. \begin{figure}[t!] \includegraphics[width=\linewidth]{figs/Intuitive_Figure.pdf} \caption{ Vanilla regret minimization methods always move the rolling weighted average policy profile discovered so far $\bar{\pi}^{t-1}$ (with average regret represented by $\bf \bar{R}^{t-1}$) a fixed step towards the latest iteration of the procedure $\pi^t$ (with instantaneous regret represented by $\bf r^t$) to the point represented by $\bar{\pi}^t$. In contrast, greedy weights will choose the point $\bar{\pi}^t_*$ that minimizes the distance to the set of equilibria we wish to approach (represented by $E$), often resulting in accelerated convergence. } \label{fig:intuitive-graphic} \end{figure} We benchmark greedy weights against past techniques for computing minimax equilibria (in two-player zero-sum games), coarse-correlated equilibria, and correlated equilibria in large, randomly generated normal-form games. Additionally, we conduct experiments in subgames of Diplomacy, which has a long history as an important benchmark for AI research~\citep{kraus1988diplomat,kraus1994negotiation,kraus1995designing,johansson2005tactical,ferreira2015dipblue} and has been a particularly active domain for research in recent years~\citep{paquette2019no,anthony2020learning,gray2021human}. We find that greedy weights significantly improves the rate of convergence whenever sampling is used, in some cases by several orders of magnitude. Finally, we find that equilibria discovered by greedy weights in general-sum games typically have higher overall social welfare than those found by prior methods. \section{Notation and Background} \label{sec:background} In a normal-form (also called strategic-form) game, each of $\mathcal{P}$ players simultaneously chooses their actions without observing the other players' choices. Each player then receives a reward determined by a function of all players' actions. All games can be written as normal-form games, though some may additionally admit more compact representations. Let $\Delta$ represent the difference between the highest and lowest possible payoff of any player in the game. Let $A_i$ denote the set of actions for player~$i$ and $A$ the set of joint actions for all players. We denote the set of joint actions for all players \emph{except} $i$ as $A_{-i}$. Let $\Sigma_i$ represent the set of probability distributions over actions in $A_i$ (i.e., the set of mixed policies, also known as strategies). $\Sigma$ is the set of joint policies across all players, and $\Sigma_{-i}$ is the set of joint policies for all players other than $i$. $\pi_i \in \Sigma_i$ denotes player~$i$'s policy, which is a probability distribution over actions in $A_i$. The probability of action~$a_i$ in $\pi_i$ is denoted $\pi_i(a_i)$. Similarly, $\pi_{-i}$ and $\pi$ denote the policies for all players other than $i$ and for all players, respectively. The payoff player $i$ receives when all players play joint action~$a\in A$ is denoted $u_i(a) = u_i(a_i, a_{-i})$. Analogously, the expected payoff to player $i$ when all players play policy profile $\pi$ is denoted $u_i( \pi) = u_i(\pi_i, \pi_{-i})$. \subsection{Equilibria in Games} Perhaps the most well-known equilibrium concept for games is the Nash equilibrium (NE)~\cite{nash1951non}. A NE is a tuple of policies (one for each player) in which no player can improve by deviating to a different policy. Formally, a policy profile $\pi$ is a NE if it satisfies: \begin{equation} \max_{i \in \mathcal{P}} \max_{\pi^\prime \in \Sigma_i} \;u_i(\pi^\prime, \pi_{-i}) - u_i(\pi_i, \pi_{-i}) \le 0 \end{equation} Well-known results in complexity theory have suggested that discovering (or even approximating) a NE in general games is computationally hard \citep{chen2009settling, daskalakis2009complexity, rubinstein2019hardness}. As a result, researchers often also consider the correlated equilibrium (CE)~\citep{aumann1974subjectivity}, an alternative solution concept which is efficiently computable in all normal-form games. Whereas a NE is a probability distribution over actions $A_i$ for each player~$i$, a CE is a probability distribution $p$ over the set of joint actions~$A$ that satisfies certain incentive constraints. In order for a probability distribution over joint actions to be a CE, it must be the case that if a mediator were to sample a joint action~$a$ from that distribution and privately share with each player~$i$ their action~$a_i$ that is part of the joint action, then no player could gain by deviating from that action. Formally, a CE is a probability distribution over joint actions in $A$ satisfying \[ \max_{i \in \mathcal{P}} \max_{\phi: A_i \rightarrow A_i} \sum_{a \in A} p(a) (u_i(\phi(a_i), a_{-i}) - u_i(a_i, a_{-i})) \le 0 \] Finally, a \emph{coarse}-correlated equilibrium (CCE)~\citep{hannan1957approximation} is also a probability distribution over joint actions but with a weaker incentive constraint than the correlated equilibrium. In order for a probability distribution over joint actions to be a CCE, it must be the case that if a mediator were to sample a joint action~$a$ from that distribution and each player~$i$ is forced to play their action~$a_i$ that is part of the joint action, then no player could gain by refusing to receive an action from the mediator and choosing an action on their own instead. Formally, a CCE satisfies: \begin{equation} \max_{i \in \mathcal{P}} \max_{a'_i \in A_i} \sum_{a \in A} p(a) (u_i(a'_i, a_{-i}) - u_i(a_i, a_{-i})) \le 0 \end{equation} We can define the $\epsilon$-versions of all of the above equilibria by replacing the $0$ on the right hand side of the equations with an $\epsilon$. In two-player zero-sum games, NE, CE, and CCE can be shown to be payoff equivalent to one another via the minimax theorem ~\cite{neumann1928theorie}. \subsection{Regret Minimization} There exist several polynomial-time algorithms for computing CEs and CCEs. This paper focuses on the leading approach for large games: regret minimization algorithms. In addition to their theoretical guarantees of convergence to equilibria, regret minimization algorithms have been behind recent empirical successes in large-scale game benchmarks such as many forms of poker (including non-two-player poker)~\citep{bowling2015heads,moravvcik2017deepstack,brown2018superhuman,brown2019superhuman}, Avalon \citep{serrino2019finding}, and Diplomacy \citep{gray2021human}. For any sequence of policies $\pi^1 \dots \pi^T$ in a game $G$, player $i$'s weighted \textbf{external regret} for not having played action $a'_i \in A_i$ is \begin{align*} R_i^{E,T}&(a'_i) = \sum_{t=1}^T w_t\big(u_i(a'_i, \pi^t_{-i}) - u_i(\pi^t)\big) \end{align*} We can thus define the overall average external regret for player~$i$ as \begin{equation} \bar{R}_i^{E,T} = \max\limits_{a'_i \in A_i} \frac{R_i^{E,T}(a'_i)}{\sum_{t=1}^T w_t} \end{equation} Analogously, we can define player $i$'s weighted \textbf{internal regret} for not swapping to action $a'_i$ every time she actually played action $a_i^A$ as \begin{align*} R_i^{I,T}(a^A_i, a'_i) =\sum_{t=1}^T \mathds{1}[a^t_i = a^A_i]w_t(u_i(a'_i, a^t_{-i}) - u_i(a^t)) \end{align*} and her overall average internal regret as \[ \bar{R}_i^{I,T} = \max\limits_{a'_i, a^A_i \in A_i} \frac{R_i^{I,T}(a^A_i, a'_i)}{\sum_{t=1}^T w_t} \] We denote the vector (for all players) of average external regrets by ${\bf \bar{R}}^{E,T}$ and average internal regret by ${\bf \bar{R}}^{I,T}$. Additionally, whenever we use the notation $R_+$, we refer to the positive regrets defined by $\max\left(0, R\right)$ for whatever regret $R$ represents. For example, $R^{E,t}_{i,+}(a_i) = \max\left(0, R_i^{E,t}(a_i)\right)$. Celebrated past results have shown that for any strategic-form game, minimizing average external regret for all players leads to a CCE while minimizing average internal regret for all players leads to a CE \citep{cesa2006prediction}. Many well-known methods exist for minimizing both internal and external regret. For our experiments in external regret minimization, we use Blackwell's regret minimization \citep{blackwell1956analog}, which asks every player to select their next action proportional to how much they regret having not selected that action in the past. Formally, each player selects action $a_i \in A_i$ at timestep $t+1$ with probability \[ \Pr(a^{t+1}_i = a_i) = \frac{R^{E,t}_{i, +}(a_i)}{\sum_{a'_i \in A_i} R^{E,t}_{i,+}(a'_i)} \] except in the case where all regrets are nonpositive upon which $a^{t+1}_i$ is chosen uniformly at random from $A_i$. For internal regret minimization, we primarily use an extension of Blackwell's regret minimization given by \pyear{hart2000simple} also known as \textbf{regret matching}. Regret matching also selects its policy with probability ``matching'' its past regrets of not switching to that action in the past, but it differs in that it additionally uses a fixed inertia parameter $\alpha$ and thus always retains a positive probability of staying in place, with probability approaching $1$ as the overall regrets vanish\footnote{Note that our formulation is slightly different from the formulation given in their original paper in that it allows us to use a very low inertia constant ($\alpha = 10^{-10}$) and thus prevents the procedure from repeating actions until the regrets become very low. We empirically observe that this dramatically accelerates convergence to CE in our experiments with large random games.}. Formally, we have \[ \Pr(a^{t+1}_i = a_i) = \left. \begin{cases} \frac{\alpha}{\alpha + \sum_{a'_i \in A_i} R^{I,t}_{i,+}(a^t_i, a'_i)}, & \text{if } a_i = a^t_i \\[10pt] \frac{R^{I,t}_{i,+}(a^t_i, a_i)}{\alpha + \sum_{a'_i \in A_i} R^{I,t}_{i,+}(a^t_i, a'_i)}, & \text{otherwise} \end{cases} \right\} \] Due to the substantial similarities between the two algorithms, we refer to both as regret matching. Both forms of regret matching have been shown to be special cases of a general class of potential-based minimizers \citep{cesa2006prediction, hart2001general, cesa2001potential}. Specifically, many of their theoretical properties can be proved via careful examination of the potential function, defined as the sum of the squared positive regrets. Formally, the potential functions that regret matching minimizes for external and internal regret, respectively, are: \[ \phi({\bf \bar{R}}_+^{E,T}) = \sum_{i \in P} \sum_{a_i \in A_i} \big(\bar{R}_{i,+}^{E,T}(a_i)\big)^2 \] \[ \phi({\bf \bar{R}}_+^{I,T}) = \sum_{i \in P} \sum_{a^A_i, a^B_i \in A_i} \big(\bar{R}^{I,T}_{i,+}(a^A_i, a^B_i)\big)^2 \] External regret matching guarantees that $\phi({\bf \bar{R}}_+^{E,T}) \leq \frac{\norm{P}\Delta^2 |A|}{T}$, which in turn guarantees that $\max\limits_{i \in P} \max\limits_{a_i \in A_i} \bar{R}_i^{E,T}(a_i) \leq \frac{\Delta \sqrt{\norm{P} \norm{A}}}{\sqrt{T}}$, with similar guarantees for internal regret. If all players' average regret is bounded by $\epsilon$, then the empirical distribution of play is an $O(\epsilon)$-equilibrium. \section{Greedy Weights} \label{sec:approach} \label{sec:greedyweights} Blackwell's original regret minimization procedure \citep{blackwell1956analog} and its various extensions (e.g. \pyear{hart2000simple}, \pyear{blum2007external}, \pyear{zinkevich2008regret}) and applications to online learning \citep{abernethy2011blackwell} typically assign equal weight to each iteration of the procedure. Recently, \pyear{brown2019solving} demonstrated that modifying the weight schedule of regret matching empirically resulted in faster convergence to equilibria while maintaining a similar worst-case convergence bound. However, this modified schedule was fixed and pre-determined before the start of the procedure. Our algorithm extends this direction of inquiry by greedily choosing the iteration weights to minimize a function of regret at runtime. Figure~\ref{fig:intuitive-graphic} demonstrates why this might prove useful. We represent the set of equilibria we wish to approach as $E$. At iteration $t$, let $\bar{\pi}^{t-1}$ represent the weighted average policy thus far and $\pi^t$ the policy played at iteration $t$ of the procedure. Their regrets are denoted by $\bf \bar{R}^{t-1}$ and $\bf r^t$, respectively. Vanilla regret minimization would give an overall weight of $\frac{1}{t}$ to iteration $t$, regardless of whether an alternative weighting would result in an average policy closer to an equilibrium. In contrast, greedy weights would choose the relative weighting between $\bar{\pi}^{t-1}$ and $\pi^t$ that minimizes the potential function measuring the distance of the resulting new average policy $\bar{\pi}^t_*$ to the set of equilibria $E$. Formally, greedy weights picks the weight of each iteration to greedily minimize $\phi_i^{E,T}$ or $\phi_i^{I,T}$, depending on whether external or internal regret is being minimized. \begin{algorithm}[t] \caption{Greedy Weights} \begin{algorithmic} \STATE {\bfseries Input:} total timesteps $T$, game $G$, regret minimizer $M$ \STATE Initialize $a$ randomly and compute immediate regret ${\bf r}$ \STATE Set $\bar{\pi} = a$, $w_{\text{sum}} = 1$, ${\bf R} = {\bf r}$ \FOR{$t=1$ {\bfseries to} $T$} \STATE $\pi, {\bf r} \gets M(G, \phi, {\bf R})$ \STATE $w \gets \argmin\limits_{w} \phi \left(({\bf R} + w {\bf r})/(w_{\text{sum}} + w)\right)$ \STATE ${\bf R} \gets {\bf R} + w {\bf r}$ \STATE $\bar{\pi} \gets (w_{\text{sum}} \bar{\pi} + w \pi) / (w_{\text{sum}} + w)$ \STATE $w_{\text{sum}} \gets w_{\text{sum}} + w$ \ENDFOR \STATE \textbf{return} $\bar{\pi}$ \end{algorithmic} \label{mainalgorithm} \end{algorithm} Algorithm~\ref{mainalgorithm} provides a formal description for the greedy weights procedure. On each iteration the regret vectors for all players, denoted by ${\bf R}$, is used to determine the policy profile $\pi$ played in the regret minimization algorithm and the resulting instantaneous regret vectors for all players, denoted by ${\bf r}$ (which in typical regret minimization would be added to ${\bf R}$, leading to the new regret vectors). Next, the weight $w$ for ${\bf r}$ that minimizes the potential function is computed. Since the potential function is convex, this can be done either analytically or via a simple line search procedure. Both the update to the regret vectors and the update to the average policy profile is weighed by $w$, and the process repeats. To reduce the risk of numerical instability and overflow, if $w > 1$, then rather than weigh the next iteration by $w$ we instead discount all previous iterations by $\frac{1}{w}$ and weigh the next iteration by $1$. As with many greedy algorithms, greedy weights is not guaranteed to converge faster than vanilla regret matching. In particular, we observe in two-player zero-sum games that setting a weight floor of $\frac{w_\text{sum}}{2t}$ is often useful for speeding up convergence. In all other settings, we did not observe a floor to be beneficial. In the Appendix, we describe ablations measuring the performance for different weight floors. Computing the optimal weight is essentially a line search procedure. It can be approximated via binary search or computed exactly by checking $O(|\mathcal{P}||A|)$ points. This is especially useful in cases where ${\bf r}$ may be expensive to compute (e.g. when evaluated using a neural network value function), because this line search only requires a single evaluation of ${\bf r}$ and is then able to compute $\phi({\bf R} + w{\bf r})$ as a simple algebraic function of ${\bf R}, {\bf r}, w$ without any further queries to the reward function. Greedy weights retains the convergence guarantees of previous regret minimization methods, as demonstrated by the following theorem. \begin{theorem} \label{mainproposition} If the policies for each player and weights for each iteration are selected according to Algorithm~\ref{mainalgorithm} and run for $T$ iterations, the resulting average distribution of plays $\bar{\pi}^T$ is guaranteed to be an $O(\frac{1}{\sqrt{T}})$\,-equilibrium. \end{theorem} The full proof for external and internal regret matching is provided in the Appendix \section{Experimental Results} \label{sec:experiments} \begin{figure}[b!] \includegraphics[width=\linewidth]{figs/mixed_paper.pdf} \caption{ In the special case of two-player zero-sum games where mixed strategies are used at each iteration is applied, greedy weights (combined with optimism \citep{syrgkanis2015fast}) outperforms many but not all previous methods for minimizing external regret. However, this trick is not feasible for general computation of equilibria or in games with a large number actions where full queries to the payoff matrix are too expensive. } \label{fig:mixed-2pzs} \end{figure} We benchmark \textbf{greedy weights} against the state-of-the-art algorithms for regret minimization on randomly generated games and on subgames from the benchmark seven-player game Diplomacy. In our experiments we evaluate the following regret minimization methods: \begin{figure*}[t!] \centering \begin{subfigure}[b]{0.49\textwidth} \centering \includegraphics[width=\textwidth]{figs/exploitability.pdf} \caption{Exploitability v. Iteration} \label{fig:2pzs_regret_v_iteration} \end{subfigure} \hfill \begin{subfigure}[b]{0.49\textwidth} \centering \includegraphics[width=\textwidth]{figs/exploitability_time.pdf} \caption{Exploitability v. Time} \label{fig:2pzs_regret_v_time} \end{subfigure} \hfill \caption{ We generate $10$ two-player zero-sum games with P1's matrix payoff entries selected uniformly at random from $[0, 1)$ and run the best of the described approaches for minimizing external regret in the sampled setting. Greedy weights outperforms all methods by almost an order of magnitude. Figure~\ref{fig:2pzs_regret_v_iteration} shows the results as a function of the number of iterations used, while Figure~\ref{fig:2pzs_regret_v_time} shows the same data as a function of time for fair comparison as iterations of greedy weights cost slightly more than previous methods. Exploitability is the distance to a Nash equilibrium. Both axes are logscale and error bars are shown at $95\%$ confidence.} \label{fig:2PZS} \end{figure*} \begin{enumerate} \item \textbf{Regret Matching (RM)} \cite{blackwell1956analog, hart2000simple}. Blackwell's was the the original (external) regret minimization procedure, where each player chooses their next policy proportionally to their positive regrets. \pyear{hart2000simple} extended their procedure to internal regret by adding a small inertia parameter that causes players to tend to stay in place as their regrets go to $0$. \item \textbf{RM+} \citep{tammelin2014solving}. RM+ makes two changes to RM. The first is that a distinction is made between the ``true'' regrets and the ``guiding'' regrets, where the guiding regrets are used to determine the policies on the next iteration. After every iteration, any negative guiding regrets are set to zero. The second is that in RM+ iteration $t$ is given weight $t$ when computing the final average policy (but not when computing the next iteration's policy). RM+ does well with mixed strategies, but does poorly with sampling~\citep{burch2017time}. \item \textbf{Linear RM} \citep{brown2019solving}. Linear RM is identical to vanilla RM except that iteration $t$ is given weight $t$ (both when computing the average policy and when computing the next iteration's policy). \end{enumerate} Additionally, prior work has discovered several additional modifications to regret minimization that significantly improves the convergence rate in two-player zero-sum games in practice. We additionally evaluate these methods. \begin{enumerate} \item \textbf{Alternating Updates} \citep{tammelin2014solving}. For two-player zero-sum games, each player's guiding regrets are updated only once every other iteration. We generalize this procedure to $n$-player games by updating each player's regrets only once every $n$ iterations. \item \textbf{Optimism} \citep{syrgkanis2015fast, farina2021faster}. The guiding regrets are modified such that the latest iteration is temporarily counted twice. This boost is subtracted away from the guiding regrets immediately after the next iteration's strategy is determined and the equilibrium regrets remain unchanged. \end{enumerate} \subsection{Pure vs Mixed Policies at each Iteration} \label{sec:mixedvspure} In order to interpret the results in the following sections, it is necessary to discuss a technique often used in regret matching in the two-player zero-sum setting. When computing a Nash equilibrium in two-player zero-sum games, it is possible to simulate each player playing their \textit{mixed} policy at each iteration rather than sampling a single action to play. This modification leads to much faster convergence with certain regret matching schemes. However, using mixed policies comes with some a major computational drawback in games with more than two players, as the computational cost of each iteration scales as $O(\norm{P}\norm{A}^{\norm{P}})$ for mixed-strategy RM as opposed to $O(\norm{A}\norm{P})$ for standard RM, making it intractable for games with more than 2-3 players, games with a large action space, or games where evaluating the payoff matrix is expensive. A game such as Diplomacy - an important AI challenge problem that has previously been tackled with RM \cite{gray2021human} - has all three of these properties, making mixed-strategy RM untenable. We show that while some regret matching variants outperform greedy RM in the mixed-strategy two-player zero-sum setting (see Figure~\ref{fig:mixed-2pzs}), only greedy regret matching improves convergence in the general setting where mixed-strategy RM cannot be applied. \subsection{Two-Player Zero-Sum Random Games} We first evaluate greedy weights on the special case of two-player zero-sum games, where external regret minimization finds a Nash equilibrium. The results are shown in Figure~\ref{fig:2PZS}. Unlike the mixed case depicted in Figure~\ref{fig:mixed-2pzs}, no prior methods achieve a faster asymptotic convergence rate than $O(\frac{1}{\sqrt{T}})$\, in the pure strategy setting. However, greedy RM empirically displays asymptotically faster convergence, and achieves regret over an order of magnitude lower after around $10^3$ iterations, even when accounting for the additional computational overhead of computing the optimal iteration weight. All experiments on random games (both zero-sum and general-sum) were done on a single CPU core. \label{sec:generalgame} \begin{figure*} \centering \begin{subfigure}[b]{0.49\textwidth} \centering \includegraphics[width=\textwidth]{figs/main_result_iterations.pdf} \caption{Regret v. Iteration} \label{fig:general_regret_v_iteration} \end{subfigure} \hfill \begin{subfigure}[b]{0.49\textwidth} \centering \includegraphics[width=\textwidth]{figs/general_time_error.pdf} \caption{Regret v. Time} \label{fig:general_regret_v_time} \end{subfigure} \hfill \caption{We generate $10$ seven-player general-sum games with the matrix payoff entries selected uniformly at random from $[0, 1)$ and run all the described state-of-the-art approaches for minimizing internal regret in the sampled setting. All methods except our newly proposed greedy weights roughly converge at the worst case bound rate of $O(\frac{1}{\sqrt{T}})$\,, while greedy weights converges several orders of magnitude faster. Figure~\ref{fig:general_regret_v_iteration} shows the results as a function of the number of iterations used, while Figure~\ref{fig:general_regret_v_time} shows it as a function of time for fair comparison as each iteration of greedy weights costs slightly more than previous methods for regret minimization. Note that both axes are logscale. Error bars are shown at $95\%$ confidence.} \label{fig:mainresult} \end{figure*} \subsection{General-Sum Games} In Figure~\ref{fig:mainresult}, we compare the convergence of different RM weighting schemes for computing correlated equilibria in random games. We observe again that no prior methods achieve asymptotically faster convergence to correlated equilibria than $O(\frac{1}{\sqrt{T}})$\, in general-sum games in the pure strategy setting. Our proposed greedy weighting scheme, however, dramatically improves convergence to correlated equilibria in large general-sum games. These results are robust to variance between games (error bars listed at $95\%$ confidence) and hold across a large spectrum of games with varying numbers of players and actions. For the sake of space, we have relegated most of these plots to the Appendix. Code to replicate the random normal-form game experiments can be found at https://github.com/hughbzhang/greedy-weights. We also investigate whether the equilibria that greedy weights discovers in general-sum games increase total expected value (i.e., social welfare) compared to equilibria found using vanilla regret minimization. Intuitively, we might expect this to be the case since iterations where players receive higher overall rewards are also likely to be iterations with lower overall regret, and would thus be upweighted by the greedy weights algorithm. We generated 100 random 7-player 10-action general-sum games with payoff entries randomly sampled between 0 and 1 and ran both the standard and greedy weights variants of regret matching for $1000$ iterations each. Indeed, greedy weights RM converges to equilibria with higher social welfare: it finds equilibrium with average welfare of $4.16 \pm 0.023$, while vanilla RM finds equilibria with average welfare $3.50 \pm 0.005$ (95\% confidence intervals). Additionally, we evaluate greedy weights on all the normal-form games included in the popular game theory library OpenSpiel \cite{lanctot2019openspiel}. For space reasons, these plots have been relegated to the appendix. \subsection{Results in Diplomacy} \label{sec:diplomacy} In addition to running experiments on randomly generated matrix games, we also benchmark greedy weights on subgames of the benchmark game of Diplomacy. Diplomacy is a popular seven-player zero-sum board game that involves simultaneous moves and both cooperation and competition. Players decide whom to support and whom to betray in pursuit of majority control of the board. Diplomacy has a long history as a benchmark for AI research~\citep{kraus1988diplomat,kraus1994negotiation,kraus1995designing,johansson2005tactical,ferreira2015dipblue} and has been a particularly active domain for research in recent years~\citep{paquette2019no,anthony2020learning,gray2021human}. Since the game state is fully observable each turn, and players act simultaneously, each turn in Diplomacy can be viewed as a normal-form game if there is a defined state value function. Moreover, since players are able to communicate before acting, it is possible for players' actions to be correlated. \begin{figure*}[ht!] \centering \begin{subfigure}[b]{.5\textwidth} \centering \includegraphics[width=\columnwidth]{figs/Diplomacy_7P_CCE_Spring.pdf} \end{subfigure}% \centering \begin{subfigure}[b]{.5\textwidth} \centering \includegraphics[width=\columnwidth]{figs/Diplomacy_7P_CE_Spring.pdf} \end{subfigure}% \caption{We benchmark greedy weights for computing both CCE and CE on the first turn of the seven-player game of Diplomacy which are computed by minimizing external and internal regret respectively. Greedy weights is significantly faster than in all cases considered, and when computing CCE, we find gains of several orders of magnitude. Note that both axes are logscale. Error bars denote $95\%$ confidence intervals. Additional plots for Diplomacy can be found in the Appendix.} \label{fig:diplomacyexperiments7P} \vspace{-10pt} \end{figure*} \begin{figure*}[!thb] \centering \begin{subfigure}[h!]{.5\textwidth} \centering \includegraphics[width=\columnwidth]{figs/FvA_Spring.pdf} \caption{Spring 1901 FvA} \label{fig:spring_fva} \end{subfigure}% \begin{subfigure}[h!]{.5\textwidth} \centering \includegraphics[width=\columnwidth]{figs/FvA_Fall.pdf} \caption{Fall 1902 FvA} \label{fig:fall_fva} \end{subfigure} \caption{We also benchmark greedy weights on a two-player zero-sum variant of diplomacy called France v. Austria. Greedy weights converges 2-3x faster than Linear RM for computing Nash equilibria in this setting. Exploitability is the $\epsilon$ of an $\epsilon$-Nash equilibrium. Note that the axes are both logscale. Error bars are at $95\%$ confidence.} \label{fig:diplomacyexperimentsFvA} \end{figure*} Prior work on no-press Diplomacy (the variant where players are unable to communicate) has achieved human-level performance by using regret matching on each turn to approximate equilibrium play for just the current turn~\cite{gray2021human}. In other words, each turn is viewed as a normal-form game in which the payoffs to each player for each joint action are determined via a pre-trained value network. Since queries to this value network are relatively expensive and the number of players in Diplomacy is large, mixed-policy techniques that do not use sampling are intractable. We run experiments on the computation of correlated equilibria and coarse correlated equilibria in Diplomacy. Additionally, we measure convergence to a Nash equilibrium in a two-player zero-sum variant of Diplomacy called France vs. Austria (FvA). In all of our Diplomacy experiments, each player chooses between the 10 actions that have highest probability in the publicly available policy network from~\citep{gray2021human}. We use the value network from~\citep{gray2021human} to determine payoffs. Our results in Figure~\ref{fig:diplomacyexperiments7P} indicate faster convergence to both a coarse-correlated and a correlated equilibrium when compared to Linear RM. In the case of CCE, greedy weights is orders of magnitude faster. Additionally, Figure~\ref{fig:diplomacyexperimentsFvA} demonstrates that in two-player zero-sum France vs. Austria subgames, greedy weights reaches the same level of convergence to a Nash equilibrium with 2-3x fewer iterations than Linear RM when using pure policies. Experiments in Diplomacy used a single CPU core and a single NVIDIA V100 GPU. The overhead time necessary for computing an optimal weight for greedy weights was negligible relative to the cost of querying the value neural network. \section{Conclusions and Future Work} \label{sec:limitations} \vspace{-0.05in} We introduce greedy weights, a novel generalization of the regret minimization framework for learning equilibria in which each new iteration is greedily weighed to minimize the procedure's average potential function (which is a function of all player's regret). In contrast, all prior regret minimization algorithms weighed iterates according to a fixed schedule. In randomly generated normal-form games, we demonstrate that greedy weights empirically converges to correlated equilibria several orders of magnitude faster than existing methods, as well as faster convergence to Nash in two-player zero-sum games. We also find that greedy weights tends to learn equilibria with higher social welfare than vanilla regret minimization methods in general-sum games. Finally, in the large-scale AI benchmark of Diplomacy, we show speedups in convergence to all of NE, CE and CCE compared to existing methods. Several important directions remain for future work. In this paper we focused our evaluation of greedy weights on strategic-form games. While we evaluated greedy weights on normal-form subgames of the sequential game Diplomacy, a natural question is whether similar results can be obtained for general sequential games that cannot be modeled as a sequence of normal-form games by extending greedy weights to counterfactual regret minimization~\cite{zinkevich2008regret}. We show some preliminary positive results in the Appendix for the sequential games of Kuhn and Leduc poker but describe several difficult remaining challenges in scaling to large sequential games, which we believe to be worthy of future investigation. Another interesting direction for future work is investigating alternative dynamic weighting schemes. In this paper we describe dynamically weighing iterates by greedily minimizing the potential function. This is the first regret minimization algorithm to be introduced that dynamically adjusts the weights of iterations based on information obtained at runtime. However, in theory there are numerous other ways to dynamically weigh the iterates, such as adjusting the weights of past iterates or searching ahead to future iterates. It remains to be seen whether other algorithms that dynamically weigh iterates can lead to even better performance. Finally, greedy weights (and regret minimization algorithms in general) cannot guarantee discovery of any \emph{particular} equilibrium. While we show that greedy weights tends to find CE in general-sum game with higher average welfare , the question of whether regret minimization procedures can be extended to find specific desired equilibria, such as Pareto optimal equilibria or the equilibrium that optimizes the sum of player utilities, remains open for resolution. \section{Old Bad Proof} Denote our player as $i$. \pyear{brown2019solving}, which in turn references \pyear{cesa2006prediction}, bounds the regret of weighted regret minimization, where iteration $t$ is given weight $w_t$, as \[ R_i^{w, T} \leq \frac{\triangle \sqrt{\lvert A \rvert} \sqrt{\sum_{t=1}^T w_t^2}}{\sum_{t=1}^T w_t} \] Because every weight chosen by Algorithm~\ref{mainalgorithm} will satisfy $1 \leq w_t \leq M$ by construction, we can immediately bound the right hand side with \[ \frac{\triangle \sqrt{\lvert A \rvert} \sqrt{\sum_{t=1}^T w_t^2}}{\sum_{t=1}^T w_t} \leq \frac{\triangle M \sqrt{\lvert A \rvert}}{\sqrt{T}} = O\left(\frac{1}{\sqrt{T}}\right) \] \section{Minimizing exploitability in zero-sum games with more than two players} While minimizing external regret is only guaranteed to converge to the set of Nash equilibria for two-player zero-sum games, researchers have found that in practice, it often also approximates the Nash equilibria of zero-sum games with larger number of players \citep{brown2019superhuman, gray2021human}. Given that greedy weights can significantly speed up regret minimization in such games, we ask the natural question of whether it can be used to approximate the Nash equilibria of zero-sum games with 3 or more players by speeding up external regret minimization. Figure~\ref{fig:exploitability} shows our results for randomly generated games with between 2 and 5 players. In two-player zero-sum games, exploitability and regret move down in lockstep, but in games with three or more players, the two measures diverge. Nevertheless, greedy weights sometimes finds approximate Nash equilibria with lower exploitability, though the gain is not nearly as large as the gains in minimizing external regret. \begin{figure*}[!htb] \centering \begin{subfigure}[b]{0.45\textwidth} \includegraphics[width=\textwidth]{figs/2P_Exploit.pdf} \end{subfigure} \hfill \begin{subfigure}[b]{0.45\textwidth} \captionsetup{labelformat=empty} \includegraphics[width=\textwidth]{figs/3P_Exploit.pdf} \end{subfigure} \hfill \begin{subfigure}[b]{0.45\textwidth} \captionsetup{labelformat=empty} \includegraphics[width=\textwidth]{figs/4P_Exploit.pdf} \end{subfigure} \hfill \begin{subfigure}[b]{0.45\textwidth} \captionsetup{labelformat=empty} \includegraphics[width=\textwidth]{figs/5P_Exploit.pdf} \end{subfigure} \caption{We check the relationship between (external) regret and exploitability (distance to a Nash equilibrium) in zero-sum games with between $2-4$ players. Each of these graphs depicts a single run of vanilla and greedy regret minimization in the games described. In a two-player zero-sum game (left), regret and exploitability decrease in lockstep as guaranteed by Theorem 7.2 in \citep{cesa2006prediction}. Despite the lack of theoretical guarantees for any game with three or more players, we observed that greedy weights sometimes finds an approximate Nash equilibrium with lower exploitability than vanilla regret minimization methods. Nevertheless, such gains are far smaller than the gains in accelerated regret minimization and not always guaranteed.} \label{fig:exploitability} \end{figure*} \clearpage \section{Convergence Speed As a Function of Game Size} In this experiment we generate general-sum games with various numbers of moves and measure the number of timesteps before greedy weights achieves regret an order of magnitude below (10x) vanilla regret minimization. Figure~\ref{fig:10xgraph} shows the average timesteps over 10 randomly generated 3-player general sum games and shows that, all else held equal, it takes greedy weights a longer time to ``pull away'' from the vanilla regret minimization as the number of moves increases. \begin{figure}[!h] \centering \includegraphics[width=\columnwidth]{figs/iterations_vs_moves.pdf} \vspace{-0.3in} \caption{Average number of iterations until 10x gain across $50$ randomly generated $3$-player games with various numbers of actions per player.} \vspace{-0.15in} \label{fig:10xgraph} \end{figure} \clearpage \section{Choice of Objective Function} \begin{figure}[h!] \centering \includegraphics[width=\columnwidth]{figs/hart.png} \caption{Minimizing the potential function performs similarly to minimizing the sum of player's regrets, suggesting that greedy weights is robust to other choices of which objective to minimize.} \label{fig:objective-function} \end{figure} For the main experiments, we minimize the sum of every player's potential function. One could also imagine that directly minimizing the sum of player's positive regrets, which directly determine the distance to an equilibrium, might be a reasonable choice. Figure~\ref{fig:objective-function} suggests that greedy weights is robust to the choice of whether to minimize the potential or the sum of regrets in randomly generated seven-player general-sum games. In our main experiments, we opt for minimizing potential because better theoretical properties which we use to prove Theorem~\ref{mainproposition}. \clearpage \section{Computing the Optimal Weight} \begin{figure}[h!] \centering \includegraphics[width=\columnwidth]{figs/weights_vs_dynamic.pdf} \caption{We measure the convergence rate as a function of the number of weights (for each iteration) considered during the greedy weights procedure by running greedy weights for $5000$ iterations across $10$ randomly generated $7$-player general-sum games. A dynamic range of $1$ is equivalent to vanilla regret minimization. This experiment suggests that adaptively selecting the weight is the primary cause of the gains observed in greedy weights rather than selecting the optimal weight.} \label{fig:how-many-guesses} \end{figure} Another natural question for greedy weights is how important choosing the optimal weight is. Figure~\ref{fig:how-many-guesses} picks the weight for each iteration by sweeping across logarithmically spaced candidate weights between $1$ and $T^2$ instead of computing the optimal weight at each iteration. The fact that considering even a small number of guesses already substantially improves the rate of regret minimization convergence by several orders of magnitude suggests that the important aspect of our algorithm is the fact that we are greedily up or down weighting iterations based on regret, rather than finding the optimal weight. \clearpage \section{Greedy Weights in N-player Games} \label{sec:greedyresultsdump} For space reasons, we were only able to show a small portion of our full experiments with greedy weights. Figure~\ref{fig:10-other-normal-form} shows our experiments for minimizing internal regret on randomly generated general games with between $2$ and $6$ players and $10$ actions per player below. \begin{figure}[!h] \centering \includegraphics[width=0.45\columnwidth]{figs/2P-10A-general-pure-5000I-42S-INTERNAL-hart.pdf} \includegraphics[width=0.45\columnwidth]{figs/3P-10A-general-pure-5000I-42S-INTERNAL-hart.pdf} \includegraphics[width=0.45\columnwidth]{figs/4P-10A-general-pure-5000I-42S-INTERNAL-hart.pdf} \includegraphics[width=0.45\columnwidth]{figs/5P-10A-general-pure-5000I-42S-INTERNAL-hart.pdf} \includegraphics[width=0.45\columnwidth]{figs/6P-10A-general-pure-5000I-42S-INTERNAL-hart.pdf} \caption{Greedy weights accelerates the convergence over vanilla regret matching for a variety of games. Here, we show results for randomly generated general-sum games with $2-6$ players and $10$ actions per player. Each plot is averaged over $10$ randomly generated games with different seeds and error bars at at $95\%$ confidence.} \label{fig:10-other-normal-form} \end{figure} \clearpage \section{Extensions to Counterfactual Regret Minimization} \label{sec:extensive_form} While greedy weights was designed to solve normal-form games faster, a natural question is whether it can be applied to counterfactual regret minimization techniques for solving extensive-form games without having to resort to using normal-form subgame approximations as typically done with large games like Diplomacy \cite{gray2021human}. We conduct some preliminary experiments on Kuhn \cite{kuhn20169} and Leduc poker \cite{southey2012bayes} which are simplified versions of classic Texas hold'em poker via the OpenSpiel library \cite{lanctot2019openspiel}. In our experiments, the objective function being minimized is the sum of all local potential functions at all infosets. Ideally, we would like to be able to choose a different iteration weight for each infoset of the game, but retaining the theoretical guarantees of convergence rates via Theorem~\ref{mainproposition} requires that the weighting used for all infosets on a given iteration must be equal. Empirically, consistent with our normal-form experiments with two-player zero-sum games described in Appendix~\ref{sec:weight_floor}, we find that setting a relatively high weight floor works best. Experiments described in Figure~\ref{fig:cfr} were run with a minimum weight floor of $100\%$ of the average weight accrued thus far. Figure~\ref{fig:efg-weightfloor} describes the results for various floor amounts in Kuhn Poker. While the results for Leduc and Kuhn poker depicted in Figure~\ref{fig:cfr} are promising, this extension of greedy weights to extensive-form games requires expanding out all chance nodes in stochastic games where the payoff is sampled from the distribution. Without doing so, in such a setting, greedy weights might upweight ``lucky'' iterations where the stochastic outcomes are particularly good for the players, which would lead to bias in the samples. Note that this problem is unique to dynamic weighting schemes like ours and does not apply for any fixed iterate weighting scheme like vanilla or Linear CFR where the stochastic samples eventually cancel themselves out in the limit. State of the art solvers that scale to the full game of poker typically use MCCFR methods that often only expand out a small number of chance nodes per iteration of CFR \cite{brown2018superhuman, brown2019deep, brown2019solving}. The question of how iterates can be weighed dynamically in such a setting without incurring bias remains open, and we believe that it is a exciting direction for future research. \begin{figure}[h!] \centering \includegraphics[width=0.49\linewidth]{figs/cbb2d135-e497-4901-b6c8-e6ac825c97ff.png} \includegraphics[width=0.49\linewidth]{figs/3ee86e24-a27e-479f-a9de-a67a4d7b58f0.png} \caption{We test out various weight floors in both Kuhn and Leduc Poker when applying the greedy weights algorithm to counterfactual regret minimization. Consistent with the results for two-player zero-sum games in Appendix~\ref{sec:weight_floor}, we find that a relatively high floor is useful for improving convergence in such games.} \label{fig:efg-weightfloor} \end{figure} \begin{figure}[hbt!] \centering \includegraphics[width=0.49\linewidth]{figs/KUHN_PAPER.png} \includegraphics[width=0.49\linewidth]{figs/LEDUC_PAPER.png} \caption{The left figure shows greedy weight when evaluated on Kuhn Poker. The right shows the same except for Leduc poker.} \label{fig:cfr} \end{figure} \clearpage \section{Ablations on the Weight Floor in Normal-Form Games} \label{sec:weight_floor} In Section~\ref{sec:experiments}, we suggested that in two-player zero-sum games, greedy weights benefited from a weight floor of $50\%$ of the average weight so far to improve convergence the procedure from getting stuck. Figure~\ref{fig:generalweightfloor} shows the result of several ablations on the optimal weight floor in general-sum games. In general-sum games, we find that weight floors that are too high cause unstable convergence, as greedy weights is no longer able to discard ``bad'' iterations from the regret minimization procedure. In contrast, we find that the choice of weight floor is robust to performance differences as long as it is relatively low. As such, we choose not to use a weight floor in our main experiments with general-sum games. In two-player zero-sum games, a weight floor appears to be beneficial when computing a minimax equilibrium (i.e., minimizing external regret). When minimizing internal regret, we find that a small weight floor is preferred, consistent with the results for general-sum games in Figure~\ref{fig:generalweightfloor}. However, when minimizing external regret, we find that a somewhat higher weight floor of 50\% to 100\% of the average iteration weight is helpful for achieving fast convergence. \begin{figure}[h!] \centering \includegraphics[width=0.33\linewidth]{figs/Screen_Shot_2021-05-27_at_8.47.29_PM.png} \includegraphics[width=0.33\linewidth]{figs/Screen_Shot_2021-05-27_at_8.47.37_PM.png} \includegraphics[width=0.33\linewidth]{figs/50move.png} \caption{When minimizing internal regret (left), a low weight floor performs best, consistent with the results in Figure~\ref{fig:generalweightfloor}. However, when minimizing external regret (middle and right), we find that having a relatively high weight floor is helpful in ensuring rapid convergence, but that even in the case where no weight floor is used (right), greedy weights still performs well relative to existing methods.} \label{fig:zerosumweightfloor} \end{figure} \begin{figure}[h!] \centering \begin{minipage}{.5\textwidth} \centering \includegraphics[width=\linewidth]{figs/floor_2PGS.pdf} \end{minipage}% \begin{minipage}{.5\textwidth} \centering \includegraphics[width=\linewidth]{figs/floor_7PGS.pdf} \end{minipage} \caption{We examine a variety of potential weight floors for regret minimization (averaged across 10 randomly generated games) and find that large weight floors cause instability in the training procedure, while small weight floors seem to be the fastest in terms of convergence.} \label{fig:generalweightfloor} \end{figure} \clearpage \section{Ablations on Weight Floor for Diplomacy Subgames} We also run weight floor ablations for the France v. Austria subgame and find similar results to the experiments for normal-form games described in a previous section of the Appendix. The results are depicted in Figure~\ref{fig:fvaweightfloor}. \begin{figure}[h!] \centering \includegraphics[width=0.49\linewidth]{figs/FvA_Floor_Spring.pdf} \includegraphics[width=0.49\linewidth]{figs/FvA_Floor_Fall.pdf} \caption{When minimizing external regret in France v. Austria, we find that a weight floor between $25\%$ and $100\%$ performs best. Confidence intervals at 95\%. The left figure depicts the start of the France v. Austria game, while the right figure depicts a subgame partway through the game.} \label{fig:fvaweightfloor} \end{figure} \clearpage \section{Experiments with the Double Oracle Algorithm} In games with an extremely large action set, one popular approach to reduce the complexity necessary to solve the game is the double oracle method \citep{mcmahan2003planning}. With the double oracle algorithm, additional actions are added one by one as needed into the regret minimization procedure instead of considering the full set of actions all at once at the start of the game. We introduce two changes to the double oracle algorithm that we demonstrate significantly improve convergence speed. First, we use greedy weights in place of vanilla regret matching, as has typically been done throughout this paper. Secondly, we seed the first iteration of the next round of the double oracle algorithm with the approximate equilibria discovered in the latest round of regret minimization. Experiments in the main paper and in Appendix~\ref{sec:greedyresultsdump} already show that greedy weights converges faster than vanilla regret minimization methods. We find that this carries over to experiments with double oracle. Furthermore, seeding the previous equilibrium discovered as the first iteration of the next regret minimization procedure provides additional gains when combined with greedy weights. This improvement is much larger than the improvement from seeding in vanilla regret matching. In vanilla regret matching, the procedure will quickly drift away from the initial moves, even if it is already very close to a Nash equilibrium, because of the fixed weighting scheme. On the other hand, greedy weights can properly weight future iterations to properly utilize seeding the regret minimization procedure closer to the equilibrium by placing lower weights on future iterations if necessary. Our empirical results are shown in Figure~\ref{fig:doubleoracle}. \begin{figure}[h!] \centering \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/DO_100M_2P_0.05T_0S_True.pdf} \end{minipage}% \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/DO_50M_2P_0.05T_0S_True.pdf} \end{minipage} \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/DO_50M_2P_0.1T_0S_True.pdf} \end{minipage} \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/DO_50M_3P_0.1T_0S_True.pdf} \end{minipage} \caption{We run double oracle and include our changes of greedy weights and seeding the previously discovered into the next iteration of double oracle. Seeding does little for vanilla regret minimization but results in substantial improvements when combined with greedy weights. $\epsilon$ measures the distance to a Nash Equilibrium. Confidence intervals are at 95\% confidence.} \label{fig:doubleoracle} \end{figure} \clearpage \section{Cooperative Settings Converge Faster} We hypothesize a relationship between how cooperative a game is and how quickly greedy weights converges to an equilibrium. Figure~\ref{fig:cooperative} shows the result of an empirical analysis. The game theory literature has long known \citep{kalai_engineering_2013} that the payoff matrix for every game can be uniquely decomposed into the sum of a zero-sum game and a purely cooperative game where all players share the same payoffs. Denoting $A_1 \cdots A_N$ as the payoff matrices for each of the $N$ players of the game, we can write $Z_1 \cdots Z_N$ and $C$ as the payoff matrices for the zero-sum and the cooperative game respectively. \[ Z_n = A_n - \frac{\sum{i=1}^N A_i}{N}, C = \frac{\sum{i=1}^N A_i}{N} \] We measure how adversarial a game G is by performing the above decomposition and computing $\frac{\norm{Z}}{\norm{G}}$ where the norm is the Frobenius Norm of that game’s payoff matrix. A purely zero-sum game will be decomposed such that C is a zero-matrix, while a purely cooperative game will have Z be a zero-matrix, so all games will be scored between 0 and 1, where 1 indicates that the game is purely zero-sum and 0 indicates that the game is purely cooperative. We randomly generate games along the entire spectrum of this measure by generating random zero-sum and cooperative games at random via the procedure described in Section~\ref{sec:experiments} and interpolating between the two. We plot the regret after running $1000$ iterations of regret matching with greedy weights as a function of the zero-sum score of the game and find a strong positive correlation. This also applies to vanilla regret matching, though the effect is much smaller in magnitude. \begin{figure}[tbh!] \centering \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/2P_50M_1000I_0S.png} \end{minipage}% \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/4P_10M_1000I_0S.png} \end{minipage} \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/7P_10M_1000I_0S.png} \end{minipage} \begin{minipage}{.49\textwidth} \centering \includegraphics[width=\linewidth]{figs/7P_10M_1000I_0S_Vanilla.png} \end{minipage} \caption{All figures except the bottom right show regret matching with greedy weights across a variety of games. All games elicit a strong positive correlation between how adversarial the game is and how high the regret remains after $1000$ iterations of regret minimization. The bottom-right figure shows that this effect is also true, but much less strongly so, for vanilla regret matching as well.} \label{fig:cooperative} \end{figure} Theoretical analysis of regret matching that improves the $O(\frac{1}{\sqrt{T}})$\, bound has proved difficult, despite a wealth of empirical evidence suggesting that the bound is loose in practice. Nevertheless, there is reason to believe that this correlation is no accident. Fully cooperative games are known to always admit a pure Nash equilibrium \citep{monderer1996potential}, and thus, regret matching with greedy weights will converge asymptotically after only a constant number of iterations, since greedy weights will give infinite weight to the pure equilibrium the moment it is discovered and the size of the game is constant with respect to the number of iterations run. On the other hand, zero-sum games are more similar to the adversarial case where Theorem~\ref{mainproposition} proves that convergence can occur no faster than $O(\frac{1}{\sqrt{T}})$\, \footnote{There are some subtle differences in that the adversary in Theorem~\ref{mainproposition} is more powerful than an opponent in a two-player zero-sum game in that she is able to pick \emph{any} regret vector for each timestep without the constraints of picking from the game matrix.}. As a partial toy example for why vanilla regret matching is unable to take as much advantage from cooperative game settings as greedy weights, imagine a two-player game with $N$ moves where player one is a dummy and receives equal utility from all possible game states and each entry of player two’s reward matrix is drawn uniformly at random from the interval $[0, 1]$. If they both play according to vanilla regret minimization, our dummy player will choose moves randomly so the central limit theorem guarantees that the regret can proceed no faster than $O(\frac{1}{\sqrt{T}})$\,. However, if greedy weights is used, the procedure will converge to an equilibrium at a worst case rate of $\frac{1}{T}$, simply because the expected number of samples before stumbling upon an entry in the interval $[1 - \epsilon, 1]$ is $O(\frac{1}{\epsilon})$. In practice, greedy weights converges even faster than this toy example because regret matching because general-sum games tend to have better than random samples for the next possible move as players learn to cooperate. While further work must be done to explain the convergence of games that are neither purely cooperative nor purely adversarial, we suspect that further study in this direction may lead to a long sought understanding of why regret matching performs so well in practice, even though its asymptotic bound is substantially worse than other methods. \clearpage \section{Additional Diplomacy Plots} We include several plots for minimizing external and internal regret for a subgame in the middle of the Diplomacy game. \begin{figure*}[ht!] \centering \begin{subfigure}[b]{.45\textwidth} \centering \includegraphics[width=\columnwidth]{figs/Diplomacy_7P_CCE_Fall.pdf} \caption{Midgame CCE Computation} \label{fig:fall_cce} \end{subfigure} \centering \begin{subfigure}[b]{.45\textwidth} \centering \includegraphics[width=\columnwidth]{figs/Diplomacy_7P_CE_Fall.pdf} \caption{Midgame CE Computation} \label{fig:fall_ce} \end{subfigure} \caption{We benchmark greedy weights for computing both CCE and CE on a turn in the middle of the game of Diplomacy, which are computed by minimizing external and internal regret respectively. Greedy weights is significantly faster than in all cases considered, and when computing CCE, we find gains of several orders of magnitude. Note that both axes are logscale. Error bars denote $95\%$ confidence intervals. } \label{fig:diplomacyexperiments7Pappendix} \vspace{-10pt} \end{figure*} \clearpage \section{Regret Minimization with Greedy Weights on Normal-Form Games in the OpenSpiel Library} \begin{figure}[!htb] \centering \includegraphics[width=0.45\columnwidth]{figs/matrix-cd.png} \includegraphics[width=0.45\columnwidth]{figs/matrix-coordination.png} \includegraphics[width=0.45\columnwidth]{figs/matrix-mp.png}\ContinuedFloat \includegraphics[width=0.45\columnwidth]{figs/matrix-rps.png} \includegraphics[width=0.45\columnwidth]{figs/matrix-pd.png} \includegraphics[width=0.45\columnwidth]{figs/matrix-rpsw.png} \end{figure} \begin{figure}[!htb] \centering \ContinuedFloat \includegraphics[width=0.45\columnwidth]{figs/matrix-sh.png}\ContinuedFloat \includegraphics[width=0.45\columnwidth]{figs/matrix-shapleys-game.png} \includegraphics[width=0.45\columnwidth]{figs/matching-pennies-3p.png} \caption{We run greedy weights on all real-world normal-form games included in the popular game theory library OpenSpiel \cite{lanctot2019openspiel} and find that greedy weights exceeds the performance of prior methods on all games evaluated.} \label{fig:openspielgames} \end{figure} \clearpage \section{Description of Diplomacy} In this section we summarize the rules of Diplomacy. A more detailed description can be found in~\cite{paquette2019no}. No-press Diplomacy is a 7-player zero-sum board game in which players compete to control a majority of the 34 \emph{supply centers} (SCs). The map contains 75 locations, only some of which are SCs. At the start of the game, players control only 3-4 units and 3-4 SCs. At any point prior to a player gaining control of a majority of SCs, all remaining players may agree to a draw. In that case, the game ends and players receive a score of $C_i^2 /\sum_{i'}C_{i'}^2$, where $C_i$ is the number of SCs that player~$i$ controls. Each turn, all players simultaneously assign one order to each of their units. Valid orders for a unit include holding the unit stationary, moving the unit to an adjacent location, supporting another unit's move, moving across water via a convoy, or convoying another unit across water. In this paper we consider specifically the \emph{no-press} variant of Diplomacy, in which player cannot communicate. In the full game, all players may communicate via private pairwise cheaptalk channels. Since the game state in no-press Diplomacy is fully observable after each turn, the game can be viewed as a series of normal-form games, where the rows in the matrix corresponds to players' actions. Therefore, given a value function, each normal-form game can be viewed as its own subgame. \clearpage \section*{Checklist} \begin{enumerate} \item For all authors... \begin{enumerate} \item Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope? \answerYes{} \item Did you describe the limitations of your work? \answerYes{See Section~\ref{sec:limitations}} \item Did you discuss any potential negative societal impacts of your work? \answerNA{Our work is a general method for solving games. While general methods can always be used for both beneficial and harmful purposes, we believe our work to too broadly applicable to discuss specific negative societal impacts.} \item Have you read the ethics review guidelines and ensured that your paper conforms to them? \answerYes{} \end{enumerate} \item If you are including theoretical results... \begin{enumerate} \item Did you state the full set of assumptions of all theoretical results? \answerYes{See Section~\ref{sec:approach}} \item Did you include complete proofs of all theoretical results? \answerYes{See Section~\ref{sec:approach} and Appendix~\ref{sec:mainpropproof}} \end{enumerate} \item If you ran experiments... \begin{enumerate} \item Did you include the code, data, and instructions needed to reproduce the main experimental results (either in the supplemental material or as a URL)? \answerYes{Code will be uploaded in supplementary materials.} \item Did you specify all the training details (e.g., data splits, hyperparameters, how they were chosen)? \answerYes{We give a detailed report in the experimental section and include the code for most experiments in the supplementary materials.} \item Did you report error bars (e.g., with respect to the random seed after running experiments multiple times)? \answerYes{We report $95\%$ confidence intervals on all the major experimental results.} \item Did you include the total amount of compute and the type of resources used (e.g., type of GPUs, internal cluster, or cloud provider)? \answerYes{See Section~\ref{sec:experiments}. Our experiments did not require substantial computational resources. Random matrix experiments were run on a single CPU core of a Macintosh laptop. Diplomacy experiments were run on a single CPU core and a single NVIDIA V100 GPU. We described the resources in Section~\ref{sec:experiments}.} \end{enumerate} \item If you are using existing assets (e.g., code, data, models) or curating/releasing new assets... \begin{enumerate} \item If your work uses existing assets, did you cite the creators? \answerYes{} \item Did you mention the license of the assets? \answerNA{} \item Did you include any new assets either in the supplemental material or as a URL? \answerNA{} \item Did you discuss whether and how consent was obtained from people whose data you're using/curating? \answerNA{} \item Did you discuss whether the data you are using/curating contains personally identifiable information or offensive content? \answerNA{} \end{enumerate} \item If you used crowdsourcing or conducted research with human subjects... \begin{enumerate} \item Did you include the full text of instructions given to participants and screenshots, if applicable? \answerNA{} \item Did you describe any potential participant risks, with links to Institutional Review Board (IRB) approvals, if applicable? \answerNA{} \item Did you include the estimated hourly wage paid to participants and the total amount spent on participant compensation? \answerNA{} \end{enumerate} \end{enumerate} \section{Convergence Proof for Theorem~\ref{mainproposition}} \label{sec:mainpropproof} To simplify the proofs, we rescale the weights after each iteration so that $\sum_{t\leq T} w^t = T$. This has no effect on the strategies played or the weighted average regret. Let $A_I = \max_{i \in \mathcal{P}} |A_i|$. \begin{proof} Let $\Phi$ be the cumulative potential function for greedy weights on iteration $t$ for player~$i$. Let ${\bf R}_i^T$ be the regret vector for player~$i$ on iteration~$T$ and let $r_i^{T+1}$ be the new regret vector from iteration $T+1$ to be added to ${\bf R}_i^T$. In external regret matching, $$\Phi({\bf R}_i^T) = \sum_{a_i \in A_i} R_+^t(a_i)^2$$ In internal regret matching, $$\Phi({\bf R}_i^T) = \sum_{a_i^A, a_i^B \in A_i} R_+^T(a_i^A, a_i^B)^2$$ We will prove by induction that \begin{equation} \sum_{i \in \mathcal{P}} \Phi({\bf R}_i^T) \le |P| C T \label{eqn:cond_regret} \end{equation} for a constant $C$ that depends only on the game and on the regret minimization algorithm used. From \pyear{cesa2006prediction} (Theorem 2.1) we know that $\Phi({\bf R}_i^{T+1}) \le \Phi({\bf R}_i^{T}) + C$ whenever external or internal regret matching is played on iteration $T+1$. For external regret matching, $C = \Delta^2 |A_I|$. For internal regret matching, $C = \Delta^2 |A_I|^2$. This result holds regardless of the sequence of actions that took place up to $T$. \begin{align} \sum_{i \in P} \Phi({\bf R}^T_i + r^{T+1}_i) & \leq |P|CT + |P|C \leq |P|C(T+1) \hspace{1cm} \\ \sum_{i \in P} \frac{\Phi({\bf R}^T_i + r^{T+1}_i)}{(T+1)^2} & \leq \frac{|P|C}{T+1} \\ \min_{w^{T+1}} \sum_{i \in P} \frac{\Phi({\bf R}^T_i + w^{T+1} r^{T+1}_i)}{(T + w^{T+1})^2} & \leq \frac{|P|C}{T + 1} \hspace{1cm} \textrm{($w^{T+1}$ selected by Algorithm~\ref{mainalgorithm})} \\ \sum_{i \in P} \frac{w'^2\Phi({\bf R}^T_i + w^{T+1} r^{T+1}_i)}{w'^2(T + w^{T+1})^2} & \leq \frac{|P|C}{T + 1} \hspace{1cm} \textrm{Rescaling }w' = \frac{T+1}{T+w^{T+1}} \label{eqn:reweight_generic} \\ \sum_{i \in P} \frac{\Phi(w' {\bf R}^T_i + w' w^{T+1} r^{T+1}_i)}{(T+1)^2} & \leq \frac{|P|C}{T + 1} \\ \sum_{i \in P} \Phi(w' {\bf R}^T_i + w' w^{T+1} r^{T+1}_i) & \leq |P|C (T + 1) \\ \label{eqn:weighted_generic} \end{align} \end{proof} which satisfies Eq. (\ref{eqn:cond_regret}) for $T+1$. It's also clear that $\sum_{t\leq T+1} w^t = T+1$ from the reweighting procedure in (\ref{eqn:reweight_generic}). This completes the proof. Finally, we can derive the weighted average regret. For external regret, this is: \begin{align} \sqrt{ \sum_{a_i \in A_i} \max(0, \sum_{t\leq T} w^t r^t(a_i))^2} & \leq \sqrt{\sum_{i\in P} \sum_{a_i \in A_i} \max(0, \sum_{t\leq T} w^t r^t(a_i))^2} \\ & \leq \sqrt{\Delta^2 |P| A_I T} \hspace{1cm} \textrm{(From (\ref{eqn:cond_regret}))}\\ \sum_{a_i \in A_i} \max(0, \sum_{t\leq T} w^t r^t(a_i)) & \leq \sqrt{\Delta^2 |P| A_I T} \hspace{1cm} \textrm{(Jensen's inequality)}\\ \sum_{a_i \in A_I} \sum_{t \leq T} w^t r^t(a_i) & \leq \sqrt{\Delta^2 |P| A_I T} \\ \bar{R}_i^T(a_i) = \frac{\sum_{a_i \in A_i} \sum_{t\leq T} w^t r^t(a_i)}{\sum_{t\leq T} w^t} & \leq \sqrt{\frac{\Delta^2 |P| A_I}{T}} \end{align} For internal regret, this is: \begin{align} \sqrt{ \sum_{a_i^A, a_i^B \in A_i} \max(0, \sum_{t\leq T} w^t r^t(a_i^A, a_i^B))^2} & \leq \sqrt{\sum_{i\in P} \sum_{a_i^A, a_i^B \in A_i} \max(0, \sum_{t\leq T} w^t r^t(a_i^A, a_i^B))^2} \\ & \leq \sqrt{\Delta^2 |P| A_I^2 T} \hspace{1cm} \textrm{(From (\ref{eqn:cond_regret}))}\\ \sum_{a_i^A, a_i^B \in A_i} \max(0, \sum_{t\leq T} w^t r^t(a_i^A, a_i^B)) & \leq \sqrt{\Delta^2 |P| A_I^2 T} \hspace{1cm} \textrm{(Jensen's inequality)}\\ \sum_{a_i^A, a_i^B \in A_I} \sum_{t \leq T} w^t r^t(a_i^A, a_i^B) & \leq \sqrt{\Delta^2 |P| A_I^2 T} \\ \bar{R}_i^T(a_i^A, a_i^B) = \frac{\sum_{a_i^A, a_i^B \in A_i} \sum_{t\leq T} w^t r^t(a_i^A, a_i^B)}{\sum_{t\leq T} w^t} & \leq \sqrt{\frac{\Delta^2 |P| A_I^2}{T}} \end{align} If each player's weighted average regret is bounded by $\epsilon$, then the weighted average policy is an $\epsilon$-equilibrium \cite{hart2000simple}. \section{Related Work} \subsection{Weighting Schemes} While the original regret minimization framework proposed by \pyear{blackwell1956analog} and \pyear{hannan1957approximation} weight all iterations of the regret minimization procedure equally, some recent work has explored the idea of weighting different iterations differently. \pyear{brown2019solving} gives convergence rate bounds and runs experiments for several (fixed) weighting schemes for the regret minimization and show that empirically, this can also lead to speed improvements in many large, sequential, two-player zero-sum games. Our work generalizes this concept by allowing the procedure itself to determine the weighting of each iteration \emph{at runtime} and extending the experiments to games with more than two players and with general sum payoff functions. \subsection{Improving Regret Minimization} A substantial amount of work over the last decade has focused on improving (external) regret minimization techniques in two-player zero-sum games, with a special eye towards the variant of regret minimization for large sequential games: CFR \citep{zinkevich2008regret}. We examine several of these variants, including CFR+ \citep{tammelin2014solving}, Linear CFR \citep{brown2019solving}, optimism \citep{syrgkanis2015fast}, and alternating updates \citep{tammelin2014solving} and describe their inner workings in more detail in Sections~\ref{sec:approach} and \ref{sec:experiments}. \subsection{Correlated Equilibria} The correlated equilibrium is one of the leading solution concepts for multiplayer games. Unlike the Nash equilibrium, it requires some sort of correlated device or common source of randomness seen by all players. However, in exchange and unlike the Nash equilibrium solution concept, it is computationally tractable and furthermore can be learned via simple procedures that are plausible for real-world agents to follow \citep{hart2000simple}. Recent work has extended such results to large sequential games, where players can undertake multiple moves in sequence instead of all moving simultaneously \citep{celli2020no}. We leave to future work whether greedy weights can be applied to accelerate regret minimization in such sequential games. While polynomial time algorithms based on linear programming have long been known for computing correlated equilibria \citep{papadimitriou2008computing}, they are relatively slow in practice. This is because, in practice, regret minimization is sublinear with respect to the matrix, while other methods are polynomial at best. \subsection{Sampled Strategies v. Monte Carlo CFR} Our requirement that players play pure strategies at each iteration is related but not identical, to prior work using Monte-Carlo methods for regret minimization (e.g. MC-CFR) \citep{lanctot2009monte, lanctot2013monte}. In MC-CFR, players play a mixed strategy at each timestep, but their regrets are estimated via sampling outcomes rather than computed exactly. As such, the calculated regrets serve only as an approximation of the true regrets. When requiring each iteration to consist of pure strategies, the sampling takes place on the player's side in that they must sample a pure strategy to play, after which they receive their exact regrets based on what they actually played. As such, the regrets we calculate are exact and if the maximum internal regret of any player is $\epsilon$, then we immediately have a $2\epsilon$-correlated equilibria. \subsection{Relationship to Online Machine Learning} Regret minimization has many applications to (and has drawn many lessons from) other fields including online machine learning and predictions of arbitrary sequences. In particular, past work has demonstrated very strong relationships between the concepts of regret minimization and online machine learning \citep{cesa2006prediction, abernethy2011blackwell}. In our application of discovering equilibria in games, we allow the procedure itself to determine the weight of each iterations. Note that in other settings where regret minimization might be applied (e.g. sequence prediction), this would \emph{not} be a reasonable allowance because it would be akin to upweighting low regret iterations (where you predicted correctly) and downweighting times when you made a mistake. However, in the self play setting for discovering the equilibria of games, each ``agent'' is a construction we use to find equilibria and we are thus uninterested in any given agent's performance, only that the overall regret of the algorithm goes to 0 as quickly as possible. As a result, we do precisely what we would not be allowed to do in any online machine learning setting: we upweight iterations that minimize overall regret for agents in the game, and downweight those that do not.
{'timestamp': '2022-04-12T02:29:50', 'yymm': '2204', 'arxiv_id': '2204.04826', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04826'}
arxiv
\section{Hybrid Probabilistic Scheme} \label{sec:appendix} We provide the Hybrid Probabilistic Fingerprinting Scheme in Algorithm~\ref{alg:hpfs}. \begin{algorithm}[h] \footnotesize \SetKwInOut{Input}{input} \SetKwInOut{Output}{output} \Input{Trajectory $\mathcal{X^*}=[x^*_1,x^*_2,\dots,x^*_m]$, location alphabet $\mathcal{G}$, occurrence probability $Pr[g_p]$ and transition probability $Pr[g_q|g_r]$ for any locations $g_p, g_q, g_r \in \mathcal{G}$, probability threshold $\tau$, fingerprinting ratio $p$, ratio balancing factor $\theta$, the first fingerprinted trajectory $\mathcal{X^o}=[x^o_1,x^o_2,\dots,x^o_m]$, the Boneh-Shaw codeword indexes $BSI = [B_1, B_2, ..., B_{bc * bs}]$ and their corresponding fingerprinting boolean flags $BSF = [F_1, F_2, ..., F_{bc * bs}]$} \Output{Fingerprinted trajectory $\mathcal{X}'=[x'_1,x'_2,\dots,x'_m]$} \uIf{$1 \in BS$}{ \uIf{$F_1 == true$}{ $x'_1 \leftarrow x^o_1$ \; } \uElse{ $x'_1 \leftarrow x^*_1$ \; } } \uElse{ $PD \leftarrow$ $Pr[x'_1 = x^*_1] = 1 - p_{current}, Pr[x'_1 = g] = \frac{Pr[g]}{\sum_{g'\in \mathcal{G} \backslash x^*_1 } Pr[g']}, g\in \mathcal{G}$\; $x'_1 \leftarrow$ sample from $PD$\; } $p_{current} = p$\; \ForAll{$j \in 2, 3, \dots, m$}{ \uIf{$j \in BSI$}{ \uIf{$F_j == true$}{ $x'_j \leftarrow x^o_j$ \; } \uElse{ $x'_j \leftarrow x^*_j$ \; } continue \; } $prob_\tau(x'_{j-1}) \leftarrow \tau$-probable set of $x'_{j-1}$\; $prob_\tau^c(x'_{j-1}) \leftarrow \{g| \lVert g, x^*_j \rVert_2 \leq \lVert x'_{j-1} , x^*_j\rVert_2, g \in prob_\tau(x'_{j-1})\}$\; \uIf{$x^*_j \in prob^c_\tau(x'_{j-1})$ and $|prob_\tau^c(x'_{j-1})| > 1$}{ $PD \leftarrow$ $Pr[x'_j = x^*_j] = 1 - p, Pr[x'_j = g] = \frac{Pr[x'_j = g | x'_{j-1}]}{\sum_{g'\in prob_\tau(x'_{j-1}) \backslash x^*_j} Pr[x'_j = g' | x'_{j-1}]} * p , g \in prob_\tau^c(x'_{j-1})$\; $x'_j \leftarrow$ sample from $PD$\; } \uElseIf{$x^*_j \in prob_\tau(x'_{j-1})$ and $|prob_\tau^c(x'_{j-1})| == 1$}{ $PD \leftarrow$ $Pr[x'_j = x^*_j] = 1 - p, Pr[x'_j = g] = \frac{Pr[x'_j = g | x'_{j-1}]}{\sum_{g'\in prob_\tau(x'_{j-1}) \backslash x^*_j} Pr[x'_j = g' | x'_{j-1}]} * p , g \in prob_\tau(x'_{j-1})$\; $x'_j \leftarrow$ sample from $PD$\;} \uElse{ $x_{closest} \leftarrow $ closet point to $x^*_j$ in $ prob_\tau(x'_{j-1})$\; \uIf{$|prob_\tau(x'_{j-1})| <= 1$}{ $x'_j \leftarrow x^*_j$\; } \uElse{ $PD \leftarrow$ $Pr[x'_j = x_{closest}] = 1 - p, Pr[x'_j = g] = \frac{Pr[x'_j = g | x'_{j-1}]}{\sum_{g'\in prob_\tau(x'_{j-1}) \backslash x_{closest}} Pr[x'_j = g' | x'_{j-1}]} * p, g \in prob_\tau(x'_{j-1})$\; $x'_j \leftarrow$ sample from $PD$\; } } \uIf{$j$ mod $\lceil \frac{1}{p} \rceil == 0$}{ $count \leftarrow$ \# of fingerprinted positions\; \uIf{$count > p * j$}{ $p_{current} \leftarrow p * (1-\theta)$\; }\uElseIf{$count < p * j$}{ $p_{current} \leftarrow p * (1+\theta)$\; }\uElse{ $p_{current} \leftarrow p$\; } } } \caption{Hybrid Probabilistic Fingerprinting Scheme} \label{alg:hpfs} \end{algorithm} \section{Experiment Results When Fingerprinting is Applied On the Original Dataset} \label{sec:appendix2} In Section \ref{ex:results}, we provide the experimental results of the proposed fingerprinting algorithm, when fingerprinting is applied after a perturbation-based differentially private mechanism planar isotropic mechanism (PIM). Therefore, we showed that the proposed scheme provide robust fingerprinting along with differential privacy. Here, we provide our results when the fingerprinting scheme is applied on original dataset without applying a differentially private data sharing mechanism. In Figure \ref{fig:random_dis_vs_pr_raw}, the proposed scheme shows high accuracy and high data utility for all random distortion ratio $p_r$s. In Figure \ref{fig:corr_dis_vs_p}, we give that our scheme maintains $100\%$ detection accuracy for all correlated distortion attacks with distortion ratio $p_c \in [0, 0.99]$, and it slightly decreases if the attacker distort all suspicious points with low correlations. We also find that a trajectory with $200$ location points is enough to support high detection accuracy (close to $1.0$) against majority collusion attacks, while for probabilistic collusion attacks, a $60\%$ detection accuracy requires a trajectory has at least $300-400$ points. In Figure~\ref{fig:majority_vs_c_raw},~ \ref{fig:majority_vs_p_raw},~ \ref{fig:prob_vs_c_raw}, and~ \ref{fig:prob_vs_p_raw}, our scheme show similar results in Section \ref{ex:results} (applying fingerprinting after achieving differential privacy). Hence, we can conclude that the proposed fingerprinting scheme also works well on original data (i.e., provides high robustness and utility) when privacy is not considered. \begin{figure}[h] \centering \includegraphics[width=0.35\textwidth]{images/random_distortion_vs_pr.png} \caption{The fingerprint robustness against random distortion attacks in the original dataset with different distortion ratio $p_r$. ($p = 0.3$)} \label{fig:random_dis_vs_pr_raw} \end{figure} \begin{figure}[h] \centering \includegraphics[width=0.35\textwidth]{images/correlated_distortion_vs_pc.png} \captionsetup{justification=centering} \caption{The fingerprint robustness against correlated distortion attacks in the original dataset with different distortion ratio $p_c$. ($p = 0.3$)} \label{fig:corr_dis_vs_p} \end{figure} \begin{figure*}[h] \centering \begin{subfigure}[b]{0.303\textwidth} \centering \includegraphics[width=\textwidth]{images/majority_vs_c_raw.png} \caption{$c$ vs. accuracy} \label{fig:majority_vs_c_raw} \end{subfigure} \hfill \begin{subfigure}[b]{0.270\textwidth} \centering \raisebox{0.5mm}[0pt][0pt]{% \makebox[\textwidth][c]{\includegraphics[width=\textwidth]{images/majority_vs_l.png}} } \caption{length vs. accuracy} \label{fig:majority_vs_l} \end{subfigure} \hfill \vspace{1.5em} \begin{subfigure}[b]{0.299\textwidth} \centering \includegraphics[width=\textwidth]{images/majority_vs_p_raw.png} \caption{$p$ vs. accuracy} \label{fig:majority_vs_p_raw} \end{subfigure} \captionsetup{justification=centering} \caption{The fingerprint robustness against majority collusion attacks in the original dataset with different (a) colluding count $c$, (b) trajectory length, and (c) fingerprinting ratio $p$.} \label{fig:raw_mjr_test} \end{figure*} \begin{figure*}[h] \centering \begin{subfigure}[b]{0.305\textwidth} \centering \includegraphics[width=\textwidth]{images/prob_vs_c_raw.png} \caption{$c$ vs. accuracy} \vspace{0mm} \label{fig:prob_vs_c_raw} \end{subfigure} \hfill \begin{subfigure}[b]{0.270\textwidth} \centering \raisebox{0.5mm}[0pt][0pt]{% \makebox[\textwidth][c]{\includegraphics[width=\textwidth]{images/prob_vs_l.png}} } \caption{length vs. accuracy} \label{fig:prob_vs_l} \end{subfigure} \hfill \begin{subfigure}[b]{0.299\textwidth} \centering \includegraphics[width=\textwidth]{images/prob_vs_p_raw.png} \caption{$p$ vs. accuracy} \label{fig:prob_vs_p_raw} \end{subfigure} \vspace{1.5em} \captionsetup{justification=centering} \caption{The fingerprint robustness against probabilistic collusion attacks in the original dataset with different (a) colluding count $c$, (b) trajectory length, and (c) fingerprinting ratio $p$.} \label{fig:raw_prob_test} \end{figure*} \section{Conclusion and Future Work} \label{sec:conclusion} In this paper, we design a system that achieves both privacy preservation and robust fingerprinting, and we also achieve high utility at the same time. We first apply the differentially private mechanism PIM to the dataset to protect the location privacy. Then, we implement a fingerprinting scheme that considers pairwise correlations in the location data and prevent the attackers from distortions and collusions. With the integration of a utility-boosting post-processing, our scheme HPFS provides high data utility for data analyzers. There are several directions for further research. First, we plan to improve our correlation model to a higher-order or a more realistic model (e.g., using road structures) and analyze the performance of the scheme. In addition, a non-uniform grid in discretization can be used and different types of collusion attacks can be defined and studied. Moreover, our approach provides differential privacy and fingerprint robustness in two separate steps. Combining those two steps to finish them simultaneously is another potential future work. \section{Discussion} \label{sec:discussion} In this section, we discuss several topics regarding the system and experimental settings. We introduce an alternative for the system model and also identify some limitations in this paper. \subsection{Correlation Model} \label{sec:corr_discussion} In this work, we use $2$-gram Markov chain to model correlations. If we use a higher-order model, each $X$'s occurrence will decrease significantly since longer prefixes are harder to find intuitively. Therefore, we cannot collect enough patterns $Xg$ to form a reliable transition distribution for a prefix $X$, thus resulting in an inaccurate transition matrix. In our implementation, GeoLife~\cite{zheng2010geolife} consists of $17,621$ trajectories in Beijing. However, we can hardly construct a reliable $3$-gram model out of it, especially if we use a dense grid for services like Google Maps that collects location data frequently. Some approaches use a sparse grid to overcome this problem~\cite{xiao2015protecting, chen2012differentially} (around $400 * 400 m^2$), but the location points are too general for analytical purposes. On the other hand, our target applications, e.g., Google Maps and outdoor exercises, cannot bear such general locations. As a result, we compromise with the $2$-gram Markov chain. \vspace{-3mm} \subsection{Decentralized Setting} \label{sec:decentral_discussion} We build our system in the centralized setting, i.e., users' location points are collected by a centralized data server and then processed by our scheme. This relies on a completely honest party involved into the system since the centralized data server (i.e., the service provider) has direct access to the collected dataset. If no such party exists, we can alternatively set up a decentralized system, where the privacy is protected before sending location data to the centralized server. Users can apply the DP protection locally on their devices by setting the desired privacy level they want to achieve. Then, the protected data are transmitted to the centralized server. Every time when the service provider collects real-time location information from users, the users instantly protect their locations under differential privacy (e.g., using PIM) and send the noisy locations to the centralized server. The server collects those locations sequentially and apply our fingerprinting scheme to the location data. In this case, real locations are not exposed to any party including the centralized server, thus protecting users' location privacy in a better way. However, this setting sacrifices users' experience while using location-based servers, and thus some service providers may offer poor services due to the inaccuracy of the location information. While using Google Maps for navigation, we definitely do not want to report incorrect locations. But if we use Google Maps to find nearby restaurants, we often accept a vague or slightly deviated localization. Service providers can choose the either setting based on the services they provide. \section{Evaluation} \label{sec:evaluation} We evaluate our proposed scheme using a real dataset in this section. We run all experiments for more than $2,000$ times with $20$ dataset shuffles and report the average. \vspace{-1mm} \subsection{Experimental Setting} \subsubsection{Baseline Approaches} For comparison, we implement a randomized fingerprinting scheme (RFS) as the baseline approach. RFS embeds a fingerprint value at each position with a uniform probability $p$. At those selected positions, RFS generates a multivariate Laplacian noise to the original coordinates. The scales along the longitude and latitude are the same and aligned with our proposed scheme by the average deviation between corresponding points. We also introduce the vanilla Boneh-Shaw codes and the vanilla Tardos codes to analyze the performance of the integrated fingerprinting scheme. \vspace{-1mm} \subsubsection{Dataset} We use the Geolife~\cite{zheng2010geolife} dataset (Version $1.3$) for evaluation. Geolife contains $17,621$ trajectories generated by $182$ users using different GPS devices over five years (April 2007 - August 2012), including $1,292,951$ kilometers in the distance and $50,176$ hours in time, where most of the locations are in Beijing, China. The dataset also covers a variety of outdoor activities, providing generality for the evaluation. \vspace{-1mm} \subsubsection{Pre-Processing} We pre-process the trajectories to avoid various data intervals. In the dataset, the time intervals vary from $1$ second to more than $60$ seconds. To build a reasonable correlation model for our system, we pre-process the trajectories to limit the time interval uniformly that approximates to $3$ seconds to simulate the services such as Google Maps and carpooling. Moreover, we remove the altitude and construct a $2$-dimensional geographical area and define the area of interest by the latitude $\in [39.6797, 40.1280]$ and the longitude $\in[116.0287, 116.7064]$. Since there are some location points far from Beijing, we remove those fragments from the dataset. We discretize the area into cells uniformly using a $1000 \times 1000$ grid both in the PIM and in the HPFS. The different selections of the grid size do not affect the performance since the two processes (PIM and HPFS) are independent, but we match the two grids for simplicity. We randomly select $80\%$ of the trajectories in the dataset to form the correlation model, while the rest are used for the evaluation on fingerprint robustness and data utility. \vspace{-1mm} \subsubsection{Parameter Settings} If not specified, we use the following parameter setting throughout the experiment. We assume $100$ SPs get the copies and each trajectory which contains $200-1200$ locations. We set $\tau = 0.005$ as the correlation threshold concluded from our preliminary experiments and the fingerprint balancing factor $\theta = 0.5$. The Tardos codes use $\omega = 0.01$ as the error probability. The Boneh-Shaw codeword consists of $10$ blocks and $5$ location points in each block. For PIM, we follow~\cite{xiao2015protecting} and set $\delta = 0.01$ for the $\delta$-location set and the privacy budget $\epsilon = 0.5$ if we mention an obfuscated dataset. The fingerprinting ratio is set to $0.3$. We suppose the attacker(s) use $p_c = 0.5$ and $p_r = 0.5$ in random and correlated distortion attacks, respectively, and $5$ SPs collude by default. \subsubsection{Fingerprint Robustness Metric} A successful accusation is to catch the analyzer who leaks the data. If multiple analyzers collude, we consider catching one of the colluders. Since the Tardos codes focus on catching all who leak the data, we adjust the accusation process for alignment. More specifically, we only consider the one with the highest scores in the Tardos detection instead of using the threshold $20ck$. \subsubsection{Utility Metrics} Following the existing works~\cite{xiao2015protecting, he2015dpt, gursoy2018differentially}, we introduce our utility metrics in this section. \paragraph{Correlation Fit Rate} The correlation fit rate shows how consecutive location pairs conform the correlations, i.e., $Pr(x_{j+1}|x_j) \geq \tau$ for a location point $x_j$. If the rate is high, most pairs follow the correlations; otherwise, the public correlations do not hold in the trajectories. \paragraph{Query Answering of Trajectories} \label{sec:qa_t} The count query is one of the most frequent usages for location datasets. Let $Q_t(D, g)$ denote the query "how many trajectories pass a circular area represented by a center $c$ and a radius $r$ in the dataset $D$". Then, we define the relative error of $Q_t$ as $$RE_t =\frac{|Q_t(D,g)-Q_t(D', g)|}{max(Q_t(D,g),b)}$$ , where $D$ is the original dataset and $D'$ is the output of our scheme. We set $b=0.01 \times |D|$ to mitigate the high sensitivity while countering small query results according to~\cite{nergiz2008towards, zhang2016privtree, chen2012differentially, gursoy2018differentially}. We calculate the average of the errors as $AvRE_t$. \paragraph{Query Answering of Patterns} We also implement another query answering metric for patterns. As discussed in Section~\ref{sec:correlation}, we only focus on the $2$-gram patterns. Given a $2$-gram pattern $P$, the count query on $P$ is $Q_p(P,D)$ that counts $P$ in the dataset $D$. The relative error $AvRE_p$ is similarly defined as $AvRE_t$. \paragraph{Trajectory Similarity} In the services like Google Maps and carpooling, the trajectory shape is also an interesting utility metric. We use Discrete Fr\'echet Distance~\cite{eiter1994computing} to calculate the similarity between the trajectories from PIM and HPFS, respectively. \subsection{Experimental Results} \label{ex:results} We implement the fingerprinting scheme on the datasets that achieve differential privacy (using PIM) and provide the experimental results here. We first show the fingerprinted dataset preserves high correlation fit rate compared with the baseline method. Then, we evaluate the fingerprint robustness in the worst case, i.e., leaking only one trajectory, since the fingerprint code length may be insufficient for a successful accusation. In Section~\ref{sec:eval_dataset}, we provide the results when the attacker leaks the whole dataset instead of a single trajectory. Moreover, we show the data utility of the fingerprinted dataset. We also evaluate the time efficiency of our scheme. In Appendix~\ref{sec:appendix2}, we display additional results when fingerprinting is applied directly on the original dataset if the privacy is not considered. \subsubsection{Correlation Fit Rate} \begin{figure}[h] \centering \includegraphics[width=0.3\textwidth]{images/correlation_fit_rate_vs_dp.png} \captionsetup{justification=centering} \caption{The correlation fit rate with different privacy budget $\epsilon$. } \label{fig:corr_fit_ratio_vs_dp} \end{figure} Figure~\ref{fig:corr_fit_ratio_vs_dp} shows the correlation fit rate for RFS and our scheme when $p$ is set to $0.3$. RFS only maintains $0.05$ fit rate for all $\epsilon$s. Our scheme gets $80\%$ correlation fit rate if $\epsilon = 0.1$, and the rate approaches the one in the original dataset (marked by the blue dashed line) when $\epsilon$ reaches $0.7$. The proposed scheme outperforms RFS and preserves most of the pairwise correlations. \subsubsection{Fingerprint Robustness Against Random Distortion Attacks (Single Trajectory)} \begin{figure}[h] \centering \includegraphics[width=0.35\textwidth]{images/random_distortion_vs_pr_dp.png} \caption{The fingerprint robustness against random distortion attacks with different distortion ratio $p_r$.} \label{fig:random_dis_vs_pr_dp} \end{figure} \begin{figure}[h] \centering \includegraphics[width=0.35\textwidth]{images/random_distortion_vs_dp.png} \caption{The fingerprint robustness against random distortion attacks for different values of privacy budget $\epsilon$.} \label{fig:random_dis_vs_dp} \end{figure} The detection accuracy against random distortion attacks ($p_r = 0.5$) reaches $1.0$ when the fingerprinting ratio $p > 0.05$ from our experimental results. Figure~\ref{fig:random_dis_vs_pr_dp} shows the fingerprint robustness of our scheme against random distortion attacks compared under different random distortion ratio $p_r$. Both our scheme and RFS show high robustness, but RFS loses the data utility (measured by $AvRE_t$) significantly compared with our scheme. In Figure~\ref{fig:random_dis_vs_dp} where we set $p_r=0.5$, our scheme also outperform RFS in data utility. The reason that RFS has similar accuracy with APFS is that RFS has more candidates to choose for each point. Unlike APFS that considers correlations and samples the output from a limited set, RFS can freely choose any point to report from the multivariate Laplacian distribution. Thus, the candidates at each position are far more than our scheme and the binary codes, i.e., the Tardos codes and the Boneh-Shaw codes. The large alphabet results in a higher accuracy for RFS, but the utility loss is too high (See the red dashed line in all three subfigures). In conclusion, APFS shows high fingerprint robustness and data utility simultaneously. \subsubsection{Fingerprint Robustness Against Correlated Distortion Attacks (Single Trajectory)} Our scheme achieves $100\%$ detection accuracy against correlated distortion attacks when $p > 0.05$ and $p_c = 0.5$. If we let $p = 0.3$ and change $p_c$, the accuracy only decrease from $100\%$ once $p_c$ reaches $0.98$. In Figure~\ref{fig:corr_dis_vs_dp}, our scheme keeps around $100\%$ detection accuracy for all privacy budgets when the fingerprinting ratio $p = 0.3$. On the other side, the Boneh-Shaw codes show very low accuracy in all datasets no matter how we choose the parameters of the codes ($bs$ and $bc$). In the obfuscated datasets where $p_c$ is set to $0.98$, all the methods are not influenced by the change of the privacy budget $\epsilon$. In those experiments, our proposed scheme APFS achieves better accuracy compared with all the baseline approaches and also provides high data utility. \begin{figure}[h] \centering \includegraphics[width=0.35\textwidth]{images/correlated_distortion_vs_dp.png} \captionsetup{justification=centering} \caption{The fingerprint robustness against correlated distortion attacks for different values of privacy budget $\epsilon$. ($p_c = 0.98$)} \label{fig:corr_dis_vs_dp} \end{figure} \subsubsection{Fingerprint Robustness Against Majority Collusion Attacks (Single Trajectory)} \begin{figure*}[h] \centering \begin{subfigure}[b]{0.299\textwidth} \centering \includegraphics[width=\textwidth]{images/majority_vs_c_dp.png} \caption{$c$ vs. accuracy} \label{fig:majority_vs_c_dp} \end{subfigure} \hfill \begin{subfigure}[b]{0.299\textwidth} \centering \includegraphics[width=\textwidth]{images/majority_vs_p_dp.png} \caption{$p$ vs. accuracy} \label{fig:majority_vs_p_dp} \end{subfigure} \hfill \begin{subfigure}[b]{0.270\textwidth} \centering \includegraphics[width=\textwidth]{images/majority_vs_dp_7.png} \caption{$\epsilon$ vs. accuracy} \label{fig:majority_vs_dp_7} \end{subfigure} \vspace{1.5em} \captionsetup{justification=centering} \caption{Comparisons of the fingerprint robustness against majority collusion attacks with different (a) colluding count $c$, (b) fingerprinting ratio $p$, and (c) privacy budget $\epsilon$.} \label{fig:mjr_test} \end{figure*} Figure~\ref{fig:mjr_test} shows the performance of different fingerprinting schemes against majority collusion attacks. We implement the Boneh-Shaw codes and the Tardos codes on top of the random scheme. HPFS is almost $100\%$ accurate and outperforms all other methods in Figure~\ref{fig:majority_vs_c_dp}. Figure~\ref{fig:majority_vs_p_dp} shows the fingerprint robustness with the change of the fingerprinting ratio $p$ in the obfuscated datasets. The detection accuracy of HPFS is close to $100\%$ if $p$ reaches $0.3$. Other methods requires greater fingerprinting ratios for a similar performance, while the Boneh-Shaw codes only get $95\%$ even if $p=1.0$. Figure~\ref{fig:majority_vs_dp_7} shows detection accuracy v.s. different privacy budgets, where the colluding count is set to $7$ for better representation. HPFS gets the highest accuracy in all scenarios and it is stable with various privacy budgets. \subsubsection{Fingerprint Robustness Against Probabilistic Collusion Attacks (Single Trajectory)} In probabilistic collusion attacks, HPFS dominates in all experiments significantly (see Figure~\ref{fig:prob_test}). Our scheme maintains a high detection accuracy regardless of the colluding count $c$ and the privacy budget $\epsilon$, and it keeps $>70\%$ accuracy after $p = 0.3$ in both DP and non-DP settings. The Boneh-Shaw codes and Tardos codes cannot effectively counter such attacks, thus showing low detection accuracy. \begin{figure*}[h] \centering \begin{subfigure}[b]{0.299\textwidth} \centering \includegraphics[width=\textwidth]{images/prob_vs_c_dp.png} \caption{$c$ vs. accuracy} \label{fig:prob_vs_c_dp} \end{subfigure} \hfill \begin{subfigure}[b]{0.299\textwidth} \centering \includegraphics[width=\textwidth]{images/prob_vs_p_dp.png} \caption{$p$ vs. accuracy} \label{fig:prob_vs_p_dp} \end{subfigure} \hfill \begin{subfigure}[b]{0.270\textwidth} \centering \includegraphics[width=\textwidth]{images/prob_vs_dp_7.png} \caption{$\epsilon$ vs. accuracy} \label{fig:prob_vs_dp_7} \end{subfigure} \vspace{1.5em} \captionsetup{justification=centering} \caption{Comparisons of the fingerprint robustness against probabilistic collusion attacks with different (a) colluding count $c$, (b) fingerprinting ratio $p$, and (c) privacy budget $\epsilon$.} \label{fig:prob_test} \end{figure*} \subsubsection{Fingerprint Robustness Against Multiple Attacks (Location Datasets)} \label{sec:eval_dataset} Figure~\ref{fig:dataset_test} shows the performance against dataset redistribution when a dataset of $100$ trajectories is leaked by the attacker. If the trajectory length is greater than $400$ and the fingerprinting ratio is at least $20\%$, the detection accuracy reaches $90\%$ in most cases, which proves our scheme are robust against those attacks if a subset or even an entire dataset is leaked. \begin{figure*}[h] \centering \begin{subfigure}[b]{0.302\textwidth} \centering \includegraphics[width=\textwidth]{images/dataset_vs_c.png} \caption{$c$ vs. accuracy} \label{fig:dataset_vs_c} \end{subfigure} \hfill \begin{subfigure}[b]{0.302\textwidth} \centering \includegraphics[width=\textwidth]{images/dataset_vs_p.png} \caption{$p$ vs. accuracy} \label{fig:dataset_vs_p} \end{subfigure} \hfill \begin{subfigure}[b]{0.298\textwidth} \centering \raisebox{0.5mm}[0pt][0pt]{% \makebox[\textwidth][c]{\includegraphics[width=\textwidth]{images/dataset_vs_l.png}} } \caption{$l$ vs. accuracy} \label{fig:dataset_vs_l} \end{subfigure} \vspace{1.5em} \captionsetup{justification=centering} \caption{Comparisons of the fingerprint robustness against majority and probabilistic collusion attacks with different (a) colluding count $c$, (b) fingerprinting ratio $p$, and (c) trajectory length $l$.} \label{fig:dataset_test} \end{figure*} \subsubsection{Utility Evaluation} Figure~\ref{fig:utility_test} shows the data utility of the proposed scheme and compare it with the released dataset from PIM. Comparing the output from PIM and from the whole system (including PIM and HPFS), we can conclude that our fingerprinting scheme provides high data utility for all metrics. \begin{figure*}[h] \centering \begin{subfigure}[b]{0.3\textwidth} \centering \includegraphics[width=\textwidth]{images/query_answer_t.png} \caption{Query Answering of Trajectories} \label{fig:trajectory_test} \end{subfigure} \hfill \begin{subfigure}[b]{0.301\textwidth} \centering \includegraphics[width=\textwidth]{images/query_answer_p.png} \caption{Query Answering of Patterns} \label{fig:pattern_test} \end{subfigure} \hfill \begin{subfigure}[b]{0.3\textwidth} \centering \includegraphics[width=\textwidth]{images/similarity.png} \caption{Trajectory Similarity} \label{fig:sim_test} \end{subfigure} \vspace{1.5em} \captionsetup{justification=centering} \caption{Data utility experiments of (a) query answering of trajectories $Q_t$, (b) query answering of patterns $Q_p$, and (c) trajectory similarity using discrete Fr\'echet distance.} \label{fig:utility_test} \end{figure*} \subsubsection{Evaluation on Computation Time} We present the computation time of the proposed scheme in Table~\ref{table:time_cost}. For a dataset of $100$ trajectories with length equal to $500$, the scheme only spends $2.5779$ seconds generating one fingerprinted copy. Also, we observe the computation time increases linearly when the trajectory length grows. In conclusion, our scheme shows excellent time efficiency in generation and scales well for large datasets. \begin{table}[h] \footnotesize \centering \vspace{2em} \caption{Execution time of generating a fingerprinted dataset ($n = 100$)} \begin{tabular}{ c c c c c c c c c c c } \hline $l$ & 100 & 200 & 300 & 400 & 500 \\ \hline time$(s)$ & 0.5177 & 1.0229 & 1.5268 & 2.0407 & 2.5779 \\ \hline \end{tabular} \label{table:time_cost} \end{table} \section{Introduction} \label{sec:introduction} The rapid evolution of the internet and mobile technologies bring unprecedented opportunities to location-based applications. Most of such applications, including map navigation and carpooling, heavily rely on location-based information to ensure that services function correctly. For instance, Doordash~\cite{doordash_web} collects users' approximate locations and displays nearby restaurants available for delivery/pickup. As a navigation application, Google Maps~\cite{gomaps_web} uses real-time locations to determine optimal routes. Most individuals are subtly accustomed to the convenient lifestyles using those location-based services, and hence they share their location patterns with such location-based service providers voluntarily (with consent). On the other hand, location datasets (including check-ins or trajectories of individuals) that are constructed by location-based service providers bring vast benefits. Researchers can use such location datasets for various data mining tasks. Businesses can also utilize such location datasets in different ways, such as boosting user experience, adapting marketing strategies, or selecting optimal location for new facilities. However, location data, i.e., movement records combined with metadata, contains sensitive information, which leads to significant privacy concerns if service providers share the datasets directly with researchers or businesses. Service providers often share such location datasets with a limited number of parties, called data analyzers, after applying privacy-preserving data sharing techniques. Nevertheless, malicious data analyzers, motivated by profit, may leak their copies to unauthorized parties. To resolve this issue, service providers can apply fingerprinting techniques on the shared datasets to enable traceability. A fingerprint is a unique signature embedded in each shared copy of the original dataset. By utilizing the embedded fingerprint in a leaked dataset, service providers can identify the source of the unauthorized redistribution with high confidence. Thus, knowing that the leaked dataset will be traced back to them, malicious parties become less motivated to leak the copies of received datasets to unauthorized parties. However, traditional digital fingerprinting schemes cannot be directly applied to the location datasets due to specific correlations in location datasets and their particular utility requirements. Typically, neighboring location points are highly correlated along the trajectory in several aspects. For instance, in a walking trajectory, recorded at every 10 seconds, it is not likely to have two contiguous location points one kilometer apart from each other. Also, one can precisely estimate/infer a given point in a location trajectory given the previous and following points. Therefore, using publicly available correlation models (constructed from public location datasets), an attacker can identify the points that violate the expected correlations as the fingerprinted data points. The attacker can then distort or remove such identified data points (i.e., distort the fingerprint), which makes it harder for the service providers to detect the source of a leaked dataset. To mitigate such vulnerabilities, a service provider may increase the fingerprinting probability (i.e., number of fingerprinted data points in the shared dataset); however, this results in significant degradation in dataset utility. Therefore, a new, robust, and utility-preserving fingerprinting scheme is required to protect location datasets. Fingerprinting only protects the dataset from redistribution. To protect the privacy of dataset participants' (users') location data, service providers still need to apply privacy-preserving techniques before sharing the dataset with data analyzers. A simple solution to this is to apply basic anonymization techniques, e.g., removing or blurring the (quasi-)identifiers of the dataset, that prevent the analyzers from identifying the users. Nevertheless, since users' movement patterns, called trajectories, are pretty distinct, the users can still be deanonymized with the help of auxiliary information. It has been shown that users' identities can be deanonymized with high confidence, given only a pattern of four location points \cite{de2013unique}. Therefore, simple anonymization is not sufficient to provide privacy for the dataset participants. Differential privacy (DP) is a state-of-the-art concept for privacy preservation that quantifies and limits the information acquired from the attackers' perspective. There exist DP-based techniques~\cite{xiao2015protecting, gursoy2018differentially} that aim to protect location datasets. However, to achieve DP, those schemes introduce too much noise, distorting the internal relations between points and losing useful features in the shared datasets. Also, these solutions do not provide liability guarantees (via fingerprinting) against dataset leakage (unauthorized redistribution). It is possible to achieve privacy protection together with robust fingerprinting in an ad-hoc way (e.g., achieving DP first and then fingerprinting the dataset), but, this ad-hoc approach results in more degradation in the utility of the shared dataset. Hence, new methods are in demand to provide both privacy and liability while preserving the utility of the shared location datasets. To tackle these challenges, in this paper, we introduce a framework that simultaneously provides robust fingerprinting, privacy preservation, and high utility when sharing location datasets. We first apply an existing event-level privacy-preserving technique, i.e., the planar isotropic mechanism~\cite{xiao2015protecting} to the trajectories in the dataset. We model the adversarial knowledge using a Hidden Markov Model. Instead of hiding a location point among the entire area where the user possibly occurs, we only protect it among highly probable regions, called $\delta$-location set based on prior knowledge and auxiliary information, i.e., a public correlation model. To solve the utility issue, we propose a smoothing scheme as the post-processing step of the differentially private mechanism and restore most correlations between consecutive points. During this process, we check the 2-gram transitions in the trajectory and replace each location that has a low probability with a highly probable one by considering the directional information of the transition. We also develop a robust fingerprinting scheme using probabilistic sampling on location datasets and integrate it as a part of the aforementioned post-processing scheme to minimize the utility degradation in the shared dataset. The proposed scheme ensures that an attacker cannot avoid accusation (by the service provider) by distorting the fingerprint even if utilizing publicly known correlations. Moreover, our scheme also prevents the attacker from colluding with other parties, e.g., using majority collusion attacks~\cite{boneh1998collusion} or probabilistic collusion attacks~\cite{yilmaz2020collusion}. We implement our proposed scheme using a real-life dataset~\cite{zheng2010geolife} and evaluate the fingerprint robustness against various attacks by measuring the accuracy of the fingerprint detection algorithm. To compare its detection accuracy, we implement a randomized approach that applies mutlivariate Laplacian noise to fingerprint the data points. We also implement two baseline collusion resistant schemes, i.e., the Tardos codes and Boneh-Shaw codes, to evaluate the performance against collusion attacks. We show that our proposed scheme achieves higher detection accuracy than all these approaches against correlated distortion attacks and collusion attacks. We also evaluate the data utility in terms of correlation fit rate, accuracy of answering queries, and trajectory similarity. We observe that our scheme provides significantly better utility than the existing approaches. The main contributions of this work can be summarized as follows: \vspace{-1mm} \begin{itemize} \item We design a system that provides both differential privacy and robust fingerprinting when sharing location trajectories. \item We propose a probabilistic fingerprinting scheme for location trajectories that utilizes publicly known correlations to counter various attacks against a fingerprinting scheme. \item We propose a scheme that restores the pairwise correlations in the trajectories as a post-processing step of differential privacy, and then combine this post-processing scheme into the proposed fingerprinting scheme to minimize the degradation in the utility of the shared datasets. \item We evaluate the fingerprint robustness and data utility of our proposed scheme compared to the baseline approaches on a real-life location dataset. \vspace{-0.5mm} \end{itemize} The rest of the paper is organized as follows. We review the existing works in Section~\ref{sec:related_works} and provide the preliminaries in Section~\ref{sec:preliminaries}. We present the system and threat models in Section~\ref{sec:problems}. In Section~\ref{sec:methodology}, we introduce the proposed scheme in detail. We evaluate our proposed scheme in Section~\ref{sec:evaluation}. In Section~\ref{sec:discussion}, we discuss several topics. In Section~\ref{sec:conclusion}, we conclude the paper. \section{Methodology} \label{sec:methodology} Here, we introduce the details of our solution to achieve both differential privacy and robust fingerprinting while sharing location datasets (including location trajectories). We perform the following procedures for each trajectory in the dataset. First, we perturb the location points using the planar isotropic mechanism~\cite{xiao2015protecting} to achieve event-level differential privacy. This mechanism considers the attacker's knowledge using the hidden Markov model. For each data point in the trajectory, the algorithm releases a perturbed location based on the prior distribution of the user's presence, i.e., the information collected from the previously reported location points. After receiving the private trajectory, we post-process the trajectory to regain pair-wise correlations. Then, we implement the fingerprinting scheme~\cite{yilmaz2020collusion} with some adaptations (considering the specific requirements for location datasets) and improvements. To maximize the utility of the shared dataset, we integrate the fingerprinting scheme to the post-processing. In the following, we provide the details of these steps. \vspace{-1.5mm} \subsection{Privacy-Preserving Location Data Sharing} \label{sec:apply_dp} We implement a perturbation-based differentially private mechanism planar isotropic mechanism (PIM)~\cite{xiao2015protecting} which adds noise controlled by the privacy budget $\epsilon$ to location points, achieving event-level privacy. In PIM, Xiao et al. construct the attacker's knowledge using the hidden Markov model at each timestamp and hide the actual position among all the highly probable points. Given the noisy trajectory and prior knowledge, the attackers cannot reveal a user's actual position at any timestamp. We note that this scheme is not our contribution; we only use PIM to achieve differential privacy of location points in trajectories. We briefly introduce the mechanism in the following. More details can be found in the original paper~\cite{xiao2015protecting}. PIM constructs the correlations along a trajectory using Markov chain. From the attacker's perspective, the perturbation process is a hidden Markov model. At timestamp $t$, PIM calculates the prior probability distribution $p_t^-$ by $p_t^- = p_{t-1}^+M$, where $p_{t-1}^+$ is the posterior distribution at timestamp $t-1$, and $M$ denotes the transition matrix. Based on the prior probabilities, we build a $\delta$-location set $\Delta X_t$ that contains minimum number of locations with the probability sum larger or equal to $1-\delta$, i.e., $$\Delta X_t=min\{s_i|\sum_{s_i}p_t^-[i]\leq 1-\delta\}$$, which means a subset of locations with the total probability less than $\delta$ is omitted. After that, we release the perturbed location given $\Delta X_t$ (details in the next paragraph) at timestamp $t$ and call it $z_t$, we update the posterior probability distribution as \begin{equation}\label{eq:posterior} p_t^+[i]=Pr(\textbf{\textit{u}}_t^*=s_i|\textbf{\textit{z}}_t)=\frac{Pr(\textbf{\textit{z}}_t|\textbf{\textit{u}}_t^*=s_i)p_t^-[i]}{\sum_jPr(\textbf{\textit{z}}_t|\textbf{\textit{u}}_t^*=s_j)p_t^-[j]} \end{equation} for each location $s_j$, where $u_t^*$ is the true location at timestamp $t$. Using $p_t^+$, we can follow the same procedure to release the next location point. The generation of the perturbed output contains $6$ steps: \begin{enumerate} \item Generate a convex hull $K'$ from $\Delta X_t$; \item Build a set $\Delta V_t$ by $$ \Delta V_t= \cup_{\textbf{\textit{v}}_1, \textbf{\textit{v}}_2 \in \text{ vertices of } K'} (\textbf{\textit{v}}_1 - \textbf{\textit{v}}_2)$$ \item Form a sensitivity hull (a convex hull) $K$ from $\Delta V_t$ , which is a stricter sensitivity metric in two dimensions than the $l_1$ norm~\cite{xiao2015protecting}; \item Convert $K$ into isotropic position $K_I$~\cite{xiao2015protecting}; \item Sample a point $\textbf{\textit{z}}'$ from $K_I$ using the $k$-norm mechanism~\cite{hardt2010geometry}, i.e., the probability of each point $\textbf{z}$ is $$Pr(\textbf{z})=\frac{1}{\Gamma(d+1)\text{VOL}(K_I/\epsilon)}exp(-\epsilon||\textbf{z}-\textbf{x}^*||_{K_I})$$, where $\textbf{x}^*$ is the true answer, $||\cdot||_{K_I}$ is the Minkowski norm of $K_I$, $d$ is the dimension ($d=2$ in the location setting), $\Gamma()$ is Gamma function and VOL$()$ is the volume; \item Convert $\textbf{\textit{z}}'$ back to the original space as $\textbf{\textit{z}}$ and release it as the final output at timestamp $t$. \end{enumerate} By observing the output at each timestamp and knowing the transition matrix as auxiliary information, the attacker cannot infer the actual locations since the generation process models the attacker in the exact same way. Thus, we achieve differential privacy for the trajectories in the location datasets. \vspace{-0.5mm} \subsection{Utility-Focused Post-Processing} \label{sec:postprocess} Similar to other perturbation-based approaches that ensure event-level differential privacy, PIM generates high amount of noise for each location point, leading to significant utility loss in the the shared location dataset. Since there are no solid constraints for the neighboring locations in the released trajectory that guarantee the moving patterns are realistic, the pairwise correlations inside are mostly very low for common $\epsilon$s. Influenced by the above two factors, the data utility of the whole trajectory drops significantly. In other words, the trajectories before and after perturbations differ considerably in terms of shape and point-wise relations. As a result, the dataset is almost unusable for the data analyzers as they can hardly infer meaningful pieces of information, e.g., moving trends and statistics, from the trajectories. Our task is to generate a usable trajectory from the noisy release and use it as the true value in fingerprinting. To solve this problem, we propose a utility-focused post-processing scheme to improve the dataset's utility. We start with the definition of the $\tau$-probable set in Definition~\ref{def:tau_prob_set}. We build the correlations using the $2$-gram Markov chain and consider the transition based on the previous location in the trajectory. \begin{definition}[$\tau$-Probable Set] Let $\tau \in [0,1]$ and $\mathcal{G}$ be the map area. Given the location $g^*$, for any $j \in \mathcal{Z}^+$, the $\tau$-probable set of $g^*$ is defined as $$prob_\tau(g^*) = \{g | Pr[x_{j+1} = g|x_j = g^*] \geq \tau\}, g \in \mathcal{G}$$ \label{def:tau_prob_set} \vspace{-3mm} \end{definition} In the post-processing scheme, we iterate the location points in the trajectory in sequential order. For each location point $\hat{x}_j$, we calculate the $\tau$-probable set of the location $x^*_{j-1}$ generated from the post-processing scheme. If $\hat{x}_j$ is not in $prob_\tau(x^*_{j-1})$, i.e., $Pr[x_j = \hat{x}_j|x_{j-1} = x^*_{j-1}] \geq \tau$, the correlations are preserved between the two points, and we do not need to perform the utility boost. Otherwise, if $Pr[x_j = \hat{x}_j|x_{j-1} = x^*_{j-1}] < \tau$, the correlations barely exist. In this case, we replace $x'_j$ with a new one from our selection. Among the $\tau$-probable set, we generally choose the one closest to $\hat{x}_j$ as the final output. The new point $x^*_j$ is treated as the true value during the following fingerprinting process. \begin{figure}[h] \centering \includegraphics[width=0.23\textwidth]{images/pit_updated.png} \caption{\textbf{Pit falling}. $x_{j-1}^*$ is the last smoothed point. The following outputs $x_j^*, x_{j+1^*},\cdots$ will stay at the same position as $x_{j-1}^*$, forming a pit.} \label{fig:pit} \end{figure} Notice that selecting the points into the $\tau$-probable set depends on the transition probability. Thus, it is not guaranteed that the $\tau$-probable set is a circle-like shape covering all the directions of the previous location $\hat{x}$. Due to the insufficiency of the correlations generated from the publicly available datasets, in some extreme cases, there exists no suitable location in the set getting close to $\hat{x}_j$ compared with the previous location $x^*_{j-1}$. If this happens and the trajectory trend continues, i.e., no turning back, the following outputs will fall into a pit. Figure~\ref{fig:pit} is an example of pit falling. $x^*_{j-1}$ is the smoothed location at the $(j-1)$-th position, and the $\tau$-probable set of it is marked using the dashed circle. Since the closest location is identical to the previous release $x^*_{j-1}$, the algorithm still reports $x^*_j = x^*_{j-1}$. Then, the following locations will still be in the same position as $x^*_{j-1}$, making the trajectory fall into a pit. Our solution is to let $x^*_j = \hat{x}_j$ in this case. By doing so, we force the scheme to jump out of the death loop while the generation still follows the temporary trend of the trajectory. The complete algorithm of the post-processing scheme is shown in Algorithm~\ref{alg:smoothing}, where $\lVert\cdot\rVert_2$ denotes the $l_2$-norm. \begin{algorithm}[h] \small \SetKwInOut{Input}{input} \SetKwInOut{Output}{output} \Input{Noisy trajectory $\hat{\mathcal{X}}=[\hat{x}_1,\hat{x}_2,\dots,\hat{x}_m]$, location alphabet $\mathcal{G}$, conditional probability in the correlations $Pr(x_j|x_{j-1})$ for any $j \in [1,m]$, probability threshold $\tau$} \Output{Smoothed trajectory $\mathcal{X^*}=[x_1^*,x_2^*,\dots,x_m^*]$} $x_1^* \leftarrow x_1$ \ForAll{$j \in \{2,3,\ldots,m\}$} { $ prob_\tau(x^*_{j-1}) \leftarrow \tau$-probable set of $x^*_{j-1}$\; $x_{closest} \leftarrow $ closet point to $\hat{x}_j $ in $ prob_\tau(x^*_{j-1})$\; \uIf{$\hat{x}_j \notin prob_\tau(x^*_{j-1})$}{ \uIf{$\lVert x^*_{j-1}, \hat{x}_j\rVert_2 \leq \lVert x^*_{j-1}, x_{closest}\rVert_2$}{ $x^*_j \leftarrow \hat{x}_j$ } \uElse{ $x^*_j \leftarrow x_{closest}$ } } \uElse{ $x^*_j \leftarrow \hat{x}_j$ } } \caption{Trajectory Post-Processing Scheme} \label{alg:smoothing} \end{algorithm} According to Definition~\ref{def:immunity}, any post-processing (e.g., randomized mapping) on the differentially private outputs do not violate the differential privacy guarantee if the actual values are unknown. Our scheme modifies each location point only based on auxiliary information, i.e., the correlation model, without considering the true values of the data points before the differentially private generation. Thus, the post-processing scheme satisfies the property of immunity to post-processing and does not violate the DP guarantee of PIM. \subsection{Robust Fingerprinting} \label{sec:location_fingerprinting} Traditional fingerprinting approaches are not robust against the attacker who inspects the correlations in the fingerprinted data. In order to mitigate such attacks, we use the probabilistic fingerprinting scheme (PFS) from \cite{yilmaz2020collusion}. The probabilistic fingerprinting scheme introduces correlations into traditional fingerprinting, and it is able to protect the generated fingerprints from correlation-based distortions. \cite{yilmaz2020collusion} focuses on pair-wise correlations and preserves them while fingerprinting, which fits our needs exactly. Nevertheless, PFS only works on datasets with limited states for each data point (e.g., 3 states in~\cite{yilmaz2020collusion}), while location datasets have infinite states in reality. Thus, we are unable to apply PFS directly to location datasets. We redesign the sampling process in PFS to solve this issue. In the remaining paragraphs of this section, we first illustrate how PFS works. After that, we identify the problem of using PFS in the location setting and propose our solution. \subsubsection{The Probabilistic Fingerprinting Scheme} \label{sec:pfs} PFS embeds the fingerprint codes from the start to the end, i.e., $x_0$ to $x_{|\mathcal{X}|-1}$. Suppose we are generating the $j$-th position in the genomic sequence $\mathcal{X}$, and the fingerprinting ratio is $p$. While determining the output $y_j$, PFS checks the transition probability $Pr[x_j = g|x_{j-1} = y_{j-1}]$ for each $g$ in the alphabet. The scheme first eliminates all the states with a transition probability less than a given threshold $\tau$. PFS then forms a probability distribution for sampling the output among the remaining states. If the original value is not eliminated, $Pr[x_j]$ is set to $1 - p$ with the rest $p$ proportionally assigned to the remaining states according to their transition probabilities. If the true value at position $j$ is eliminated, the scheme only generates the output proportionally from the remaining states. During a generation, some positions are perturbed while some remain the same as the original true values. We use $FP$s and $NoFP$s to represent them, respectively. PFS balances the distribution of the $FP$s by using the balancing factor $\theta$. The scheme checks the $FP$ count every $\lceil \frac{1}{p} \rceil$ points. If the actual $FP$ count is larger than expected, then the temporary fingerprinting ratio is changed to $p * (1 - \theta)$. If the $FP$ are not enough, the ratio becomes $p * (1 + \theta)$. PFS also integrates the Boneh-Shaw codes \cite{boneh1998collusion} into the fingerprinting scheme for collusion resistance. In the first fingerprinted copy of the genomic sequence, the authors arbitrarily pick $bc * bs$ $FP$ data points to represent the $\Gamma(bc, bs)$ Boneh-Shaw codes. The codes consist of $bc$ blocks, and each block has $bs$ data points. For the $i$-th copy, the scheme reports the original values for the first $i-1$ blocks and releases the "FP" values for the rest blocks. For instance, if $bc=3$, the scheme will output 4 different Boneh-Shaw codewords, i.e., $[B_1^{FP}, B_2^{FP}, B_3^{FP}]$, $[B_1^{TR}, B_2^{FP}, B_3^{FP}]$, $[B_1^{TR}, B_2^{TR}, B_3^{FP}]$, and $[B_1^{TR}, B_2^{TR}, B_3^{TR}]$, where $B^{FP}$ means the block has the same values as in the first fingerprinted trajectory and $B^{TR}$ refers to the true values of the block. Since there are at most $bc+1$ different codewords for the Boneh-Shaw codes, they loop the codewords and assign them to the rest copies in turn. Since PFS changes some positions from $FP$ to $NoFP$, the number of $FP$ decreases. To maintain a stable number of $FP$ bits, the scheme calculates the fingerprinting ratio for the rest points by excluding the Boneh-Shaw codes before the start of each generation to make sure the aggregate fingerprinting ratio is similar. \subsubsection{Challenges for Using PFS for Location Data} \label{sec:challenges} There are several challenges to applying the fingerprinting directly onto the location trajectories. First of all, the scheme itself is designed for data with limited states~\cite{yilmaz2020collusion}. For location data, the states are infinite in reality. Even if we discretize the map area of interest using a grid, the states are still excessive, which potentially results in a complexity issue. Moreover, the logic inside PFS causes a vulnerability while used in the trajectories. PFS checks the correlations between the previously released point and the current value for each position. After filtering the low probable states, if the correlations hold, the scheme assigns a probability of $1-p$ to share the true value and the rest is proportionally distributed to the rest states according to the transition probability. This process normally works in location fingerprinting, but when the correlations are low between those points, things change. According to PFS, the scheme eliminates the true value since the correlations do not hold. Then, the scheme proportionally samples a point from the remaining $\tau$-probable set consisting of highly probable points and reports that one. In trajectory fingerprinting, once the sampled output appears outside of the next point's $\tau$-probable set, the rest of the points will wander among the $\tau$-probable set forever. For instance, in Figure~\ref{fig:deathloop}, we show how a death loop is formed. Here, PFS is fingerprinting the $j$-th position in the trajectory, while $x'_{j-1}$ is the last fingerprinted location and the dashed circular area in black is the $\tau$-probable set of $x'_{j-1}$. $x^*_j$ is the actual location at position $j$, and it is in the $\tau$-probable set of $x'_{j-1}$. PFS wants to sample a point among the $\tau$-probable set and release that point. If the sampled point is located as $x'_j$ in Figure~\ref{fig:deathloop}, we realize that the next true value $x^*_{j+1}$ is not in the $\tau$-probable set of $x'_j$. In this case, the scheme will sample a location only among the set without considering the true value. The next true value will be more likely to occur outside of the $\tau$-probable set (marked by red dashed circle) as well since the actual trajectory moves forward and the sampled output sticks to the area close to the first separation, i.e., $x'_j$. If the generation continues, the fingerprinted locations will stay around the first deviated location $x'_j$ and finally form a death loop. We resolve this issue by additionally considering directional transitions between points during the sampling process in PFS. \begin{figure}[h] \centering \includegraphics[width=0.28\textwidth]{images/deathloop_updated.png} \caption{\textbf{A death loop}. $x_j'$ is sampled inside the $\tau$-probable set of $x_{j-1}'$, but it makes the next true value $x_{j+1}^*$ outside its $\tau$-probable set. Following FPS, the following points will be sampled among $prob_\tau(x_j')$ only.} \label{fig:deathloop} \end{figure} \subsubsection{Adaptive Fingerprinting Scheme} \label{sec:APFS} To solve the aforementioned challenges, we apply a direction-sensitive sampling to PFS instead of the vanilla approach, called the adaptive fingerprinting scheme (see Algorithm~\ref{alg:afs} for details). For a released point $x_{j-1}'$, we first form a set containing all locations closer or equal to $x^*_j$ than $x_{j-1}'$ in the $\tau$-prob set, called $\tau$-closer set, which can be expressed as $$prob_\tau^c(x'_{j-1}) \leftarrow \{g| \lVert g, x^*_j \rVert_2 \leq \lVert x'_{j-1} , x^*_j\rVert_2, g \in prob_\tau(x'_{j-1})\}$$. Normally, if the true value $x^*_j$ is in the $\tau$-closer set, we sample the output among it by setting the probability of choosing the true value as $1-p$ and the rest is proportionally assigned based on the transition probability to the destination. We improve the sampling process using temporary true values to avoid death loops in the generation. There are four cases while selecting the true value at the $j$-th position. If the true value $x^*_j$ is in the $\tau$-closer set of the previously released location $x'_{j-1}$, there is no difference between ours and in PFS. If the true value $x^*_j$ is not in the $\tau$-closer set, we check its membership in the $\tau$-probable set and sample from the same distribution as above but among the $\tau$-probable set instead. If not, we check the closest point $\tilde{x}$ to the true value in $prob_\tau(x'_{j-1})$. If $\tilde{x}$ is the same as $x'_{j-1}$, which means there exists no such location closer than the true value, we let the temporary true value be the original true value $x^*_j$. Otherwise, we choose $\tilde{x}$ as temporary true value at this timestamp and perform the proportional sampling scheme. For the first location in the trajectory, we do not have the conditional probabilities. Instead, we use the emission probability alternatively. \begin{algorithm}[h] \small \SetKwInOut{Input}{input} \SetKwInOut{Output}{output} \Input{Trajectory $\mathcal{X^*}=[x^*_1,x^*_2,\dots,x^*_m]$, location alphabet $\mathcal{G}$, conditional probability in the correlations $Pr(x_j|x_{j-1})$ for any $j \in [1,m]$, probability threshold $\tau$, fingerprinting ratio $p$} \Output{Fingerprinted trajectory $\mathcal{X}'=[x'_1,x'_2,\dots,x'_m]$} \ForAll{$j \in 2, 3, \dots, m$}{ $prob_\tau(x'_{j-1}) \leftarrow \tau$-probable set of $x'_{j-1}$\; $prob_\tau^c(x'_{j-1}) \leftarrow \{g| \lVert g, x^*_j \rVert_2 \leq \lVert x'_{j-1} , x^*_j\rVert_2, g \in prob_\tau(x'_{j-1})\}$\; \uIf{$x^*_j \in prob^c_\tau(x'_{j-1})$ and $|prob_\tau^c(x'_{j-1})| > 1$}{ $PD \leftarrow$ $Pr[x'_j = x^*_j] = 1 - p, Pr[x'_j = g] = \frac{Pr[x'_j = g | x'_{j-1}]}{\sum_{g'\in prob_\tau(x'_{j-1}) \backslash x^*_j} Pr[x'_j = g' | x'_{j-1}]} * p , g \in prob_\tau^c(x'_{j-1})$\; $x'_j \leftarrow$ sample from $PD$\; } \uElseIf{$x^*_j \in prob_\tau(x'_{j-1})$ and $|prob_\tau^c(x'_{j-1})| == 1$}{ $PD \leftarrow$ $Pr[x'_j = x^*_j] = 1 - p, Pr[x'_j = g] = \frac{Pr[x'_j = g | x'_{j-1}]}{\sum_{g'\in prob_\tau(x'_{j-1}) \backslash x^*_j} Pr[x'_j = g' | x'_{j-1}]} * p , g \in prob_\tau(x'_{j-1})$\; $x'_j \leftarrow$ sample from $PD$\;} \uElse{ $x_{closest} \leftarrow $ closet point to $x^*_j$ in $ prob_\tau(x'_{j-1})$\; \uIf{$|prob_\tau(x'_{j-1})| <= 1$}{ $x'_j \leftarrow x^*_j$\; } \uElse{ $PD \leftarrow$ $Pr[x'_j = x_{closest}] = 1 - p, Pr[x'_j = g] = \frac{Pr[x'_j = g | x'_{j-1}]}{\sum_{g'\in prob_\tau(x'_{j-1}) \backslash x_{closest}} Pr[x'_j = g' | x'_{j-1}]} * p, g \in prob_\tau(x'_{j-1})$\; $x'_j \leftarrow$ sample from $PD$\; } } } \caption{Adaptive Fingerprinting Scheme} \label{alg:afs} \end{algorithm} \subsection{Integration of the Fingerprinting Scheme with the Post-Processing} \label{sec:HPFS} Observing that the post-processing (in Section~\ref{sec:postprocess}) includes the similar operations with the improved FPS considering the correlations in the data, we integrate the post-processing scheme into the probabilistic sampling step. One notable benefit of this integration is the increase of the detection accuracy against collusion attacks in the obfuscated datasets. Originally, we receive a trajectory $\hat{\mathcal{X}}$ from the post-processing and assume it to be the ground truth while fingerprinting. We perturb around $p * |\hat{\mathcal{X}}|$ location points and only use them to identify the source of the unauthorized redistribution. However, in reality, some other points in $\hat{\mathcal{X}}$ have also been perturbed in the post-processing while choosing the surrogates, but they are not involved in the detection process. To solve the issue, we propose a hybrid scheme by combining the post-processing and robust fingerprinting simultaneously for each point. By doing so, we are able to make all the perturbed points from either steps contribute to the detection, which increases the fingerprint code length and finally increase the detection accuracy. In the hybrid scheme, if a location point has low correlation with the previous released point, we replace the true value with the one closet to it among the $\tau$-probable set. If there is at most $1$ location in the $\tau$-probable set, we force the true value to be the output. If $2$ or more locations exist, we perform the proportional sampling similar to~\ref{sec:APFS}. When the location point has high correlation instead, we sample from the $\tau$-closer set if the $\tau$-closer set contains at least $2$ points or from the $\tau$-probable set if not. The full algorithm (which we call ``Hybrid Probabilistic Fingerprinting Scheme'') is shown in Algorithm~\ref{alg:hpfs}. \vspace{-3mm} \subsection{Detecting the Source of The Unauthorized Redistribution} \label{sec:detection} \cite{yilmaz2020collusion} proposes two detection metrics for PFS, probability-based and similarity-based detections. The probability-based detection compares location points at the same position among the leaked trajectory and the shared copies archived in the system. For each position $j$, the algorithm finds all the copies with the value equal to the leaked one. It assigns $1/|S_j|$ to each copy since each has $1/|S_j|$ chance of leaking the data. In the similarity-based detection, each analyzer receives $1/m$ score, where $m$ is the length of the leaked trajectory. Both detections calculate the accumulated scores and consider the one with the highest one as the criminal. Our elementary experiments show that the similarity-based detection works better in the location data, as the probability-based one is much more sensitive and often mischarges an innocent analyzer if distortion attacks are involved. Both similarity-based and probability-based mechanisms rely on the exact match. In location data, slight perturbation is enough to invalidate those exact matches and thus influence the detecting accuracy. Thus, we replace it with a distance-based match in similarity-based detection. For each location point in the trajectory, we consider the analyzers with the shortest distance to the leaked one as suspicious and use the aggregate scores for the detection. In the Hybrid Probabilistic Fingerprinting Scheme (in Section~\ref{sec:HPFS}), we follow~\cite{yilmaz2020collusion} and implement the detection of the Boneh-Shaw codes. While analyzing such trajectories, we first run the similarity-based detection and sort the scores in decreasing order. We pick the top $\lfloor\frac{1}{max(scores)}\rfloor$ candidates and determine the final source using the Boneh-Shaw inspection. For the remaining candidates, we traverse all the Boneh-Shaw blocks and find the first block with more $FP$s than $NoFP$s. Suppose we get the $k$'s block. Then, we check if there is a candidate that belongs to the $k$-th group in the Boneh-Shaw generation. If so, we accuse that candidate. If there are multiple candidates in the $k$-th group, we report the one with the highest score among them. If none of them is in the group, we accuse the one with the highest score. When a dataset instead of a single trajectory is leaked, we implement an aggregate detection scheme to identify the source of the unauthorized redistribution. We first use the similarity-based detection to analyze each leaked trajectory in the dataset and calculate a similarity score for each analyzer. Then, we get the average for each analyzer and finally accuse an analyzer using the aforementioned Boneh-Shaw code inspection. \section{Preliminaries} \label{sec:preliminaries} In this section, we first introduce the definition of differential privacy and its key property: immunity to post-processing. We then introduce two popular collusion-resistant fingerprinting schemes as the baseline approaches against collusion attacks. We integrate one of the schemes into our proposed robust fingerprinting scheme (i.e., the Boneh-Shaw codes) and compare it with the vanilla versions of these schemes in Section~\ref{sec:evaluation}. \vspace{-2mm} \subsection{Differential Privacy} \label{sec:dp} Differential privacy (DP) quantifies privacy and limits the inference of any single individual from observing the query results between neighboring databases (that differ in one data record). The formal definition is as follows: \begin{definition}[Differential Privacy]~\cite{dwork2008differential} \label{def:dp} For any neighboring datasets $D, D'$ that only differ in one data record, a randomized algorithm $\mathcal{M}$ satisfies $\epsilon$-differential privacy if for all possible outputs $\mathcal{S} \subseteq Range(\mathcal{M})$ $$ Pr(\mathcal{M}(D) \in \mathcal{S}) \leq e^\epsilon * Pr(\mathcal{M}(D') \in \mathcal{S})\text{.}$$ \end{definition} An important property of differential privacy is its immunity to post-processing, which is expressed as follows: \begin{definition}[Post-processing]~\cite{dwork2014algorithmic} \label{def:immunity} Let $\mathcal{M}$ be a randomized algorithm that is $(\epsilon, \delta)$-differentially private. For any arbitrary randomized mapping $f:\mathcal{R}^q \rightarrow \mathcal{R}^r$ where $p,q \in \mathbb{N}^+$, $f\circ \mathcal{M}$ is $(\epsilon, \delta)$-differentially private. \end{definition} In other words, perturbations to the differentially private outputs without knowing the true values will not violate the privacy guarantee. \vspace{-2mm} \subsection{The Boneh-Shaw Codes} \label{sec:bs} The Boneh-Shaw codes~\cite{boneh1998collusion} is a kind of collusion-resistant fingerprinting binary codes. It catches one of the colluders with only a probability $\omega$ of incorrect accusation with $c$ service providers colluding ($\omega$-secure) under the marking assumption~\cite{boneh1998collusion}. $\Gamma(n, d)$-codes serve $n$ users and consist of $n*d$ digits. Each user $i \in [1,n]$ gets the first $(i-1)*d$ bits as $1$'s and the rest $(n-i)*d$ as $0$'s. An example of the $\Gamma(4,3)$ code is: \{111-111-111, 000-111-111, 000-000-111, 000-000-000\}, and each user receives one of the codewords. By identifying the first block with a majority of $1$'s in the leaked data, e.g., the $i$-th block, the algorithm considers the user $i$ as guilty. In the above example, if 001-011-111 is leaked, the $2$nd user who owns 000-111-111 will be accused of leaking the data since the $2$nd block is the first block with a majority of $1$'s. \vspace{-2mm} \subsection{The Tardos Codes} \label{sec:tardos} The Tardos codes~\cite{tardos2008optimal} are another binary fingerprint technique under the marking assumption. The codes utilize randomization in construction and provide $\omega$-secure against colluding attacks, while they require a shorter code length than the Boneh-Shaw codes in the same setting. The construction of the Tardos codes requires the number of sharings $n$, the number of colluding units $c$, and the expected security $\omega$. The minimal binary code length to ensure $\omega$-secure is $m = 100c^2k$, where $k=\lceil \log (1/\omega)\rceil$ ($\log$ refers to natural logarithm). Let $t = 1/(300c)$ and $sin^2t'=t, 0<t'<\pi /4$. $p_i$ denotes the probability of $1$ at position $i$, i.e., $Pr(X_i=1)=p_i$, and is independently calculated. To select the probability for each position $i$, we sample $r_i \in [t', \pi /2-t']$ uniformly and then acquire $p_i = sin^2r_i$. Let $X_{ji}$ denotes the $i$-th digit of the user $j$ and $\mathcal{Y}=\{y_1, y_2, \dots, y_m\}$ is the leaked data. While accusing the colluders, the codes use a scoring function as \begin{equation} U_{ji} = \begin{cases} \sqrt{\frac{1-p_i}{p_i}} & \text{if $X_{ji} = 1$}\\ -\sqrt{\frac{p_i}{1-p_i}} & \text{if $X_{ji} = 0$}\\ \end{cases} \end{equation} and accuse the user $j$ if $\sum_{i=1}^m y_i U_{ji} \geq 20ck$. \section{Problem Statement} \label{sec:problems} In this section, we describe the system setting, including the data model, the system model, and the threat model. Table ~\ref{tab:symbol} shows the commonly used symbols in the paper. \begin{table}[t] \footnotesize \centering \caption{\label{tab:symbol}Symbols and notations.} \begin{tabular}{|p{2.9cm}|p{4.8cm}| } \hline $\mathcal{X}=[x_1,x_2,\dots,x_{|\mathcal{X}|}]$ & A trajectory \\ $\hat{\mathcal{X}} =[\hat{x_1},\hat{x}_2,\dots,\hat{x}_{|\hat{\mathcal{X}}|}]$ & The trajectory released by the differential privacy mechanism\\ $\mathcal{X}^*=[x^*_1,x^*_2,\dots,x^*_{|\mathcal{X}^*|}]$ & The trajectory released by the post-processing \\ $\mathcal{X}'_j=[x'_{1j},x'_{2j},\dots,x'_{|\mathcal{X}'|j}]$ & The fingerprinted trajectory of the data analyzer $DA_j$ \\ $\mathcal{Y}=[y_1,y_2,\dots,y_{|\mathcal{Y}|}]$ & The leaked trajectory \\ $\mathcal{G}$ & The location alphabet \\ $m$ & The trajectory length, i.e., $|\mathcal{X}|$ \\ $p$ & The fingerprinting ratio \\ $n$ & The number of data analyzers \\ \hline \end{tabular} \end{table} \vspace{-2mm} \subsection{Data Model} \label{sec:data_model} We introduce the data model for our system, including the format of trajectories, discretization, and correlations. \vspace{-1mm} \subsubsection{Trajectories} A trajectory $\mathcal{X}=[x_1,x_2,\dots,x_{|\mathcal{X}|}]$ is an ordered sequence of location data points with the same time interval between any adjacent location points. In our setting, a location point $x$ consists of GPS coordinates only, since we pre-process the trajectories to share the same time interval and omit the timestamps. Although some secondary metadata can occur such as velocities and directions, we leave these to future work. \vspace{-1mm} \subsubsection{Map Discretization} In location settings, a map area is often discretized into cells for simplicity~\cite{gursoy2018differentially, xiao2015protecting, he2015dpt, chen2012differentially}. Following those existing works, we divide the continuous two dimensional space using a uniform grid of $N_{lat} \times N_{lng}$. Throughout the rest of the paper, we still use "points" to represent a discretized area for generalization. \vspace{-1mm} \subsubsection{Correlations} \label{sec:correlation} We build our correlations using the Markov chain. For each location $g \in \mathcal{G}$, the transition probability is modeled as $Pr[Xg|X]$, where $X$ is a prefix sequence of $|X|$ points and can be empty. We use the $2$-gram model in our scheme ($|X|=1$). We continue the discussion in Section~\ref{sec:corr_discussion}. \vspace{-2mm} \subsection{System Model} \label{sec:system_model} The system workflow is shown in Figure~\ref{fig:model}. There are two parties in our setting: the service provider and the data analyzers. A service provider, e.g., Google Maps or a carpooling application, collects users' location trajectories while offering the corresponding service(s) to the users. The service provider stores the location dataset in their data server and is willing to share them with other parties. Meanwhile, researchers and businesses, categorized as data analyzers, want to access such location datasets. As discussed, releasing location data may raise privacy concerns. Therefore, the service provider aims to ensure users' location privacy before sharing. More specifically, it applies a privacy-preserving approach that prevents recipients (data analyzers) from knowing the users' exact locations. This process inevitably perturbs the data and influences data utility, which is not desired by the analyzers, especially when strong protection is applied. To best serve the analyzers and keep the users' privacy intact simultaneously, we propose post-processing techniques at the service provider to regain partial data utility. \begin{figure}[h] \centering \includegraphics[width=0.45\textwidth]{images/model_updated.png} \caption{The system model.} \label{fig:model} \end{figure} As also discussed, a misbehaving data analyzer may distribute (leak) a copy of the received location dataset to other untrusted parties without permission. Therefore, we propose a novel fingerprinting scheme for location trajectories, using which the service provider embeds unique fingerprint patterns into each shared location dataset. The proposed fingerprinting scheme is robust in case the attacker tries to distort the fingerprint by exploiting the correlations among the location data from public sources or by colluding with other misbehaving data analyzers which also receive the same location dataset (with different unique fingerprint patterns). Furthermore, the fingerprinting scheme is integrated into the aforementioned post-processing to minimize the utility degradation in the shared dataset. \begin{figure}[h] \centering \includegraphics[width=0.45\textwidth]{images/detection_updated.png} \caption{Detecting the source of the unauthorized redistribution.} \label{fig:detection} \end{figure} The fingerprint detection workflow (for the source of an unauthorized redistribution) is shown in Figure~\ref{fig:detection}. Once an unauthorized dataset is found publicly, the service provider performs an aggregate detection scheme. It runs the detection scheme for each trajectory in the leaked dataset. The service provider aggregates the detection results (e.g., scores) and finally accuses an analyzer of leaking the dataset. The details are given in Section~\ref{sec:detection}. \section{Related Work} \label{sec:related_works} In this section, we introduce some existing works in location privacy and digital fingerprinting, respectively. \vspace{-1.5mm} \subsection{Location Privacy} \label{sec:related_privacy} \vspace{-0.5mm} Location data contain sensitive information such as moving patterns and preferred locations. Traditional privacy enhancing techniques, e.g., k-anonymity~\cite{sweeney2002k} and l-diversity~\cite{machanavajjhala2007diversity}, have been adapted to the location setting. However, for a location dataset, those methods have their limitations in dealing with data streams with various lengths. Some works~\cite{fung2008anonymity, abul2008never} split the trajectories into equal-length fragments and achieve privacy on the fragment, which is not sufficient for privacy protection on trajectories. Differential privacy~\cite{dwork2008differential} as a popular privacy definition has also been used to protect location datasets in recent years~\cite{shokri2014privacy, yu2017dynamic, cao2017quantifying, shokri2011quantifying}. Geo-indistinguishability~\cite{andres2013geo} defines a variant of differential privacy based on the distance between the points of interests, but it only works on location points instead of trajectories. Several methods~\cite{chen2012differentially,gursoy2018differentially, he2015dpt} provide differential privacy to the statistics extracted from original location datasets. Some of those works~\cite{,gursoy2018differentially, he2015dpt} also generate a synthetic dataset instead of the statistics. Those works completely eliminate moving features of any specific user while preserving statistics, which significantly decreases the usability of the dataset from certain services, e.g., map navigation and carpooling. \cite{jiang2013publishing} releases differentially private trajectories by sampling and interpolating them. Still, the scheme has an additional restriction that the start and end locations are revealed in advance. \cite{xiao2015protecting} generates perturbed trajectories by considering point-wise correlations and prior knowledge from previous released points. The method fits our objective and provides enough privacy protection to trajectories. We use it to achieve privacy guarantees for location datasets and provide the details in~Section \ref{sec:apply_dp}. \vspace{-1.5mm} \subsection{Digital Fingerprinting} \label{sec:related_fingerprinting} \vspace{-0.5mm} Digital fingerprinting embeds a unique identifier, e.g., a sequence of marks, to the data by adding, removing or editing partial values of the data. Several works have been proposed to enable digital fingerprinting for data distribution~\cite{cheng2011anti, boneh1998collusion, tardos2008optimal}. Boneh and Shaw design a fingerprint code and prevent the receivers from colluding~\cite{boneh1998collusion}. Tardos et al. propose a probability-based fingerprinting scheme that can catch all suspicious individuals simultaneously~\cite{tardos2008optimal}. However, those methods are designed for binary streams, where pairwise correlations are omitted in most cases. Considering correlations, some researchers aim to provide fingerprint robustness in the data with various types, i.e., relational databases~\cite{wu2004collusion, li2005fingerprinting, ji2021curse, liu2004block} or multimedia~\cite{lafaye2008watermill}. These approaches are not applicable as well since trajectories in location datasets contain high correlations between neighboring location points, which is a different setting. \cite{yilmaz2020collusion} introduces a fingerprinting scheme for sequential data that considers correlations between data points. However, it only works when the states are limited and inter-transitable. We improve this work and implement it in our system. \subsection{Threat Model} \label{sec:threats} In this section, we introduce the threat model considering the parties in our system. The service provider is the only entity that accesses raw data from the users. Thus, we assume the service provider is honest (i.e., it does not distribute unauthorized copies of users' data to other unauthorized parties). As we will discuss in Section~\ref{sec:decentral_discussion}, location data can also be shared by the users in a differentially private way, which prevents the service provider from knowing the original data as well. But, in this work, since we focus on the privacy and unauthorized redistribution of the location datasets that are shared by a service provider, we do not consider that part. Nevertheless, what we proposed can be easily extended to provide privacy of users' data during the sharing process with the service provider. The analyzers are considered to be potentially malicious. The analyzers understand that the dataset has been perturbed to protect the privacy of dataset participants, but they may be curious about the original (non-perturbed) data values in the dataset. For this, they can utilize auxiliary information from public sources, e.g., the correlations in the map area of interest. They build their knowledge along each trajectory using a hidden Markov model, where the original values along the trajectory are states and the reported values at those positions are the observations (details are in Section~\ref{sec:apply_dp}. With the help of those auxiliary information, they can analyze the received trajectories and try to infer the true location points. From the perspective of fingerprinting, a malicious analyzer (i.e., attacker) may want to redistribute only one trajectory or a subset of the location dataset (i.e., multiple trajectories) to other parties, e.g., motivated by profit, without being accused. To avoid being tracked, the analyzer tries to distort the fingerprint signature. They can exploit the public correlations, collude with other analyzers, or even use both to hide their identity. In the rest of the section, we discuss all the attacks the analyzers can perform against the proposed fingerprinting scheme. \vspace{-1mm} \subsubsection{Random Distortion Attack} The random distortion attack is the baseline attack in which the attacker distorts the location points in the trajectory in order to distort the fingerprint. For each location point in the trajectory, the attacker adds a $2$-dimensional multivariate Laplacian noise with a probability $p_r$. \vspace{-1mm} \subsubsection{Correlated Distortion Attack} The attacker can utilize the public correlations to improve the baseline distortion. This attack was first introduced in~\cite{yilmaz2020collusion}. In this attack, the attacker analyzes the correlations between consecutive points along the trajectory from the start to the end. It checks the 2-gram transition from the previous point to the current one, i.e., $Pr(x_j|x_{j-1})$ at location $j$. If the transition probability is lower than a threshold $\tau$, the attacker considers the point is fingerprinted with high probability. The attacker decides to distort the point with a probability of $p_c$. The attacker first constructs a set containing all highly probable locations, i.e., the transition probability from the previous point $x_{j-1}$ to each point in the set is at least $\tau$. The attacker samples an output based on the transition probability from the last true point $x_{j-1}$ to each point in the set. By doing so, the attacker distorts the suspicious positions, and thus avoids being detected. If multiple parties collude by sharing their copies with each other, they can perform more powerful attacks. We consider two types of collusion attacks in our setting, differing in whether the attackers take auxiliary information into account. \vspace{-1mm} \subsubsection{Majority Collusion Attack~\cite{boneh1998collusion}} In the majority collusion attack, the attackers collude and analyze the merged dataset point by point. At each position, the attackers always choose the most frequent value as the output. The majority voting makes the trajectory lose some fingerprint bits, which may mislead the fingerprint detection mechanism and result in accusing an innocent party. \vspace{-1mm} \subsubsection{Probabilistic Collusion Attack~\cite{yilmaz2020collusion}} Similar to the correlated distortion attack, the correlated collusion attack~\cite{yilmaz2020collusion} exploits the auxiliary information. The attackers share the datasets and analyze them using correlations, i.e., the transition probabilities. They also set a probability $p_e$ to approximate the actual fingerprinting probability $p$. Suppose the attackers are deciding the output for the $j$-th position in a trajectory. The attackers collect all the location at position $j$ to form an alphabet $G = \{g_1, g_2, \dots, g_K\}$ at this position, where $K$ is the number of the distinct locations, and count the occurrence as $c_{j,k}$ for each location $g_k$, $k\in[1,K]$. The attackers filter those with low transition probabilities from the last released point $y_{j-1}$. Among the remaining set, they perform the probabilistic sampling, where the probability is proportional to $(1-p_e)^{c_{j,k}} \cdot (\frac{p_e}{|G_j|-1})^{n-c_{j,k}} \cdot P(x_j = g_k | x_{j-1} = x'_{j-1})$, where $G_j$ refers to the alphabet at position $j$. The first part $(1-p_e)^{c_{j,k}} \cdot (\frac{p_e}{|G_j|-1})^{n-c_{j,k}}$ is the probability of $g_k$ being the original location at position $j$ based on the assumed probability $p_e$, and the latter part is the transition probability from the previous location. By combining the two parts, the attackers are able to calibrate such probability that a location with a very low probability is barely the true location even it occurs multiple times, and a location with a high probability in the correlation model is more likely to be the true value although it occurs rarely. The attackers finally sample a location based on the weighted probability distribution and report that location at position $j$.
{'timestamp': '2022-04-12T02:28:12', 'yymm': '2204', 'arxiv_id': '2204.04792', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04792'}
arxiv
\section{Introduction} \label{sec:intro} \begin{figure}[ht] \centering \includegraphics[width=\linewidth]{figs/teaser.pdf} \caption{The trend of WDL approaches from the perspective of a business task in Alibaba. The average GPU utilization of these models is collected from the training workloads by an in-house optimized Tensorflow in PS training strategy. The statistics show that along with the performance improvement, training WDL models does not take full advantage of the GPU resources by the canonical training frameworks (which reach 95\%+ GPU utilization when training CV or NLP models of same scale).}\label{fig:teaser} \end{figure} Recommender systems have nowadays become the key for higher revenue, user engagement, and customer retention on social network and E-commerce platforms. To cope with the explosive data growth, recommender systems are quickly evolving from collaborative filtering~\cite{schafer2007collaborative} (CF) to deep neural network (DNN) models and consistently improving the task accuracy, as shown in Fig.~\ref{fig:teaser}. Starting from Google's Wide\&Deep~\cite{cheng2016wide}, the innovation of industrial-scale recommendation models~\cite{guo2017deepfm, zhou2018deep, zhou2019deep, naumov2019deep, qi2020search, zhou2020can} follows two trends: 1) the embedding layer becomes wider, consuming up to thousands of feature fields~\cite{naumov2019deep}; 2) the feature interaction layer is going deeper~\cite{naumov2019deep, qi2020search, zhou2020can} by leveraging multiple DNN submodules over different subsets of features. We denote these models as Wide-and-Deep Learning (WDL{}) Recommendation Models. The industrial WDL{} models must be periodically re-trained to reflect user interest drift and new hot spots timely and accurately. Hence, high training throughput is critical for WDL{} models to catch up streaming data and reduce the latency of continuous delivery~\cite{chen2015continuous}. Training the state-of-the-art WDL{} models via Parameter Server (PS)~\cite{li2014scaling} on a large-scale distributed CPU cluster is time-consuming owing to insufficient computation capability to accomplish deep feature interactions. Recent work, represented by Facebook's TorchRec\footnote{https://github.com/facebookresearch/torchrec, \emph{Accessed: 2021.11.30}}, Baidu's PaddleBox~\cite{MLSYS2020_f7e6c855}, and NVIDIA's HugeCTR\footnote{https://github.com/NVIDIA-Merlin/HugeCTR, \emph{Accessed: 2021.11.30}} prefer a GPU-centric synchronous training framework on WDL{} workloads because high-end NVIDIA GPU (e.g., NVIDIA Tesla V100) has a 30x higher single precision FLOPS over Intel CPU~\footnote{https://www.nvidia.com/en-us/data-center/v100/, \emph{Accessed: 2021.11.30}}. Most of these efforts do improve the training throughput by leveraging GPU devices. However, we observe substantial hardware underutilization (e.g., measured GPU utilization) along with the growing number of feature fields and feature interaction modules, as illustrated in Fig.~\ref{fig:teaser}. This implies that the WDL{} training workloads are far from achieving the peak performance of hardware, and a further acceleration shall be anticipated. Although customizing hardware for a specific WDL{} workload pattern could be an option~\cite{smelyanskiy2019zion}, there are following concerns: 1) We have various WDL{} designs owning markedly different workload patterns (e.g., the number of feature fields, the submodules of feature interaction layer), and new WDL{} models are emerging monthly; 2) For public cloud usage, commodity hardware is preferred for the sake of budget and elasticity. Thus, we raise two questions of \emph{What causes the hardware underutilization issue in training WDL{} models?}, and \emph{Can we address this issue from software system's perspective?} We conduct a systematic analysis (detailed in \S\ref{sec:implication}) across a variety of WDL{} workloads and obtain implications as follows: \begin{enumerate}[leftmargin=*] \item WDL{} model training has fragmentary operations within embedding and feature interaction layers because of the massive number (up to thousands) of feature fields, which brings in a non-trivial overhead of launching operations (e.g., issuing a CUDA kernel to CUDA streams) and hardware underutilization. \item The embedding layer of WDL{} model mainly consists of memory-intensive and communication-intensive operations (in distributed environments), while the feature interaction and multi-layer perceptron (MLP) own computation-intensive operations. The computing resource would be underutilized in processing the large volume of embedding parameters and leads to a pulse-like GPU usage. \end{enumerate} We then propose a novel framework with Packing, Interleaving and Caching Augmented Software System Optimization (PICASSO{}) to answer the above two questions. First, we create fine-grained embedding feature groups. Operations within the same group are packed to reduce the number of fragmentary operations; Second, operations from distinct groups are interleaved from both of data level and kernel level to improve hardware utilization; Third, we develop a data distribution-aware caching mechanism leveraging the large volume of DRAM and the high bandwidth of GPU device memory. \par Evaluation shows that PICASSO{} significantly improves the GPU utilization during training a variety of industrial WDL{} models, and it accelerates the throughput by an order of magnitude compared to state-of-the-art generic training frameworks. PICASSO{} has been deployed in our in-house training cluster, appearing as \underline{XDL2} within Alibaba and \underline{HybridBackend} in AliCloud. The delay to continuous delivery is decreased from 8.6 hours to 1.4 hours on average, which is unprecedented inside Alibaba and instructive to the community. We summarize the main contributions of this paper as follows: \begin{enumerate}[leftmargin=*] \item We analyze the hardware underutilization and reveal the cause when training WDL{} models by GPU-centric synchronous frameworks. \item We propose PICASSO{} that resolves the underutilization issue with a software-system approach that is applicable to commodity hardware. \item We build a system that sustains our daily production workloads with up to a trillion parameters and petabytes of training data, achieving 6x training performance speedup on average without increasing the budget. PICASSO{} has been released for public cloud usage~\footnote{https://github.com/alibaba/HybridBackend}. \end{enumerate} \begin{figure}[tp] \centering \includegraphics[width=\linewidth]{figs/hsdl_architecture.pdf} \caption{A Standard architecture of WDL{}, 1) \emph{The embedding layer} ingests multiple fields of features (as opposed to NLP tasks with only one field of ``word''), adopts various hashing or numerical operations, and queries embedding (in various dimension) from memory; 2) \emph{The feature interaction layer} processes the fetched feature embeddings through a number of feature interaction modules; 3) the outputs of the modules are concatenated and fed to the multi-layer perception (MLP) for yielding final predictions.}\label{fig:rec_model} \end{figure} \section{Implication from Analyzing Workloads} \label{sec:implication} \subsection{Architecture of WDL{} Models} \label{subs:implication-arch-models} WDL{} models share a typical architecture as shown in Fig.~\ref{fig:rec_model}: \noindent \textbf{Data Transmission Layer} processes streamed training data in the form of categorical feature identity (ID) as well as dense feature vectors. Categorical feature IDs usually have a varying length (i.e., multi-hot or non-tabular data), and they can reach up to tens or hundreds of MBytes within a batch. Normally, the data is stored in remote databases and requires a transmission via Ethernet; \noindent \textbf{Embedding Layer} projects a high-dimensional feature space of sparse categorical features to a low-dimensional embedding feature space. The embedding parameters are represented by dense vectors named \emph{feature embedding}, and they are stored in DRAM in the form of \emph{embedding table}s. Each feature embedding can be queried by its categorical feature ID to get trained in WDL{}. Since a large volume of feature embeddings would be queried from DRAM per training batch, the embedding layer is dominated by memory-intensive operations. \begin{figure*}[t] \centering \begin{minipage}[t]{0.28\linewidth} \centering \includegraphics[width=\linewidth]{figs/Data_Distribution.pdf} \caption{Distribution of categorical feature IDs across representative WDL{} datasets.} \label{fig:investigation} \end{minipage} \hfill \begin{minipage}[t]{0.7\linewidth} \centering \includegraphics[width=0.99\linewidth]{figs/lowlevel.pdf} \caption{Low-level projection of the standard architecture of WDL{} models: the multiple feature fields and constituent feature interaction modules would duplicate a large number of operations in the computation graph.}\label{fig:lowlevel} \end{minipage} \end{figure*} \noindent \textbf{Feature Interaction Layer} would first organize feature embeddings from the embedding layer into several groups. Each group applies an individual \emph{feature interaction module}, such as GRU~\cite{chung2014empirical} and Transformer~\cite{vaswani2017attention}, to extract useful information from intra-group feature embeddings. The outputs of the constituent feature interaction modules are then concatenated to form a final output of the feature interaction layer. There could be tens of constituent feature interaction modules to engage different subsets of feature embedding, yielding up to hundreds of thousands of operations. \noindent \textbf{MLP} builds fully-connected layers to provide final predictions by the training data of a batch. MLP also contains computation-intensive architectural units such as batch normalization~\cite{ioffe2015batch} and residual connection~\cite{he2016deep}. It is worth noting that the accuracy loss is usually intolerable in many business scenarios. Thus, generic acceleration strategies (e.g., half-precision, quantized pruning \cite{alistarh2017qsgd}, gradient staleness) may only apply to a fraction of WDL{} models. \subsection{Data Distribution in WDL{} Workload} \label{subs:data-distribution} The categorical feature IDs of each feature field are usually skewed or non-uniformly distributed. We investigate the data distribution of five representative WDL{} datasets (statistics are listed in Tab.~\ref{tab:dataset}) and Fig.~\ref{fig:investigation}. When being sorted in a descending order by frequency, 20\% of IDs will cover 70\% by average and up to 99\% of the training data. Therefore, it is beneficial to cache frequently accessed data when training WDL{} models. \subsection{Distributed Training Strategies of WDL{} Model} \label{subs:implication-train-mode} In general, three types of training strategies are adopted in training WDL{} models in a GPU-centric distributed system: \noindent \textbf{Parameter Server (PS) Strategy} \cite{li2014scaling} is still the de facto training strategy applied in industry, where training data is partitioned across multiple \emph{worker nodes} while model parameters are partitioned across multiple \emph{server nodes}. Worker nodes would \emph{pull} down model parameters from server nodes and train them by using local partitioned training data; By the end of each iteration, worker nodes would \emph{push} up corresponding gradients back to server nodes asynchronously to update the parameters. \noindent \textbf{Data-parallel (DP) Strategy} is the default distributed training strategy by frameworks such as Tensorflow~\cite{cheng2017tensorflow} and PyTorch~\cite{li2020pytorch}. The training data is evenly partitioned across all worker nodes while the model parameters are replicated across all worker nodes. It uses a collective communication primitive named \emph{Allreduce} to aggregate gradients and thus updates local replica of model parameters synchronously. \noindent \textbf{Model-parallel (MP) Strategy}~\cite{dean2012large,kim2019parallax} has no server nodes. Instead, it partitions and stores all parameters across multiple worker nodes. It then uses a collective communication primitive named \emph{AllToAllv} to exchange data among all worker nodes synchronously. \subsection{Characterization of WDL{} Workload} \label{subs:characterize_model_arch} We first conduct a low-level projection of WDL{} workloads to the underlying hardware, and we then summarize three representative workload patterns. \par Each WDL{} layer consists of a set of \emph{operator}s from the algorithmic perspective. An operator is normally implemented as a kernel in programs, and their invocations during the training are referred as the \emph{operations}. The execution of an operation requires various hardware resources. Fig.~\ref{fig:lowlevel} illustrates a low-level projection of a standard WDL{} model trained within a distributed system with respect to three types of hardware resources: intra-node bandwidth (e.g, DRAM and PCIe bandwidth), computing resource (e.g., GPU Streaming Multiprocessors (SM)), and inter-node bandwidth (NVLink and Ethernet bandwidth). In distributed training of WDL{} models, the embedding layer mainly consists of the following operators: \texttt{Unique} (eliminate redundant categorical feature IDs to reduce memory access overhead), \texttt{Partition} (partition categorical feature IDs into local IDs and remote IDs), \texttt{Gather} (query local IDs from embedding tables), \texttt{Shuffle} (communicate remote worker nodes to fetch feature embeddings belonging to remote IDs), \texttt{Stitch} (concatenate locally queried feature embeddings and remotely fetched feature embeddings), and \texttt{SegmentReduction} (pooling feature embedding by segments, e.g., summation of behaviour feature embeddings from the same \emph{user}). The embedding layer has a majority of operators bounded by a dominant type of hardware resource (e.g., the \texttt{Shuffle} operator is bounded by inter-node bandwidth). The feature interaction layer and MLP have operators mainly bounded by computation resources. Similarly, the backward pass can be treated as a mirror image of the forward pass. In a synchronous GPU-centric training system, this low-level projection indicates that the hardware resource usage is sporadic, which implies that, at a time, the training would be bounded by one type of hardware resource while the other types of resource are underutilized. \par This projection reflects three characteristics of WDL{} workloads compared to CV and NLP workloads. \begin{itemize}[leftmargin=*] \item Embedding layer and feature interaction layer involve a massive number of small-sized operations (i.e., embedding of single feature field could involve hundreds of operations, and WDL{} workload would have to process up to thousands of feature fields), which has a significant launch overhead. \item The invocations of the same operator from the embedding layer by different feature fields would race for the same type of hardware resource at a time, which bounds the throughput when the hardware resource is relatively strained (e.g., PCIe bandwidth between CPU and GPU). \item The skewed data distribution as described in \S\ref{subs:data-distribution} would cause unbalanced hardware resource usage across worker nodes in distributed systems, which shall compromise the throughput during synchronous training. \end{itemize} \begin{figure}[tp] \centering \includegraphics[width=\linewidth]{figs/breakdown.pdf} \caption{Worker-side breakdown of the three WDL{} models by PS and MP strategies (``exposed'' indicates the period when the operation blocks all the others).}\label{fig:breakdown} \end{figure} We probe into the statistics of WDL{} workloads from a cluster of NVIDIA Tesla V100s (``EFLOPS'' in Tab.~\ref{tab:testbed}) at Alibaba Cloud (composed of commodity hardware devices, as specified in \cite{dong2020eflops}). The models are implemented by Tensorflow under either PS strategy or MP strategy as introduced in \S\ref{subs:implication-train-mode}. We observe three representative patterns from the profiling and worker-side performance breakdown, as shown in Fig.~\ref{fig:breakdown}. \begin{itemize}[leftmargin=*] \item \emph{I/O\&Memory Intensive Workload}. WDL{} models represented by \emph{W\&D}~\cite{cheng2016wide} have substantial data transmission and embedding lookup operations, where the I/O may not be fully overlapped by the other procedures, as shown in Fig.~\ref{fig:breakdown}. I/O\&Memory intensive models emerge along with the prosperity of feature engineering and transferable pretrained embedding, where massive feature fields should be tackled to achieve the best accuracy. Even with I/O optimization, the exposed I/O and memory access still occupy around 20\% of the total training walltime in Fig.~\ref{fig:breakdown}. \item \emph{Communication Intensive Workload}. This type of workload spends most of the time in communication-related operations. The large volume of communication from fetching remote high-dimensional embedding features as well as the frequent parameter exchange from high-order cross features cause severe communication overhead in distributed WDL{} workloads. We take CAN~\cite{zhou2020can} for instance, which is recently derived from DIN~\cite{zhou2018deep} and DLRM~\cite{mudigere2021high}. CAN contains a combination of feature interaction modules over a substantial number of feature fields, and therefore it brings up an extensive communication overhead by around 60\% in MP mode and 70\% in PS mode as shown in Fig.~\ref{fig:breakdown}. \item \emph{Computation Intensive Workload}. Some WDL{} models are throttled by computation operations, since deep and complex WDL{} models benefit from the advancement in the domain of CV and NLP. A variant of MMoE~\cite{zhao2019recommending}, which is derived from canonical DIN~\cite{zhou2018deep} and owns 71 experts at MLP, serves for scenario-aware CTR prediction in our business. In Fig.~\ref{fig:breakdown}, MMoE spends about 50\% of the training time in arithmetic calculations. In practice, computation-intensive WDL{} models tend to work for scenarios of multiple sub-tasks \cite{sheng2021one} (e.g., multi-objective learning, meta-learning), super-complicated computation \cite{senior2020improved} (e.g., extremely-deep network over a number of feature fields), and multi-modal co-training \cite{wei2019mmgcn}. \end{itemize} \section{System Design of PICASSO{}}% \label{sec:design_and_architecture} In this section, we first introduce the overall architecture of PICASSO{}, which accommodates the hardware topology of GPU-centric training cluster and thus allows a hybrid distributed training strategy for WDL{} models. Second, we introduce a three-fold key idea of accelerating training by improving hardware utilization. \subsection{Hybrid Distributed Training Strategy}% \begin{figure}[t] \centering \includegraphics[width=1.0\linewidth]{figs/hybrid-parallel-arch-santa.pdf} \caption{PICASSO{} allows the hybrid strategy of MP and DP, where embedding parameters are partitioned across PICASSO-Executor{}s (MP), and dense parameters are replicated across PICASSO-Executor{}s (DP). Besides, canonical DP and MP are also supported by PICASSO{}.}% \label{fig:sys-design-hb} \end{figure} We propose the architecture of PICASSO{} in Fig.~\ref{fig:sys-design-hb}, which is designed for GPU-centric clusters. One such cluster usually consists of multiple homogeneously configured \emph{machines (cluster node)}, and each machine instead has a heterogeneous architecture, including processors (e.g., Intel CPU), accelerators (e.g., NVIDIA GPU), and the uncore system (e.g., DRAM). In addition, there are interconnects like PCIe and NVLink among components within a machine, and all these machines are further connected through Ethernet as a distributed system. Correspondingly, PICASSO{} sets up multiple \emph{PICASSO-Executor{}}s, which are mapped to different machines in the cluster. Each PICASSO-Executor{} has heterogeneous hardware resource: 1) GPU Stream Multiprocessor (SM) and CPU physical cores as computation resource; 2) hierarchical memory subsystem made of GPU device memory, DRAM, Intel Persistent Memory, and SSD (if accessible) as memory storage resource; 3) hierarchical interconnects like NVLink, PCIe, InfiniBand, and Ethernet as communication resource. \par With this architecture, PICASSO{} can customize hybrid distributed training strategies for different layers within WDL{} model as follows: \begin{itemize}[leftmargin=*] \item The embedding layer has a tremendous volume of embedding parameters, and it adopts a model-parallel (MP) strategy. The embedding parameters are partitioned across all PICASSO-Executor{}s and stored within the hierarchical memory subsystem. The parameters are exchanged synchronously among PICASSO-Executor{}s via the AllToAllv collective communication primitive. \item Feature interaction layer and MLP have a much smaller volume of parameters than the embedding layer. We adopt a data-parallel (DP) strategy for those two layers, where the parameters are replicated across all PICASSO-Executor{}s and aggregated via the Allreduce primitive. \end{itemize} \subsection{Packing} \label{subs:packing} \begin{figure}[htpb] \centering \includegraphics[width=1.0\linewidth]{figs/pack.pdf} \caption{Illustration of \emph{packing} optimization: a) Without packing, looking up feature embedding from three embedding tables requires a total of 18 operators; b) By D-packing and K-packing, PICASSO{} reduces the total number of operators to 4 packed operators.} \label{fig:packing} \end{figure} To address the fragmentary operations as described in \S\ref{subs:characterize_model_arch}, we propose a \emph{Packing} method that effectively reduces the number of operations from two aspects: \begin{figure*}[htp] \centering \includegraphics[width=\linewidth]{figs/interleaving.pdf} \caption{ (a) \emph{D-Interleaving} starts from MLP to eliminate GPU device memory capacity bounds; (b) \emph{D-Interleaving} starts from the embedding layer to reduce overhead. (c) \emph{K-Interleaving} the packed and non-packed embedding operations on different hardware resource.}% \label{fig:interleave} \end{figure*} \noindent\textbf{Data-Packing} (D-Packing). When categorical feature IDs from different feature fields are fed into the same operator within the embedding layer, PICASSO{} combines categorical feature IDs into a single \emph{packed ID tensor}. Thus, we can launch a single operation (named \emph{packed operation}) to process the packed data, which fits into the Single-Instruction-Multiple-Data (SIMD) programming paradigm~\cite{patterson2016computer} of NVIDIA GPU devices. Also, it significantly reduces the overhead of launching a massive number of operations onto GPU devices. In addition, a naive strategy of packing up all categorical feature IDs into a single tensor may cause severe throughput issues. For instance, industrial-scale recommender systems usually implement embedding tables by using a \emph{hashmap} to accommodate the growing amount of feature embedding. A massive number (million-level) of concurrent querying requests shall suffer from the low-level locks of a hashmap. Therefore, we pack up categorical feature IDs when their embedding tables share the same feature dimension. Thus, we obtain packed operations with the number proportional to that of distinct feature dimensions. Nevertheless, some packed operations may still encounter too many concurrent queries to compromise the throughput of the hashmap due to skewed data distribution and large feature dimensions. We propose a method to evaluate the execution cost by estimating the parameter volume (the number of floats) within packed operations as shown in Equation~\ref{eq:pack-vars}. \begin{equation} \label{eq:pack-vars} \text{CalcVParam}(T) = N\sum_{t\in T}(t_{\text{dim}}\sum_{\text{ID}\in t}\text{ID}_{\text{freq}}), \end{equation} where $N$ refers to the total number of categorical feature IDs, $T$ refers to a packed embedding table, $t_{\text{dim}}$ denotes the feature dimension of an embedding table, and $\text{ID}_{\text{freq}}$ refers to the frequency of a categorical feature ID. $N$ and $\text{ID}_{\text{freq}}$s would be obtained from the statistics in the warm-up iterations. If a packed operation has a high $\text{CalcVParam}(T)$ above average, we shall further evenly split it into multiple shards. For instance, suppose that we have one packed operation for all embedding tables with a feature dimension of 8 and the data distribution is uniform. For embedding tables with a dimension of 32, we will create four shards of packed operations, each with a quarter of these embedding tables. \noindent\textbf{Kernel-Packing} (K-Packing). Kernel fusion is already a widely adopted optimization for deep learning systems. There are mainly two approaches: 1) hand-written huge kernels; 2) compilation-based code generation. Huge kernels, such as fusing the whole embedding layer into a single CUDA kernel, would miss the opportunity of interleaving operations bounded by distinct hardware resources (see details in \S\ref{subs:interleaving}). Compilation-based code generation relies on static input and output shapes from each operator to infer the suitable sizes for generated kernels. However, categorical feature IDs induce dynamic operator shapes that disrupt the efficiency of compilation techniques like Tensorflow XLA. In contrast, our kernel-packing evaluates all kernels by their hardware resource utilization, and they are grouped into computation-intensive kernels, memory-intensive kernels, and communication-intensive kernels. We only fuse up kernels from the same kernel group and leave opportunities for interleaving their execution across different kernel groups.\par Fig.~\ref{fig:packing} illustrates the process of our packing optimization. Categorical feature IDs are first grouped together (i.e., D-Packing). Each group of categorical feature IDs is fed into a fused kernel (i.e., K-Packing) named \texttt{Unique\&Partition} to eliminate memory access and data communication from redundant IDs. The categorical feature IDs would be fetched from their local partition of embedding tables. We then develop another fused kernel named \texttt{Shuffle\&Stitch} to fulfill a stitched output of the shuffle kernel and remove the explicit stitch kernel. \subsection{Interleaving} \label{subs:interleaving} After applying the Packing optimization, we further develop two types of \emph{Interleaving} optimization to improve utilization across different hardware resources. \noindent\textbf{Data-Interleaving}(D-Interleaving): When WDL{} model is trained with large batch sizes (e.g., tens of thousand), operations would suffer from various hardware bounds. For instance, the footprint of GPU device memory from intermediate tensors (the so-called \emph{feature map} in Tensorflow) is proportional to the data batch size. Because the capacity of GPU device memory is restricted (e.g., 32GBytes in NVIDIA Tesla V100), large batch size is likely to cause an out-of-memory (OOM) issue and crash the training. However, large batch size is usually desired for both high accuracy and throughput in WDL{} training. Therefore, PICASSO{} adopts a micro-batch-based data interleaving (D-interleaving) approach that allows users to slice and interleave workloads starting from a specified layer of WDL{} models. To address the OOM issue of GPU device memory, we can divide the output embedding of feature interaction layer into several micro batches and apply D-Interleaving on MLP, where the peak GPU device memory usage can be amortized as shown in Fig.~\ref{fig:interleave} (a). Also, we can divide categorical feature IDs into several micro batches and apply D-Interleaving to the rest of the training Fig.~\ref{fig:interleave} (b). By default, we evenly divide data into micro batches to attain a load balancing, and the micro-batch size can be estimated by: \begin{equation} \label{eq:micro-batch} \text{BS}_{\text{micro}} = \min_{\text{op} \in \text{layer}}(\text{RBound}_{\text{op}}/\text{RInstance}_{\text{op}}), \end{equation} where $\text{BS}_{\text{micro}}$ is the estimated micro-batch size, $\text{RBound}_{\text{op}}$ denotes the bound value of an operator's dominant hardware resource (e.g., GPU device memory capacity), and $\text{RInstance}_{\text{op}}$ denotes the cost per data instance from an operator's dominant hardware resource. Since the shape of an operator from the embedding layer is usually dynamic, no analytical values from Equation~\ref{eq:micro-batch} can be deduced in advance. Instead, we determine their values empirically or experimentally from warm-up iterations of training. \noindent\textbf{Kernel-Interleaving}(K-Interleaving): The Packing mechanism transforms hundreds of operations into a small number of packed operations. However, the packed operations from different embedding tables still race for the same hardware resource. For instance, when all the \texttt{Shuffle\&Stitch} operations are launched concurrently, the Ethernet bandwidth would throttle the training throughput. We propose a \emph{Kernel-Interleaving} (K-Interleaving) optimization that establishes control dependencies among groups of packed operations as shown in Fig.~\ref{fig:interleave}. To ensure that a so-called \emph{Interleaving group} would not be bounded by various hardware resources, we first determine the capacity of each interleaving group, denoted as $\text{Capacity}_{\text{g}}$, in terms of processed parameters by: \begin{equation} \label{eq:capacity-i-group} \text{Capacity}_{\text{g}} = \min_{\text{op} \in \text{layer}}(\text{RBound}_{\text{op}}/\text{RParam}_{\text{op}}), \end{equation} where $\text{RBound}_{\text{op}}$ has the same definition as in Equation~\ref{eq:micro-batch} and $\text{RParam}_{\text{op}}$ denotes the cost of training a parameter from an operator's dominant hardware resource. Here, we simply treat the parameter volume as the cost in embedding lookup and exchange. We could also change the number of interleaving groups by proportionally modifying $\text{Capacity}_{\text{g}}$ in PICASSO{}. It is worth noting that we allow users to specify a \emph{preset excluded embedding}, where the packed operations have no control dependencies on the other K-Interleaving groups. For instance, when the output (feature embedding) of some operations will not be concatenated with other feature embedding for the downstream layers, K-Interleaving can advance their downstream operations. \subsection{Caching} \label{subs:caching} \begin{figure}[t] \centering \includegraphics[width=0.9\linewidth]{figs/cache.pdf} \caption{Gather embedding vectors (e.g., ``Emb-8002'') via \emph{Cache} approach upon \emph{HybridHash}.}% \label{fig:cache-and-weave-opt} \end{figure} \emph{Caching} is a widely applied system technique that utilizes the hierarchical memory subsystem to reduce memory access latency. However, the effectiveness of caching, i.e., the \emph{cache hit ratio}, depends on multiple factors such as the data distribution and the access pattern. In \S\ref{subs:data-distribution}, we observe that only 20\% of the categorical feature IDs are being queried in a high frequency, which motivates us to propose an optimization named \emph{HybridHash}. It aims to eliminate two hardware bounds: 1) The DRAM has a large capacity but is bounded by the memory access bandwidth; 2) The GPU device memory has a high bandwidth but is bounded by the limited capacity. \par As shown in Fig.~\ref{fig:cache-and-weave-opt}, HybridHash serves as a hashmap to store, fetch, and update embedding parameters. We refer to GPU device memory as the \emph{Hot-storage} and DRAM as the \emph{Cold-storage}. Unlike other GPU-based hashmap solutions, we consider Hot-storage as an expensive resource, which shall avoid any waste of its capacity. Therefore, we place the hashmap, a sparse data structure, on Cold-storage and utilize Hot-storage only as a scratchpad to store and update the frequently accessed embedding. Recall from \S\ref{subs:data-distribution} that categorical feature IDs in WDL{} workload follow a certain distribution. It is reasonable to record the frequency of each queried ID from the hashmap during a predefined number of warm-up iterations. HybridHash then periodically loads the top-$k$ ($k$ would be determined by the size of Hot-storage) frequent embedding from Cold-storage to Hot-storage to retain the hottest categorical feature IDs. After the warm-up steps, the majority of ID queries are expected to hit in Hot-storage, and missed queries can be handled by Cold-storage. Note that HybridHash would place all data on Hot-storage when its capacity is found to be far beyond the total size of embedding tables during the warm-up steps. In addition, HybridHash can be extended to a multiple-level cache system, including devices like Intel's persistent memory and SSD. The algorithm of HybridHash is shown in Algorithm~\ref{alg:hybridhash}. L\ref{line:warm_start}-\ref{line:warm_end} depict the steps to collect statistics during the warmup iterations, L\ref{line:normal_start}-\ref{line:normal_end} introduce the rules to get embedding, and L\ref{line:update_start}-\ref{line:update_end} define the procedures to update the content in Hot-storage. \begin{algorithm} \caption{Algorithm of HybridHash} \label{alg:hybridhash} \begin{algorithmic}[1] \Procedure{HybridHash}{IDs, itr} CStore: cold storage to hold hashmap \\ HStore: hot storage as a cache \\ FCounter: a host-side counter to record ID's frequency \\ warmup\_iters: iterations to warm up Hybridhash \\ flush\_iters: flush HStore by top features in CStore every flush\_iters \\ IDs: categorical feature IDs to query \\ itr: current iteration \If{$\text{itr} < \text{warmup\_iters}$} \For{$\forall id \in \text{IDs}$}\label{line:warm_start} \State $\text{FCounter}(id) \gets \text{FCounter}(id) + 1$ \State $feat(id) \gets \text{CStore}(id)$ \EndFor \label{line:warm_end} \Else \For{$\forall id \in \text{IDs}$} \label{line:normal_start} \If{$id$ is found in HStore} \State $feat\_hot(id) \gets \text{HStore}(id)$ \Else \State $feat\_cold(id) \gets \text{CStore}(id)$ \EndIf \State $\text{FCounter}(id) \gets \text{FCounter}(id) + 1$ \EndFor \State $feat = feat\_hot \cup feat\_cold$ \label{line:normal_end} \If{$\text{itr} \% \text{flush\_iters} = 0$} \label{line:update_start} \State $hot\_ids \gets \text{top-}k(\text{FCounter})$ \State $\text{HStore} \gets \text{CStore}(hot\_ids)$ \EndIf \label{line:update_end} \EndIf \\ \Return $feat$ \EndProcedure \end{algorithmic} \end{algorithm} \section{Experiment} In this section, we conduct extensive experiments to answer the following research questions: \begin{itemize}[leftmargin=*] \item \textbf{RQ1}: To what extent does PICASSO{} improve training throughput by unleashing the hardware potential compared to the state-of-the-art generic frameworks with computation optimizations? \item \textbf{RQ2}: How do the software system optimizations in PICASSO{} affect the utilization of each hardware resource? \item \textbf{RQ3}: How does PICASSO{} perform on the diversified WDL{} model architectures and feature fields? \end{itemize} \subsection{Experimental Setup} \label{sub:exp_setup} We conduct the experiments on PICASSO{} from two aspects: 1) Benchmarking the performance of PICASSO{} with state-of-the-art frameworks on public datasets. 2) Evaluating the design of PICASSO{} by production-ready datasets and three representative models. Tab.~\ref{tab:testbed} summarizes our testbeds, including public-accessible machines from AliCloud (Gn6e) for the performance benchmarking, as well as an on-premise cluster of Tesla-V100 (EFLOPS) for the system design evaluation. \begin{table}[t] \centering \footnotesize \caption{Specification of testbeds (per node)} \label{tab:testbed} \resizebox{\linewidth}{!}{ \begin{tabular}{p{0.9cm}|p{1.3cm}p{1.7cm}p{1.1cm}p{1.4cm}} \toprule \textbf{Cluster} & \textbf{CPU} & \textbf{GPU} & \textbf{DRAM} & \textbf{Network} \\ \midrule Gn6e & Xeon 8163 (96 cores) & 8xTesla V100-SXM2 (256GB HBM2) & 724GB DDR4 &32Gbps (TCP) \\ EFLOPS & Xeon 8269CY (104 cores) & 1xTesla V100S-PCIe (32GB HBM2) & 512GB DDR4 & 100Gbps (RDMA)\\ \bottomrule \end{tabular} } \end{table} \noindent\textbf{Testing Models and Datasets}. \emph{DLRM} \cite{mudigere2021high} is a benchmarking model proposed by Facebook and adopted by MLPerf; \emph{DeepFM} \cite{guo2017deepfm}, derived from Wide\&Deep model, is widely applied in industrial recommender systems; \emph{DIN} \cite{zhou2018deep} and \emph{DIEN} \cite{zhou2019deep} are two models training multi-field categorical data with complicated feature interaction modules. We also utilize the three representative models discussed in \S\ref{sec:implication} for a system-design evaluation. \par For benchmarking datasets, we collect: 1) \emph{Criteo} \cite{criteo}, a widely adopted click-through-rate (CTR) dataset by Kaggle and MLPerf \cite{mlperf}, and 2) \emph{Alibaba}\cite{qi2020search}, an open-sourced industrial-level CTR dataset. For a system-design evaluation, we use in-house production datasets at Alibaba, which has a large number of one- or multi-hot categorical features. The statistics of these datasets are depicted in Tab.~\ref{tab:dataset}. The datasets are placed on a remote server to download via network. Following common industrial settings, the models would go through only one epoch of the entire dataset and adopt a full-precision training to avoid accuracy loss. \begin{table}[t] \centering \caption{Statistics of datasets in experiments (lengths of sequential features are shown in parentheses)} \label{tab:dataset} \resizebox{\linewidth}{!}{ \begin{tabular}{p{1.3cm}|p{0.95cm}p{1.22cm}p{2cm}|p{1.2cm}p{0.9cm}p{0.7cm}} \toprule \textbf{Dataset} & \textbf{Instances} & \textbf{\# numeric features} & \textbf{\# sparse feature fields} & \textbf{Model} & \textbf{Emb. dim.} & \textbf{\# of params} \\ \midrule Criteo & 4B & 13 & 26 & DLRM/ DeepFM & 128 & 6B \\ Alibaba & 13M & 0 & 1,207 (7+12$\times$100) & DIN/ DIEN & 4 & 6B \\ \midrule Product-1 & Infinite & 10 & 204 & W\&D & 8$\sim$32 & 160B \\ Product-2 & Infinite & 0 & 1,834 (334+30$\times$50) & CAN & 8$\sim$200 & 1T \\ Product-3 & Infinite & 0 & 584 (84+10$\times$50) & MMoE & 12$\sim$128 & 1T \\ \bottomrule \end{tabular} } \end{table} \noindent\textbf{State-of-the-art Training Frameworks}. We evaluate and compare the performance of PICASSO{} with mainstream open-sourced WDL{} training frameworks, including: \emph{Tensorflow-PS} (abbr. TF-PS) of version 1.15 \cite{tf15} with an asynchronous PS training strategy (one PS on CPU and multiple workers on GPUs). NVLink does not work in this training mode; \emph{PyTorch} of version 1.8 \cite{pytorch} with a hybrid training strategy on WDL{} models with AllToAll communication (over NCCL) developed by Facebook. The embedding tables towards different feature fields are manually placed on different GPUs based on their sizes; \emph{Horovod} \cite{sergeev2018horovod} on PyTorch distributed data-parallel (DDP) mode with an Allreduce communication. \noindent\textbf{Evaluation Metrics}. A group of metrics are employed in our experiments for comprehensive measurements: \begin{itemize}[leftmargin=*] \item \emph{AUC} is a standard CTR metric to evaluate the accuracy; \item \emph{Performance} refers to the throughput of training system (instances per second per node (IPS)) and training walltime (GPU core hours); \item \emph{GPU SM Utilization} is the fraction of time, when at least one warp was active on a multiprocessor, averaged over all SMs; \item \emph{Bandwidth Utilization} is the measured network (PCIe / NVLink / RDMA) bandwidth. \end{itemize} We use NVIDIA's DCGM \cite{dcgm} to inspect the metrics of device utilization on our testbeds. \begin{figure*}[t] \centering \begin{minipage}[t]{0.325\linewidth} \centering \includegraphics[width=\linewidth]{figs/Benchmark_walltime.pdf} \caption{Walltime in GPU core hours of training the four models completely by the compared training systems.}\label{fig:performance} \end{minipage} \hfill \begin{minipage}[t]{0.325\linewidth} \centering \includegraphics[width=\linewidth]{figs/DLRM_SM.pdf} \caption{CDF of SM utilization of training DLRM during the entire process by the four compared systems.}\label{fig:dlrm_sm} \end{minipage} \hfill \begin{minipage}[t]{0.325\linewidth} \centering \includegraphics[width=\linewidth]{figs/DLRM_PCIe.pdf} \caption{PCIe and NVLink bandwidth consumption of training DLRM by the four compared systems.}\label{fig:dlsd_pcie} \end{minipage} \end{figure*} \subsection{Evaluation on Benchmarks (RQ1)} We first examine the performance of PICASSO{} on one Gn6e cluster node over benchmarking tasks. We tune the batch sizes for each framework's best throughput while maintaining the models' accuracy. \begin{table}[tp] \centering \caption{AUC of trained models by four training systems} \label{tab:auc} \resizebox{\linewidth}{!}{ \begin{tabular}{m{1cm}|m{1.6cm}m{1.6cm}m{1.6cm}m{1.6cm}} \toprule & \textbf{PICASSO{}} & \textbf{PyTorch} & \textbf{TF-PS} & \textbf{Horovod} \\ \midrule DLRM & 0.8025 (42K) & 0.8025 (7K) & 0.8024 (6K) & 0.8025 (10K) \\ DeepFM & 0.8007 (30K) & 0.8007 (7K) & 0.8007 (7K) & 0.8007 (8K) \\ DIN & 0.6331 (32K) & 0.6329 (20K) & 0.6327 (16K) & 0.6329 (24K) \\ DIEN & 0.6345 (32K) & 0.6344 (16K) & 0.6340 (12K) & 0.6343 (24K) \\ \bottomrule \end{tabular} } \end{table} \noindent\textbf{Accuracy and Throughput}. The AUCs, with corresponding batch sizes per GPU device, are listed in Tab.~\ref{tab:auc}. For DLRM and DeepFM, PICASSO{} achieves the same AUC with PyTorch and Horovod, which is better than the asynchronous training by TF-PS. For DIN and DIEN, PICASSO{} even obtains a slightly improved accuracy than the others, which is instructive for industrial practice. \par In terms of throughput, Fig.~\ref{fig:performance} records the training walltime of models by the four frameworks. TF-PS has the worst performance among the four because of extensive data exchange and PCIe congestion between server and worker nodes. Horovod and PyTorch have much-improved performance over TF-PS due to the usage of collective communication primitives (i.e., Allreduce and AllToAll). PICASSO{} presents the best performance, and the advantage is more remarkable on DIN and DIEN due to the relatively complicated workload patterns (a hybrid of memory-, and computation-intensive layers; and Alibaba dataset has a higher sparsity than Criteo). The result shows that PICASSO{} impressively accelerates the training by at least 1.9$\times$, and up to 10$\times$ compared to the baseline framework (TF-PS). \noindent\textbf{Hardware Utilization}. We then investigate the runtime utilization of the underlying hardware when training the DLRM model, and we plot the GPU SM utilization and NVLink/PCIe bandwidth consumption in a 10-millisecond granularity in Fig.~\ref{fig:dlrm_sm} and Fig.~\ref{fig:dlsd_pcie}. Although the other frameworks optimize some phases of training (e.g., PyTorch and Horovod present intermittent high GPU SM utilization), they suffer from certain bottlenecks implied from the large CDF area of low GPU SM utilization. In contrast, PICASSO{} has barely any area of low GPU SM utilization, meaning that the bottlenecks on this testbed are effectively addressed by the software system optimization. In terms of bandwidth utilization, PICASSO{} is much better than the TF-PS baseline as leveraging the collective communication primitives and the hardware coherency via NVLink. When compared to Horovod and PyTorch, PICASSO{} still slightly improves bandwidth usage due to pipelines in interleaving. The improvement of hardware utilization indicates that though the generic frameworks have pushed the computation efficiency to a peak level, PICASSO{} still succeeds to unleash the potential of the underlying hardware resources. \begin{figure*}[htbp] \centering \begin{minipage}[t]{0.325\linewidth} \centering \includegraphics[width=0.99\linewidth]{figs/System_SPS.pdf} \caption{Training performance of the three models by the three training systems in the in-house cluster.}\label{fig:acceleration} \end{minipage} \hfill \begin{minipage}[t]{0.32\linewidth} \centering \includegraphics[width=\linewidth]{figs/System_Interleaving.pdf} \caption{Training performance by using 1 to 11 interleaving groups. The three models own 16, 19, 11 packed embedding respectively.}\label{fig:scale_up} \end{minipage} \hfill \begin{minipage}[t]{0.32\linewidth} \centering \includegraphics[width=\linewidth]{figs/System_Scaling_Out.pdf} \caption{Training performance of scaling-out of PICASSO{} ranging from 1 to 128 workers in the in-house cluster.} \label{fig:scale_out} \end{minipage} \end{figure*} \subsection{Evaluation of System Design (RQ2)} \begin{table}[t] \centering \caption{Ablation study on PICASSO{}} \label{tab:ablation_study} \resizebox{\linewidth}{!}{ \begin{tabular}{m{0.7cm}m{2cm}|m{0.8cm}m{1.1cm}m{1.1cm}m{1.2cm}} \toprule & & \textbf{IPS} & \textbf{PCIe (GBps)} & \textbf{Comm. (Gbps)} & \textbf{SM util. (\%)} \\ \midrule \multirow{4}{0.7cm}{W\&D} & PICASSO{} & 22,825 & 1.57 & 2.48 & 32 \\ & \, w/o Packing & 17,827 & 1.54 & 1.84 & 23 \\ & \, w/o Interleaving & 16,218 & 1.49 & 1.69 & 21 \\ & \, w/o Caching & 19,264 & 1.51 & 2.07 & 25 \\ \midrule \multirow{4}{0.7cm}{CAN} & PICASSO{} & 12,218 & 2.59 & 8.50 & 62 \\ & \, w/o Packing & 8,769 & 2.55 & 6.66 & 45 \\ & \, w/o Interleaving & 7,957 & 2.02 & 6.94 & 43 \\ & \, w/o Caching & 10,829 & 2.60 & 7.41 & 51 \\ \midrule \multirow{4}{0.7cm}{MMoE} & PICASSO{} & 2,546 & 2.31 & 6.61 & 98 \\ & \, w/o Packing & 2,270 & 2.27 & 6.10 & 96 \\ & \, w/o Interleaving & 1,319 & 1.87 & 3.80 & 64 \\ & \, w/o Caching & 2,401 & 2.28 & 6.44 & 98 \\ \bottomrule \end{tabular} } \end{table} Industrial WDL{} workloads are usually much more complicated than the benchmarking workloads, regarding both model architecture and data distribution. We investigate the effectiveness of PICASSO{} in industry services by W\&D, CAN, and MMoE models over industrial datasets. Meanwhile, we measure the fine-grained contribution of packing, interleaving and caching by training throughput. The evaluation is conducted over 16 nodes in the EFLOPS cluster if not specified explicitly. We use the commonly-used asynchronous PS strategy of Tensorflow at Alibaba as the baseline. We also implement PICASSO{} without software system optimization, denoted as ``PICASSO{}(Base)'', which can be seen as a pure hybrid-parallel training strategy framework. Fig.~\ref{fig:acceleration} depicts the IPS, where we observe a 4$\times$ acceleration on CAN and MMoE. We then dive into the software system optimizations via an ablation study. \noindent\textbf{Ablation Study}. We remove the software system optimization from PICASSO{}, in turn, to verify its effect on WDL{} tasks and collect metrics in Tab.~\ref{tab:ablation_study}. By using the packing approach, the fragmentary operations on feature embedding are packed together, leading to an improvement on IPS by 30\% and the correspondingly increased hardware usage of PCIe, network and GPU SMs. The interleaving approach utilizes pipelines to hide memory access and network latency by computation-intensive operations. Obviously, MMoE owns the most complicated computation workload among the three models and thus benefits most from this optimization. The interleaving approach significantly raises the performance of MMoE by 93\%. This is consistent with the analysis that the two models suffer heavy computation load, and PICASSO{} helps diffuse the pulse-like GPU usage throughout the entire training process. W\&D, not having sufficient computation, would benefit from the data-interleaving to mitigate the congestion on PCIe and network. Caching relies on leveraging the distribution of input data. Thus, we run 100 steps as a warm-up to collect the statistics and then set the Hot-storage size to 1GB on GPU memory to maintain the unique IDs' hit ratio above 20\% within each batch. HybridHash improves the performance by up to 13\%, which attributes to a balanced utilization of PCIe and GPUs. \begin{table}[t] \centering \caption{Number of operations in computational graph} \label{tab:nodes} \begin{tabular}{c|cccc} \toprule \multirow{2}{*}{\textbf{Model}} & \multicolumn{2}{c}{\textbf{\# of operations}} & \multicolumn{2}{c}{\textbf{\# of packed embedding}} \\ & Baseline & PICASSO{} & Baseline & PICASSO{} \\ \midrule W\&D & 100,039 & 14,882 (14.9\%) & 204 & 16 (7.8\%) \\ CAN & 381,364 & 67,985 (17.8\%) & 364 & 19 (5.2\%) \\ MMoE & 300,524 & 75,217 (25.0\%) & 94 & 11 (11.7\%) \\ \bottomrule \end{tabular} \end{table} \noindent\textbf{Effectiveness of Packing}. WDL{} models tend to own fragmentary operations for the multi-field embedding and feature interactions. We dump the computational graph of the three models through Baseline and PICASSO{}, and the number of operations and packed embedding are shown in Tab.~\ref{tab:nodes}. The statistic implies that PICASSO{} dramatically reduces the fragmentary operations, even if the interleaving optimization supplements a certain amount of operations to pipeline the executions. \noindent\textbf{Interleaving Groups}. The number of interleaving groups affects the efficiency of the embedding layer. Fig.~\ref{fig:scale_up} shows the throughput by varying the number of K-interleaving groups. Obviously, the communication-intensive workloads, i.e., W\&D and CAN, can benefit from the increased interleaving as the combination of packed embedding uniformizes the usage of each hardware resource. We also see that the batch interleaving contributes differently to the models. The result reflects that utilizing more micro-batches would greatly improve the performance of the computation-intensive workload, i.e., CAN and MMoE, by meeting the saturation of GPU. It reveals that the interleaving strategies are effective for WDL workloads when there is sufficient input data and underutilized hardware. \begin{table}[t] \centering \caption{Hit ratio and IPS by varying the size of Hot-storage} \label{tab:cache} \resizebox{\linewidth}{!}{ \begin{tabular}{m{1.3cm}|m{1.0cm}m{0.8cm}m{1.0cm}m{0.8cm}m{1.0cm}m{0.8cm}} \toprule \multirow{2}{*}{\textbf{Hot-Storage}} & \multicolumn{2}{c}{\textbf{W\&D}} & \multicolumn{2}{c}{\textbf{CAN}} & \multicolumn{2}{c}{\textbf{MMoE}} \\ & Hit ratio & IPS & Hit ratio & IPS & Hit ratio & IPS \\ \midrule 256MB & 9\% & -11\% & 20\% & -19\% & 9\% & -3\% \\ 512MB & 18\% & -5\% & 28\% & -10\% & 16\% & -1\% \\ 1GB & 24\% & +0\% & 37\% & +0\% & 21\% & +0\% \\ 2GB & 28\% & +1\% & 44\% & +5\% & 24\% & +0\% \\ 4GB & 31\% & -3\% & 45\% & +2\% & 27\% & -2\% \\ \bottomrule \end{tabular} } \end{table} \noindent\textbf{Size of Hot-storage}. In the industrial WDL{} workload, it is impossible to foresee the size of the embedding tables since the model should constantly deal with the newly-emerged categorical feature IDs. We set the size of Hot-storage to 1GB in the previous evaluations to ensure 20\% hit ratio. Tab.~\ref{tab:cache} depicts the cache hit ratio and improvement of IPS by varying the size of Hot-storage. Larger cache size carries more embedding, yet we find an apparent marginal effect of the hit ratio when the cache size reaches above 2GB. Although the large cache hits more ID queries, the occupation of GPU memory forces the training to compromise the batch size, leading to a slight reduction in the overall throughput. Hence, it is no need to pursue high cache hit ratio by setting an excessively large cache size in WDL{} workload. \noindent\textbf{Scaling Out}. We scale out the training clusters from one PICASSO-Executor{} to 128 PICASSO-Executor{}s and illustrate the performance by IPS in Fig.~\ref{fig:scale_out}. The correlation between IPS and the number of PICASSO-Executor{}s shows that PICASSO{} achieves near-linear scalability on CAN and MMoE while attaining a sublinear throughput on W\&D. This result implies that PICASSO{} can amortize the additional communication overhead from the increasing number of PICASSO-Executor{}s and handle large-scale WDL{} training. \subsection{Applicability Experiment (RQ3)}~\label{sec:rq3} \begin{table}[h] \centering \caption{Training throughput of 12 AUC prediction models by PICASSO{} and in-house XDL.} \label{tab:performance} \resizebox{\linewidth}{!}{ \begin{tabular}{m{1.8cm}|m{2.8cm}m{2.4cm}m{1.9cm}} \toprule \textbf{Model} & \textbf{Batch size} & \textbf{GPU SM utilization} & \textbf{IPS} \\ \midrule LR~\cite{gai2017learning} & 20K $\xrightarrow{}$ 36K (20K x 2) & 9 $\xrightarrow{}$ 22 (+144\%) & 12.0K $\xrightarrow{}$ 25.9K (+115\%) \\ W\&D~\cite{cheng2016wide} & 19K $\xrightarrow{}$ 36K (18K x 2) & 21 $\xrightarrow{}$ 35 (+67\%) & 14.7K $\xrightarrow{}$ 22.2K (+50\%) \\ TwoTowerDNN\cite{fan2019mobius} & 12K $\xrightarrow{}$ 36K (12K x 3) & 35 $\xrightarrow{}$ 97 (+177\%) & 4.7K $\xrightarrow{}$ 12.1K (+160\%) \\ DLRM~\cite{mudigere2021high} & 10K $\xrightarrow{}$ 30K (10K x 3) & 38 $\xrightarrow{}$ 98 (+158\%) & 3.8K $\xrightarrow{}$ 10.4K (+171\%) \\ DCN~\cite{wang2017deep} & 14K $\xrightarrow{}$ 36K (12K x 3) & 56 $\xrightarrow{}$ 92 (+64\%) & 9.0K $\xrightarrow{}$ 13.7K (+52\%) \\ xDeepFM~\cite{lian2018xdeepfm} & 6K $\xrightarrow{}$ 20K (5K x 4) & 45 $\xrightarrow{}$ 98 (+117\%) & 3.1K $\xrightarrow{}$ 5.9K (+89\%) \\ ATBRG~\cite{feng2020atbrg} & 3K $\xrightarrow{}$ 6K (3K x 2) & 13 $\xrightarrow{}$ 26 (+100\%) & 0.8K $\xrightarrow{}$ 1.4K (+82\%) \\ DIN~\cite{zhou2018deep} & 15K $\xrightarrow{}$ 45K (15K x 3) & 34 $\xrightarrow{}$ 80 (+135\%) & 7.5K $\xrightarrow{}$ 16.0K (+113\%) \\ DIEN~\cite{zhou2019deep} & 15K $\xrightarrow{}$ 45K (15K x 3) & 29 $\xrightarrow{}$ 75 (+159\%) & 7.3K $\xrightarrow{}$ 15.6K (+115\%) \\ DSIN~\cite{feng2019deep} & 9K $\xrightarrow{}$ 27K (9K x 3) & 40 $\xrightarrow{}$ 93 (+133\%) & 4.7K $\xrightarrow{}$ 9.8K (+111\%) \\ CAN~\cite{zhou2020can} & 12K $\xrightarrow{}$ 48K (12K x 4) & 17 $\xrightarrow{}$ 75 (+341\%) & 3.9K $\xrightarrow{}$ 12.1K (+210\%) \\ STAR~\cite{sheng2021one} & 2K $\xrightarrow{}$ 8K (2K x 4) & 32 $\xrightarrow{}$ 98 (+206\%) & 0.6K $\xrightarrow{}$ 2.0K (+215\%) \\ \bottomrule \end{tabular} } \end{table} \noindent\textbf{Varying Feature Interactions}. We further investigate the performance of PICASSO{} on more industrial-scale WDL{} models with various types of feature interaction modules. We select 12 AUC prediction models, and tune the hyperparameters to ensure the convergence of the models. The models are slightly modified to cope with the Product-2 dataset. To show the adaptability of PICASSO{}, we take the in-house optimized XDL as the baseline to train those models in synchronous PS training mode. The performance of the 12 models is listed in Table~\ref{tab:performance}. Obviously, the proposed PICASSO{} significantly improves the GPU utilization compared to the in-house optimized XDL~\cite{jiang2019xdl} framework. It indicates that with the software system optimization, PICASSO{} is able to be aware of the hardware bound, and unleash the hardware potential for various WDL{} model architectures. \begin{table}[t] \centering \caption{Performance of CAN by varying number of feature fields on synthetic dataset} \label{tab:massive_field} \resizebox{\linewidth}{!}{ \begin{tabular}{m{1.6cm}|m{0.7cm}m{0.7cm}m{0.7cm}m{0.7cm}m{0.84cm}m{0.7cm}m{0.84cm}m{0.84cm}} \toprule Feature field & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \midrule PICASSO{} & 12.20 & 6.14 & 4.13 & 3.13 & 2.50 & 2.09 & 1.82 & 1.61 \\ AP & 12.20 & 6.10 & 4.07 & 3.05 & 2.44 & 2.03 & 1.74 & 1.53 \\ Increment & 0.0\% & +0.6\% & +1.7\% & +2.5\% & +2.6\% & +2.7\% & +4.3\% & +5.3\% \\ XDL & 2.40 & 1.18 & 0.75 & 0.56 & 0.42 & 0.36 & 0.31 & 0.25 \\ AP & 2.40 & 1.20 & 0.80 & 0.60 & 0.48 & 0.40 & 0.34 & 0.30 \\ Increment & 0.0\% & -1.5\% & -6.8\% & -6.1\% & -13.1\% & -9.6\% & -10.3\% & -15.3\% \\ \bottomrule \end{tabular} } \end{table} \noindent\textbf{Increasing Feature Fields}. We present the performance of PICASSO by varying the number of feature fields. As currently we do not operate business that ingests thousands of feature fields, we make a synthetic dataset by duplicating the feature fields of Product-2. Therefore, the number of feature fields becomes an integral multiple of 364 in the data source. Correspondingly, we duplicate the feature interaction layers to process the synthetic dataset. The outputs of the feature interaction layers are concatenated together to feed to a mutual MLP. Tab.~\ref{tab:massive_field} depicts the IPS by PICASSO and the in-house optimized XDL, as well as the theoretical IPS by arithmetic progression (AP). Though the requirements of the underlying hardware resources increase by the number of feature fields, PICASSO performs slightly better than AP due to the packing of the fragmentary operations. In contrast, the PS baseline suffers from the massive operations by the large number of feature fields and the constituent feature interactions, thereby presenting significant IPS drop compared to AP. \noindent\textbf{Discussion}. Evaluations show that PICASSO{} successfully unleashes the potential of hardware resources, where PICASSO{} uniformizes the hardware usage for high overall hardware utilization (RQ2) and provides diversified optimization for WDL{} models with different attributes (RQ3). Employing super-large batch size in training requires certain auxiliary approaches (e.g., global batch normalization \cite{chen2020simple}, Lamb optimizer \cite{you2019large}), which can be applied in PICASSO{} through implementation in Tensorflow. Obviously, should we deploy customized hardware to enhance specific hardware resources, or if particular WDL{} tasks presented high tolerance for accuracy loss from the precision-lossy mechanisms, the performance of PICASSO{} will surely be further improved. \section{Deployment in Production} \begin{table}[t] \centering \caption{Performance of PICASSO{} at Alibaba Cloud} \label{tab:online_performance} \resizebox{\linewidth}{!}{ \begin{tabular}{m{1.6cm}|m{1.6cm}m{1.2cm}m{2.5cm}} \toprule & \textbf{Average task walltime (h)} & \textbf{GPU SM util. (\%)} & \textbf{Bandwidth (Gbps)} \\ \midrule XDL & 8.6 & 15 & 1.412 (TCP) \\ PICASSO & 1.4 & 75 & 6.851 (TCP+RDMA) \\ \bottomrule \end{tabular} } \end{table} We implement PICASSO{} on top of Tensorflow. It has been deployed in our on-premises clusters since October 2020 to serve business of online and offline WDL{} tasks, including information retrieval, advertisement bidding, recommendation, and search ranking. Since we deployed PICASSO{}, training throughput has been greatly improved, and impressive performance has been achieved in a number of highly-promoted sales. In-house sophisticated scheduling and failover-recovery strategies are employed by PICASSO{} for robust training \cite{huang2019yugong,feng2021scaling}, which are beyond this paper's scope. \par The arithmetic computation is still very heavy in training state-of-the-art WDL{} designs. Benefiting from popular CV and NLP training acceleration approaches, we have applied the latest solutions, such as GPU acceleration libraries (e.g., CUTLASS \cite{cutlass} and CuDNN \cite{cudnn}), operator-level graph replacement \cite{chen2018tvm}, compiler optimization \cite{dean2017machine}, and quantitative communication\cite{jiang2018linear} to PICASSO{}. We also implement topology-aware communication\cite{dong2021accl} to avoid IO tasks on GPU devices from the same node competing for limited NIC resources. These accelerations are orthogonal to the optimization of PICASSO{}. We provide users with a flexible interface to invoke these methods when tuning their design. Other emerging technologies can be integrated into PICASSO{} via the Tensorflow ecosystem. We instrument a production training cluster of one Tesla-V100 per worker, which runs hundreds of daily WDL{} workloads. These workloads present remarkably different training intensities by various input features, embedding dimensions, feature interaction modules, and shapes of MLP. We record job statistics of the succeeded training tasks from Jun. 1st, 2021, to Nov. 15th, 2021. To make a comparison, we prepare previously deployed XDL \cite{jiang2019xdl} in another production cluster with comparable types of workloads. The results in Tab.~\ref{tab:online_performance} show that PICASSO{} brings around 6$\times$ performance acceleration on average and contributes to improving the utilization of underlying hardware. The throughput acceleration reduces the delay of daily continuous delivery by 7 hours on average. We further probe into several representative models (with entirely different model architecture and data distribution) from the monitored cluster and present the required walltime over 128 Tesla-V100s to train petabyte-scale data accumulated by one year as shown in Tab.~\ref{tab:year}. The statistics reveal that PICASSO{} reduces model training of 100-billion-scale parameters from one month to 2 days. Moreover, regarding a WDL{} model with 1-trillion-scale parameters (one of the currently largest models satisfying real-time inference throughput demand in our business), the training completes within nine days, while the baseline framework is estimated to occupy the resources for more than three months. This training acceleration is critical in the latest ML/DL trends of providing high WDL{} business value. \section{Related Work} \label{sec:related_work} We summarize the trending research approaches with respect to training WDL{} jobs into three categories as follows: \noindent \textbf{Hardware Customization}. For a specific WDL{} workload with a high business value, it is profitable to customize the hardware itself to achieve a cutting-edge performance and throughput. AIBox/PaddleBox \cite{zhao2019aibox,zhao2020distributed} leverages non-volatile memory to drastically reduce the training scale from an MPI cluster with hundreds of CPUs to a single machine with 8 GPUs. HugeCTR/Merlin is a customized framework running on NVIDIA's DGX-1/DGX-2 supernodes equipped with high-end interconnects named NV-Switch. Zion \cite{smelyanskiy2019zion} and RecSpeed \cite{krishna2020accelerating} customize their node specification for DLRM~\cite{mudigere2021high} and its variants by adding more NICs and RoCEs to alleviate the I/O bottleneck. Nevertheless, hardware customization is still expensive and a waste of resources when facing rapid shifts in WDL{} designs. Further, training systems upon customized hardware are difficult to scale out on cloud elastically. \begin{table}[t] \centering \caption{Walltime (GPU-core hour) to train data accumulated by one year (``P'' indicates the predicted walltime)} \label{tab:year} \resizebox{\linewidth}{!}{ \begin{tabular}{m{1.8cm}|m{1cm}m{1cm}m{1.6cm}m{1.6cm}} \toprule Model scale & $\sim$ 1B & $\sim$ 10B & $\sim$ 100B & $\sim$ 1T \\ \midrule XDL & 2,072 & 11,013 & 88,129 (P) & 323,480 (P)\\ PICASSO{} & 747 & 2,285 & 6,091 & 27,256 \\ \bottomrule \end{tabular} } \end{table} \noindent \textbf{Subsystem Optimization}. Subsystem optimization diagnoses specific bottlenecks and improves the performance of certain workloads. For example, the communication protocol in BytePS \cite{peng2019generic} accelerates the data exchange in PS strategy. Kraken \cite{xie2020kraken} develops memory-efficient table structure to hold parameters of embedding layers. ScaleFreeCTR~\cite{guo2021scalefreectr} utilizes GPU to accelerate the embedding lookup of parameters stored in DRAM. Het~\cite{miao2021het} introduces staleness to embedding update which is suitable for the WDL{} designs with small-size local embedding tables. These optimizations are likely to miss opportunities of improving overall performance systematically owing to the unawareness of either sparse manipulation or intensive computation of WDL{}s, while precision-lossy operations like staleness would do harm to the E-commerce WDL{} models. \noindent \textbf{Generic DNN Training Optimization}. There are already a variety of proposed training frameworks targeting dense models from domains such as CV and NLP. These frameworks provide meticulous strategies for splitting and pipelining workloads during training. Megatron \cite{shoeybi2019megatron} speeds up the transformer module in NLP workloads. GPipe \cite{huang2018gpipe} implements pipeline over mini batches, and Pipedream \cite{narayanan2019pipedream} further fills the bubble between forward and backward pass by weight stashing. GShard~\cite{lepikhin2020gshard} relies on a compilation approach to shard parameters and activations. Unfortunately, WDL{} models are usually sensitive to numeric precision and gradient staleness \cite{xu2021step,zhuang2021accumulated,cai2020rethinking}, and WDL{} workload has much more operators on dynamic shape of data than CV and NLP models. Hence, these generic DNN training optimizations may not apply to WDL{} workload at an industrial scale. \section{Conclusion} \label{sec:conclusion} In this paper, we introduce PICASSO{}, a deep learning training system upon Tensorflow, to accelerate the training of WDL{} models on commodity hardware with the awareness of model architecture and data distribution. With the investigation of representative workloads at Alibaba Cloud, we design an advantageous training framework and provide workload-aware software optimization: 1) packing the embedding tables and the subsequent operations to reduce the fragmentary operations that are not friendly to GPU-centric training; 2) interleaving the embedding layer and the feature interaction to diffuse the pulse-like usage throughout the entire training process; 3) caching the frequently-visited categorical IDs to expedite the repeated embedding queries. Product deployment at Alibaba Cloud demonstrates that a 1-trillion parameter WDL{} model through one-year petabyte-scale data can be efficiently trained in 27,256 GPU core hours, significantly reducing the training cost by a factor of 12. PICASSO{} helps decrease the delay of daily continuous delivery by 7 hours, which is crucially important for state-of-the-art recommender systems. \section*{Acknowledgement} This work is supported by Alibaba Group. We thank Lixue Xia, Wencong Xiao, Shiru Ren, Zhen Zheng, and Zheng Cao for useful pointers regarding the writing of this paper. We appreciate Hua Zong, Kaixv Ren, Wenchao Wang, Xiaoli Liu, Yunxin Zhou, Hao Li, Guowang Zhang, Sui Huang and Lingling Jin for implementing the key components of the training and serving infrastructure. \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-19T02:30:58', 'yymm': '2204', 'arxiv_id': '2204.04903', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04903'}
arxiv
\section{Algorithm} For simplicity, we first study a special variant of (C)C-SSP in which actions stochastically lead to a small number of potentials states, denoted as (C)C-SSP under {\em limited transition}. \begin{definition}[Limited Transition] \label{def:loc} There exists a constant $\gamma\in \mathbb N_+$ such that $N_a(s) \le \gamma$ for all $a \in \mathcal A, s \in \mathcal S$. \end{definition} In subsection~\ref{sec:fptas-limited}, we study (C)C-SSP under limited and disjoint transition, wherease in subsection \ref{sec:fptas-disjoint}, we relax the limited transition assumption. In susbsection~\ref{sec:fptas}, we present an FPTAS for (C)C-SSP under local transition assumption, which generalizes the former cases. \vspace{-10pt} \subsection{FPTAS for (C)C-SSP under Limited and Disjoint Transition} \label{sec:fptas-limited} \begin{algorithm}[ht] \footnotesize \caption{\texttt{lim-DynSSP}$[M, \epsilon]$}\label{alg} \SetKwInOut{Input}{Input} \SetKwInOut{Output}{Output} \Input{An instance of CC-SSP $M$; a parameter $\epsilon$ for the approximation guarantee} \Output{A deterministic policy $\pi$ } ${\tt DP}_{\textsc{Er}}(s_k,k,\ell_k) \leftarrow \infty$; ${\tt DP}_{\sc \pi}(s_k,k,\ell_k) \leftarrow \varnothing$, ${\tt DP}_{\bar \Bell}(s_k,k,\ell_k) \leftarrow \mathbf{0}$, for $k=0,...,h$;\\ ${\tt DP}_{\textsc{Er}}(s_h,h,\ell_h) \leftarrow r(s_h),$ for all $s_h\in \mathcal S_h, \ell_h \in \mathcal L_k = \{0\}$ \\ \For{$k=h-1,...,0; s_k\in \mathcal S_k; \ell_k \in \mathcal L_k$ }{ ${\tt DP}_{\textsc{Er}}(s_k,k,\ell_k), {\tt DP}_{\pi}(s_k,k,\ell_k), {\tt DP}_{\bar \Bell}(s_k,k,\ell_k) \leftarrow \texttt{Update}[s_k,\ell_k, \{\texttt{DP}_{\textsc{Er}}(\cdot, k+1,\cdot)\}] $ \label{alg:update} } $\pi \leftarrow \texttt{Fetch-Policy}[\texttt{DP}]$ \Return $\pi$ \end{algorithm} \begin{algorithm}[ht] \footnotesize \caption{\mbox{\texttt{Update}$\big[s_k,\ell_k, \{\texttt{DP}(s,k+1,\ell)\}_{s\in \mathcal S_{k+1}}^{\ell\in \mathcal L_{k+1}} \big]$}}\label{alg:update-lim} $\textsc{Er}(s_k)\leftarrow \infty$\\ $\textsc{Act} \leftarrow \varnothing$\\ $\textsc{Alloc} \leftarrow \mathbf{0}$\\ \For{$a \in \mathcal A$} { // Find an allocation $\overline \Bell_{k+1}$ that acheives the minimum execution risk for action $a$ such that the total utility value is at least $\ell_k$ \\ \For{$\overline \Bell_{k+1} = (\overline \ell^{1}_{k+1}, \overline \ell^{2}_{k+1},...) \in \mathcal L_{k+1}^{|N_a(s_k)|}$ \label{alg:alc}}{ $ \overline v_a(s_k, \overline \Bell_{k+1}) \leftarrow \Big \lfloor \frac{1}{L_k} \Big( \sum_{s^i_{k+1} \in N_a(s_k)} T(s_k, a, s^i_{k+1}) \overline \ell^{i}_{k+1} + U(s_k, a) \Big) \Big\rfloor \cdot L_k$ \label{alg:bel1}\\ \If{$\overline v_a(s_k, \overline \Bell_{k+1}) \ge \ell_k$}{ $\textsc{Er}_a(s_k, \overline \Bell_{k+1}) := r(s_k)+(1-r(s_k)) \sum_{s^i_{k+1} \in N_a(s_k)} T(s_k, a, s^i_{k+1}) \cdot \texttt{DP}_{\textsc{Er}}(s^i_{k+1}, k+1, \overline \Bell^i_{k+1})$ \label{alg:er0}\\ \If{$\textsc{Er}_a(s_k, \overline \Bell_{k+1}) < \textsc{Er}(s_k)$}{ \label{alg:er1} $\textsc{Er}(s_k) \leftarrow \textsc{Er}_a(s_k, \overline \Bell_{k+1})$\\ $\textsc{Act} \leftarrow a$ \label{alg:er2}\\ $\textsc{Alloc} \leftarrow \overline \Bell_{k+1}$ } } } } \Return $\textsc{Er}(s_k), \textsc{Act}, \textsc{Alloc}$ \end{algorithm} \begin{algorithm}[ht] \footnotesize \caption{\texttt{Fetch-Policy}$[\texttt{DP}]$}\label{alg:policy} $\mathcal C_k \leftarrow \varnothing$ for $k=1,...,h-1$ \\ $\ell_{0} \leftarrow$ Find the maximum $\ell_{0} \in \mathcal L_{0}$ such that ${\tt DP}_{\textsc{Er}}(s_{0},0,\ell_{0}) \le \Delta$ and ${\tt DP}_{\textsc{Er}}(s_{0},0,\ell_{0} + L_{0}) > \Delta$ \label{alg:f1}\\ $\mathcal C_0 \leftarrow \{(s_0, \ell_0)\}$ \\ \For{$k=0,...,h-1$}{ \For{$(s^i_k, \overline \ell^i_k) \in \mathcal C_k$}{ $\pi(s^i_{k}) \leftarrow {\tt DP}_{\pi}(s^i_{k},k,\overline\ell_{k}^i)$ \\ $\overline \Bell_{k+1}\leftarrow {\tt DP}_{\bar \Bell}(s^i_{k},k,\overline\ell^i_{k})$ \\ $\mathcal C_{k+1} \leftarrow \mathcal C_{k+1} \cup \{(s^i_{k+1}, \overline \ell^i_{k+1})\}_{s^i_{k+1} \in N_{a}(s^i_{k}) }$ where $a=\pi(s^i_{k})$\label{alg:f2} } } \Return $\pi$ \end{algorithm} The procedure involves constructing a 3-dimensional dynamic programming table, ${\tt DP}(\cdot,\cdot,\cdot)$, where each cell ${\tt DP}(s_k,k,\ell_k)$ corresponds to state $s_k \in \mathcal S_k$, time step $k$, and a discrete utility value $\ell_k$ (which we will clarify next). Each cell contains three quantities, ${\tt DP}_{\textsc{Er}}(s_k,k,\ell_k)\in \mathbb R_+$ which maintains the minimum execution risk from state $s_k$, executing an action that accrues a total value of at least $\ell_k$; ${\tt DP}_\pi(s_k,k,\ell_k)=a$, the corresponding policy action $a$; and ${\tt DP}_{\bar \Bell}(s_k,k,\ell_k)\in \mathbb R_+^{|N_a(s_k)|}$, a value allocation for subsequent states as we see next. The main idea behind the algorithm lies in a utility discretization procedure that shrinks the set of possible values at a given state into a manageable number, exploiting the limited and disjoint transition assumptions. A detailed description is provided in Algorithm {\tt lim-DynSSP} (Alg.~\ref{alg}). The algorithm relies on two subroutines, {\tt Update} (Alg.~\ref{alg:update-lim}) and {\tt Fetch-Policy} (Alg.~\ref{alg:policy}). The former computes a discretized version of the Bellman equation along with the corresponding execution risk, and the latter recursively extracts the corresponding policy. Line~\ref{alg:bel1} of {\tt Update} computes a discretized version of the Bellman equation under discretized future rewards, and Line~\ref{alg:er0} recursively computes the execution risk based on Lemma~\ref{lem:rec}. The pseudo-code is provided herein is for CC-SSP; however, it is also applicable to C-SSP with minor modifications. Namely, Line~\ref{alg:er0} of {\tt Update} should be replaced by \begin{align*} \textsc{Er}_a(s_k, \overline \Bell_{k+1})\leftarrow& \sum_{\mathclap{s^i_{k+1} \in N_a(s_k)}} T(s_k, a, s^i_{k+1}) \\ &\quad \cdot \texttt{DP}_{\textsc{Er}}(s^i_{k+1}, k+1, \overline \Bell^i_{k+1}) + C(s_k, a) \end{align*} and $\Delta$ by $P$ in Line~\ref{alg:f1} of {\tt Fetch-Policy}. Thus, all results in this paper apply to C-SSP as well. (In the remaining text, the term {\em execution risk} in the context of C-SSP would refer to the {\em total cost} instead.) Let $U_{\max}:=\max_{s\in \mathcal S, a \in \mathcal A} U(s,a)$ be the maximum utility of an action. Denote a discrete set of values $\mathcal L_k$ for each time step $k=0,...,h$ as \begin{align} \label{eq:defL} \mathcal L_k &:= \{0,L_k,2L_k,..., \lfloor \tfrac{U_{\max}\cdot (h-k)}{L_k}\rfloor L_k \}, \qquad\text{where } \notag \\ L_k &:=\frac{\epsilon U_{\max}}{(h-k)(\ln h + 1)}. \end{align} Let $\pi$ be a solution returned by {\tt lim-DynSSP}, and $v_\pi(s_k):= \mathbb{E}[\sum_{k'=k}^{h-1} U(S_{k'}, \pi(S_{k'}) ) ]$ be the corresponding value function at state $s_k$. Similarly, denote $\pi^*$ to be an optimal solution, and $v_{\pi^*}(s_k)$ be the corresponding value function. Without loss of generality, assume that $v_{\pi^*}(s_0) \ge U_{\max}$ \footnote{If $U_{\max} = U(s_k,a) > v_{\pi^*}(s_0)$, then any policy that outputs action $a$ at state $s_k$ must be infeasible. Thus, such an action can be deleted from the set of allowable actions at state $s_k$. Therefore, $U_{\max}$ can be taken as second largest utility action and so on. The procedure can be performed in polynomial-time as follows. Fix a policy $\pi(s_{k}) = a$, and set the rest $\pi(s_{k'}')= a'_{k'}$ such that action $a'_{k'}$ achieves the minimum execution risk for $k'=h-1,...,0$ (computed recursively using Lemma~\ref{lem:rec}). If the solution is infeasible, repeat the procedure at different $k$. If again infeasible, one can safely drop $U(s_k,a)$, consider the next largest utility, and then repeat the procedure.}. Define $\overline v_\pi(s_0)$ (resp., $\overline v_{\pi^*}(s_0)$) to be a discretized objective value computed recursively by, \begin{equation}\footnotesize \overline v_\pi(s_k) = \bigg\lfloor \tfrac{1}{L_k}\Big(\sum_{\mathclap{s_{k+1} \in \mathcal S_{k+1}}} T(s_k, \pi(s_k), s_{k+1}) \cdot \overline v_\pi(s_{k+1}) + U(s_k, a)\Big)\bigg\rfloor L_k. \label{eq:recd} \end{equation} The above equation corresponds to step~\ref{alg:bel1} of {\tt Update}. \begin{lemma} \label{lem:opt} Let $\pi$ be a policy obtained by {\tt lim-DynSSP} and $\pi^*$ be an optimal deterministic policy. The policy $\pi$ is feasible and satisfies $\overline v_{\pi}(s_0) \ge \overline v_{\pi^*}(s_0)$. \end{lemma} \begin{proof} We show (by induction) that for some $\ell_k \in \mathcal L_k$ and $\overline \Bell_{k+1} \in \mathcal L_{k+1}^{|N_a(s_k)|}$, there exists an action $a$ such that $\ell_k = \overline v_a(s_k, \overline \Bell_{k+1}) \ge \overline v_{\pi^*}(s_k),$ where $\overline v_a(\cdot,\cdot)$ is defined in Line~\ref{alg:bel1} of {\tt Update}. The algorithm enumerates all values of $\overline \Bell_{k+1}$ such that it attains the minimum execution risk for every $\ell_k \in \mathcal L_k$. Throughout recursion, the procedure ensures that a feasible solution $\pi$ can be constructed such that $\ell_k = \overline v_a(s_k, \overline \Bell_{k+1}) \ge \overline v_{\pi^*}(s_k)$, as shown by {\tt Fetch-Policy}. We proceed with the induction proof; for the base case, $k=h-1$, we have $ \overline v_a(s_{h-1}, \overline \Bell_{h}) = \lfloor U(s_{h-1}, a)/L_{h-1} \rfloor L_{h-1}$. Clearly, there is an action that satisfies the claim. For the inductive step, suppose the claim holds at step $k$, we show that the claim also holds for step $k-1$. Note that algorithm {\tt lim-DynSSP} enumerates all discretized allocations $\overline \Bell_k$ at step $k-1$ (as per Step~\ref{alg:alc} of {\tt Update}). Also note that $\overline v_{\pi^*}(s_k) \in \mathcal L_k$ as the largest element in set $\mathcal L_k$, defined in Eq.~\raf{eq:defL}, satisfies$\lfloor {U_{\max}(h-k)}/{L_k}\rfloor L_k \ge \overline v_{\pi^*}(s_k)$. Hence, there exists an allocation $\overline \Bell_k$ such that each $i$-th element $\overline \ell_k^i = \overline v_{a}(s^i_k, \overline \Bell_{k+1}) \ge \overline v_{\pi^*}(s^i_k)$ for some $\overline \Bell_{k+1}$ (inductive assumption). Hence, there exists an $\ell_{k-1}$ and an action $a$ such that \begin{align} &\ell_{k-1}= \overline v_a(s_{k-1}, \overline \Bell_k) \notag\\ &= \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{\mathclap{s^i_k \in N_a(s_{k-1})}} T(s_{k-1}, a, s^i_k) \overline \ell^{i}_{k} + U(s_{k-1}, a) \Big)\bigg\rfloor L_{k-1}\notag \\ &\ge \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{\mathclap{s_{k} \in \mathcal S_k}} T(s_{k-1}, a, s_{k}) \overline v_{\pi^*}(s_k) + U(s_{k-1}, a)\Big)\bigg\rfloor L_{k-1} \notag \\ &= \overline v_{\pi^*}(s_{k-1}), \end{align} where the inequality follows by the inductive assumption. It remains to show that such action $a$ is feasible. Each cell ${\tt DP}_{\pi}(\cdot, \cdot, \cdot)$ corresponds to an action that achieves the minimum execution risk that accrues a total value of at least $\ell_k$. Since the execution risk is a non-decreasing function (Line~\ref{alg:er0} of {\tt Update}), ${\tt DP}_{\textsc{Er} }(s_k, k, \ell_{k}) \le {\textsc{Er}}_{\pi^*}(s_{k}) \le \Delta$ for some $\ell_k = \overline v_{\pi^*}(s_k)$. By the disjoint transition assumption, there is a unique state $s_{k-1}$ that involves the row $\texttt{DP}_{\textsc{ER}}(s_k, k, \cdot)$, $s_k \in N_a(s_{k-1})$, in computing $\texttt{DP}_{\textsc{ER}}(s_{k-1}, k-1, \ell_{k-1})$ (Line~\ref{alg:er0} of {\tt Update}). Hence, only table cells related to state $s_{k-1}$ sets the values of $\overline\ell_k^i$ of the subsequent states $s_k \in N_a(s_{k-1})$. As each cell $\texttt{DP}_{\pi}(s_{k}, k, \overline \ell^i_{k})$ corresponds to a single action, no two $s_{k-1}, s'_{k-1}$ share subsequent state $s_k$, and only one cell among row $\texttt{DP}_{\pi}(s_{k-1}, k-1, \cdot)$ is backtracked by {\tt Fetch-Policy}, the policy remains consistent, i.e., it outputs a single action for each state. (Note that this is not the case if $s_k$ has multiple parents in the And-Or graph, which is the case under local transition assumption.) Such c action is backtracked by {\tt Fetch-Policy}. Therefore, policy $\pi$ is feasible. \end{proof} \begin{lemma}\label{lem:dis} An optimal deterministic policy $\pi^*$ satisfies $\overline v_{\pi^*}(s_{k}) \ge v_{\pi^*}(s_k)- \sum_{k'=k}^{h-1} L_{k'}.$ \end{lemma} \begin{proof} We proceed with an inductive proof. For the base case, computing Eq.~\raf{eq:recd} for $\pi^*$ at $k=h-1$, we have \begin{align} &\overline v_{\pi^*}(s_{h-1}) = \Big\lfloor \tfrac{U(s_{h-1}, \pi^*(s_{h-1}))}{L_{h-1}}\Big\rfloor \cdot L_{h-1}\notag\\ & \ge U(s_{h-1}, \pi^*(s_{h-1})) - L_{h-1} = v_{\pi^*}(s_{h-1}) - L_{h-1}, \end{align} which follows using the property $\lfloor \frac{x}{y}\rfloor y \ge x - y$ for $x,y \in \mathbb R_+$. For the inductive step, suppose that we have, $ \overline v_{\pi^*}(s_{k}) \ge v_{\pi^*}(s_k)- \sum_{k'=k}^{h-1} L_{k'}.$ We compute the corresponding inequality for $s_{k-1}$ as follows, \begin{align} &\overline v_{\pi^*}(s_{k-1}) = \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{s_{k} \in \mathcal S_k} T(s_{k-1}, \pi^*(s_{k-1}), s_{k}) \cdot \overline v_{\pi^*}(s_{k}) \notag \\ &\qquad + U(s_{k-1}, \pi^*(s_{k-1}))\Big)\bigg\rfloor L_{k-1} \\ & \ge \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{s_{k} \in \mathcal S} T(s_{k-1}, \pi^*(s_{k-1}), s_{k}) \cdot \big( v_{\pi^*}(s_{k}) \notag \\ &\qquad - \sum_{k'=k}^{h-1} L_{k'} \big) + U(s_{k-1}, \pi^*(s_{k-1}))\Big)\bigg\rfloor L_{k-1}, \label{eq:inductive} \end{align} where Eq.~\raf{eq:inductive} follows by the inductive assumption. Since $T(\cdot,\cdot,\cdot)$ is a probability function that adds up to one, and using the property $\lfloor \frac{x}{y}\rfloor y \ge x - y$ for $x,y \in \mathbb R_+$, we obtain, \begin{align} &\overline v_{\pi^*}(s_{k-1})\ge \sum_{s_{k} \in \mathcal S} T(s_{k-1}, \pi^*(s_{k-1}), s_{k}) \cdot v_{\pi^*}(s_{k}) \notag \\ &\qquad + U(s_{k-1}, \pi^*(s_{k-1})) - \sum_{k'=k-1}^{h-1} L_{k'} \notag\\ &= v_{\pi^*}(s_{k-1}) - \sum_{k'=k-1}^{h-1} L_{k'}, \label{eq:lem2f} \end{align} which completes the inductive proof. \end{proof} \begin{corollary} \label{thm:fptas1} {\tt lim-DynSSP} is an FPTAS for (C)C-SSP under limited and disjoint transition assumptions. \end{corollary} \begin{proof} First, observe that the algorithm maintains a dynamic programming table with minimum execution risk. Subroutine {\tt Fetch-Policy} ensures that a feasible solution with such property is retrieved. The algorithm runs in $O\big(\big(\tfrac{h^{2} \ln h+1}{\epsilon}\big)^{\gamma + 1} |\mathcal A| |\mathcal S|\big)$. Note that by the limited transition assumption, $\gamma$ is a constant; thus, the running time is polynomial. By Lemma~\ref{lem:dis} and by the definition of $L_k$ given in Eq.~\raf{eq:defL}, we obtain \begin{align} \overline v_{\pi^*}(s_0) &\ge v_{\pi^*}(s_0) - \sum_{k=0}^{h-1} L_{k} \notag \\ &= v_{\pi^*}(s_0) - \sum_{k=0}^{h-1} \frac{\epsilon U_{\max}}{(h-k)(\ln h + 1)} \notag \\ &= v_{\pi^*}(s_0) - \frac{\epsilon U_{\max}}{\ln h + 1} \sum_{k=0}^{h-1} \frac{1}{(h-k)}\notag \\ &\ge v_{\pi^*}(s_0) - \frac{\epsilon U_{\max}}{\ln h + 1} (\ln h + 1) \label{eq:har}\\ &\ge (1-\epsilon)\cdot v_{\pi^*}(s_0), \label{eq:har2} \end{align} where Eq.~\raf{eq:har} follows by using an upper bound on the harmonic series, $\sum_{n=1}^k \tfrac{1}{n} \le \ln k + 1$. By Lemma~\ref{lem:opt} and Eq.~\raf{eq:har2}, $v_\pi(s_0) \ge \overline v_{\pi}(s_0) \ge \overline v_{\pi^*}(s_0) \ge (1-\epsilon) v_{\pi^*}(s_0),$ which completes the proof. \end{proof} \vspace{-10pt} \subsection{FPTAS for (C)C-SSP under Disjoint Transition}\label{sec:fptas-disjoint} In this section, we relax the limited transition assumption and show how to obtain an FPTAS for (C)C-SSP. In other words, we assume $\gamma$ is a polynomial in definition~\ref{def:loc}. The main idea behind our algorithm is to improve {\tt Update} subroutine to avoid full enumeration of $\overline \Bell_{k+1}$, which is exponential in the number of subsequent states $|N_a(s_k)|$. Such enumeration could be feasible under the limited transition assumption, but not in general. We show here how the structure of this step could be exploited. Notably, finding an allocation that achieves the minimum execution risk such that the total utility value is at least $\ell_k$ is a slight generalization for a well-known problem called {\em minimum Knapsack} (MinKS) \cite{pruhs2007approximation, bentz2016note}. More formally, \begin{definition} \label{def:ks} Multiple-choice minimum Knapsack problem (McMinKS) is defined as follows. Given a set of categories $\mathcal N$, and a set of allowable choices $\mathcal M_i$ per category $i\in \mathcal N$, an item $(i,j)$ is defined by weight $w_{i,j} \in \mathbb R_+$ and value $v_{i,j}\in \mathbb R_+$ for $i \in \mathcal N$ and $j \in \mathcal M_i$. The goal is to select one item from the allowable choices $\mathcal M_i$ per category $i$ (hence the name multiple-choice) such that the total weight is minimized, and the total value is at least $D \in \mathbb R_+$. \end{definition} The problem can be formally defined as an {\em integer linear program} (ILP) as follows. \begin{align} \text{(McMinKS)}\quad & \min_{x_{i,j} \in \{0,1\}} \sum_{i\in \mathcal N} \sum_{j \in \mathcal M_i} w_{i,j} x_{i,j}, \notag\\ \text{Subject to}\quad & \sum_{i \in \mathcal N} \sum_{j\in \mathcal M_i} v_{i,j} x_{i,j} \ge D, \label{con}\\ & \sum_{j \in \mathcal M_i} x_{i,j} = 1, \quad \text{for all } i \in \mathcal N. \end{align} Algorithm \ref{alg:update2}, denoted by {\tt KS-Update}, presents a reduction from the allocation subproblem to McMinKS in Lines~\ref{alg:ks0}-\ref{alg:ksl}. Indeed, finding an optimal solution for the corresponding McMinKS instance will obtain an FPTAS (Lemma~\ref{lem:opt} holds and hence Corollary~\ref{thm:fptas1} proof follows). However, MinKS is NP-Hard \cite{pruhs2007approximation, kellerer2004knapsack}, therefore our best bet is to find an approximate solution in polynomial time. Although there is an FPTAS for MinKS, the approximation guarantee is provided on the objective function, which in our case, following the reduction, is the constraint for the original (C)C-SSP problem. Thus, we need an algorithm that bounds the constraint violation of McMinKS (which is the objective of (C)C-SSP, following the reduction above). some modifications are needed to the algorithm to obtain a bounded McMinKS constraint violation and handle the multiple-choice extension (as we will see next). \begin{algorithm}[ht] \footnotesize \caption{\mbox{\texttt{KS-Update}$[s_k,\ell_k, \{\texttt{DP}(s,k+1,\ell)\}_{s\in \mathcal S_{k+1}}^{\ell\in \mathcal L_{k+1}} ]$}}\label{alg:update2} $\textsc{Er}(s_k)\leftarrow \infty$; $\textsc{Act} \leftarrow \varnothing$; $\textsc{Alloc} \leftarrow \mathbf{0}$ \\ \For{$a \in \mathcal A$} { // Find an allocation $\overline \Bell_{k+1}$ that achieves the minimum execution risk for action $a$ such that the total utility value is at least $\ell_k$ \\ Let $\mathcal N := \{1,...,|N_a(s_k)|\}$ \label{alg:ks0}\\ Let $\mathcal M_i := \mathcal L_{k+1}$ for $i\in \mathcal N$ \\ Let $w_{i,j} := T(s_k, a, s^i_{k+1}) \cdot \texttt{DP}_{\textsc{Er}}(s^i_{k+1}, k+1, \overline \ell^i_{k+1})$ for all $j=\overline \ell^i_{k+1} \in \mathcal L_{k+1}$ and $s^i_{k+1} \in N_a(s_k)$ \label{alg:redw}\\ Let $v_{i,j} := {T(s_k, a, s^i_{k+1}) \cdot \overline \ell^i_{k+1}}$ for $j=\overline\ell^i_{k+1} \in \mathcal M_i$ and $i$ such that $s^i_{k+1} \in N_a(s_k)$\\ Let $D:= \ell_k - U(s_k, a)$ \label{alg:ksl}\\ $\overline \Bell_{k+1} \leftarrow$ \texttt{Dyn-MinKS}$[(w_{i,j}, v_{i,j})_{i\in \mathcal N,j \in \mathcal M_i}, D]$ \label{alg:lineks} $\textsc{Er}_a(s_k, \overline \Bell_{k+1}) := r(s_k)+(1-r(s_k)) \sum_{s^i_{k+1} \in N_a(s_k)} T(s_k, a, s^i_{k+1}) \cdot \texttt{DP}_{\textsc{Er}}(s^i_{k+1}, k+1, \overline \ell^i_{k+1})$ \\ \If{$\textsc{Er}_a(s_k, \overline \Bell_{k+1}) < \textsc{Er}(s_k)$}{ $\textsc{Er}(s_k) \leftarrow \textsc{Er}_a(s_k, \overline \Bell_{k+1})$\\ $\textsc{Act} \leftarrow a$\\ $\textsc{Alloc} \leftarrow \overline \Bell_{k+1}$ } } \Return $\textsc{Er}(s_k), \textsc{Act}, \textsc{Alloc}$ \end{algorithm} \begin{algorithm}[ht] \footnotesize \caption{\texttt{Dyn-MinKS}$[(w_{i,j}, v_{i,j})_{i\in \mathcal N,j \in \mathcal M_i}, D]$}\label{alg:ks} $\Bell=(\ell^i)_{i\in \mathcal N} \leftarrow \mathbf{0}$ \\ $\texttt{TB}(i, \rho) \leftarrow \infty$ for all $i\in \mathcal N$ and $\rho \in \mathcal R$ \\ $\texttt{TB}(0, \rho) \leftarrow 0$ for all $\rho$\\ Let $\overline v_{i,j} := \Big\lfloor \frac{v_{i,j}}{R_k}\Big\rfloor\cdot R_k$ for all $i\in \mathcal N$ and $j \in \mathcal M_i$ \label{alg:discdem}\\ \For{$i = 1,..., |\mathcal N|$} { \For{$\rho \in \mathcal R_k = \Big\{0, R_k, 2R_k,..., \Big\lfloor \frac{D + \max_{i,j} v_{i,j} }{R_k} \Big\rfloor R_k \Big\}$} { $\texttt{TB}(i, \rho) \leftarrow \min_{j \in \mathcal M_i} \texttt{TB}(i-1, [\rho - \overline v_{i,j}]^+) + w_{i,j} $\\ $\texttt{Alc}(i,\rho) \leftarrow \arg\min_{j \in \mathcal M_i} \texttt{TB}(i-1, [\rho - \overline v_{i,j}]^+) + w_{i,j}$, where $[x]^+ = x$ if $x\ge 0$ and $[x]^+=0$ otherwise, for any $x \in \mathbb R$ } } Find minimum $\rho'$ such that $\rho' \ge D$\label{alg:fetch1}\\ \For{$i = |\mathcal N|, |\mathcal N|-1,..., 1$ }{ $j = \texttt{Alc}(i,\rho' )$; $\rho' \leftarrow \rho' - \overline v_{i,j}$ \label{alg:fetch2}; $\ell^i \leftarrow j$ } \Return $\Bell$ \end{algorithm} Algorithm~\ref{alg:ks}, denoted as {\tt Dyn-MinKS}, gives a dynamic programming procedure to solve McMinKS within a bounded constraint violation. The algorithm rounds the values into a discrete set of possible values that provably can have a bounded constraint violation (as per Lemma~\ref{lem:minks} below). The set of possible {\em discretized} values $\mathcal R_k$ is defined as \begin{equation} \mathcal R_k := \Big\{0, 1R_k,..., \Big\lfloor \frac{D+ \max_{i,j} v_{i,j}}{R_k} \Big\rfloor R_k \Big\}, \label{eq:defR} \end{equation} where $R_k$ is a discretization factor defined below. Let $\Bell$ be an allocation returned by algorithm {\tt Dyn-MinKS} and $\Bell^*$ be an optimal solution. \begin{lemma}\label{lem:minks} Algorithm {\tt Dyn-MinKS} obtains a solution $\Bell = (\ell^1,..., \ell^{|\mathcal N|})$ that satisfies \begin{align*} \sum_{i \in \mathcal N} w_{i,\ell^{i}} \le \sum_{i \in \mathcal N} w_{i,\ell^{i*}}, \text{ and } \sum_{i \in \mathcal N} v_{i,\ell^{i}} \ge \sum_{i \in \mathcal N} v_{i,\ell^{i*}} - |\mathcal N| R_k, \end{align*} where $\Bell^*$ is an optimal solution. \end{lemma} \begin{proof} Define $\overline v_{i, \ell^i} := \lfloor v_{i, \ell^i}/R_k \rfloor R_k$ as in Line~\ref{alg:discdem} of {\tt Dyn-MinKS} (also define $\overline v_{i,\ell^{i*}} := \lfloor v_{i, \ell^{i*}}/R_k \rfloor R_k$). The algorithm maintains a table {\tt TB}$(i,\rho)$ of minimum total item weights up to category $i$ that satisfies a total value of at least $\rho$. Since the algorithm discretizes values (Line~\ref{alg:discdem}), and the largest element of $\mathcal R$ is an upper bound on $\sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}} $ (by the definition of $\mathcal R$ in Eq.~\raf{eq:defR}), then any discretized optimal total values are considered in the table. Therefore in steps~\ref{alg:fetch1}-\ref{alg:fetch2}, the algorithm obtains a minimum $\rho \ge D$ that accrues the least total weight, hence $\sum_{i \in \mathcal N} w_{i,\ell^{i}} \le \sum_{i \in \mathcal N} w_{i,\ell^{i*}}$. By the feasibility of optimal solutions $\sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}} \ge D$, and since $\rho$ is the least element that satisfies $\rho \ge D$, we have \begin{equation} \label{eq:minks-d} \rho = \sum_{i \in \mathcal N} \overline v_{i,\ell^{i}} \ge \sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}}. \end{equation} Thus, by Eq.~\raf{eq:minks-d} and rounding values down (Line~\ref{alg:discdem} of {\tt Dyn-MinKS}), \begin{align*} \sum_{i \in \mathcal N} v_{i,\ell^{i}} &\ge \sum_{i \in \mathcal N} \overline v_{i,\ell^{i}} \ge \sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}} \ge \sum_{i \in \mathcal N} (v_{i,\ell^{i*}} - R_k) \\ &= \sum_{i \in \mathcal N} v_{i,\ell^{i*}} - |\mathcal N| R_k , \end{align*} which completes the proof. \end{proof} We define algorithm {\tt dis-DynSSP} by replacing {\tt Update} at Line~\ref{alg:update} of {\tt lim-DynSSP} by {\tt KS-Update}, and using the following discretization factors, \begin{align} \label{eq:newR} L_k = \frac{\epsilon U_{\max}}{3(h-k) (\ln h + 1)} \quad \text{and}\quad R_k = \frac{L_k}{\gamma}. \end{align} \begin{lemma}\label{lem:opt2} Let $\pi$ be a policy obtained by {\tt dis-DynSSP} and $\pi^*$ be an optimal deterministic policy. The solution $\pi$ satisfies $\overline v_{\pi}(s_k) \ge \overline v_{\pi^*}(s_k) - 2 \sum_{k'=k}^{h-1}\cdot L_{k'}.$ \end{lemma} \begin{proof} We show (by induction) that for some $\ell_k \in \mathcal L_k$ and action $a$, we have $\ell_k = \overline v_\pi(s_k) \ge \overline v_{\pi^*}(s_k)- 2 \sum_{k'=k}^{h-1}\cdot L_{k'}.$ We proceed with the induction proof; for the base case, $k=h-1$, we have $ \overline v_\pi(s_{h-1}) = \lfloor U(s_{h-1}, a)/L_{h-1} \rfloor L_{h-1}$. Clearly, there is an action that satisfies the claim. For the inductive step, suppose the claim holds at step $k$; we show that the claim also holds for step $k-1$. Since the {\tt dis-DynSSP} considers all possible values for $\ell_{k-1}$ at time $k-1$, there exists an $\ell_{k-1}$, an action $a$, and a solution $\overline \Bell_k$ (Line \ref{alg:lineks} of {\tt KS-Update}) such that, {\footnotesize \begin{align} &\ell_{k-1} = \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{s^i_k \in N_a(s_{k-1})} T(s_{k-1}, a, s^i_k) \overline \ell^{i}_{k} \notag \\ &\qquad \quad + U(s_{k-1}, a) \Big)\bigg\rfloor L_{k-1}\notag \\ &\ge \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{s^i_{k} \in N_a(s_{k-1})} T(s_{k-1}, a, s^i_{k}) \overline \ell^{i*}_k - |\mathcal N_{a}(s_{k-1})| R_k \notag \\ &\qquad \quad + U(s_{k-1}, a)\Big)\bigg\rfloor L_{k-1} \label{eq:bylemminks} \end{align} }% where Eq.~\raf{eq:bylemminks} follows by Lemma~\ref{lem:minks} (where $v_{i,j}:= T(s_{k-1},a, s^i_k)\cdot \overline v_\pi(s^i_k)$ and $w_{i,j}:=T(s_{k-1}, a, s^i_k) \cdot \texttt{DP}_{\textsc{Er}}(s^i_k, k, \overline \ell^i_{k})$ as per Line~\ref{alg:redw} of {\tt KS-Update}). By the inductive assumption and Eq.~\raf{eq:bylemminks}, {\footnotesize \begin{align*} \ell_{k-1} &\ge \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{s_{k} \in \mathcal S} T(s_{k-1}, a, s_{k}) \big(\overline v_{\pi^*}(s_k) - 2\sum_{k'=k}^{h-1}L_{k'}\big) \notag \\ &\qquad \quad - |\mathcal N_{a}(s_{k-1})| R_{k-1} + U(s_{k-1}, a)\Big)\bigg\rfloor L_{k-1} \end{align*} }% Therefore, {\footnotesize \begin{align} &\ell_{k-1} \ge \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{s_{k} \in \mathcal S_k} T(s_{k-1}, a, s_{k}) \overline v_{\pi^*}(s_k) + U(s_{k-1}, a) \notag \\ &\qquad\quad - 2\sum_{k'=k}^{h-1}L_{k'} - \gamma R_{k-1}\Big)\bigg\rfloor L_{k-1} \label{eq:dround0} \end{align} }% Thus, by the definition of $R_{k}$ in Eq.~\raf{eq:newR}, the r.h.s of Eq.~\raf{eq:dround0} can be written as, \begin{align} &\ell_{k-1}\ge \bigg\lfloor \tfrac{1}{L_{k-1}}\Big(\sum_{s_{k} \in \mathcal S_k} T(s_{k-1}, a, s_{k}) \overline v_{\pi^*}(s_k) + U(s_{k-1}, a) \notag \\ &\qquad \quad -2\sum_{k'=k}^{h-1}L_{k'} - L_{k-1} \Big)\bigg\rfloor L_{k-1} \label{eq:dround1}\\ &\ge \overline v_{\pi^*}(s_k) - 2 \sum_{k'=k-1}^{h-1} L_{k'} \label{eq:dround2}, \end{align} By the disjoint transition assumption (following the feasibility argument in the proof of Lemma~\ref{lem:opt}), policy $\pi$ is feasible. \end{proof} \begin{corollary} \label{thm:fptas2} Algorithm {\tt dis-DynSSP} is an FPTAS for (C)C-SSP under disjoint transition assumption. \end{corollary} \begin{proof} First, observe that the algorithm maintains a dynamic programming table with minimum execution risk. Lines~\ref{alg:f1} of subroutine {\tt Fetch-Policy} ensures that a feasible solution with such property is constructed. The algorithm runs in polynomial time as the sizes of $\mathcal L_k$ and $\mathcal R_k$ are polynomial. By Lemma~\ref{lem:dis} and Lemma~\ref{lem:opt2}, expanding for $s_0$, and by the definition of $L_k$ and $R_k$, we obtain \begin{align} \overline v_\pi(s_0) &\ge \overline v_{\pi^*}(s_0) - 2 \sum_{k=0}^{h-1} L_{k} \\ &\ge v_{\pi^*}(s_0) - \sum_{k=0}^{h-1}L_{k} - 2 \sum_{k=0}^{h-1} L_{k} \end{align} Substituting $L_{k}$ obtains, \begin{align} & = v_{\pi^*}(s_0) - 3 \sum_{k=0}^{h-1} \frac{\epsilon U_{\max}}{3(h-k)(\ln h + 1)} \\ &= v_{\pi^*}(s_0) - \frac{\epsilon U_{\max}}{\ln h + 1} \sum_{k=0}^{h-1} \frac{1}{(h-k)} \end{align} Using the upper bound on the harmonic series $\sum_{n=1}^k \tfrac{1}{n} \le \ln k + 1$ obtains \begin{align} \overline v_\pi(s_0) &\ge v_{\pi^*}(s_0) - \frac{\epsilon U_{\max}}{\ln h + 1} (\ln h + 1) \label{eq:harr2}\\ &\ge (1-\epsilon)\cdot v_{\pi^*}(s_0), \ \end{align} Therefore, $v_\pi(s_0) \ge \overline v_{\pi}(s_0) \ge (1-\epsilon) v_{\pi^*}(s_0),$ which completes the proof. \end{proof} \vspace{-30pt} \subsection{FPTAS for (C)C-SSP under Local Transition} \vspace{-20pt} \label{sec:fptas} \begin{algorithm}[ht] \footnotesize \caption{\texttt{DynSSP}$[M, \epsilon]$}\label{alg2} ${\tt DP}_{\textsc{Er}}(s_k,k,\ell_k) \leftarrow \infty$; ${\tt DP}_{\sc \pi}(s_k,k,\ell_k) \leftarrow \varnothing$, ${\tt DP}_{\bar \Bell}(s_k,k,\ell_k) \leftarrow \mathbf{0}$, for all $k=0,...,h-1$; $s_k\in \mathcal S_k$; $\ell_k \in \mathcal L_k$ \\ ${\tt DP}_{\textsc{Er}}(s_h,h,0) \leftarrow r(s_h)$ \\ \For{$k=h-1,...,0; J_k\in \mathcal J_k; \ell_k \in \mathcal L_k$ }{ $\big({\tt DP}_{\textsc{Er}}(s^c_k,k,\ell_k), {\tt DP}_{\pi}(s^c_k,k,\ell_k), {\tt DP}_{\bar \Bell}(s^c_k,k,\ell_k)\big)_{s^c_k \in J_k} \leftarrow \texttt{mKS-Update}[J_k,\ell_k, \{\texttt{DP}_{\textsc{Er}}(\cdot,k+1,\cdot)\}] $ \label{alg:update} } $\pi \leftarrow \texttt{Fetch-Policy}[\texttt{DP}]$ \Return $\pi$ \end{algorithm} \begin{algorithm}[ht] \footnotesize \caption{\mbox{\texttt{mKS-Update}\small $\big[J_k,\ell_k, \{\texttt{DP}(s,k+1,\ell)\}_{s\in\mathcal S_{k+1}}^{\ell\in \mathcal L_{k+1}} \big ]$}}\label{alg:update3} $\textsc{Er}(s^c_k)\leftarrow \infty$ for $s_k^c \in J_k$\\ $\textsc{Act} \leftarrow \varnothing$\\ $\textsc{Alloc} \leftarrow \mathbf{0}$ \\ \For{$\mathbf a=(a^c)_{s^c_{k} \in J_k} \in \mathcal A^{|J_k|}$}{ // Find an allocation that achieves the minimum execution risk of states in $J_k$ such that the total utility at each $s_k^c\in J_k$ is at least $\ell_k$\\ Let $\mathcal N := \big\{1,..., |\bigcup_{s^c_k \in J_k} N_{a^c}(s^c_k)| \big\}$ \label{alg:mks0}\\ Let $\mathcal M_i := \mathcal L_{k+1}$ for $i\in \mathcal N$ \\ Let $w_{i,j} := \sum_{s^c_k \in J_k} T(s^c_k, a^c, s^i_{k+1}) \cdot \texttt{DP}_{\textsc{Er}}(s^i_{k+1}, k+1, \overline \ell^i_{k+1})$ for all $j=\overline \ell^i_{k+1} \in \mathcal L_{k+1}$ and $s^i_{k+1} \in N_a(s^c_k)$\\ \For{$ s^c_k \in J_k$}{ Let $v^c_{i,j} := {T(s^c_k, a^c, s^i_{k+1}) \cdot \overline \ell^i_{k+1}}$ for all $j=\overline\ell^i_{k+1} \in \mathcal M_i$ and $i$ such that $s^i_{k+1} \in N_a(s^c_k)$\\ Let $D^c:= \ell_k - U(s^c_k, a^c)$ \label{alg:mksl} } $(\overline \Bell^i_{k+1})_{i \in \mathcal N } \leftarrow$ Solve \texttt{MMcMinKS}$[\{ (w_{i,j}, v^c_{i,j})_{i\in \mathcal N,j \in \mathcal M_i}, D^c\}_{s^c_k \in J_k}]$ $\textsc{Er}_{a^c}(s^c_k, \overline \Bell_{k+1}) := r(s^c_k)+(1-r(s^c_k)) \sum_{s^i_{k+1} \in N_{a^c}(s^c_k)} T(s^c_k, a^c, s^i_{k+1}) \cdot \texttt{DP}_{\textsc{Er}}(s^i_{k+1}, k+1, \overline \ell^i_{k+1})$ for $s^c_k \in J_k$\\ \If{$\sum_{s^c_k \in J_k}\textsc{Er}_{a^c}(s^c_k, \overline \Bell_{k+1}) < \sum_{s^c_k \in J_k}\textsc{Er}(s^c_k)$}{ \For{$s^c_k \in J_k$}{ $\textsc{Er}(s^c_k) \leftarrow \textsc{Er}_{a^c}(s^c_k, \overline \Bell_{k+1})$\\ $\textsc{Act}^c \leftarrow a^c$ \\ $\textsc{Alloc}^c \leftarrow (\overline\Bell^i_{k+1})_{s^i_{k+1} \in N_{a^c}(s^c_k)}$ } } } \Return $(\textsc{Er}(s^c_k), \textsc{Act}^c, \textsc{Alloc}^c)_{s^c_k \in J_k}$ \end{algorithm} To deal with (C)C-SSP with local transitions, we show how to convert the allocation subproblem into a {\em multi-dimensional} version of McMinKS (denoted as MMcMinKS). Define a family of disjoint sets of states $\mathcal J_k \subseteq 2^{\mathcal S_k}$ as \begin{align*} \mathcal J_k &:= \{J_k \subseteq \mathcal S_k \mid N_a(s_k) \cap N_{a'}(s'_k) \neq \varnothing,\\ &\qquad \text{ for } s_k, s'_k \in J_k; a,a' \in \mathcal A \}. \end{align*} According to the local transition assumption, $|J_k|$ is at most a constant $\psi$, a necessary property that enables a polynomial-time algorithm. MMcMinKS extends definition~\ref{def:ks} allowing the value of each item to be a $|J_k|$-dimensional vector. The goal is to compute the total minimum weight such that the total value for each dimension is at least $D^c \in \mathbb R_+$ for $c= \{1,...,|J_k|\}$. More formally, the problem can be defined as an ILP by replacing Cons.~\raf{con} by $\sum_{i \in \mathcal N} \sum_{j\in \mathcal M_i} v^c_{i,j} x_{i,j} \ge D^c,$ for $c=1,...,|J_k|$. The main idea, presented in Alg.~\ref{alg2} (denoted by {\tt DynSSP}), is to operate on clusters of states $J_k$ instead of individual states as in {\tt dis-DynSSP}. {\tt mKS-Update} (Alg.~\ref{alg:update3}) provides a reduction from the allocation problem into MMcMinKS. The main ideas remain similar to {\tt dis-DynSSP} except that here we require to solve an instance of multi-dimensional McMinKS. This can be done by a slight modification of {\tt Dyn-MinKS}: create $|J_k|$ dimensional dynamic programming table {\tt TB}$(j, \rho^1,..., \rho^{|J_k|})$. Since $|J_k|\le \psi$ is a constant, the size of the table is polynomial in the input size. \begin{theorem} \label{thm:fptas3 Algorithm {\tt DynSSP} is an FPTAS for (C)C-SSP under local transition assumption. \vspace{-5pt} \end{theorem} A proof of the theorem can be obtains using that of Corollary~\ref{thm:fptas2} with a slight modification of Lemma~\ref{lem:minks} to account for higher dimensional dynamic programming table. \section*{Appendix} \subsection*{Proof of Lemma \ref{lem:minks}} \begin{proof} Define $\overline v_{i, \ell^i} := \lfloor v_{i, \ell^i}/R_k \rfloor R_k$ as in Line~\ref{alg:discdem} of {\tt Dyn-MinKS} (also define $\overline v_{i,\ell^{i*}} := \lfloor v_{i, \ell^{i*}}/R_k \rfloor R_k$). Since the algorithm discretizes values (Line~\ref{alg:discdem}), and the largest element of $\mathcal R$ is an upper bound on $\sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}} $ (by the definition of $\mathcal R$ in Eq.~\raf{eq:defR}), then any discretized optimal total values are considered in the table. The algorithm maintains a table {\tt TB}$(i,\rho)$ of minimum total item weights up to user $i$ that satisfies a total value of at least $\rho$. Therefore in steps~\ref{alg:fetch1}-\ref{alg:fetch2}, the algorithm obtains a minimum $\rho \ge D$ that accrues the least total weight, hence $\sum_{i \in \mathcal N} w_{i,\ell^{i}} \le \sum_{i \in \mathcal N} w_{i,\ell^{i*}}$. By the feasibility of optimal solutions $\sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}} \ge D$, and since $\rho$ is the least element that satisfies $\rho \ge D$, we have \begin{equation} \label{eq:minks-d} \sum_{i \in \mathcal N} \overline v_{i,\ell^{i}} \ge \sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}}. \end{equation} Thus, by Eq.~\raf{eq:minks-d} and rounding values down (Line~\ref{alg:discdem} of {\tt Dyn-MinKS}), \begin{align*} \sum_{i \in \mathcal N} v_{i,\ell^{i}} &\ge \sum_{i \in \mathcal N} \overline v_{i,\ell^{i}} \ge \sum_{i \in \mathcal N} \overline v_{i,\ell^{i*}} \ge \sum_{i \in \mathcal N} (v_{i,\ell^{i*}} - R_k) &= \sum_{i \in \mathcal N} v_{i,\ell^{i*}} - |\mathcal N| R_k , \end{align*} which completes the proof. \end{proof} \subsection*{Proof of Corollary~\ref{thm:fptas2}} \begin{proof} First, observe that the algorithm maintains a dynamic programming table with minimum execution risk. Lines~\ref{alg:f1} of subroutine {\tt Fetch-Policy} ensures that a feasible solution with such property is constructed. The algorithm runs in polynomial time as the sizes of $\mathcal L_k$ and $\mathcal R_k$ are polynomial. By Lemma~\ref{lem:dis} and Lemma~\ref{lem:opt2}, expanding for $s_0$, and by the definition of $L_k$ and $R_k$, we obtain \begin{align} \overline v_\pi(s_0) &\ge \overline v_{\pi^*}(s_0) - 2 \sum_{k'=0}^{h-1} L_{k'} \\ &\ge v_{\pi^*}(s_0) - \sum_{k'=0}^{h-1}L_{k'} - 2 \sum_{k'=k}^{h-1} L_{k'}\\ & = v_{\pi^*}(s_0) - 3 \sum_{k=0}^{h-1} \frac{\epsilon U_{\max}}{3(h-k)(\ln h + 1)} \\ &= v_{\pi^*}(s_0) - \frac{\epsilon U_{\max}}{\ln h + 1} \sum_{k=0}^{h-1} \frac{1}{(h-k)} \notag \\ &\ge v_{\pi^*}(s_0) - \frac{\epsilon U_{\max}}{\ln h + 1} (\ln h + 1) \label{eq:harr2}\\ &\ge (1-\epsilon)\cdot v_{\pi^*}(s_0), \ \end{align} where Eq.~\raf{eq:harr2} follows by using an upper bound on the harmonic series, $\sum_{n=1}^k \tfrac{1}{n} \le \ln k + 1$. Therefore, \begin{align} v_\pi(s_0) \ge \overline v_{\pi}(s_0) \ge (1-\epsilon) v_{\pi^*}(s_0), \end{align} which completes the proof. \end{proof} \section{Conclusion} \vspace{-10pt} This work provides the first fully polynomial-time approximation scheme for a class of constrained stochastic shortest path under local transition. Since the problem is NP-Hard, our algorithm is the best polynomial-time approximation algorithm attainable in theory. We believe our results provide fundamental insights into the problem and can lead to the future development of algorithms and faster heuristics for (C)C-SSP and constrained reinforcement learning. \section{Problem Definition} We provide formal definitions for C-SSP and CC-SSP as follows. A fixed-horizon constrained stochastic shortest path (C-SSP) is a tuple \mbox{$ M= \langle \mathcal S, \mathcal A, T, U, s_0, h,C, P\rangle$}, where $\mathcal S$ and $\mathcal A$ are finite sets of discrete {states} and {actions}, respectively; $T: \mathcal S \times\mathcal A\times \mathcal S \rightarrow [0,1]$ is a probabilistic {transition function} between states, $T(s,a,s') = \Pr(s' \mid a,s)$, where $s,s' \in \mathcal S$ and $a\in \mathcal A$; $U: \mathcal S \times \mathcal A\rightarrow \mathbb R_+$ is a non-negative {utility function}; $s_0$ is an initial state; $h$ is the planning horizon; $C: \mathcal S \times \mathcal A\rightarrow \mathbb R_+$ is a non-negative {cost function}; $P\in \mathbb R_+$ is a positive upper bound on the cost. A {\em deterministic} policy $\pi(\cdot,\cdot)$ is a function that maps a state and time step into an action, $\pi:\mathcal S\times \{0,1,...,h-1\} \rightarrow \mathcal A$. For simplicity, we write $\pi(s_k)$ to denote $\pi(s_k,k)$. A {\em run} is a sequence of random states $S_0, S_1,\ldots, S_{h-1}, S_h$ that result from executing a policy, where $S_0 = s_0$ is known. The objective is to compute a policy that maximizes (resp. minimizes) the expected utility (resp. cost) while satisfying the constraint. More formally, \begin{align} \textsc{(C-SSP)}\quad&\quad\max_{\pi} \mathbb{E}\Big[\sum_{\mathclap{k=0}}^{h-1} U(S_{k}, \pi(S_{k}) ) \Big] \label{obj1}\\ \text{Subject to }\quad & \mathbb{E} \Big[\sum_{k=0}^{h-1} C(S_k, \pi(S_k))\mid \pi \Big] \le \ P.\notag \end{align} The SSP problem and its constrained variants can be visualized by a direct acyclic And-Or graph (DAG), where the vertices represent the states and actions. Thus, at depth $k$ the set of state nodes are the states that are reachable from previous actions at depth $k-1$, denoted as $\mathcal S_{k}\subseteq \mathcal S$. At each depth we have at most $|\mathcal S|$ states. Fig.~\ref{fig:ccssp_graph} provides a pictorial illustration of the SSP And-Or (search) graph. Not that unlike And-Or search trees obtained by history enumeration algorithms (see, e.g., \cite{sungkweon2021ccssp}), with such representation, a node may have multiple parents, leading to significant reduction in the search space. \begin{figure}[ht] \centering \includegraphics[scale=.7]{figs/AndOr.pdf}\vspace{-5pt} \caption{SSP graph where circles are state nodes and squares are actions. Circles with thick borders represent reachable states at time $k$, denoted as $\mathcal S_k$.}\vspace{-10pt} \label{fig:ccssp_graph} \end{figure} The objective function and the constraint's left hand side can be written recursively using Bellman equation as \begin{align*} v_\pi(s_k) &:= \sum_{\mathclap{s_{k+1} \in \mathcal S_{k+1}}} T(s_k, \pi(s_k), s_{k+1}) v_\pi(s_{k+1}) + U(s_k, \pi(s_k)),\\ c_\pi(s_k) &:= \sum_{\mathclap{s_{k+1} \in \mathcal S_{k+1} }} T(s_k, \pi(s_k), s_{k+1}) c_\pi(s_{k+1}) + C(s_k, \pi(s_k)), \end{align*} for $k=0,...,h-1.$ A fixed-horizon chance-constrained stochastic shortest path (CC-SSP) problem is formally defined as a tuple $M=\langle \mathcal S, \mathcal A, T,U, s_0, h, r, \Delta \rangle,$ where $\mathcal S, \mathcal A, T, U, s_0, h, \mathcal N$ are defined as in C-SSP, and \begin{itemize} \item $r: \mathcal S \rightarrow [0,1]$ is the probability of failure at a given state; \item $\Delta$ is the corresponding risk budget, a threshold on the probability of failure over the planning horizon. \end{itemize} Let $R(s)$ be a Bernoulli random variable that indicate failure at state $s$, such that $R(s)=1$ if and only if $s$ is risky state, and zero otherwise. For simplicity, we write $R(s)$ to denote $R(s)=1$. The objective of {CC-SSP} is to compute a deterministic policy (or a conditional plan) $\pi$ that maximizes (or minimizes) the cumulative expected utility (or cost) while bounding the probability of failure at {\em any} time step throughout the planning horizon. More precisely, \begin{align} \textsc{(CC-SSP)}\quad&\quad\max_{\pi} \mathbb{E}\Big[\sum_{\mathclap{k=0}}^{h-1} U(S_{k}, \pi(S_{k}) ) \Big] \\ \text{Subject to }\quad & \Pr\Big(\bigvee_{k=0}^{h} R(S_k) \mid \pi \Big) \le \Delta. \label{con1} \end{align} To better understand Cons.~\raf{con1}, define the {\em execution risk} of a run at state $s_k$ as $$\textsc{Er}_{\pi}(s_k) := \Pr\Big(\bigvee_{k'=k}^{h} R(S_{k'}) \mid S_k = s_k\Big).$$ According to the definition, Cons.~\raf{con1} is equivalent to $\textsc{Er}_\pi(s_0) \le \Delta$. The lemma below shows that such constraint can be computed recursively. \begin{lemma}[\cite{khonji2021dual}]\label{lem:rec} The execution risk of policy $\pi$ can be written as \begin{equation*} \footnotesize \textsc{Er}_{\pi}(s_k) = \left\{\begin{array}{l} r(s_k)+(1-r(s_k)) \\ \hspace{35pt}\displaystyle\sum_{\mathclap{s_{k+1}\in \mathcal S}}\textsc{Er}_{\pi}(s_{k+1}) \pi(s_k) T(s_k, a, s_{k+1}), \vspace{-10pt}\\ \hfill\text{if } k=0,...,h-1, \\ r(s_h),\hfill \text{if } k=h. \end{array}\right. \end{equation*} \end{lemma} In this work, we study a variant of (C)C-SSP in which the number of state-action pairs that share subsequent states is bounded. Such extension denoted as (C)C-SSP under {\em local transition}. More formally, define the set of potential next states after executing action $a$ from state $s_k \in \mathcal S_k$ for $k=0,...,h-1$ by, \begin{align*} N_a(s_k) &:= \{s_{k+1} \mid T(s_k,a,s_{k+1}) > 0, s_{k+1}\in \mathcal S_{k+1} \},\\ N_a(s_h) &:= \varnothing. \end{align*} \begin{definition}[Local Transition] \label{def:loc} There exists a constant $\psi\in \mathbb N_+$ such that $$\big| \{s'_k \mid N_a(s_k) \cap N_{a'}(s'_k) \neq \varnothing, \text{ for } s'_k \in \mathcal S_k, a' \in \mathcal A\} \big| \le \psi,$$ for any $ s_k \in \mathcal S_k, a\in \mathcal A.$ \end{definition} When $\psi = 0$, we call our problem (C)C-SSP under {\em disjoint transition}. The And-Or graph under disjoint transition assumption is, in fact, an And-Or tree. Such structure helps to easily obtain a dynamic programming structure that is exploited in our algorithms, shown in subsections~\ref{sec:fptas-limited}-\ref{sec:fptas-disjoint}. To benchmark our algorithm, we relay on the notion of approximation algorithms. The subject of approximation algorithms is well-studied in the theoretical computer science community \cite{Vazirani10}. As follows, we define some standard terminology for approximation algorithms. Consider a maximization problem $\Pi$ with non-negative objective function $f(\cdot)$; let $F$ be a feasible solution to $\Pi$ and $F^\star$ be an optimal solution to $\Pi$. $f(F) $ denotes the objective value of $F$. Let $\ensuremath{\textsc{Opt}}= f(F^\star)$ be the optimal objective value of $F^\star$. A common definition of approximate solutions is $\alpha$-approximation, where $\alpha$ characterizes the approximation ratio between the approximate solution and an optimal solution. \begin{definition}[\cite{Vazirani10}] For $\alpha\in[0,1]$, an $\alpha$-approximation to maximization problem $\Pi$ is an algorithm that obtains a feasible solution $F$ for any instance such that $f(F)\ge \alpha \cdot \ensuremath{\textsc{Opt}}.$ \label{def:alpha} \end{definition} In particular, {\em fully polynomial-time approximation scheme} (FPTAS) is a $(1-\epsilon)$-approximation algorithm to a maximization problem, for any $\epsilon>0$. The running time of a FPTAS is polynomial in the input size and for every fixed $\tfrac 1 \epsilon$. In other words, FPTAS allows to trade the approximation ratio against the running time. \section{Introduction} The {\em Markov decision process} (MDP) \cite{howard1960dynamic} is a classical model for planning in uncertain environments. An MDP consists of states, actions, a stochastic transition function, a utility function, and an initial state. A solution of MDP is a policy that maps a state to an action that maximizes the global expected utility. The {\em stochastic shortest path} (SSP) \cite{bertsekas1991analysis} is an MDP with non-negative utility values. The problem has an interesting structure and can be formulated with a dual linear programming (LP) formulation \cite{d1963probabilistic} that can be interpreted as a minimum cost flow problem. Moreover, SSP admits many heuristics-based algorithms \cite{bonet2003labeled, hansen2001lao} that utilize admissible heuristics to guide the search without exploring the whole state space. Besides, constrained SSP (C-SSP) \cite{altman1999constrained} provides the means to add mission-critical requirements while optimizing the objective function. Each requirement is formulated as a {\em budget constraint} imposed by a non-replenishable resource for which a bounded quantity is available during the entire plan execution. Resource consumption at each time step reduces the resource availability during subsequent time steps (see ~\cite{de2021constrained} for a detailed discussion). A stochastic policy of C-SSP is attainable using several efficient algorithms (e.g., \cite{feinberg1996constrained}). A heuristics-based search approach in the dual LP can further improve the running time for large state spaces \cite{trevizan2016heuristic}. For deterministic policies, however, it is known that C-SSP is NP-Hard for the finite-horizon case \cite{khonji2019approximability} (even when the planning horizon is only 2). The problem is also NP-Hard for the discounted infinite-horizon case~\cite{feinberg2000constrained}. A special type of constraint occurs when we want to bound the probability of constraint violations by some threshold $\Delta$, which is often called a {\em chance constrained} SSP (CC-SSP). To simplify the problem, \cite{dolgov2003approximating} proposes approximating the constraint using Markov's inequality, which converts the problem to C-MDP. Another approach by \cite{de2017bounding} applies Hoeffding's inequality on the sum of independent random variables to improve the bound. Both methods provide conservative policies that respect safety thresholds at the expense of the objective value (which could be arbitrarily worse than the optimal). In the partially observable setting, the problem is called chance constrained partially observable MDP (CC-POMDP). Several algorithms address CC-POMDP under risk constraints~\cite{santana2016rao,khonji2019approximability}. However, due to partial observability, these methods require an enumeration of histories, making the solution space exponentially large with respect to the planning horizon. To speed up the computation, \cite{sungkweon2021ccssp} provides an {\em anytime} algorithm using a Lagrangian relaxation method for CC-SSP and CC-POMDP that returns feasible sub-optimal solutions and gradually improves the solution's optimality when sufficient time is permitted. Unfortunately, the solution space is represented as an And-Or tree of all possible history trajectories, causing the algorithm to slow down as we increase the planning horizon. In this work, we study a variant of (C)C-SSP in which the number of state-action pairs that share subsequent states is bounded by a constant, denoted as (C)C-SSP under {\em local transitions}. This variant captures a wide class of SSP problems where state reachability exhibit certain {\em locality} such that only a constant number of states can reach some {\em nearby} states. The main contribution of this paper is a {\em fully polynomial time approximation scheme} (FPTAS) that computes (near) optimal deterministic policies for finite-horizon (C)C-SSP under local transitions in polynomial time. Since, (C)C-SSP is shown to be NP-Hard (even under local transitions assumption \cite{khonji2019approximability}), our result is the best possible approximation algorithm attainable in theory.
{'timestamp': '2022-04-12T02:27:39', 'yymm': '2204', 'arxiv_id': '2204.04780', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04780'}
arxiv
\section{Introduction} \label{sec:introduction} Process mining is a branch of data science that aims to analyze the execution of business processes starting from the event data contained in the information systems supporting the processes. Several types of process mining are available, including \emph{process discovery} (the automatic discovery of a process model from the event data), \emph{conformance checking} (the comparison between the behavior contained in the event data against the process model, with the purpose to find deviations), \emph{model enhancement} (the annotation of the process model with frequency/performance information) and \emph{predictive analytics} (predicting the next path or the time until the completion of the instance). Process mining is applied worldwide to a huge amount of data using different tools (academic/commercial). Some important tool features to allow process mining in organizational settings are: the \emph{pre-processing and transformation} possibilities, the \emph{possibility to drill-down} (creating smaller views on the dataset, to focus on some aspect of the process), the availability of \emph{visual analytics} (which are understandable to non-business users), the \emph{responsiveness and performance} of the tool, and the possibilities of \emph{machine learning} (producing useful predictive analytics and what-if analyses). Commercial tools tackle these challenges with more focus than academic/open-source tools, which, on the other hand, provide more complex analyses (e.g., process discovery with inductive miner, declarative conformance checking). The PM4Py library \url{http://www.pm4py.org}, based on the Python 3 programming language, permits to integrate with the data processing and machine learning packages which are available in the Python world (Pandas, Scikit-Learn). However, most of its algorithms work in single-thread, which is a drawback for performance. In this demo paper, we will present a GPU-based open-source library for process mining, PM4Py-GPU, based on the NVIDIA RAPIDS framework, allowing us to analyze a large amount of event data with high performance offering access to GPU-based machine learning. The speedup over other open-source libraries for general process mining purposes is more than 10x. The rest of the demonstration paper is organized as follows. Section \ref{sec:preliminaries} introduces the NVIDIA RAPIDS framework, which is at the base of PM4Py-GPU, and of some data formats/structures for the storage of event logs; Section \ref{sec:implementationTool} presents the implementation, the different components of the library and some code examples; Section \ref{sec:assessment} assess PM4Py-GPU against other products; Section \ref{sec:relatedWork} introduces the related work on process mining on big data and process mining on GPU; Finally, Section \ref{sec:conclusion} concludes the demo paper. \section{Preliminaries} \label{sec:preliminaries} This section will first present the NVIDIA RAPIDS framework for GPU-enabled data processing and mining. Then, an overview of the most widely used file formats and data structures for the storage of event logs is provided. \subsection{NVIDIA RAPIDS} The NVIDIA RAPIDS framework \url{https://developer.nvidia.com/rapids} was launched by NVIDIA in 2018 with the purpose to enable general-purpose data science pipelines directly on the GPU. It is composed of different components: CuDF (GPU-based dataframe library for Python, analogous to Pandas), CuML (GPU-based general-purpose machine learning library for Python, similar to Scikit-learn), and CuGraph (GPU-based graph processing library for Python, similar to NetworkX). The framework is based on CUDA (developed by NVIDIA to allow low-level programming on the GPU) and uses RMM for memory management. NVIDIA RAPIDS exploit all the cores of the GPU in order to maximize the throughput. When a computation such as retrieving the maximum numeric value of a column is operated against a column of the dataframe, the different cores of the GPU act on different parts of the column, a maximum is found on every core. Then the global maximum is a reduction of these maximums. Therefore, the operation is parallelized on all the cores of the GPU. When a group-by operation is performed, the different groups are identified (also here using all the cores of the GPU) as the set of rows indices. Any operation on the group-by operation (such as taking the last value of a column per group; performing the sum of the values of a column per group; or calculating the difference between consecutive values in a group) is also performed exploiting the parallelism on the cores of the GPU. \subsection{Dataframes and File Formats for the Storage of Event Logs} In this subsection, we want to analyze the different file formats and data structures that could be used to store event logs, and the advantages/disadvantages of a columnar implementation. As a standard to interchange event logs, the XES standard is proposed \url{https://xes-standard.org/}, which is text/XML based. Therefore, the event log can be ingested in memory after parsing the XML, and this operation is quite expensive. Every attribute in a XES log is typed, and the attributes for a given case do not need to be replicated among all the events. Event logs can also be stored as CSV(s) or Parquet(s), both resembling the structure of a table. A CSV is a textual file hosting an \emph{header row} (containing the names of the different columns separated by a separator character) and many \emph{data rows} (containing the values of the attributes for the given row separated by a separator character). A problem with the CSV format is the typing of the attributes. A Parquet file is a binary file containing the values for each column/attribute, and applying a column-based compression. Each column/attribute is therefore strictly typed. CuDF permits the ingestion of CSV(s)/Parquet(s) into a dataframe structure. A dataframe is a table-like data structure organized as columnar storage. As many data processing operations work on a few attributes/columns of the data, adopting a columnar storage permits to retrieve specific columns with higher performance and to reduce performance problems such as cache misses. Generally, the ingestion of a Parquet file in a CuDF dataframe is faster because the data is already organized in columns. In contrast, the parsing of the text of a CSV and its transformation to a dataframe is more time expensive. However, NVIDIA CuDF is also impressive in the ingestion of CSV(s) because the different cores of the GPU are used on different parts of the CSV file. \section{Implementation and Tool} \label{sec:implementationTool} In PM4Py-GPU, we assume an event log to be ingested from a Parquet/CSV file into a CuDF dataframe using the methods available in CuDF. On top of such dataframe, different operations are possible, including: \begin{itemize} \item \emph{Aggregations/Filtering at the Event Level}: we would like to filter in/out a row/event or perform any aggregation based solely on the properties of the row/event. Examples: filtering the events/rows for which the cost is $> 1000$; associate its number of occurrences to each activity. \item \emph{Aggregations/Filtering at the Directly-Follows Level}: we would like to filter in/out rows/events or perform any sort of aggregation based on the properties of the event and of the previous (or next) event. Examples: filtering the events with activity \emph{Insert Fine Notification} having a previous event with activity \emph{Send Fine}; calculating the frequency/performance directly-follows graph. \item \emph{Aggregations/Filtering at the Case Level}: this can be based on global properties of the case (e.g., the number of events in the case or the throughput time of the case) or on properties of the single event. In this setting, we need an initial exploration of the dataframe to group the indexes of the rows based on their case and then perform the filtering/aggregation on top of it. Examples: filtering out the cases with more than $10$ events; filtering the cases with at least one event with activity \emph{Insert Fine Notification}; finding the throughput time for all the cases of the log. \item \emph{Aggregations/Filtering at the Variant Level}: the aggregation associates each case to its variant. The filtering operation accepts a collection of variants and keeps/remove all the cases whose variant fall inside the collection. This requires a double aggregation: first, the events need to be grouped in cases. Then this grouping is used to aggregate the cases into the variants. \end{itemize} To facilitate these operations, in PM4Py-GPU we operate three steps starting from the original CuDF dataframe: \begin{itemize} \item The dataframe is ordered based on three criteria (in order, case identifier, the timestamp, and the absolute index of the event in the dataframe), to have the events of the same cases near each other in the dataframe, increasing the efficiency of group-by operations. \item Additional columns are added to the dataframe (including the position of the event inside a case; the timestamp and the activity of the previous event) to allow for aggregations/filtering at the directly-follows graph level. \item A \emph{cases dataframe} is found starting from the original dataframe and having a row for each different case in the log. The columns of this dataframe include the number of events for the case, the throughput time of the case, and some numerical features that uniquely identify the case's variant. Case-based filtering is based on both the original dataframe and the cases dataframe. Variant-based filtering is applied to the cases dataframe and then reported on the original dataframe (keeping the events of the filtered cases). \end{itemize} The PM4Py-GPU library is available at the address \url{https://github.com/Javert899/pm4pygpu}. It does not require any further dependency than the NVIDIA RAPIDS library, which by itself depends on the availability of a GPU, the installation of the correct set of drivers, and of NVIDIA CUDA. The different modules of the library are: \begin{itemize} \item \emph{Formatting module (format.py)}: performs the operations mentioned above on the dataframe ingested by CuDF. This enables the rest of the operations described below. \item \emph{DFG retrieval / Paths filtering (dfg.py)}: discovers the frequency/performance directly-follows graph on the dataframe. This enables paths filtering on the dataframe. \item \emph{EFG retrieval / Temporal Profile (efg.py)}: discovers the eventually-follows graphs or the temporal profile from the dataframe. \item \emph{Sampling (sampling.py)}: samples the dataframe based on the specified amount of cases/events. \item \emph{Cases dataframe (cases\_df.py)}: retrieves the cases dataframe. This permits the filtering on the number of events and on the throughput time. \item \emph{Variants (variants.py)}: enables the retrieval of variants from the dataframe. This permits variant filtering. \item \emph{Timestamp (timestamp.py)}: retrieves the timestamp values from a column of the dataframe. This permits three different types of timestamp filtering (events, cases contained, cases intersecting). \item \emph{Endpoints (start\_end\_activities.py)}: retrieves the start/end activities from the dataframe. This permits filtering on the start and end activities. \item \emph{Attributes (attributes.py)}: retrieves the values of a string/numeric attribute. This permits filtering on the values of a string/numeric attribute. \item \emph{Feature selection (feature\_selection.py)}: basilar feature extraction, keeping for every provided numerical attribute the last value per case, and for each provided string attribute its one-hot-encoding. \end{itemize} An example of usage of the PM4Py-GPU library, in which a Parquet log is ingested, and the directly-follows graph is computed, is reported in the following listing. \begin{table*}[!t] \caption{Event logs used in the assessment, along with their number of events, cases, variants and activities.} \centering \resizebox{0.83\textwidth}{!} \begin{tabular}{|l|l|l|l|l|} \hline {\bf Log} & {\bf Events} & {\bf Cases} & {\bf Variants} & {\bf Activities} \\ \hline roadtraffic\_2 & 1,122,940 & 300,740 & 231 & 11 \\ roadtraffic\_5 & 2,807,350 & 751,850 & 231 & 11 \\ roadtraffic\_10 & 5,614,700 & 1,503,700 & 231 & 11 \\ roadtraffic\_20 & 11,229,400 & 3,007,400 & 231 & 11 \\ \hline bpic2019\_2 & 3,191,846 & 503,468 & 11,973 & 42 \\ bpic2019\_5 & 7,979,617 & 1,258,670 & 11,973 & 42 \\ bpic2019\_10 & 15,959,230 & 2,517,340 & 11,973 & 42 \\ \hline bpic2018\_2 & 5,028,532 & 87,618 & 28,457 & 41 \\ bpic2018\_5 & 12,571,330 & 219,045 & 28,457 & 41 \\ bpic2018\_10 & 25,142,660 & 438,090 & 28,457 & 51 \\ \hline \end{tabular} } \label{tab:eventLogData} \end{table*} \begin{lstlisting}[label=lst:example] import cudf from pm4pygpu import format, dfg df = cudf.read_parquet('receipt.parquet') df = format.apply(df) frequency_dfg = dfg.get_frequency_dfg(df) \end{lstlisting} \captionof{lstlisting}{Example code of PM4Py-GPU.} \section{Assessment} \label{sec:assessment} In this section, we want to compare PM4Py-GPU against other libraries/solutions for process mining to evaluate mainstream operations' execution time against significant amounts of data. The compared solutions include PM4Py-GPU (described in this paper), PM4Py (CPU single-thread library for process mining in Python; \url{https://pm4py.fit.fraunhofer.de/}), the PM4Py Distributed Engine (described in the assessment). All the solutions have been run on the same machine (Threadripper 1920X, 128 GB of DDR4 RAM, NVIDIA RTX 2080). The event logs of the assessment include the Road Traffic Fine Management \url{https://data.4tu.nl/articles/dataset/Road_Traffic_Fine_Management_Process/12683249}, the BPI Challenge 2019 \url{https://data.4tu.nl/articles/dataset/BPI_Challenge_2019/12715853} and the BPI Challenge 2018 \url{https://data.4tu.nl/articles/dataset/BPI_Challenge_2018/12688355} event logs. The cases of every one of these logs have been replicated $2$, $5$, and $10$ times for the assessment (the variants and activities are unchanged). Moreover, the smallest of these logs (Road Traffic Fine Management log) has also been replicated $20$ times. The information about the considered event logs is reported in Table \ref{tab:eventLogData}. In particular, the suffix (\_2, \_5, \_10) indicates the number of replications of the cases of the log. The results of the different experiments is reported in Table \ref{tab:expExecutionTime}. The first experiment is on the importing time (PM4Py vs. PM4Py-GPU; the other two software cannot be directly compared because of more aggressive pre-processing). We can see that PM4Py-GPU is slower than PM4Py in this setting (data in the GPU is stored in a way that facilitates parallelism). The second experiment is on the computation of the directly-follows graph in the four different platforms. Here, PM4Py-GPU is incredibly responsive The third experiment is on the computation of the variants in the different platforms. Here, PM4Py-GPU and the PM4Py Distributed Engine perform both well (PM4Py-GPU is faster to retrieve the variants in logs with a smaller amount of variants). \begin{table}[ht] \caption{Comparison between the execution times of different tasks. The configurations analyzed are: P4 (single-core PM4Py), P4G (PM4Py-GPU), P4D (PM4Py Distributed Engine). The tasks analyzed are: importing the event log from a Parquet file, the computation of the DFG and the computation of the variants. For the PM4Py-GPU (computing the DFG and variants), the speedup in comparison to PM4Py is also reported.} \resizebox{\textwidth}{!} \begin{tabular}{|l|cc|ccc|ccc|} \hline ~ & \multicolumn{2}{|>{}c|}{Importing} & \multicolumn{3}{|>{}c|}{DFG} & \multicolumn{3}{|>{}c|}{Variants} \\ {\bf Log} & {\bf P4} & {\bf P4G} & {\bf P4} & {\bf P4G} & {\bf P4D} & {\bf P4} & {\bf P4G} & {\bf P4D} \\ \hline roadtraffic\_2 & {\bf 0.166s} & 1.488s & 0.335s & {\bf 0.094s} (3.6x) & 0.252s & 1.506s & {\bf 0.029s} (51.9x) & 0.385s \\ roadtraffic\_5 & {\bf 0.375s} & 1.691s & 0.842s & {\bf 0.098s} (8.6x) & 0.329s & 3.463s & {\bf 0.040s} (86.6x) & 0.903s \\ roadtraffic\_10 & {\bf 0.788s} & 1.962s & 1.564s & {\bf 0.105s} (14.9x) & 0.583s & 7.908s & {\bf 0.055s} (144x) & 1.819s \\ roadtraffic\_20 & {\bf 1.478s} & 2.495s & 3.200s & {\bf 0.113s} (28.3x) & 1.048s & 17.896s & {\bf 0.092s} (195x) & 3.380s \\ \hline bpic2019\_2 & {\bf 0.375s} & 1.759s & 0.980s & {\bf 0.115s} (8.5x) & 0.330s & 3.444s & 0.958s (3.6x) & {\bf 0.794s} \\ bpic2019\_5 & {\bf 0.976s} & 2.312s & 2.423s & {\bf 0.156s} (15.5x) & 0.613s & 8.821s & {\bf 0.998s} (8.9x) & 1.407s \\ bpic2019\_10 & {\bf 1.761s} & 3.156s & 4.570s & {\bf 0.213s} (21.5x) & 1.679s & 19.958s & {\bf 1.071s} (18.6x) & 4.314s \\ \hline bpic2018\_2 & {\bf 0.353s} & 1.846s & 1.562s & {\bf 0.162s} (9.6x) & 0.420s & 6.066s & 5.136s (1.2x) & {\bf 0.488s} \\ bpic2018\_5 & {\bf 0.848s} & 2.463s & 3.681s & {\bf 0.214s} (17.2x) & 0.874s & 14.286s & 5.167s (2.8x) & {\bf 0.973s} \\ bpic2018\_10 & {\bf 1.737s} & 3.470s & 7.536s & {\bf 0.306s} (24.6x) & 1.363s & 29.728s & 5.199s (5.7x) & {\bf 1.457s} \\ \hline \end{tabular} } \label{tab:expExecutionTime} \end{table} \section{Related Work} \label{sec:relatedWork} {\bf Process Mining on Big Data Architectures}: an integration between process mining techniques and Apache Hadoop has been proposed in \cite{DBLP:conf/bpm/HernandezZEA15}. Apache Hadoop does not work in-memory and requires the serialization of every step. Therefore, technologies such as Apache Spark could be used for in-memory process mining\footnote{\url{https://www.pads.rwth-aachen.de/go/id/ezupn/lidx/1}}. The drawback of Spark is the additional overhead due to the log distribution step, which limits the performance benefits of the platform. Other platform such as Apache Kafka have been used for processing of streams \cite{DBLP:journals/sncs/NogueiraR21}. Application-tailored engines have also been proposed. The ``PM4Py Distributed engine'' \footnote{\url{https://www.pads.rwth-aachen.de/go/id/khbht}} has been proposed as a multi-core and multi-node engine tailored for general-purpose process mining with resource awareness. However, in contrast to other distributed engines, it misses any failure-recovery option and therefore is not good for very long lasting computations. The Process Query Language (PQL) is integrated in the Celonis commercial process mining software \url{https://www.celonis.com/} and provides high throughput for mainstream process mining computations in the cloud. \\ {\bf Data/Process Mining on GPU}: many popular data science algorithms have been implemented on top of a GPU \cite{DBLP:journals/widm/Cano18}. In particular, the training of machine learning models, which involve tensor operations, can have huge speed-ups using the GPU rather than the CPU. In \cite{DBLP:conf/caise/TaxVRD17} (LSTM neural networks) and \cite{DBLP:conf/icpm/Pasquadibisceglie19} (convolutional neural networks), deep learning approaches are used for predictive purposes. Some of the process mining algorithms have been implemented on top of a GPU. In \cite{DBLP:conf/bpm/KundraJS15}, the popular alpha miner algorithm is implemented on top of GPU and compared against the CPU counterpart, showing significant gains. In \cite{DBLP:conf/bpm/FerreiraS16}, the discovery of the paths in the log is performed on top of a GPU with a big speedup in the experimental setting. \section{Conclusion} \label{sec:conclusion} In this paper, we presented PM4Py-GPU, a high-performance library for process mining in Python, which is based on the NVIDIA RAPIDS framework for GPU computations. The experimental results against distributed open-source software (PM4Py Distributed Engine) are very good, and the library seems suited for process mining on a significant amount of data. However, an expensive GPU is needed to make the library work, which could be a drawback for widespread usage. We should also say that the number of process mining functionalities supported by the GPU-based library is limited, hence comparisons against open-source/commercial software supporting a more comprehensive number of features might be unfair. \section*{Acknowledgements} We thank the Alexander von Humboldt (AvH) Stiftung for supporting our research. \bibliographystyle{splncs04}
{'timestamp': '2022-04-12T02:33:41', 'yymm': '2204', 'arxiv_id': '2204.04898', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04898'}
arxiv
\section{Introduction} \setitemize[0]{leftmargin=5mm} \setenumerate[0]{leftmargin=*} \noindent Over the last decade, Twitter has emerged not only as one of the most influential micro-blogging platforms, but also one of the most actively engaging (if sometimes polarizing) fronts for social, political, and even health discourse. Early work \cite{pak2010twitter,dodds2011temporal} identified tweets as a crucial indicator of public sentiment. Since then, various samples of tweet data have been used to analyze a wide variety of phenomena, including the recent COVID-19 pandemic. However, past work largely uses topic-based keywords to obtain datasets of interest (often at the expense of geo-location information); for example, work that analyzes emotions in tweets that mention COVID-19-associated terms \cite{DBLP:journals/corr/abs-2004-03688,info:doi/10.2196/19447}. Further, very little work explores changes in patterns of emotions of individuals over time. This paper introduces a new framework to analyze patterns of emotions associated with tweets over time, which we refer to as \textit{Tweet Emotion Dynamics (TED)}. TED builds on ideas first introduced in \newcite{hipson2021emotion}, and applies metrics such as \textit{home base, variability,} and \textit{rise rate} to tweets. We also introduce a new dataset of geo-located English \textit{\underline{T}weets from \underline{US} and \underline{C}anada} \textit{(TUSC)}. TUSC is not restricted to specific topics and so can be used to study tweets in general, as well as to study notable phenomena (such as a pandemic, climate change, or polarizing political events) on tweets at large (as opposed to examining tweets directly discussing those phenomena). TUSC also includes a subset, (\textit{TUSC100}), made up of tweets from 170K tweeters who each posted at least a 100 tweets between 2020 and 2021. TUSC100 is especially well suited for longitudinal analysis. The creation of the datasets included careful post-processing to make the resource particularly suitable for textual analysis. TUSC and TED can each be used, together or independently, to explore a wide range of research questions pertaining to tweets and emotions that may be of interest to researchers in Psychology, Affective Science, Social Science, Behavioural Science, Public Health, NLP, and Linguistics. In this paper, we use them to explore questions about how people use emotion-associated words in English tweets from US and Canada.\footnote{Words have associations with emotions; e.g., {\it success} with pleasure, {\it illness} with displeasure, etc.} We record the common characteristics of emotion word usage from 2015 to 2021, with a special focus on 2020 --- the year that the WHO declared the Novel Coronavirus Disease (COVID-19) outbreak to be a pandemic --- and its adjoining years (2019 and 2021). Finally, we benchmark individual tweeter behaviour in terms of various TED metrics. Recording this information holds considerable promise in future work; for example, for studying the emotional impact of the pandemic, for helping clinicians and patients track emotional well-being before and after health interventions, studying emotion regulation and coping strategies, etc. The data (tweet IDs), Emotion Dynamics code, and visualizations are freely available through the project homepage.\footnote{\href{https://github.com/Priya22/EmotionDynamics}{https://github.com/Priya22/EmotionDynamics}} \section{Related Work} \noindent We group related work into two kinds: 1. psychological and psychology-inspired research on the theory of emotions and utterance emotion dynamics; and 2. NLP research in analyzing emotions in tweets. \subsection{Emotions} \noindent Several influential studies have shown that the three most fundamental, largely independent, dimensions of affect and connotative meaning are valence (V) (positiveness--negativeness / pleasure--displeasure), arousal (A) (active--sluggish), and dominance (D) (dominant-–submissive / in control--out of control) \cite{Osgood57,russell1977evidence,russell2003core}. Valence and arousal specifically are commonly studied in a number of psychological and neuro-cognitive explorations of emotion. The NRC VAD Lexicon \cite{vad-acl2018} contains about twenty thousand commonly used English words (lemmas and common morphological variants) that have been scored on valence (0 = maximally unpleasant, 1 = maximally pleasant), arousal (0 = maximally calm/sluggish, 1 = maximally active/intense), and dominance (0 = maximally weak, 1 = maximally powerful).\footnote{http://saifmohammad.com/WebPages/nrc-vad.html} As an example, the word \textit{nice} has a valence of .93, an arousal of .44, and dominance of .65, whereas the word despair has a valence of .11, an arousal of .79, and dominance of .25. \newcite{hipson2021emotion} introduced Utterance Emotion Dynamics (UED), a framework to quantify patterns of change of emotional states associated with utterances along a longitudinal (temporal) axis. Specifically, they proposed a series of metrics, including:\\[-16pt] \begin{enumerate} \item \textit{Density or Mean}: A measure of the average utterance emotional state. For example, the proportion of emotion words a person utters over a given span of time. If each word has a real-valued emotion score (say, for V, A, and D), then this is calculated as the mean of emotion scores of the words in the utterance window. This roughly captures the utterance emotional state.\\[-18pt] \item \textit{Variability}: The extent to which a speaker's utterance emotional state changes over time (measured as the standard deviation of the emotion states). \\[-18pt] \item \textit{Home Base:} A speaker's home base is the subspace of high-probability emotional states where they are most likely to be found. This is formulated as the range of values within one standard deviation of the average of the emotion states at each timestep.\\[-18pt] \item \textit{Rise and Recovery Rates:} Sometimes a speaker moves out of their home state, reaches a peak value of emotion state, before returning to the home state. The rise rate quantifies the rate at which a speaker moves towards the peak; recovery rate is the rate at which they go from the peak to the home state.\\[-16pt] \end{enumerate} One can determine UED metrics using: 1.\@ the utterances by a speaker, 2.\@ the temporal information about the utterances, for e.g., time stamps associated with the utterances, or simply an ordering of utterances by time, and 3.\@ features of emotional state drawn from text. The emotional state at a particular instant can be determined using simple lexical features (say, drawn from emotion lexicons), predictions of supervised machine learning systems, etc. \newcite{hipson2021emotion} apply this framework to utterances from a corpus of movie dialogues, which are naturally ordered along a temporal axis. They represented emotional state in a two-dimensional valence--arousal space. The co-ordinates are determined by the average valence and arousal scores of the words (using the NRC VAD lexicon) in a small window of recent utterances (usually spanning 20 to 50 words). Rolling windows of words (moving forward one-word at a time) determine the sequence of emotional states. Here, we apply that framework to tweets. However, in this work we consider each of the valence, arousal, and dominance dimensions separately (separate one-dimensional axes). \subsection{Analyzing Emotions in Tweets} \noindent \newcite{dodds2011temporal} analyzes large amounts of Twitter data to explore temporal patterns of `societal happiness'. \newcite{larsen2015we} show a correlation between patterns of emotional expression in tweets with WHO data on anxiety and suicide rates, across geographical location. \newcite{snefjella2018national} analyze differences in language use in 40 million tweets from Canada and the USA, and find that the former tend to use more positive language, which correlates with national character stereotypes of Canadians being more agreeable and less aggressive. Twitter data has been used to study people's emotions during significant events, commonly revolving around certain tragedies and natural disasters, and significant political events. \newcite{doi:10.1177/0956797614562218} studied the changes in intensity of emotions of anxiety, anger, and sadness expressed on Twitter regarding the Sandy Hook Elementary School shooting. The 2016 US Presidential Election spurred several studies on the language used across geographical and political lines \cite{DVN/PDI7IN_2016}. Twitter was also used to measure the impacts of the COVID-19 pandemic on the emotional states and mental health of tweeters \cite{DBLP:journals/corr/abs-2004-03688}. \newcite{info:doi/10.2196/19447}, for example, looked at changes in the usage of tweets that expressed fear, anger, sadness, and joy in COVID-associated tweets from January 28 to April 9 2020. In our work, we focus on the emotion dimensions of valence, arousal, and dominance, rather than categorical dimensions such as anger, fear, sadness, etc. We also study these patterns of emotion usage across a large time period (2015--2021), and in geo-located tweets. \begin{table*}[t!] {\small \centering \begin{tabular}{lrrr r rrr} \hline \textbf{Dataset} & \multicolumn{3}{c}{\textbf{Canada}} & & \multicolumn{3}{c}{\textbf{USA}} \\ & \#tweets & \# tweeters &Av.TpT & & \#tweets & \# tweeters & Av.TpT \\ \hline {TUSC-Country} & &\\ \rowcolor{gray!8} $\;\;\;$ 2015 & 89,566 & 40,290 & 15.729 && 131,330 & 104,670 & 13.805\\ $\;\;\;$ 2016 & 93,280 & 40,994 & 16.164 && 133,413 & 109,110 & 14.305\\ \rowcolor{gray!8} $\;\;\;$ 2017 & 94,364 & 39,258 & 18.067 && 133,854 & 107,080 & 16.015\\ $\;\;\;$ 2018 & 95,403 & 38,866 & 21.763 && 133,066 & 105,227 & 19.394 \\ \rowcolor{gray!8} $\;\;\;$ 2019 & 330,361 & 70,122 & 22.040 && 339,186 & 204,311 & 19.341\\ \rowcolor{yellow!8} $\;\;\;$ 2015--2019 & 702,974 & 159,284 & 18.753 && 870,849 & 516,885 & 16.572\\ \vspace*{-3mm} &\\ $\;\;\;$ 2020 & 321,176 & 57,465 & 22.123 && 503,976 & 250,080 & 19.698\\ \rowcolor{gray!8} $\;\;\;$ 2021 & 304,106 & 49,128 & 22.192 && 478,798 & 214,653 & 19.566\\ \rowcolor{yellow!8} $\;\;\;$ 2015--2021 & 1,328,256 & 206,691 & 19.73 && 1,853,623 & 802,369 & 17.45 \\ \vspace*{-3mm} &\\ {TUSC-City} & & \\ $\;\;\;$ 2020 (Apr--Dec) & 15,039,503 & 716,063 & 19.275 && 23,470,855 & 2,669,081 & 17.556\\ \rowcolor{gray!8} $\;\;\;$ 2021 & 22,371,990 & 798,602 & 19.367 && 43,693,643 & 3,247,124 & 17.306\\ \rowcolor{yellow!8} $\;\;\;$ 2020--2021 & 37,411,493 & 1,049,774 & 19.327 && 67,164,498 & 4,274,374 & 17.413\\ \hline \end{tabular} \caption{\#tweets, \#tweeters, and Average number of token per tweet (Av.TpT) in the TUSC Datasets.} \label{tab:tusc-stats} } \end{table*} \section{Tweets Dataset: TUSC} \subsection{Sampling Tweets} \label{sec:collection} \noindent Twitter's regular API allows one to obtain a random sample of tweets from the past week. However, the search is limited to only the tweets from the past week. The Academic search API provides access to historical tweets, but with a lower rate limit. To benefit from both APIs and to confirm that our results are consistent regardless of the API and search method, we compiled two separate tweet datasets using each of the APIs:\\[3pt] \noindent 1. using Twitter's free API and its geo-location and random-sample switches to collect tweets from 46 prominent American and Canadian cities. Data collection began in April 1, 2020 and is ongoing. We refer to the dataset created with this method as \textit{TUSC-City}.\\[3pt] \noindent 2. using Twitter's Academic API to collect tweets emanating from US and Canada from Jan 2015 to Dec 2021. The Academic API provides switches to specify the country of origin and the time span of search. However, the sample of results it provides tend to be in reverse chronological order for the specified time span. Thus, to obtain a sample of tweets from various time spans across the various years of interest, we employed the following strategy: For each year of interest, we randomly generated a date time (using unix epoch seconds). We then specified a search interval of 8 hours starting from that date time. We repeated this procedure thousands of times for each year. Since we were especially interested in the years of 2019, 2020, and 2021, we collected more data from these years. We refer to the resulting dataset as \textit{TUSC-Country}. \subsection{Tweet Curation} \noindent We curated the tweet collection to make it more suitable for computational natural language analyses by applying the following steps:\\[-16pt] \begin{itemize} \item Kept one tweet per user, per day. This mitigates the impact of highly prolific tweeters and commercial accounts on the dataset.\\[-16pt] \item Kept only English language tweets (since the English set is the focus of this project). These are identified by the \texttt{iso\_language} tag provided by Twitter for each tweet.\\[-16pt] \item Removed all retweets.\\[-16pt] \item Removed all tweets containing a URL and/or links to media (to focus on textual tweets). This also limits tweets by commercial organizations.\\[-16pt] \item Discarded all tweets with less than three tokens. This eliminates certain formulaic tweets such as wishes for holidays. The tweet text is tokenized using the Python implementation\footnote{https://github.com/myleott/ark-twokenize-py} of the Twokenizer package \cite{gimpel2010part,owoputi2013improved}.\\[-16pt] \end{itemize} \noindent We kept quotes and replies as they include new textual information. \subsection{Key Data Statistics and Distribution} \noindent We organize the TUSC tweets as per the sampling strategy used to obtain them (see TUSC-Country and TUSC-City in \S \ref{sec:collection}) as well as the year of posting (2015 through 2021), and country of origin (US, Canada). Table \ref{tab:tusc-stats} shows the number of tweets, number of tweeters, and average number of tokens per tweet in each of these dataset groupings. (Table \ref{tab:stats-det} in the Appendix shows a breakdown by city for TUSC-City.) It is interesting that an average Canadian tweet has about two more tokens per tweet than a US tweet (one possible explanation is the tendency of American tweeters to use more informal and non-standard language, as found in \newcite{snefjella2018national}). TUSC-City is the larger dataset, and contains millions of tweets for many of the 46 cities for 9 months in 2020 (Apr--Dec), and all the months of 2021. This is particularly useful for analyzing trends at the city--level, and also at the user-level, since we are more likely to have a large number of tweets from the same user. \section{Emotion Word Usage in American and Canadian Tweets} \noindent The TUSC datasets can be used to answer several important questions about emotion word usage in English tweets from US and Canada, including: \begin{itemize} \item Are there notable trends across years in the valence, arousal, and dominance of tweets? Are we tweeting with more positive words, more negative words, more high arousal words, etc. than in past years? \item How has the COVID-19 pandemic impacted the emotionality of our tweets? At what point of time in the pandemic did we use the most amount of words conveying a lack of control and uncertainty? At what point of time in the pandemic did we use the most negative words? How were individual cities impacted? In relative terms, tweets from which cities were the most positive during the pandemic, and which were most negative? Which cities recovered best to positivity in 2021, as compared to 2020? \item How are Canada and US different in terms of emotion word usage? Did the pandemic impact the emotionality differently in the two countries? \end{itemize} \noindent We will explore these, and other, questions below. We used the NRC Valence, Arousal, and Dominance (NRC VAD) Lexicon \cite{vad-acl2018} to determine the emotion associations of the words in tweets.\footnote{http://saifmohammad.com/WebPages/nrc-vad.html} Specifically, we used the subset of the lexicon with entries for only the polar terms: i.e., only those valence entries were included that had scores $\leq$0.33 (negative words) or scores $\geq$0.67 (positive words).\footnote{There is no ``correct'' threshold to determine these classes; different thresholds simply make the positive and negative classes more or less restrictive.} Similarly, only those arousal and dominance entries were included that had scores $\leq$0.33 or $\geq$0.67. The entries with scores between 0.33 and 0.67 are considered neutral for that dimension. \noindent \textbf{Methodological Note:} Similar analyses can also be performed using categorical emotions, such as joy, sadness, fear, anger, etc., using the NRC Emotion Lexicon \cite{MohammadT10,Mohammad13}.\footnote{\url{http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm}} See discussions on categorical and dimensional emotions in \cite{mohammad2020survey}. \subsection{Average V, A, and D Across US--Canada} \begin{figure}[t!] \begin{center} \includegraphics[width=0.8\columnwidth]{figs/Fig1.png} \caption{Average Valence, Arousal, and Dominance of words per tweet for each dataset (year).} \label{fig:avg-vad} \end{center} \end{figure} \noindent For each tweet, we take the average of the valence, arousal, and dominance values of each of the words in the tweet text. The averages are computed for TUSC-City over all tweets from each city, and for TUSC-Country at the country-level. We test whether the differences in values between countries and years are statistically significant by using the paired t-Test, with the significance threshold for the $p$-value set to 0.001.\\[4pt] \noindent \textbf{Yearly Trends:} Figure \ref{fig:avg-vad} shows the average V, A, and D scores of tweets when aggregated at the country and year level, for the various data subsets. The gradient bars at the top show the colors used to indicate where the values lie in the spectrum from lowest to highest.\\[3pt] \noindent \textit{Valence:} Observe that the average valence of Canadian tweets is consistently higher (more positive) than the tweets from the US (statistically significant); the difference are steady across years. There is a slight downward trend for valence in both countries from 2015 to 2019 (more so for US; Canada mean rises back up a bit after 2017). We see the lowest values of mean valence occur in 2020 for both TUSC-Country and TUSC-City (the year the pandemic hit) for both the US and Canada. Average valence rises back up in 2021.\\\\[3pt] \noindent \textit{Arousal:} Overall, tweets from Canada have lower average arousal (more calm, less active) than the US (statistically significant). Again, the difference in mean between the two countries remains relatively steady across years. Across years, arousal values for both countries increase from 2015 till 2017; they then drop steadily for Canada, while the USA sees a peak in 2019 followed by slight drops in subsequent years. \begin{figure}[t] \includegraphics[width=\columnwidth]{figs/Table3.png} \caption{Monthly trends in valence {\small (TUSC-Country)}.} \label{fig:v-month} \vspace*{-3mm} \end{figure} \noindent \textit{Dominance:} Canada on the whole consistently has higher dominance values (greater feeling of control) than the US across the Both countries have the lowest dominance values in 2015, and the highest in 2021 (Canada peaks at the same value in 2018--2019 as well). For all three dimensions, we note that the yearly trends observed in TUSC-Country are largely also observed in the TUSC-City trends, across 2020--2021.\\[6pt] \noindent {\bf Monthly Trends:} Figure \ref{fig:v-month} shows a breakdown of the average valence scores at the month level, across years. (Figures \ref{fig:a-month} and \ref{fig:d-month} in the Appendix show the breakdown for arousal and dominance.) We immediately notice from the color shading that Canada consistently has higher valence (green), lower arousal (blue), and higher dominance (purple) than the US, across the months and years. June 2020 is particularly notable as it has the lowest values of valence for both USA and Canada; we hypothesize that this is an effect of both the COVID-19 pandemic (the seriousness of which was starting to become evident a couple of months earlier in March 2020) and the \textit{black lives matter} protests (which peaked after the Dylan Roof shooting incident). By contrast, the final months of 2021 have the highest positivity. This could be attributed to feelings of a potential return to normalcy, as well as a general uptick in mood due to the holiday season (this was just before the Omicron variant took root in early 2022). The dominance numbers indicate that April and May of 2020 for Canada (March, April, and May 2020 for the US) are marked by some of the lowest scores, suggestive of a feeling of loss of control due to the onset of the global COVID-19 pandemic. \subsection{Tweets with Emotional Terms} \noindent The experiments above showed notable differences in the average V/A/D scores of tweets across US and Canada. However, they also lead to further questions such as whether the higher valence in Canadian tweets is because of a greater usage of positive words or a lower usage of negative words. To explore such questions, we determine how frequently people post tweets with at least one high valence word, how frequently people post tweets with at least one low valence word, how frequently people post tweets with at least one high arousal word, and so on. High and low categorization of a word is based on whether their score (for V/A/D) is $\geq$0.67 or $\leq$0.33, respectively. \begin{figure}[t] \begin{center} \includegraphics[width=0.9\columnwidth]{figs/Fig3.png} \caption{Percentage of tweets with at least one --- low valence word, high valence word, low arousal word, high arousal word, low dominance word, high dominance word --- across datasets (years).} \label{fig:vad-perc} \end{center} \vspace*{-6mm} \end{figure} \noindent Figure \ref{fig:vad-perc} shows the results. The darker shades of the color indicate a greater percentage of tweets had at least one of the relevant emotional words.\\[3pt] Observe that in both American and Canadian tweets:\\[-16pt] \begin{itemize} \item people post markedly more tweets with at least one positive word than tweets with at least one negative word (about 100\% more).\\[-16pt] \item people post markedly more tweets with at least one low arousal word than tweets with at least one high-arousal word (about 40\% more).\\[-16pt] \item people post markedly more tweets with at least one high dominance word than tweets with at least one low-dominance word (about 33\% more). \end{itemize} In terms of their differences, we see that the tweets from Canada are marked by both a higher usage of high-valence words, as well as a lower usage of low-valence words, than the US (statistically significant). Tweets from Canada have a higher proportion of low arousal words, whereas high arousal word usage is similar in both countries. Canadian tweeters use about the same number of low dominance words as those in the US, but use a greater number of high dominance words. Across years, low valence words increase in usage relatively steadily until 2020, and drop in 2021. For all dimensions, the sharpest rise in usage occurs from 2016 to 2017. When comparing TUSC-Country 2020 with 2021, observe that the higher number of low valence words used is more prominent than the lower number of high valence words --- thus, the drop in average valence in 2020 (Figure 1) is because people \textit{tweeted more negative words} (and not because people \textit{tweeted less positive words}). See \newcite{VM2022-TED} for an analysis of the topics driving the differences across V, A, and D: across the years, and across US and Canada. \section{Tweet Emotion Dynamics} \noindent While the previous section looked at samples of tweets emanating from countries and cities as a whole, in this section we explore individual tweeter behaviours and \textit{metrics} of emotion word usage over time. Specifically, we apply the framework of Utterance Emotion Dynamics (UED) \cite{hipson2021emotion} to tweets to explore a number of questions, such as:\\[-16pt] \begin{itemize} \item What is the usual range and distribution of various metrics of tweet emotion dynamics (TED), such as mean and recovery rate, for American and Canadian tweeters? Establishing benchmarks for these metrics is crucial for subsequent studies that may explore, for example, the impact of a health intervention on one's TED metrics.\\[-16pt] \item Are there notable differences in the distributions of TED metrics across American and Canadian tweeters?\\[-16pt] \item Are there notable differences in the distributions of TED metrics across 2020 and 2021?\\[-12pt] \end{itemize} Recall that computing UED metrics requires: 1.\@ a set of texts associated with each speaker, 2.\@ a temporal ordering of these texts, and 3.\@ a way to determine emotions associated with the texts. The timestamp of a tweet provides the temporal order. The tweets from each speaker are then concatenated together and tokenized to obtain a ordered list of tokens. Next, a rolling window of 20 tokens is considered to determine the average V, A, and D scores of the words in that window. These scores are a representation of utterance emotional state corresponding to that window. The rolling window is moved forward one word at a time to determine the subsequent averages.\footnote{Variations of this approach that do not use rolling windows across tweet boundaries produce similar results.} In the rest of this section, we use the term \textit{mean} to refer to the mean of all the rolling window averages for a speaker. We re-implemented the \newcite{hipson2021emotion} R code in Python. Also, rather than using the valence--arousal two-dimensional (ellipse-based) representation of emotions explored in their work, we analyse the dynamics of each emotion dimension separately along one-dimensional axes. This eases the interpretation of the UED metrics, and allows for considering more dimensions such as dominance. We also break down the rise and recovery rates into separate rates corresponding to when one is moving from the home base to higher emotion values (Hm--Hi), from the highest value to home (Hi--Hm), from the home base to lower emotion values (Hm--Lo), and from the lowest value to home (Lo--Hm). This allows us to explore whether, for example, some tweeters have close-to-median Hi--Hm rates, but markedly low Lo--Hm rates (indicating that once they start uttering negative words, then they tend to dwell in the negatives and only gradually return to their home state). \begin{figure}[t] \includegraphics[width=\columnwidth]{figs/Distributions-VAD-Mean-Rates.png} \caption{Distributions of Means, Rise Rates, and Recovery Rates for Valence, Arousal, and Dominance (TUSC100).} \label{fig:ted-hist} \vspace*{-3mm} \end{figure} \begin{figure*}[t] \begin{center} \includegraphics[width=1.6\columnwidth]{figs/freq-tweeters-TED.png} \caption{Box plots of means, rise rates, and recovery rates of Valence, Arousal, and Dominance of tweeters in 2020 and 2021 (TUSC100-2020 and TUSC100-2021).} \label{fig:ted-box} \end{center} \vspace*{-3mm} \end{figure*} We use the code to determine TED metrics for the tweeters in in the TUSC-Country dataset. Only tweeters with at least 100 tweets in a year were considered, since drawing inferences about one's tweeting behavior requires a sufficient sample size. There were about 40K such tweeters in the 2020 subset and about 130K such tweeters in the 2021 subset. We refer to their tweets (5.6M from 2020 and 19M from 2021) as the \textit{TUSC100-2020} and \textit{TUSC100-2021} datasets, respectively. Average number of tweets by a tweeter in these datasets is 153 (no tweeters had more than 365 tweets due to our earlier stated `one tweet per user per day' pre-processing policy). See Table \ref{tab:t100-stats} in the Appendix for detailed statistics. Figure \ref{fig:ted-hist} plots the distributions of some of the metrics for the joint set of 2020 and 2021 tweeters. The plots in (a) are distributions of the mean values for the three emotion dimensions (V, A, D). The x-axis is made up of bins of size 0.005 (from 0--0.005 to 0.995--1). The y-axis indicates the number of tweeters with mean values in each of the bins. Observe that the means for V, A, and D all follow a near-normal distribution. Mean valence and dominance values are more spread out compared to arousal values. For V, most fall between 0.5--0.8 , with a median value of around 0.65, though we can see that there is a long tail of outliers. Dominance scores are spread around a median score of 0.6, and the median is even lower for arousal (0.49). Figure \ref{fig:ted-hist}(b) shows distributions for rises rates and recovery rates. Observe that these have a much narrower spread, and the distributions for all three dimensions are roughly the same. Figure \ref{fig:ted-box} shows box and whisker plots of the same three metrics: mean, rise rate, and recovery rates. However, separate plots are shown for tweeters from US and Canada, and across 2020 and 2021. The shaded region (the box) indicates the ``middle portion" of the data distribution, i.e, the range covered between the first quartile (the 25\% mark) and the third quartile (the 75\% mark), with the median (50\% mark) lying at the border of the light and dark shaded regions. The whiskers, the lines on either end of the plot, are at a distance of 1.5 times the inter-quartile length (inter-quartile length is the distance between the first and third quartiles). Points beyond the whiskers are considered outliers. Additionally, the average value (mean) is indicated with the pink horizontal dashed line. Observe that the mean valence is lower in 2020 than in 2021, and Canadian tweeters on average use more positive words than their US counterparts.\footnote{These trends align with the trends observed in Table 2.} The distributions for mean arousal are quite similar across 2020 and 2021, but US tweeters have slightly higher mean arousal values. Canadian tweeters have a slightly higher median of dominance scores than US tweeters; whereas the US tweeters tend to have a wider range of dominance values. The difference in the distributions of the mean values for Canada and US is statistically significant for all three dimensions ($p$-values $< 0.001$). The median rise rates and recovery rates do not differ markedly across countries or years. However, there is a notably large range of the third quartile (the quartile above the median) for Canadian tweeters in 2021. These are tweeters who are quicker to jump in and out of their home base. Tables \ref{tab:ted-val}, \ref{tab:ted-ar}, \ref{tab:ted-dom} of the Appendix report mean scores for all of the TED metrics, averaged across all tweeters by country and year. This includes a breakdown of the rates into Hm-Hi, Hi-Hm, Hm-Lo, and Lo-Hm. Notable trends there are that the average rise and recovery rates on the high side of the home state (Hm-Hi, Hi-Hm) are lower than for the low side of the home state (Lo-Hm, Hm-Lo), for the valence and dominance dimensions. This says that tweeters are slower to rise to more positive and more dominant states, but quicker to both descend to more negative and less dominant states, and recover from them; similarly, they are slower to transit to and from states of high activity (high dominance). This difference between Hi and Lo rates is reversed for arousal. Thus, we are quicker to rise to states of high arousal, and come back down from them to the home state. We also noticed in our analyses that there exist several tweeters that have very high rise rates but normative recovery rates, and also tweeters that have very high rise rates but normative recovery rates. Identifying such characteristics and tracking them in the context of health interventions is particularly promising future work. However, it should be noted that we strongly encourage such studies, when conducted, to be led by clinicians and psychologists, with appropriate consent and ethics approvals. \subsection{City as Speaker} \noindent An interesting variation of the experiments above, is to consider each city as a `speaker', rather than individual tweeters. Figure \ref{fig:city-speaker-mean}, in the Appendix, shows the average TED metrics for each of the 46 cities in TUSC-City. The color gradients make it easy to spot which cities have had markedly high V/A/D means across 2020 and 2021. Consistent with some of the earlier country-level results, we see that the Canadian cities tend to have higher valence, lower arousal, and higher dominance, than the US cities. London, Ottawa, Halifax, and Victoria have the highest valence (most positive). From the set of Canadian cities, Windsor stands out as an anomaly with valence close to many US cities. Detroit, Houston, Los Angeles, and Philadelphia have some of the lowest valence values of all cities. All cities improve from 2020 to 2021, some more drastically than others (Boston, Indianapolis, San Jose, for example). Quebec and Windsor have the highest arousal rates in Canada; in the US, El Paso is at the top for both years. Nashville, San Francisco, San Jose, and Seattle have lower arousal rates (more in line with the average Canadian city). Washington, San Jose, and Boston also show markedly high dominance, as well as San Francisco. Among Canadian cities, Ottawa and Victoria have the highest dominance scores for 2020 and 2021, and Windsor again the lowest. Figure \ref{fig:city-speaker-rest}, in the Appendix, shows values of the variabilities, rise rates, and recovery rates for the valence dimension. Looking at the column for variability, Windsor jumps out among the Canadian cities for having comparatively higher variability. Washington and Phoenix in 2020 have relatively high variability. Moving to the next columns, Windsor again has the highest rise and recovery rates among Canadian cities; US cities are the on the whole quicker to rise and fall. The various metrics listed for various cities should be useful to those interested in the tweets from particular cities. Future work will drill down further into the data for individual cities to determine the factors driving the emotion word usage. \section{Conclusion} \noindent We introduced the Tweet Emotion Dynamics framework to quantify changes in emotions associated with tweets over time. We also released the TUSC dataset --- a large collection of English geo-located tweets from Canada and the USA that were posted between 2015 and 2021. We studied emotion word usage in this data, using multiple metrics, for the primary dimensions of valence, arousal, and dominance. Our results showed interesting trends in the emotions expressed by tweeters from the two countries across different years, and also uncovered contrasts between Canadian and US tweeters. An expanded version of this paper presents further experiments, including a deeper analysis of the words and topics driving the emotional differences across tweets from US and Canada, and across the years (from 2015 to 2021) \cite{VM2022-TED}. Future work will look at expanding our dataset with tweets from countries around the world, and also in languages other than English. We will also explore how our proposed TED framework can be useful to studies by clinicians and psychologists on measuring mental health outcomes from social media data. Additionally, we will study the applications of Utterance Emotion Dynamics in other contexts such as novels, personal diaries, forum posts, and speech. \section*{Acknowledgements} We thank Will Hipson for early discussions on his R code for utterance emotion dynamics. The first author is supported by funding from the Natural Sciences and Engineering Research Council of Canada, and resources provided by the Vector Institute of Artificial Intelligence. \section{Bibliographical References} \label{main:ref} \bibliographystyle{lrec2022-bib}
{'timestamp': '2022-04-28T02:25:06', 'yymm': '2204', 'arxiv_id': '2204.04862', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04862'}
arxiv
\section{Introduction} In Task 8 \cite{taskpaper}, we are expected to assess the similarity of pairs of multilingual news articles. Ten different languages are covered in this task, including Spanish, Italian, German, English, Chinese, Arabic, Polish, French, Turkish and Russian. Task 8 emphasizes more the events themselves described in the news rather than the style of writing or other subjective characteristics. Therefore, it is beneficial to improve the quality of clustering of news articles and to explore similar news coverage across different outlets or regions. The foundation model \cite{foundationmodel} we choose is XLM-RoBERTa (XLM-R) \cite{xlmr} which has been proved to be a powerful multilingual pre-trained language model compared with other models like mBERT \cite{mbert} and it can process all the languages existing in Task 8. Based on that, a great variety of strategies have been tested along with our exploration like data augmentation (DA), head-tail combination, multi-label loss, adapted R-Drop, etc. Through this task, we realized the importance of data quality and efficient training schemes in a cross-lingual setting. By struggling to improve the richness of the data and find out what methods are effective when training such a similarity assessment model, our system\footnote{Our code will be available at \url{https://github.com/GeekDream-x/SemEval2022-Task8-TonyX}} ranked 1st in this competition. \section{Background} \subsection{Dataset Description} \label{taskdescription} There are 4,964 samples with 8 language pairs in the training set and the test set contains 4,593 samples in 18 different language pairs, the details of which are presented in Table \ref{dataset}. Due to some inaccessible URLs, the training set is slightly smaller than it should be (22 samples missing in total). The similarity scores of pairs of articles in provided dataset are rated on a 4-point scale (between 1 and 4) from most to least similar from 7 sub-dimensions, including \textit{Geography}, \textit{Entities}, \textit{Time}, \textit{Narrative}, \textit{Overall}, \textit{Style} and \textit{Tone} (an example is provided in Appendix). However, only the predictions for \textit{Overall} will be used to evaluate the performance of our systems. \subsection{Related Work} Research on text similarity always attracts people's eyes as it acts as the basis of quite a few NLP downstream tasks like information retrieval \cite{infomationretrieval}. Previously, some methods based on statistics like BM25 \cite{bm25} and Edit Distance \cite{editdistance} are used to evaluate the relevance between two texts but they do not work anymore in cross-lingual settings. Then, after dense word embedding in low dimensions like Word2Vec \cite{word2vec} was put forward, methods like calculating the cosine similarity \cite{semanticcosinesimilarity} with the sentence embedding based on each word embedding came into use. However, it is hard for these approaches to capture the latent meaning of the whole article precisely. Nowadays, depending on transformer-based general pre-trained models are becoming the new paradigm and plenty of models for multilingual and cross-lingual settings have been proposed like mBERT \cite{mbert}, ERNIE-M \cite{erniem} and XLM-R \cite{xlmr}. \section{System Overview} \label{systemoverview} Our baseline system is simply providing a pair of articles to XLM-R and regressing its output from [CLS] token to the manually annotated similarity score by training with Mean Squared Error (MSE). All the optimization methods discussed below are applied based on this architecture and the overall framework of our final system is illustrated in Figure \ref{fig:systemdiagram}. After training with all the positive strategies, we then made an ensemble of the best models on each fold for the final prediction. \begin{figure} \centering \includegraphics[scale=0.38]{imgs/system-diagram-thin.png} \caption{The overall framework of our system proposed for SemEval-2022 Task 8.} \label{fig:systemdiagram} \end{figure} \subsection{Data Augmentation} In this task, we augmented the training data in two different ways and they will be introduced respectively in the following subsections. \subsubsection{Back Translation} It is clear from Table \ref{dataset} that the original training set is not sufficient to train XLM-R, so we made use of back-translation to enrich it. As the English pairs account for the largest, we only paid attention to the non-English samples in this stage. Take the French samples for example, by calling Google Translation API\footnote{\url{https://cloud.google.com/translate}}, we translate the French articles to English and then translate the English texts back to French. As for the cross-lingual pairs with German and English, we only back-translate the German part and then combine it with the corresponding English part to form a new sample. \begin{table*} \small \setlength\tabcolsep{2pt} \centering \begin{tabular}{llllllllllllllllllll} \toprule & \textbf{ar} & \textbf{de} & \textbf{en} & \textbf{es} & \textbf{fr} & \textbf{it} & \textbf{pl} & \textbf{ru} & \textbf{tr} & \textbf{zh} & \textbf{de-en} & \textbf{de-fr} & \textbf{de-pl} & \textbf{es-en} & \textbf{es-it} & \textbf{fr-pl} & \textbf{pl-en} & \textbf{zh-en} & \textbf{Total} \\ \midrule \textbf{Train} & 274 & 857 & 1787 & 567 & 72 & 0 & 349 & 0 & 462 & 0 & 574 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 4942 \\ \textbf{Test} & 298 & 611 & 236 & 243 & 111 & 442 & 224 & 287 & 275 & 769 & 190 & 116 & 35 & 498 & 320 & 11 & 64 & 223 & 4953 \\ \textbf{Train+DA} & 548 & 1714 & 1787 & 1134 & 461 & 586 & 689 & 401 & 924 & 800 & 1148 & 317 & 0 & 586 & 586 & 0 & 349 & 800 & 12830 \\ \bottomrule \end{tabular} \caption{\label{dataset} Data distribution in each set. Columns with one language (e.g. ``zh'') mean the two articles in a pair are in the same language. Columns with two languages (e.g. ``zh-en'') indicate the corresponding cross-lingual pairs. } \end{table*} \begin{table} \centering \begin{tabular}{ccc} \toprule \textbf{Origin} &\textbf{Quantity} & \textbf{Target} \\ \midrule \multirow{3}{*}{en-en} & 401 & ru-ru \\ & 800 & zh-zh / zh-en \\ & 586 & it-it / es-en / es-it \\ pl-pl & 349 & pl-en \\ de-en & 317 & de-fr / fr-fr \\ \bottomrule \end{tabular} \caption{\label{translate-train arrangement}Arrangement for the construction of translate-train set. } \end{table} \subsubsection{Translate Train} Another weakness of the original training set is the severe lack of some monolingual language pairs which exist in the test set but not in the training set like Chinese and quite a few cross-lingual language pairs like German to French. To deal with this problem, we planned to generate translate-train data to fill the gap. In such semantic comprehension tasks, it is undoubted that the richer semantic information is, the better the model performance will be. Therefore, for maintaining the semantic richness to the largest extent, we made an arrangement for the construction of the translate-train set (details are provided in Table \ref{translate-train arrangement}). As the average quantity of non-English monolingual samples in the training set is 430, for the sake of balancing the whole dataset, we decided to round it down to 400 and let it be the number of translated samples for Russian (due to some precision issues, it became 401 accidentally). As we may know, Russian and English both belong to Indo-European Family \cite{russian} while Chinese is a member of the Sino-Tibetan Family \cite{chinese}, which indicates that there are quite a lot of common characteristics between the two languages like syntactic structures and lexical analysis methods. So, the most English samples in the original training set would help more in understanding Russian instead of Chinese. Therefore, we decided to generate more Chinese pairs and here we just doubled the number for Russian. Furthermore, the English samples left were all used for generating samples in Italian and Spanish. In order to improve the reusability of those samples newly translated already, some work on recombination among different languages pairs was done in this phase. For instance, translating German to English samples to French would let us get German to French samples in the meantime. \subsection{Head-tail Combination} \label{headtailintroduction} There is no doubt that different types of texts have different features. As for news, the title tends to be the most informative place in each article since the authors need to use as few concise words as possible to let the readers know what happened in the story. Besides, we believe the head and tail parts of a news article provide much information as well as similar to the introduction and conclusion parts in a research paper. As the XLM-R is capable of processing 512 tokens in each sequence (a pair of articles) at most and the large majority of articles in the training set are much longer than 256 tokens (see Appendix), we tried different truncation strategies to further boost the model performance. \subsection{Multi-label Loss} \label{multilabellossintro} As introduced in Background, only the predictions for \textit{Overall} will be used to evaluate, but the other 6 sub-dimensions are also probably helpful for assisting in building a better model. Consequently, we tried to assign various weights for \textit{Overall} when calculating the loss while treating other sub-dimensions equally. For example, if the loss for \textit{Overall} accounts for 40\%, the percentages of the other six sub-dimensions are all 10\% individually. \subsection{Adapted R-Drop}\label{rdropoverview} R-Drop is proved to be an effective regularization method based on dropout, by minimizing the KL-divergence of the output distributions of every two sub-models generated via dropout in model training \cite{liang2021rdrop}. To better fit with this regression task, we replaced the KL-divergence loss with MSE loss (adapted R-Drop). Similarly, at each training step, we feed the samples through the forward pass of the network twice. Then, our adapted R-Drop method tries to regularize the model by minimizing the two predicted scores for the same sample, which is: $$ L_{R}^{i} = \textup{MSE}(y_{1}^{i}, y_{2}^{i}) $$ where the $ y_{1}^{i} $ means the model output in the first forward pass for the $ i_{th} $ sample. With the basic MSE loss $ L_{B} $ of the two forward passes: $$ L_{B}^{i} = \frac{1}{2} \cdot (\textup{MSE}(y_{1}^{i}, \hat y^{i}) + \textup{MSE}(y_{2}^{i}, \hat y^{i})) $$ where the $\hat y^{i} $ is the label of the $ i_{th} $ sample, the final training target is minimizing $ L^{i} $ for $ i_{th} $ sample: $$ L^{i} = \alpha \cdot L_{R}^{i} + (1-\alpha) \cdot L_{B}^{i}$$ where the $ \alpha $ is the weight for the adapted R-Drop loss. Based on this description, it is easy to extend the formulas to the one of forwarding three times. \subsection{Extra Linear Layers} In our baseline system, the prediction score is generated by passing the output of [CLS] token from XLM-R through a single linear layer with the size of (1024, 1). In other words, there are only 1024 parameters that are responsible for the regression from the sentence representation vector to the prediction score, which is probably beyond their power. Hence, we attempted to add a few more layers on top of the XLM-R. \subsection{Post-processing} Once getting the prediction scores, we further corrected some wrong numbers which were outside the expected range. As introduced in Section \ref{taskdescription}, the annotators annotated the similarity in the range (1, 4); consequently, we clipped the outliers. \section{Experimental setup} \subsection{Dataset Split} Both the original training set and the training set with DA set were split into 10 subsets with no intersection by random sampling. All the experiments discussed in this paper were conducted with 10-fold cross-validation, and the results displayed are the averages. By using the cross-validation method \cite{crossvalidation}, we could ensure the strategies applied will take a good effect on the final test set to the largest extent. \subsection{Pre-processing} The news articles in all the data sets are released as URLs and the task organizers offer us a python script\footnote{\url{https://github.com/euagendas/semeval\_8\_2022\_ia\_downloader}} which helps to download the pages. After downloading the original files in JSON format, we then extracted and combined ``title'' and ``text'' parts of each article and abandoned all other information like ``description''. Before starting training our model, apart from conducting data augmentation to the training set, we also cleaned the data and joined the head and tail parts of each article. During the process of cleaning, we mainly removed some dirty formatted data like URLs and file paths. \subsection{Evaluation Metrics} The evaluation metric for task 8 is the Pearson's Correlation Coefficient (Pearson's CC) which is a measure of linear correlation between two series of data with a range from -1 to 1 (from least to most correlated) \cite{pearson}. \subsection{Others} Although hyper-parameters tuning is not a crucial point in our work, we tested a few values for several of them within a small range as they did have an influence on our decisions about how well a strategy worked (see Appendix). Additionally, to help readers replicate our experiments, the details of tools and libraries are provided (see Appendix). \begin{table}[t] \centering \begin{tabular}{lc} \toprule \multicolumn{1}{l}{\textbf{System}} & \multicolumn{1}{l}{\textbf{Pearson's CC}} \\ \midrule \multicolumn{2}{c}{\textit{w/ data augmentation}} \\ \midrule Baseline & 83.49 \\ \ \ \ \ + DA & \textbf{85.86} \\ \midrule \multicolumn{2}{c}{\textit{w/o data augmentation}} \\ \midrule Baseline & 84.94 \\ \ \ \ \ + Head-tail Combination & 85.38 \\ \ \ \ \ + Multi-label Loss & 85.33 \\ \ \ \ \ + Adapted R-Drop & \textbf{86.14} \\ \ \ \ \ + Extra Linear Layers & 85.50 \\ \bottomrule \end{tabular} \caption{\label{WholeResults}Best results with training methods we used.} \end{table} \section{Results} \subsection{Overall Performance} Finally, our system got 0.818 on the evaluation set according to the official scoring system and ranked 1st. As results are shown in Table \ref{WholeResults}, all the strategies introduced in Section \ref{systemoverview} turned out to have positive effects, and we will discuss the effect of the strategies mentioned individually in the following subsections. For convenience, all the results from our experiments are multiplied by 100. \subsection{Data Augmentation} To find out whether the augmented data was helpful or not, we trained our system on the original training set and the training set with DA respectively (samples used for testing were removed in both of them), then tested it on each fold of the DA set. In experiments on other strategies, we trained and tested our system on the original training set. And this is the difference between the two baselines in Table \ref{WholeResults}. Without any surprise, an evident increase is observed from the results displayed in the top part of Table \ref{WholeResults}, based on which we could make a conclusion that a more abundant training set is definitely beneficial for building a strong system. \subsection{Head-tail Combination} As introduced in Section \ref{headtailintroduction}, we realized the importance of the head and tail parts of the news articles. However, we cannot determine which part should be paid more attention to heuristically. So, we tried on different ratios of head-tail combination and the results are enumerated in Table \ref{headtailresults}. Clearly, the head part plays a much more important role by comparing the first and last rows where only either of them are used. However, from the middle three rows where the head and tail parts are combined, it is indicated that the tail part also benefits the whole model performance. \begin{table}[t] \centering \begin{tabular}{llc} \toprule \textbf{Head} & \textbf{Tail} & \textbf{Pearson's CC} \\ \midrule 256 & 0 & 84.94 \\ 200 & 56 & \textbf{85.38} \\ 128 & 128 & 85.21 \\ 56 & 200 & 84.53 \\ 0 & 256 & 78.85 \\ \bottomrule \end{tabular} \caption{\label{headtailresults}Results on different head-tail combinations.} \end{table} \subsection{Multi-label Loss} As discussed in Section \ref{multilabellossintro}, we used other 6 dimensions and assigned a few different values for the weight of \textit{Overall} from 0\% to 100\%. It is explicitly observed from Table \ref{multilabelresults} that there is an overwhelming increase followed by a slight drop while the weight of \textit{Overall} rises gradually. Based on the experiment results, we believe that \textit{Overall} is of the greatest importance to this task, yet the other 6 sub-dimensions also have a positive effect on achieving a better similarity assessment system. \begin{table}[] \centering \begin{tabular}{lc} \toprule \textbf{\textit{Overall} Weight} & \textbf{Pearson's CC} \\ \midrule 0\% & 45.17 \\ 30\% & 85.07 \\ 50\% & 85.31 \\ 75\% & \textbf{85.33} \\ 100\% & 84.94 \\ \bottomrule \end{tabular} \caption{\label{multilabelresults}Results on training with multi-label loss.} \end{table} \subsection{Adapted R-drop} As described in Section \ref{rdropoverview}, the training loss in our system is composed of both the loss between predictions and labels and the loss between the predictions from different forwarding processes. Here, we explored forwarding once to three times while changing the weight of adapted R-Drop loss. Apparently, there is a phenomenon from Table \ref{rdropresults} that no matter how large the weight of R-Drop loss is, the more forwarding times are, the better results we will achieve. However, by comparing the results between forwarding once and twice and the results between forwarding twice and three times, we speculate that there is a marginal utility \cite{marginalutility} on this trick, which means the additional benefit from this method will decrease while simply continuing increasing the number of forwarding. \begin{table}[] \centering \small \begin{tabular}{lccccc} \toprule \textbf{RD Weight} & 1\% & 5\% & 10\% & 30\% & 50\% \\ \midrule \textbf{1F} & 84.94 & 84.94 & 84.94 & 84.94 & 84.94 \\ \textbf{2F} & 85.77 & 85.85 & 85.78 & 86.03 & 85.99 \\ \textbf{3F} & \textbf{85.95} & \textbf{86.14} & \textbf{85.98} & \textbf{86.13} & \textbf{86.07} \\ \bottomrule \end{tabular} \caption{\label{rdropresults} Results about adapted R-Drop (RD) in different settings. ``2F'' means forwarding twice.} \end{table} \subsection{Extra Linear Layers} During the process of exploration in this direction, we attempted to add 2 or 3 extra linear layers to test if it worked. In the 2-layer setting, the sizes of the layers are (1024, 512) and (512, 1) while sizes composed of (1024, 768), (768, 256) and (256, 1) are prepared for the 3-layer setting. Two sets of experiments were conducted in both settings about whether to put an activation layer (we used GELU \cite{gelu} here) between adjacent linear layers or not. It can be observed from Table \ref{addlinearlayersresults} that there is only a quite small difference that caused by activation layers in each setting and the effect of that is not always positive. In addition, by comparing the results from different settings, we could draw a conclusion that more parameters did help to boost the system performance even if the benefit does not show linear growth. \begin{table}[] \centering \begin{tabular}{lc} \toprule \textbf{System} & \textbf{Pearson's CC} \\ \midrule 1-layer & 84.94 \\ 2-layer & 85.46 \\ \ \ \ \ + activation & \textbf{85.50} \\ 3-layer & 85.32 \\ \ \ \ \ + activation & 85.23 \\ \bottomrule \end{tabular} \caption{\label{addlinearlayersresults} Results on different extra layers.} \end{table} \subsection{Negative Results} Aside from the strategies discussed above, several tricks that were attempted to deploy in our system as well turned out to be meaningless or had a bad effect on the model performance. For example, we tried to use a pooling vector (max or mean) or the fusion of [CLS] vectors from different layers in XLM-R as the article representation. We also tried to expand the length of sentences that XLM-R could process to 1024 tokens by modifying its position embedding matrix by means of adding a random shift vector after each vector or just randomly initializing the latter part of the learnable expanded matrix. Each negative strategy mentioned above brought approximately at least 2 points drop on the Pearson's CC. Furthermore, unsurprisingly, a two-tower architecture where each shared-parameter model processed each article in a pair led to scores of points decrease, which reflected the importance of semantic interaction via the attention mechanism inside the model. \subsection{Error Analysis} After the evaluation phase ended, the evaluation data with labels were provided and we also checked the system performance on different language pairs individually. The details of our best submission are presented in Table \ref{resultsinbestsubmissiontable}. It is obvious that the model tends to perform worse on the language pairs which are rare or absent from the training set like German to Polish (only 64.31). Interestingly, although having seen monolingual samples in Polish and related cross-lingual data, the system still behaves badly on Polish monolingual data (just slightly over 75), which is probably due to its complicated lexical variation and grammar rules \cite{polish}. \begin{table}[] \centering \begin{tabular}{cccccc} \toprule \textbf{en} & \textbf{de} & \textbf{es} & \textbf{pl} & \textbf{tr} \\ \midrule 87.19 & 84.96 & 86.64 & 75.29 & 83.54 \\ \midrule \textbf{ar} & \textbf{ru} & \textbf{zh} & \textbf{fr} & \textbf{it} \\ \midrule 79.42 & 78.47 & 76.78 & 86.53 & 86.17 \\ \midrule \textbf{es-en} & \textbf{de-en} & \textbf{pl-en} & \textbf{zh-en} \\ \midrule 86.35 & 85.98 & 88.18 & 81.00 \\ \midrule \textbf{es-it} & \textbf{de-fr} & \textbf{de-pl} & \textbf{fr-pl} \\ \midrule 81.97 & 68.89 & 64.31 & 82.68 \\ \bottomrule \end{tabular} \caption{\label{resultsinbestsubmissiontable}Individual results of all language pairs in our best submission.} \end{table} \section{Conclusion} By deploying various optimization methods, including data augmentation, head-tail combination, multi-label loss, adapted R-Drop and adding extra linear layers, we built a relatively strong system for assessing the similarity between a pair of news articles in multilingual and cross-lingual settings and ranked 1st in the competition with a Pearson's CC of 0.818 on the official evaluation set. In the future, apart from enriching the training data, we are also supposed to analyze the languages individually and try to leverage the exclusive rules or features of each language rather than relying too heavily on general pre-trained models to further boost the model performance, especially on those minority languages. \section{Introduction} In Task 8 \cite{taskpaper}, we are expected to assess the similarity of pairs of multilingual news articles. Ten different languages are covered in this task, including Spanish, Italian, German, English, Chinese, Arabic, Polish, French, Turkish and Russian. Task 8 emphasizes more the events themselves described in the news rather than the style of writing or other subjective characteristics. Therefore, it is beneficial to improve the quality of clustering of news articles and to explore similar news coverage across different outlets or regions. The foundation model \cite{foundationmodel} we choose is XLM-RoBERTa (XLM-R) \cite{xlmr} which has been proved to be a powerful multilingual pre-trained language model compared with other models like mBERT \cite{mbert} and it can process all the languages existing in Task 8. Based on that, a great variety of strategies have been tested along with our exploration like data augmentation (DA), head-tail combination, multi-label loss, adapted R-Drop, etc. Through this task, we realized the importance of data quality and efficient training schemes in a cross-lingual setting. By struggling to improve the richness of the data and find out what methods are effective when training such a similarity assessment model, our system\footnote{Our code will be available at \url{https://github.com/GeekDream-x/SemEval2022-Task8-TonyX}} ranked 1st in this competition. \section{Background} \subsection{Dataset Description} \label{taskdescription} There are 4,964 samples with 8 language pairs in the training set and the test set contains 4,593 samples in 18 different language pairs, the details of which are presented in Table \ref{dataset}. Due to some inaccessible URLs, the training set is slightly smaller than it should be (22 samples missing in total). The similarity scores of pairs of articles in provided dataset are rated on a 4-point scale (between 1 and 4) from most to least similar from 7 sub-dimensions, including \textit{Geography}, \textit{Entities}, \textit{Time}, \textit{Narrative}, \textit{Overall}, \textit{Style} and \textit{Tone} (an example is provided in Appendix). However, only the predictions for \textit{Overall} will be used to evaluate the performance of our systems. \subsection{Related Work} Research on text similarity always attracts people's eyes as it acts as the basis of quite a few NLP downstream tasks like information retrieval \cite{infomationretrieval}. Previously, some methods based on statistics like BM25 \cite{bm25} and Edit Distance \cite{editdistance} are used to evaluate the relevance between two texts but they do not work anymore in cross-lingual settings. Then, after dense word embedding in low dimensions like Word2Vec \cite{word2vec} was put forward, methods like calculating the cosine similarity \cite{semanticcosinesimilarity} with the sentence embedding based on each word embedding came into use. However, it is hard for these approaches to capture the latent meaning of the whole article precisely. Nowadays, depending on transformer-based general pre-trained models are becoming the new paradigm and plenty of models for multilingual and cross-lingual settings have been proposed like mBERT \cite{mbert}, ERNIE-M \cite{erniem} and XLM-R \cite{xlmr}. \section{System Overview} \label{systemoverview} Our baseline system is simply providing a pair of articles to XLM-R and regressing its output from [CLS] token to the manually annotated similarity score by training with Mean Squared Error (MSE). All the optimization methods discussed below are applied based on this architecture and the overall framework of our final system is illustrated in Figure \ref{fig:systemdiagram}. After training with all the positive strategies, we then made an ensemble of the best models on each fold for the final prediction. \begin{figure} \centering \includegraphics[scale=0.38]{imgs/system-diagram-thin.png} \caption{The overall framework of our system proposed for SemEval-2022 Task 8.} \label{fig:systemdiagram} \end{figure} \subsection{Data Augmentation} In this task, we augmented the training data in two different ways and they will be introduced respectively in the following subsections. \subsubsection{Back Translation} It is clear from Table \ref{dataset} that the original training set is not sufficient to train XLM-R, so we made use of back-translation to enrich it. As the English pairs account for the largest, we only paid attention to the non-English samples in this stage. Take the French samples for example, by calling Google Translation API\footnote{\url{https://cloud.google.com/translate}}, we translate the French articles to English and then translate the English texts back to French. As for the cross-lingual pairs with German and English, we only back-translate the German part and then combine it with the corresponding English part to form a new sample. \begin{table*} \small \setlength\tabcolsep{2pt} \centering \begin{tabular}{llllllllllllllllllll} \toprule & \textbf{ar} & \textbf{de} & \textbf{en} & \textbf{es} & \textbf{fr} & \textbf{it} & \textbf{pl} & \textbf{ru} & \textbf{tr} & \textbf{zh} & \textbf{de-en} & \textbf{de-fr} & \textbf{de-pl} & \textbf{es-en} & \textbf{es-it} & \textbf{fr-pl} & \textbf{pl-en} & \textbf{zh-en} & \textbf{Total} \\ \midrule \textbf{Train} & 274 & 857 & 1787 & 567 & 72 & 0 & 349 & 0 & 462 & 0 & 574 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 4942 \\ \textbf{Test} & 298 & 611 & 236 & 243 & 111 & 442 & 224 & 287 & 275 & 769 & 190 & 116 & 35 & 498 & 320 & 11 & 64 & 223 & 4953 \\ \textbf{Train+DA} & 548 & 1714 & 1787 & 1134 & 461 & 586 & 689 & 401 & 924 & 800 & 1148 & 317 & 0 & 586 & 586 & 0 & 349 & 800 & 12830 \\ \bottomrule \end{tabular} \caption{\label{dataset} Data distribution in each set. Columns with one language (e.g. ``zh'') mean the two articles in a pair are in the same language. Columns with two languages (e.g. ``zh-en'') indicate the corresponding cross-lingual pairs. } \end{table*} \begin{table} \centering \begin{tabular}{ccc} \toprule \textbf{Origin} &\textbf{Quantity} & \textbf{Target} \\ \midrule \multirow{3}{*}{en-en} & 401 & ru-ru \\ & 800 & zh-zh / zh-en \\ & 586 & it-it / es-en / es-it \\ pl-pl & 349 & pl-en \\ de-en & 317 & de-fr / fr-fr \\ \bottomrule \end{tabular} \caption{\label{translate-train arrangement}Arrangement for the construction of translate-train set. } \end{table} \subsubsection{Translate Train} Another weakness of the original training set is the severe lack of some monolingual language pairs which exist in the test set but not in the training set like Chinese and quite a few cross-lingual language pairs like German to French. To deal with this problem, we planned to generate translate-train data to fill the gap. In such semantic comprehension tasks, it is undoubted that the richer semantic information is, the better the model performance will be. Therefore, for maintaining the semantic richness to the largest extent, we made an arrangement for the construction of the translate-train set (details are provided in Table \ref{translate-train arrangement}). As the average quantity of non-English monolingual samples in the training set is 430, for the sake of balancing the whole dataset, we decided to round it down to 400 and let it be the number of translated samples for Russian (due to some precision issues, it became 401 accidentally). As we may know, Russian and English both belong to Indo-European Family \cite{russian} while Chinese is a member of the Sino-Tibetan Family \cite{chinese}, which indicates that there are quite a lot of common characteristics between the two languages like syntactic structures and lexical analysis methods. So, the most English samples in the original training set would help more in understanding Russian instead of Chinese. Therefore, we decided to generate more Chinese pairs and here we just doubled the number for Russian. Furthermore, the English samples left were all used for generating samples in Italian and Spanish. In order to improve the reusability of those samples newly translated already, some work on recombination among different languages pairs was done in this phase. For instance, translating German to English samples to French would let us get German to French samples in the meantime. \subsection{Head-tail Combination} \label{headtailintroduction} There is no doubt that different types of texts have different features. As for news, the title tends to be the most informative place in each article since the authors need to use as few concise words as possible to let the readers know what happened in the story. Besides, we believe the head and tail parts of a news article provide much information as well as similar to the introduction and conclusion parts in a research paper. As the XLM-R is capable of processing 512 tokens in each sequence (a pair of articles) at most and the large majority of articles in the training set are much longer than 256 tokens (see Appendix), we tried different truncation strategies to further boost the model performance. \subsection{Multi-label Loss} \label{multilabellossintro} As introduced in Background, only the predictions for \textit{Overall} will be used to evaluate, but the other 6 sub-dimensions are also probably helpful for assisting in building a better model. Consequently, we tried to assign various weights for \textit{Overall} when calculating the loss while treating other sub-dimensions equally. For example, if the loss for \textit{Overall} accounts for 40\%, the percentages of the other six sub-dimensions are all 10\% individually. \subsection{Adapted R-Drop}\label{rdropoverview} R-Drop is proved to be an effective regularization method based on dropout, by minimizing the KL-divergence of the output distributions of every two sub-models generated via dropout in model training \cite{liang2021rdrop}. To better fit with this regression task, we replaced the KL-divergence loss with MSE loss (adapted R-Drop). Similarly, at each training step, we feed the samples through the forward pass of the network twice. Then, our adapted R-Drop method tries to regularize the model by minimizing the two predicted scores for the same sample, which is: $$ L_{R}^{i} = \textup{MSE}(y_{1}^{i}, y_{2}^{i}) $$ where the $ y_{1}^{i} $ means the model output in the first forward pass for the $ i_{th} $ sample. With the basic MSE loss $ L_{B} $ of the two forward passes: $$ L_{B}^{i} = \frac{1}{2} \cdot (\textup{MSE}(y_{1}^{i}, \hat y^{i}) + \textup{MSE}(y_{2}^{i}, \hat y^{i})) $$ where the $\hat y^{i} $ is the label of the $ i_{th} $ sample, the final training target is minimizing $ L^{i} $ for $ i_{th} $ sample: $$ L^{i} = \alpha \cdot L_{R}^{i} + (1-\alpha) \cdot L_{B}^{i}$$ where the $ \alpha $ is the weight for the adapted R-Drop loss. Based on this description, it is easy to extend the formulas to the one of forwarding three times. \subsection{Extra Linear Layers} In our baseline system, the prediction score is generated by passing the output of [CLS] token from XLM-R through a single linear layer with the size of (1024, 1). In other words, there are only 1024 parameters that are responsible for the regression from the sentence representation vector to the prediction score, which is probably beyond their power. Hence, we attempted to add a few more layers on top of the XLM-R. \subsection{Post-processing} Once getting the prediction scores, we further corrected some wrong numbers which were outside the expected range. As introduced in Section \ref{taskdescription}, the annotators annotated the similarity in the range (1, 4); consequently, we clipped the outliers. \section{Experimental setup} \subsection{Dataset Split} Both the original training set and the training set with DA set were split into 10 subsets with no intersection by random sampling. All the experiments discussed in this paper were conducted with 10-fold cross-validation, and the results displayed are the averages. By using the cross-validation method \cite{crossvalidation}, we could ensure the strategies applied will take a good effect on the final test set to the largest extent. \subsection{Pre-processing} The news articles in all the data sets are released as URLs and the task organizers offer us a python script\footnote{\url{https://github.com/euagendas/semeval\_8\_2022\_ia\_downloader}} which helps to download the pages. After downloading the original files in JSON format, we then extracted and combined ``title'' and ``text'' parts of each article and abandoned all other information like ``description''. Before starting training our model, apart from conducting data augmentation to the training set, we also cleaned the data and joined the head and tail parts of each article. During the process of cleaning, we mainly removed some dirty formatted data like URLs and file paths. \subsection{Evaluation Metrics} The evaluation metric for task 8 is the Pearson's Correlation Coefficient (Pearson's CC) which is a measure of linear correlation between two series of data with a range from -1 to 1 (from least to most correlated) \cite{pearson}. \subsection{Others} Although hyper-parameters tuning is not a crucial point in our work, we tested a few values for several of them within a small range as they did have an influence on our decisions about how well a strategy worked (see Appendix). Additionally, to help readers replicate our experiments, the details of tools and libraries are provided (see Appendix). \begin{table}[t] \centering \begin{tabular}{lc} \toprule \multicolumn{1}{l}{\textbf{System}} & \multicolumn{1}{l}{\textbf{Pearson's CC}} \\ \midrule \multicolumn{2}{c}{\textit{w/ data augmentation}} \\ \midrule Baseline & 83.49 \\ \ \ \ \ + DA & \textbf{85.86} \\ \midrule \multicolumn{2}{c}{\textit{w/o data augmentation}} \\ \midrule Baseline & 84.94 \\ \ \ \ \ + Head-tail Combination & 85.38 \\ \ \ \ \ + Multi-label Loss & 85.33 \\ \ \ \ \ + Adapted R-Drop & \textbf{86.14} \\ \ \ \ \ + Extra Linear Layers & 85.50 \\ \bottomrule \end{tabular} \caption{\label{WholeResults}Best results with training methods we used.} \end{table} \section{Results} \subsection{Overall Performance} Finally, our system got 0.818 on the evaluation set according to the official scoring system and ranked 1st. As results are shown in Table \ref{WholeResults}, all the strategies introduced in Section \ref{systemoverview} turned out to have positive effects, and we will discuss the effect of the strategies mentioned individually in the following subsections. For convenience, all the results from our experiments are multiplied by 100. \subsection{Data Augmentation} To find out whether the augmented data was helpful or not, we trained our system on the original training set and the training set with DA respectively (samples used for testing were removed in both of them), then tested it on each fold of the DA set. In experiments on other strategies, we trained and tested our system on the original training set. And this is the difference between the two baselines in Table \ref{WholeResults}. Without any surprise, an evident increase is observed from the results displayed in the top part of Table \ref{WholeResults}, based on which we could make a conclusion that a more abundant training set is definitely beneficial for building a strong system. \subsection{Head-tail Combination} As introduced in Section \ref{headtailintroduction}, we realized the importance of the head and tail parts of the news articles. However, we cannot determine which part should be paid more attention to heuristically. So, we tried on different ratios of head-tail combination and the results are enumerated in Table \ref{headtailresults}. Clearly, the head part plays a much more important role by comparing the first and last rows where only either of them are used. However, from the middle three rows where the head and tail parts are combined, it is indicated that the tail part also benefits the whole model performance. \begin{table}[t] \centering \begin{tabular}{llc} \toprule \textbf{Head} & \textbf{Tail} & \textbf{Pearson's CC} \\ \midrule 256 & 0 & 84.94 \\ 200 & 56 & \textbf{85.38} \\ 128 & 128 & 85.21 \\ 56 & 200 & 84.53 \\ 0 & 256 & 78.85 \\ \bottomrule \end{tabular} \caption{\label{headtailresults}Results on different head-tail combinations.} \end{table} \subsection{Multi-label Loss} As discussed in Section \ref{multilabellossintro}, we used other 6 dimensions and assigned a few different values for the weight of \textit{Overall} from 0\% to 100\%. It is explicitly observed from Table \ref{multilabelresults} that there is an overwhelming increase followed by a slight drop while the weight of \textit{Overall} rises gradually. Based on the experiment results, we believe that \textit{Overall} is of the greatest importance to this task, yet the other 6 sub-dimensions also have a positive effect on achieving a better similarity assessment system. \begin{table}[] \centering \begin{tabular}{lc} \toprule \textbf{\textit{Overall} Weight} & \textbf{Pearson's CC} \\ \midrule 0\% & 45.17 \\ 30\% & 85.07 \\ 50\% & 85.31 \\ 75\% & \textbf{85.33} \\ 100\% & 84.94 \\ \bottomrule \end{tabular} \caption{\label{multilabelresults}Results on training with multi-label loss.} \end{table} \subsection{Adapted R-drop} As described in Section \ref{rdropoverview}, the training loss in our system is composed of both the loss between predictions and labels and the loss between the predictions from different forwarding processes. Here, we explored forwarding once to three times while changing the weight of adapted R-Drop loss. Apparently, there is a phenomenon from Table \ref{rdropresults} that no matter how large the weight of R-Drop loss is, the more forwarding times are, the better results we will achieve. However, by comparing the results between forwarding once and twice and the results between forwarding twice and three times, we speculate that there is a marginal utility \cite{marginalutility} on this trick, which means the additional benefit from this method will decrease while simply continuing increasing the number of forwarding. \begin{table}[] \centering \small \begin{tabular}{lccccc} \toprule \textbf{RD Weight} & 1\% & 5\% & 10\% & 30\% & 50\% \\ \midrule \textbf{1F} & 84.94 & 84.94 & 84.94 & 84.94 & 84.94 \\ \textbf{2F} & 85.77 & 85.85 & 85.78 & 86.03 & 85.99 \\ \textbf{3F} & \textbf{85.95} & \textbf{86.14} & \textbf{85.98} & \textbf{86.13} & \textbf{86.07} \\ \bottomrule \end{tabular} \caption{\label{rdropresults} Results about adapted R-Drop (RD) in different settings. ``2F'' means forwarding twice.} \end{table} \subsection{Extra Linear Layers} During the process of exploration in this direction, we attempted to add 2 or 3 extra linear layers to test if it worked. In the 2-layer setting, the sizes of the layers are (1024, 512) and (512, 1) while sizes composed of (1024, 768), (768, 256) and (256, 1) are prepared for the 3-layer setting. Two sets of experiments were conducted in both settings about whether to put an activation layer (we used GELU \cite{gelu} here) between adjacent linear layers or not. It can be observed from Table \ref{addlinearlayersresults} that there is only a quite small difference that caused by activation layers in each setting and the effect of that is not always positive. In addition, by comparing the results from different settings, we could draw a conclusion that more parameters did help to boost the system performance even if the benefit does not show linear growth. \begin{table}[] \centering \begin{tabular}{lc} \toprule \textbf{System} & \textbf{Pearson's CC} \\ \midrule 1-layer & 84.94 \\ 2-layer & 85.46 \\ \ \ \ \ + activation & \textbf{85.50} \\ 3-layer & 85.32 \\ \ \ \ \ + activation & 85.23 \\ \bottomrule \end{tabular} \caption{\label{addlinearlayersresults} Results on different extra layers.} \end{table} \subsection{Negative Results} Aside from the strategies discussed above, several tricks that were attempted to deploy in our system as well turned out to be meaningless or had a bad effect on the model performance. For example, we tried to use a pooling vector (max or mean) or the fusion of [CLS] vectors from different layers in XLM-R as the article representation. We also tried to expand the length of sentences that XLM-R could process to 1024 tokens by modifying its position embedding matrix by means of adding a random shift vector after each vector or just randomly initializing the latter part of the learnable expanded matrix. Each negative strategy mentioned above brought approximately at least 2 points drop on the Pearson's CC. Furthermore, unsurprisingly, a two-tower architecture where each shared-parameter model processed each article in a pair led to scores of points decrease, which reflected the importance of semantic interaction via the attention mechanism inside the model. \subsection{Error Analysis} After the evaluation phase ended, the evaluation data with labels were provided and we also checked the system performance on different language pairs individually. The details of our best submission are presented in Table \ref{resultsinbestsubmissiontable}. It is obvious that the model tends to perform worse on the language pairs which are rare or absent from the training set like German to Polish (only 64.31). Interestingly, although having seen monolingual samples in Polish and related cross-lingual data, the system still behaves badly on Polish monolingual data (just slightly over 75), which is probably due to its complicated lexical variation and grammar rules \cite{polish}. \begin{table}[] \centering \begin{tabular}{cccccc} \toprule \textbf{en} & \textbf{de} & \textbf{es} & \textbf{pl} & \textbf{tr} \\ \midrule 87.19 & 84.96 & 86.64 & 75.29 & 83.54 \\ \midrule \textbf{ar} & \textbf{ru} & \textbf{zh} & \textbf{fr} & \textbf{it} \\ \midrule 79.42 & 78.47 & 76.78 & 86.53 & 86.17 \\ \midrule \textbf{es-en} & \textbf{de-en} & \textbf{pl-en} & \textbf{zh-en} \\ \midrule 86.35 & 85.98 & 88.18 & 81.00 \\ \midrule \textbf{es-it} & \textbf{de-fr} & \textbf{de-pl} & \textbf{fr-pl} \\ \midrule 81.97 & 68.89 & 64.31 & 82.68 \\ \bottomrule \end{tabular} \caption{\label{resultsinbestsubmissiontable}Individual results of all language pairs in our best submission.} \end{table} \section{Conclusion} By deploying various optimization methods, including data augmentation, head-tail combination, multi-label loss, adapted R-Drop and adding extra linear layers, we built a relatively strong system for assessing the similarity between a pair of news articles in multilingual and cross-lingual settings and ranked 1st in the competition with a Pearson's CC of 0.818 on the official evaluation set. In the future, apart from enriching the training data, we are also supposed to analyze the languages individually and try to leverage the exclusive rules or features of each language rather than relying too heavily on general pre-trained models to further boost the model performance, especially on those minority languages.
{'timestamp': '2022-04-12T02:30:46', 'yymm': '2204', 'arxiv_id': '2204.04844', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04844'}
arxiv
\section{Introduction} Currently, the evaluation of synthesized speech quality mainly relies on subjective listening tests, which are very expensive and time-consuming since they require numerous human listeners. Although there are many traditional objective speech quality evaluation methods~\cite{recommendation2001perceptual, beerends2013perceptual, malfait2006p, grancharov2006low}, they either require clean reference audio or are easily affected by background noise, enhancement algorithms, and application scenarios, which causes their results to differ from those obtained via manual evaluation of synthesized speech. To improve the accuracy of objective evaluation, recently, researchers have started to explore quality assessment methods that do not require any reference audio for the application of synthetic datasets. Related works often employ neural network-based frameworks and use large-scale synthetic speech for training~\cite{lo2019mosnet, choi2021neural}. In the MOS challenge 2022, the organizers have provided three state-of-the-art approaches as baselines~\cite{huang2021ldnet, cooper2021generalization} and a large synthetic corpus collected from past Blizzard challenges~\cite{karaiskos2008blizzard,kinga2009blizzard,King2010TheBC,King2011TheBC,King2012TheBC,King2013TheBC,King2016TheBC}. The baseline systems are basically built on utterance-level MOS scores using either original speech~\cite{huang2021ldnet}, domain, or latent features~\cite{zezario2021deep, huang2021ldnet}. In addition to the accuracy of model fitting, one of the major challenges is that the existing system usually performs worse on out-of-domain (OOD) data. A better solution is to introduce self-supervised learned (SSL) models. One of the baselines provided by the organizers has proved the generalization ability of pretrained SSL models ~\cite{cooper2021generalization}. The organizers have examined the performance of fine-tuning various Wav2Vec 2.0 \cite{baevski2020wav2vec} and HuBERT \cite{hsu2021hubert} models which are pretrained using different corpora and have surprisingly found that such methods can do moderately well in even the very challenging case of zero-shot utterance-level prediction. However, we have observed that for pretrained models obtained from the same framework trained with different data, their performance on different metrics is not the same. Therefore, we suspect that the data and different model configurations used for pre-training will affect the performance. Model fusion enables us to utilize different pretrained models within the same framework. By splicing the outputs of multiple models and feeding them into the fusion module, we can expect that the fused framework can benefit from different models simultaneously. Fusing diverse models should lead to a large amount of combined pretrained knowledge being covered, which in turn might help achieve better results on the OOD task. In this paper, we introduce our proposed fusion model framework. To achieve good evaluation results, we have experimented with a number of different strategies and finally proposed an effective model fusion approach. Compared with the simple fusion method where SSL output features are directly fed to a linear regression layer, our proposed model fusion approach achieves better performance on both the main track and OOD track. Our model fusion approach has a significant impact on the OOD track, where we observed that comprehensive performance improves at the expense of system-level SRCC scores. According to the official analysis results, our system (T11) ranks first on 6 out of all 16 evaluation metrics and is one of the top 3 ranked systems on 13 out of the 16 metrics. On the main track, we have better performance at the system level, while on the OOD track, we are better at the utterance level. \iffalse \begin{figure*}[ht] \centering \includegraphics[scale=0.5]{model.pdf} \caption{The flowchart of the proposed method: (a) overall structure of fusion model, (b) SSL-MOS sub-systems, (c) model fuser.}\vspace{-0.5cm} \label{fig:model} \end{figure*} \fi \section{Proposed Approach} We describe the SSL model fusion approach (fusion model) as well as a secondary approach involving fine-tuning SSL models. \subsection{Fusion Model} The proposed fusion model method consists of 2 separate parts: SSL-MOS sub-systems and a model fuser (as shown in Figure \ref{fig:model}). The challenge organizers offer a MOS scoring framework based on the self-supervised pretrained model. It fine-tunes various pretrained SSL models such as Wav2Vec 2.0 and HuBERT by mean-pooling the model’s output embeddings, adding a linear output layer, and training with the L1 loss~\cite{cooper2021generalization}. Initially, we have tried to modify the fully connected layer of this sub-system, attempting to transform the regression problem in the original model into a classification problem. However, no satisfactory results were obtained, so this paper follows the original framework as a subsystem (as shown in the Figure~\ref{fig:model} (b)). Several newly developed self-supervised pretrained models are selected and experimented as MOS-scoring subsystems. Through each subsystem, MOS scores have been predicted. Although they do not show very significant differences in evaluating metrics such as MSE at the macro level, some deviations can be found in their specific scoring. By looking at the MOS scores, it can be assumed that each sub-system captures different information from the training dataset. So the question that naturally arises is: how to combine these scores in order to get more information from the training set? Several model fusion methods have been tested for the MOS scores combination target. By analyzing the performance of the fusion methods, a simple yet effective model fuser has been proposed. A 2-layer model has been designed (as shown in the Figure~\ref{fig:model} (c)), consisting of a fully connected layer without bias for capturing the weighted information and a linear function for obtaining the residual information between ground truth and the predicted scores after a fully connected layer. \begin{figure}[t] \includegraphics[scale=0.35]{model3.pdf} \caption{The flowchart of the proposed method: (a) overall structure of fusion model, (b) SSL-MOS sub-systems, (c) model fuser.}\vspace{-0.5cm} \label{fig:model} \end{figure} \subsection{Fine-tuning SSL Models With ASR Evaluation} In addition to the method above, we also seek to use the text for generating the synthesized speech as additional information to improve the accuracy of MOS prediction. The intuition is that the better the quality of the synthesized speech, the easier an ASR (Automatic Speech Recognition) system trained on human speech data can recognize the synthesized speech. However, only using ASR evaluation metrics such as Character Error Rate (CER) as inputs does not produce satisfactory results on MOS prediction because the correlation between MOS and ASR accuracy is relatively weak. We instead combine them with the method of fine-tuning SSL models. The system is a modified version of the sub-system in Figure~\ref{fig:model} (b) and its structure is shown in Figure~\ref{model_cer}. We first perform ASR with different pretrained models without fine-tuning on the MOS dataset. Then the model takes both the speech and ASR evaluation scores as inputs and takes the MOS as outputs. Similar to the fine-tuned SSL method, the model contains a pretrained SSL model to transform the speech input into contextual representation. The representation and the ASR evaluation scores then go through two separate linear layers and produce two 1-dimensional outputs. These two outputs are concatenated into a vector and go through another linear layer to predict the MOS. \begin{figure}[t] \vspace{-0.2cm} \includegraphics[scale=0.5]{model_cer.pdf}\vspace{-0.5cm} \caption{Framework for fine-tuning SSL models with ASR evaluation scores.} \label{model_cer} \vspace{-0.6cm} \end{figure} \iffalse \begin{figure} \includegraphics[scale=0.5]{w2vb100_cer_mos.pdf}\vspace{-2cm} \caption{MOS and CER of the ASR results on training set. The ASR model used is Wav2Vec 2.0 Base, which is fine-tuned on 100-hours of labeled data.} \label{cer_mos} \end{figure} \vspace{-2cm} \fi \section{Datasets} The datasets, which are divided into a main track and an “out-of-domain” (OOD) sub-track~\cite{huang2022voicemos}, are provided by the VoiceMOS competition organizers. \subsection{Main Track} The samples of the main track dataset come from a collection of Blizzard Challenges (BC) ~\cite{karaiskos2008blizzard,kinga2009blizzard,King2010TheBC,King2011TheBC,King2012TheBC,King2013TheBC,King2016TheBC} and Voice Conversion Challenges (VCC)~\cite{toda2016voice,wester2016analysis,lorenzo2018voice,yi2020voice,zhao2020voice}, as well as published samples from ESPnet-TTS~\cite{watanabe2018espnet}. The main track data is in English and consists of 4,974 examples for training, 1,066 examples for validation, and 1,066 examples for testing (the label of the test dataset was not revealed until the end of the VoiceMOS Challenge). There are 33 types of MOS scores on the main track, with scores ranging from 1 to 5 in steps of 0.125. \subsection{Out-of-domain Track} The out-of-domain (OOD) track is intended to test the generalization ability of the model. The samples of the OOD track come from the listening test of the Blizzard Challenge 2019~\cite{wu2019blizzard} (the audio samples from this challenge were not included in our main track listening test). Different from the main track, the OOD track data is in Chinese. It has provided 136 labeled examples for training, 136 examples for validation, and 540 examples for testing (the label of the test dataset was not revealed until the end of the VoiceMOS Challenge). Moreover, 540 unlabeled examples are provided for training as well. Note that the MOS scores of the labeled samples in the OOD track cannot be categorized into 33 types like the main track. This is one of the reasons why we don't use the classification method as our sub-system. Figure~\ref{fig:data} shows the MOS score distributions on both tracks. \begin{figure}[t] \vspace{-0.2cm} \includegraphics[scale=0.4]{distribution.pdf} \caption{The MOS score distributions: (a) training dataset of the main track, (b) evaluation dataset of the main track, (c) training dataset of the OOD track, (d) evaluation dataset of the OOD track.} \label{fig:data} \vspace{-0.6cm} \end{figure} \section{Experiments} \label{sec:exp-con} \begin{table*}[!t] \footnotesize \centering \caption{Results on the main track. Models finally selected for fusion are marked in bold.}\vspace{-0.3cm} \label{tab_ssl} \begin{tabular}{l|rrrr|rrrr} \hline \multicolumn{9}{c}{\small (a) Results of fine-tuning different pretrained SSL models individually for MOS prediction.}\\ \hline & \multicolumn{4}{c}{ Utterance level } & \multicolumn{4}{|c}{ System level } \\ Pretrained SSL Model & MSE & LCC & SRCC & KTAU & MSE & LCC & SRCC & KTAU \\ \hline \textbf{W2V 2.0 Base} & $0.235$ & $0.875$ & $0.878$ & $0.707$ & $0.094$ & $0.935$ & $0.941$ & $0.803$ \\ \textbf{W2V 2.0 Large} & $0.197$ & $0.875$ & $0.873$ & $0.697$ & $0.068$ & $0.948$ & $0.953$ & $0.820$ \\ \textbf{W2V 2.0 Large (LV-60)} & \boldmath{$0.191$} & $0.878$ & $0.878$ & $0.704$ & \boldmath{$0.060$} & \boldmath{$0.950$} & $0.953$ & $0.823$ \\ \textbf{HuBERT Base} & $0.207$ & $0.878$ & $0.876$ & $0.700$ & $0.077$ & $0.944$ & $0.947$ & $0.812$ \\ HuBERT Large & $0.288$ & $0.813$ & $0.809$ & $0.623$ & $0.103$ & $0.923$ & $0.924$ & $0.757$ \\ HuBERT Extra Large & $0.229$ & $0.852$ & $0.849$ & $0.666$ & $0.082$ & $0.930$ & $0.931$ & $0.777$\\ \textbf{WavLM Base} & $0.199$ & \boldmath{$0.891$} & \boldmath{$0.891$} & \boldmath{$0.722$} & $0.072$ & $0.949$ & $0.954$ & $0.828$ \\ \textbf{WavLM Base+} & $0.248$ & $0.879$ & $0.883$ & $0.709$ & $0.115$ & $0.948$ & \boldmath{$0.958$} & \boldmath{$0.832$} \\ \textbf{WavLM Large} & $0.192$ & $0.876$ & $0.872$ & $0.695$ & $0.063$ & \boldmath{$0.950$} & $0.952$ & $0.827$ \\ Data2Vec & $0.314$ & $0.826$ & $0.842$ & $0.660$ & $0.144$ & $0.905$ & $0.931$ & $0.779$ \\ \hline \multicolumn{9}{c}{\small (b) Results on the main track validation set with different fusion methods. }\\ \hline & \multicolumn{4}{c}{ Utterance level } & \multicolumn{4}{|c}{ System level } \\ Fusion Method & MSE & LCC & SRCC & KTAU & MSE & LCC & SRCC & KTAU \\ \hline LightGBM & $0.187$ & $0.885$ & $0.883$ & $0.709$ & $0.055$ & $0.953$ & $0.956$ & $0.827$ \\ Neural Networks & $0.172$ & $0.890$ & $0.891$ & $0.719$ & $0.055$ & $0.956$ & $0.960$ & $0.840$ \\ Voting & $0.167$ & \boldmath{$0.902$} & \boldmath{$0.902$} & \boldmath{$0.736$} & $0.054$ & $0.957$ & $0.961$ & $0.848$ \\ Weighted Voting & $0.164$ & $0.898$ & $0.897$ & $0.728$ & \boldmath{$0.049$} & $0.958$ & $0.961$ & $0.845$ \\ Linear Regression & $0.160$ & $0.898$ & $0.898$ & $0.730$ & $0.052$ & \boldmath{$0.961$} & \boldmath{$0.965$} & \boldmath{$0.853$} \\ \textbf{Linear Regression (features)} & \boldmath{$0.154$} & \boldmath{$0.902$} & $0.901$ & $0.735$ & $0.057$ & $0.956$ & $0.957$ & $0.841$ \\ \textbf{Proposed Model Fuser} & $0.156$ & \boldmath{$0.902$} & $0.901$ & $0.735$ & $0.051$ & $0.960$ & $0.962$ & $0.848$ \\ Linear Regression (with CER) & $0.160$ & $0.899$ & $0.898$ & $0.730$ & $0.053$ & $0.960$ & $0.964$ & $0.851$\\ Proposed Model Fuser (with CER) & $0.157$ & $0.901$ & $0.901$ & $0.734$ & $0.055$ & $0.958$ & $0.963$ & $0.850$ \\ \hline \end{tabular} \vspace{-0.3cm} \end{table*} \iffalse \begin{table*}[!t] \centering \caption{Results of fine-tuning different pretrained SSL models individually for MOS prediction. Models finally selected for fusion are marked in bold.}\vspace{-0.3cm} \label{tab_ssl} \begin{tabular}{l|rrrr|rrrr} \hline & \multicolumn{4}{c}{ Utterance level } & \multicolumn{4}{|c}{ System level } \\ Pretrained SSL Model & MSE & LCC & SRCC & KTAU & MSE & LCC & SRCC & KTAU \\ \hline \textbf{W2V 2.0 Base} & $0.235$ & $0.875$ & $0.878$ & $0.707$ & $0.094$ & $0.935$ & $0.941$ & $0.803$ \\ \textbf{W2V 2.0 Large} & $0.197$ & $0.875$ & $0.873$ & $0.697$ & $0.068$ & $0.948$ & $0.953$ & $0.820$ \\ \textbf{W2V 2.0 Large (LV-60)} & \boldmath{$0.191$} & $0.878$ & $0.878$ & $0.704$ & \boldmath{$0.060$} & \boldmath{$0.950$} & $0.953$ & $0.823$ \\ \textbf{HuBERT Base} & $0.207$ & $0.878$ & $0.876$ & $0.700$ & $0.077$ & $0.944$ & $0.947$ & $0.812$ \\ HuBERT Large & $0.288$ & $0.813$ & $0.809$ & $0.623$ & $0.103$ & $0.923$ & $0.924$ & $0.757$ \\ HuBERT Extra Large & $0.229$ & $0.852$ & $0.849$ & $0.666$ & $0.082$ & $0.930$ & $0.931$ & $0.777$\\ \textbf{WavLM Base} & $0.199$ & \boldmath{$0.891$} & \boldmath{$0.891$} & \boldmath{$0.722$} & $0.072$ & $0.949$ & $0.954$ & $0.828$ \\ \textbf{WavLM Base+} & $0.248$ & $0.879$ & $0.883$ & $0.709$ & $0.115$ & $0.948$ & \boldmath{$0.958$} & \boldmath{$0.832$} \\ \textbf{WavLM Large} & $0.192$ & $0.876$ & $0.872$ & $0.695$ & $0.063$ & \boldmath{$0.950$} & $0.952$ & $0.827$ \\ Data2Vec & $0.314$ & $0.826$ & $0.842$ & $0.660$ & $0.144$ & $0.905$ & $0.931$ & $0.779$ \\ \hline \end{tabular} \vspace{-0.3cm} \end{table*} \begin{table*}[!t] \centering \caption{Results on the main track validation set with different fusion methods. Submission versions are marked in bold.} \vspace{-0.3cm} \label{tab_fusion_main} \begin{tabular}{l|rrrr|rrrr} \hline & \multicolumn{4}{c}{ Utterance level } & \multicolumn{4}{|c}{ System level } \\ Fusion Method & MSE & LCC & SRCC & KTAU & MSE & LCC & SRCC & KTAU \\ \hline LightGBM & $0.187$ & $0.885$ & $0.883$ & $0.709$ & $0.055$ & $0.953$ & $0.956$ & $0.827$ \\ Neural Networks & $0.172$ & $0.890$ & $0.891$ & $0.719$ & $0.055$ & $0.956$ & $0.960$ & $0.840$ \\ Voting & $0.167$ & \boldmath{$0.902$} & \boldmath{$0.902$} & \boldmath{$0.736$} & $0.054$ & $0.957$ & $0.961$ & $0.848$ \\ Weighted Voting & $0.164$ & $0.898$ & $0.897$ & $0.728$ & \boldmath{$0.049$} & $0.958$ & $0.961$ & $0.845$ \\ Linear Regression & $0.160$ & $0.898$ & $0.898$ & $0.730$ & $0.052$ & \boldmath{$0.961$} & \boldmath{$0.965$} & \boldmath{$0.853$} \\ \textbf{Linear Regression (featrues)} & \boldmath{$0.154$} & \boldmath{$0.902$} & $0.901$ & $0.735$ & $0.057$ & $0.956$ & $0.957$ & $0.841$ \\ \textbf{Proposed Model Fuser} & $0.156$ & \boldmath{$0.902$} & $0.901$ & $0.735$ & $0.051$ & $0.960$ & $0.962$ & $0.848$ \\ Linear Regression (with CER) & $0.160$ & $0.899$ & $0.898$ & $0.730$ & $0.053$ & $0.960$ & $0.964$ & $0.851$\\ Proposed Model Fuser (with CER) & $0.157$ & $0.901$ & $0.901$ & $0.734$ & $0.055$ & $0.958$ & $0.963$ & $0.850$ \\ \hline \end{tabular} \vspace{-0.3cm} \end{table*} \fi \subsection{Fusion Model: Performance On Main Track} \label{subsec:mod_fu} For the main track, we first examined 10 pretrained SSL models~\cite{baevski2020wav2vec,chen2021wavlm,hsu2021hubert,chen2021wavlm,baevski2022data2vec} for MOS prediction individually, and the results are shown in Table~\ref{tab_ssl} (a). And then 7 well-performed SSL models (Wav2Vec 2.0 Base, Wav2Vec 2.0 Large, Wav2Vec 2.0 (LV-60), HuBERT Base, WavLM Base, WavLM Base+ and WavLM Large) are chosen for model fusion. In the preparation stage, each sub-system is firstly fine-tuned independently on the same training dataset. During the fine-tuning period, the L1 loss is used, and the model is trained for 1,000 epochs with a batch size of 1 and a learning rate of 0.0001, and early stopping is adopted if the loss hasn’t decreased for 20 epochs. Then, the model with the lowest validation loss is chosen. Next, five basic fusion methods (voting, weighted voting, neural networks, linear regression, and random forests (LightGBM~\cite{ke2017lightgbm} in particular)) have been tested as the model fuser (as shown in the Table~\ref{tab_ssl} (b)). The weights in weighted voting are learned during training. And the neural networks use Sigmoid as activation function. From the results, we found voting is better than LightGBM and neural networks with the sigmoid activation function, which indicates that the non-linear information is less significant than linear information. We also found weighted voting performs better than voting, from which we can infer that the contribution of different sub-models to the overall score is different. In addition, linear regression is better than weighted voting, we suppose that linear regression might be able to retain the residual information of the ground truth. Our model fuser is implemented based on the above descriptions. \begin{figure}[!t] \includegraphics[scale=0.3]{ood_implementation4.pdf} \caption{Implementation details of our proposed approach: (a) main track fusion model, (b) OOD track fusion model \uppercase\expandafter{\romannumeral1}, (c) OOD track fusion model \uppercase\expandafter{\romannumeral2}} \label{implementation_details} \vspace{-0.5cm} \end{figure} The above model fuser is an attempt to use the MOS scores predicted by each sub-model. However, each sub-system would compress the information of the latent features obtained from the SSL pretrained model in the process of predicting MOS scores. Therefore, we also tried to directly concatenate output features of each SSL pre-model and then run regression. In the challenge, we submitted the results of both versions of the model fusion strategy and ultimately chose our model fuser since it gives better overall performance. \begin{table*}[!t] \small \centering \caption{Results on the OOD track with different fusion methods. Submission versions are marked in bold.} \vspace{-0.3cm} \label{tab_fusion_ood} \begin{tabular}{lc|rrrr|rrrr} \hline & & \multicolumn{4}{c}{ Utterance level } & \multicolumn{4}{|c}{ System level } \\ Fusion Method & Unlabeled data & MSE & LCC & SRCC & KTAU & MSE & LCC & SRCC & KTAU \\ \hline Voting & - & $0.169$ & $0.892$ & $0.783$ & $0.597$ & $0.050$ & $0.978$ & $0.948$ & $0.812$ \\ Linear Regression & - & $0.176$ & $0.886$ & $0.768$ & $0.584$ & $0.040$ & $0.979$ & $0.947$ & $0.819$ \\ Linear Regression (features) & - & $0.166$ & $0.893$ & $0.783$ & $0.598$ & $0.039$ & $0.981$ & $0.956$ & $0.841$ \\ Proposed Model Fuser & - & $0.171$ & $0.890$ & $0.779$ & $0.595$ & $0.039$ & $0.979$ & $0.959$ & $0.833$ \\ Voting & $\surd$ & $0.159$ & \boldmath{$0.903$} & $0.796$ & $0.609$ & $0.051$ & $0.981$ & $0.961$ & $0.845$ \\ Linear Regression & $\surd$ & $0.155$ & $0.900$ & \boldmath{$0.804$} & \boldmath{$0.619$} & $0.042$ & $0.980$ & $0.957$ & $0.833$ \\ \textbf{Linear Regression (features)} & $\surd$ & $0.158$ & $0.898$ & $0.791$ & $0.608$ & $0.040$ & \boldmath{$0.982$} & \boldmath{$0.969$} & \boldmath{$0.870$} \\ \textbf{Proposed Model Fuser} & $\surd$ & \boldmath{$0.149$} & \boldmath{$0.903$} & $0.790$ & $0.604$ & \boldmath{$0.036$} & \boldmath{$0.982$} & $0.958$ & $0.841$ \\ \hline \end{tabular} \end{table*} \subsection{Semi-Supervised Approach: OOD Track Performance} \begin{table*}[!t] \small \centering \vspace{-0.1cm} \caption{Results on the validation set with different sets of CERs as inputs. To obtain CERs, eight Wav2Vec 2.0 models fine-tuned for the ASR task are used to conduct ASR, including 4 different model settings (Wav2Vec 2.0 Base, Wav2Vec 2.0 Large, Wav2Vec 2.0 Large LV-60 and Wav2Vec 2.0 Large LV-60 with self-training) and 2 different fine-tuning data settings (100 hours and 960 hours of Librispeech data). We experimented with using single or multiple CER inputs (predicted by two Wav2Vec 2.0 Base models, 4 models fine-tuned on 100 hours of Librispeech data or all of the 8 models). Wav2Vec (W2V) 2.0 base is used as the pretrained SSL model. (Note that the pretrained SSL model is different from the ASR model.)}\vspace{-0.3cm} \label{tab_cer} \begin{tabular}{l|rrrr|rrrr} \hline & \multicolumn{4}{c}{ Utterance level } & \multicolumn{4}{|c}{ System level } \\ ASR Models & MSE & LCC & SRCC & KTAU & MSE & LCC & SRCC & KTAU \\ \hline W2V 2.0 Base (100h) & \boldmath{$0.184$} & $0.882$ & $0.883$ & $0.709$ & \boldmath{$0.067$} & \boldmath{$0.948$} & \boldmath{$0.952$} & \boldmath{$0.823$} \\ W2V 2.0 Base (960h) & $0.209$ & $0.874$ & $0.872$ & $0.697$ & $0.085$ & $0.935$ & $0.938$ & $0.798$ \\ 2 models (W2V 2.0 Base) & $0.209$ & \boldmath{$0.886$} & \boldmath{$0.886$} & \boldmath{$0.714$} & $0.086$ & $0.947$ & $0.948$ & $0.817$ \\ 4 models (100h) & $0.255$ & $0.865$ & $0.875$ & $0.702$ & $0.114$ & $0.923$ & $0.943$ & $0.803$ \\ 8 models & $0.247$ & $0.881$ & $0.880$ & $0.704$ & $0.136$ & $0.933$ & $0.933$ & $0.797$ \\ \hline \end{tabular} \vspace{-0.1cm} \end{table*} \begin{table*}[!t] \footnotesize \centering \caption{SRCC in utterance-level (UTT) and system-level (SYS) for the combination of different pretrained SSL models and ASR models. The results that are better than the baseline (finetuned SSL models without ASR evaluation) are marked in bold.}\vspace{-0.3cm} \label{tab_comb} \begin{tabular}{l|rr|rr|rr} \hline & \multicolumn{6}{c}{ ASR Model } \\ Pretrained SSL Model & \multicolumn{2}{c}{W2V 2.0 Base (100h)} & \multicolumn{2}{|c}{W2V 2.0 Large (100h)} & \multicolumn{2}{|c}{W2V 2.0 Large (LV-60) (100h)} \\ & UTT & SYS & UTT & SYS & UTT & SYS \\ \hline W2V 2.0 Base & \boldmath{$0.883$} & \boldmath{$0.952$} & \boldmath{$0.881$} & $0.936$ & $0.871$ & $0.935$ \\ W2V 2.0 Large & $0.846$ & $0.936$ & \boldmath{$0.878$} & \boldmath{$0.955$} & \boldmath{$0.886$} & $0.935$ \\ W2V 2.0 Large (LV-60) & $0.813$ & $0.892$ & $0.876$ & $0.951$ & $0.829$ & $0.930$ \\ HuBERT Base & $0.858$ & $0.938$ & $0.872$ & \boldmath{$0.954$} & $0.872$ & $0.943$ \\ WavLM Base & $0.880$ & $0.939$ & $0.880$ & $0.944$ & $0.884$ & $0.942$ \\ WavLM Base+ & $0.866$ & $0.935$ & $0.871$ & $0.942$ & $0.876$ & $0.936$ \\ WavLM Large & $0.868$ & $0.942$ & $0.864$ & $0.949$ & $0.869$ & \boldmath{$0.954$} \\ \hline \end{tabular} \vspace{-0.3cm} \end{table*} Because the OOD track contains unlabeled data, we attempted to predict the MOS scores of the OOD data by a semi-supervised learning method. As shown in the Figure~\ref{implementation_details}, the method consists of 4 steps: (1) We train our proposed system with the main track data to obtain system $a$. (2) We fine-tune the sub-systems trained in step 1 (referred to as the main track sub-systems) with only labeled OOD data and conduct model fusion with the fine-tuned sub-systems to obtain system $b$. (3) We feed the unlabeled data to system $b$ and obtain MOS scores to label them. (4) We combine the newly-labeled data in step 3 with the labeled OOD data to create a new OOD training dataset, with which we fine-tune the main track sub-systems and conduct model fusion again to obtain system $c$. MOS scores predicted by system $a$ are used for the main track and MOS scores predicted by system $c$ are used for the OOD track. Table~\ref{tab_fusion_ood} shows the results of various fusion model methods with semi-supervised learning versus those with no unlabeled data at all. It can be noticed that our semi-supervised approach improves the performance significantly. \subsection{Fine-tuning SSL Models With ASR Evaluation} We used CER to evaluate the accuracy of the ASR output and experimented with using single or multiple CER results produced by different ASR models, as shown in Table~\ref{tab_cer}. The results indicate that using a single CER input is generally better than using multiple CER inputs. We have examined different combinations of SSL models and ASR models, as shown in Table~\ref{tab_comb}. The results show that not every combination can improve the performance compared to the baseline (fine-tuned SSL models without ASR evaluation), which might be the reason behind the inferior performance of using multiple CER inputs. Note that the performance tends to be better when the same architecture is used for the pretrained SSL model and the ASR model. We finally picked out two combinations with better performance (Wav2Vec 2.0 Base with Wav2Vec 2.0 Base 100h as ASR model, Wav2Vec 2.0 Large with Wav2Vec 2.0 Large 100h as ASR model) together with other five fine-tuned SSL models without ASR evaluation for model fusion. However, the results in Table~\ref{tab_ssl} (b) shows that the fusion result is not improved compared to that without ASR evaluation involved, and the reason needs to be further investigated. \iffalse \begin{table*}[] \centering \begin{tabular}{l|llll|lllll} \hline & \multicolumn{4}{|c}{ Utterance level } & \multicolumn{4}{c}{ System level } \\ Model & MSE & LCC & SRCC & KTAU & MSE & LCC & SRCC & KTAU \\ \hline Pretrained 2 & $0.831$ & $0.374$ & $0.393$ & $0.275$ & $0.541$ & $0.354$ & $0.352$ & $0.243$ \\ From scratch & $0.777$ & $0.304$ & $0.261$ & $0.178$ & $0.504$ & $0.239$ & $0.181$ & $0.117$ \\ Fine-tuned & $0.417$ & $0.715$ & $0.711$ & $0.529$ & $0.162$ & $0.852$ & $0.862$ & $0.663$ \\ FT+sil.aug & $0.428$ & $0.713$ & $0.709$ & $0.528$ & $0.153$ & $0.854$ & $0.861$ & $0.665$ \\ FT+speed aug & $0.421$ & $0.716$ & $0.707$ & $0.526$ & $0.176$ & $0.857$ & $0.867$ & $0.672$ \\ FT+both aug & $\mathbf{0 . 3 0 5}$ & $\mathbf{0 . 7 9 6}$ & $\mathbf{0 . 7 9 1}$ & $\mathbf{0 . 6 0 4}$ & $\mathbf{0 . 0 9 6}$ & $\mathbf{0 . 9 0 5}$ & $\mathbf{0 . 9 1 2}$ & $\mathbf{0 . 7 3 7}$ \\ \hline \end{tabular} \caption{MOSNet BVCC results} \label{tab:my_label} \end{table*} \fi \section{Conclusion} \label{sec:con} For the MOS 2022 challenge, we have experimented with a number of different strategies and finally proposed an effective fusion model. For the main track, we selected 7 pretrained SSL models as sub-systems and designed a simple yet effective model fuser based on the analysis of five model fusion methods. For the OOD track, we followed the 7 SSL models chosen on main track and adopted a semi-supervised learning method which has improved the performance significantly. Our final submission uses model fuser to fuse 7 subsystems on main track and uses the semi-supervised learning method on OOD track. We also attempted to utilize text information by fine-tuning SSL models with ASR evaluation. Our systems ranked first in 6 out of 16 evaluation metrics over all tracks. Furthermore, in 13 out of 16 metrics, our systems were one of the top 3 ranked ones. \newpage \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:31:24', 'yymm': '2204', 'arxiv_id': '2204.04855', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04855'}
arxiv
\section{Introduction} Extracting structured knowledge from unstructured text is an important task for knowledge discovery and management. Biomedical literature and clinical narratives offer rich interactions between entities mentioned in the text~\cite{craven1999constructing,xu2014automatic}, which can be useful for applications such as bio-molecular information extraction, pharmacogenomics, and identifying drug-drug interactions (DDIs), among others~\cite{luo2017bridging}. Manually annotating these relations for training supervised learning systems is an expensive and time-consuming process~\cite{segura20111st,kilicoglu2011constructing,segura2013semeval,li2016biocreative}, so the task often involves leveraging rule-based~\cite{abacha2011automatic,kilicoglu2020broad} and weakly supervised approaches~\cite{peng2016improving,dai2019distantly}. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{ccccc} \toprule \multirow{2}{*}{\bf Model and Data} & \multicolumn{2}{c}{\bf{Original}} & \multicolumn{2}{c}{\bf{Filtered}}\\ & \textbf{AUC} & \textbf{F1} & \textbf{AUC} & \textbf{F1} \\ \midrule \citet{amin2020data} & 68.4 & 64.9 & 50.8 & 53.1 \\ \citet{hogan2021abstractified} & 82.6 & 77.6 & 11.8 & 19.8 \\ \bottomrule \end{tabular} } \caption{ Two state-of-the-art Bio-DSRE models evaluated on the respective datasets before~(Original) and after~(Filtered) removing test relationships also appearing in the training set. % Both models were trained and evaluated at \emph{bag-level}. } \label{table:fixed_results} \end{table} More recently, \citet{amin2020data} and \citet{hogan2021abstractified} used domain-specific language models~\cite{gu2021domain} that were pre-trained on biomedical data for Bio-DSRE, producing significantly more accurate results when compared with recent results in the general domain~\cite{gao-etal-2021-manual,christopoulou2021distantly,10.1145/3404835.3463103}. In this work, we find that these results can be largely attributed to the overlap between the training and the test sets, which allows the model to score higher by simply memorizing the training relations rather than generalizing to new, previously unknown ones. In \cref{table:fixed_results}, we show that removing this leakage (51.9\%, \cref{table:leakage_stats}) results in a significant decrease in predictive accuracy. For example, the AMIL model with relation type embedding $L$ proposed by \citet{hogan2021abstractified} achieves an 82.6 AUC when evaluated on their Bio-DSRE dataset, while producing an 11.8 AUC when evaluated on the subset of the test set of relationships that do not overlap with the training set. The training-test overlap in the datasets proposed by \citet{hogan2021abstractified} and \citet{amin2020data} is due to the same entities appearing with different names in multiple relationships, although two entity names are mapped to the same UMLS concept \cite{bodenreider2004unified}, they are still treated as two distinct entities. Furthermore, we also identified other problems, such as redundant facts, and unclear coverage of UMLS concepts. To mitigate these issues and noting the lack of existing best practices and an agreed upon benchmark for the Bio-DSRE research, we introduce a new benchmark to fill this gap With widespread use of the SNOMED CT in healthcare systems, we follow the guidelines outlined by \citet{chang-etal-2020-benchmark} for benchmarking biomedical link prediction models, and propose a considerably challenging Bio-DSRE dataset \textsc{MedDistant19}\xspace. \begin{table}[!t] \centering \resizebox{7.5cm}{!}{ \begin{tabular}{rccc} \toprule \textbf{\bf Triples} & \textbf{Train} & \textbf{Valid} & \textbf{Test} \\ \midrule Textual & 92,972 & 13,555 (51.9\%) & 33,888 (51.2\%) \\ CUI & 211,789 & 41,993 (26.7\%) & 89,486 (26.5\%) \\ \bottomrule \end{tabular} } \caption{ Training-test leakage we identified in the data constructed and used by \citet{amin2020data}~(see their Appendix~A.4 in their \emph{k-tag} setup). % Numbers between parentheses show the percentage overlap, where the authors considered text-based instead of CUI-based triples. } \label{table:leakage_stats} \end{table} \section{Related Work} Relation Extraction~(RE) is an important task in biomedical applications. Traditionally, supervised methods require large-scale annotated corpora, which is impractical to scale for broad-coverage biomedical relation extraction ~\cite{kilicoglu2011constructing,kilicoglu2020broad}. In cases where such supervision is available, it is limited to protein-protein interactions~\cite{peng2017deep}, drug-drug interactions~\cite{kavuluru2017extracting}, and chemical-disease interactions~\cite{peng2016improving}. Distant Supervision~(DS) allows for the automated collection of noisy training examples~\cite{mintz2009distant} by aligning a given knowledge base~(KB) with a collection of text sources. DS was used in recent works \cite{alt2019fine} using Multi-Instance Learning~(MIL) by creating \emph{bags} of instances~\cite{riedel2010modeling} for corpus-level triple extraction.\footnote{RE is used to refer to two different tasks: sentence-level detection of relational instances and corpus-level triples extraction, a kind of knowledge completion task \cite{ji2021survey}.} \begin{figure}[!t] \includegraphics[width=1.0\linewidth]{figures/fig_bag_example_v2.pdf} \centering \caption{ An example of a bag instance representing the UMLS concept pair~(\texttt{C0240066}, \texttt{C0085576}) from the \textsc{MedDistant19}\xspace dataset, expressing the relation \textit{cause\_of}. % In this example, three out of six sentences express the relation, while others are incorrect labels resulting from the distant supervision. } \label{fig:bag_example} \end{figure} \citet{dai2019distantly} introduced the use of the Unified Medical Language System~(UMLS) Metathesaurus~\cite{bodenreider2004unified} as a KB with PubMed~\cite{canese2013pubmed} MEDLINE abstracts as text collection, and implemented a knowledge-based attention mechanism~\cite{han2018neural} for joint learning with knowledge graph completion using SimplE~\cite{kazemi2018simple} embeddings and entity type classification. Their pipeline was simplified by \citet{amin2020data}, who extended R-BERT~\cite{wu2019enriching} to handle bag-level MIL, and demonstrated that preserving the direction of the relationships improves the accuracy of the model. Lacking benchmark corpora, \citet{amin2020data} also outlined the steps to create the dataset. Similar steps were followed by \citet{hogan2021abstractified}, who introduced the concept of \emph{abstractified} MIL~(AMIL), by including different argument pairs belonging to the same semantic types (see \cref{fig:ent_types}) pair in one bag, boosting performance on rare-triples. \begin{figure*} \includegraphics[width=0.75\linewidth]{figures/fig_hierarchical_types} \centering \caption{Type Hierarchy: each concept in the UMLS is classified under a type taxonomy. % The \emph{coarse-grained} and \emph{fine-grained} entity types are referred to as \textbf{Semantic Group~(SG)} and \textbf{Semantic Type~(STY)} respectively. } \label{fig:ent_types} \end{figure*} In this work, we investigate recent results from the Bio-DSRE literature by probing the respective datasets for overlaps between training and test sets. We found a significant overlap between the training set and the held-out validation and test sets in the dataset constructed by \citet{amin2020data} and \citet{hogan2021abstractified} (\cref{table:leakage_stats}). Our inspection revealed concept normalization to be the root cause, where in UMLS, each concept is mapped to a \textit{Concept Unique Identifier (CUI)} and a given CUI might have different surface forms~\cite{bodenreider2004unified}. Consider a relationship between a pair of UMLS entities (\texttt{C0013798}, \texttt{C0429028}). These two entities can appear in different forms within a text, such as (\emph{electrocardiography}, \emph{Q-T interval}), (\emph{ECG}, \emph{Q-T interval}), and (\emph{EKG}, \emph{Q-T interval}); each of these distinct pairs still refers to the same original pair (\texttt{C0013798}, \texttt{C0429028}). \citet{amin2020data} claim no such text-based leakage, but when canonicalized to their CUIs this results in leakage across the splits as reported in \cref{table:leakage_stats}. Due to these inconsistencies and lack of benchmark and best practices, we introduce the \textsc{MedDistant19}\xspace dataset. Our work utilizes the SNOMED CT Knowledge Graph~(KG), extracted from UMLS, that offers a careful selection of the concept types and proper handling of the inverse relations ~\cite{chang-etal-2020-benchmark}. The dataset focuses on rare-triples and considers a narrower subset of the relations. \section{Constructing the MedDistant19 Dataset} \label{sec:md19_construction} \paragraph{Documents} We used PubMed MEDLINE abstracts published up to 2019\footnote{\url{https://lhncbc.nlm.nih.gov/ii/information/MBR/Baselines/2019.html}} as our text source, containing 32,151,899 abstracts. Following \citet{hogan2021abstractified}, we used \textsc{ScispaCy}~\cite{neumann-etal-2019-scispacy} for sentence tokenization, resulting in 150,173,169 unique sentences. In this work, we further introduce the use of a specialized UMLS entity linker from \textsc{ScispaCy}~\footnote{\url{https://github.com/allenai/scispacy}}, since named entity recognition and normalization has been shown to be the largest source of errors in biomedical RE~\cite{kilicoglu2020broad}. We used the default settings in \textsc{SciSpaCy} for linking entity mentions to their UMLS CUIs, and filtering disabled concepts from UMLS. This resulted in the entity linked mentions at the sentence level. \paragraph{Knowledge Base} We use UMLS2019AB~\footnote{\url{https://download.nlm.nih.gov/umls/kss/2019AB/umls-2019AB-full.zip}} as our main knowledge source and apply a set of rules, resulting in a distilled and carefully reduced version of UMLS2019AB. The UMLS Metathesaurus~\cite{bodenreider2004unified} covers concepts from 222 source vocabularies, thus being the largest ontology of biomedical concepts. However, covering all ontologies can be challenging given the interchangeable nature of the concepts. For example, \emph{programmed cell death 1 ligand 1} is an alias of concept \texttt{C1540292} in the HUGO Gene Nomenclature Committee ontology~\citep{hgnc}, and it is an alias of concept \texttt{C3272500} in the National Cancer Institute Thesaurus. This makes entity linking more challenging, since a surface form can be linked to multiple entity identifiers, and makes it easier to have overlaps between training and test set, since the same fact may appear in both with different entity identifiers. Furthermore, benchmark corpora for biomedical Named Entity Recognition~\cite{dougan2014ncbi,li2016biocreative} and RE~\cite{herrero2013ddi,krallinger2017overview} focuses on specific entity types~(e.g.\@\xspace diseases, chemicals, proteins), and are usually normalized to a single ontology~\cite{kilicoglu2020broad}. Following this trend, we also focus on a single vocabulary for Bio-DSRE. We use SNOMED CT, which is the most widely used clinical terminology in the world for documentation and reporting in healthcare~\cite{chang-etal-2020-benchmark}. \begin{table} \centering \resizebox{7.0cm}{!}{ \begin{tabular}{rcc} \toprule \textbf{Properties} & \textbf{Prior} & \textbf{MD19} \\ \midrule \textit{approximate entity linking} & & \cmark \\ \textit{unique NA sentences} & & \cmark \\ \textit{inductive} & & \cmark \\ \textit{triples leakage} & \cmark & \\ \textit{NA-type constraint} & & \cmark \\ \textit{NA-argument role constraint} & & \cmark \\ \bottomrule \end{tabular} } \caption{\textsc{MedDistant19}\xspace~(MD19) comparison with prior work~\cite{amin2020data,hogan2021abstractified}. }\label{table:md19_props} \end{table} \begin{table}[!t] \centering \resizebox{7.5cm}{!}{ \begin{tabular}{rccc} \toprule {\bf Facts} & {\bf Training} & {\bf Validation} & {\bf Testing} \\ \midrule Inductive (I) & 345,374 & 62,116 & 130,563\\ Transductive (T) & 402,522 & 41,491 & 84,414 \\ \bottomrule \end{tabular} } \caption{Number of raw inductive and transductive SNOMED-KG triples used for alignment with text data.}\label{table:snomed_kg_splits} \end{table} UMLS classifies each entity in a type taxonomy as shown in \cref{fig:ent_types}. This allows for narrowing the concepts of interest. Following \citet{chang-etal-2020-benchmark}, we consider 8 semantic groups in SNOMED CT: Anatomy~(ANAT), Chemicals \& Drugs~(CHEM), Concepts \& Ideas~(CONC), Devices~(DEVI), Disorders~(DISO), Phenomena~(PHEN), Physiology~(PHYS), and Procedures~(PROC). For a complete list of semantic types covered in \textsc{MedDistant19}\xspace, see Appendix~A.1. Similarly, each relation is categorized into a type and has a reciprocal relation in UMLS~(Appendix~A.2), which can result in an overlap between the training and test set if not addressed~\cite{dettmers2018convolutional}. These steps follow \citet{chang-etal-2020-benchmark}, with the difference that we only consider relations of type \emph{has relationship other than synonymous, narrower, or broader}~(RO); this is consistent with prior works in Bio-DSRE~\citep{dai2019distantly,amin2020data,hogan2021abstractified}. We also exclude uninformative relations, \textit{same\_as}, \textit{possibly\_equivalent\_to}, \textit{associated\_with}, \textit{temporally\_related\_to}, and ignore inverse relations as generally is the case in RE. In addition, \citet{chang-etal-2020-benchmark} ensure that the validation and test set do not contain any new entities, making it a transductive learning setting where we assume all test entities are known beforehand. However, in real-world applications of biomedical RE, we are expected to extract relations between unseen entities. To support this setup, we also consider an inductive KG split proposed by \citet{daza2021inductive}. \cref{table:snomed_kg_splits} summarizes the statistics of the KGs used for alignment with the text. We use split ratios of 70\%, 10\%, and 20\%. Relationships are defined between CUIs, and have no overlap between training, validation, and test set. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{ccccccc} \toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{Summary}}} & \textbf{Entities} & \textbf{Relations} & \textbf{STY} & \textbf{SG} \\ \cline{3-6} & & 25,028 & 39 & 65 & 8 \\ \midrule \textbf{Split} & \textbf{Instances} & \textbf{Facts} & \textbf{Rare (\%)} & \textbf{Bags} & \textbf{NA (\%)} \\ \midrule \textbf{Train} & 251,558 & 2,366 & 92.3\% & 80,668 & 96.9\% \\ \textbf{Valid} & 179,393 & 806 & 87.8\% & 31,805 & 98.2\% \\ \textbf{Test} & 213,602 & 1,138 & 91.3\% & 50,375 & 98.1\% \\ \bottomrule \end{tabular} } \caption{Summary statistics of the \textsc{MedDistant19}\xspace dataset using Inductive SNOMED-KG split~(\cref{table:snomed_kg_splits}). % The number of relations include the unknown relation type~(NA). % Rare represents the proportion of the fact triples which have 8 or fewer instances in a given split as defined by \citet{hogan2021abstractified}. % \textsc{MedDistant19}\xspace focuses on rare triples with high NA proportions, making it a challenging benchmark. % } \label{table:summary_stats} \end{table} \subsection{Knowledge-to-Text Alignment} We now describe the procedure for searching fact triples to match relational instances in text. Let $\mathcal{E}$ and $\mathcal{R}$ respectively denote the set of UMLS CUIs and relation types, and let $\mathcal{G} \subseteq \mathcal{E} \times \mathcal{R} \times \mathcal{E}$ denote the set of relationships contained in UMLS. For producing a training-test split, we first create a set $\mathcal{G}^{+} \subseteq \mathcal{E} \times \mathcal{E}$ of related entity pairs, as follows: \begin{equation*} \mathcal{G}^{+} = \{ (e_{i}, e_{j}) \mid \langle e_{i}, p, e_{j} \rangle \in \mathcal{G} \lor \langle e_{j}, p, e_{i} \rangle \in \mathcal{G} \}. \end{equation*} Following the Local-Closed World Assumption~\cite[LCWA,][]{dong2014knowledge,DBLP:journals/pieee/Nickel0TG16}, in which we assume that a KG is only locally complete. More precisely, if we have observed any triple for a particular subject, predicate pair $(e_i,r_k)$, then we will assume that any non-existing triple $(e_i, r_k, .)$ is indeed unknown and replace $r_k$ by "NA". Following this, we obtain a set of unrelated entity pairs by corrupting one of the entities in each pair in $\mathcal{G}^{+}$ and making sure it does not appear in $\mathcal{G}^{+}$, obtaining a new set $\mathcal{G}^{-} \subseteq \mathcal{E} \times \mathcal{E}$ of unrelated entities: \begin{equation*} \begin{aligned} \mathcal{G}^{-} & = \{ (\overline{e_{i}}, e_{j}) \mid (e_{i}, e_{j}) \in \mathcal{G}^{+} \land (\overline{e_{i}}, e_{j}) \not\in \mathcal{G}^{+} \}\\ & \cup \{ (e_{i}, \overline{e_{j}}) \mid (e_{i}, e_{j}) \in \mathcal{G}^{+} \land (e_{i}, \overline{e_{j}}) \not\in \mathcal{G}^{+} \}. \end{aligned} \end{equation*} During the corruption process, we enforce two constraints; \begin{inparaenum}[1)] \item \emph{NA-type constraint}: the two entities appearing in each negative pair in $\mathcal{G}^{-}$ should belong to the same entity types as the entities in the initial positive pair, and \item \emph{NA-role constraint}: that the entities used in the negative pair must have appeared in one or more positive pairs. \end{inparaenum} For each entity linked sentence, we only consider those sentences that have SNOMED CT entities and have pairs in $\mathcal{G}^{+}$ and $\mathcal{G}^{-}$. Selected positive and negative pairs are mutually exclusive and have no overlap across splits. Since we only consider unique sentences associated with a pair, this makes for unique negative training instances, in contrast to \citet{amin2020data} who considered generating positive and negative pairs from the same sentence. We define negative examples as relational sentences mentioning argument pairs with \emph{unknown relation type} (NA), i.e.\@\xspace there might be a relation but the considered set of relations do not cover it. Our design choices are summarized in \cref{table:md19_props}. We prune high-frequency positive and negative pairs, remove mention-level overlap across the splits and apply type-based mention pruning. Specifically, we pool mentions by types and remove the sentences which have the mention appearing more than 1000 times. This step was crucial in removing highly non-informative mentions, such as \textit{increased} (STY: \textit{Qualitative Concept}), mentioned over 449951 times compared to \textit{malignant tumor} (STY: \textit{Neoplastic Process}) mentioned 473 times. \cref{table:summary_stats} shows the final summary of \textsc{MedDistant19}\xspace using inductive split. \cref{fig:ent_rel_dist} shows entity and relation plots, following a long-tail. \section{Experiments} \textsc{MedDistant19}\xspace is released in a format that is compatible with the widely adopted RE framework OpenNRE \cite{han-etal-2019-opennre}. To report our results, we use the \emph{corpus-level RE metrics} Area Under the Precision-Recall (PR) curve (AUC), Micro-F1, Macro-F1, and Precision-at-$k$ (P@$k$) with $k \in \{ 100, 200, 300, 1000, 2000 \}$, and the \emph{sentence-level RE metrics} Precision, Recall, and F1. Due to imbalanced nature of relational instances~(\cref{fig:ent_rel_dist}), following \citet{gao-etal-2021-manual}, we report Macro-F1 values, and following \citet{hogan2021abstractified} we report sentence-level RE results on relationships including frequent and rare triples. \begin{table*}[!t] \centering \resizebox{15cm}{!}{ \begin{tabular}{ccccccccccc} \toprule \textbf{Model} & \textbf{Bag} & \textbf{Strategy} & \textbf{AUC} & \textbf{F1-micro} & \textbf{F1-macro} & \textbf{P@100} & \textbf{P@200} & \textbf{P@300} & \textbf{P@1k} & \textbf{P@2k} \\ \midrule \multirow{5}{*}{CNN} & - & AVG & 5.8 & 10.5 & 3.2 & 32.0 & 28.0 & 23.3 & 15.6 & 10.8 \\ & - & ONE & 6.4 & 10.7 & 2.8 & 33.0 & 26.5 & 23.6 & 15.5 & 11.2 \\ \cmidrule{3-11} & \cmark & AVG & 10.3 & 12.8 & 4.7 & 48.0 & 37.0 & 32.0 & 19.5 & 13.6 \\ & \cmark & ONE & 8.5 & 17.9 & 3.7 & 39.0 & 32.5 & 27.3 & 18.7 & 13.3 \\ & \cmark & ATT & 6.0 & 13.5 & 2.6 & 31.0 & 28.5 & 22.3 & 15.7 & 10.7 \\ \midrule \multirow{5}{*}{PCNN} & - & AVG & 6.3 & 12.8 & 4.8 & 37.0 & 30.0 & 26.6 & 16.8 & 10.6 \\ & - & ONE & 6.6 & 9.7 & 2.9 & 34.0 & 26.0 & 22.3 & 16.3 & 11.7 \\ \cmidrule{3-11} & \cmark & AVG & 9.5 & 15.2 & 5.5 & 48.0 & 36.0 & 31.3 & 19.1 & 13.8 \\ & \cmark & ONE & 6.8 & 15.3 & 2.6 & 34.0 & 27.0 & 26.0 & 16.3 & 12.3 \\ & \cmark & ATT & 5.7 & 13.7 & 2.4 & 36.0 & 24.0 & 23.6 & 14.9 & 10.8 \\ \midrule \multirow{5}{*}{BERT} & - & AVG & \textbf{55.4} & \textbf{55.1} & 23.3 & \textbf{97.0} & 90.0 & 87.3 & \textbf{58.8} & \textbf{37.8} \\ & - & ONE & 53.0 & 52.1 & \textbf{23.6} & 94.0 & \textbf{92.0} & \textbf{87.6} & 57.5 & 36.4 \\ \cmidrule{3-11} & \cmark & AVG & 49.8 & 53.5 & 20.3 & 89.0 & 82.0 & 80.3 & 58.1 & 36.1 \\ & \cmark & ONE & 25.2 & 27.8 & 12.3 & 52.0 & 53.5 & 50.6 & 39.3 & 28.0 \\ & \cmark & ATT & 36.9 & 40.3 & 12.7 & 84.0 & 73.5 & 66.0 & 45.3 & 31.4 \\ \midrule \multicolumn{11}{c}{\textbf{SOTA Published Before \textsc{MedDistant19}\xspace}$^\dagger$} \\ \midrule \multicolumn{3}{c}{JointSimplE\_NER+KATT \cite{dai2019distantly}} & - & - & - & - & - & - & - & 91.3 \\ \multicolumn{3}{c}{RBERT+MIL \cite{amin2020data}} & 68.4 & 64.9 & - & 97.4 & 98.3 & 98.6 & - & 98.3 \\ \multicolumn{3}{c}{AMIL (Rel. Type L) \cite{hogan2021abstractified}} & 87.2 & 81.2 & - & - & - & - & - & 100.0 \\ \bottomrule \end{tabular} } \caption{ Baselines adopted from \citet{gao-etal-2021-manual} for \textsc{MedDistant19}\xspace. % CNN and PCNN models at sentence-level are reported with GloVe, while bag-level models are reported with Word2Vec. % BERT-based models are initialized with BioBERT. % We also include previously published results for completeness. % $\dagger$ The results are not directly comparable due to differences in the corpora used. % All the previously published results were trained at bag-level. % % } \label{table:main_results} \end{table*} \begin{figure}[!t] \includegraphics[width=0.81\linewidth]{figures/fig_ent_rel_dists.pdf} \centering \caption{ (\textit{Left}) Entity distribution based on Semantic Types. % (\textit{Right}) Relations distribution. % }\label{fig:ent_rel_dist} \end{figure} \subsection{Baselines} \label{subsection:baselines} Our baseline experiments largely follow the setup of \citet{gao-etal-2021-manual}. For sentence encoding, we use CNN~\cite{liu2013convolution}, PCNN~\cite{zeng2015distant}, and BERT~\cite{devlin2019bert}. We used GloVe~\cite{pennington2014glove} and Word2Vec~\cite{mikolov2013distributed}\footnote{DRE baselines using CNN/PCNN models use 50-dimensional word embeddings from GloVe. Therefore, we trained 50-dim Word2Vec embeddings on PubMed abstracts.} for CNN/PCNN models, and initialized BERT with BioBERT~\cite{lee2020biobert}. We trained our models both at \emph{sentence-level} and at \emph{bag-level}. In contrast, prior works only considered bag-level training for Bio-DSRE \cite{dai2019distantly,amin2020data,hogan2021abstractified}. The sentence-level setup is similar to standard RE~\cite{wu2019enriching}, with the difference that the evaluation is conducted at bag-level. We also consider different pooling strategies, namely average (AVG), which averages the representations of sentences in a bag, at-least-one \citep[ONE,][]{zeng2015distant}, which generates relation scores for each sentence in a bag and then selects the top scoring sentence, and attention~(ATT), which learns an attention mechanism over the sentences within a bag. \begin{figure} \includegraphics[width=1\linewidth]{figures/fig_bert_baselines_pr_curves.png} \centering \caption{ Precision-Recall (PR) curves for BERT-based baselines initialized with BioBERT on \textsc{MedDistant19}\xspace. % The trends largely follow the general-domain~\cite{gao-etal-2021-manual} with exception of BERT+bag+ONE. % } \label{fig:pr_curves} \end{figure} \cref{table:main_results} presents our main results. In all the cases, BERT sentence encoder performed better than CNN and PCNN since pre-trained language models are effective for entity-centric transfer learning \cite{amin2021t2ner}, domain-specific fine-tuning \cite{amin2019mlt}, and can implicitly store relational knowledge during pre-training \cite{petroni2019language}. This trend is similar to the general-domain. We also validate the finding that sentence-level training in pre-trained language models~(LMs) performs better than the bag-level~\cite{gao-etal-2021-manual,10.1145/3404835.3463103}. Argubaly those sentences that have been correctly labeled by distant supervision~(e.g.\@\xspace \cref{fig:bag_example}) provide enough learning signal at sentence-level, given the generalization abilities of LMs. However, in bag-level training, we force the model to jointly learn from clean and noisy samples, thus limiting its overall performance. This raises further questions into using MIL with LMs. But, we do not find this trend to hold for CNN/PCNN, instead the bag-level models performed slightly better. We also find GloVe to be a better initialization for sentence-level training and Word2Vec for bag-level. We further plot PR curves for BERT-based baselines in \cref{fig:pr_curves}. \textbf{Pooling Strategies} In all cases, AVG proved to be a better pooling strategy; this finding is consistent with prior works. Both \citet{amin2020data} and \citet{gao-etal-2021-manual} found ATT to produce less accurate results with LMs, however, contrary to general-domain, in \textsc{MedDistant19}\xspace, BERT+bag+ONE had lower performance than BERT+bag+ATT. We attribute this to the challenging nature of the benchmark, since it is focused on long-tail relations and therefore, the signal to learn from is insufficient when picking the optimal example in the bag for BERT+bag+ONE. This results in sparse gradients and longer training time.\footnote{While we trained all BERT-based models for 3 epochs, BERT+bag+ONE was trained for 50 epochs} \textbf{Relational Category} To further study the impact of bag-level and sentence-level training on \textsc{MedDistant19}\xspace, we analyse the relation category-specific results as in \citet{chang-etal-2020-benchmark}, and the results on rare and frequent triples as in \citet{hogan2021abstractified}. Following \citet{chang-etal-2020-benchmark}, we grouped the relations based on cardinality, where the cardinality is defined as: for a given relation type, if the set of head or tail entities belong to only one semantic group, then it has cardinality 1 otherwise M (many). The results are shown in \cref{table:sent_vs_bag_rel_cat} for sentence- and bag-level training with average pooling. We note that both training strategies perform comparably on 1-1 category but the bag-level training suffers a huge performance drop in M-1 and 1-M settings. We reason that this could be due to the lack of enough training signal to differentiate between heterogeneous entity types pooled over instances in a bag. \textbf{Long-Tail Performance} Following \citet{hogan2021abstractified}, we also perform sentence-level triples evaluation of BERT-based encoders trained at sentence-level and bag-level. The authors divided the triples (including "NA" instances) into two categories, those with 8 or more sentences are defined as common triples and others as rare triples. \cref{table:sent_vs_bag_common_rare} shows these results. We note that both training strategies performed comparably on rare-triples with BERT+sent+AVG more precise than BERT+bag+AVG. However, we find noticeable differences on common triples where BERT+bag+AVG had higher recall but still low precision. This could be explained because of overfitting to type and mention heuristics at bag-level, where sentence-level training allows to have more focus on context. The current state-of-the-art model AMIL (Rel. Type L) from \citet{hogan2021abstractified} creates bags of instances by abstracting entity pairs belonging to the same semantic type pair into a single bag, thus producing heterogeneous bags. Due to the nature of their methodology, it is not suited for sentence-level models, which already produce more accurate results than bag models. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rC{1.2cm}C{1.2cm}C{1.2cm}} \toprule \textbf{Model} & \textbf{P} & \textbf{R} & \textbf{F1} \\ \midrule \multicolumn{4}{c}{\bf All Triples}\\ \midrule BERT+sent+AVG & \textbf{0.44} & 0.49 & \textbf{0.46} \\ BERT+bag+AVG & 0.36 & \textbf{0.52} & 0.42 \\ \midrule \multicolumn{4}{c}{\bf Common Triples} \\ \midrule BERT+sent+AVG & \textbf{0.35} & 0.47 & \textbf{0.40} \\ BERT+bag+AVG & 0.28 & \textbf{0.53} & 0.37 \\ \midrule \multicolumn{4}{c}{\bf Rare Triples} \\ \midrule BERT+sent+AVG & \textbf{0.57} & \textbf{0.52} & \textbf{0.55} \\ BERT+bag+AVG & 0.52 & 0.50 & 0.51 \\ \bottomrule \end{tabular} } \caption{Sentence-level RE metrics comparing BERT baselines trained at bag and sentence-level with AVG pooling on Rare and Common subsets of \textsc{MedDistant19}\xspace The triples include NA relational instances.} \label{table:sent_vs_bag_common_rare} \end{table} \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rC{1.2cm}C{1.2cm}C{1.2cm}} \toprule \textbf{Model} & \textbf{1-1} & \textbf{1-M} & \textbf{M-1} \\ \midrule BERT+sent+AVG & \textbf{21.3} & \textbf{26.1} & \textbf{30.7} \\ BERT+bag+AVG & 19.4 & 9.4 & 3.0 \\ \bottomrule \end{tabular} } \caption{Averaged F1-micro score on relation specific category. The categories are defined using the \textit{cardinality} of head and tail semantic group types.} \label{table:sent_vs_bag_rel_cat} \end{table} \subsection{Analysis} \textbf{Context, Mention, or Type?} RE models are known to heavily rely on information from entity mentions, most of which is type information, and existing datasets may leak shallow heuristics via entity mentions that can inflate the prediction results \cite{peng2020learning}. To study the importance of mentions, contexts, and entity types in \textsc{MedDistant19}\xspace, we take inspiration from \citet{peng2020learning,han2020more} and conduct an ablation of different text encoding methods. We consider entity mentions with special entity markers \cite{wu2019enriching,amin2020data} as the \emph{Context + Mention} (CM) setting, which is common in RE with LMs. We then remove the context and only use mentions, and we refer to this as the \emph{Only Mention} (OM) setting. This is similar to KG-BERT \cite{yao2019kg} for relation prediction. We then only consider the context by replacing subject and object entities with special tokens, resulting in the \emph{Only Context} (OC) setting. % Lastly, we consider two type-based (STY) variations as \emph{Only Type} (OT) and \emph{Context + Type} (CT). We conduct these experiments with BioBERT trained at sentence-level and evaluated at bag-level. \begin{figure} \includegraphics[width=0.9\linewidth]{figures/fig_encoding_methods_ablation.pdf} \centering \caption{Ablation showing the effect of different text encoding methods following the general-domain trends.}\label{fig:text_encoding_ablation} \end{figure} We observe in \cref{fig:text_encoding_ablation} that the CM method had the highest performance but surprisingly, OM performed quite well. This highlights the ability of LMs to memorize the facts and act as soft KBs \cite{petroni2019language, safavi-koutra-2021-relational}. This trend is also consistent with general-domain \cite{peng2020learning}. The poor performance in the OC setting shows that the model struggles to understand the context, which is more pronounced in noisy-prone distant RE compared to supervised RE. Our CT setup can be seen as sentence-level extrapolation of the AMIL model \cite{hogan2021abstractified}, which struggles to perform better than the baseline (OM). However, comparing OC with CT, it is clear that the model benefits from type information as it can help constraint the relations space. Using only the type information had the least performance as the model fails to disambiguate between different entities belonging to the same type. \textbf{Inductive or Transductive?} To study the impact of \emph{transductive} and \emph{inductive} splits (\cref{table:snomed_kg_splits}), we created another Bio-DSRE corpus using transductive train, validation, and test triples. The corpus generated is different than the inductive one, but it can offer insights into the model's ability to handle unseen mentions. As shown in \cref{table:ind_vs_trans}, the performance using transductive is slightly better than inductive for corpus-level extractions, in terms of AUC, however, the F1-micro score is slightly better in inductive than transductive. We conclude from this that the model is able to learn patterns that exploit mention and type information to extrapolate to unseen mentions. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rccc} \toprule \textbf{Split} & \textbf{AUC} & \textbf{F1-micro} & \textbf{F1-macro} \\ \midrule Inductive (I) & 55.5 & \textbf{56.5} & \textbf{24.8} \\ Transductive (T) & \textbf{57.4} & 53.0 & 24.1 \\ \bottomrule \end{tabular} } \caption{BERT+sent+AVG performance on two corpora created with inductive and transductive set of triples.} \label{table:ind_vs_trans} \end{table} \textbf{Does Expert Knowledge Help?} We now consider several pre-trained LMs with different knowledge capacities, specific to biomedical and clinical language understanding, with the aim to better understand \textsc{MedDistant19}\xspace challenges and gain insights into models behavior. In first category we consider non-expert models. We provide their details in Appendix E. In the second category, we consider expert models which either modify the MLM objective or introduce new pre-training tasks using external knowledge, such as UMLS. MedType \cite{vashishth2021improving}, initialized with BioBERT, is pre-trained to predict semantic types. KeBioLM \cite{yuan2021improving}, initialized with PubMedBERT, uses relational knowledge by initializing the entity embeddings with TransE \cite{bordes2013translating}, improving downstream entity-centric tasks, including RE. UmlsBERT \cite{michalopoulos2021umlsbert}, initialized with ClinicalBERT, modifies MLM to mask words belonging to the same CUI and further introduces semantic type embeddings. SapBERT \cite{liu2021self}, initialized with PubMedBERT, introduces a metric learning task for clustering synonyms together in an embedding space. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rcccccc} \toprule \multirow{2}{*}{\textbf{Encoder}} & \multicolumn{5}{c}{\textbf{Knowledge}} & \multirow{2}{*}{\textbf{AUC}} \\ \cline{2-6} & \textit{Biomedical} & \textit{Clinical} & \textit{Type} & \textit{Triples} & \textit{Synonyms} \\ \midrule BERT & & & & & & 0.42 \\ ClinicalBERT & \cmark & \cmark & & & & 0.47 \\ BlueBERT & \cmark & & & & & 0.55 \\ SciBERT & \cmark & & & & & 0.55 \\ BioBERT & \cmark & & & & & 0.55 \\ PubMedBERT & \cmark & & & & & \textbf{0.62} \\ \midrule MedType & \cmark & & \cmark & & & 0.54 \\ KeBioLM & \cmark & & & \cmark & & \textbf{0.61} \\ UmlsBERT & \cmark & \cmark & \cmark & & & 0.53 \\ SapBERT & \cmark & & & & \cmark & 0.57 \\ \bottomrule \end{tabular} } \caption{Fine-tuning different biomedical and clinical domain LMs on \textsc{MedDistant19}\xspace.}\label{table:encoders_study} \end{table} \cref{table:encoders_study} shows the results of these sentence encoders fine-tuned on the \textsc{MedDistant19}\xspace dataset at sentence-level with AVG pooling. Without any domain-specific knowledge, BERT performs slightly worse than the lowest-performing biomedical model, highlighting the presence of shallow heuristics in the data that are common to the general and biomedical domains. While domain-specific pre-training improves the results, similar to \citet{gu2021domain}, we find clinical LMs underperform on the biomedical RE task. There was no performance gap between BlueBERT, SciBERT and BioBERT. However, PubMedBERT brought significant improvement which is consistent with \citet{gu2021domain}. For expert knowledge-based models we noted a negative impact on performance. While we would expect type-based models, MedType and UmlsBERT, to bring improvement, their negative effect can be attributed to overfitting certain types and their patterns. KeBioLM, which is initialized with PubMedBERT, slightly degrades the performance despite having seen the triples used in \textsc{MedDistant19}\xspace during pre-training, highlighting the difficulty of the \textsc{MedDistant19}\xspace dataset. SapBERT which uses the synonyms knowledge also hurt PubMedBERT's performance, suggesting that while synonyms can help for entity linking, RE is a much more elusive task in noisy real-world scenarios. \section{Conclusion} In this work, we highlighted a severe training-test overlap in the corpus used by previous studies in Bio-DSRE, causing inflated performance. We noted other inconsistencies including the KGs used and lack of standard baselines. To mitigate these issues and observing a lack of existing best practices or a benchmark, we introduce a challenging new benchmark \textsc{MedDistant19}\xspace, which derives its KG from SNOMED CT \cite{chang-etal-2020-benchmark}. The benchmark can directly be used with standard RE frameworks, such as OpenNRE~\citep{han-etal-2019-opennre}. We conducted a thorough set of experiments and provided baselines showing both the quality of the dataset and the need for better models. \section{Legal \& Ethical Considerations} \textbf{Does the dataset contain information that might be considered sensitive or confidential? (e.g.\@\xspace personally identifying information)} We use PubMed MEDLINE abstracts \cite{canese2013pubmed}\footnote{\url{https://lhncbc.nlm.nih.gov/ii/information/MBR/Baselines/2019.html}} that are publicly available and is distributed by National Library of Medicine (NLM). These texts are in the biomedical and clinical domain, and are almost entirely in English. It is standard to use this corpus as a text source in several biomedical LMs \cite{gu2021domain}. We cannot claim the guarantee that it does not contain any confidential or sensitive information e.g, it has clinical findings mentioned throughout the abstracts such as \textit{A twenty six year old male presented with high grade fever}, which identifies the age and gender of a patient but not the identity. We did not perform thorough analysis to distill such information since it is in public domain. For other concerns, see Appendix section B and D. \section{Introduction} Extracting structured knowledge from unstructured text is an important task for knowledge discovery and management. Biomedical literature and clinical narratives offer rich interactions between entities mentioned in the text \cite{craven1999constructing,xu2014automatic}, which can be useful for applications such as bio-molecular information extraction, pharmacogenomics, and identifying drug-drug interactions (DDIs), among others \cite{luo2017bridging}. Manually annotating these relations for training supervised learning systems is an expensive and time-consuming process \cite{segura20111st,kilicoglu2011constructing,segura2013semeval,li2016biocreative}, so the task often involves leveraging rule-based \cite{abacha2011automatic,kilicoglu2020broad} and weakly supervised approaches \cite{peng2016improving,dai2019distantly}. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{ccccc} \toprule \multirow{2}{*}{\bf Model and Data} & \multicolumn{2}{c}{\bf{Original}} & \multicolumn{2}{c}{\bf{Filtered}}\\ & \textbf{AUC} & \textbf{F1} & \textbf{AUC} & \textbf{F1} \\ \midrule \citet{amin2020data} & 68.4 & 64.9 & 50.8 & 53.1 \\ \citet{hogan2021abstractified} & 82.6 & 77.6 & 11.8 & 19.8 \\ \bottomrule \end{tabular} } \caption{ Two state-of-the-art Bio-DSRE models evaluated on the respective datasets before (Original) and after (Filtered) removing test relationships also appearing in the training set. % Both models were trained and evaluated at \emph{bag-level}. } \label{table:fixed_results} \end{table} More recently, \citet{amin2020data} and \citet{hogan2021abstractified} used domain-specific language models \cite{gu2021domain} that were pre-trained explicitly on biomedical data for Bio-DSRE, producing disproportionately more accurate results when compared with recent results in the general domain \cite{gao-etal-2021-manual,christopoulou2021distantly,10.1145/3404835.3463103}. In this work, we highlight that these results can be largely attributed to the overlap between the training and the test facts, which allows the model to score higher just by memorizing the training relations rather than generalizing to new, previously unknown ones. In \cref{table:fixed_results}, we show that removing this leakage (51.9\%, \cref{table:leakage_stats}) results in a significant decrease in predictive accuracy. For example, AMIL model with relation type embedding $L$ proposed by \citet{hogan2021abstractified} achieves an 82.6 AUC when evaluated on their Bio-DSRE dataset, while producing an 11.8 AUC when evaluated on the subset of the test set of relationships that do not overlap with the training set. The training-test overlap in the datasets proposed by \citet{hogan2021abstractified} and \citet{amin2020data} is due to the same entities appearing with different names in multiple relationships, although two entity names are mapped to the same UMLS concept \cite{bodenreider2004unified}, they are still treated as two distinct entities. Furthermore, we also identified other problems, such as redundant facts, and unclear coverage of UMLS concepts. To mitigate these issues, we follow the guidelines outlined by \citet{chang-etal-2020-benchmark} for benchmarking biomedical link prediction models, and propose a new Bio-DSRE benchmark. \begin{table}[!t] \centering \resizebox{7.5cm}{!}{ \begin{tabular}{rccc} \toprule \textbf{\bf Triples} & \textbf{Train} & \textbf{Valid} & \textbf{Test} \\ \midrule Textual & 92,972 & 13,555 (51.9\%) & 33,888 (51.2\%) \\ CUI & 211,789 & 41,993 (26.7\%) & 89,486 (26.5\%) \\ \bottomrule \end{tabular} } \caption{ Training-test leakage we identified in the data constructed and used by \citet{amin2020data} (see their Appendix A.4 in their \emph{k-tag} setup). % Numbers between parentheses show the percentage overlap, where the authors considered text-based instead of CUI-based triples. } \label{table:leakage_stats} \end{table} \section{Related Work} Relation Extraction (RE) is an important task in biomedical applications. Traditionally, supervised methods require large-scale annotated corpora, which is impractical to scale for broad-coverage biomedical relation extraction \cite{kilicoglu2011constructing,kilicoglu2020broad}. In cases where such supervision is available, it is limited to protein-protein interactions \cite{peng2017deep}, drug-drug interactions \cite{kavuluru2017extracting}, and chemical-disease interactions \cite{peng2016improving}. Distant Supervision (DS) allows for the automated collection of noisy training examples \cite{mintz2009distant} by aligning a given knowledge base (KB) with a collection of text sources. DS was used in recent works \cite{alt2019fine} using Multi-Instance Learning (MIL) by creating \emph{bags} of instances \cite{riedel2010modeling} for corpus-level triples extraction.\footnote{RE is used to refer to two different tasks: sentence-level detection of relational instances and corpus-level triples extraction, a kind of knowledge completion task \cite{ji2021survey}.} \begin{figure}[!t] \includegraphics[width=1.0\linewidth]{figures/bag-example-crop.pdf} \centering \caption{An example of a bag instance representing the UMLS concept pair (\texttt{C0240066}, \texttt{C0085576}) from the \textsc{MedDistant19}\xspace dataset, expressing the relation \textit{cause\_of}. % In this example, three out of six sentences express the relation, while others are wrong labels from distant supervision. } \label{fig:bag_example} \end{figure} \citet{dai2019distantly} introduced the use of the Unified Medical Language System (UMLS) Metathesaurus \cite{bodenreider2004unified} as a KB with PubMed \cite{canese2013pubmed} MEDLINE abstracts as text collection, and implemented a knowledge-based attention mechanism \cite{han2018neural} for joint learning with knowledge graph completion using SimplE \cite{kazemi2018simple} embeddings and entity type classification. Their pipeline was simplified by \citet{amin2020data}, who extended R-BERT \cite{wu2019enriching} to handle bag-level MIL, and demonstrated that preserving the direction of the relationships improves the accuracy of the model. Lacking benchmark corpora, \citet{amin2020data} also outlined the steps to create the dataset. Similar steps were followed by \citet{hogan2021abstractified}, who introduced the concept of \emph{abstractified} MIL (AMIL), by absorbing different argument pairs belonging to the same semantic types (see \cref{fig:ent_types}) pair in one bag, boosting performance on rare-triples. They also proposed the use of \textsc{ScispaCy} \cite{neumann-etal-2019-scispacy} for sentence tokenization, resulting in improved overall performance. \begin{figure*} \includegraphics[width=0.75\linewidth]{figures/fig_hierarchical_types.png} \centering \caption{Type Hierarchy: each concept in the UMLS is classified under a type taxonomy. % The \emph{coarse-grained} entity type is called \textbf{Semantic Group (SG)} and the \emph{fine-grained} entity type is called \textbf{Semantic Type (STY)}. } \label{fig:ent_types} \end{figure*} In this work, we investigate some recent results from the Bio-DSRE literature by probing the respective benchmarks for overlaps between training and test sets. We found a severe overlap between the training set and the held-out validation and test sets in the dataset constructed by \citet{amin2020data} and \citet{hogan2021abstractified}. An issue of entity linking or concept normalization. Where in UMLS, each concept is mapped to a UMLS \textit{Concept Unique Identifier (CUI)}, where a given CUI might have different surface forms \cite{bodenreider2004unified}. \cref{table:leakage_stats} shows the leakage statistics. Consider a relationship between a pair of UMLS entities (\texttt{C0013798}, \texttt{C0429028}). These two entities can appear in different forms within a text, such as (\emph{electrocardiography}, \emph{Q-T interval}), (\emph{ECG}, \emph{Q-T interval}), and (\emph{EKG}, \emph{Q-T interval}); each of these distinct pairs still refers to the same original pair (\texttt{C0013798}, \texttt{C0429028}). \citet{amin2020data} claim no such text-based leakage, but when normalized this results in leakage across the splits as reported in \cref{table:leakage_stats}. Due to these inconsistencies and lack of benchmark and best practices, we introduce the \textsc{MedDistant19}\xspace dataset. Our work utilizes the SNOMED-CT Knowledge Graph (KG) extracted from the UMLS that offers a careful selection of the concept types, proper handling of the inverse relations, and highlights the need for downstream benchmarks \cite{chang-etal-2020-benchmark}. The dataset is particularly focused on rare-triples and considers a narrower subset of the relations. \section{Constructing the MedDistant19 Dataset} \label{sec:md19_construction} \paragraph{Documents} We used PubMed MEDLINE abstracts from 2019\footnote{\url{https://lhncbc.nlm.nih.gov/ii/information/MBR/Baselines/2019.html}} as our text source, containing 32,151,899 abstracts. Following \citet{hogan2021abstractified}, we used \textsc{ScispaCy} \cite{neumann-etal-2019-scispacy} for sentence tokenization, resulting in 150,173,169 unique sentences. Previous studies used Exact Match for entity linking \cite{amin2020data,hogan2021abstractified}. In this work, we further introduce the use of a specialized UMLS entity linker from \textsc{ScispaCy}~\footnote{\url{https://github.com/allenai/scispacy}}, since named entity recognition and normalization was shown to be the largest source of errors in biomedical RE \cite{kilicoglu2020broad}. We used the default settings in \textsc{SciSpaCy} for linking entity mentions to their UMLS CUIs, and filtering disabled concepts from UMLS. This resulted in the entity linked mention at the sentence level. \paragraph{Knowledge Base} We use UMLS2019AB~\footnote{\url{https://download.nlm.nih.gov/umls/kss/2019AB/umls-2019AB-full.zip}} as our main knowledge source. The UMLS Metathesaurus \cite{bodenreider2004unified} covers concepts from 222 source ontologies, thus being the largest ontology of biomedical concepts. However, covering all ontologies can be challenging given the interchangeable nature of the concepts. For example, \emph{programmed cell death 1 ligand 1} is an alias of concept \texttt{C1540292} in the HUGO Gene Nomenclature Committee ontology~\citep{hgnc}, and it is an alias of concept \texttt{C3272500} in the National Cancer Institute Thesaurus. This makes entity linking more challenging, since a surface form can be linked to multiple entity identifiers, and makes it easier to have overlaps between training and test set, since the same fact may appear in both with different entity identifiers. Furthermore, benchmark corpora for biomedical Named Entity Recognition \cite{dougan2014ncbi,li2016biocreative} and RE \cite{herrero2013ddi,krallinger2017overview} focuses on specific entity types (e.g.\@\xspace diseases, chemicals, proteins), and are usually normalized to a single ontology \cite{kilicoglu2020broad}. Following this trend, we also focus on a single vocabulary for Bio-DSRE. We use SNOMED-CT, which is the most widely used clinical terminology in the world for documentation and reporting in healthcare \cite{chang-etal-2020-benchmark}. \begin{table} \centering \resizebox{7.0cm}{!}{ \begin{tabular}{rcc} \toprule \textbf{Properties} & \textbf{Prior} & \textbf{MD19} \\ \midrule \textit{approximate entity linking} & & \cmark \\ \textit{unique NA sentences} & & \cmark \\ \textit{inductive} & & \cmark \\ \textit{triples leakage} & \cmark & \\ \textit{NA-type constraint} & & \cmark \\ \textit{NA-argument role constraint} & & \cmark \\ \bottomrule \end{tabular} } \caption{\textsc{MedDistant19}\xspace (MD19) properties in comparison with the prior works \cite{amin2020data,hogan2021abstractified}. }\label{table:md19_props} \end{table} \begin{table}[!t] \centering \resizebox{7.5cm}{!}{ \begin{tabular}{rccc} \toprule {\bf Facts} & {\bf Training} & {\bf Validation} & {\bf Testing} \\ \midrule Inductive (I) & 345,374 & 62,116 & 130,563\\ Transductive (T) & 402,522 & 41,491 & 84,414 \\ \bottomrule \end{tabular} } \caption{Number of raw inductive and transductive SNOMED-KG triples used for alignment with text data.}\label{table:snomed_kg_splits} \end{table} UMLS classifies each entity in a type taxonomy as shown in \cref{fig:ent_types}. This allows for narrowing the concepts of interest. Following \cite{chang-etal-2020-benchmark}, we consider 8 semantic groups in SNOMED-CT: Anatomy (ANAT), Chemicals \& Drugs (CHEM), Concepts \& Ideas (CONC), Devices (DEVI), Disorders (DISO), Phenomena (PHEN), Physiology (PHYS), and Procedures (PROC). For a complete list of semantic types covered in \textsc{MedDistant19}\xspace, see Appendix A.1. Similarly, each relation is categorized into a type and has a reciprocal relation in UMLS (Appendix A.2), which can result in an overlap between the training and test set if not addressed \cite{dettmers2018convolutional}. These steps follow \citet{chang-etal-2020-benchmark}, with the difference that we only consider relations of type \emph{has relationship other than synonymous, narrower, or broader} (RO); this is consistent with prior works in Bio-DSRE~\citep{dai2019distantly,amin2020data,hogan2021abstractified}. We also exclude uninformative relations, \textit{same\_as}, \textit{possibly\_equivalent\_to}, \textit{associated\_with}, \textit{temporally\_related\_to}, and ignore inverse relations as generally is the case in RE. In addition, \citet{chang-etal-2020-benchmark} ensure that the validation and test set do not contain any new entities, making it a transductive learning setting where we assume all test entities are known beforehand. However, in real-world applications of biomedical RE, we are expected to extract relations between unseen entities. To support this setup, we also consider an inductive KG split proposed by \citet{daza2021inductive}. \cref{table:summary_stats} summarizes the statistics of the KGs used for alignment with the text. We use split ratios of 70\%, 10\%, and 20\%. Relationships are defined between CUIs, and have no overlap between training, validation, and test set. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{ccccccc} \toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{Summary}}} & \textbf{Entities} & \textbf{Relations} & \textbf{STY} & \textbf{SG} \\ \cline{3-6} & & 25,028 & 39 & 65 & 8 \\ \midrule \textbf{Split} & \textbf{Instances} & \textbf{Facts} & \textbf{Rare (\%)} & \textbf{Bags} & \textbf{NA (\%)} \\ \midrule \textbf{Train} & 251,558 & 2,366 & 92.3\% & 80,668 & 96.9\% \\ \textbf{Valid} & 179,393 & 806 & 87.8\% & 31,805 & 98.2\% \\ \textbf{Test} & 213,602 & 1,138 & 91.3\% & 50,375 & 98.1\% \\ \bottomrule \end{tabular} } \caption{Summary statistics of the \textsc{MedDistant19}\xspace dataset using Inductive SNOMED-KG split (\cref{table:snomed_kg_splits}). The number of relations include the unknown relation type (NA). Rare represents the proportion of the fact triples which have 8 or fewer instances in a given split as defined by \citet{hogan2021abstractified}. \textsc{MedDistant19}\xspace focuses on rare triples with high NA proportions, making it a challenging benchmark.} \label{table:summary_stats} \end{table} \subsection{Knowledge-to-Text Alignment} We now describe the procedure for searching fact triples to match relational instances in text. Let $\mathcal{E}$ and $\mathcal{R}$ respectively denote the set of UMLS CUIs and relation types, and let $\mathcal{G} \subseteq \mathcal{E} \times \mathcal{R} \times \mathcal{E}$ denote the set of relationships contained in UMLS. For producing a training-test split, we first create a set $\mathcal{G}^{+} \subseteq \mathcal{E} \times \mathcal{E}$ of related entity pairs, as follows: \begin{equation*} \mathcal{G}^{+} = \{ (e_{i}, e_{j}) \mid \langle e_{i}, p, e_{j} \rangle \in \mathcal{G} \lor \langle e_{j}, p, e_{i} \rangle \in \mathcal{G} \}. \end{equation*} Following the Local-Closed World Assumption \cite[LCWA,][]{dong2014knowledge,DBLP:journals/pieee/Nickel0TG16}, we obtain a set of unrelated entity pairs by corrupting one of the entities in each pair in $\mathcal{G}^{+}$ and making sure it does not appear in $\mathcal{G}^{+}$, obtaining a new set $\mathcal{G}^{-} \subseteq \mathcal{E} \times \mathcal{E}$ of unrelated entities: \begin{equation*} \begin{aligned} \mathcal{G}^{-} & = \{ (\overline{e_{i}}, e_{j}) \mid (e_{i}, e_{j}) \in \mathcal{G}^{+} \land (\overline{e_{i}}, e_{j}) \not\in \mathcal{G}^{+} \}\\ & \cup \{ (e_{i}, \overline{e_{j}}) \mid (e_{i}, e_{j}) \in \mathcal{G}^{+} \land (e_{i}, \overline{e_{j}}) \not\in \mathcal{G}^{+} \}. \end{aligned} \end{equation*} During the corruption process, we enforce two constraints \begin{inparaenum}[1)] \item the two entities appearing in each negative pair in $\mathcal{G}^{-}$ should belong to the same entity types as the entities in the initial positive pair, and \item that the entities used in the negative pair must have appeared in one or more positive pairs. \end{inparaenum} For each entity linked sentence, we only consider those sentences that have SNOMED-CT entities and have pairs in $\mathcal{G}^{+}$ and $\mathcal{G}^{-}$. Selected positive and negative pairs are mutually exclusive and have no overlap across splits. Since we only consider unique sentences associated with a pair, this makes for unique negative training instances, in contrast to \citet{amin2020data} who considered generating positive and negative pairs from the same sentence. We define negative examples as relational sentences mentioning argument pairs with \emph{unknown relation type} (NA), i.e.\@\xspace there might be a relation but the considered set of relations do not cover it. Our design choices are summarized in \cref{table:md19_props}. We prune high-frequency positive and negative pairs, remove mention-level overlap across the splits and apply type-based mention pruning. Specifically, we pool mentions by types and remove the sentences which have the mention appearing more than 1000 times. This step was crucial in removing highly non-informative mentions, such as \textit{increased} (STY: \textit{Qualitative Concept}), mentioned over 449951 times compared to \textit{malignant tumor} (STY: \textit{Neoplastic Process}) mentioned 473 times. \cref{table:summary_stats} shows the final summary of \textsc{MedDistant19}\xspace using inductive split. \cref{fig:ent_rel_dist} shows entity and relation plots, following a long-tail. \section{Experiments} \textsc{MedDistant19}\xspace is released in a format that is compatible with the widely adopted RE framework OpenNRE \cite{han-etal-2019-opennre}. To report our results, we use the \emph{corpus-level RE metrics} Area Under the Precision-Recall (PR) curve (AUC), Micro-F1, Macro-F1, and Precision-at-$k$ (P@$k$) with $k \in \{ 100, 200, 300, 1000, 2000 \}$, and the \emph{sentence-level RE metrics} Precision, Recall, and F1. Due to imbalanced nature of relational instances (\cref{fig:ent_rel_dist}), following \citet{gao-etal-2021-manual}, we report Macro-F1 values, and following \citet{hogan2021abstractified} we report sentence-level RE results on relationships including frequent and rare triples. \begin{table*}[!t] \centering \resizebox{15cm}{!}{ \begin{tabular}{ccccccccccc} \toprule \textbf{Model} & \textbf{Bag} & \textbf{Strategy} & \textbf{AUC} & \textbf{F1-micro} & \textbf{F1-macro} & \textbf{P@100} & \textbf{P@200} & \textbf{P@300} & \textbf{P@1k} & \textbf{P@2k} \\ \midrule \multirow{5}{*}{CNN} & - & AVG & 5.8 & 10.5 & 3.2 & 32.0 & 28.0 & 23.3 & 15.6 & 10.8 \\ & - & ONE & 6.4 & 10.7 & 2.8 & 33.0 & 26.5 & 23.6 & 15.5 & 11.2 \\ \cmidrule{3-11} & \cmark & AVG & 10.3 & 12.8 & 4.7 & 48.0 & 37.0 & 32.0 & 19.5 & 13.6 \\ & \cmark & ONE & 8.5 & 17.9 & 3.7 & 39.0 & 32.5 & 27.3 & 18.7 & 13.3 \\ & \cmark & ATT & 6.0 & 13.5 & 2.6 & 31.0 & 28.5 & 22.3 & 15.7 & 10.7 \\ \midrule \multirow{5}{*}{PCNN} & - & AVG & 6.3 & 12.8 & 4.8 & 37.0 & 30.0 & 26.6 & 16.8 & 10.6 \\ & - & ONE & 6.6 & 9.7 & 2.9 & 34.0 & 26.0 & 22.3 & 16.3 & 11.7 \\ \cmidrule{3-11} & \cmark & AVG & 9.5 & 15.2 & 5.5 & 48.0 & 36.0 & 31.3 & 19.1 & 13.8 \\ & \cmark & ONE & 6.8 & 15.3 & 2.6 & 34.0 & 27.0 & 26.0 & 16.3 & 12.3 \\ & \cmark & ATT & 5.7 & 13.7 & 2.4 & 36.0 & 24.0 & 23.6 & 14.9 & 10.8 \\ \midrule \multirow{5}{*}{BERT} & - & AVG & \textbf{55.4} & \textbf{55.1} & 23.3 & \textbf{97.0} & 90.0 & 87.3 & \textbf{58.8} & \textbf{37.8} \\ & - & ONE & 53.0 & 52.1 & \textbf{23.6} & 94.0 & \textbf{92.0} & \textbf{87.6} & 57.5 & 36.4 \\ \cmidrule{3-11} & \cmark & AVG & 49.8 & 53.5 & 20.3 & 89.0 & 82.0 & 80.3 & 58.1 & 36.1 \\ & \cmark & ONE & 25.2 & 27.8 & 12.3 & 52.0 & 53.5 & 50.6 & 39.3 & 28.0 \\ & \cmark & ATT & 36.9 & 40.3 & 12.7 & 84.0 & 73.5 & 66.0 & 45.3 & 31.4 \\ \midrule \midrule \multicolumn{3}{c}{JointSimplE\_NER+KATT \cite{dai2019distantly}} & - & - & - & - & - & - & - & 91.3 \\ \multicolumn{3}{c}{BERT+bag+AVG \cite{amin2020data}} & 68.4 & 64.9 & - & 97.4 & 98.3 & 98.6 & - & 98.3 \\ \multicolumn{3}{c}{AMIL (Rel. Type L) \cite{hogan2021abstractified}} & 87.2 & 81.2 & - & - & - & - & - & 100.0 \\ \multicolumn{3}{c}{AMIL (Rel. Type L)*} & 82.6 & 77.6 & - & 100.0 & 100.0 & 100.0 & - & 99.7 \\ \bottomrule \end{tabular} } \caption{Baselines adopted from \citet{gao-etal-2021-manual} for \textsc{MedDistant19}\xspace. CNN and PCNN models at sentence-level are reported with GloVe, while bag-level models are reported with Word2Vec. BERT-based models are initialized with BioBERT. We also include previously published results for completeness. The results are not directly comparable due to differences in the corpora used. All the previously published results were trained at bag-level. The symbol * marks our re-run of the best model reported by \citet{hogan2021abstractified}.} \label{table:main_results} \end{table*} \begin{figure}[!t] \includegraphics[width=0.81\linewidth]{figures/fig_ent_rel_dists.pdf} \centering \caption{(\textit{Left}) Entity distribution based on Semantic Types. (\textit{Right}) Relations distribution.}\label{fig:ent_rel_dist} \end{figure} \subsection{Baselines} \label{subsection:baselines} Our baseline experiments largely follow the setup of \citet{gao-etal-2021-manual}. For sentence encoding, we use CNN \cite{liu2013convolution}, PCNN \cite{zeng2015distant}, and BERT \cite{devlin2019bert}. We used GloVe \cite{pennington2014glove} and Word2Vec \cite{mikolov2013distributed}\footnote{DRE baselines using CNN/PCNN models use 50-dimensional word embeddings from GloVe. Therefore, we trained 50-dim Word2Vec embeddings on PubMed abstracts.} for CNN/PCNN models, and initialized BERT with BioBERT \cite{lee2020biobert}. We trained our models both at \emph{sentence-level} and at \emph{bag-level}. In contrast, prior works only considered bag-level training for Bio-DSRE \cite{dai2019distantly,amin2020data,hogan2021abstractified}. The sentence-level setup is similar to standard RE \cite{wu2019enriching}, with the difference that the evaluation is conducted at bag-level. We also consider different pooling strategies, namely average (AVG), which averages the representations of sentences in a bag, at-least-one \citep[ONE,][]{zeng2015distant}, which generates relation scores for each sentence in a bag and then selects the top scoring sentence, and attention (ATT), which learns an attention mechanism over the sentences within a bag. \begin{figure} \includegraphics[width=1\linewidth]{figures/fig_bert_baselines_pr_curves.png} \centering \caption{Precision-Recall (PR) curves for BERT-based baselines initialized with BioBERT on \textsc{MedDistant19}\xspace. The trends largely follow the general-domain \cite{gao-etal-2021-manual} with exception of BERT+bag+ONE.} \label{fig:pr_curves} \end{figure} \cref{table:main_results} presents our main results. In all the cases, BERT sentence encoder performed better than CNN and PCNN. This trend is similar to the general-domain. We also validate the finding that sentence-level training in pre-trained language models (LMs) performs better than the bag-level \cite{gao-etal-2021-manual,10.1145/3404835.3463103}. We argue that when trained at sentence-level, those sentences that have been correctly labeled by distant supervision (e.g.\@\xspace \cref{fig:bag_example}) provides enough learning signal, given the generalization abilities of LMs. However, in bag-level training, we force the model to jointly learn from clean and noisy samples, thus limiting its overall performance. This raises further questions into using MIL with LMs. But, we do not find this trend to hold for CNN/PCNN, instead the bag-level models performed slightly better. We also find GloVe to be a better initialization for sentence-level training and Word2Vec for bag-level. We further plot PR curves for BERT-based baselines in \cref{fig:pr_curves}. In all cases, AVG proved to be a better pooling strategy; this finding is consistent with prior works. Both \citet{amin2020data} and \citet{gao-etal-2021-manual} found ATT to produce less accurate results with LMs, however, contrary to general-domain, in \textsc{MedDistant19}\xspace, BERT+bag+ONE had lower performance than BERT+bag+ATT. We attribute this to the challenging nature of the benchmark, since it is focused on long-tail relations and therefore, the signal to learn from is insufficient when picking the optimal example in the bag for BERT+bag+ONE. This results in sparse gradients and longer training time.\footnote{While we trained all BERT-based models for 3 epochs, BERT+bag+ONE was trained for 50 epochs} The current state-of-the-art model AMIL (Rel. Type L) from \citet{hogan2021abstractified} creates bags of instances by abstracting entity pairs belonging to the same semantic type pair into a single bag, thus producing heterogeneous bags. Due to the nature of their methodology, it is not suited for sentence-level models, which already produce more accurate results than bag models. To further study the impact of bag-level and sentence-level training on \textsc{MedDistant19}\xspace, we analyse the relation category-specific results as in \citet{chang-etal-2020-benchmark}, and the results on rare and frequent triples as in \citet{hogan2021abstractified}. Following \citet{chang-etal-2020-benchmark}, we grouped the relations based on cardinality, where the cardinality is defined as: for a given relation type, if the set of head or tail entities belong to only one semantic group, then it has cardinality 1 otherwise M (many). The results are shown in \cref{table:sent_vs_bag_rel_cat} for sentence- and bag-level training with average pooling. We note that both training strategies perform comparably on 1-1 category but the bag-level training suffers a huge performance drop in M-1 and 1-M settings. We reason that this could be due to the lack of enough training signal to differentiate between heterogeneous entity types pooled over instances in a bag. Following \citet{hogan2021abstractified}, we also perform sentence-level evaluation of BERT-based encoders trained at sentence-level and bag-level. The authors divided the triples (including "NA" instances) into two categories, those with 8 or more sentences are defined as common triples and others as rare triples. \cref{table:sent_vs_bag_common_rare} shows these results. We note that both training strategies performed comparably on rare-triples with BERT+sent+AVG more precise than BERT+bag+AVG. However, we find noticeable differences on common triples where BERT+bag+AVG had higher recall but still low precision. This could be explained because of overfitting to type and mention heuristics at bag-level, where sentence-level training allows to have more focus on context. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rC{1.2cm}C{1.2cm}C{1.2cm}} \toprule \textbf{Model} & \textbf{P} & \textbf{R} & \textbf{F1} \\ \midrule \multicolumn{4}{c}{\bf All Triples}\\ \midrule BERT+sent+AVG & \textbf{0.44} & 0.49 & \textbf{0.46} \\ BERT+bag+AVG & 0.36 & \textbf{0.52} & 0.42 \\ \midrule \multicolumn{4}{c}{\bf Common Triples} \\ \midrule BERT+sent+AVG & \textbf{0.35} & 0.47 & \textbf{0.40} \\ BERT+bag+AVG & 0.28 & \textbf{0.53} & 0.37 \\ \midrule \multicolumn{4}{c}{\bf Rare Triples} \\ \midrule BERT+sent+AVG & \textbf{0.57} & \textbf{0.52} & \textbf{0.55} \\ BERT+bag+AVG & 0.52 & 0.50 & 0.51 \\ \bottomrule \end{tabular} } \caption{Sentence-level RE metrics comparing BERT baselines trained at bag and sentence-level with AVG pooling on Rare, Common and All triples. The triples also include NA relational instances.} \label{table:sent_vs_bag_common_rare} \end{table} \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rC{1.2cm}C{1.2cm}C{1.2cm}} \toprule \textbf{Model} & \textbf{1-1} & \textbf{1-M} & \textbf{M-1} \\ \midrule BERT+sent+AVG & \textbf{21.3} & \textbf{26.1} & \textbf{30.7} \\ BERT+bag+AVG & 19.4 & 9.4 & 3.0 \\ \bottomrule \end{tabular} } \caption{Averaged F1-micro score on relation specific category. The categories are defined using the \textit{cardinality} of head and tail semantic group types.} \label{table:sent_vs_bag_rel_cat} \end{table} \subsection{Analysis} \textbf{Context, Mention, or Type?} RE models are known to heavily rely on information from entity mentions, most of which is type information, and existing datasets may leak shallow heuristics via entity mentions that can inflate the prediction results \cite{peng2020learning}. To study the importance of mentions, contexts, and entity types in \textsc{MedDistant19}\xspace, we take inspiration from \citet{peng2020learning,han2020more} and conduct an ablation of different text encoding methods. We consider entity mentions with special entity markers \cite{wu2019enriching,amin2020data} as the \emph{Context + Mention} (CM) setting, which is common in RE with LMs. We then remove the context and only use mentions, and we refer to this as the \emph{Only Mention} (OM) setting. This is similar to KG-BERT \cite{yao2019kg} for relation prediction. We then only consider the context by replacing subject and object entities with special tokens, resulting in the \emph{Only Context} (OC) setting. % Lastly, we consider two type-based (STY) variations as \emph{Only Type} (OT) and \emph{Context + Type} (CT). We conduct these experiments with BioBERT trained at sentence-level and evaluated at bag-level. The results are shown in \cref{fig:text_encoding_ablation}. \begin{figure} \includegraphics[width=0.9\linewidth]{figures/fig_encoding_methods_ablation.pdf} \centering \caption{Ablation showing the effect of different text encoding methods following the general-domain trends.}\label{fig:text_encoding_ablation} \end{figure} We observe that the CM method had the highest performance but surprisingly, OM performed quite well. This highlights the ability of LMs to memorize the facts and act as soft KBs \cite{petroni2019language, safavi-koutra-2021-relational}. This trend is also consistent with general-domain \cite{peng2020learning}. The poor performance in the OC setting shows that the model struggles to understand the context, which is more pronounced in noisy-prone distant RE compared to supervised RE. Our CT setup can be seen as sentence-level extrapolation of the AMIL model \cite{hogan2021abstractified}, which struggles to perform better than the baseline (OM). However, comparing OC with CT, it is clear that the model benefits from type information as it can help constraint the relations space. Using only the type information had the least performance as the model fails to disambiguate between different entities belonging to the same type. \textbf{Inductive or Transductive?} To study the impact of \emph{transductive} and \emph{inductive} splits (\cref{table:snomed_kg_splits}), we created another Bio-DSRE corpus using transductive train, validation, and test triples. The corpus generated is different than the inductive one, but it can offer insights into the model's ability to handle unseen mentions. As shown in \cref{table:ind_vs_trans}, the performance using transductive is slightly better than inductive for corpus-level extractions, in terms of AUC, however, the F1-micro score is slightly better in inductive than transductive. We conclude from this that the model is able to learn patterns that exploit mention and type information to extrapolate to unseen mentions. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rccc} \toprule \textbf{Split} & \textbf{AUC} & \textbf{F1-micro} & \textbf{F1-macro} \\ \midrule Inductive (I) & 55.5 & \textbf{56.5} & \textbf{24.8} \\ Transductive (T) & \textbf{57.4} & 53.0 & 24.1 \\ \bottomrule \end{tabular} } \caption{BERT+sent+AVG performance on two corpora, one created with inductive set of triples and the other with transductive set of triples.} \label{table:ind_vs_trans} \end{table} \textbf{Does Expert Knowledge Help?} We now consider several pre-trained LMs with different knowledge capacities, specific to biomedical and clinical language understanding, with the aim to better understand \textsc{MedDistant19}\xspace challenges and gain insights into models behavior. We consider BERT \cite{devlin2019bert} as a baseline model. Next, we consider domain-specific models: ClinicalBERT \cite{alsentzer2019publicly} which is pre-trained on the clinical notes \cite{johnson2016mimic}, BlueBERT \cite{peng2019transfer} and BioBERT \cite{lee2020biobert} which are pre-trained on PubMed, and SciBERT \cite{beltagy2019scibert}, which is pre-trained on PubMed and Computer Science papers. The recently introduced PubMedBERT \cite{gu2021domain} is trained on PubMed from \emph{scratch}, showing state-of-the-art performance on several biomedical tasks. We categorize these models as non-expert since they are only trained with Masked Language Modeling (MLM) objective. In the second category, we consider expert models which either modify the MLM objective or introduce new pre-training tasks using external knowledge, such as UMLS. MedType \cite{vashishth2021improving}, initialized with BioBERT, is pre-trained to predict semantic types. KeBioLM \cite{yuan2021improving}, initialized with PubMedBERT, uses relational knowledge by initializing the entity embeddings with TransE \cite{bordes2013translating}, improving downstream entity-centric tasks, including RE. UmlsBERT \cite{michalopoulos2021umlsbert}, initialized with ClinicalBERT, modifies MLM to mask words belonging to the same CUI and further introduces semantic type embeddings. SapBERT \cite{liu2021self}, initialized with PubMedBERT, introduces a metric learning task for clustering synonyms together in an embedding space. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rcccccc} \toprule \multirow{2}{*}{\textbf{Encoder}} & \multicolumn{5}{c}{\textbf{Knowledge}} & \multirow{2}{*}{\textbf{AUC}} \\ \cline{2-6} & \textit{Biomedical} & \textit{Clinical} & \textit{Type} & \textit{Triples} & \textit{Synonyms} \\ \midrule BERT & & & & & & 0.42 \\ ClinicalBERT & \cmark & \cmark & & & & 0.47 \\ BlueBERT & \cmark & & & & & 0.55 \\ SciBERT & \cmark & & & & & 0.55 \\ BioBERT & \cmark & & & & & 0.55 \\ PubMedBERT & \cmark & & & & & \textbf{0.62} \\ \midrule MedType & \cmark & & \cmark & & & 0.54 \\ KeBioLM & \cmark & & & \cmark & & \textbf{0.61} \\ UmlsBERT & \cmark & \cmark & \cmark & & & 0.53 \\ SapBERT & \cmark & & & & \cmark & 0.57 \\ \bottomrule \end{tabular} } \caption{Fine-tuning different biomedical and clinical domain LMs on \textsc{MedDistant19}\xspace.}\label{table:encoders_study} \end{table} \cref{table:encoders_study} shows the results of these sentence encoders fine-tuned on the \textsc{MedDistant19}\xspace dataset at sentence-level with AVG pooling. Without any domain-specific knowledge, BERT performs slightly worse than the lowest-performing biomedical model, highlighting the presence of shallow heuristics in the data that are common to the general and biomedical domains. While domain-specific pre-training improves the results, similar to \citet{gu2021domain}, we find clinical LMs underperform on the biomedical RE task. There was no performance gap between BlueBERT, SciBERT and BioBERT. However, PubMedBERT brought significant improvement which is consistent with \citet{gu2021domain}. In terms of expert knowledge-based models, we do not notice any improvements instead, all of them had a negative impact. While we would expect type-based models, MedType and UmlsBERT, to bring improvement, their negative effect can be attributed to overfitting certain types and their patterns. KeBioLM, which is initialized with PubMedBERT, slightly degrades the performance despite having seen the triples used in \textsc{MedDistant19}\xspace during pre-training, highlighting the difficulty of the \textsc{MedDistant19}\xspace dataset. SapBERT which uses the synonyms knowledge also hurt PubMedBERT's performance, suggesting that while synonyms can help for entity linking, RE is a much more elusive task in noisy real-world scenarios. \section{Conclusion} In this work, we highlighted a severe training-test overlap in the corpus used by previous studies in Bio-DSRE, causing inflated performance. We noted other inconsistencies including the KGs used and lack of standard baselines. To mitigate these issues, we introduce a new benchmark \textsc{MedDistant19}\xspace, which derives its KG from SNOMED-CT \cite{chang-etal-2020-benchmark} and is particularly focused on long-tail relations. The benchmark can directly be used with standard RE frameworks, such as OpenNRE~\citep{han-etal-2019-opennre}. We conducted a thorough set of experiments and provided baselines showing both the quality of the dataset and the need for better models. \section{Legal \& Ethical Considerations} \textbf{Does the dataset contain information that might be considered sensitive or confidential? (e.g., personally identifying information)} We use PubMed MEDLINE abstracts \cite{canese2013pubmed}\footnote{\url{https://lhncbc.nlm.nih.gov/ii/information/MBR/Baselines/2019.html}} that are publicly available and is distributed by National Library of Medicine (NLM). These texts are in the biomedical and clinical domain, and are almost entirely in English. It is standard to use this corpus as a text source in several biomedical LMs \cite{gu2021domain}. We cannot claim the guarantee that it does not contain any confidential or sensitive information e.g, it has clinical findings mentioned throughout the abstracts such as \textit{A twenty six year old male presented with high grade fever}, which identifies the age and gender of a patient but not the identity. We did not perform thorough analysis to distill such information since it is in public domain. For other concerns, see Appendix section B and D. \section{Introduction} Extracting structured knowledge from unstructured text is important for knowledge discovery and management. Biomedical literature and clinical narratives offer rich interactions between entities mentioned in the text~\cite{craven1999constructing,xu2014automatic}, which can be helpful for applications such as bio-molecular information extraction pharmacogenomics, and identifying drug-drug interactions (DDIs), among others~\cite{luo2017bridging}. Manually annotating these relations for training supervised learning systems is an expensive and time-consuming process~\cite{segura20111st,kilicoglu2011constructing,segura2013semeval,li2016biocreative}, so the task often involves leveraging rule-based~\cite{abacha2011automatic,kilicoglu2020broad} and weakly supervised approaches~\cite{peng2016improving,dai2019distantly}. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{ccccc} \toprule \multirow{2}{*}{\bf Model and Data} & \multicolumn{2}{c}{\bf{Original}} & \multicolumn{2}{c}{\bf{Filtered}}\\ & \textbf{AUC} & \textbf{F1} & \textbf{AUC} & \textbf{F1} \\ \midrule \citet{amin2020data} & 68.4 & 64.9 & 50.8 & 53.1 \\ \citet{hogan2021abstractified} & 82.6 & 77.6 & 11.8 & 19.8 \\ \bottomrule \end{tabular} } \caption{ % Two state-of-the-art Bio-DSRE models were evaluated on the respective datasets before~(Original) and after~(Filtered), removing test relationships also appearing in the training set. % Both models were trained and evaluated at \emph{bag-level}. % } \label{table:fixed_results} \end{table} More recently, \citet{amin2020data} and \citet{hogan2021abstractified} used domain-specific language models~\cite{gu2021domain} that were pre-trained on biomedical data for Bio-DSRE, producing significantly more accurate results when compared with recent results in the general domain~\cite{gao-etal-2021-manual,christopoulou2021distantly,10.1145/3404835.3463103}. In this work, we find that these results can be attributed mainly to the overlap between the training and the test sets, which allows the model to score higher by simply memorizing the training relations rather than generalizing to new, previously unknown ones. In \cref{table:fixed_results}, we show that removing this leakage (51.9\%, \cref{table:leakage_stats}) results in a significant decrease in predictive accuracy. For example, the AMIL model with relation type embedding $L$ proposed by \citet{hogan2021abstractified} achieves an 82.6 AUC when evaluated on their Bio-DSRE dataset while producing an 11.8 AUC when evaluated on the subset of the test set of relationships that do not overlap with the training set. The training-test overlap in the datasets proposed by \citet{hogan2021abstractified} and \citet{amin2020data} is due to the same entities appearing with different names in multiple relationships, although two entity names are mapped to the same UMLS concept \cite{bodenreider2004unified}, they are still treated as two distinct entities. Furthermore, we also identified other problems, such as redundant facts and unclear coverage of UMLS concepts. To mitigate these issues and noting the lack of existing best practices and an agreed-upon benchmark for the Bio-DSRE research, we introduce a new benchmark to fill this gap. With the widespread use of the SNOMED CT in healthcare systems, we follow the guidelines outlined by \citet{chang-etal-2020-benchmark} for benchmarking biomedical link prediction models and propose a considerably challenging Bio-DSRE dataset \textsc{MedDistant19}\xspace. \begin{table}[!t] \centering \resizebox{7.5cm}{!}{ \begin{tabular}{rccc} \toprule \textbf{\bf Triples} & \textbf{Train} & \textbf{Valid} & \textbf{Test} \\ \midrule Textual & 92,972 & 13,555 (51.9\%) & 33,888 (51.2\%) \\ CUI & 211,789 & 41,993 (26.7\%) & 89,486 (26.5\%) \\ \bottomrule \end{tabular} } \caption{ % Training-test leakage we identified in the data constructed and used by \citet{amin2020data}~(see their Appendix~A.4 in the \emph{k-tag} setup). % Numbers between parentheses show the percentage overlap, where the authors considered text-based instead of CUI-based triples. % } \label{table:leakage_stats} \end{table} \section{Related Work} Relation Extraction~(RE) is an important task in biomedical applications. Traditionally, supervised methods require large-scale annotated corpora, which is impractical to scale for broad-coverage biomedical relation extraction ~\cite{kilicoglu2011constructing,kilicoglu2020broad}. In cases where such supervision is available, it is limited to protein-protein interactions~\cite{peng2017deep}, drug-drug interactions~\cite{kavuluru2017extracting}, and chemical-disease interactions~\cite{peng2016improving}. Distant Supervision~(DS) allows for the automated collection of noisy training examples~\cite{mintz2009distant} by aligning a given knowledge base~(KB) with a collection of text sources. DS was used in recent works \cite{alt2019fine} using Multi-Instance Learning~(MIL) by creating \emph{bags} of instances~\cite{riedel2010modeling} for corpus-level triple extraction.\footnote{RE is used to refer to two different tasks: sentence-level detection of relational instances and corpus-level triples extraction, a kind of knowledge completion task \cite{ji2021survey}.} \begin{figure}[!t] \includegraphics[width=1.0\linewidth]{figures/fig_bag_example_v2.2.pdf} \centering \caption{ % An example of a bag instance representing the UMLS concept pair~(\texttt{C0240066}, \texttt{C0085576}) from the \textsc{MedDistant19}\xspace dataset, expressing the relation \textit{cause\_of}. % In this example, three out of six sentences express the relation, while others are incorrect labels resulting from the distant supervision. % } \label{fig:bag_example} \end{figure} \citet{dai2019distantly} proposed the use of the Unified Medical Language System~(UMLS) Metathesaurus~\cite{bodenreider2004unified} as a KB with PubMed~\cite{canese2013pubmed} MEDLINE abstracts as text collection, and implemented a knowledge-based attention mechanism~\cite{han2018neural} for joint learning with knowledge graph completion using SimplE~\cite{kazemi2018simple} embeddings and entity type classification. Their pipeline was simplified by \citet{amin2020data}, who extended R-BERT~\cite{wu2019enriching} to handle bag-level MIL and demonstrated that preserving the direction of the relationships improves the accuracy of the model. Lacking benchmark corpora, \citet{amin2020data} also outlined the steps to create the dataset. Similar steps were followed by \citet{hogan2021abstractified}, who introduced the concept of \emph{abstractified} MIL~(AMIL), by including different argument pairs belonging to the same semantic types (see \cref{fig:ent_types}) pair in one bag, boosting performance on rare-triples. \begin{figure*} \includegraphics[width=0.85\linewidth]{figures/fig_hierarchical_types_v2.3.pdf} \centering \caption{ % Type Hierarchy: each concept in the UMLS is classified under a type taxonomy. % The \emph{coarse-grained} and \emph{fine-grained} entity types are referred to as \textbf{Semantic Group~(SG)} and \textbf{Semantic Type~(STY)} respectively. % } \label{fig:ent_types} \end{figure*} In this work, we investigate recent results from the Bio-DSRE literature by probing the respective datasets for overlaps between training and test sets. We found a significant overlap between the training set and the held-out validation and test sets in the dataset constructed by \citet{amin2020data} and \citet{hogan2021abstractified} (see \cref{table:leakage_stats}). Our inspection revealed concept normalization to be the root cause, whereas in UMLS, each concept is mapped to a \textit{Concept Unique Identifier (CUI)} and a given CUI might have a different surface forms~\cite{bodenreider2004unified}. Consider a relationship between a pair of UMLS entities (\texttt{C0013798}, \texttt{C0429028}). These two entities can appear in different forms within a text, such as (\emph{electrocardiography}, \emph{Q-T interval}), (\emph{ECG}, \emph{Q-T interval}), and (\emph{EKG}, \emph{Q-T interval}); each of these distinct pairs still refers to the same original pair (\texttt{C0013798}, \texttt{C0429028}). \citet{amin2020data} claim no such text-based leakage, but when canonicalized to their CUIs this results in leakage across the splits as reported in \cref{table:leakage_stats}. Since DSRE aims at corpus-level triples extraction, train-test triples leakage is problematic compared to supervised relation extraction at sentence-level, where we aim to generalize RE models to newer contexts. Prior works in distantly supervised biomedical RE \cite{dai2019distantly,amin2020data,hogan2021abstractified} mainly focus on improving the models for Bio-DSRE and construct different datasets, where we noted inconsistencies in the recent works (\cref{table:leakage_stats}). Due to the lack of standard datasets and best practices, we focus on carefully constructing a new dataset intended to be a primary benchmark in Bio-DSRE called \textsc{MedDistant19}\xspace. Our work utilizes the SNOMED CT Knowledge Graph~(KG), extracted from UMLS, that offers a careful selection of the concept types and proper handling of the inverse relations ~\cite{chang-etal-2020-benchmark}. The dataset focuses on rare triples and considers a narrower subset of the relations. In supervised RE, ChemProt \cite{krallinger2017overview} and DDI-2013 \cite{herrero2013ddi} focus on multi-class interactions between chemical-protein and drug-drug respectively. EU-ADR \cite{van2012eu}, GAD \cite{bravo2015extraction} studies binary relation between gene-disease, and CDR \cite{li2016biocreative} focuses on binary relation between chemical-disease. Therefore, being limited in their coverage of entity and relation types. \section{Constructing the MedDistant19 Dataset} \label{sec:md19_construction} \paragraph{Documents} We used PubMed MEDLINE abstracts published up to 2019\footnote{\url{https://lhncbc.nlm.nih.gov/ii/information/MBR/Baselines/2019.html}} as our text source, containing 32,151,899 abstracts. Following \citet{hogan2021abstractified}, we used \textsc{ScispaCy}~\footnote{\url{https://github.com/allenai/scispacy}}~\cite{neumann-etal-2019-scispacy} for sentence tokenization, resulting in 150,173,169 unique sentences. We further used \textsc{ScispaCy} for linking entity mentions to their UMLS CUIs and filtering disabled concepts from UMLS. This resulted in the entity-linked mentions at the sentence level. \paragraph{Knowledge Base} We use UMLS2019AB~\footnote{\url{https://download.nlm.nih.gov/umls/kss/2019AB/umls-2019AB-full.zip}} as our primary knowledge source and apply a set of rules, resulting in a distilled and carefully reduced version of UMLS2019AB. The UMLS Metathesaurus~\cite{bodenreider2004unified} covers concepts from 222 source vocabularies, thus being the most extensive ontology of biomedical concepts. However, covering all ontologies can be challenging given the interchangeable nature of the concepts. For example, \emph{programmed cell death 1 ligand 1} is an alias of concept \texttt{C1540292} in the HUGO Gene Nomenclature Committee ontology~\citep{hgnc}, and it is an alias of concept \texttt{C3272500} in the National Cancer Institute Thesaurus. This makes entity linking more challenging since a surface form can be linked to multiple entity identifiers and makes it easier to have overlaps between training and test sets since the same fact may appear in both with different entity identifiers. Furthermore, benchmark corpora for biomedical Named Entity Recognition~\cite{dougan2014ncbi,li2016biocreative} and RE~\cite{herrero2013ddi,krallinger2017overview} focuses on specific entity types~(e.g.\@\xspace diseases, chemicals, proteins), and are usually normalized to a single ontology~\cite{kilicoglu2020broad}. Following this trend, we also focus on a single vocabulary for Bio-DSRE. We use SNOMED CT, which is the most widely used clinical terminology in the world for documentation and reporting in healthcare~\cite{chang-etal-2020-benchmark}. \begin{table} \centering \resizebox{7.0cm}{!}{ \begin{tabular}{rcc} \toprule \textbf{Properties} & \textbf{Prior} & \textbf{MD19} \\ \midrule \textit{unique NA sentences} & & \cmark \\ \textit{inductive} & & \cmark \\ \textit{triples leakage} & \cmark & \\ \textit{NA-type constraint} & & \cmark \\ \textit{NA-argument role constraint} & & \cmark \\ \bottomrule \end{tabular} } \caption{ % \textsc{MedDistant19}\xspace~(MD19) comparison with prior work~\cite{amin2020data,hogan2021abstractified}. % }\label{table:md19_props} \end{table} \begin{table}[!t] \centering \resizebox{7.5cm}{!}{ \begin{tabular}{rccc} \toprule {\bf Facts} & {\bf Training} & {\bf Validation} & {\bf Testing} \\ \midrule Inductive (I) & 345,374 & 62,116 & 130,563\\ Transductive (T) & 402,522 & 41,491 & 84,414 \\ \bottomrule \end{tabular} } \caption{ % The number of raw inductive and transductive SNOMED-KG triples used for alignment with text. % }\label{table:snomed_kg_splits} \end{table} UMLS classifies each entity in a type taxonomy as shown in \cref{fig:ent_types}. This allows for narrowing the concepts of interest. Following \citet{chang-etal-2020-benchmark}, we consider 8 semantic groups in SNOMED CT: Anatomy~(ANAT), Chemicals \& Drugs~(CHEM), Concepts \& Ideas~(CONC), Devices~(DEVI), Disorders~(DISO), Phenomena~(PHEN), Physiology~(PHYS), and Procedures~(PROC). For a complete list of semantic types covered in \textsc{MedDistant19}\xspace, see \cref{table:md19_semantic_types_and_groups}. Similarly, each relation is categorized into a type and has a reciprocal relation in UMLS (\cref{tab:rel_set_md19}), which can result in train-test leakage~\cite{dettmers2018convolutional}. These steps follow \citet{chang-etal-2020-benchmark}, with the difference that we only consider relations of type \emph{has relationship other than synonymous, narrower, or broader}~(RO); this is consistent with prior works in Bio-DSRE. We also exclude uninformative relations, \textit{same\_as}, \textit{possibly\_equivalent\_to}, \textit{associated\_with}, \textit{temporally\_related\_to}, and ignore inverse relations as generally is the case in RE. In addition, \citet{chang-etal-2020-benchmark} ensure that the validation and test set do not contain any new entities, making it a transductive learning setting where we assume all test entities are known beforehand. However, in real-world applications of biomedical RE, we are expected to extract relations between unseen entities. To support this setup, we also consider an inductive KG split method proposed by \citet{daza2021inductive}. \cref{table:snomed_kg_splits} summarizes the statistics of the KGs used for alignment with the text. We use split ratios of 70\%, 10\%, and 20\%. Relationships are defined between CUIs and have no overlap between training, validation, and test set. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{ccccccc} \toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{Summary}}} & \textbf{Entities} & \textbf{Relations} & \textbf{STY} & \textbf{SG} \\ \cline{3-6} & & 25,028 & 39 & 65 & 8 \\ \midrule \textbf{Split} & \textbf{Instances} & \textbf{Facts} & \textbf{Rare (\%)} & \textbf{Bags} & \textbf{NA (\%)} \\ \midrule \textbf{Train} & 251,558 & 2,366 & 92.3\% & 80,668 & 96.9\% \\ \textbf{Valid} & 179,393 & 806 & 87.8\% & 31,805 & 98.2\% \\ \textbf{Test} & 213,602 & 1,138 & 91.3\% & 50,375 & 98.1\% \\ \bottomrule \end{tabular} } \caption{ % Summary statistics of the \textsc{MedDistant19}\xspace dataset using Inductive SNOMED-KG split~(\cref{table:snomed_kg_splits}). % The number of relations includes the unknown relation type~(NA). % Rare represents the proportion of the fact triples which have 8 or fewer instances in a given split as defined by \citet{hogan2021abstractified}. % \textsc{MedDistant19}\xspace focuses on rare triples with high NA proportions, making it a challenging benchmark. % } \label{table:summary_stats} \end{table} \subsection{Knowledge-to-Text Alignment} We now describe the procedure for searching fact triples to match relational instances in text. Let $\mathcal{E}$ and $\mathcal{R}$ respectively denote the set of UMLS CUIs and relation types, and let $\mathcal{G} \subseteq \mathcal{E} \times \mathcal{R} \times \mathcal{E}$ denote the set of relationships contained in UMLS. For producing a training-test split, we first create a set $\mathcal{G}^{+} \subseteq \mathcal{E} \times \mathcal{E}$ of related entity pairs, as follows: \begin{equation*} \mathcal{G}^{+} = \{ (e_{i}, e_{j}) \mid \langle e_{i}, p, e_{j} \rangle \in \mathcal{G} \lor \langle e_{j}, p, e_{i} \rangle \in \mathcal{G} \}. \end{equation*} Following the Local-Closed World Assumption~\cite[LCWA,][]{dong2014knowledge,DBLP:journals/pieee/Nickel0TG16}, in which we assume that a KG is only locally complete. More precisely, if we have observed any triple for a particular subject, predicate pair $(e_i,r_k)$, then we will assume that any non-existing triple $(e_i, r_k, .)$ is indeed unknown and replace $r_k$ by "NA". Following this, we obtain a set of unrelated entity pairs by corrupting one of the entities in each pair in $\mathcal{G}^{+}$ and making sure it does not appear in $\mathcal{G}^{+}$, obtaining a new set $\mathcal{G}^{-} \subseteq \mathcal{E} \times \mathcal{E}$ of unrelated entities: \begin{equation*} \begin{aligned} \mathcal{G}^{-} & = \{ (\overline{e_{i}}, e_{j}) \mid (e_{i}, e_{j}) \in \mathcal{G}^{+} \land (\overline{e_{i}}, e_{j}) \not\in \mathcal{G}^{+} \}\\ & \cup \{ (e_{i}, \overline{e_{j}}) \mid (e_{i}, e_{j}) \in \mathcal{G}^{+} \land (e_{i}, \overline{e_{j}}) \not\in \mathcal{G}^{+} \}. \end{aligned} \end{equation*} During the corruption process, we enforce two constraints; \begin{inparaenum}[1)] \item \emph{NA-type constraint}: the two entities appearing in each negative pair in $\mathcal{G}^{-}$ should belong to the same entity types as the entities in the initial positive pair, and \item \emph{NA-role constraint}: that the entities used in the negative pair must have appeared in one or more positive pairs. \end{inparaenum} For each entity linked sentence, we only consider those sentences that have SNOMED CT entities and have pairs in $\mathcal{G}^{+}$ and $\mathcal{G}^{-}$. Selected positive and negative pairs are mutually exclusive and have no overlap across splits. Since we only consider unique sentences associated with a pair, this makes for unique negative training instances, in contrast to \citet{amin2020data} who considered generating positive and negative pairs from the same sentence. We define negative examples as relational sentences mentioning argument pairs with \emph{unknown relation type} (NA), i.e.\@\xspace there might be a relationship, but the considered set of relations does not cover it. Our design choices are summarized in \cref{table:md19_props}. We prune high-frequency positive and negative pairs, remove mention-level overlap across the splits and apply type-based mention pruning. Specifically, we pool mentions by type and remove the sentences which have the mention appearing more than 1000 times. This step was valuable in removing highly non-informative mentions, such as \textit{increased} (STY: \textit{Qualitative Concept}), mentioned over 449,951 times compared to \textit{malignant tumor} (STY: \textit{Neoplastic Process}) mentioned 473 times. \cref{table:summary_stats} shows the final summary of \textsc{MedDistant19}\xspace using inductive split and \cref{fig:ent_rel_dist} shows entity and relation plots, following a long-tail. \begin{figure}[!t] \includegraphics[width=0.81\linewidth]{figures/fig_ent_rel_dists.pdf} \centering \caption{ (\textit{Left}) Entity distribution based on Semantic Types. % (\textit{Right}) Relations distribution. % }\label{fig:ent_rel_dist} \end{figure} \section{Experiments} \textsc{MedDistant19}\xspace\footnote{\url{https://github.com/suamin/MedDistant19}} is released in a format that is compatible with the widely adopted RE framework OpenNRE \cite{han-etal-2019-opennre}. To report our results, we use the \emph{corpus-level RE metrics} Area Under the Precision-Recall (PR) curve (AUC), Micro-F1, Macro-F1, and Precision-at-$k$ (P@$k$) with $k \in \{ 100, 200, 300, 1k, 2k \}$, and the \emph{sentence-level RE metrics} Precision, Recall, and F1. Due to imbalanced nature of relational instances~(\cref{fig:ent_rel_dist}), following \citet{gao-etal-2021-manual}, we report Macro-F1 values, and following \citet{hogan2021abstractified} we report sentence-level RE results. \begin{table*}[!t] \centering \resizebox{15cm}{!}{ \begin{tabular}{ccccccccccc} \toprule \textbf{Model} & \textbf{Bag} & \textbf{Strategy} & \textbf{AUC} & \textbf{F1-micro} & \textbf{F1-macro} & \textbf{P@100} & \textbf{P@200} & \textbf{P@300} & \textbf{P@1k} & \textbf{P@2k} \\ \midrule \multirow{5}{*}{CNN} & - & AVG & 5.8 & 10.5 & 3.2 & 32.0 & 28.0 & 23.3 & 15.6 & 10.8 \\ & - & ONE & 6.4 & 10.7 & 2.8 & 33.0 & 26.5 & 23.6 & 15.5 & 11.2 \\ \cmidrule{3-11} & \cmark & AVG & 10.3 & 12.8 & 4.7 & 48.0 & 37.0 & 32.0 & 19.5 & 13.6 \\ & \cmark & ONE & 8.5 & 17.9 & 3.7 & 39.0 & 32.5 & 27.3 & 18.7 & 13.3 \\ & \cmark & ATT & 6.0 & 13.5 & 2.6 & 31.0 & 28.5 & 22.3 & 15.7 & 10.7 \\ \midrule \multirow{5}{*}{PCNN} & - & AVG & 6.3 & 12.8 & 4.8 & 37.0 & 30.0 & 26.6 & 16.8 & 10.6 \\ & - & ONE & 6.6 & 9.7 & 2.9 & 34.0 & 26.0 & 22.3 & 16.3 & 11.7 \\ \cmidrule{3-11} & \cmark & AVG & 9.5 & 15.2 & 5.5 & 48.0 & 36.0 & 31.3 & 19.1 & 13.8 \\ & \cmark & ONE & 6.8 & 15.3 & 2.6 & 34.0 & 27.0 & 26.0 & 16.3 & 12.3 \\ & \cmark & ATT & 5.7 & 13.7 & 2.4 & 36.0 & 24.0 & 23.6 & 14.9 & 10.8 \\ \midrule \multirow{5}{*}{BERT} & - & AVG & \textbf{55.4} & \textbf{55.1} & 23.3 & \textbf{97.0} & 90.0 & 87.3 & \textbf{58.8} & \textbf{37.8} \\ & - & ONE & 53.0 & 52.1 & \textbf{23.6} & 94.0 & \textbf{92.0} & \textbf{87.6} & 57.5 & 36.4 \\ \cmidrule{3-11} & \cmark & AVG & 49.8 & 53.5 & 20.3 & 89.0 & 82.0 & 80.3 & 58.1 & 36.1 \\ & \cmark & ONE & 25.2 & 27.8 & 12.3 & 52.0 & 53.5 & 50.6 & 39.3 & 28.0 \\ & \cmark & ATT & 36.9 & 40.3 & 12.7 & 84.0 & 73.5 & 66.0 & 45.3 & 31.4 \\ \midrule \multicolumn{11}{c}{\textbf{SOTA Published Before \textsc{MedDistant19}\xspace}$^\dagger$} \\ \midrule \multicolumn{3}{c}{JointSimplE\_NER+KATT \cite{dai2019distantly}} & - & - & - & - & - & - & - & 91.3 \\ \multicolumn{3}{c}{RBERT+MIL \cite{amin2020data}} & 68.4 & 64.9 & - & 97.4 & 98.3 & 98.6 & - & 98.3 \\ \multicolumn{3}{c}{AMIL (Rel. Type L) \cite{hogan2021abstractified}} & 87.2 & 81.2 & - & - & - & - & - & 100.0 \\ \bottomrule \end{tabular} } \caption{ Baselines adopted from \citet{gao-etal-2021-manual} for \textsc{MedDistant19}\xspace. % CNN and PCNN models at sentence-level are reported with GloVe, while bag-level models are reported with Word2Vec. % BERT-based models are initialized with BioBERT. % We also include previously published results for completeness. % $\dagger$ The results are not directly comparable due to differences in the corpora used. % All the previously published results were trained at bag-level. % % } \label{table:main_results} \end{table*} \subsection{Baselines} \label{subsection:baselines} Our baseline experiments largely follow the setup of \citet{gao-etal-2021-manual}.\footnote{\url{https://github.com/pminervini/meddistant-baselines}} For sentence encoding, we use CNN~\cite{liu2013convolution}, PCNN~\cite{zeng2015distant}, and BERT~\cite{devlin2019bert}. We used GloVe~\cite{pennington2014glove} and Word2Vec~\cite{mikolov2013distributed}\footnote{DRE baselines using CNN/PCNN models use 50-dimensional word embeddings from GloVe. Therefore, we trained 50-dim Word2Vec embeddings on PubMed abstracts.} for CNN/PCNN models and initialized BERT with BioBERT~\cite{lee2020biobert}. We trained our models both at \emph{sentence-level} and at \emph{bag-level}. In contrast, prior works only considered bag-level training for Bio-DSRE \cite{dai2019distantly,amin2020data,hogan2021abstractified}. The sentence-level setup is similar to standard RE~\cite{wu2019enriching}, with the difference that the evaluation is conducted at the bag level. We also consider different pooling strategies, namely average (AVG), which averages the representations of sentences in a bag, at least one \citep[ONE,][]{zeng2015distant}, which generates relation scores for each sentence in a bag, and then selects the top-scoring sentence, and attention~(ATT), which learns an attention mechanism over the sentences within a bag. \cref{table:main_results} presents our main results. In all the cases, the BERT sentence encoder performed better than CNN and PCNN since pre-trained language models are effective for entity-centric transfer learning \cite{amin2021t2ner}, domain-specific fine-tuning \cite{amin2019mlt}, and can implicitly store relational knowledge during pre-training \cite{petroni2019language}. This trend is similar to the general domain and the experiments provide consistent baselines lacking in the prior works. We also validate the finding that sentence-level training in pre-trained language models~(LMs) performs better than the bag-level~\cite{gao-etal-2021-manual,10.1145/3404835.3463103}. Arguably those sentences that have been correctly labeled by distant supervision~(e.g.\@\xspace \cref{fig:bag_example}) provide enough learning signal at the sentence level, given the generalization abilities of LMs. However, we force the model to jointly learn from clean and noisy samples in bag-level training, thus limiting its overall performance. This raises further questions about using MIL with LMs. But, we do not find this trend for CNN/PCNN. Instead, the bag-level models performed slightly better. We also find GloVe to be a better initialization for sentence-level training and Word2Vec for bag-level. We further plot PR curves for BERT-based baselines in \cref{fig:pr_curves}. \textbf{Pooling Strategies} In all cases, AVG proved to be a better pooling strategy; this finding is consistent with prior works. Both \citet{amin2020data} and \citet{gao-etal-2021-manual} found ATT to produce less accurate results with LMs, however, contrary to general-domain, in \textsc{MedDistant19}\xspace, BERT+bag+ONE had lower performance than BERT+bag+ATT. We attribute this to the nature of the benchmark since it is focused on long-tail relations, and therefore, the signal to learn from is insufficient when picking the optimal example in the bag for BERT+bag+ONE. This results in sparse gradients and longer training time.\footnote{While we trained all BERT-based models for 3 epochs, BERT+bag+ONE was trained for 50 epochs, where further training had limited performance gains.} \textbf{Relational Category} To further study the impact of bag-level and sentence-level training on \textsc{MedDistant19}\xspace, we analyze the relation category-specific results as in \citet{chang-etal-2020-benchmark}, and the results on rare and frequent triples as in \citet{hogan2021abstractified}. Following \citet{chang-etal-2020-benchmark}, we grouped the relations based on cardinality, where the cardinality is defined as: for a given relation type, if the set of head or tail entities belongs to only one semantic group, then it has cardinality 1 otherwise, M (many). The results are shown in \cref{table:sent_vs_bag_rel_cat} for sentence- and bag-level training with average pooling. We note that both training strategies perform comparably in 1-1 category, but the bag-level training suffers a huge performance drop in M-1 and 1-M settings. This could be due to the lack of enough training signal to differentiate between heterogeneous entity types pooled over instances in a bag. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rC{1.2cm}C{1.2cm}C{1.2cm}} \toprule \textbf{Model} & \textbf{1-1} & \textbf{1-M} & \textbf{M-1} \\ \midrule BERT+sent+AVG & \textbf{21.3} & \textbf{26.1} & \textbf{30.7} \\ BERT+bag+AVG & 19.4 & 9.4 & 3.0 \\ \bottomrule \end{tabular} } \caption{ % Averaged F1-micro score on relation-specific category. The categories are defined using the \textit{cardinality} of head and tail semantic group types. % } \label{table:sent_vs_bag_rel_cat} \end{table} \textbf{Long-Tail Performance} Following \citet{hogan2021abstractified}, we also perform sentence-level triples evaluation of BERT-based encoders trained at sentence-level and bag-level. The authors divided the triples (including "NA" instances) into two categories, those with 8 or more sentences are defined as common triples and others as rare triples. \cref{table:sent_vs_bag_common_rare} shows these results. We note that both training strategies performed comparably on rare triples with BERT+sent+AVG more precise than BERT+bag+AVG. However, we find noticeable differences in common triples where BERT+bag+AVG had a higher recall but still low precision. This could be explained because of overfitting to type and mention heuristics at bag-level, whereas sentence-level training allows having more focus on context. The current state-of-the-art model AMIL (Rel. Type L) from \citet{hogan2021abstractified} creates bags of instances by abstracting entity pairs belonging to the same semantic type pair into a single bag, thus producing heterogeneous bags. Due to the nature of their methodology, it is not suited for sentence-level models, which already produce more accurate results than bag models. \begin{figure}[!t] \includegraphics[width=1\linewidth]{figures/fig_bert_baselines_pr_curves.png} \centering \caption{ % Precision-Recall (PR) curves for BERT-based baselines initialized with BioBERT on \textsc{MedDistant19}\xspace. % % } \label{fig:pr_curves} \end{figure} \begin{table}[!t] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rC{1.2cm}C{1.2cm}C{1.2cm}} \toprule \textbf{Model} & \textbf{P} & \textbf{R} & \textbf{F1} \\ \midrule \multicolumn{4}{c}{\bf All Triples}\\ \midrule BERT+sent+AVG & \textbf{0.44} & 0.49 & \textbf{0.46} \\ BERT+bag+AVG & 0.36 & \textbf{0.52} & 0.42 \\ \midrule \multicolumn{4}{c}{\bf Common Triples} \\ \midrule BERT+sent+AVG & \textbf{0.35} & 0.47 & \textbf{0.40} \\ BERT+bag+AVG & 0.28 & \textbf{0.53} & 0.37 \\ \midrule \multicolumn{4}{c}{\bf Rare Triples} \\ \midrule BERT+sent+AVG & \textbf{0.57} & \textbf{0.52} & \textbf{0.55} \\ BERT+bag+AVG & 0.52 & 0.50 & 0.51 \\ \bottomrule \end{tabular} } \caption{ % Sentence-level RE metrics comparing BERT baselines trained at bag and sentence-level with AVG pooling on Rare and Common subsets of \textsc{MedDistant19}\xspace. % The triples include NA relational instances. % } \label{table:sent_vs_bag_common_rare} \end{table} \subsection{Analysis} \textbf{Context, Mention, or Type?} RE models are known to heavily rely on information from entity mentions, most of which is type information, and existing datasets may leak shallow heuristics via entity mentions that can inflate the prediction results \cite{peng2020learning}. To study the importance of mentions, contexts, and entity types in \textsc{MedDistant19}\xspace, we take inspiration from \citet{peng2020learning,han2020more} and conduct an ablation of different text encoding methods. We consider entity mentions with special entity markers \cite{wu2019enriching,amin2020data} as the \emph{Context + Mention} (CM) setting, which is common in RE with LMs. We then remove the context and only use mentions, and we refer to this as the \emph{Only Mention} (OM) setting. This is similar to KG-BERT \cite{yao2019kg} for relation prediction. We then only consider the context by replacing subject and object entities with special tokens, resulting in the \emph{Only Context} (OC) setting. Lastly, we consider two type-based (STY) variations as \emph{Only Type} (OT) and \emph{Context + Type} (CT). We conduct these experiments with BioBERT trained at sentence-level and evaluated at bag-level. We observe in \cref{fig:text_encoding_ablation} that the CM method had the highest performance, but surprisingly, OM performed quite well. This highlights the ability of LMs to memorize the facts and act as soft KBs \cite{petroni2019language, safavi-koutra-2021-relational}. This trend is also consistent with general-domain \cite{peng2020learning}. The poor performance in the OC setting shows that the model struggles to understand the context, more pronounced in noisy-prone distant RE than in supervised RE. Our CT setup can be seen as a sentence-level extrapolation of the AMIL model \cite{hogan2021abstractified}, which struggles to perform better than the baseline (OM). However, comparing OC with CT, it is clear that the model benefits from type information as it can help constraint the space of the relations. Using only the type information had the least performance as the model fails to disambiguate between different entities belonging to the same type. \textbf{Inductive or Transductive?} To study the impact of \emph{transductive} and \emph{inductive} splits (\cref{table:snomed_kg_splits}), we created another Bio-DSRE corpus using transductive train, validation, and test triples. The corpus generated differs from the inductive one, but it can offer insights into the model's ability to handle unseen mentions. As shown in \cref{table:ind_vs_trans}, the performance using transductive is slightly better than inductive for corpus-level extractions in terms of AUC. However, the F1-micro score is slightly better in inductive than transductive. We conclude that the model can learn patterns that exploit mentions and type information to extrapolate to unseen mentions. \begin{figure}[!t] \includegraphics[width=0.9\linewidth]{figures/fig_encoding_methods_ablation.pdf} \centering \caption{Ablation showing the effect of different text encoding methods with \textsc{MedDistant19}\xspace.}\label{fig:text_encoding_ablation} \end{figure} \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rccc} \toprule \textbf{Split} & \textbf{AUC} & \textbf{F1-micro} & \textbf{F1-macro} \\ \midrule Inductive (I) & 55.5 & \textbf{56.5} & \textbf{24.8} \\ Transductive (T) & \textbf{57.4} & 53.0 & 24.1 \\ \bottomrule \end{tabular} } \caption{ % BERT+sent+AVG performance on corpora created with an inductive and transductive set of triples. } \label{table:ind_vs_trans} \end{table} \textbf{Does Expert Knowledge Help?} We now consider several pre-trained LMs with different knowledge capacities, specific to biomedical and clinical language understanding, to gain insights about the state-of-the-art encoders' performance and effectiveness on the \textsc{MedDistant19}\xspace benchmark. We consider BERT \cite{devlin2019bert} as a baseline model. Next, we consider domain-specific models: ClinicalBERT \cite{alsentzer2019publicly} which is pre-trained on the clinical notes \cite{johnson2016mimic}, BlueBERT \cite{peng2019transfer} and BioBERT \cite{lee2020biobert} which are pre-trained on PubMed, and SciBERT \cite{beltagy2019scibert}, which is pre-trained on PubMed and Computer Science papers. The recently introduced PubMedBERT \cite{gu2021domain} is trained on PubMed from \emph{scratch}, showing state-of-the-art performance on several biomedical tasks. We categorize these models as non-expert since they are only trained with Masked Language Modeling (MLM) objective. In the second category, we consider expert models that modify the MLM objective or introduce new pre-training tasks using external knowledge, such as UMLS. MedType \cite{vashishth2021improving}, initialized with BioBERT, is pre-trained to predict semantic types. KeBioLM \cite{yuan2021improving}, initialized with PubMedBERT, uses relational knowledge by initializing the entity embeddings with TransE \cite{bordes2013translating}, improving downstream entity-centric tasks, including RE. UmlsBERT \cite{michalopoulos2021umlsbert}, initialized with ClinicalBERT, modifies MLM to mask words belonging to the same CUI and further introduces semantic type embeddings. SapBERT \cite{liu2021self}, initialized with PubMedBERT, introduces a metric learning task for clustering synonyms together in an embedding space. \begin{table} \centering \resizebox{\linewidth}{!}{ \begin{tabular}{rcccccc} \toprule \multirow{2}{*}{\textbf{Encoder}} & \multicolumn{5}{c}{\textbf{Knowledge Type}} & \multirow{2}{*}{\textbf{AUC}} \\ \cline{2-6} & \textit{Biomedical} & \textit{Clinical} & \textit{Type} & \textit{Triples} & \textit{Synonyms} \\ \midrule & \multicolumn{5}{c}{\textsc{Non-Expert Models}} & \\ \midrule BERT & & & & & & 0.42 \\ ClinicalBERT & \cmark & \cmark & & & & 0.47 \\ BlueBERT & \cmark & & & & & 0.55 \\ SciBERT & \cmark & & & & & 0.55 \\ BioBERT & \cmark & & & & & 0.55 \\ PubMedBERT & \cmark & & & & & \textbf{0.62} \\ \midrule & \multicolumn{5}{c}{\textsc{Expert Knowledge Models}} & \\ \midrule MedType & \cmark & & \cmark & & & 0.54 \\ KeBioLM & \cmark & & & \cmark & & \textbf{0.61} \\ UmlsBERT & \cmark & \cmark & \cmark & & & 0.53 \\ SapBERT & \cmark & & & & \cmark & 0.57 \\ \bottomrule \end{tabular} } \caption{ % Fine-tuning different biomedical and clinical domain LMs on \textsc{MedDistant19}\xspace. % }\label{table:encoders_study} \end{table} \cref{table:encoders_study} shows the results of these sentence encoders fine-tuned on the \textsc{MedDistant19}\xspace dataset at sentence-level with AVG pooling. Without any domain-specific knowledge, BERT performs slightly worse than the lowest-performing biomedical model, highlighting the presence of shallow heuristics in the data common to the general and biomedical domains. While domain-specific pre-training improves the results, similar to \citet{gu2021domain}, we find clinical LMs underperform on the biomedical RE task. There was no performance gap between BlueBERT, SciBERT, and BioBERT. However, PubMedBERT brought significant improvement, consistent with \citet{gu2021domain}. For expert knowledge-based models, we noted a negative impact on performance. While we would expect type-based models, MedType and UmlsBERT, to bring improvement, their negative effect can be attributed to overfitting certain types and their patterns. KeBioLM, which is initialized with PubMedBERT, slightly degrades the performance despite seeing the triples used in \textsc{MedDistant19}\xspace during pre-training, highlighting the difficulty of the \textsc{MedDistant19}\xspace dataset. SapBERT which uses the knowledge of synonyms, also hurt PubMedBERT's performance, suggesting that while synonyms can help in entity linking, RE is a much more elusive task in the noisy real-world scenarios. \section{Limitations} We provide several limitations of our work as presented in its current form. \textsc{MedDistant19}\xspace aims to introduce a new benchmark with good practices. However, it is still limited in its scope of ontologies considered. It also has a limited subset of relation types provided by UMLS. For example, the current benchmark does not include an important relation \textit{may\_treat}, because it is outside SNOMED CT. Since \textsc{MedDistant19}\xspace is focused on SNOMED CT, it lacks coverage of important protein-protein interactions, drugs side-effects, and relations involving genes as provided by RxNorm, Gene Ontology, etc. It is also smaller in size compared to the NYT10 benchmark in the general-domain \cite{riedel2010modeling}. While it is valuable to have a challenging benchmark that can be used to examine the performance of methods on rare triples mainly, it can skew models evaluated against this benchmark towards rare cases. This may lead to the models that do not perform well in real-world scenarios, where data imbalances are present. Despite these limitations, \textsc{MedDistant19}\xspace still offers a challenging and focused benchmark that can help improve the weakly supervised broad-coverage biomedical relation extraction. \section{Conclusion} In this work, we highlighted a severe training-test overlap in the corpus used by previous studies in Bio-DSRE, causing inflated performance. We noted other inconsistencies, including the KGs used and lack of standard baselines. To mitigate these issues and observing a lack of existing best practices or a benchmark, we introduce a challenging new benchmark \textsc{MedDistant19}\xspace, which derives its KG from SNOMED CT \cite{chang-etal-2020-benchmark}. The benchmark can directly be used with standard RE frameworks, such as OpenNRE~\citep{han-etal-2019-opennre}. We conducted a comprehensive set of experiments and provided baselines showing both the quality of the dataset and the need for better models. \section*{Acknowledgments} The authors would like to thank the anonymous reviewers for their helpful feedback. The work was partially funded by the European Union (EU) Horizon 2020 research and innovation programme through the projects Precise4Q (777107) and Clarify (875160), and the German Federal Ministry of Education and Research (BMBF) through the project CoRA4NLP (01IW20010). The authors also acknowledge the cluster compute resources provided by the DFKI and UCL. \section*{Legal \& Ethical Considerations} \textbf{Does the dataset contain information that might be considered sensitive or confidential? (e.g.\@\xspace personally identifying information)} We use PubMed MEDLINE abstracts \cite{canese2013pubmed}\footnote{\url{https://lhncbc.nlm.nih.gov/ii/information/MBR/Baselines/2019.html}} that are publicly available and is distributed by National Library of Medicine (NLM). These texts are in the biomedical and clinical domains and are almost entirely in English. It is standard to use this corpus as a text source in several biomedical LMs \cite{gu2021domain}. We cannot claim the guarantee that it does not contain any confidential or sensitive information e.g, it has clinical findings mentioned throughout the abstracts such as \textit{A twenty-six-year-old male presented with high-grade fever}, which identifies the age and gender of a patient but not the identity. We did not perform a thorough analysis to distill such information since it is in the public domain. \textsc{MedDistant19}\xspace is automatically-created and susceptible to noise and thus needs to be approached carefully as a potential source for biomedical knowledge. While the dataset was not created to represent \emph{true} biomedical knowledge, it has the potential to be treated as a reliable reference. It is worthwhile to construct a manually annotated test set similar to \citet{gao-etal-2021-manual} for the general domain to partly address this issue.
{'timestamp': '2022-04-12T02:27:38', 'yymm': '2204', 'arxiv_id': '2204.04779', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04779'}
arxiv
\section{Introduction} Conversational Semantic Role Labeling (CSRL) \citep{xu2021conversational} is a recently proposed dialogue understanding task, which aims to extract predicate-argument pairs from the entire conversation. Figure \ref{fig:example} illustrates a CSRL example where a CSRL parser is required to identify ``{\small《泰坦尼克号》}(Titanic)'' as the \texttt{ARG1} argument of the predicate ``{\small 看过} (watched)" and the \texttt{ARG0} argument of the predicate ``{\small 是} (is)". We can see that in the original conversation, ``{\small《泰坦尼克号》}(Titanic)'' is omitted in the second turn and referred as ``{\small 这} (this)" in the last turn. By recovering the dropped and referred components in conversation, CSRL has shown its usefulness to a set of Chinese dialogue tasks, including multi-turn dialogue rewriting \citep{su-etal-2019-improving} and response generation \citep{wu-etal-2019-proactive}. However, there remains a paucity of evidence on its effectiveness towards non-Chinese languages owing to the lack of multilingual CSRL models. To adapt a model into new languages, previous solutions can be divided into three categories: 1) manually annotating a new dataset in the target language \citep{daza2020x} 2) borrowing machine translation and word alignment techniques to transfer the dataset from the source language into the target language \citep{daza2019translate, fei2020cross-acl} 3) zero-shot transfer learning with multilingual pre-trained language model \citep{rijhwani2019zero, sherborne2021zero}. Due to the fact that manually collecting annotations is costly and translation-based methods might introduce translation or word alignment errors, zero-shot cross-lingual transfer learning is more practical to the NLP community. \begin{figure}[t!] \centering \includegraphics[width=1.0\linewidth]{example.pdf} \caption{An example of CSRL parsing.} \label{fig:example} \vspace{-1.5em} \end{figure} Recent works have witnessed prominent performances of multilingual pre-trained language models (PrLMs) \citep{devlin2019bert, conneau2020unsupervised} on cross-lingual tasks, including machine translation \citep{lin2020pre, chen-etal-2021-zero}, semantic role labeling (SRL) \citep{conia2020bridging, conia2021unifying} and semantic parsing \citep{fei2020cross-taslp, sherborne2021zero}. However, cross-lingual CSRL, as a combination of three challenging tasks (i.e., cross-lingual task, dialogue task and SRL task), suffers three outstanding difficulties: 1) \textbf{latent space alignment} - how to map word representations of different languages into an overlapping space; 2) \textbf{conversation structure encoding} - how to capture high-level dialogue features such as speaker dependency and temporal dependency; and 3) \textbf{semantic arguments identification} - how to highlight the relations between the predicate and its arguments, wherein PrLMs can only partially encode multilingual inputs to an overlapping vector space. Although there are some success that can separately achieve structural conversation encoding \citep{mehri-etal-2019-pretraining, zhang-zhao-2021-structural} and semantic arguments identification \citep{wu-etal-2021-domain}, a unified method for jointly solving these problems is still under-explored, especially in a cross-lingual scenario. In this work, we summarize our contributions as follows: \textbf{(1)} We propose a simple but effective model which consists of three modules, namely cross-lingual language model (CLM), structure-aware conversation encoder (SA-Encoder) and predicate-argument encoder (PA-Encoder), and five well-designed pre-training objectives. Our model implicitly learns language-agnostic, conversational structure-aware and semantically rich representations to perform zero-shot cross-lingual CSRL. \textbf{(2)} Experiments show that our method achieves impressive cross-lingual performance on the language pair (Zh$\rightarrow$En) , and outperforms all baselines on the two newly collected English CSRL test sets. \textbf{(3)} We confirm the usefulness of CSRL to the question-in-context rewriting task in English and multi-turn response generation tasks in English, German and Japanese. We believe this finding is important and will facilitate the research of non-Chinese dialogue tasks that suffer from ellipsis and anaphora. \textbf{(4)} We release our code, the new annotated English CSRL test sets and checkpoints of our best models to facilitate the further research at \url{https://github.com/hahahawu/Zero-Shot-XCSRL}. \section{Related Work} \paragraph{Zero-shot cross-lingual transfer learning.} Recently, thanks to the rapid development of multilingual pre-trained language models such as multilingual BERT \citep{devlin2019bert} and XLM-R \citep{conneau2020unsupervised}, a number of approaches have been proposed for zero-shot cross-lingual transfer learning on various downstream tasks, including semantic parsing \citep{sherborne2021zero}, natural language generation \citep{shen2018zero} and understanding \citep{liu2019zero, lauscher2020zero}. In this work, we claim our method is zero-shot because no non-Chinese CSRL annotations are seen during the CSRL training stage. For decoding, we directly use the cross-lingual CSRL model trained on Chinese CSRL data to analyze conversations in other languages. To our best knowledge, our work is the first step to cross-lingual CSRL. \paragraph{Conversational semantic role labeling.} While ellipsis and anaphora frequently occur in dialogues, \citet{xu2021conversational} observed that most of the dropped or referred components can be found in dialogue histories. Following this observation, they proposed conversational semantic role labeling (CSRL) which required the model to find predicate-argument structures over the entire conversation instead of a single sentence. In this way, when analyzing a predicate in the latest utterance, a CSRL model needs to consider both the current turn and previous turns to search potential arguments, and thus might recover the omitted components. Furthermore, \citet{xu2020semantic, xu2021conversational} also confirmed the usefulness of CSRL to Chinese dialogue tasks by applying CSRL information into downstream dialogue tasks. However, there are still two main problems to be solved for CSRL task: (1) the performance of current state-of-the-art CSRL model \citep{xu2021conversational} is still far from satisfactory due to the lack of high-level conversational and semantic features modeling; (2) the usefulness of CSRL to conversational tasks in non-Chinese languages has not been confirmed yet due to the lack of cross-lingual CSRL models. In this work, we primarily focus on the latter problem and propose a simple but effective model to perform cross-lingual CSRL. We would like to distinguish our work from the work \citep{wu-etal-2021-csagn} which purely focuses on improving the monolingual CSRL performance where they try to model predicate-aware representations. This solution could benefit to monolingual CSRL task, but hurt the cross-lingual performance, because the relative positions of the predicates may differ from language to language. \begin{figure*}[t!] \centering \includegraphics[width=0.98\linewidth]{architecture.png} \caption{Overall model architecture.} \label{fig:model} \vspace{-0.2cm} \end{figure*} \section{Methodology} Following \citet{xu2021conversational}, we solve the CSRL task as a sequence labeling problem. Formally, given a dialogue $C = \{u_1, u_2, ..., u_N\}$ of $N$ utterances, where $u_i = \{w^i_1, w^i_2, ..., w^i_{|u_i|}\}$ consisting of a sequence of words, and a predicate indicator ${p} = ({p}_1^1, ..., {p}_k^i, ..., {p}_{|u_N|}^N)$ used to identify whether a word is the predicate or not, our goal is to assign each word with a semantic role label $l \in L$ where $L$ is the label set. We also incorporate speaker role indicator ${r}$ to distinguish speakers, and dialogue turn indicator ${t}$ to distinguish dialogue turns. \subsection{Architecture} \label{sec:architecture} \paragraph{Cross-lingual Language Model (CLM)} We concatenate all utterances into a sequence and then use a pre-trained cross-lingual language model such as XLM-R \citep{conneau2020unsupervised} or mBERT \citep{devlin2019bert} to capture the syntactic and semantic characteristics. Following \citet{conia2021unifying}, we obtain word representations $\textbf{e} \in \mathbb{R}^{|S| \times d}$ by concatenating the hidden states of the four top-most layers of the language model, where $|S|$ is the sequence length and $d$ is the dimension of the hidden state. \paragraph{Structure-aware Conversation Encoder (SC-Encoder)} Different from standard SRL\citep{carreras2005introduction}, CSRL requires the models to find arguments from not only the current turn, but also previous turns, thus bringing more challenges of dialogue modeling. To address this problem, we propose a universal structure-aware conversation encoder which comprises of two parts, i.e., word-level encoder and utterance-level encoder. Formally, with the speaker role embedding $\bm{r} \in \mathbb{R}^{|S| \times d}$ and dialogue turn embedding $\bm{t} \in \mathbb{R}^{|S| \times d}$, the word-level encoder computes a sequence of timestep encodings $\bm{s} \in \mathbb{R}^{|S| \times d}$ as follows: \begin{equation} \small \bm{s}_{(i, k)}^j = \left\{ \begin{array}{ll} \bm{e}_k^i \oplus \bm{t}_k^i \oplus \bm{r}_k^i & \text{if}~~j=0 \\ \bm{s}_{(i, k)}^{j-1} \oplus \textsc{MTrans}^j(\bm{s}_{(i, k)}^{j-1}) & \text{otherwise} \end{array}\right. \end{equation} where $\bm{s}_{(i, k)}^j$ is the timestep encoding of $k$-th token in $i$-th utterance from $j$-th word-level encoder layer while $j \in (0, \dots, N_1)$, $\oplus$ represents vector concatenation, and \textsc{MTrans} is the \textbf{M}odified \textbf{Trans}former encoder layer. Concretely, we replace the \texttt{[Add]} operation in the first residual connection layer with \texttt{[Concat]} because we argue that concatenation is a superior approach to preserve the information from previous layers\footnote{More details about \textsc{MTrans} in Appendix \ref{apx:mtrans}.}. We obtain utterance representations $\bm{u} \in \mathbb{R}^{N \times d}$ by max-pooling over words in the same utterance. Then we pass the resulting utterance representations $\bm{u}$ through a stack of Bi-LSTM \citep{hochreiter1997long} layers to obtain the sequentially encoded utterance representations $\bm{u}^{\prime} \in \mathbb{R}^{N \times d}$. Finally, we combine the utterance-level feature $\bm{u}^{\prime}$ with the word-level feature $\bm{s}$ to obtain structure-aware dialogue context representations $\bm{g} \in \mathbb{R}^{|S| \times d}$ as follows: \begin{equation} \bm{g}_k^i = \text{Swish}(\mathbf{W}^g[\bm{s}_{(i, k)}^{N_1} \oplus \bm{u}_i^{\prime}] + \mathbf{b}^g) \end{equation} where $\text{Swish}(x)=x\cdot\text{sigmoid}(x)$ is a non-linear activation function, $\bm{s}_{i,k}^{N_1}$ is the encoding of $k$-th token in $i$-th utterance from the last layer of the word-level encoder. $\mathbf{W}^g$ and $\mathbf{b}^g$ are trainable parameters. \begin{figure}[t!] \centering \includegraphics[width=1.0\linewidth]{latent_space_alignment.png} \caption{Illustration of pre-training objectives for latent space alignment.} \label{fig:latent_space_alignment} \vspace{-0.2cm} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=1.0\linewidth]{conversation_structure_encoding.png} \caption{Illustration of pre-training objectives for conversation structure encoding.} \label{fig:conversation_structure_encoding} \vspace{-0.5cm} \end{figure} \paragraph{Predicate-Argument Encoder (PA-Encoder)} We introduce the third module (i.e., predicate-argument encoder) whose goal is to capture the relations between each predicate-argument couple that appears in the conversation. Similar with the word-level encoder, we use a stack of $\textsc{MTrans}$ layers to implement this encoder. Formally, with the predicate embedding $\bm{p} \in \mathbb{R}^{|S| \times d}$, the model calculates the predicate-specific argument encodings $\bm{a} \in \mathbb{R}^{|S| \times d}$ as follows: \begin{equation} \small \bm{a}_{(i, k)}^j = \left\{ \begin{array}{ll} \bm{g}_k^i \oplus \bm{p}_k^i & \text{if}~~j=0 \\ \bm{a}_{(i, k)}^{j-1} \oplus \textsc{MTrans}^j(\bm{a}_{(i, k)}^{j-1}) & \text{otherwise} \end{array}\right. \end{equation} where $\bm{a}_{(i,k)}^{j}$ is the argument encoding of $k$-th token in $i$-th utterance from $j$-th encoder layer while $j \in (0,\dots, N_2)$. Finally, we obtain the semantic role encoding $\bm{l}$ using the resulting argument encodings from the last layer of the predicate-argument encoder: \begin{equation} \bm{l}_k^i = \text{Swish}(\mathbf{W}^l\bm{a}_{(i,k)}^{N_2} + \mathbf{b}^l) \end{equation} In particular, our proposed model is mostly language-agnostic since we do not explicitly introduce any language-specific knowledge such as word order, part-of-speech tags or dependent relations, and only introduce the predicate indicator that might contain some language-specific information in the semantic module, which would not affect latent space alignment and dialogue modeling. \begin{figure}[t!] \centering \includegraphics[width=0.8\linewidth]{semantic_argument_identification.png} \caption{Illustration of pre-training objectives for semantic argument identification.} \label{fig:semantic_argument_identification} \vspace{-1em} \end{figure} \subsection{Pre-training Objectives} \label{sec:pretrain-obj} Besides the universal model, we also elaborately design five pre-training objectives to model task-specific but language-agnostic features for better cross-lingual performance. In this section, we divide our pre-training objectives into three groups according to the challenges to be solved. \paragraph{Latent space alignment} In cross-lingual language module, we use mBERT or XLM-R to align the latent space of different languages. Although mBERT and XLM-R have exhibited good alignment ability, even both of them are trained with unpaired data, we may further improve it when we have access to parallel data. We first use translation language model (TLM) \citep{conneau2019cross} to learn word-level alignment ability. Concretely, we concatenate parallel sentences as a single consecutive token sequence with special tokens separating them and then perform masked language modeling (MLM) \citep{devlin2019bert} on the concatenated sequence. Besides, we also attempt to improve sentence-level alignment ability using hard parallel sentence identification (HPSI). Specifically, we select a pair of parallel or non-parallel sentences from the training set with equal probability. Then the model is required to predict whether the sampled sentence pair is parallel or not. Different from the standard PSI \citep{dou2021word}, we sample the non-parallel sentence upon the n-gram similarity or construct it by text perturbation (details in Appendix \ref{apx:hpsi}) instead of in a random manner. Figure \ref{fig:latent_space_alignment} illustrates the workflows of TLM and HPSI. We pre-train the CLM using the combination of TLM and HPSI, finally achieving latent space alignment. \begin{table*}[t!] \small \fontsize{10}{11} \selectfont \setlength\tabcolsep{2.1pt} \centering \bgroup \def1.2{1.2} \begin{tabular}{l|cccccc} \toprule Dataset & language & \#dialogue & \#utterance & \#predicate & \#tokens per utterance & cross ratio \\ \hline DuConv & ZH & 3,000 & 27,198 & 33,673 & 10.56 & 21.89\% \\ Persona-Chat & EN & 50 & 2,669 & 477 & 17.96 & 17.74\% \\ CMU-DoG & EN & 50 & 3,217 & 450 & 12.57 & 7.41\% \\ \bottomrule \end{tabular} \egroup \caption{Statistics of the annotations on DuConv, NewsDialog and PersonalDialog.} \label{tab:statistics} \vspace{-1em} \end{table*} \paragraph{Conversation structure encoding} Although there are a number of pre-training objectives proposed to learn dialogue context representations \citep{mehri-etal-2019-pretraining} and structural representations \citep{zhang-zhao-2021-structural}, we tend to explicitly model speaker dependency and temporal dependency in the conversation, both of which have been proven to be critical to CSRL task \citep{xu2021conversational}. We first propose speaker role identification (SPI) to learn speaker dependency in the conversation. Specifically, we randomly sample $K_1\%$ utterances and replace their speaker indicators with special mask tags. To make the task harder and effective, we split the utterances into clauses if only two interlocutors utter in turn in a conversation. The goal of SPI is to predict the masked speaker roles according to the corrupted speaker indicators and context. Secondly, we borrow utterance order permutation (UOR) to encourage the model to be aware of temporal connections among utterances in the context. Concretely, given a set of utterances, we randomly shuffle the last $K_2\%$ utterances and require the model to organize them into a coherent context. Figure \ref{fig:conversation_structure_encoding} illustrates the workflows of SPI and UOR. We pre-train the SC-Encoder using the combination of SPI and UOR. \paragraph{Semantic arguments identification} The core of all SRL-related tasks is to recognize the predicate-argument pairs from the input. Therefore, we propose semantic arguments identification (SAI) objective to strengthen the correlations between the predicate and its arguments with the help of external standard SRL corpus, i.e., CoNLL-2012. Specifically, for each SRL sample, we only focus on those arguments, including ARG0-4, ARG-LOC, ARG-TMP and ARG-PRP, all of which are defined in both SRL and CSRL tasks. The model is encouraged to find the textual spans of these arguments with the given predicate. We believe this objective would benefit to boundary detection, especially for location and temporal arguments. Figure \ref{fig:semantic_argument_identification} illustrates the workflow of SAI. We drop the SC-Encoder to fit in standard SRL samples which do not have any conversational characteristics. \subsection{Training} \paragraph{Hierarchical Pre-training} The pre-training is hierarchically conducted according to different modules, and the pre-training of the upper module is based on the pre-trained lower modules. Specifically, we first train CLM module with TLM and HPSI; then we train SC-Encoder with SPI and UOR while keeping the weights of pre-trained CLM module unchanged; finally we train PA-Encoder with SAI while freezing the weights of pre-trained CLM and SC-Encoder modules. Hopefully, we expect that each module could acquire different knowledge with specific pre-training objectives. \paragraph{CSRL training} We initialize the specific modules, including CLM, SC-Encoder and PA-Encoder, from the pre-trained checkpoints. The CSRL model is trained only using Chinese CSRL annotations and no additional data is introduced during the CSRL training stage. We train our model to minimize the cross-entropy error for a training sample with label $y$ based on the semantic role encoding $\bm{l}$, \vspace{-1em} \begin{equation} p = \text{softmax}(\bm{l}_t)\quad \mathcal{L}_{CSRL} = -\sum_{l=1}^L y\log p \end{equation} \section{Experiments} \begin{table*}[t!] \fontsize{9}{10} \selectfont \setlength\tabcolsep{4.5pt} \centering \bgroup \def1.2{1.2} \begin{tabular}{lclcccccccccccc} \toprule[0.8pt] \multirow{2}{*}{Method} & Trainable & \multicolumn{3}{c}{DuConv} & & \multicolumn{3}{c}{Persona-Chat} & & \multicolumn{3}{c}{CMU-DoG} \\ \cline{3-5} \cline{7-9} \cline{11-13} & parameters & F1$_{all}$ & F1$_{cross}$ & F1$_{intra}$ & & F1$_{all}$ & F1$_{cross}$ & F1$_{intra}$ & & F1$_{all}$ & F1$_{cross}$ & F1$_{intra}$ \\ \hline SimpleBERT & 117 M & 86.54 & 81.62 & 87.02 & & - & - & - & & - & - & - \\ CSRL-BERT & 147 M & 88.46 & 81.94 & 89.46 & & - & - & - & & - & - & - \\ CSAGN & 163 M & {\textbf{89.47}} & {\textbf{84.57}} & {\textbf{90.15}} & & - & - & - & & - & - & - \\ SimpleXLMR & 292 M & 84.75 & 63.44 & 85.12 & & 62.96 & 14.29 & 63.03 & & 50.54 & 14.29 & 58.50 \\ CSRL-XLMR & 320 M & 88.03 & 78.12 & 89.33 & & 63.18 & 18.71 & 65.05 & & 53.84 & 34.20 & 59.78 \\ CSAGN-XLMR & 338 M & 88.52 & 82.45 & 89.98 & & 63.02 & 17.82 & 64.97 & & 52.73 & 30.11 & 58.91 \\ Translation-test & - & - & - & - & & 63.49 & 13.90 & 66.67 & & 47.91 & 27.44 & 50.92\\ Translation-train & - & - & - & - & & 60.12 & 9.67 & 62.50 & & 44.27 & 25.40 & 47.87\\ \hline \multicolumn{4}{l}{\textit{Fine-tune all parameters}} \\ \hline Ours$_\text{mBERT}$ & 272 M & 87.20 & 81.14 & 88.11 & & 58.38 & 9.39 & 61.77 & & 48.13 & 20.92 & 52.91 \\ Ours$_{\text{XLM-R}}$ & 372 M & 88.35 & 83.39 & 89.21 & & \textbf{67.29} & 24.29 & \textbf{70.61} & & \textbf{61.74} & \textbf{60.32} & \textbf{62.67}\\ Ours$_{\text{XLM-R + pre-train}}$ & 372 M & {88.60} & {84.10} & {89.24} & & 67.23 & \textbf{25.43} & 69.89 & & 59.24 & 58.94 & 60.89 \\ \hline \multicolumn{4}{l}{\textit{Freeze parameters of the language model}} \\ \hline Ours$_{\text{mBERT}}$ & 180 M & 87.08 & 81.46 & 87.98 & & 59.04 & 11.23 & 62.13 & & 48.87 & 21.78 & 53.54\\ Ours$_{\text{XLM-R}}$ & 180 M & 88.30 & 83.38 & 89.17 & & 65.57 & 24.11 & 68.51 & & \textbf{59.60} & 56.16 & \textbf{60.78}\\ Ours$_{\text{XLM-R + pre-train}}$ & 180 M & {88.60} & {83.72} & {89.27} & & \textbf{66.75} & \textbf{24.13} & \textbf{69.44} & & 58.45 & \textbf{58.92} & 58.82\\ \toprule[0.8pt] \end{tabular} \egroup \caption{Evaluation results on the DuConv, Persona-Chat and CMU-DoG datasets.} \label{tab:csrl-results} \vspace{-0.5cm} \end{table*} \subsection{Datasets} \paragraph{CSRL data} We use the same split as \citet{xu2021conversational} where DuConv annotations are splitted into 80\%/10\%/10\% as train/dev/in-domain test set. Furthermore, we manually collect two CSRL test sets for cross-lingual evaluation based on Persona-Chat\citep{zhang2018personalizing} and CMU-DoG\citep{zhou2018dataset}, both of which are English conversation datasets. The CSRL data annotation is difficult because it needs great expertise in SRL and dialogue. So we only explore cross-lingual CSRL on Chinese$\rightarrow$English (Zh$\rightarrow$En) here, and we leave other languages for future work. Following the instructions in \citet{xu2021conversational}, we manually collect two out-of-domain CSRL test sets based on English dialogue datasets Persona-Chat and CMU-DoG. Specifically, we also annotate the arguments ARG0-4, ARG-TMP, ARG-LOC and ARG-PRP and require that the labeled arguments can only appear in the current turn or the previous turns. We employ three annotators who have studied Chinese CSRL annotations for a period time before this annotation. The first two annotators are required to label all cases and any disagreements between them are solved by the third annotator. The statistics of the datasets are listed in Table \ref{tab:statistics}. \paragraph{Pre-training data} For TLM and HPSI objectives which requires parallel data to enhance alignment ability, we choose IWSLT'14 English$\leftrightarrow$Chinese (En$\leftrightarrow$Zh) translations\footnote{https://wit3.fbk.eu/}. For SPI and UOR objectives whose goal is to model high-level conversational features, we select samples from Chinese conversation dataset (i.e., DuConv) and English conversation datasets (i.e., Persona-Chat and CMU-DoG) with equal probability. For SAI, we borrow the Chinese and English SRL annotations from CoNLL-2012\citep{pradhan2012conll}. We stress that by \textbf{keeping the sampling balance} of Chinese and English data for every pre-training objective and \textbf{sharing all parameters across the languages}, our model would capture task-specific but language-agnostic features. \subsection{Experimental Setup} Following previous work\citep{xu2021conversational}, we evaluate our system on micro-average F1$_{all}$, F1$_{cross}$ and F1$_{intra}$ over the (predicate, argument, label) tuples, wherein we calculate F1$_{cross}$ and F1$_{intra}$ over the arguments in the different, or same turn as the predicate. We refer these two types of arguments as \emph{cross}-arguments and \emph{intra}-arguments. For language in-domain evaluation, we compare to \emph{SimpleBERT} \citep{shi2019simple}, \emph{CSRL-BERT} \citep{xu2021conversational} and \emph{CSAGN} \citep{wu-etal-2021-csagn}, all of which employ the Chinese pre-trained language model as the backbone. For cross-lingual evaluation, we compare to \emph{SimpleXLMR}, \emph{CSRL-XLMR} and \emph{CSAGN-XLMR} by simply replacing the BERT backbones of those models with XLM-R. Additionally, we also compare to the back-translation baselines, i.e., Translate-test and Translate-train. Specifically, Translate-test means that the English test data is translated and projected to Chinese annotations using Google Translate \citep{wu2016google} and the state-of-the-art word alignment toolkit Awesome-align\citep{dou2021word}. Similarly, Translate-train means the Chinese training data is translated and projected to English annotations for training. We feed the translated samples into CSAGN/CSAGN-XLMR to obtain the back-translation results. \begin{table*}[t!] \fontsize{9}{10} \selectfont \setlength\tabcolsep{4.5pt} \centering \bgroup \def1.2{1.2} \begin{tabular}{lccccccccccccc} \toprule[0.8pt] \multirow{2}{*}{Method} & \multicolumn{3}{c}{DuConv} & & \multicolumn{3}{c}{Persona-Chat} & & \multicolumn{3}{c}{CMU-DoG} \\ \cline{2-4} \cline{6-8} \cline{10-12} & F1$_{all}$ & F1$_{cross}$ & F1$_{intra}$ & & F1$_{all}$ & F1$_{cross}$ & F1$_{intra}$ & & F1$_{all}$ & F1$_{cross}$ & F1$_{intra}$ \\ \hline All objectives & \textbf{88.60} & \textbf{83.72} & \textbf{89.27} & & {66.75} & \textbf{24.13} & {69.44} & & 58.45 & \textbf{58.92} & 58.82\\ \hdashline \multicolumn{1}{l}{w/o TLM \& HPSI} & 88.07 & 81.90 & 89.06 & & 65.07 & 23.91 & 68.34 & & 58.23 & 53.15 & 59.24 \\ \multicolumn{1}{l}{w/o SPI \& UOR} & 87.75 & 81.56 & 88.81 & & \textbf{68.35} & 22.86 & \textbf{71.29} & & 58.08 & 47.93 & 60.22 \\ \multicolumn{1}{l}{w/o SAI} & 88.00 & 83.16 & 89.06 & & 64.74 & 23.33 & 67.99 & & \textbf{59.94} & 54.68 & \textbf{61.87} \\ only w/ TLM \& HPSI & 87.82 & 83.21 & 88.95 & & 65.56 & 24.12 & {68.60} & & 57.32 & 52.74 & 59.11 \\ only w/ SPI \& UOR & 88.45 & {83.70} & 89.10 & & 64.09 & 24.09 & 67.50 & & 59.71 & 57.23 & 60.80 \\ only w/ SAI & 88.49 & 82.97 & 89.24 & & 65.82 & 23.30 & 69.18 & & 57.20 & 50.54 & 57.63 \\ \hdashline \multicolumn{1}{l}{w/ end2end pre-training} & 87.28 & 81.02 & 88.73 & & 64.37 & 21.17 & 67.77 & & 57.86 & 50.40 & 58.20 \\ \hline \hline \multicolumn{1}{l}{Ours$_{\text{XLM-R}}$} & \textbf{88.30} & \textbf{83.38} & \textbf{89.17} & & \textbf{65.57} & \textbf{24.11} & \textbf{68.51} & & \textbf{59.60} & \textbf{56.16} & \textbf{60.78}\\ \hdashline \multicolumn{1}{l}{w/o SC-Encoder} & 88.02 & 79.11 & 89.05 & & 63.12 & 17.55 & 66.70 & & 57.72 & 50.42 & 58.03 \\ \multicolumn{1}{l}{w/o PA-Encoder} & 88.10 & 81.32 & 88.78 & & 64.05 & 22.38 & 64.82 & & 58.24 & 54.00 & 59.23 \\ \multicolumn{1}{l}{w/o SC-Encoder and PA-Encoder} & 86.14 & 73.63 & 87.12 & & 62.87 & 12.38 & 63.02 & & 52.44 & 41.02 & 56.23 \\ \hdashline \multicolumn{1}{l}{w/o \textsc{MTrans}} & 88.25 & 83.01 & 89.08 & & 65.27 & 23.10 & 68.38 & & 58.58 & 55.41 & 59.98 \\ \toprule[0.8pt] \end{tabular} \egroup \caption{Ablation studies on pre-training objectives and different modules.} \label{tab:ablation-results} \vspace{-0.5cm} \end{table*} \subsection{Main Results} Table \ref{tab:csrl-results} summarized the results of all compared methods on DuConv, Persona-Chat and CMU-DoG datasets. Firstly, we can see that our method achieves competitive performance over all datasets, especially in cross-lingual scenario where our method outperforms the baselines by large margins no matter fine-tuning or freezing the language model during the CSRL training stage. Although CSAGN exceeds our method on DuConv test set, it fails to work well in cross-lingual scenario. We think this is because it heavily relies on the rich features from the Chinese pre-trained language model and it is overfitting on the predicate-aware information. Superior to CSAGN, our model with the multilingual backbone achieves outstanding performance on both language in-domain and cross-lingual datasets. This observation is expected because (1) our model is language-agnostic which makes the cross-lingual transfer easier; (2) our model captures high-level conversational features in SC-Encoder, thus enhancing the capacities of the model to recognize cross-arguments; (3) rich semantic features are modeled by PA-Encoder, which would improve the capacities of the model to recognize intra-arguments. Secondly, although our model has achieved good performance over all datasets, further improvements can be observed after incorporating the proposed pre-training objectives, especially when freezing the parameters of the language model. Exceptionally, we find that the performance on the CMU-DoG dataset heavily drops after introducing the pre-training objectives, especially in terms of F1$_{intra}$. We think this is because the semantic argument spans in CoNLL-2012 are relatively different from those in CMU-DoG, thus leading to the vague boundary detection and performance drop. To verify this assumption, we conduct an ablation study by removing SAI from the pre-training stage. Interestingly, we observe substantial improvements over F1$_{all}$ and F1$_{intra}$, suggesting that pre-training on CoNLL-2012 does hurt the performance on CMU-DoG. Furthermore, we also find that fine-tuning all parameters leads to slightly better performance than freezing the language model during the CSRL training stage. This finding is consistent with the previous work \citep{conia2021unifying}. Table \ref{tab:ablation-results} presents the results of ablation studies on pre-training objectives and different modules. For the pre-training objectives, we found that (1) removing TLM \& HPSI objective hurts the performance consistently but slightly; (2) SPI \& UOR objectives help the model to better identify the cross-arguments; (3) SAI objective helps to find intra-arguments on DuConv and Persona-Chat, but might hurt the F1$_{intra}$ score on CMU-DoG; (4) hierarchical pre-training is superior to end-to-end pre-training which simultaneously optimizes all auxiliary objectives. We think this is because the end2end pre-training is extremely unstable and confuses the optimization process of the model. For model components, we found that only removing one of the SC-Encoder, PA-Encoder or \textsc{MTrans} slightly affect the performance. However, the performance heavily decreases when SC-Encoder and PA-Encoder are both removed. We think the reason is that at least one module is needed to capture the high-level features on the top of the language model. We preserve these two modules in our model since they essentially learn different abilities, i.e., the ability of dialogue modeling and semantics modeling, which also makes our model more explainable. \begin{table}[t] \small \centering \begin{tabular}{ll} \toprule[0.8pt] {U1} & how many games did the colts win? \\ {U2} & \underline{the Colts}$_\textbf{ARG0}$ finished with a 12-2 record. \\ {Question} & who did they \underline{play}$_{\textbf{predicate}}$ in the playoffs? \\ \textbf{\textcolor{red}{Question$^{\prime}$}} & {\textcolor{red}{who did the Colts play in the playoffs?}} \\ \toprule[0.8pt] \end{tabular} \caption{An example of question-in-context rewriting.} \label{tab:rewrite-case} \vspace{-2em} \end{table} \begin{table*}[t!] \fontsize{9}{10} \selectfont \setlength\tabcolsep{4.5pt} \centering \bgroup \def1.2{1.2} \begin{tabular}{lccccccccccc} \toprule[0.8pt] \multirow{2}{*}{Method} & \multicolumn{3}{c}{Persona-Chat (en)} & & \multicolumn{2}{c}{BConTrast (de)} & & \multicolumn{2}{c}{BSD (ja)} \\ \cline{2-4} \cline{6-7} \cline{9-10} & B1/2 & D1/2 & Human [1-5] & & B1/2 & D1/2 & & B1/2 & D1/2 \\ \hline Seq2Seq & 0.138/0.069 & 0.051/0.094 & 2.72 & & 0.089/0.042 & 0.041/0.089 & & 0.125/0.051 & 0.123/0.248\\ \hdashline mUniLM$_{\text{wo/CSRL}}$ & 0.188/0.113 & 0.114/0.217 & 3.02 & & 0.107/0.061 & 0.079/0.187 & & 0.162/0.080 & 0.175/0.320\\ mUniLM$_{\text{w/CSRL}}$ & {0.195}/{0.122} & {0.116}/{0.223} & {3.16} & & 0.112/0.065 & 0.082/0.191 & & 0.178/0.088 & 0.177/0.326\\ \hdashline mBART$_{\text{wo/CSRL}}$ & 0.198/0.125 & 0.120/0.228 & 3.20 & & 0.115/0.072 & 0.086/0.206 & & 0.193/0.097 & 0.182/0.340\\ mBART$_{\text{w/CSRL}}$ & \textbf{0.217}/\textbf{0.136} & \textbf{0.124}/\textbf{0.233} & \textbf{3.25} & & \textbf{0.118}/\textbf{0.077} & \textbf{0.090}/\textbf{0.212} & & \textbf{0.205}/\textbf{0.110} & \textbf{0.185}/\textbf{0.346}\\ \toprule[0.8pt] \end{tabular} \egroup \caption{Evaluations on response generation tasks in English, German and Japanese.} \label{tab:response-results} \vspace{-0.5cm} \end{table*} \subsection{Applications} \citet{xu2021conversational} has confirmed the usefulness of CSRL by applying CSRL parsing results to two Chinese dialogue tasks, including dialogue context rewriting and dialogue response generation. In the same vein, we also explore whether CSRL could benefit to the same non-Chinese dialogue tasks. \paragraph{Question-in-context Rewriting} \label{sec:rewrite} \emph{Question-in-context rewriting} \citep{elgohary-etal-2019-unpack} is a challenging task which requires the model to resolve the conversational dependencies between the question and the context, and then rewrite the original question into independent one. This is an example in Table \ref{tab:rewrite-case}. The question {``who did they play in the playoffs?"} cannot be independently understood without knowing ``they'' refer to, but it can be resolved with the given context. Since the CSRL models can identify the predicate-argument structures from the entire conversation, we believe that it can help this rewriting task by searching the dropped or referred components from the context. For example, in Table \ref{tab:rewrite-case}, our CSRL parser can find that the {ARG0} of the predicate ``play" is ``the Colts". Motivated by this observation, we attempt to borrow CSRL to help the question rewriting with the context. We first employ the pre-trained cross-lingual CSRL parser (Ours$_{\text{XLM-R + pre-train}}$) to extract predicate-argument pairs from conversations. We adopt the model proposed in \citep{xu2020semantic} to achieve the rewriting. More details about the model are in Appendix \ref{apx:models}. \begin{table}[t!] \small \centering \begin{tabular}{lccc} \toprule[0.8pt] Method & B1 & B2 & B4 \\ \hline Seq2Seq & - & - & 49.67\\ SARG\citep{huang2020sarg} & - & - & \textbf{54.80}\\ RUN\citep{liu2020incomplete} & \textbf{70.50} & 61.20 & 49.10 \\ Human evaluation & - & - & 59.92\\ \hline Ours$_{\text{wo/~CSRL}}$ & 69.24 & 62.93 & 52.78 \\ Ours$_{\text{w/~CSRL}}$ & {70.26} & \textbf{64.19} & {54.23}\\ \toprule[0.8pt] \end{tabular} \caption{Evaluation results on the dataset of CANARD.} \label{tab:canard-results} \vspace{-2em} \end{table} Since the rewriting datasets are only available in Chinese and English, we hereby only evaluate on CANARD \cite{elgohary-etal-2019-unpack} which is a widely used English question rewriting dataset, and report the BLEU scores. Table \ref{tab:canard-results} lists the evaluation results on CANARD. We can see that our implementation with CSRL achieves competitive performance against the state-of-the-art rewriting models, i.e., SARG \cite{huang2020sarg} and RUN \cite{liu2020incomplete}, and significantly outperforms the baseline method \citep{bahdanau2014neural}. Note that, in this part, we are more focused on the improvements after introducing CSRL information. We find that the scores across all metrics are improved with the aid of CSRL. To figure out the reasons of these improvements, we investigate which type of questions could benefit from CSRL information most. By comparing the rewritten questions of different methods, we find that the questions that require information completion, especially those containing referred components (around 15\% cases), benefit from CSRL most. This observation is in line with our expectation that our CSRL parser could consistently offer essential guidance by recovering the dropped or referred text components. \paragraph{Multi-turn Dialogue Response Generation} Besides the rewriting task that is heavily affected by omitted components, we also explore the usefulness of CSRL to \emph{multi-turn dialogue response generation}, one of the main challenges in dialogue community. In contrast to single-turn dialogue response generation, multi-turn dialogues suffer more frequently occurred ellipsis and anaphora, which leads to vague context representations. To this end, we attempt to employ CSRL to build better context representations. In specific, we highlight the words picked up by the CSRL parser, and then teach the model to pay more attention on those words which would hold more semantic features. We evaluate on three dialogue datasets in different languages, including \textbf{Persona-Chat} \citep{zhang2018personalizing} in English, \textbf{BConTrast} \citep{farajian2020findings} in German and \textbf{BSD} \citep{rikters2019designing} in Japanese. We report BLEU-1/2 and Distinct-1/2 scores for the comparison. We employ the pre-trained cross-lingual CSRL parser (Ours$_{\text{XLM-R}}$) to analyze the latest utterance, and obtain the predicate-argument pairs. Then the concatenated sequence of the extracted pairs and the context is fed into our model for response generation. We adopt the UniLM \citep{dong2019unified} or mBART \citep{liu2020multilingual} as our generation model. More implementation details are in Appendix \ref{apx:models}. Table \ref{tab:response-results} summarizes the results on three datasets. We can see that the models with different backbones can consistently benefit from the additional introduced CSRL information. While substantial gains from CSRL information are obtained on English and Japanese dialogues, smaller improvements are observed on the German dialogue task. We think this is because English is well-represented in pre-trained multilingual models and Japanese is more similar to Chinese while German accounts for none of both. Apart from automatic evaluation criteria, we also conduct human evaluation on the English dataset. Specifically, we randomly select 200 generated responses for each method, and then recruit three annotators to evaluate the coherence and informativeness of the response against the conversation context by giving a score ranging from 1(worst) to 5(best). We find that the method with CSRL wins in 35\% cases, and ties with the vanilla model in around 55\% cases. With more careful analysis, we find that the responses that contains entities mentioned in histories benefit from CSRL information most. We think this is because none-phrases are more likely to be recognized as semantic arguments by CSRL parser, and then receive more attentions during encoding. \section{Conclusion} In this work, we propose a simple but effective model with five pre-training objectives to perform zero-shot cross-lingual CSRL, and also confirm the usefulness of CSRL to non-Chinese dialogue tasks.
{'timestamp': '2022-04-12T02:34:15', 'yymm': '2204', 'arxiv_id': '2204.04914', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04914'}
arxiv
\section{Introduction} Curriculum Learning (CL) attempts to optimize the order in which an agent accumulates experience, increasing performance while reducing training time for complex tasks~\cite{narvekar2020curriculum,foglino2019optimization,narvekar2017autonomous}. The core of CL is to generalize the experience and knowledge acquired in simple tasks and leverage it to learn complex tasks. Viable results are achieved in simulation, where the system dynamics can be easily modeled and the environment is predictable. One major limitation of many curriculum learning approaches is that the time to generate the curriculum is greater than the time to learn the target task from scratch, which prohibits the use of such methods in complex, real-world, high-fidelity domains \cite{narvekar2020curriculum}. The useful scenario of transfer to the real world remains challenging: System identification, domain adaptation, and domain randomization have performed Sim2Real transfer by attempting to match simulation with the physical environment (see~\ref{sim2real}), but these methods are elaborate and time-consuming if the simulation dynamics are expensive. Since the dynamics of high-fidelity (HF) environments may not lend themselves to optimize a curriculum \cite{zhang2020automatic, openai2020neurips}, we propose learning the curriculum in a simplified version of the HF environment, which we call the low-fidelity (LF) environment. Parameters from each LF task can then be transferred, generating a corresponding task in the HF environment. This curriculum transfer problem is an open question (see ~\cite{narvekar2020curriculum}), and to our knowledge, our novel approach is the first to address this problem. We refer to this as transferring the {\it schema} of the curriculum: only task parameters are transferred as to address situations where policies and value functions cannot be directly transferred due to differences in the observation and action spaces. High-level task descriptions can be used to model inter-task relationships, and tasks with similar task-descriptors are shown to aid positive transfer~\cite{rostami2020using, sinapov2015learning}. We show that our curriculum transfer approach leads to a quicker convergence even in cases where the dynamics of the LF and HF environments are different enough such that traditional domain adaptation methods do not produce a sufficient boost in learning. \begin{figure*} \centering \includegraphics[width=0.7\linewidth, height=0.3\linewidth]{Images/Overview-CoRL2.pdf} \vspace{-1em} \caption{Overview of the proposed curriculum transfer approach ACuTE. The curriculum is generated and optimized in the low-fidelity environment, which is then mapped to generate a curriculum of the high-fidelity environment and learned before learning the final target task. The policy is then transferred to a physical robot.} \label{fig:overview} \vspace{-1em} \end{figure*} An overview of our approach is shown in Fig~\ref{fig:overview}. We consider a complex task and call it the HF target task, and map it to its simplified LF representation. The simplified dynamics of the LF environment allows curricula generation and experimentation to avoid costly setup and expensive data collection associated with the HF environment. Once an optimized curriculum is generated in the LF environment, the task parameters are mapped to obtain their respective HF counterparts. We learn these source tasks iteratively, transferring skills, before learning the target task. Finally, we perform a demonstration with Sim2Real transfer from the HF environment to test our effectiveness on a physical TurtleBot. In this work, we perform extensive experimental evaluation to demonstrate that curriculum transfer enables the agent to reduce the overall target task time compared to baselines. Through ACuTE, we propose an autonomous curriculum transfer method, which we refer to as ``Automated Curriculum Transfer'', that parameterizes the target task to generate and optimize the sequence of source tasks. We notice quick and efficient learning compared to baseline approaches present in literature such as Domain Adaptation \cite{carr2019domain}, Self-Play \cite{sukhbaatar2018intrinsic} and Teacher-Student curriculum learning~\cite{DBLP:journals/tnn/MatiisenOCS20}. Additionally, we observe an improved jumpstart and time to threshold performance even when we add elements that make the HF target task too difficult to learn without a curriculum. We demonstrate that our approach is independent of the learning algorithm by showing improved performance in the HF environment when using a different learning algorithm from the one used when optimizing the curriculum, and also demonstrate positive transfer with imperfect mapping between the two environments. We observe that the Sim2Real transfer achieves successful task completion performance, equivalent to the HF agent's performance, on a physical TurtleBot. \section{Related Work} \label{sec:related_work} \textbf{Transfer Learning} uses knowledge from learned tasks and transfers it to a complex target task~\cite{taylor2009transfer}. Policy transfer is one such approach, in which the policy learned in a source task is used to initialize the policy for the next task in the curriculum \cite{narayan2017seapot,da2019survey, taylor2009transfer, lazaric2012transfer}. One popular transfer learning technique is to transfer the value function parameters learned in one task to initialize the value function of the next task in curriculum \cite{liu2006value, abel2018policy, liu2019value, lazaric2012transfer}. \textbf{Sim2Real Transfer}\labeltext{Sim2Real Transfer}{sim2real} allows a model to be trained in simulation before deploying onto hardware, reducing time, cost, and safety issues. However, it encounters what Tobin~\emph{et.~al.}~\cite{tobin2017domain} describe as the ``Reality Gap'' where a model does not allow an agent to train on realistic details. The same authors introduce ``domain randomization'' as a solution, later expanded upon by Peng~\emph{et.~al.} \cite{peng2018sim}. Continual learning on incremental simulations can help tackle the sample inefficiency problem of domain randomization~\cite{josifovski2020}. In contrast, Operational Space Control \cite{kaspar2020sim2real} avoids domain randomization while speeding up training with fewer hyperparameters. Carr~\emph{et.~al.} \cite{carr2019domain} proposed a domain adaptation strategy approach, where state knowledge is transferred across semantically related games. Unlike aforementioned works, in this paper, we transfer the curriculum and not the policy to handle situations where Sim2Real fails,~e.g.,~when the observation and action spaces of the simulation and real environment are different. \textbf{Curriculum Learning} was introduced in the early 1990's, where it was used for grammar learning \cite{elman1993learning}, control problems \cite{sanger1994neural} and in supervised classification tasks \cite{bengio2009curriculum}. CL has been extensively used for RL, with applications ranging from complex games \cite{gao2021efficiently,wu2018master}, to robotics \cite{karpathy2012curriculum}, and self-driving cars \cite{qiao2018automatically}. In \cite{narvekar2020curriculum}, the authors propose a framework for curriculum learning (CL) in RL, and use it to classify and survey existing CL algorithms. The three main elements of CL are task generation, task sequencing, and transfer learning. Task generation produces a set of source tasks that can be learned before learning the target task \cite{silva2018object,kurkcu2020autonomous}. Task sequencing orders the generated tasks to facilitate efficient transfer from the source to the target task \cite{narvekar2017autonomous, sukhbaatar2018intrinsic, DBLP:journals/tnn/MatiisenOCS20}. Metaheuristic search methods are a popular tool to evaluate the performance of the task sequencing optimization framework \cite{foglino2019optimization}. In our work, we propose a framework to generate the source tasks and optimize their sequence, while evaluating performance against three baseline approaches. In most existing methods, generating and optimizing the curricula to learn a complex task is still time-consuming and sometimes takes longer compared to learning from scratch. Our proposed framework addresses this concern by generating, optimizing, and then transferring the schema of the curriculum from a simple and easy-to-learn environment to a complex and realistic environment. \vspace{-0.75em} \section{Theoretical Framework} \subsection{Markov Decision Processes} An episodic Markov Decision Process (MDP) $M$ is defined as a tuple $(\mathcal{S},\! \mathcal{A},\! p,\! r,\! \gamma)$, where $\!\mathcal{S}\!$ is the set of states, $\!\mathcal{A}\!$ is the set of actions, $\!p(s'\!|s,a)\!$ is the transition function,~ $\!r(s'\!,a,s)\!$ is the reward function and $\gamma\!\in\! [0,1]$ is the discount factor. For each timestep $t$, the agent observes a state $s$ and performs an action $a$ given by its policy function $\pi_\theta(a|s)$, with parameters $\theta$. The agent's goal is to learn an \emph{optimal policy $\pi^*\!$}, maximizing its discounted return $G_0 = \sum^{K}_{k = 0}\!\gamma^k\! r(s'_k,a_k,s_k) $ until the end of the episode at timestep $K$. \begin{figure*} \begin{center} \begin{tabular}{ c c c } {\includegraphics[width=0.29\textwidth, height=0.215\textwidth]{Images/LF_grid_0.png}} & {\includegraphics[width=0.29\textwidth]{Images/HF_example.jpg}}& {\includegraphics[width=0.29\textwidth]{Images/real_world/turtlebot_boxed.jpg}} \\ {\small{\textbf{(a) Target task in Low Fidelity Environment}}} & {\small{\textbf{(b) Target task in High Fidelity Environment}}} & {\parbox{0.29\textwidth}{\small{\textbf{(c) Target task in Physical Environment, using a camera (blue) to interact with fiducials (red). LIDAR (green) is also visible.}}}} \end{tabular} \end{center} \vspace{-1em} \caption{Illustration of the final target task in LF, HF and physical environment. The agent performs navigation, breaking action on 2 trees and 1 rock and then crafts a stone-axe at the crafting table to successfully terminate the task. \label{fig:Final_tasks}} \end{figure*} \vspace{-1em} \vspace{-0.5em} \subsection{Curriculum Learning (CL)} \label{section:CL} We define a task-level curriculum as: \\ \textit{Let $\mathcal{T}$ be a set of tasks, where $M_i = (\mathcal{S}_i, \mathcal{A}_i, p_i, r_i)$ is a task in $\mathcal{T}$. Let $\mathcal{D^T}$ be the set of all possible transition samples from tasks in $\mathcal{T}$ : $\mathcal{D^T} = \{(s,a,r,s') \, | \, \exists \, m_i \!\in \!\mathcal{T} \: s.t. \: s\! \in\! \mathcal{S}_i, \: a \!\in\! \mathcal{A}_i, \: s' \! \sim\! p_i(\cdot|s,a),\: r \leftarrow r_i(s,a,s') \}$. A curriculum $C = [M_1, M_2, \ldots, M_n]$ is an ordered list of tasks, where $M_i$ is the $i^{th}$ task in the curriculum. The ordered list signifies that samples from $M_i$ must be used for training a policy before samples from $M_{i+1}$ are used. The sequence of tasks terminates on the target task $M_n$.} \vspace{-0.5em} \subsection{Problem Formulation} The aim of CL is to generate a curriculum and train an agent on a sequence of tasks $\{M_1, M_2, ..., M_U\}$, such that the agent's performance on the final target task $(M_U)$ improves relative to learning from scratch. The domains $\mathcal{T}^{HF}$ and $\mathcal{T}^{LF}$ of possible tasks are sets of MDPs in the high-fidelity (HF) and the low-fidelity (LF) environments, respectively. An individual task can be realized by varying a set of \textit{parametric variables} and subjecting the task to a set of \textit{constraints}. The \textit{parametric variables $P$} are a set of attribute-value pair features $[ P_1,..., P_n ]$ that parameterize the environment to produce a specific task. Each $P_i \in P$ has a range of possible values that the feature can take while the $constraints$ of a domain are a set of tasks attained by determining the goal condition $P_G$. Let $\mathcal{C}_U^{\mathcal{T}_{LF}}$ be the set of all curricula over tasks $\mathcal{T}^{LF}$ of length $U$ in the LF environment. Similarly, let $\mathcal{C}_U^{\mathcal{T}_{HF}}$ be the set of all curricula over tasks $\mathcal{T}^{HF}$ of length $U$ in the HF environment. The goal is to find a curriculum ${c_U}^{\mathcal{T}_{LF}}$ in the LF environment that can be transferred through a set of mapping functions $\mathcal{F} := \{f_1, f_2, \ldots, f_n \}$ to attain the curriculum in the HF environment ${c_U}^{\mathcal{T}_{HF}}$. A mapping function maps the parametric variables in the LF environment ($P^{LF}$) to the parametric variables in the HF environment ($P^{HF}$). We characterize the mapping as an affine transformation given by: \[P^{HF} = A\odot P^{LF} + B \] where $A = [a_1, \ldots, a_n]^T \in \mathbb{R}^n$ and $B = [b_1, \ldots, b_n]^T \in \mathbb{R}^n$ denote linear mapping and translation vector and $\odot$ is the Hadamard product. Thus, a parameter mapping ($f_i : P^{LF}_i \rightarrow{} P^{HF}_i$) is given by: \[P^{HF}_i = a_i P^{LF}_i + b_i\] The source tasks of the curriculum in the HF environment are learned before final target task as described in Section~\ref{section:CL}. \vspace{-0.5em} \subsection{Running Example} For the physical environment shown in Fig~\ref{fig:Final_tasks}c, we generate Crafter-TurtleBot (Fig~\ref{fig:Final_tasks}b), a realistic simulation of the physical environment. The aim is to learn a policy in this high-fidelity (HF) environment, through an automated curriculum transfer from the low-fidelity (LF) environment (Fig~\ref{fig:Final_tasks}a), and perform Sim2Real Policy transfer from the HF environment to execute the task in the physical environment. The agent's goal is to break 2 trees to collect 2 pieces of wood, break a rock to collect a stone and craft a stone axe at the crafting table. The agent needs to navigate, face the object and perform the break action to collect it in inventory. The parametric variables for this task are the width $(P_W)$ and height $(P_H)$ of the navigable area, the number of trees $(P_{T,e})$, rocks $(P_{R,e})$, and crafting table $(P_{CT})$ present, the number of wood $(P_{T,i})$ and stones $(P_{R,i})$ present in the inventory of the agent when the episode starts, and the goal $(P_G)$ of the task. The goal is drawn from a discrete set, which can be navigating to an item, breaking a subset of the items present in the environment or crafting the stone axe. As described in Fig~\ref{fig:overview}, the HF target task is mapped to its LF equivalent. The simplified LF dynamics allow efficient curriculum optimization. Once the curriculum is generated, each task of the LF is mapped back to generate an equivalent HF task, which are learned through a curriculum to develop a successful task policy for the target HF task. This policy is then transferred to the Physical Robot through a Sim2Real Transfer. \begin{figure*} \centering \includegraphics[width=0.78\linewidth, height=0.25\linewidth]{Images/one-to-one-mapping.pdf} \vspace{-1em} \caption{\small{Illustrative example of the low-fidelity to high-fidelity mapping in the crafting task.}} \label{fig:one-to-one_example} \end{figure*} \vspace{-0.5em} \subsection{Curriculum Transfer Approach} \label{section:Algorithm for curriculum transfer} ACuTE consists of three parts: Generating a LF target task, Curriculum generation in LF, and Task sequencing and learning in HF. Algorithm~\ref{alg:curriculum_transfer_framework} presents our approach. The first step entails generating the LF target task from the HF target task. To obtain the task parameters for the LF task, we pass the HF target task parameters ($P^{HF_U}$) through the inverse of the affine mapping functions $ f^{-1}(P^{HF_U}) \: \forall f \in \mathcal{F}$ followed by {\tt Generate\_Env} (line 1), to obtain the parameters for the target task in the LF environment. The two requirements for obtaining a corresponding mapping are as follows: \begin{itemize} \item Each task parameter in the HF environment ($P^{HF}$) needs a corresponding task parameter in the LF environment ($P^{LF}$). $\forall \: P^{HF}_i\!\in\!P^{HF} \: \exists \: P^{LF}_i$ s.t. $f_i(P^{LF}_i) = P^{HF}_i$. Varying these task parameters yields different tasks that are sequenced to form a curriculum. \item The final task in the HF environment must be mapped to the final task in the LF environment. $\forall f \in \mathcal{F} \:\exists \: f(P^{LF_U}) = P^{HF_U}$ Thus, we can guarantee that each source task obtained through the curriculum in the LF can be mapped to a corresponding task for the HF environment. \end{itemize} The actions in the HF can be complex, but each action can be simplified to an LF action that need not be correspondingly equivalent. Our approach does not assume an equivalency between the state or the action spaces between the LF and the HF environments, but only on the two requirements listed above. To generate and sequence the source tasks in the LF environment, we compared two approaches. The first approach, called Handcrafted Curriculum Transfer (HC), involves a human expert deciding the parametric variables $P^{HC}$ for the tasks for the curriculum (line 3). The second approach, Automated Curriculum Transfer (AC), automatically generates and optimizes a sequence of source tasks from the parametric variables $P^{AC}$ for the agent to learn the final task with the fewest number of episodes (line 5). \vspace{-0.5em} \subsection{Handcrafted and Automated Curriculum Transfer Generation} To optimize curricula through Handcrafted Curriculum Transfer ({\tt Generate\_HC}) (HC), a human expert determines the parametric variables $P^{HC}$ and the task sequence for the source tasks in the curriculum. Whereas, for optimizing curriculum using the Automated (AC) procedure ({\tt Generate\_AC}), we use the approach given in Algorithm \ref{alg:automated_curr_generation}. We start from an empty sequence of source task parameters $P_W$. The algorithm calls a parameterizing function ({\tt Init\_Src}) that assigns random values to the parametric variables for the first source task $P^{LF_1}$ from the range of values $P^{AC}$ can attain while simultaneously initializing an RL agent ({\tt Init\_Agent}). Based on $P^{LF_1}$, the algorithm generates the first task for the agent, $M^{LF}_1$, using the function ({\tt Generate\_Env}). The agent attempts learning this source task $({\tt Learn})$ with the initial policy $\pi_{1,w,init}$, until the \textit{stopping criterion} is met. The \textit{stopping criterion} determines if the agent's goal rate ($\delta$) is $\! \geq \! \delta_G \!$ in the last $ s $ episodes (Algorithm \ref{alg:curriculum_transfer_framework} line 12). Failure to meet the \textit{stopping criterion} implies that the agent has reached maximum permitted episodes (termed \textit{budget} ($b$)) signifying $\delta \! < \!\delta_G$. The value for $\delta_G$ is set at $0.85$ for our experiments. \begin{algorithm}[b] \small \caption{{\tt ACuTE}($N\!,\!W,\!U,\!P^{HF_U},\!f,\!s,\!b$)} \label{alg:curriculum_transfer_framework} \raggedright \textbf{Output}: HF target task policy: $\pi^{HF}_U$ \\ \textbf{Algorithm:} \begin{algorithmic}[1] \STATE $M^{LF}_U \xleftarrow[]{}$ {\tt Generate\_Env(}$f^{-1}(P^{HF_U})$) \IF{{\tt curriculum = HC}} \STATE $C^{LF}= ${\tt Generate\_HC}$(M^{LF}_U, U)$ \\ \ELSIF{{\tt curriculum = AC}} \STATE $C^{LF}$={\tt Generate\_AC}$(M^{LF}_U, U, N, W, seeds)$\\ \ENDIF \STATE $\pi^{HF}_0 \xleftarrow[]{} \emptyset$ \FOR{$u \in U$} \STATE $M^{HF}_u \xleftarrow[]{} f(C^{LF}_u)$ \WHILE{\textit{episode} $< b$} \STATE $\pi^{HF}_u$ = {\tt Learn}$(M^{HF}_u, \pi^{HF}_{u-1})$ \IF{$\mathbb{E}[\pi^{HF}_u[episode\!-\!s\!:] ] \geq \delta_G$} \STATE \textbf{break} \ENDIF \ENDWHILE \ENDFOR \STATE \textbf{return} $\pi^{HF}_U$ \end{algorithmic} \end{algorithm} \hfill \vspace{-1em} In AC, the first task of the curriculum is randomly initialized $N$ times and learned until \textit{stopping criterion} is met. The algorithm then finds the $W$ most promising solutions (${\tt Best\_Candidates}$), based on fewest interactions to meet the \textit{stopping criterion}. To optimize the sequence of the curriculum, we use beam search \cite{lowerre1976harpy}. Beam search is a greedy search algorithm that uses a breadth-first search approach to formulate a tree. At each level of the tree, the algorithm sorts all the ($N \times W$) successors of the tree ($N$ successor tasks for each task of $W$) at the current level in increasing order of number of episodes required to learn the task $M^{LF}_{u,w,n}$. Then, it selects $(W)$ number of best tasks at each level, given by fewest interactions to reach \textit{stopping criterion}, and performs the same step until the tree reaches the desired number of levels $(U)$. \begin{algorithm}[t] \caption{{\tt Generate\_AC($N,W,U,M^{LF}_U, seeds$)}} \label{alg:automated_curr_generation} \raggedright \textbf{Output}: LF Curriculum Parameters: $P_W$\\ \textbf{Placeholder Initialization}: Timesteps: $T_1,\ldots, T_U \! \leftarrow \!\emptyset$ \\ LF task params for all tasks at each beam level $\xi_1,\ldots, \xi_U \leftarrow \emptyset$\\ LF task params at each width and level $\xi_{1,W}, \xi_{2,W}, \ldots, \xi_{U,W} \leftarrow \emptyset$\\ LF curriculum params ${P_W} \leftarrow \emptyset$ \\LF task policies for all tasks at each beam level: $\Pi_1, \ldots, \Pi_U \leftarrow \emptyset$\\ LF task policies for each width and level: $\Pi_{1,W}, \ldots, \Pi_{U,W} \leftarrow \emptyset$\\ \textbf{Algorithm:} \begin{algorithmic}[1] \small \FOR{$u \in U$} \FOR{$w \in W$} \FOR{$n \in N$} \IF{$u = 1$} \STATE $P^{LF_u} \leftarrow$ {\tt Init\_Src}$(M^{LF}_U)$ \STATE $\pi_{1,w,init} = $ {\tt Init\_Agent}$(seeds)$ \ELSE \STATE $P^{LF_u} \leftarrow$ {\tt Init\_Inter}$(\!\xi_{u-1,W}[w],\! M^{LF}_U)$ \STATE $\pi_{u,w, init} = $ {\tt Load\_Agent}$(\Pi_{u-1,W}[w])$ \ENDIF \STATE $\xi_u\;[w,n] \leftarrow P^{LF_u}$ \STATE $M^{LF}_{u,w,n} = $ {\tt Generate\_Env}$(P^{LF_u})$ \STATE $(t_{u,w,n}, \pi_{u,w,,n,fin}) = $ {\tt Learn}${(M^{LF}_{u,w,n}, \pi_{u,w,n,init}})$ \STATE $T_u\;[w,n] \leftarrow t_{u,w,n} \:, \: \Pi_u\;[w,n] \leftarrow \pi_{u,w,n,fin} $ \ENDFOR \ENDFOR \STATE $T_{u,\!W}, \Pi_{u,\!W}, \xi_{u,\!W} $= {\tt Best\_Candidates}$(T_u, \!\Pi_u,\! W, \!\xi_u)$ \ENDFOR \STATE $P_W \leftarrow $ {\tt Best\_LF\_Params}$(\xi_{1,W}, \xi_{2,W}, \ldots, \xi_{U,W})$ \STATE \textbf{return} $P_W$ \end{algorithmic} \end{algorithm} Now, using the parametric variables $P^{LF_1}$ for each task in the beam ($w\! \in\! W$), the algorithm generates parametric variables $P^{LF_2}$ (${\tt Init\_Inter}$) for the next task $M^{LF}_2$ in the curriculum. This is done by choosing a goal $P_G$ not encountered by the agent until the current level $u$ in the beam $w$, and randomly initializing parametric variables $\geq$ the minimum required to accomplish this goal. The agent then attempts learning $M^{LF}_2$ with the final policy of the previous source task in the beam $\pi_{1,w,fin}$ (${\tt Load\_Agent}$). The task terminates when the agent meets the \textit{stopping criterion}. The algorithm finds the $W$ most promising solutions, given by fewest interactions to reach \textit{stopping criterion} (${\tt Best\_Candidates}$) and carries out this procedure iteratively, until the final target task $M^{LF}_{U}$ is learned. The parameters of the curriculum with the lowest number of episodes to reach the \textit{stopping criterion} is selected as the most promising solution (${\tt Best\_LF\_Params}$) $P_W$ for learning the target task. The curriculum generation procedure requires the length of the curriculum $U$ to be $>=$ the number of goals attainable. This ensures all the goals available ($P_G$) are encountered by the agent in the curriculum. \subsubsection{Task Sequencing and Learning in HF} Once the LF curriculum parametric variables ($P_W$) are obtained, they are passed through the set of mapping functions ($\mathcal{F}$) to attain the task parameters in HF, generating the curriculum source tasks from these parameters. The agent attempts learning the first source task $M^{HF}_1$ with an initial policy $\pi^{HF}_{1,init}$. The task terminates when the agent meets the \textit{stopping criterion}, generating the final policy $\pi^{HF}_{1,fin}$. This learned policy is used as an initial policy for the next source task $M^{HF}_2 $ in the curriculum. This procedure is carried out iteratively, culminating at the HF target task, returning $\pi^{HF}_U$ (Algorithm~\ref{alg:curriculum_transfer_framework}, line 8-15). \section{Experimental Results} \begin{figure*} \begin{center} \begin{tabular}{ c c c } {\includegraphics[width=0.33\linewidth,height=0.23\textwidth]{Images/LF_wo_Fire.png}} & {\includegraphics[width=0.31\linewidth,height=0.23\textwidth]{Images/AC_LFS_wo_Fire.png}}& {\includegraphics[width=0.31\linewidth,height=0.23\textwidth]{Images/AC_Baselines_wo_Fire.png}} \\ {\small{\textbf{(a) LF - gridworld}}} & {\small{\textbf{(b) HF - Crafter-Turtlebot}}} & {\small{\textbf{(c) Crafter-Turtlebot Baselines}}} \\ {\includegraphics[width=0.33\linewidth,height=0.23\textwidth]{Images/LF_Fire.png}} & {\includegraphics[width=0.31\linewidth,height=0.23\textwidth]{Images/AC_LFS_Fire.png}}& {\includegraphics[width=0.31\linewidth,height=0.23\textwidth]{Images/AC_Baselines_w_Fire.png}} \\ {\small{\textbf{(d) LF w/ Fire - gridworld}}} & {\small{\textbf{(e) HF w/ Fire - Crafter-Turtlebot}}} & {\small{\textbf{(f) Crafter-Turtlebot w/ Fire - Baselines}}} \end{tabular} \end{center} \hspace{10mm} \begin{minipage}{0.8\textwidth} \includegraphics[width=\linewidth,height=0.08\textwidth]{Images/CT_AAMAS_label.pdf} \end{minipage} \vspace{-1em} \caption{\small{Learning Curves for low fidelity (LF) and high fidelity (HF) environments with and without Fire.}} \label{fig:learning_curves} \vspace{-1em} \end{figure*} We aim to answer the following questions: (1) Does the automated curriculum transfer yield sample efficient learning? (2) Does it scale to environments that are too difficult to learn from scratch? (3) Is the curriculum transfer framework independent of the RL algorithm used to generate the curriculum? (4) Can we perform a Sim2Real transfer to a physical robot? (5) Can the curriculum transfer framework yield successful convergence with imperfect (e.g., noisy) mappings between the HF and LF environments? \footnote{Code available at: \url{https://github.com/tufts-ai-robotics-group/ACuTE}} To answer the first question, we evaluate our curriculum transfer method on grid-world as low-fidelity (LF) and Crafter-TurtleBot as the high-fidelity (HF) environments. In the LF environment, the agent can move 1 cell forward if the cell ahead is clear or rotate $\pi/2$ clockwise or counter-clockwise. In the target task, the agent receives a reward of $+1\!\times\!10^3$ upon crafting a stone axe, and $-1$ reward for all other steps. In the source tasks of the curriculum, the agent also receives $+50$ reward for breaking an item that is needed for crafting. This reward shaping is absent in the final target task. The agent's sensor emits a beam at incremental angles of $\pi/4$ to determine the closest object in the angle of the beam (i.e., the agents received a local-view of its environment). Two additional sensors provide information on the amount of wood and stones in the agent's inventory (See Appendix Section A.1 for further details). The HF environment, Crafter-TurtleBot, is structurally similar to the grid-world domain, but differs in that objects are placed in continuous locations to more closely model the real-world. The agent is a TurtleBot, rendered in PyBullet \cite{coumans2019}. An example of the LF $\leftrightarrow$ HF mapping between the tasks in LF and HF environments is shown in Fig \ref{fig:one-to-one_example}. Here, the task mapping is demonstrated on an intermediate task of the curriculum, whose goal is to break a rock and craft a stone axe at the crafting table. The task mapping function ensures the LF and HF tasks have the same number and types of objects in the environments and the inventory. The mapping considers increased navigable area in the HF and does not assume the positions of the objects are preserved. In each episode, objects are positioned randomly within the boundaries of the environment. Refer to Appendix A.6 for details on mapping function set $\mathcal{F}$. In the HF environment, the agent's navigation actions are moving forward 0.25 units and rotating by $\frac{\pi}{9}$ radians. The break and craft actions and the reward shaping in source tasks is identical to the LF environment. The HF agent's sensor is similar to the LF agent's sensor; however, it emits beams at incremental angles of $\frac{\pi}{10}$, accounting for the large state space of the location of objects. To evaluate the performance of curriculum transfer, we used the \textit{jumpstart} \cite{lazaric2012transfer, foglino2019optimization} metric. \textit{Jumpstart} evaluates the performance increase over $D$ episodes after transfer from a source task as compared to a baseline approach. \textit{Jumpstart} is defined as: \vspace{-1mm} \[ \eta_j := \frac{1}{D} \sum_{i=1}^D (G^i_{M^c_f} - G^i_{M^b_f})\] \vspace{-1.5mm} \noindent where $G^i_{M^c_f}$ and $G^i_{M^b_f}$ are the returns obtained during episode $i$ in task $M^c_f$ (learning through automated curriculum transfer) and the baseline task $M^b_f$ respectively. Another metric we used is the \textit{time to threshold} metric \cite{taylor2009transfer, narvekar2020curriculum}, which computes how faster an agent can learn a policy that achieves expected return $G \geq \delta$ on the target task if it transfers knowledge, as opposed to learning from another approach, where $\delta$ is desired performance threshold. \vspace{-0.45em} \subsection{Curriculum Generation in High Fidelity} \label{subsection:curricula_generation_results} We used the algorithm presented in Algorithm \ref{alg:curriculum_transfer_framework} to generate and sequence the source tasks using the handcrafted curriculum transfer (HC) and the automated curriculum transfer (AC) approach. The navigable area in target task $M^{LF}_U$ in low-fidelity (LF) environment is a grid of $\mathbb{R}_{LF}^2 \!\xrightarrow{} [10\! \times\!10]$, as seen in Fig \ref{fig:Final_tasks}a, and the high-fidelity (HF) target task area is a continuous $\mathbb{R}_{HF}^2 \!\xrightarrow{} [4 m\! \times\! 4 m]$ space, as seen in Fig \ref{fig:Final_tasks}b. Both these environments contain 4 trees, 2 rocks and 1 crafting table, placed at random locations. The RL algorithm was a Policy Gradient \cite{williams1992simple} network with $\epsilon$-greedy action selection for learning the optimal policy. The episode terminates when the agent successfully crafts a stone axe or exceeds the total number of timesteps permitted, which is $10^2$ in the LF environment and $6\!\times\!10^2$ in the HF environment. All experiments are averaged over 10 trials. (See Appendix Section A.2). For generating the AC in the LF environment, we set the width of the beam search algorithm at $W\!=\!4$, and the length of the beam at $N\!=\!20$, the curriculum length was $U\! =\! 4$, and \textit{budget} $\!b \! = \! 5\times10^3$. We obtained the parameters after performing a heuristic grid search over the space of the search algorithm. We evaluated our curriculum transfer framework with four other baselines. \textit{Learning from scratch} trains the final HF target task without any curriculum. We also adopted three approaches from the literature designed for speeding-up RL agents: Asymmetric Self-play \cite{sukhbaatar2018intrinsic}, Teacher-Student Curriculum learning~\cite{DBLP:journals/tnn/MatiisenOCS20} and Domain Adaptation for RL \cite{carr2019domain}. The first two baselines do not make use of the LF environment while the third uses the LF environment as the source domain. All baseline approaches involve reward shaping similar to the source task of the automated curriculum transfer approach. The results in Figs \ref{fig:learning_curves}a and \ref{fig:learning_curves}b show that the AC approach results in a substantial improvement in learning speed, and is comparable to the curriculum proposed by a human expert. Furthermore, as shown in Fig~\ref{fig:learning_curves}f, the curriculum transfer method outperforms the three baseline approaches\footnote{Refer Appendix Section A.5 for learning curves for reward} in terms of learning speed. The learning curve for our curriculum transfer approaches has an offset on the x-axis to account for the time steps used to go through the curriculum before moving on to the target task, signifying \textit{strong transfer} \cite{taylor2009transfer}. The other three baseline approaches perform better than learning from scratch, but do not outperform the curriculum transfer approach. Self-Play requires training a goal-proposing agent, which contributes to the sunk cost for learning. Whereas, Domain Adaptation relies on the similarity between the tasks. Teacher-Student curriculum learning requires defining the source tasks of the curriculum beforehand, and the teacher attempts to optimize the order of the tasks. All baselines involve interactions in the costly high-fidelity domain for generating/optimizing the curriculum, which proves to be costly. This sunk cost has been accounted in the learning curves by having an offset on the x-axis. See Appendix Section A.3 for details on our adaptation and tuning of these three baselines. Table \ref{table:jumpstart_metric} compares the \textit{jumpstart} values for AC with the baselines. The higher \textit{jumpstart}, the better performance of the curriculum. AC achieves high positive \textit{jumpstart} and \textit{time to threshold} performance in comparison to baseline approaches, denoting improved performance and quicker learning (magnitude $> \!10^7$ timesteps). \subsection{Results with Added Complexity} To answer the second question, we evaluated our framework in a situation where the target task in the HF environment is too difficult to learn from scratch. To do this, both the LF and HF environments were modified by adding a new type of object, ``fire'', such that when the agent comes in contact with it, the episode terminates instantly with a reward of $\!-1\!\times\!10^3$. \begin{table}[t] \small \begin{tabular}{|p{0.09\linewidth}|p{0.38\linewidth}|p{0.16\linewidth}|p{0.16\linewidth}|} \hline Env & Methods & $\Delta$Jumpstart (Return) & $\Delta$Time-to-threshold\\ \hline \multirow{3}{*}{HF}&AC $\xrightarrow[]{}$ Learning from scratch &304 $\pm$ 242& 5.4 $\times 10^7$ \\ &AC $\xrightarrow[]{}$ Carr~\emph{et.~al.}& 231$\pm$160&3.5 $\times 10^7$\\ &AC $\xrightarrow[]{}$ Sukhbaatar \emph{et.~al.}& 85$\pm$130&2.1 $\times 10^7$\\ &AC $\xrightarrow[]{}$ Matiisen \emph{et.~al.}& 568 $\pm$205&6.3 $\times 10^7$\\ \hline \multirow{3}{*}{\shortstack[l]{\\HF\\w/\\Fire}}& AC $\xrightarrow[]{}$ Learning from scratch& 628$\pm$284&1.02 $\times 10^8$\\ &AC $\xrightarrow[]{}$ Carr~\emph{et.~al.}& 519$\pm$126&8.4 $\times 10^7$\\ &AC $\xrightarrow[]{}$ Sukhbaatar \emph{et.~al.}& 288$\pm$87&7.8 $\times 10^7$\\ &AC $\xrightarrow[]{}$ Matiisen \emph{et.~al.}& 346$\pm$121&4.6 $\times 10^7$\\ \hline \end{tabular} \caption{\small{Table comparing \textit{jumpstart} (mean$\pm$SD), and \textit{time to threshold} for learning the final target task. Here, HF and AC refer to high-fidelity and automated curriculum transfer respectively. Time-to-threshold measured in timesteps.}} \label{table:jumpstart_metric} \vspace{-3em} \end{table} \begin{figure}[b] \vspace{-1em} \includegraphics[width=0.7\linewidth,height=0.45\linewidth]{Images/comparison.png} \caption{\small{Learning HF target task through different RL algorithms.}} \label{fig:A2C} \end{figure} The parameters listed in Section \ref{subsection:curricula_generation_results} are used to optimize AC in the LF environment. From learning curves in Figs. \ref{fig:learning_curves}d, \ref{fig:learning_curves}e, \ref{fig:learning_curves}f and Table \ref{table:jumpstart_metric}, we observe our curriculum transfer approach, AC, consistently achieving higher average reward, better \textit{jumpstart} and \textit{time to threshold} performance compared to baselines. Learning from scratch fails to converge to a successful policy in $10^8$ interactions, while the other baseline achieves marginally better performance than learning from scratch. Table~\ref{table:jumpstart_metric} summarizes the jumpstart and the time-to-threshold between the approaches. Our approach still achieves a high jumpstart, and converges much quicker than other approaches. Through this experiment, we see our AC approach extrapolates to challenging environments, producing quicker and efficient convergence. Refer Appendix section A.1.1 for trends observed in different runs in our AC approach. \vspace{-0.6em} \subsection{Results with Different RL Algorithms} To answer the third question, we conducted experiments by making the HF learning algorithm different (PPO~\cite{DBLP:journals/corr/SchulmanWDRK17} and DQN~\cite{mnih_human-level_2015}) from the RL algorithm used for generating the curriculum in the LF environment (Policy gradient). Fig \ref{fig:A2C} shows the result of this test (See Appendix A.4 for hyperparameters). In all the cases, learning through a curriculum is quicker and more efficient than learning from scratch. Here, we do not intend to find the best RL algorithm to solve the task, but demonstrate that actor-critic networks, policy gradients and value function based approaches learn the HF target task through curriculum, irrespective of the RL algorithm used to optimize the LF curriculum. \begin{figure*} \begin{center} \begin{tabular}{ c c c } \label{fig:learning_curves_noisy} {\includegraphics[width=0.33\linewidth,height=0.23\textwidth]{Images/noise_wo_fire.png}} & {\includegraphics[width=0.31\linewidth,height=0.23\textwidth]{Images/noise_fire.png}}& {\includegraphics[width=0.15\linewidth,height=0.23\textwidth]{Images/CT_AAMAS_label_noise.pdf}} \\ {\small{\textbf{(a) Noisy mappings - HF}}} & {\small{\textbf{(b) Noisy mappings - HF w/ Fire}}} & {} \end{tabular} \caption{\small{Comparison of Learning Curves for high fidelity (HF) environments generated using noisy mappings.}} \label{fig:learning_curves_noisy} \end{center} \end{figure*} \subsection{Noisy Mappings} In the above sections, we evaluated the curriculum transfer schema on accurate mappings between the two environments. In certain partially observable environments, it might not be possible to obtain such an accurate mapping between the two environments. To demonstrate the efficacy of our approach in imperfect mappings, we evaluate the experiments by incorporating noise in the mapping function. The noisy mapping function involves a multivariate noise over the range of the parametric variables. While obtaining the noisy parameters, we do not incorporate any noise in the parameter for the goal condition, as we can safely assume that the goals have been mapped accurately. The noisy mappings are given by: \[P_{noisy} = P_{exact} + \mathcal{N}(0, \Sigma) \] where $\Sigma = \begin{bmatrix} \sigma_1 & 0 & 0 & \ldots\\ 0 & \sigma_2 & 0 & \ldots\\ \ldots & \ldots & \ldots & \ldots\\ \ldots & \ldots & \ldots & \sigma_n \end{bmatrix}_{n \times n}$is the covariance matrix, which is symmetric and positive semi-definite, and $\sigma_i = (max(P_i) - min(P_i))/6$, covers the entire range of the parametric variable in six standard deviations. We verify whether the noisy parameters meet the minimum requirements of reaching the goal for the sub-task. If the requirements are not met, we generate a new set of noisy parameters until the requirements are met. The learning curves for the automated curriculum transfer generated through noisy parameters are shown in Fig~\ref{fig:learning_curves_noisy}. We compare its performance with learning curves for automated curriculum transfer generated through exact mappings, and with other baseline approaches present in the literature. Even with noisy mappings, the automated curriculum transfer outperforms other curriculum approaches, and performs comparable to the automated curriculum transfer with exact mappings. On the complicated task (HF with Fire), the automated curriculum transfer with noisy mappings takes longer to converge on the source tasks of the curriculum, yet it achieves a significant performance advantage over other baselines. \subsection{Runtime Comparison} Since our approach relies on the low-fidelity environment for curriculum generation, its sunk cost in computational runtime is significantly lesser than baseline approaches, in which curriculum generation requires extensive interactions in the costly high-fidelity environment. Fig~\ref{fig:runtime} compares the computational runtime (in CPU Hours) required to run one trial (with each episode having a maximum of $6\times 10^2$ timesteps) of the high-fidelity task until the \textit{stopping criterion} is met. The experiments were conducted using a 64-bit Linux Machine, having Intel(R) Core(TM) i9-9940X CPU @ 3.30GHz processor and 126GB RAM memory. The sunk cost of our automated curriculum transfer approach involves the interactions required to optimize the curriculum in the LF environment, and the interactions required to learn the source tasks in the HF environment. \begin{figure}[t] \includegraphics[width=0.8\linewidth,height=0.45\linewidth]{Images/runtime.png} \vspace{-1em} \caption{\small{Runtime comparison of different approaches.}} \label{fig:runtime} \vspace{-1em} \end{figure} \section{Transfer to a Physical Robot}\label{appendix:transfer_to_robot} To answer the fourth question and demonstrate the efficacy of this approach in the real-world, we performed a Sim2Real transfer on a TurtleBot after the simulated robot had learned the target task through the curriculum. We demonstrate object breaking and item retrieval, followed by crafting, through a TurtleBot which reads fiducials scattered throughout the environment. We made use of the TurtleBot~2, modified to have an on-board laptop (running Ubuntu 16.04 and ROS Kinetic) which interfaces with a camera (the Intel D435i) and a LIDAR unit (the Slamtec RPLIDAR-A2). These additional sensors were used to provide more stable odometry via the Canonical Scan Matcher \cite{censi2008icp}, as the default odometry stack was found to have too much drift to be relied upon. The full platform is visible in Fig \ref{fig:Final_tasks}c. Making use of the modified odometry stack, movement was provided as actions that attempt movement in the approximate units expected by the high-fidelity environment. In this setting, the target task policy learned through our automated curriculum transfer approach in the high-fidelity Crafter-TurtleBot environment is transferred to run in this physical setting. No learning is taking place on the agent as the physical experimentation continues. These fiducials are QR codes corresponding to the different possible objects in the known environment: trees, rocks, and the crafting table. When demonstrated, the agent controls the TurtleBot to navigate to the Tree locations before calling the break action, and is then visible navigating to the Rock locations before again calling the break action. The agent completes the sequence by navigating to the crafting table before calling the craft action. The policy is run without any modifications. It is important to note that breaking and crafting actions are successful only in the event of reading the fiducial. In this way, we restrict the agent to being successful only in the cases where it has operated successfully in the physical environment, allowing the agent to proceed only in the event of a sensible Sim2Real transfer. \vspace{-0.5cm} \section{Conclusion and Future Work} We proposed a framework for automated curriculum transfer from an easy-to-solve environment to a real-world scenario. Our curriculum transfer approach generated results comparable to a curriculum generated by a human expert, exceeding the baseline performances. Our experimental evaluations show improved learning time and jumpstart performance on the final target task, even when additional challenging elements are introduced. We demonstrated ACuTE is independent of the RL algorithm used to generate the curriculum and is easily Sim2Real transferable to a physical robot setting and is also scalable to environments with inexact mappings. An extension of our approach will be to scale the algorithm to multi-agent settings, with inter-agent curriculum transfer. A limitation of this work is that the task mapping is generated heuristically, a future work would involve automating the mapping generation. Future work can investigate how a LF version of the environment can be created autonomously, and providing a theoretical guarantee for the curriculum transfer approach. Second, while in this work we only transferred the schema of the curriculum, our baseline comparison with Domain Adaptation suggests that DA can be combined with curriculum transfer such that the agent can learn the tasks in the curriculum even faster. Finally, our algorithms for optimizing the curriculum in the LF environment did not make use of any data from the HF domain, and in future work, we plan to modify our framework to use interaction experience from both domains when constructing the curriculum. \vspace{-0.5cm} \begin{acks} The research presented in this paper was conducted with partial support from DARPA (contract W911NF-20-2-0006) and AFRL (contract FA8750-22-C-0501). \end{acks} \bibliographystyle{ACM-Reference-Format} \balance
{'timestamp': '2022-04-12T02:29:41', 'yymm': '2204', 'arxiv_id': '2204.04823', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04823'}
arxiv
\section{Introduction} \label{sec:1} Contextual bandits are ubiquitous models in reinforcement learning and sequential decision making in environments with finite action spaces. The range of applications is extensive and includes different problems that time-varying and action-dependent information are important, such as personalized recommendation of news articles, healthcare interventions, advertisements, and clinical trials~\cite{li2010contextual,bouneffouf2012contextual,tewari2017ads,nahum2018just,durand2018contextual,varatharajah2018contextual,ren2020dynamic}. In many applications, consequential variables for decision making are not perfectly observed. Technically, the context vectors are often observed in a partial, transformed, and/or noisy manner~\cite{bensoussan2004stochastic,bouneffouf2017context,tennenholtz2021bandits}. In general, sequential decision making algorithms under imperfect observations provide a richer class of models compared to those of perfect observations. Accordingly, they are commonly used in different problems, including space-state models for robot control and filtering \cite{roesser1975discrete,nagrath2006control,kalman1960new,stratonovich1960application}. We study contextual bandits with imperfectly observed context vectors. The probabilistic structure of the problem understudy as time proceeds, is as follows. At every time step, there are $N$ available actions (also referred to as `arms'), and the unobserved context of arm $i$ at time $t$, denoted by $x_i(t) \in \mathbb{R}^{d_x}$, is generated according to a multivariate normal distribution $N(0_{d_x}, \Sigma_x)$. Moreover, the corresponding observation (i.e., output) is $y_i(t)\in \mathbb{R}^{d_y}$, while the stochastic reward $r_i(t)$ of arm $i$ is determined by the context and the unknown parameter $\mu_*$. Formally, we have \begin{eqnarray} y_i(t) &=& A x_i(t) + \zeta_{i}(t)\label{eq:om},\\ r_i(t) &=& x_i(t)^\top \mu_* + \psi_{i}(t),\label{eq:reward} \end{eqnarray} where $\zeta_{i}(t)$ and $\psi_{i}(t)$ are the noises of observation and reward, following the the distributions $N(0_{d_y}, \Sigma_{y})$ and $N(0, \gamma_r^2)$, respectively. Further, the $d_y \times d_x$ sensing matrix $A$ captures the relationship between $x_i(t)$ and the noiseless portion of $y_i(t)$. At each time, the goal is to learn to choose the optimal arm $a^*(t)$ maximizing the reward, by utilizing the available information by time $t$. That is, the agent chooses an arm based on the observations collected so far from the model in \eqref{eq:om}. So, the resulting reward will be provided to the agent according to the equation in \eqref{eq:reward}. Clearly, to choose high-reward arms, the agent needs accurate estimates of the unknown parameter $\mu_*$, as well as those of the contexts $x_i(t)$, for $i=1, \cdots, N$. However, because $x_i(t)$ is not observed, the estimation of $\mu_*$ is available only through the output $y_i(t)$. Thereby, design of efficient reinforcement learning algorithms with guaranteed performance is challenging. Bandits are thoroughly investigated in the literature, assuming that $\{x_i(t)\}_{1\leq i \leq N}$ are perfectly observed. Early papers focus on the method of Upper-Confident-Bounds (UCB) for addressing the exploitation-exploration trade-off~\cite{lai1985asymptotically,abe1999associative,auer2002using,abbasi2011improved,chu2011contextual}. UCB-based methods take actions following optimistic estimations of the parameters, and are commonly studied in reinforcement learning \cite{abbasi2011regret,faradonbeh2020optimism}. Another popular and efficient family of reinforcement learning policies use randomized exploration, usually in the Bayesian form of Thompson sampling~\cite{chapelle2011empirical, agrawal2013thompson,faradonbeh2019applications,faradonbeh2020input,faradonbeh2020adaptive,modi2020no}. For contextual bandits that contexts are generated under certain conditions, exploration-free policies with Greedy nature can expose efficient performance~\cite{bastani2021mostly}. Besides, numerical analysis shows that Greedy algorithms outperform Thompson sampling under imperfect context observations \cite{park2022efficient}. Therefore, this work focuses on the theoretical analysis of Greedy policies for imperfectly observed contextual bandits. Currently, theoretical results for bandits with imperfect context observations are scarce. One approach is to assume that additional information is provided to the algorithm (e.g., a known nuisance parameter)~\cite{tennenholtz2021bandits}. However, such information is not available in general, and such assumptions can lead to persistently sub-optimal action selection. When the output observations are of the same dimension as the context vectors, average-case asymptotic efficiency is shown~\cite{park2021analysis}. That is, the expected regret of Thompson sampling policies that use context estimates for calculating the posterior, scales asymptotically as the logarithm of time~\cite{park2021analysis}. However, comprehensive analyses and non-asymptotic theoretical performance guarantees for general output observations are not currently available and are adopted as the focus of this work. We perform the \emph{finite-time worst-case} analysis of Greedy reinforcement learning algorithms for imperfectly observed contextual bandits. We establish efficiency and provide high probability upper bounds for the regret that consists of logarithmic factors of the time horizon and of the failure probability. Furthermore, the effects of other problem parameters such as the number of arms and the dimension are fully characterized. Illustrative numerical experiments showcasing the efficiency are also provided. To study the performance of reinforcement learning policies, different technical difficulties arise in the high probability analyses. First, one needs to study the eigenvalues of the empirical covariance matrices, since the estimation accuracy depends on them. Furthermore, it is required to consider the number of times the algorithm selects sub-optimal arms. Note that both quantities are stochastic and so worst-case (i.e., high probability) results are needed for a statistically dependent sequence of random objects. To obtain the presented theoretical results, we employ advanced technical tools from martingale theory and random matrices. Indeed, by utilizing concentration inequalities for matrices with martingale difference structures, we carefully characterise the effects of order statistics and tail-properties of the estimation errors. The remainder of this paper is organized as follows. In Section~\ref{sec:2}, we formulate the problem and discuss the relevant preliminary materials. Next, a Greedy reinforcement learning algorithm for contextual bandits with imperfect context observations is presented in Section \ref{sec:3}. In Section \ref{sec:4}, we provide theoretical performance guarantees for the proposed algorithm, followed by numerical experiments in Section~\ref{sec:5}. Finally, we conclude the paper and discuss future directions in Section~\ref{sec:6}. We use $A^\top$ to refer to the transpose of the matrix $A \in \mathbb{C}^{p \times q}$. For a vector $v \in \mathbb{C}^d$, we denote the $\ell_2$ norm by $\|v\| = \left(\sum_{i=1}^d |v_i|^2\right)^{1/2}$. Additionally, $C(A)$ and $C(A)^\perp$ are employed to denote the column-space of the matrix $A$ and its orthogonal subspace, respectively. Further, $P_{C(A)}$ is the projection operator onto $C(A)$. Finally, $\lambda_{\min}(A)$ and $\lambda_{\max}(A)$ denote the minimum and maximum eigenvalues of the symmetric matrix $A$, respectively. \section{Problem Formulation} \label{sec:2} First, we formally discuss the problem of contextual bandits with imperfect context observations. A bandit machine has $N$ arms, each of which has its own unobserved context $x_i(t)$, for $i \in \{1,\cdots,N\}$. Equation \eqref{eq:om} presents the observation model, where the observations $\{y_i(t)\}_{1\leq i \leq N}$ are linearly transformed functions of the contexts, perturbed by additive noise vectors $\{\zeta_{i}(t)\}_{1\leq i \leq N}$. Equation \eqref{eq:reward} describes the process of reward generation for different arms, depicting that \emph{if} the agent selects arm $i$, then the resulting reward is an \emph{unknown} linear function of the unobserved context vector, subject to some additional randomness due to the reward noise $\psi_i(t)$. The agent aims to maximize the cumulative reward over time, by utilizing the sequence of observations. To gain the maximum possible reward, the agent needs to learn the relationship between the rewards $r_i(t)$ and the observations $y_i(t)$. For that purpose, we proceed by considering the conditional distribution of the reward $r_i(t)$ given the observation $y_i(t)$, i.e., $\mathbb{P}(r_i(t)|y_i(t))$, which is \begin{eqnarray} N(y_i(t)^\top D^\top \mu_*, \gamma_{ry}^2),\label{eq:condr} \end{eqnarray} where $D=(A^\top \Sigma^{-1}_y A + \Sigma^{-1}_x)^{-1} A^\top \Sigma^{-1}_y$ and $\gamma_{ry}^2 = \mu_*^\top(A^{\top} \Sigma_y^{-1} A + \Sigma_x^{-1})^{-1} \mu_* + \gamma_r^2$. Based on the conditional distribution in \eqref{eq:condr}, in order to maximize the expected reward given the observation, we consider the conditional expectation of the reward given the observations, $y_i(t)^\top D^\top \mu_*$. So, letting $\eta_* = D^\top \mu_*$ be the transformed parameter, we focus on the estimation of $\eta_*$. The rationale is twofold; first, the conditional expected reward can be inferred with only knowing $\eta_*$, regardless of the exact value of the true parameter $\mu_*$. Second, $\mu_*$ is not estimable when the rank of the sensing matrix $A$ in the observation model is less than the dimension of $\mu_*$. Indeed, estimability of $\mu_*$ needs the restrictive assumptions of non-singular $A$ and $d_y \geq d_x$. The optimal policy that reinforcement learning policies need to compete against knows the true parameter $\mu_*$. That is, to maximize the reward given the output observations, the optimal arm at time $t$, denoted by $a^*(t)$, is \begin{eqnarray} a^*(t) = \argmax_{1\leq i \leq N} y_i(t)^\top \eta_*.\label{eq:op} \end{eqnarray} Then, the performance degradation due to uncertainty about the environment that the parameter $\mu_*$ represents, is the assessment criteria for reinforcement learning policies. So, we consider the following performance measure, which is commonly used in the literature, and is known as \emph{regret} of the reinforcement learning policy that selects the sequence of actions $a(t), t =1,2, \cdots$: \begin{flalign} \mathrm{Regret}(T) &= \sum_{t=1}^T \left(y_{a^*(t)}(t) - y_{a(t)}(t)\right)^\top \eta_*.\label{eq:reg} \end{flalign} In other words, the regret at time $T$ is the total difference in the obtained rewards, up to time $T$, where the difference at time $t$ is between the optimal arms $a^*(t)$ and the arm $a(t)$ chosen by the reinforcement learning policy based on the output observations by the time $t$. \section{Reinforcement Learning Policy} \label{sec:3} In this section, we explain the details of the Greedy algorithm for contextual bandits with imperfect observations. Although inefficient in some reinforcement learning problems, Greedy algorithms are known to be efficient under certain conditions such as covariate diversity~\cite{bastani2021mostly}. Intuitively, the latter condition expresses that the context vectors cover all directions in $\mathbb{R}^{d_x}$ with a non-trivial probability, so that additional exploration is not necessary. As discussed in Section \ref{sec:2}, it suffices for the policy to learn to maximize \begin{eqnarray} \mathbb{E}[r_i(t)|y_i(t)]=y_i(t)^\top \eta_*. \end{eqnarray} To estimate the quantity $y_i(t)^\top \eta_*$, we use the least-squares estimate $\widehat{\eta}(t)$ (that will be explained shortly), in lieu of the truth $\eta_*$. So, the Greedy algorithm selects the arm $a(t)$ at time $t$, such that \begin{eqnarray} a(t) = \argmax_{1\leq i \leq N} y_i(t)^\top \widehat{\eta}(t).\label{eq:pol} \end{eqnarray} The recursions to update the parameter estimate $\widehat{\eta}(t)$ and the empirical inverse covariance matrix $B(t)$ are as follows: \begin{eqnarray} B(t+1) &=& B(t) + y_{a(t)}(t)y_{a(t)}(t)^\top\label{eq:B}\\ \widehat{\eta}(t+1) &=& B(t+1)^{-1} \left(B(t) \widehat{\eta}(t) + y_{a(t)}(t) r_{a(t)}(t)\right),~~~~\label{eq:etahat} \end{eqnarray} where the initial values consist of $B(1) = \Sigma^{-1}$, for some arbitrary positive definite matrix $\Sigma$, and $\widehat{\eta}(1)=\mathbf{0}_{d_y}$. Algorithm~\ref{algo} provides the pseudo-code for the Greedy reinforcement learning policy. \begin{algorithm}[h] \begin{algorithmic}[1] \State Set $B(1) = I_{d_y}$, $\widehat{\eta}(1) = \mathbf{0}_{d_y}$ \For{$t = 1,2, \dots, $} \State Select arm $a(t)= \underset{1 \leq i \leq N}{\argmax}~ y_i(t)^{\top} \widehat{\eta}(t)$ \State Gain reward $r_{a(t)}(t) = x_{a(t)}(t)^\top \mu_* + \psi_{a(t)}(t)$ \State Update $B(t+1)$ and $\widehat{\eta}(t+1)$ by \eqref{eq:B} and \eqref{eq:etahat} \EndFor \end{algorithmic} \caption{: Greedy policy for contextual bandits with imperfect context observations} \label{algo} \end{algorithm} \section{Theoretical Performance Guarantees} \label{sec:4} In this section, we present a theoretical result for Algorithm \ref{algo} presented in the previous section. The result provides a worst-case analysis and establishes a high probability upper-bound for the regret in \eqref{eq:reg}. \begin{theorem} Assume that Algorithm \ref{algo} is used in a contextual bandit with $N$ arms and the output dimension $d_y$. Then, with probability at least $1-4\delta$, we have \begin{equation*} \mathrm{Regret}(T) = O\left(Nd_y^{2} \left(\log \frac{Nd_y T}{\delta}\right)^{5/2} \log \frac{d_y T}{\delta} \right). \end{equation*} \end{theorem} Before proceeding to the proof of the theorem, we discuss its intuition. The regret bound above scales linearly with the number of arms $N$, quadratically with the dimension of the observations $d_y$, and logarithmically with the time horizon $T$. Note that the dimension of unobserved context vectors does not appear in the regret bound, because the optimal policy in \eqref{eq:op} does not have the exact values of the context vectors. So, similar to the reinforcement learning policy, the optimal policy needs to estimate the contexts as well, as can be seen in \eqref{eq:op}. Intuitively, the linear growth of the regret bound with $N$ relies on the fact that a policy is more likely to choose one of the sub-optimal arms when $N$ is larger. So, as more non-optimal arms exist, it leads to incurring larger sub-optimalities in the arm selection and larger regret. In addition, it can be seen in the proof of the theorem that the quadratic terms of $d_y$ are generated by the scaling of the $\ell_2$ norms of the $d_y$ dimensional random vectors $y_i(t)$, as well as the rates of concentration of $d_y \times d_y$ empirical covaraince matrices $B(t)$. Further, the term $\left(\log (Nd_yT/\delta)\right)^{5/2}$ reflects the tail-effect of the random context vectors. Lastly, aggregating reward difference at time $t$ (which decays proportional to $t^{-0.5}$) together with the probability of choosing a sub-optimal arm (which shrinks with the same $t^{-0.5}$ rate), we obtain the last logarithmic term in the regret bound in the theorem; $\log (d_yT/\delta)$. \begin{proof} First, for $T > 0$ and $0 < \delta < 0.25$, define the event \begin{eqnarray} W_T = \left\{\underset{\{1\leq \tau \leq t~and~1\leq i \leq N\}}{\max} ||S_y^{-0.5}y_i(\tau)||_{\infty} \leq v_T(\delta)\right\} \label{eq:WT}, \end{eqnarray} where $v_T(\delta) = (2\log (2Nd_yT/\delta) )^{0.5}$. We use the following intermediate results, for which the proofs are deferred to the appendix. \begin{lemma} Let $\sigma\{X_1,\dots,X_n\}$ be the sigma-field generated by random vectors $X_1,\dots,X_n$. For the observation of chosen arm $y_{a(t)}(t)$ at time t and the filtration $\{\mathscr{F}_{t}\}_{1\leq t \leq T}$ defined according to $$\mathscr{F}_{t} = \sigma\{\{a(\tau)\}_{1\leq \tau \leq t},\{y_i(\tau)\}_{1\leq \tau \leq t, 1\leq i \leq N}, \{r_{a(\tau)}(\tau)\}_{1\leq \tau \leq t}\},$$ we have \begin{flalign} \mathbb{E}[ S_y^{-0.5} y_{a(t)}(t)y_{a(t)}(t)^{\top} S_y^{-0.5}|\mathscr{F}_{t-1}] = P_{C(S_y^{0.5}\widehat{\eta}(t))} (k_N-1) + I_{d_y},\nonumber \end{flalign} where $k_N = \mathbb{E}\left[\left(\underset{1 \leq i \leq N}{\max}\{Z_i\}\right)^2\right]$ and $S_y = \mathrm{Cov}(y_i(t))$. That is, $k_N$ is the expected maximum of $N$ independent $Z_i$ with the standard normal distribution. \label{lem:1} \end{lemma} \begin{lemma} For the event $W_T$ defined in \eqref{eq:WT}, we have $\mathbb{P}(W_T) \geq 1 -\delta$.\label{lem:2} \end{lemma} \begin{lemma} (Matrix Azuma Inequality~\cite{tropp2012user}) Consider the sequence $\{X_k\}_{1\leq k\leq K}$ of symmetric $d \times d$ random matrices adapted to some filtration $\{\mathscr{G}_k\}_{1\leq k\leq K}$, such that $\mathbb{E}[X_k|\mathscr{G}_{k-1}] = 0$. Assume that there is a deterministic sequence of symmetric matrices $\{A_k\}_{1\leq k\leq K}$ that satisfy $X_k^2 \preceq A_k^2$ , almost surely. Let $\sigma^2 = \|\sum_{1\leq k\leq K} A_k^2\|$. Then, for all $\varepsilon\geq 0$, it holds that \begin{eqnarray} \mathbb{P}\left(\lambda_{\max} \left(\sum_{k=1}^K X_k\right) \geq \varepsilon\right) \leq d \cdot e^{-\varepsilon^2/8\sigma^2}. \end{eqnarray} \label{lem:3} \end{lemma} \begin{lemma} In Algorithm 1, let $\widehat{\eta}(t)$ be the parameter estimate, as defined in \eqref{eq:etahat}. Then, for $t\leq T$, on the event $W_T$ defined \eqref{eq:WT}, we have \begin{eqnarray} \mathbb{P}\left(\|\widehat{\eta}(t)-\eta_*\| > \varepsilon |B(t) \right) \leq 2 \cdot \mathrm{exp}\left(-\frac{(\varepsilon-\lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\|)^2}{2d_y \lambda_{\max}(B(t)^{-1})\gamma^2_{ry}} \right), \end{eqnarray} as long as $\varepsilon \geq \lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\|$. \label{lem:4} \end{lemma} \begin{lemma} Given $\mathbf{y}_t = \{y_i(t)\}_{1\leq i \leq N}$ and $B(t)$, if $$(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*/\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\| \geq \lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\|,$$ then, the probability of choosing a sub-optimal arm is bounded as follows: \begin{flalign} \mathbb{P}(a^*(t)\neq a(t)|\mathbf{y}_t, B(t)) \leq 2\cdot\mathrm{exp}\left(-\frac{ \left(\frac{(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*}{\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\|}- \lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\| \right)^2}{2d_y \lambda_{\max}(B(t)^{-1}) \gamma^2_{ry}} \right), \nonumber \end{flalign} where $a^{**}(t)$ is the second best arm (i.e., it has the second largest conditional expected reward). \label{lem:5} \end{lemma} \begin{lemma} Suppose that we have $N$ independent normal $N(0,\gamma^2)$ random variables. Then, the probability density function of the difference between the maximum of the $N$ random variables and the second largest among all, is upper-bounded by $N/\sqrt{2\pi \gamma^2}$. \label{lem:6} \end{lemma} First, we consider the inverse of the (unnormalized) empirical covariance matrix $B(t)$ in \eqref{eq:B}. By Lemma \ref{lem:1}, the minimum eigenvalue of $\mathbb{E}[ S_y^{-0.5} y_{a(t)}(t)y_{a(t)}(t)^{\top} S_y^{-0.5}|\mathscr{F}_{t-1}]$ is greater than $1$, for all $t$. Thus, for all $t>0$, it holds that \begin{eqnarray} \lambda_{\min}\left(\sum_{\tau=1}^t \mathbb{E}[ S_y^{-0.5} y_{a(\tau)}(\tau)y_{a(\tau)}(\tau)^{\top} S_y^{-0.5}|\widehat{\eta}(\tau) ] \right) \geq t.\label{eq:mineig} \end{eqnarray} Now, we focus on a high probability lower-bound for the smallest eigenvalue of $B(t)$. On the event $W_T$, the matrix $v_T^2(\delta)I - S_y^{-0.5}y_i(t)y_i(t)^\top S_y^{-0.5}$ is positive semidefinite for all $i$ and $t$. Let \begin{eqnarray} X_{\tau} &=& S_y^{-0.5}y_{a(\tau)}(\tau)y_{a(\tau)}(\tau)^\top S_y^{-0.5} - \mathbb{E}[S_y^{-0.5} y_{a(\tau)}(\tau)y_{a(\tau)}(\tau)^\top S_y^{-0.5}|\mathscr{F}_{\tau-1}]\nonumber,\\ Y_\tau &=& \sum_{j=1}^\tau \left( S_y^{-0.5}y_{a(j)}(j)y_{a(j)}(j)^\top S_y^{-0.5}-\mathbb{E}[S_y^{-0.5}y_{a(j)}(j)y_{a(j)}(j)^\top S_y^{-0.5}|\mathscr{F}_{j-1}] \right). \end{eqnarray} Then, $X_{\tau}=Y_{\tau}-Y_{\tau-1}$ and $\mathbb{E}\left[ X_{\tau} | \mathscr{F}_{\tau-1} \right] = 0$. Thus, $X_{\tau}$ is a martingale difference sequence. Because $v_T^2(\delta)I - S_y^{-0.5}y_i(t)y_i(t)^\top S_y^{-0.5} \succeq 0$ for all $i$ and $t$, $2v_T^2(\delta)I - X_\tau \succeq 0$ and $4v_T^4(\delta)I - X_\tau^2 \succ 0$, for all $\tau$, on the event $W_T$. By Lemma \ref{lem:3}, we get \begin{flalign} \mathbb{P}\left(\lambda_{\min} \left(\sum_{\tau=1}^{t-1} X_{\tau}\right) \leq (t-1)\varepsilon \right) &\leq d_y \cdot \mathrm{exp}\left(-\frac{((t-1)\varepsilon)^2}{8(4(t-1)v_T^4(\delta))}\right)\nonumber\\ &= d_y \cdot \mathrm{exp}\left(-\frac{(t-1)\varepsilon^2}{32v_T^4(\delta)}\right), \end{flalign} for $\varepsilon \leq 0$. Now, using \begin{eqnarray} \sum_{\tau=1}^{t-1} X_{\tau} = S_y^{-0.5}B(t)S_y^{-0.5} - \sum_{\tau=1}^{t-1}\mathbb{E}[S_y^{-0.5}y_{a(\tau)}(\tau)y_{a(\tau)}(\tau)^\top S_y^{-0.5}|\mathscr{F}_{\tau-1}],~~~~ \end{eqnarray} together with \begin{flalign} &\lambda_{\min}\left(S_y^{-0.5}B(t)S_y^{-0.5}-\sum_{\tau=1}^{t-1}\mathbb{E}[S_y^{-0.5}y_{a(\tau)}(\tau)y_{a(\tau)}(\tau)^\top S_y^{-0.5}|\mathscr{F}_{\tau-1}]\right) \nonumber\\ &\leq \lambda_{\min}(S_y^{-0.5}B(t)S_y^{-0.5})-\lambda_{\min}\left( \sum_{\tau=1}^{t-1}\mathbb{E}[S_y^{-0.5}y_{a(\tau)}(\tau)y_{a(\tau)}(\tau)^\top S_y^{-0.5}|\mathscr{F}_{\tau-1}] \right) \end{flalign} and \eqref{eq:mineig}, we obtain \begin{flalign} & P\left( \lambda_{\min}\left(S_y^{-0.5}B(t)S_y^{-0.5}-\sum_{\tau=1}^{t-1}\mathbb{E}[S_y^{-0.5}y_{a(\tau)}(\tau)y_{a(\tau)}(\tau)^\top S_y^{-0.5}|\mathscr{F}_{\tau-1}]\right) \leq (t-1) (1 + \varepsilon) \right) \nonumber\\ &= P\left( \lambda_{\min} (S_y^{-0.5}B(t)S_y^{-0.5}) \leq (t-1) (1 + \varepsilon) \right) \nonumber\\ &\leq d_y \cdot \mathrm{exp}\left(-\frac{(t-1)\varepsilon^2}{32v_T^4(\delta)}\right), \end{flalign} where $-1 \leq \varepsilon \leq 0$ is arbitrary, and we used the fact that $\lambda_{\min} (S_y^{-0.5}B(t)S_y^{-0.5}) \geq 0$. Indeed, on the event $W_T$ defined in \eqref{eq:WT}, for $-1\leq \varepsilon \leq 0$ we have \begin{flalign} \mathbb{P}\left( \lambda_{\min} (B(t)) \leq \lambda_{s} (t-1) (1 + \varepsilon) \right) \leq~d_y \cdot \mathrm{exp}\left(-\frac{(t-1)\varepsilon^2}{32v_T^4(\delta)}\right),\label{eq:eig} \end{flalign} where $\lambda_{s} = \lambda_{\min}(S_y)$. In other words, with the probability at least $1-2\delta$, we have \begin{eqnarray} \lambda_{\min} (B(t)) \leq \lambda_s(t-1) \left(1 - \sqrt{\frac{32v_T(\delta)^4}{t-1}\log\frac{d_y T}{\delta}} \right),\label{eq:eig2} \end{eqnarray} for all $1 \leq t \leq T$. Next, we investigate the estimation error $\|\eta_* - \widehat{\eta}(t)\|$. Using $\|y_i(t)\| \leq \sqrt{d_y\lambda_s} v_{T}(\delta)$ on the event $W_T$, we have \begin{eqnarray} (y_{a^*(t)}(t) - y_{a(t)}(t) )^\top \eta_* \leq 2 \sqrt{d_y\lambda_{s}} v_{T}(\delta) \|\eta_* - \widehat{\eta}(t)\|.\label{eq:bderror} \end{eqnarray} So, we write the regret in the following form: \begin{flalign} \mathrm{Regret}(T) = \sum_{t=1}^T (y_{a^*(t)}(t)-y_{a(t)}(t))^\top \eta_* I(a^*(t) \neq a(t)),\label{eq:reg2} \end{flalign} where $I(\cdot)$ is the indicator function. Here, we denote $\lambda_t = \lambda_{\max}(B(t)^{-1})$. By \eqref{eq:eig2}, we can find $t^*_T = 128 v_T(\delta)^4 \log \frac{d_y T}{\delta} + 1$, such that \begin{eqnarray} \lambda_{t} \leq \frac{2}{\lambda_s (t-1)}, \label{eq:lambdat} \end{eqnarray} with the probability at least $1-\delta$, for all $t^*_T < t \leq T$. By Lemma \ref{lem:4}, \eqref{eq:bderror} and \eqref{eq:lambdat}, for all $t^*_T < t \leq T$, with the probability at least $1-3\delta$, we have \begin{flalign} (y_{a^*(t)}(t)-y_{a(t)}(t))^\top \eta_* \leq a_1(t-1)^{-0.5},~~~~~~\label{eq:bderror2} \end{flalign} where $a_1 = 4\sqrt{d_y\lambda_s} v_T(\delta) \left(\sqrt{2d_y \log(2T\delta^{-1})} + \|\Sigma^{-1}\eta_*\|\right)$. Note that $(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*$ is the difference of the maximum and second largest variables of $N$ independent ones with the distribution $N\left(0, \eta_*^\top S_y\eta_*\right)$. By Lemma \ref{lem:6}, the density of $$D_t=(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*$$ is bounded by $N/\sqrt{2\pi \eta_*^\top S_y\eta_*}$. Thus, by marginalizing $\mathbf{y}_t$ from $\mathbb{P}(a^*(t)\neq a(t)|\mathbf{y}_t,B(t))$, which is obtained in Lemma \ref{lem:5}, we have \begin{flalign} \mathbb{P}(a^*(t)\neq a(t)|B(t)) = \int \mathbb{P}(a^*(t)\neq a(t)|\mathbf{y}_t, B(t)) f_{\mathbf{y}_t}(\mathbf{y}_t)d\mathbf{y}_t \leq a_2 Nd_y v_T(\delta)\lambda_{t}^{0.5} ,\label{eq:probat} \end{flalign} where $a_2=2 \|\Sigma^{-1}\eta_*\|/\sqrt{2\pi\eta_*^T S_y \eta_* }$. Since $\lambda_{t} \leq 2 \lambda_s^{-1} (t-1)^{-1}$, for all $t^*_T < t \leq T$ by \eqref{eq:lambdat}, we have \begin{eqnarray} \mathbb{P}(a^*(t)\neq a(t)) \leq 2 a_2 Nd_y v_T(\delta)(\lambda_{s} (t-1))^{-0.5}.\label{eq:probat} \end{eqnarray} Now, to find the upper bound of the sum of indicator functions in \eqref{eq:reg2}, we construct a martingale difference sequence that satisfy the conditions in Lemma \ref{lem:3}. To that end, let $X_1 = Y_1 = 0$, $$X_\tau = (t-1)^{-0.5} I(a^*(t) \neq a(t)) - (t-1)^{-0.5} \mathbb{P}(a^*(t) \neq a(t)|\mathscr{F}_{t-1}^*),$$ and $Y_t = \sum_{\tau=1}^t X_\tau$ , where \begin{eqnarray} \mathscr{F}_{t-1}^* = \sigma\{\{B(\tau)\}_{1\leq \tau \leq t-1}\}. \end{eqnarray} Since $\mathbb{E}[X_\tau|\mathscr{F}_{\tau-1}^*]=0$, the above sequences $\{X_\tau\}_{\tau\geq 0}$ and $\{Y_\tau\}_{\tau\geq 0}$ are a martingale difference sequence and a martingale with respect to the filtration $\{\mathscr{F}_{\tau}^*\}_{1\leq \tau \leq T}$, respectively. Let $c_\tau =2(\tau-1)^{-0.5}$. Since $\sum_{\tau=1}^T |X_\tau| \leq \sum_{\tau=1}^T c_\tau^2 \leq 4\log T$, by Lemma \ref{lem:3}, we have \begin{flalign} \mathbb{P}( Y_T - Y_1 > \varepsilon) \leq \mathrm{exp} \left(-\frac{\varepsilon^2}{2\sum_{t=1}^T c_t^2}\right) \leq \mathrm{exp} \left(-\frac{\varepsilon^2}{32\log T }\right). \end{flalign} Thus, with the probability at least $1-4\delta$, it holds that \begin{flalign} \sum_{t^*_T \leq t \leq T } \frac{1}{\sqrt{t-1}} I(a^*(t) \neq a(t)) \leq \sqrt{32\log T \log \delta^{-1} } + \sum_{t^*_T \leq t \leq T} \frac{1}{\sqrt{t-1}} \mathbb{P}(a^*(\tau) \neq a(\tau)|\mathscr{F}_{\tau-1}^*).\label{eq:indi} \end{flalign} By \eqref{eq:probat}, $\mathbb{P}(a^*(t) \neq a(t)|\mathscr{F}_{t-1}^*)$ above is bounded by $2a_2 Nd_y v_T(\delta)\lambda_{s}^{-0.5} (t-1)^{-0.5}$, for all $t^*_T < t \leq T$. Thus, we can bound the second term as \begin{eqnarray} \sum_{t^*_T \leq t \leq T} \frac{1}{\sqrt{t-1}} \mathbb{P}(a^*(\tau) \neq a(\tau)|\mathscr{F}_{\tau-1}^*) \leq 2 a_2 Nd_y v_T(\delta)\lambda_{s}^{-0.5} \log T.\label{eq:indi2} \end{eqnarray} Therefore, by \eqref{eq:indi} and \eqref{eq:indi2}, putting together the terms for $t < t^*_T$ and $t \geq t^*_T$, with the probability at least $1-4\delta$, the following inequalities hold for the regret of the algorithm, which yield to the desired result: \begin{eqnarray} \mathrm{Regret}(T) &=&\sum_{t=1}^T (y_{a^*(t)}(t)-y_{a(t)}(t))^\top \eta_* I(a^*(t) \neq a(t))\nonumber\\ &\leq& \left(2\sqrt{d_y}v_T(\delta)\|\eta_*\|\right) t^*_T+ \sum_{t^*_T \leq t \leq T} a_1\frac{1}{\sqrt{t-1}} I(a^*(t) \neq a(t)) \nonumber\\ &\leq& \left(2\sqrt{d_y}v_T(\delta)\|\eta_*\|\right) t^*_T +a_1 \left(\sqrt{8\log T \log \delta^{-1} } + \sum_{t^*_T \leq t \leq T} \frac{1}{\sqrt{t-1}} \mathbb{P}(a^*(\tau) \neq a(\tau)|\mathscr{F}_{\tau-1}^*)\right) \nonumber\\ &\leq& O\left(Nd_y^{2} \left(\log \frac{Nd_y T}{\delta}\right)^{5/2} \log \frac{d_y T}{\delta} \right). \end{eqnarray} \end{proof} \begin{figure*}[h!] \centering \psfrag{N=10~~~~}{\scriptsize$N=10$} \psfrag{N=20~~~~}{\scriptsize$N=20$} \psfrag{N=50~~~~}{\scriptsize$N=50$} \psfrag{N=100~~~~}{\scriptsize$N=100$} \psfrag{dy=5~~~~}{\scriptsize$d_y=5$} \psfrag{dy=10~~~~}{\scriptsize$d_y=10$} \psfrag{dy=20~~~~}{\scriptsize$d_y=20$} \psfrag{dy=50~~~~}{\scriptsize$d_y=50$} \psfrag{N~~~~~~~~~~~~~~~~~~~~~~}{~~~~~~~~~~~~~~Normalized Regret vs Time} \psfrag{N~~~~~~~~~~~~~~~~~~~~~~~~}{~~~~~~~~~~~~~~~~Normalized Regret vs Time} \psfrag{t}{$t$} \includegraphics[width=0.48\textwidth]{fig1.eps} \includegraphics[width=0.48\textwidth]{fig2.eps} \normalsize \caption{Plots of $\mathrm{Regret}(t)/\log t$ over time for the different number of arms $N = 10,20,100$ and $d_y=5,20,50$. The solid and dashed lines represent average and worst regret curves, respectively.} \label{fig:1} \end{figure*} \begin{figure*}[h!] \centering \psfrag{N=10~~~~}{\scriptsize$N=10$} \psfrag{N=20~~~~}{\scriptsize$N=20$} \psfrag{N=50~~~~}{\scriptsize$N=50$} \psfrag{N=100~~~~}{\scriptsize$N=100$} \psfrag{dy}{$d_y$} \psfrag{A~~~~~~}{\scriptsize Average} \psfrag{90\%}{\scriptsize 90\%} \psfrag{W~~~~}{\scriptsize Worst} \psfrag{N~~~~~~~~~~~~~~~~~~~~~~~~}{~~~~~~~~~~~~~~~~~~~~Regret at $T=2000$} \includegraphics[width=0.7\textwidth]{fig3.eps} \normalsize \caption{Plot of average and worst-case $\mathrm{Regret}(T)$ at $T=2000$ for different number of arms $N = 10,20,50$ and dimension of observations $d_y = 5,20,50$. } \label{fig:2} \end{figure*} \section{Numerical Illustrations} \label{sec:5} In this section, we perform numerical analyses for the theoretical result in the previous section. We simulate cases for imperfectly observed contextual bandits with $N=10,20,50$ arms and with different dimensions of the observations; $d_y=5,20,50$, while we fix the context dimension to $d_x=20$. Each case is repeated $100$ times and the average and worst quantities of $100$ scenarios are reported. In Figure \ref{fig:1}, the left plot depicts the average-case (solid) and worst-case (dashed) regret among all scenarios, normalized by $\log t$. The number of arms $N$ varies as shown in the graph, while the dimension is fixed to $d_y=10$. Next, the plot on the right-hand-side of the figure illustrates that the normalized regret increases over time for different $d_y$, and for the fixed number of arms $N=5$. For both plots, the worst-case regret curves are well above the average-case ones, as expected. However, the slopes of curves for both cases decays as time goes on, implying that the worst-case regret grows logarithmically with $t$. Figure \ref{fig:2} presents the average-case and worst-case regret at time $T=2000$ (not normalized by $\log T$) for different number of arms $N=10,20,50$ and different dimensions $d_y=5,20,50$. The graph shows how the regret increase as $N$ and $d_y$ grow. \section{Conclusion} \label{sec:6} This work investigates reinforcement learning algorithms for contextual bandits that the contexts are observed imperfectly, and focuses on the theoretical analysis of the regret. We establish performance guarantees for Greedy algorithms and obtain high probability regret bounds growing logarithmically with the horizon. There are multiple interesting future directions introduced in this paper. First, it will be of interest to study reinforcement learning policies for settings that each arm has its own parameter. Further, regret analysis for contextual bandits under imperfect context observations where the sensing matrix is unknown, is another problem for future work. \section{Appendices} \subsection{Proof of Lemma 1} We use the following decomposition \begin{eqnarray} S_y^{-0.5} y_{a(t)}(t) = P_{C(S_y^{0.5}\widehat{\eta}(t))} S_y^{-0.5} y_{a(t)} (t) + P_{C(S_y^{0.5}\widehat{\eta}(t))^\perp} S_y^{-0.5} y_{a(t)} (t). \label{eq:decomp} \end{eqnarray} We claim that $P_{C(S_y^{0.5}\widehat{\eta}(t))} S_y^{-0.5} y_{a(t)}$ and $P_{C(S_y^{0.5}\widehat{\eta}(t))^\perp} S_y^{-0.5} y_{i}(t) $ are statistically independent. To show it, define \begin{eqnarray} Z(\nu,N) = \underset{Z_i,1 \leq i \leq N}{\argmax}\left\{ Z_i^\top \nu \right\}\label{eq:zmun}, \end{eqnarray} where $Z_i$ has the distribution $N(\mathbf{0}_{d_y},I_{d_y})$ and $\nu$ is an arbitrary vector in $\mathbb{R}^{d_y}$. The vector $Z_i$ can be decomposed as $Z_i = P_{C(\nu)} Z_i + (I_d-P_{C(\nu)}) Z_i$ Then, we have $Z(\nu,N) = \underset{Z_i,1 \leq i \leq N}{\argmax} \left\{ (P_{C(\nu)} Z_i)^\top \nu \right\}$, because $P_{C(\nu)}\nu = \nu$. This implies that only the first term of the decomposed terms, $P_{C(\nu)} Z_i$, affects the result of $\underset{Z_i,1 \leq i \leq N}{\argmax} \left\{ Z_i^\top \nu \right\}$. This means that $Z(\nu,N)$ has the same distribution as $P_{C(\nu)} Z(\nu,N) +(I_d- P_{C(\nu)})Z_{i}$, which means \begin{eqnarray} Z(\nu,N) \overset{d}{=}P_{C(\nu)} Z(\nu,N) +(I_d- P_{C(\nu)})Z_{i}\label{eq:equaldis}, \end{eqnarray} where $\overset{d}{=}$ is used to denote the equality of the probability distributions. Note that $$ S_y^{-0.5} y_{a(t)} = \argmax_{S_y^{-0.5} y_{i}, 1\leq i \leq N} (S_y^{-0.5} y_{i}(t))^\top S_y^{0.5}\widehat{\eta}(t). $$ Thus, $S_y^{-0.5} y_{a(t)}$ has the same distribution as $P_{C(S_y^{0.5}\widehat{\eta}(t))} S_y^{-0.5} y_{a(t)} + P_{C(S_y^{0.5}\widehat{\eta}(t))^\perp} S_y^{-0.5} y_{i}(t) $, where $P_{C(S_y^{0.5}\widehat{\eta}(t))} S_y^{-0.5} y_{a(t)}$ and $P_{C(S_y^{0.5}\widehat{\eta}(t))^\perp} S_y^{-0.5} y_{i}(t) $ are statistically independent. By the decomposition \eqref{eq:decomp} and the independence, \\ $\mathbb{E}\left[ S_y^{-0.5}y_{a(t)}(t)y_{a(t)}(t)^\top S_y^{-0.5} | \mathscr{F}_{t-1} \right]$ can be written as \begin{flalign} &\mathbb{E}\left[ S_y^{-0.5}y_{a(t)}(t)y_{a(t)}(t)^\top S_y^{-0.5} | \mathscr{F}_{t-1} \right] \nonumber\\ &= \mathbb{E}\left[ (P_{C(S_y^{0.5} \widehat{\eta}(t))} + P_{C(S_y^{0.5} \widehat{\eta}(t))^\perp}) S_y^{-0.5}y_{a(t)}(t)y_{a(t)}(t)^\top S_y^{-0.5} (P_{S_y^{0.5} \widehat{\eta}(t)} + P_{S_y^{0.5} \widehat{\eta}(t)^\perp}) | \mathscr{F}_{t-1} \right]\nonumber\\ &= \mathbb{E}\left[ P_{C(S_y^{0.5} \widehat{\eta}(t))} S_y^{-0.5}y_{a(t)}(t)y_{a(t)}(t)^\top S_y^{-0.5} P_{C(S_y^{0.5} \widehat{\eta}(t))} | \mathscr{F}_{t-1} \right] + P_{C(S_y^{0.5} \widehat{\eta}(t))^\perp} . \end{flalign} To proceed, we show that the first term above, $\mathbb{E}[ P_{S_y^{0.5}\widehat{\eta}(t)} S_y^{-0.5} y_{a(t)}(t)y_{a(t)}(t)^{\top} S_y^{-0.5}P_{S_y^{0.5}\widehat{\eta}(t)} |\widehat{\eta}(t)] =a P_{S_y^{0.5}\widehat{\eta}(t) }$ for some constant $a>1$. Using $P_{C(\nu)} = \nu\nu^\top/\nu^\top \nu$ for an arbitrary vector $\nu \in \mathbb{R}^{d_y}$, we have \begin{eqnarray} && P_{S_y^{0.5}\widehat{\eta}(t) } \mathbb{E}[ S_y^{-0.5} y_{a(t)}(t) y_{a(t)}(t)^{\top} S_y^{-0.5}|\widehat{\eta}(t) ]P_{S_y^{0.5}\widehat{\eta}(t)}\nonumber\\ &=& \frac{S_y^{0.5}\widehat{\eta}(t)\widehat{\eta}(t)^{\top}S_y^{0.5} }{\widehat{\eta}(t)^{\top}S_y \widehat{\eta}(t)} \mathbb{E}[ S_y^{-0.5} y_{a(t)}(t)y_{a(t)}(t)^{\top} S_y^{-0.5}|\widehat{\eta}(t) ] \frac{S_y^{0.5}\widehat{\eta}(t)\widehat{\eta}(t)^{\top}S_y^{0.5} }{\widehat{\eta}(t)^{\top}S_y \widehat{\eta}(t)} \nonumber\\ &=& \frac{S_y^{0.5}\widehat{\eta}(t)}{\widehat{\eta}(t)^{\top} S_y \widehat{\eta}(t)} \mathbb{E}[ (\widehat{\eta}(t)^{\top} S_y^{0.5} S^{-0.5}_y y_{a(t)}(t))^2|\widehat{\eta}(t) ]\frac{\widehat{\eta}(t)^{\top}S_y^{0.5}}{\widehat{\eta}(t)^{\top}S_y\widehat{\eta}(t)} \nonumber\\ &=& P_{S_y^{0.5}\widehat{\eta}(t) } \mathbb{E}\left[ \left. \left( \left(\overrightarrow{S_y^{0.5}\widehat{\eta}(t)}\right)^\top S_y^{-0.5} y_{a(t)}(t) \right)^2\right|\widehat{\eta}(t) \right], \end{eqnarray} where $\overrightarrow{S_y^{0.5}\widehat{\eta}(t)} = S_y^{0.5}\widehat{\eta}(t)/\|S_y^{0.5}\widehat{\eta}(t))\|$ is the unit vector aligned linearly with $S_y^{0.5}\widehat{\eta}(t)$. Now, it suffices to prove that $$ \mathbb{E}\left[ \left. \left( \left(\overrightarrow{S_y^{0.5}\widehat{\eta}(t)}\right)^\top \left(S_y^{-0.5} y_{a(t)}(t)\right) \right)^2\right|\widehat{\eta}(t) \right]>1.$$ Note that $\left(\overrightarrow{S^{0.5}_y\widehat{\eta}(t)}\right)^\top S^{-0.5}_y y_{i}(t)$ has the standard normal distribution, since $S^{-0.5}_y y_{i}(t)$ has the distribution $N(0, I_{d_y})$. Thus, $\left(\overrightarrow{S_y^{0.5} \widehat{\eta}(t)}\right)^\top S_y^{-0.5} y_{a(t)}(t)$ is the maximum variable of $N$ variables with the standard normal density. Thus, using $$a(t) = \argmax_{1\leq i\leq N} \{ y_i(t)^\top \widehat{\eta}(t) \} = \argmax_{1\leq i\leq N} \left\{ y_i(t)^\top S_y^{-0.5} \overrightarrow{S_y^{0.5}\widehat{\eta}(t)} \right\},$$ we have \begin{eqnarray} y_{a(t)}(t)^\top S_y^{-0.5}\overrightarrow{S_y^{0.5} \widehat{\eta}(t)} \overset{d}{=} \underset{1 \leq i \leq N}{\max} \{V_i:V_i \sim N(0,1) \}. \end{eqnarray} where $\overset{d}{=}$ denotes the equality in terms of distribution. As such, we have \begin{eqnarray} \mathbb{E}\left[\left. \left(y_{a(t)}(t)^\top S_y^{-0.5}\overrightarrow{S_y^{0.5} \widehat{\eta}(t)} \right)^2\right|\widehat{\eta}(t)\right] = \mathbb{E}\left[ \left(\underset{1 \leq i \leq N}{\max} (\{V_i:V_i \sim N(0,1) \}\right)^2 \right]\label{eq:kn}. \end{eqnarray} We define the quantity in \eqref{eq:kn} as $k_N$, \begin{eqnarray} k_N = \mathbb{E}\left[ \left(\underset{1 \leq i \leq N}{\max} (\{V_i:V_i \sim N(0,1) \}\right)^2 \right], \end{eqnarray} which is greater than 1 for $N\geq 2$ and grows as $N$ gets larger, because $\mathbb{E}[V_i^2] = 1 < \mathbb{E}\left[ \left(\underset{1 \leq i \leq N}{\max} (\{V_i:V_i \sim N(0,1) \}\right)^2 \right]$. Therefore, \begin{eqnarray} \mathbb{E}[ S_y^{-0.5} y_{a(t)}(t)y_{a(t)}(t)^{\top} S_y^{-0.5}|\widehat{\eta}(t) ] = P_{C(S_y^{0.5}\widehat{\eta}(t)) } k_N + P_{C(S_y^{0.5}\widehat{\eta}(t))^\perp} = P_{C(S_y^{0.5}\widehat{\eta}(t))} (k_N-1) + I_{d_y}.\label{eq:matdec} \end{eqnarray} \subsection{Proof of Lemma 2} Note that $S_y^{-0.5} y_i(t)$ has the normal distribution $N(0,I_{d_y})$. Then, we have \begin{eqnarray} \mathbb{P}\left( |y_{ij}(t)| \geq \varepsilon \right) \leq 2 \cdot e^{-\frac{\varepsilon^2}{2}} \end{eqnarray} where $y_{ij}(t)$ is the $j$th component of $y_{i}(t)$. By plugging $v_T(\delta)$ to $\varepsilon$, we have \begin{eqnarray} \mathbb{P}\left( |y_{ij}(t)| \geq v_T(\delta) \right) \leq 2 \cdot e^{-\frac{v_T(\delta)^2}{2}} = 2 \cdot e^{-\log\frac{2Nd_yT}{\delta}} = \frac{\delta}{Nd_yT}. \end{eqnarray} Thus, \begin{eqnarray} \mathbb{P} (W_T) \geq 1 - \sum_{t=1}^T\sum_{i=1}^N\sum_{j=1}^{d_y} \mathbb{P}\left( |y_{ij}(t)| \geq v_T(\delta) \right) \geq 1-\delta. \end{eqnarray} \subsection{Proof of Lemma 4} Note that $\widehat{\eta}(t)$ has the distribution $N\left(\mathbb{E}[\widehat{\eta}(t)|\mathscr{F}_{t-1}], \mathrm{Cov}(\widehat{\eta}(t)|\mathscr{F}_{t-1})\right)$ given the observations up to time $t$, where \begin{eqnarray} \mathbb{E}[\widehat{\eta}(t)|\mathscr{F}_{t-1}] &=& B(t)^{-1} \left(\sum_{\tau=1}^{t-1} y_{a(\tau)}(\tau) r_{a(\tau)}(\tau) \right) = (I-B(t)^{-1}\Sigma^{-1})\eta_*\nonumber\\ \mathrm{Cov}(\widehat{\eta}(t)|\mathscr{F}_{t-1}) &=& B(t)^{-1} (B(t) - \Sigma^{-1})B(t)^{-1}\gamma^2_{ry}. \end{eqnarray} For $Z\sim N(0, \lambda_{\max}(B(t)^{-1})\gamma^2_{ry} )$, using the Chernoff bound, we get \begin{eqnarray} \mathbb{P}\left(\|\widehat{\eta}(t)-\eta_*\| > \varepsilon + \|B(t)^{-1}\Sigma^{-1}\eta_*\| |B(t) \right) &\leq& \mathbb{P}\left( d_y Z^2 > \varepsilon^2 \right) \nonumber\\ &\leq& 2 \cdot \mathrm{exp}\left(-\frac{\varepsilon^2}{2 d_y \lambda_{\max}(B(t)^{-1})\gamma^2_{ry}}\right),\label{eq:cdfeta}~~~~ \end{eqnarray} where $\varepsilon \geq 0$. Thus, \begin{eqnarray} \mathbb{P}\left(\|\widehat{\eta}(t)-\eta_*\| > \varepsilon |B(t) \right) \leq 2 \cdot \mathrm{exp}\left(-\frac{(\varepsilon-\lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\|)^2}{2 d_y \lambda_{\max}(B(t)^{-1})\gamma^2_{ry}} \right), \end{eqnarray} where $\varepsilon \geq \lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\|$. \subsection{Proof of Lemma 5} Let $a^{**}(t)$ be the arm with the second largest expected reward at time $t$ and $\eta_{**}$ be a vector such that $y_{a^{*}(t)}(t)^\top \eta_{**}= y_{a^{**}(t)}(t)^\top \eta_{**}$ and $\theta(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t), \eta_*-\eta_{**})=0$, where $\theta(x,y)$ is the angle between two vectors $x$ and $y$. Then, \begin{eqnarray} (y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_* &=& (y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_{**} + (y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top (\eta_{*}-\eta_{**}) \nonumber\\ &=&\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\| ~\| \eta_{*}-\eta_{**}\|\cos \theta(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t), \eta_*-\eta_{**})\nonumber\\ &=&\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\| ~\| \eta_{*}-\eta_{**}\|. \end{eqnarray} If $\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\|~\|\eta_*-\widehat{\eta}(t)\| \leq (y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*$, we can guarantee $a^*(t)=a(t)$. Thus, the probability not to choose the optimal arm at time $t$ given the observations and $B(t)$ is \begin{flalign} &\mathbb{P}(a^*(t)\neq a(t)|\{y_i(t)\}_{1\leq i \leq N},B(t)) = \mathbb{P} \left(\left. \|\widehat{\eta}(t)-\eta_*\| > \frac{(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*}{\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\|} \right|\{y_i(t)\}_{1\leq i \leq N},B(t)\right) \nonumber\\ &\leq \left\{\begin{tabular}{cc} 1,& if $\frac{(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*}{\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\|} < \lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\|$\\ $2\cdot\mathrm{exp}\left(-\frac{ \left(\frac{(y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t))^\top \eta_*}{\|y_{a^{*}(t)}(t) - y_{a^{**}(t)}(t)\|}- \lambda_{\max}(B(t)^{-1}) \|\Sigma^{-1}\eta_*\| \right)^2}{2d_y\lambda_{\max}(B(t)^{-1})\gamma^2_{ry}} \right)$, & otherwise. \end{tabular}\right. \end{flalign} \subsection{Proof of Lemma 6} Let $X_1\dots,X_N$ be the order statistics of variables with the standard normal density. The joint distribution of the maximum, $X_N$, and the second maximum variable, $X_{N-1}$, of $N$ independent ones with the standard normal density is \begin{eqnarray} f_{X_{(N-1)}, X_{(N)}}(x_{N-1},x_{N}) = N(N-1) \phi(x_N)\phi(x_{N-1}) \Phi(x_{N-1})^{N-2}, \end{eqnarray} where $\phi$ and $\Phi$ are the pdf and cdf of the standard normal distribution, respectively. The density of $D=X_N-X_{N-1}$, which is the difference of the maximum and second largest variable, can be bounded by $N \phi(0)$ as follows: \begin{eqnarray} f_{D}(d) &=& \int f_{D,X_{N-1}}(d, x_{N-1}) d x_{N-1} \nonumber\\ &=& \int N(N-1) \phi(x_{N-1}+d)\phi(x_{N-1}) \Phi(x_{N-1})^{N-2} dx_{N-1}\nonumber\\ &\leq& N \phi(0). \end{eqnarray} Thus, the density $\gamma D$ is bounded by $N\phi(0)/\gamma = N/\sqrt{2\pi\gamma^2}$. \ifarxiv \input{appendix} \input{Bibliofile} \else \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:27:12', 'yymm': '2204', 'arxiv_id': '2204.04773', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04773'}
arxiv
\subsection{Vehicle Deadlocks} A vehicle deadlock is a state where each vehicle is waiting for another vehicle around and/or inside shared road segments, such as four-way stationary intersections, merging points, single-track lanes, and construction zones. To recover from the vehicle deadlock, vehicles have to break a tie and/or at least one vehicle has to yield and recede. The vehicle deadlock happens even when the centralized and decentralized cooperation protocols \cite{azimi2014stip, lin2019graph, aoki2017configurable, aoki2018dynamic} work properly, due to two reasons: (i) System Failure and (ii) Large Intersection. \textit{\textbf{Deadlock due to System Failure:}} This deadlock happens due to a control failure, a communication failure, a localization failure, and/or a time-synchronization failure of the vehicle system. Under this deadlock, at least one vehicle fails to stop at the appropriate location and may violate the critical section. \textit{\textbf{Deadlock due to Large Intersection:}} At a large intersection, such as a long single-track lane and/or large center turn lane, each vehicle cannot detect and/or negotiate with each other until deadlock happens because of the limitations of communication ranges and/or sensor-detection ranges. These deadlocks happen even for human drivers. Human drivers recover from these deadlocks by accounting for the surrounding situations. For example, when one vehicle exceeds the stop line, as shown in Figures \ref{fig:Scenarios4Deadlock}-(b), -(c), and -(d), the vehicle has to yield and recede to allow the on-coming traffic to move forward. Also, for the case shown in Figure \ref{fig:Scenarios4Deadlock}-(e), the usage of single-track lanes and passing places are explicitly described in the Highway Code Book at UK \cite{HighwayCodeUK}. To guarantee road safety, the drivers use a combination of traffic rules, social norms, and verbal/non-verbal communications. \subsection{Traffic Environments} Our deadlock recovery protocol A-DRIVE is designed for two traffic environments, \textit{Homogeneous Traffic} and \textit{Mixed Traffic}, keeping in mind that a long transition period might be required \cite{bansal2017forecasting}. \textit{\textbf{Homogeneous Traffic:}} The traffic only consists of Connected and Automated Vehicles (CAVs). In our protocol, V2V communication-based A-DRIVE is designed for this traffic environment. \textit{\textbf{Mixed Traffic:}} The traffic has CAVs as well as non-connected self-driving vehicles and human-driven vehicles. These non-connected vehicles are not equipped with any communication devices. The local perception-based A-DRIVE component is for this traffic environment. Even after the spread of autonomous driving technologies in the society, human-driven vehicles might remain for a while. Therefore, we have to design a vehicle cooperation protocol both for the homogeneous traffic and for the mixed traffic, and these protocols should be seamlessly used. \subsection{State Transitions and Cost Function}\label{sec:yieliding_cost} In this section, we present a priority assignment technique that determines which vehicle can proceed and which vehicle must yield and recede to resolve vehicle deadlocks. This component is commonly used for V2V communication-based A-DRIVE and for Local perception-based A-DRIVE. In these $2$ A-DRIVE approaches, we use $3$ elements: (i) vehicle state, (ii) localization state, and (iii) yielding cost. First, each vehicle is in a vehicle state $\Phi_{state}$ that dynamically transitions, and is used to make decisions for vehicle navigation. Secondly, each vehicle holds its \textit{localization state} $\rho_{location}$ that represents the location recognized by the vehicle. The localization state is a Boolean function and becomes $1$ when the vehicle considers its location is within the intersection or within the shared road segment. On the other hand, the localization state $\rho_{location}$ becomes $0$ if the vehicle is outside the intersection area. This value is very useful to resolve a vehicle deadlock, because the deadlock may happen due to the miscalculation of the vehicle location and/or vehicle state. For example, in Figures \ref{fig:LocalizationState}-(a) and -(b), Car B waits at the stop line but exceeds the given line due to the localization errors and/or control failures. Car B are actually within the intersection but it considers its location is out of the intersection area and its localization state $\rho_{location}$ becomes $0$. Thirdly, each vehicle calculates its \textit{yielding cost} $\chi(v_i)$ that represents its cost to yield for resolving the vehicle deadlock. The cost $\chi(v_i)$ becomes larger value when the yielding maneuver for vehicle $i$ is more time-consuming. Each vehicle uses these $3$ elements to negotiate with surrounding vehicles and to resolve the vehicle deadlock. We first present these $3$ elements and secondly discuss the priority assignment and tie-breaking rules. \subsubsection{Vehicle States and Localization States}\label{sec:state} For deadlock recovery protocols, we use $6$ vehicle states: \textit{NOT AROUND INTERSECTION}, \textit{APPROACH}, \textit{WAIT}, \textit{CROSSING}, \textit{IN DEADLOCK} and \textit{YIELDING}. The state transition diagram is shown in Figure \ref{fig:state_deadlockrecovery}. We briefly describe these vehicle states here. \begin{description} \item[1. \textit{NOT AROUND INTERSECTION}]\mbox{}\\ Any vehicles not near the stationary and/or dynamic intersections are in the \textit{NOT AROUND INTERSECTION} state. \item[2. \textit{APPROACH}]\mbox{}\\ When the vehicle approaches the intersection, its state $\Phi_{state}$ transitions to the \textit{APPROACH} state. \item[3. \textit{WAIT}]\mbox{}\\ After the vehicle reaches and stops at the stop line or virtual stop line at the intersection, its state becomes \textit{WAIT} state. The vehicle in the \textit{WAIT} state is not inside the stationary and/or dynamic intersection when the system has no localization failure. \item[4. \textit{CROSSING}]\mbox{}\\ Once the vehicle enters the stationary and/or dynamic intersection, the vehicle state $\Phi_{state}$ transitions to the \textit{CROSSING} state. After the vehicle exits the intersections, its state transitions to the \textit{NOT AROUND INTERSECTION} state. \item[5. \textit{IN DEADLOCK}]\mbox{}\\ Once the vehicle detects that it is involved in a vehicle deadlock, the vehicle state transitions to the \textit{IN DEADLOCK} state. Each vehicle can detect the deadlock by using its local perception and its wait time. In particular, the vehicles in the \textit{WAIT} state and the \textit{CROSSING} state have to keep sensing to detect the vehicle deadlock. \item[6. \textit{YIELDING}]\mbox{}\\ When the vehicle uses the deadlock recovery protocol and determines to yield and recede, the vehicle state transitions to the \textit{YIELDING} state. \end{description} Each CAV holds $1$ of these $6$ vehicle states to negotiate with the other vehicles. In practice, vehicles in the \textit{WAIT} and \textit{CROSSING} can be involved in the vehicle deadlocks. \begin{figure}[!b] \begin{center} \begin{tabular}{c} \begin{minipage}{0.5\hsize} \begin{center} \includegraphics[clip, width=3.85cm]{pic/Priority1.png} \hspace{1.6cm} (a) Vehicle Exceeding\\Virtual Stop Line. \label{fig:case1} \end{center} \end{minipage} \begin{minipage}{0.5\hsize} \begin{center} \includegraphics[clip, width=3.45cm]{pic/Priority2.png} \hspace{1.6cm} (b) Vehicle Exceeding\\Stop Line. \label{fig:case2} \end{center} \end{minipage}\\ \begin{minipage}{0.10\hsize} \end{minipage}\\ \end{tabular} \caption{Localization State and Vehicle Deadlocks.} \label{fig:LocalizationState} \end{center} \end{figure} \subsubsection{Follower-aware Cost Function}\label{sec:costfunc} In this section, we present a \textit{follower-aware cost function} that represents the cost to yield to resolve a vehicle deadlock. The follower-aware cost function considers $2$ factors: (i) Distance to a passing space or to the entrance of the intersection and (ii) Presence of the following vehicles. First, as shown in Figure \ref{fig:Scenarios4Deadlock}-(e), when two vehicles face each other in a critical section, the vehicle closer to a passing space should yield and recede. If there are no passing places or wide parts of the road, the entrance of the critical section is considered as the evacuation site. This approach contributes to shorten the time to resolve the deadlock. Secondly, when one vehicle blocks on-coming multiple vehicles and leads a deadlock, it is preferable that the single vehicle yields and recedes, because the backing operation of multiple vehicles might be difficult and time-consuming. As human drivers comprehensively understand the situation and resolve a vehicle deadlock, the follower-aware cost function gives the yielding cost to increase the traffic throughput. We present the cost function and cost to yield $\chi$ in Eqs. (\ref{eq:cost_func_comm}) and (\ref{eq:cost_func_percp}). Here, $\chi(v_{i, comm})$ and $\chi(v_{i, perception})$ represent the costs to yield for vehicle $i$ for V2V communication-based A-DRIVE and Perception-based A-DRIVE, respectively. \begin{figure}[!t] \centering \includegraphics[width=7.35cm]{pic/Dspace.PNG} \caption{Distance to a Passing Place and a Vehicle Deadlock.} \label{fig:Dspaceexplain} \end{figure} \begin{figure}[!t] \centering \includegraphics[width=7.35cm]{pic/Nf.PNG} \caption{Number of the Following Vehicles.} \label{fig:Nf_number} \end{figure} \begin{equation} \chi(v_{i, comm}) = s_{comm} \cdot D_{SPACE} + t_{comm} \cdot N_{f} \label{eq:cost_func_comm} \end{equation} \begin{equation} \chi(v_{i, perception}) = s_{perception} \cdot D_{SPACE} + t_{perception} \cdot G \label{eq:cost_func_percp} \end{equation} In these equations, $D_{SPACE}$ describes the physical distance to a passing place and/or evacuation site, as shown in Figure \ref{fig:Dspaceexplain}. When the physical distance $D_{SPACE}$ is larger, the cost $\chi(v_i)$ becomes larger value. For example, in Figure\ref{fig:Dspaceexplain}, Car A has larger value for the distance $D_{SPACE}$ and the yielding cost $\chi(v_i)$ becomes larger. $N_f$ describes the number of the following vehicles within the communication range. Since CAV gets the information from the received safety beacon, BSM, they can get this value. As shown in Figure \ref{fig:Nf_number}, Car A has two followers and $N_{f,A}$ becomes $2$. In addition, Car B has no followers and $N_{f,B}$ becomes $0$. In fact, when we have a larger value for $N_f$, the yielding and backing operation become more difficult and more time-consuming. $G$ is a Boolean function to describe the presence of the following vehicle, because each CAV cannot get the exact number of its followers only by using on-board perception systems. Lastly, $s_{comm}$, $s_{perception}$, $t_{comm}$ and $t_{perception}$ are scale factors. \subsubsection{Priority for Deadlock Recovery} The protocol uses these $3$ factors, vehicle state $\Phi_{state}$, localization state $\rho_{location}$, and yielding cost $\chi$, to determine the priority and which vehicle yields and recedes. We present $3$ rules of deadlock recovery for Connected and Automated Vehicles here. \begin{enumerate} \item \textbf{Vehicles within the intersection ($\rho_{location}=1$) have the higher priority, compared to vehicles outside the intersection ($\rho_{location}=0$).} \item \textbf{When multiple vehicles block each other and they are within the intersection ($\rho_{location}=1$), the vehicle having the larger yielding cost has the higher priority.} \item \textbf{When multiple vehicles block each other and they are outside the intersection ($\rho_{location}=0$), the vehicles use the random numbers to break a tie.} \end{enumerate} We give these rules to guarantee road safety while increasing traffic throughput when CAVs resolve the deadlock. First, the localization state is the most important factor. The vehicles within the intersection have the higher priority, because at least one vehicle has to proceed and exit the intersection in order to resolve the deadlock. The deadlock shown in Figures \ref{fig:Scenarios4Deadlock}-(b), -(c) and -(d), can be resolved by using this rule. Secondly, since the yielding cost $\chi(v_i)$ represents the difficulty and complexity of backing operation of vehicle $i$, we can use the cost to determine the priority. The deadlock shown in Figure \ref{fig:Scenarios4Deadlock}-(e) can be resolved by using the yielding cost. Thirdly, as shown in \ref{fig:Scenarios4Deadlock}-(a), when multiple vehicles wait for each other before the stop line at the intersection, they simply use the random numbers to resolve the deadlock. Overall, we use the vehicle state to detect the vehicle deadlock, and we mainly use the localization state and the yielding cost for the negotiation. \subsection{V2V Communications-based A-DRIVE: For Homogeneous Traffic} Here, we present V2V communication-based A-DRIVE that uses V2V communications for safe cooperation. \subsubsection{Message Contents for V2V Communications} To enable a peer-to-peer negotiation by using V2V communications, CAVs exchange $5$ elements as follows. \begin{itemize} \item vehicle state $\Phi_{state}$. \item localization state $\rho_{location}$. \item yielding cost $\chi$. \item random number $R$. \item presence of human-driven vehicle(s) $HV_{flag}$ \end{itemize} These elements are used for determining a priority and resolving a deadlock. $HV_{flag}$ is the flag representing the presence of human-driven vehicle(s) in the vehicle deadlock. When there are no human-driven vehicles involved in the deadlock, the flag becomes $0$ and each CAV follows V2V communication-based A-DRIVE. On the other hand, when the flag becomes $1$, each CAV follows Local perception-based A-DRIVE. To keep the consistency among multiple vehicles involved in the deadlock, when one vehicle has $1$ for the $HV_{flag}$, all the neighboring vehicles change its value to $1$. In other words, CAVs cooperatively sense the presence of non-connected and human-driven vehicles to improve road safety. \subsubsection{Detection of Deadlocks} By definition, a vehicle deadlock happens when multiple vehicles wait for each other. A CAV can detect the presence of a deadlock using its map database that shows other vehicle paths and using on-board perceptions and the received messages over V2V communications that show other vehicle states and locations. Our deadlock recovery protocol will then be initiated and each vehicle negotiates to resolve the deadlock. \subsubsection{Negotiation and Deadlock Recovery}\label{sec:comm_nego} In the protocol, each CAV determines its priority by exchanging their vehicle states $\Phi_{state}$, localization states $\rho_{location}$, yielding costs $\chi$ and random value $R$. First, the vehicle states are used for understanding which vehicles are involved in the vehicle deadlock. Secondly, the localization states and yielding costs are used for the priority assignment. When all vehicles have the same localization states, each vehicle has to negotiate by using the yielding costs. In this negotiation, the vehicle having the largest value on the yielding cost have the priority to use the intersection. On the other hand, When vehicles having $0$ and $1$ in the localization state $\rho_{location}$ are mixed, the vehicles having $0$ in the state $\rho_{location}$ have to start the backing operation, because they are blocking other vehicles at the intersection. In this V2V communication-based A-DRIVE, all negotiations are through the inter-vehicle negotiation, and the negotiation is always reliable and safe. The order of passing vehicles in the intersection correctly reflects the localization state and yielding cost. \subsection{Perception-based A-DRIVE: For Mixed Traffic} In this section, we present Perception-based A-DRIVE for the mixed traffic of CAVs and non-connected vehicles. We firstly present a non-communication-based negotiation scheme that reflect the yielding cost. In addition, we present the compatibility of V2V communication-based A-DRIVE and Perception-based A-DRIVE. Since the negotiation for deadlock recovery cannot use the vehicular communications, each CAV shows its yielding cost by using its wait time. The vehicle having the smaller cost starts to yield and recede first, and therefore, the vehicle having the larger cost may be consequently able to access the intersection area and resolve the deadlock. To guarantee road safety around the intersection, each vehicle always uses its own perception systems and cannot proceed to avoid vehicle collisions. \subsubsection{Non-communication-based Negotiation}\label{sec:non-comm_nego} We now present a non-communication-based negotiation mechanism, in which each automated vehicle determines its threshold waiting time $\Delta$ by its yielding cost $\chi(v)$ presented in Eq. (\ref{eq:cost_func_percp}). The threshold waiting time $\Delta_i$ for vehicle $i$ is the upper limit time period to wait in a deadlock situation. Once its waiting time is exceeding the threshold $\Delta_i$, the vehicle $i$ starts the backing operation. The threshold time $\Delta_i$ is shown as follows. \begin{equation} \Delta_i = a \cdot \chi(v_i) + R_i \label{eq:delta_function} \end{equation} Here, $a$ is a scale factor and $R_i$ is a random value generated at each vehicle. The random value $R_i$ is used by vehicle $i$ for breaking a tie when multiple vehicles involved in a deadlock situation have the exact same yielding cost. This mechanism with random value for breaking a tie is also used for previous vehicle cooperation protocols \cite{azimi2013reliable, azimi2014stip}. In this negotiation protocol, the vehicle being difficult to yield waits for long duration. In other words, the vehicle being difficult to yield remains at the intersection and consequently accesses the intersection area first. The vehicles being able to yield and recede easily have to yield immediately. This logic is very straightforward to us, human drivers, and the protocol might be used even in a mixed traffic environment. \subsubsection{Compatibility for 2 Components} A-DRIVE includes $2$ components and they can be inclusively used for each CAV in practice. In fact, the decision-making processes and the cost functions defined in Eqs. (\ref{eq:cost_func_comm}) and (\ref{eq:cost_func_percp}) have the multiple common elements. In these $2$ subcomponents, each CAV calculates its threshold waiting time in a deadlock situation, and once its once its waiting time exceeds the given threshold, the vehicle starts the backing operation to yield the intersection. Consequently, the higher-priority vehicle can use the intersection area first. In addition, A-DRIVE is robust and resilient against packet loss and/or delay, and never compromises road safety. For example, when one of the vehicles involved in a deadlock situation has the communication failures and/or continuous packet losses, the vehicle is classified as a non-connected vehicle and the local perception-based protocol is used to calculate the threshold waiting time. Since all connected vehicles cooperatively sense the presence of non-connected vehicle, all the vehicles consistently use the Local perception-based A-DRIVE in this case and no vehicle collisions and/or accidents occur. \subsection{Performance Metric} We define the \textit{Trip Time} that represents the time taken by a vehicle to traverse the intersection. We calculate the trip time for each simulated vehicle and compare that against the trip time taken by the car assuming that it stays at a constant speed and does not stop at the intersection. Here, trip time is defined as the time taken by a vehicle to go from a certain start-point before the shared road segment to a certain end-point after the shared road segment. The difference between these two trip times is considered to be the \textit{Trip Delay} due to the intersection, and the \textit{Average Trip Delay} and \textit{Worst Trip Delay} across all CAVs in each simulation are compared in our evaluation. \subsection{Scenarios} We present the evaluation in a single-track lane, as shown in Figures \ref{fig:EvaluationOne} and \ref{fig:Delay_IntersectionSize}. We show the single-track lane for the experiments in Figure \ref{fig:VehicleDeadlock_AutoSim}. The variables for the simulations are set by utilizing the DSRC standards \cite{kenney2011dedicated, cheng2007mobile}. Also, the communication range and frequency for V2V communications are set as 400 m and 10 Hz, respectively. Each simulation runs for 30 minutes, and we evaluate the time delay of the vehicles that are generated during the last 20 minutes to skip initial transients and measure steady-state behavior. Our simulations evaluate A-DRIVE by comparing against one baseline traffic protocol: \textit{Lane Priority-based Protocol}. \begin{figure}[!b] \begin{center} \begin{tabular}{c} \begin{minipage}{0.5\hsize} \begin{center} \includegraphics[clip, width=4.35cm]{pic/AverageDelay3.png} \hspace{1.6cm} (a) Average Trip Delay for Deadlock Recovery. \label{fig:case1} \end{center} \end{minipage} \begin{minipage}{0.5\hsize} \begin{center} \includegraphics[clip, width=4.35cm]{pic/WorstDelay3.png} \hspace{1.6cm} (b) Worst Trip Delay for Deadlock Recovery. \label{fig:Deadlock_Worst} \end{center} \end{minipage}\\ \begin{minipage}{0.10\hsize} \end{minipage}\\ \end{tabular} \caption{Trip Delay and Traffic Volume.} \label{fig:EvaluationOne} \end{center} \end{figure} \begin{description} \item[\textbf{Lane Priority-based Protocol}]\mbox{}\\ Vehicles follow the lane priority that is given from the map database. Even when one vehicle stops near the intersection exit, the vehicle has to start the backing operation if it drives on the lower-priority lane. \end{description} To evaluate our protocol from sparse traffic rural road segments to very congested urban road segments, we change the traffic volume from 200 vehicles per hour to 800 vehicles per hour for each direction. Also, in the simulation, the traffic arrival pattern follows the exponential distribution. In addition, we change the size of intersection from 10 meters to 100 meters. \subsection{Evaluation for Traffic Throughput} \begin{figure}[!t] \centering \includegraphics[width=7.5cm]{pic/Delay_Size.PNG} \caption{Trip Delay and Intersection Size.} \label{fig:Delay_IntersectionSize} \end{figure} We first evaluate the Average Trip Delay and the Worst-case Trip Delay by changing the traffic volume, as shown in Figure \ref{fig:EvaluationOne}. Here, in all cases, A-DRIVE demonstrates the superior performance, compared to the baseline protocol. When the packet losses happen, the vehicles start to use the Local perception-based A-DRIVE. When the traffic volume is low, A-DRIVE and the simple baseline protocol demonstrate similar performance. On the other hand, when the traffic volume increases, the lane priority-based protocol has longer worst-case waiting time, because the vehicles on lower-priority lane might have to keep yielding and waiting for a long time. In addition, we show the Average Trip Delay by changing the physical size of intersection and the traffic volume, as shown in Figure \ref{fig:Delay_IntersectionSize}. In all cases, A-DRIVE demonstrates the better performance than the baseline protocol. In the baseline protocol, the vehicles on lower-priority lane sometimes have to recede multiple times. In particular, for the long intersection, the recovery times from deadlocks become long time and the trip delays are exponentially increased. On the other hand, in A-DRIVE, each CAV negotiates to determine the priority and does not need to take these unnecessary actions. \section{Introduction} \input{01_Introduction \section{Assumptions} \input{02_Assumptions} \section{A-DRIVE: A Deadlock Detection and Recovery Protocol} \input{03_Protocol} \vspace{3mm} \section{Implementation and Evaluation} \input{04_Implementation} \vspace{3mm} \section{Related Work} \input{05_relatedwork} \vspace{3mm} \section{Conclusion} \input{06_conclusion} \bibliographystyle{./bibliography/IEEEtran}
{'timestamp': '2022-04-12T02:34:06', 'yymm': '2204', 'arxiv_id': '2204.04910', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04910'}
arxiv
\section*{Introduction} Recurrent Neural Networks (RNN) specialize in processing sequential data, such as natural speech or text, and broadly, multivariate time series data~\cite{Pang_2019_CVPR, mikolov2010recurrent, noisy1998}. With such omnipresent data, RNN address a wide range of tasks in the form of prediction, generation, and translation for a myriad of applications which include stock prices, markers of human body joints, music composition, spoken language, and sign language ~\cite{tino2001financial, su2019predict, Pennington2017, sutskever2014sequence, gregor2015draw, choi2016text, mao2018deepj, guo2018hierarchical}. While RNN are ubiquitous systems, these networks cannot be easily explained in terms of the architectures they assume, the parameters that they incorporate, and the learning process that they undergo. As a result, it is not straightforward to associate an optimally performing RNN with a particular dataset and a task. The difficulty stems from RNN characteristics making them intricate dynamic systems. In particular, RNN can be classified as \textit{(i) nonlinear} \textit{(ii) high-dimensional} \textit{(iii) non-autonomous} dynamical systems with \textit{(iv) varying parameters}, which are either global (hyperparameters) or connectivity weights during training. RNN are defined as multi-layered systems where each layer is viewed as a sequential composition of a function \emph{\textbf{f}} for each time step of the input sequence. The equations describing a generic RNN are \begin{align} & h_{t+1} = \emph{\textbf{f}}(h_t, x_t) = \sigma(\textbf{U}x_t + \textbf{V}h_t + b),\label{eq:RNNdef} \\ & y_t = \textbf{W} h_t, \label{eq:RNNdef_output} \end{align} where $h_t$ are the hidden states of the RNN, $t$ is the time step, $x_t$ is the input, \textbf{$U$} are the connectivity weight parameters for the input, \textbf{$V$} are the connectivity weight parameters for hidden (internal) states, $b$ is the bias term, and $\sigma$ is a non-linear activation function (e.g., sigmoid or $\tanh$). The hidden states $h_t$ are translated to the predicted output $y_t$, where \textbf{$W$} are the connectivity weight parameters for the output~\cite{elman1990finding}. For RNN to be effective in handling different time scales, it is important to employ the concept of parameter sharing across inputs of different length. This allows the network to generalize across inputs and identify similar features. Since input data may exhibit these features in different orders or duration, the relationship between elements in a sequence must be learnt by the network hidden states through their connectivity parameters. Such requirements introduce several fundamental bottlenecks that hinder the performance of generic RNN. The first bottleneck is due to \textit{long-term propagation of gradients during training} which typically results in vanishing or exploding gradients~\cite{goodfellow2016deep}. In addition, even when the propagation of gradients is stabilized, another bottleneck stems from RNN being a dynamic map constituting the \textit{composition of the function} \emph{\textbf{f}} at each time step being a dynamic map. The long-term repetition of the composition may amplify small inaccuracies at individual time step to large contributions. \begin{figure}[t!] \centering \includegraphics[width = \linewidth]{intro.pdf} \caption{ \textbf{RNN performance for the same task varies significantly with hyperparameter variation.} A) RNN variants randomly initialized with initial states and hyperparameters exhibit a wide distribution of accuracy on the target learning task. B) Clustering of variants with various embeddings (left to right). PCA 2D embedding of the connectivity weights (left), $W$ in Eq.~\ref{eq:RNNdef} does not result in useful clustering. PCA 2D embedding of LE spectrum (middle) separates the variants based on accuracy better. AeLLE 2D embedding (right) is capable, by a vertical line classifier to separate variants and isolate high accuracy variants with high precision.} \label{fig:Overview} \end{figure} In order to have a network which can propagate and learn longer sequence in a robust way, it was shown that the eigenvalues of \emph{\textbf{f}} need to be close to zero \cite{Bengio1994}. Furthermore, architectures of RNN, such as Long Short-Term Memory (LSTM)~\cite{hochreiter1997long} and Gated Recurrent Units (GRU)\cite{cho2014gru, chung2014empiricalgru}, have been proposed to mitigate the extreme effects of these long-term dependencies. LSTM and GRU remedy these problems by incorporating gates (self-loops) which allow the network to learn the amount of information that each component should preserve from previous time steps. By implementing this structure, LSTMs and GRUs are able to learn long-term dependencies, making them useful for a wide variety of applications \cite{huang2015bidirectional, santhanam2020context, liu2017bidirectional, ghosh2016contextual, choi2016text, akilan20193d, wang2016image, byeon2015scene, zhou2019hyperspectral}. While such specific architectures are intuitive and robust, they represent singular points in the space of RNN. In addition, for these architectures, the accuracy still depends on hyperparameters, among which are the initial state of the network, initialization of the network connectivity weights, optimization settings, architectural parameters, and the input statistics. Each of these factors has the potential to impact network learning and as a consequence task performance. Indeed, by fixing the task and randomly sampling hyperparameters and inputs, the accuracy of otherwise identical networks can vary significantly, as demonstrated in Fig.~\ref{fig:Overview}A. Mitigation of the sensitivity on error gradient propagation and informing parameter selection typically involves studying the stability of the propagation of the recursive compositions of the hidden states, i.e., $h_t$~\cite{Bengio1994}. Since vanishing and exploding gradients arise from long products of Jacobians of the hidden states dynamics whose norm could exponentially grow or decay, much effort has been made to mathematically describe the link between model parameters and the eigen- and singular-value spectra of long products~\cite{Pascanu,Poole2016, wang2018predicting,Chen2018}. For architectures used in practice, these approaches appear to have a limited scope~\cite{Yang2017,zheng2020r}. This is likely due to spectra having non-trivial properties reflecting intricate long-time dependencies within the trajectory, and due to the need to take into account the dynamic nature of RNN systems. The identification of RNN as dynamical systems and as such developing appropriate analyses appears as a prospective direction. Recently, dynamical systems methodology has been applied to introduce constraints to RNN architecture to achieve better robustness, such as orthogonal (unitary) RNN~\cite{wisdom2016full,jing2017tunable,mhammedi2017efficient,vorontsov2017orthogonality,azencot2021differential,Chang2019,Kerg_nnRNN} and additional architectures such as coupled oscillatory RNN~\cite{rusch2020coupled} and Lipschitz RNN~\cite{erichson2020lipschitz}. These approaches set network weights to form dynamical systems which have the desired Jacobians for long-term information propagation. In addition, analyses such as stochastic treatment of the training procedure have been shown to stabilize various RNN~\cite{lim2021noisy}. Furthermore, a universality analysis of fixed points of different RNN, proposed in~\cite{Niru_universality}, hints that RNN architectures could be organized in similarity classes such that despite having different architectural properties would exhibit similar dynamics when optimally trained. In light of this analysis, it remains unclear to which similarity classes in the space of RNN the constrained architectures belong and what is the distribution of the architectures within each class. These unknowns warrant development of dynamical systems tools that \textit{characterize and classify RNN variants}. A powerful dynamical system method for characterization and predictability of dynamical systems is \textit{Lyapunov Exponents (LE)}~\cite{ruelle1979ergodic, Oseledets:2008}. LE capture the information generation by the system's dynamics through measurement of the separation rate of infinitesimally close trajectories. The collection of all LE is called LE spectrum (see Fig.~\ref{fig:LEs}). When LE are computed from observed evolution of the system, Oseledets theorem guarantees that LE characterize each ergodic component of the system, i.e., when long enough evolution of a trajectory in an ergodic component is sampled, the computed LE spectrum is guaranteed to be the same (see Methods section for details of computation)~\cite{ergodic-components, ochs1999stability}. Efficient approaches and algorithms have been developed for computing LE spectrum~\cite{lyap-algos}. These have been applied to various dynamical systems including hidden states of RNN and variants such as LSTM and GRU~\cite{Engelken}. Multiple features of LE spectrum provide an insight into an underlying dynamical system. For example, the maximal LE will determine the linear stability of the system~\cite{perron1930ordnungszahlen}. Further, a system having LE greater than zero represents chaotic dynamics with the magnitude of the first exponent indicating the degree of chaos; when the magnitude decreases and approaches zero, the degree of chaos decreases as well. When all exponents are negative, the dynamics converge towards a fixed point attractor. Zero exponents represent limit cycles or quasiperiodic orbits~\cite{PhysRevLett.73.1927, Abarbanel1991}. Many additional features of LE, even non-direct, correspond to properties of the dynamical system. For example, the mean exponent determines the rate of contraction of full volume elements and is similar to the KS entropy~\cite{SHIBATA2001182}. The LE variance measures heterogeneity in stability across different directions and can reflect the conditioning of the product of many Jacobians. In the study of turbulence~\cite{PhysRevLett.51.1442brandstater}, LE close to and below zero in a chaotic system have been showed to align with the inertial subrange of the turbulent system~\cite{yamada_turb}. These features are descriptive and hold for nonlinear autonomous dynamical systems which share with RNN the characteristics of being \textit{(i) nonlinear} and \textit{(ii) high-dimensional}. However, RNN possess two additional characteristics of \textit{(iii) non-autonomous} systems due to the hidden states dynamics $h_t$ driven by inputs $x_t$, and \textit{(iv) varying parameters}. Computing meaningful LE spectrum and preserving its features might still be plausible for RNN with non-autonomous inputs and fixed parameters, as described in~\cite{vogt2020lyapunov}. This approach relies on the theory of random dynamical systems which establishes LE spectrum even for a system driven by a noisy random input sequence sampled from a stationary distribution~\cite{arnold2013random}. Analytical foundations employ uncorrelated Gaussian inputs, however, the framework is expected to apply to a wider range of well-behaved input statistics. This includes those with finite, low-order moments and finite correlation times like character streams from written language and sensor data from motion capture systems. The time course of the driven dynamics depends on the specific input realization, but critically, the theory guarantees that the stationary dynamics for all input realizations share the same stability properties which will, in general, depend on the input distribution, e.g., its variance. \begin{figure*}[ht!] \centering \includegraphics[width = 0.87\textwidth]{lyaup_exp.pdf} \caption{\textbf{LE Spectrum of RNN variants.} RNN (top left) hidden states \textit{h} evolution is tracked to calculate the LE spectrum of the network. The exponents are found by calculating the expansion and the contraction of nearby trajectories over time (bottom left). LE spectra correspond to points on LE spectrum curves (right). Variation of hyperparameters will correspond to distinct spectra curves. Basic known LE features such as Maximum, Initial Slope, Final Slope, Number of exponents greater than zero marked on the plot, do not directly correlate to task accuracy.} \label{fig:LEs} \end{figure*} While including non-autonomous inputs in the analysis of RNN LE spectrum appears feasible, very little is known about LE spectrum features for systems with varying parameters, especially systems like RNN which have a high number of parameters making them sensitive to parameter variation and impractical to analyze on a per-parameter basis. In fact, contradictory examples in~\cite{vogt2020lyapunov} and in Fig.~\ref{fig:LEs} suggest that the known features of LE spectrum are not directly correlated with RNN robustness and accuracy. Such inconsistency motivates our work where we develop a data driven methodology, called \textit{AeLLE}, to infer LE spectrum features and associate them with RNN performance. The methodology implements an Autoencoder (Ae) which learns through its \textit{L}atent units a representation of \textit{LE} spectrum (LLE) and correlates the spectrum with the accuracy of RNN for a particular task. The latent representation appears to be low dimensional and interpretable such that even a simple linear embedding of the representation, denoted as AeLLE, corresponds to a classifier for selection of optimally performing parameters of RNN based on LE spectrum. We show that once AeLLE is trained, it holds for novel inputs and we also investigate the correlation between AeLLE classification accuracy and needed RNN training. \section*{Methods} The proposed AeLLE methodology consists of three steps: 1) Computation of LE spectrum, 2) Autoencoder for LE spectrum, and 3) Embedding of Autoencoder Latent representation. \subsection*{Computation of LE~\cite{Engelken,vogt2020lyapunov}} We compute LE by adopting the well-established algorithm~\cite{Benettin1980,Dieci:1995gp} and follow the implementation in~\cite{Engelken,vogt2020lyapunov}. For a particular task, each batch of input sequences is sampled from a set of fixed-length sequences of the same distribution. We choose this set to be the validation set. For each input sequence in a batch, a matrix \textbf{Q} is initialized as the identity to represent an orthogonal set of nearby initial states. The hidden states \textbf{$h_t$} are initialized as zeros. To track the expansion and the contraction of the vectors of \textbf{Q}, the Jacobian of the hidden states at step t, $\textbf{J}_{t}$, is calculated and then applied to the vectors of \textbf{Q}. The Jacobian $\textbf{J}_t$ can be found by taking the partial derivatives of the RNN hidden states at time $t$, $h_t$, with respect to the hidden states at time at $t-1$, $h_{t-1}$ \begin{equation} \left[\textbf{J}_{t}\right]_{ij} = \frac{\partial \textbf{h}_{t}^j}{\partial \textbf{h}_{t-1}^i}. \end{equation} Beyond the hidden states, the Jacobian will depend on the input $x_t$. This dependence allows us to capture dynamics of a network as it responds to input. The expansion factor of each vector is calculated by updating \textbf{Q} by computing the \textit{QR} decomposition at each time step \begin{equation} \textbf{Q}_{t+1}, \textbf{R}_{t+1} = QR(\textbf{J}_{t}\textbf{Q}_{t}). \end{equation} If $r_t^i$ is the expansion factor of the $i^{th}$ vector at time step $t$ -- corresponding to the $i^{th}$ diagonal element of \textbf{R} in the QR decomposition-- then the $i^{th}$ LE $\lambda_i$ resulting from an input signal of length $T$ is given by \begin{equation}\label{eq:Lyap_sum} \lambda_k = \frac{1}{T}\sum_{t=1}^T {\log}(r_t^k) \end{equation} The LE resulting from each input $x^m$ in the batch of input sequences are calculated in parallel and then averaged. For each experiment, the LE were calculated over a fixed number of time steps with \textit{n} different input sequences. The mean of \textit{n} resulting LE spectra is reported as the LE spectrum. To normalize the spectra across different network sizes and consequently the number of LE in the spectrum, we interpolate the spectrum such that it retains the shape of the largest network size. Through this interpolation, we can represent the LE spectra as curves. Spectra curves will have the same number of LE points for small networks and for larger networks. \subsection*{Autoencoder for LE spectrum} As illustrated in Fig.~\ref{fig:Overview}, the computed LE spectrum appears to organize RNN variants and correlate them with accuracy better than direct quantities of RNN architecture, e.g., the connectivity weights of the output layer $W$ and their embeddings. However, it is also evident that the correlation is subtle and depends on the choice of the embedding (features) of LE spectrum. In fact, when hyperparameters are varied, we observe that direct LE spectrum features are not correlated with performance (see Fig. \ref{fig:LEs} insets of maximum, zero-crossing, initial slope and final slope) . This warrants association of a robust embedding that will extract key correlative features between LE spectrum and RNN accuracy. For such purpose, Autoencoder methodology has been introduced as a methodology for learning robust and nonlinear embeddings from data and employed in numerous feature extraction applications~\cite{meng2017relational, zabalza2016novel, hou2017deep, lv2018deep, liu2014feature}. Autoencoders are multilayered neural networks consisting of two components: an \textit{encoder} network $\mathcal{\phi}$ and a \textit{decoder} network $\mathcal{\psi}$. The encoder receives an input data \emph{\textbf{Z}} and includes multiple layers that shrink in dimension as the input propagates through the layers. The last layer of the encoder, and typically the most compact in dimension, is denoted as the Latent layer. The decoder is a multi-layered network as well, receiving input from the Latent layer and is typically a reflection of the encoder, such that each layer expands in dimension up to the decoder's last (output) layer of same dimension as the first (input) layer of the encoder, see Fig.~\ref{fig:Methods}. The Autoencoder is trained for the task of reconstruction, namely the output of the decoder is optimized to closely match the input into the encoder. Over the course of training, the Latent layer becomes representative of the variance in the input data and extracts key features that might not immediately be apparent in the input. In addition to the reconstruction task, it is possible to include constraints on the optimization by the formulation of a loss function for the Latent layer values (Latent space), e.g., a classification or prediction criterion. This can constrain the organization of values in the Latent space~\cite{goodfellow2016deep, chollet2017deep}. \begin{figure*}[t!] \centering \includegraphics[width = 0.85\textwidth]{autoenc.pdf} \caption{\textbf{AeLLE: LE spectrum Autoencoder and Latent Representation Embedding.} A) LE Autoencoder is set to reconstruct LE spectrum (LE Reconstruction loss) and correlate it with task accuracy (Accuracy Prediction loss). B) The Latent space of the LE spectrum Autoencoder correlates LE spectrum and accuracy. Embedding of Latent space representation provides a low-dimensional clustering and classification space. We find that Latent space clusters the LE spectra well such that simple embedding (PCA) and simple linear classifiers (hyperplane, hyperellipse or threshold) classify RNN variants according to accuracy.} \label{fig:Methods} \end{figure*} We propose to adopt the Autoencoder methodology for correlating LE spectra and RNN task accuracy. In this setup, the input into the encoder of the Autoencoder of LE spectrum of RNN (Ae) is the LE spectrum and denoted as \emph{\textbf{Z}}. Ae consists of a fully-connected encoder network $\mathcal{\phi} $, a decoder network $\mathcal{\psi}$, and a prediction network $\theta$ defined by \begin{equation}\label{eq:AE} \begin{split} \hat{Z} = (\psi \circ \phi)Z, \\ \hat{T} = (\theta \circ \phi)Z, \end{split} \end{equation} where \emph{$\hat{\textbf{Z}}$}, and \emph{$\hat{\textbf{T}}$}, correspond to the output from the decoder and predicted accuracy, respectively, with loss of $L = ||Z - \hat{Z} ||^2 + \alpha \cdot || T - \hat{T}||_n$. Ae performs the reconstruction task, optimization of the first term of Eq.~\ref{eq:AEloss}, mean-squared reconstruction error of LE spectrum, as well as prediction of the associated RNN accuracy \emph{\textbf{T}} (best validation loss), the second term of Eq.~\ref{eq:AEloss}. \begin{equation}\label{eq:AEloss} \phi, \psi, \theta = \argmin_{\phi, \psi, \theta} (||Z - \hat{Z} ||^2 + \alpha \cdot || T - \hat{T}||_n ). \end{equation} The parameter $n$ can defined based on the desired behavior. The most common choices are the $n=1$-norm and $n=2$-norm. During training of Ae, the weight $\alpha$ in the prediction loss is gradually being increased so that Ae emphasizes RNN accuracy prediction once the reconstruction error has converged. We found that this approach allows to capture features of both RNN dynamics and accuracy. A choice of $\alpha$ being too small leads to dominance of the reconstruction loss such that the correlation between LE spectrum and RNN accuracy is not captured. Conversely, when $\alpha$ is initially set to a large value, the reconstruction along with the prediction diverge. The convergence of Ae for different RNN variants, as we demonstrate in Results section, shows that correlative features between LE spectrum and RNN accuracy can be inferred. The dependency of Ae convergence on a delicate balance of the two losses reconfirms that these features are tangled and thus the need for Ae embedding. We describe the settings of $\alpha$ and additional Ae implementation details in Supplementary Materials. \subsection*{Embedding of Autoencoder Latent Representation} When the loss function of Ae converges, it indicates that the Latent space captures the correlation between LE spectrum and RNN accuracy. However, an additional step is typically required to achieve an organization of the Latent representation based on RNN variants accuracy. For this purpose, a low dimensional embedding, denoted as AeLLE, of the Latent representation needs to be implemented. An effective embedding would indicate the number of dominant features needed for the organization, provide a classification space for the LE spectrum features and connect them with RNN parameters. We propose to apply the Principal Component Analysis (PCA) embedding to the Latent representation~\cite{pearson1901liii, su2020clustering}. The embedding consists of computing PCA (PC modes) and projecting the representation on the dominant PC modes (e.g. 2 or 3 PC modes). Notably, while other, nonlinear, embeddings are possible, e.g., tSNE or UMAP~\cite{van2008visualizing, mcinnes2018umap}, when PCA results in a few dominant PC modes and a projection of them results in effective organization it indicates that the Latent representation has successfully captured the characterizing features of the correlation. We show in the Results section that, for all examples of RNN architectures and tasks that we considered, the PCA embedding is sufficient to provide an effective space. In particular, in this space, most accurate RNN variants (green) can be clustered from other variants (red) through a simple clustering procedure, either a hyperplane or a hyperellipse (see Fig.~\ref{fig:Results}). \begin{figure}[t!] \centering \includegraphics[width = 0.5\textwidth]{Figure4.pdf} \caption{\textbf{Application of AeLLE to examples of RNN and tasks.} For each example shown left to right: 2D AeLLE space and classifier, error distribution as function of hyperparameters, examples of output for three error values. \textbf{A) Target Learning with Rank1-RNN.} While $g$ hyperparameter indicates possibility to train a network with low-error, each $g$ value includes both low and high error variants (middle). AeLLE with 2D PCA embedding clusters the variants such that low error ($<0.2$) ones (across $g$ values) are located in the bottom-right of the plane. For such an error, the outputs are visually indistinguishable from the target (right). \textbf{B) Character Prediction (CharRNN) with LSTM.} The network size hyperparameter of $256$ and $512$ appear optimal for accuracy for the CharRNN task. Different initialization can impact the accuracy for each network size (middle). AeLLE 2D PCA (left) clusters variants according to network size branches and in addition organizes variants into groups of high and low error variants (green $< 1.75$). Low error region can be identified with an ellipse and examples show the probability maps for characters with such error (right). \textbf{C) Sequential MNIST classification (SMNIST) with LSTM.} The network size hyperparameter of $32$ and $64$ appear optimal for accuracy for the SMNIST task (middle) in contrast to CharRNN task. AeLLE 2D PCA (left) clusters variants into an arc shape where low error variants (green $< 0.5$) are all separated from high error variants (red) in the left segment of the arc. Low error region can be identified with an ellipse and examples show the probability maps for digit recognition with such error (right).} \label{fig:Results} \end{figure} \section*{Results} To investigate application and generality of our proposed method, we consider tasks with various inputs and outputs and various RNN architectures that have been demonstrated as effective models for these tasks. In particular, we choose three tasks: Signal Reconstruction, Character Prediction and Sequential MNIST. All three tasks involve learning temporal relations in the data with different forms of the input and objectives of the task. Specifically, the inputs range from low-dimensional signals to categorical character streams to pixel greyscale values. Nonetheless, across this wide variety of input data and tasks, the AeLLE space and clustering is consistently able to separate variants of hyperparameters according to accuracy (indicated by colors and elliptical regions in Fig.~\ref{fig:Results}) in a way that is more informative than network hyperparameters alone. More specifically, the Signal Reconstruction task, also known as target learning, a random RNN is being tracked to generate a target output signal from a random input~\cite{sussillo2009generating, zheng2020r}. This task involves intricate time-dependent signals and a generic RNN for which dynamics in the absence of training are chaotic. Character Prediction is a common task which takes as an input a sequence of textual characters and outputs the next character of the sequence. This task is a rather simple task and used to benchmark various RNN variants. In particular, LSTM models have been shown to be successful in this task. Sequential MNIST is a more extensive benchmark for RNN classification accuracy. The input in the task is an image of a handwritten digit unrolled into a sequence of numerical values (pixels greyscale values) and the output is a corresponding label of the digit. We investigate LSTM performance on this task which was demonstrated to achieve high accuracy. We describe the outcomes of AeLLE application and resulting insights per each task below. \subsection*{Target Learning with Random RNN} To examine how AeLLE interprets generic RNN with time evolving signals as output and input, we test Rank-1 RNN. Such a model corresponds to training a single rank of the connectivity matrix, the output weights $W$, on the task of target learning (Eq.~\ref{eq:RNNdef_output} only). We set the target signal (output) to be a four-sine wave, a benchmark used in~\cite{sussillo2009generating}. A key parameter in Rank-1 RNN is the amplification factor of the connectivity, $g$, which controls the output signal in the absence of training. For $g \leq 1$, the output signal is zero, while for $g \geq 1.8$ the output signal is strongly chaotic. In the interval $1< g < 1.8$ the output signal is weakly chaotic. Previous work has shown that the network can generate the target when it is in the weakly chaotic regime, i.e., $1<g<1.8$ and trained with FORCE optimization algorithm~\cite{sussillo2009generating, depasquale2018full}. However, not all samples of the random connectivity correspond to accurate target generation. Even for $g$ values in the weakly chaotic interval, there would be Rank-1 RNN variants that fail to follow the target (see Fig.~4A). Thereby, the target learning task, Rank-1 RNN architecture, and FORCE optimization are ideal candidates to test whether AeLLE can organize the variants of Rank-1 RNN models according to accuracy. The candidate hyperparameters for variation would be in 1) sampling of fixed connectivity weights (from normal distribution) and 2) the parameter $g$ from the weakly chaotic regime. We structure the benchmark set to include 1200 hyperparameter variants and compute LE spectrum for each of them. After training is complete, the set of LE in the validation set are projected onto the Autoencoder's AeLLE space, depicted in Fig.~\ref{fig:Results}A-left. Our results show that AeLLE organizes the variants in a 2D space according to accuracy. The variants with low error values ($<0.2$) are colored in \textit{green} and variants with larger error values ($>0.2$) are colored in \textit{red}. With this threshold, only $22\%$ of networks are classified as low-error and $78\%$ as large error. We demonstrate the disparity in the signals that different error values correspond to in Fig.~\ref{fig:Results}A-right. AeLLE space succeeds to correlate LE spectrum with accuracy such that most low-error networks are clustered in the bottom-right of the two-dimensional projection (see Fig. \ref{fig:Results}A), whereas large-error networks are concentrated in the left and top of the region shown. The coloring demonstrates that the red and the green regions can be easily separated using a hyperplane or a hyperellipse and multiple candidates as top performing variants can be identified with such a simple classification. Comparison of AeLLE clustering with a direct clustering according to values of $g$, Fig.~\ref{fig:Results}A-left vs Fig.~\ref{fig:Results}A-middle, shows that while most networks with $g< 1.6$ include variants with low-error, there are also variants with high-error for each value of $g$. This is not the case for all variants in the low-error hyperellipse of the AeLLE space. These variants have different $g$ and connectivity values and sampling from the hyperellipse provides a higher probability Rank-1 RNN variant to be accurate. \subsection*{Character Prediction with LSTM} Multiple RNN tasks are concerned with non-time dependent signals, such as sequences of characters in a written text. Therefore, we test AeLLE on LSTM networks that perform the character prediction task (CharRNN) in which for a given sequence of characters (input) the network predicts the character (output) that follows. In particular, we train LSTM networks on English translation of Leo Tolstoy's \textit{War and Peace}, similar to the setup described in \cite{karpathy2015visualizing}. In this setup, each unique character is assigned an index (number of unique characters in this text is 82), and the text is split into disjoint sequences of a fixed length $l = 101$, where the first $l-1 = 100$ characters represent the input, and the final character represents the output. The loss is computed as the cross entropy loss between the expected character index and the output one. The hyperparameters of network size (number of hidden states) and initialization of weight parameters appear to have most impact on the accuracy. We create 1200 variants of these parameters, varying the number of hidden units from 64 to 512 and sample initial weights from a symmetric uniform distribution with the parameter $p$ denoting the half-width of the uniform distribution from which the initial weights are sampled in the range of $[0.04,0.4]$. We split the variants into Autoencoder training set ($80\%$) and validation set ($20\%$). The validation is depicted in Fig.~\ref{fig:Results}B-left. Similarly to the target learning task, we mark the variant networks according to accuracy. LSTM networks with loss $<1.75$ are considered as low-error (\textit{green}) which includes $28.3\%$ of networks, while the rest of the networks with larger loss are considered as large-error (\textit{red}). We depict examples of error values and the impact on character prediction in Fig.~\ref{fig:Results}B-right. Similarly to the target learning example, nor the network size, nor the initialization parameter $p$ alone provide clear separation between low-error and large-error variants and need to be set to optimal values together, Fig.~\ref{fig:Results}B-middle. Previous investigations indicated that larger network sizes would be preferable for achieving better accuracy. This is indeed reflected in the variants that we have examined. Smaller networks (size 64 and 128) do not reach low-error accuracy. Larger networks can attain low-error, however, we observe that much larger networks (size 512) are not necessarily more accurate than mid size networks (size 256) across variants that we compared. AeLLE analysis, based on LE spectrum, clearly reflects these observations. We find that AeLLE in 2D space separates the spectra of the variants into four branches which correspond to the four network sizes that were varied. The branches corresponding to smaller networks are located in the top of the AeLLE plane, whereas larger networks are in either the lower half or the far left of the AeLLE plane. Among larger networks, the set of low-error variants is stretched to the right of the bottom region (marked by ellipse), meanwhile, the higher-error networks, even of larger size, are all located in the top and left regions of the AeLLE plane, see Fig.~\ref{fig:Results}B-left. Effectively, AeLLE disentangles the dependence on the two parameters and succeeds to cluster high-accuracy networks into an easily identifiable cluster. \subsection*{Sequential MNIST Classification with LSTM} \label{sec: SMNIST results} LSTM networks have been shown to be applicable in a variety of sequence related tasks. A common benchmark for LSTM is the sequential MNIST task (SMNIST) applied on MNIST dataset~\cite{lecun1998gradient}. In this task, the input is a sequence of pixel greyscale values unrolled from an image of handwritten digits from $0-9$. The output is a prediction of the corresponding label (digit) written in the image. We follow the SMNIST task setup in~\cite{bai2018empirical}, where each image is treated as sequential data and each row is the input at one time, and number of time steps is equal to the number of columns in the image. The loss corresponds to the cross entropy between the predicted and the expected one-hot encoding of the digit. As in CharRNN, we vary two hyperparameters, network size chosen from values of $32-256$, and initialization parameter $p$ sampled from the range of $[2.0, 3.0]$. Similarly to previously described tests, we color code the variants according to accuracy. LSTM networks with loss $<0.5$ are considered as low-error (\textit{green}) which includes $28\%$ of networks, while the rest of the networks with higher loss are considered as large-error (\textit{red}). We illustrate different outputs and error values in Fig.~\ref{fig:Results}C-right. SMNIST accuracy appears to be favorable for smaller network sizes, conversely to CharRNN task. LSTM variants of larger size (128 and 256) do not achieve low-errors while LSTMs of 32 units appear to have the smallest number of high-error variants. Furthermore, the distribution of errors appears to be in the full range of the parameter $p$ indicating the importance of selecting both hyperparameters for optimal accuracy. As in previous tests, AeLLE analysis is able to unravel variants and their accuracy according to LE spectrum. AeLLE plane clusters the spectra of variants with low-error into a group in a form of a dense arc in the mid-left part of the plane, see Fig.~\ref{fig:Results}C-left. Such separation clearly distinguishes between the two groups of accuracies and allows easy detection of the high-accuracy group by fitting an ellipse which contains the arc. \subsection*{Pre-Trained AeLLE for Accuracy Prediction} In the three tests described above, we find that the same general approach of AeLLE allows selection of variants of hyperparameters of RNN associated with accuracy. LE spectrum is computed for fully trained models to set apart the sole role of hyperparameter variation. Namely, all variants in these benchmarks have been trained prior to computing LE spectrum. Over the course of training, connectivity weight parameters vary and as a result LE spectrum undergoes deformations. However, it appears that the general properties of LE spectrum such as the overall shape emerge early in training. From these findings and the success of AeLLE, a natural question arises: how early in training can AeLLE identify networks that will perform well upon completion of training? To investigate this question we use a pre-trained AeLLE classifier, i.e., trained on a subset of variants that were fully trained for the task. We then propose to test how such pre-trained fixed AeLLE represents variants that are only partially trained, e.g., underwent $0\%-50\%$ of training. This test is expected to show how robust are the inferred features within AeLLE correlating hyperparameters and LE spectrum subject to optimization of connectivity weights. Also it would provide insight into how long it is necessary to train the network to predict the accuracy of a hyperparameter variant. \begin{figure*} [t!] \centering \includegraphics[width=0.9\textwidth]{pretrained_AeLLE.pdf} \caption{\textbf{Pre-Trained AeLLE during RNN training.} Prediction of task accuracy of inputs in a test set by pre-trained AeLLE threshold classifier ($PC1 >5$) of SMNIST LSTM variants is shown during ($0\%,5\%,20\%,50\%$) RNN training. Before the RNN is trained there are no low error variants (green; task accuracy of $<0.5$) crossing the threshold. As training progresses, low error variants cross the threshold, such that at $50\%$ of training almost all low error variants have crossed the threshold (high Recall). At $20\%$ of training many low error variants crossed the threshold and almost all large error variants (red) remained outside of the threshold (high Precision).} \label{fig:Extension} \end{figure*} We select the SMNIST task with LSTM models with 64 hidden states size and initialization parameter \textit{p} between 2.0 and 2.5 (200 variants with similar number of low- and large-accuracy models) as the test for the study. We then compute LE spectrum for first ten epochs of the training (out of all 20 epoch) for all variants. We then select 64 variants into a training set and train AeLLE on LE spectrum curves for all epochs of the training set. We define such AeLLE as a Pre-Trained AeLLE and investigate its performance. We select the validation set (16 variants), and apply the same loss threshold of 0.5 as above. Therefore, $56.3\%$ of these variants are low-error networks and $43.7\%$ are large-error networks. We use this set to define a simple threshold that classifies low- and large-error variants according to AeLLE ( Fig.~\ref{fig:Extension} green shaded region of $PC1>5$). We then apply the same Pre-Trained AeLLE and accuracy threshold to variants in the test set (120 variants) at different epochs (formulated as \% of Training) illustrated in Fig.~\ref{fig:Extension} with training progressing from left to right and Table~\ref{tab:PR_LEs}. We observe that projection of variants LE spectrum onto AeLLE (points in AeLLE 2D embedding) changes over the course of training. Before training, the embedding is dense with none of the embedded LE spectra is positioned in the low-error region. In the course of training, the embedded points separate from each other such that points corresponding to low-error move to the right and points of large-error remain to the left and outside of the threshold region. Specifically, after just a single epoch, 5\% of training, we find that the Recall, i.e., the number of the low-error networks which fall within the low-error threshold region, is $35.9\%$. The Precision, i.e., how many networks in the region are low-error, is $95.8\%$, reflecting that $23$ of $24$ variants are correctly identified as low-error. After 4 epochs of training (20\%), the Recall becomes $67.2\%$ such that the region contains more low-error networks, and Precision of $91.5\%$. As training proceeds to $35\%$ and $50\%$, we observe that the Recall rate is further enhanced to $82\%$ and $89.1\%$ respectively. This can be visually observed with almost all green points being included in the green threshold region in Fig.~\ref{fig:Extension}-($50\%$ Task Training). With improvement of the Recall, we also observe that the Precision slightly decreases to $79\%$ and $75\%$ respectively, indicating that several large-error LE spectrum (red points) are erroneously classified as low-error. As a result, we observe that F1 score settles at approximately $0.81$ value.We contrast these results by computing the Recall and the Precision rates at the completion training ($100\%$). We find that in such a case the Recall would increase to approximately $96.9\%$, while Precision would drop to $62\%$ with F1 score of $0.76$. Such F1 score is lower than the score for $35\%$ and $50\%$ which indicates that in terms of optimizing the F1 score an optimum would be reached much earlier in training. Notably, the classifier that we have chosen is the simplest classifier (threshold of the dominant PC mode) to establish a low bound on the the effectiveness of AeLLE during training. We expect improved classification rates for more precise classifiers. \begin{table}[t!] \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{l|l l|l|l} Training & \multicolumn{4}{c}{\textbf{AeLLE} vs. [Loss]} \\ \hline \%& \multicolumn{2}{c|}{Recall} & Precision & F1 \\ \hline 0\% & 0\%& [0\%]& -- & --\\ 5\% & \color{blue} \textbf{35.9\%} &\color{black} [21.4\%] & \textbf{95.8\%} \color{blue} [100\%] & \color{blue} \textbf{0.52} \color{black}[0.35]\\ 20\% & \color{blue}\textbf{67.2\%} & \color{black}[49.0\%] & \textbf{91.5\%} \color{blue} [100\%] & \color{blue} \textbf{0.78} \color{black}[0.66]\\ 35\% & \color{blue}\textbf{82.0\%} &\color{black}[62.6\%] & \textbf{79.2\% }\color{blue} [100\%] & \color{blue} \textbf{0.81} \color{black}[0.77] \\ 50\% & \color{blue}\textbf{89.1\%} &\color{black}[70.4\%] & \textbf{75.0\%} \color{blue} [99\%] & \textbf{0.81} \color{blue} [0.82] \\ 100\% & \textbf{96.9\%} & & \textbf{62.0\%} & \textbf{0.76} \end{tabular} } \caption{Precision, Recall, and F1 Score of pre-trained AeLLE classifier for RNN final accuracy evaluated at different stages of training compared with a direct classifier based on loss values.} \label{tab:PR_LEs} \end{table} In summary, we find that Pre-Trained AeLLE converges early in training to an effective classifier that predicts the accuracy of the given RNN when fully trained. To further quantify the effectiveness of AeLLE classifier prediction, we compare it with a direct feature of training, the loss value at each stage of training, see Table~\ref{tab:PR_LEs}. We find that variants with low loss early in training do correspond to variants that will be classified as low-error, indicated by almost perfect Precision rate of $99\%-100\%$. However, it appears that many variants of high accuracy do not converge quickly. Indeed, the Recall rate for a classifier based on loss values is $21\%-70\%$ for $5\%-50\%$ of training, while in contrast, AeLLE Recall rate is $35\%-89.1\%$ during the same training procedure. This indicates that classification based only on loss could miss multiple variants that may turn out to be accurate. \section*{Discussion} While Recurrent Neural Networks (RNN) are ubiquitous in their applicability to multi-dimensional input sequences and associated tasks, the relation of RNN configurations to accuracy is still lacking. Indeed, RNN can be viewed as nonlinear high-dimensional non-autonomous dynamical systems with varying parameters, and as such, are complex systems that require advanced appropriate methods for analysis. In this work, we studied whether the methodology of Lyapunov exponents (LE), designed for nonlinear complex systems, can assist in inference of the relation between RNN hyperparameters and accuracy. While the direct approach of Lyapunov analysis and its standard features cannot be correlated with accuracy, we show that there exists a learnable relationship through an auxiliary Autoencoder for LE spectrum. The proposed Autoencoder infers the features of LE spectrum that are most related to accuracy and hence serves as a link between RNN architectural configurations and accuracy on a given task. LE methodology is an effective toolset to study nonlinear dynamical systems since LE measure the divergence of nearby trajectories, thus indicate the degree of stability and chaos in that system. Indeed, LE has been applied to various dynamical systems and applications, and there exist theoretical underpinning for characterization of these systems by LE spectrum. However, RNN differ from typical systems by being non-autonomous and possessing multiple hyperparameters that provide a configuration for network architecture. Furthermore, RNN undergo training, in which optimization of loss varies the connectivity parameters. These aspects make the information contained in LE tangled such that it is unknown whether under such alterations LE spectrum remains descriptive of the underlying RNN. Our results demonstrate that the information that LE contain regarding the dynamics of a network could be related to network accuracy on various tasks. In particular, we show that AeLLE Latent representation can generalize across inputs such that AeLLE trained on LE spectra of RNN with inputs belonging to the validation set, can generalize and provide an effective representation for a separate set of inputs, i.e., the test set. Furthermore, we also show that AeLLE can generalize for connectivity weights training such that pre-trained AeLLE can capture the unique features that correspond to accuracy early-on in training. Due to these generalization properties, we conclude that AeLLE with an appropriate classifier can serve as a predictive and diagnostic tool for hyperparameter selection early in training. Specifically, the projection of the LE spectrum of a network onto Pre-Trained AeLLE can predict whether a network will eventually achieve low or large error before completing training. With a simple classifier, being a threshold in the dominant PC mode, we observe that prediction is effective as early as $35\%$ into training. With a more precise classifier, we expect this prediction to happen even sooner. From practical standpoint, this property allows a quick selection of sets of hyperparameters for the network during hyperparameter optimization. Notably, AeLLE is unable to predict the performance of networks which have not been subject to training at all. This is expected as the statistics of the input and the task are not yet captured in the parameters of the RNN and, therefore, in the LE. While our work focuses on selection of RNN hyperparameters with high-accuracy, the AeLLE methodology is general and could be utilized to other systems and extensions. For example, the Autoencoder and its Latent representation can be utilized to organize and classify architectural variants of RNN for particular tasks and could be targeted toward inference of features that define each architecture. Furthermore, extension of AeLLE methodology can be used to search and unravel novel architectures. AeLLE approach can be also adopted to analyze other complex dynamical systems. For example, long-term forecasting of temporal signals from dynamical systems is a challenging problem that has been addressed with a similar data-driven approach using autoencoders or spectral methods~\cite{Lusch2018, lange2021fourier}. Application of AeLLE could unify such approaches for dynamical systems representing various physical systems. The key building blocks in AeLLE that would need to be established for each of these extensions is efficient computation of LE exponents and sufficient sampling of data to train the Autoencoder to form an informative Latent representation. \section*{Code and Data Availability} The datasets analysed during the current study as well as the code used to generated results are available in the LyapunovAutoEncode repository, https://github.com/shlizee/LyapunovAutoEncode. \bigskip \input{LEGuided_NMI.bbl} \end{document}
{'timestamp': '2022-04-12T02:32:51', 'yymm': '2204', 'arxiv_id': '2204.04876', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04876'}
arxiv
\section{Introduction} \label{sec:introduction} With growing interest and innovations in data-driven digital technologies, privacy has become an important legal topic for the technology to be regulations-compliant. In Europe, the General Data Protection Regulation (GDPR) \cite{regulation2016regulation} requires data owners to have a legal basis for processing personally identifiable information (PII), which also includes the explicit consent of the subjects. In cases where explicit consent is not possible, anonymization is often seen as a resorted-to solution. Clinical texts contain rich information about patients, including their gender, age, profession, residence, family, and history, that is useful for record keeping and billing purposes \cite{johnson2016mimic,shickel2017deep}. \begin{figure}[!t] \includegraphics[width=0.85\linewidth]{figures/fig_anon_example_bionlp.png} \centering \caption{ % The process of text de-identification involves the removal of a predefined set of direct identifiers in text \cite{elliot2016anonymisation}. % For clinical notes, this set is often the PHI categories (or types) defined by the Health Insurance Portability and Accountability Act (HIPAA) \cite{gunn2004health}. % The example here shows a de-identified excerpt of a patient note from the Spanish-Catalan stroke dataset used in this study (translated into English here for readability). % } \label{fig:anon_example} \end{figure} In this work, we focus on the task of removing PHI from clinical texts, also called de-identification (\cref{fig:anon_example}). We address a real-world challenge where the target texts are code-mixed (Spanish-Catalan) and domain-constrained (stroke). To avoid high annotation costs, we consider a more realistic setting where we annotate a gold evaluation corpus and a few hundred examples for training. Our approach is motivated by strong performance of pre-trained LMs in few-shot cross-lingual transfer for NER with high sample efficiency (see \cref{fig:few_shot_conll_i2b2}) in comparison to supervised or unsupervised approaches. Our contributions are summarized as follows: \begin{itemize} \item We empirically show the few-shot cross-lingual transfer property of multi-lingual pre-trained LM, mBERT, for NER. \item We apply this property to solve a low-resource problem of code-mixed and domain-specific clinical note de-identification. \item We annotate a few-shot training corpus and a gold evaluation set, minimizing annotation costs while achieving a significant performance boost without needing a large-scale labeled training corpus. \end{itemize} \section{Related Work} GDPR-compliant anonymization requires complete and irreversible removal of any information that may lead to a subject's data being identified (directly or indirectly) from a dataset \cite{elliot2016anonymisation}. However, de-identification is limited to removing specific predefined direct identifiers; further replacement of such direct identifiers with pseudonyms is referred to as pseudonymization \cite{alfalahi2012pseudonymisation}. Generally, de-identification can be seen as a subset of anonymization despite interchangeable usage of the terms in the literature \cite{chevrier2019use}. We focus on solving the problem of de-identification in the clinical domain as a sequence labeling task, specifically named entity recognition (NER) \cite{lample2016neural}. \subsection{Clinical De-identification} 2014 i2b2/UTHealth \cite{stubbs2015annotating}, and the 2016 CEGS N-GRID \cite{stubbs2017identification} shared tasks explore the challenges of clinical de-identification on diabetic patient records and psychiatric intake records respectively. Earlier works include machine learning and rule-based approaches \cite{meystre2010automatic,yogarajan2018survey}, with \citet{liu2017identification} and \citet{dernoncourt2017identification} being the first to propose neural architectures. \citet{friedrich2019adversarial} propose an adversarial approach to learn privacy-preserving text representations; \citet{yang2019study} use domain-specific embeddings trained on unlabeled corpora. While most works have mainly focused on English, some efforts have been made for Swedish \cite{velupillai2009developing,alfalahi2012pseudonymisation} and Spanish (with a synthetic dataset at the MEDDOCAN shared task \cite{marimon2019automatic}). As outlined in \citet{lison2021anonymisation}, a significant challenge in clinical text de-identification is the lack of labeled data. \citet{hartman2020customization} show that a small number of manually labeled PHI examples can significantly improve performance. Prior works in few-shot NER consider the problem where a model is trained on one or more source domains and tested on unseen domains with a few labeled examples per class, some of which with entity tags different from those in the source domains \cite{yang2020simple}. Models are trained with prototypical methods, noisy supervised pre-training, or self-labeling \cite{huang2020few}. We consider a setting where the target and source domains share the \emph{same} entity (PHI) tags, but with a few labeled examples in the target domain (or language). A similar setup has been employed in few-shot question answering \cite{ram2021few}. \section{Problem Statement} \label{sec:methodology} We approach the de-identification problem as an NER task. Given an input sentence $\mathbf{x}$ with $N$ words: $\mathbf{x}=[x_i]_{i=1:N}$, we feed it to an encoder $f_{\phi}: \mathbb{R}^{N} \rightarrow \mathbb{R}^{N \times d}$ to obtain a sequence of hidden representations $\mathbf{h}=[h_i]_{i=1:N}$ \begin{align*} \mathbf{h} = f_{\phi}(\mathbf{x}). \end{align*} We feed $\mathbf{h}$ into the NER classifier which is a linear classification layer with the \texttt{softmax} activation function to predict the PHI label of $\mathbf{x}$: \begin{align*} p_{\theta}(\mathbf{Y}|\mathbf{x}) = \texttt{softmax}(\mathbf{W}^T\mathbf{h} + \mathbf{b}). \end{align*} $p_{\theta}(\mathbf{Y}|\mathbf{x}) \in \mathbb{R}^{N \times |\mathcal{P}|}$ is the probability distribution of PHI labels for sentence $\mathbf{x}$ and $\mathcal{P}$ is the PHI label set. $\theta = [\phi, \mathbf{W} \in \mathbb{R}^{d \times |\mathcal{P}|}, \mathbf{b} \in \mathbb{R}^{|\mathcal{P}|}]$ denote the set of learnable parameters and $d$ being the hidden dimension. The model is trained to minimize the per-sample negative log-likelihood: \begin{align} \mathcal{L} = -\frac{1}{N} \sum_{i=1}^{N} \log p_{\theta}(Y_i=y_i|x_i). \end{align} For pre-trained LMs, this setting corresponds to NER fine-tuning \cite{wu2019beto}. When we jointly fine-tune on more than one NER dataset, we refer to it as multi-task learning. \begin{definition}[\textbf{Few-Shot NER}]\label{def:1} Given an entity label set $\mathcal{P}$, we define the task of few-shot NER as having access to $K\leq M$ labeled sentences containing each element $ p \in \mathcal{P}$ at least once, where $K$ is a small number (e.g., in $[50,500]$) and $M$ is orders of magnitude larger (e.g., $\geq 1000$). \end{definition} \begin{figure*}[!t] \includegraphics[width=1.0\linewidth]{figures/fig_few_shot_conll_i2b2.png} \centering \caption{ % \textbf{Few-shot cross-lingual NER transfer of mBERT}. We compare different transfer learning scenarios from English (EN) to Spanish (ES) for two pairs of datasets as preliminary study to investigate the effectiveness of the few-shot cross-lingual transfer in mBERT: CoNLL-2003 to CoNLL-2002 (\emph{left}) and i2b2-2014 to MEDDOCAN (\emph{right}). % We use supervised fine-tuning on the full training set of the target language (ES) as the \emph{upper bound} and the zero-shot score of the model (pre-trained only on the source language (EN) training set) as the \emph{lower bound} for target language (ES) performance. We then consider 50, 100, 250, and 500 examples from the target language as few-shot training corpora and train the models for 15 epochs. % The models without any pre-training on the source corpus (scratch) eventually outperform the \emph{lower bound} as the number of examples grow; with sufficient epochs, the model with only 50 target-language samples reaches more than 10\% gain in de-identification task (\emph{right: scratch-50}). % However, we find the cross-lingual transfer-learning strategy to be most sample efficient when pre-trained on \emph{source} language---50-shot performance (\emph{left \& right: pretrain-50}) comparable to 500-shot (\emph{left \& right: scratch-500}). We apply this strategy to address the real-world challenges of Spanish-Catalan de-identification. % }\label{fig:few_shot_conll_i2b2} \end{figure*} \begin{definition}[\textbf{Few-Shot NER Transfer}]\label{def:2} Given an NER dataset in a source domain (or language), we define the task of few-shot cross-domain (or cross-lingual) NER transfer as adapting a model trained on the source domain (or language) to a target domain (or language) with access to a few-shot corpus (\cref{def:1}). \end{definition} \noindent This setting is different from prior studies in NER transfer including few-shot \cite{huang2020few}, unsupervised \cite{keung2020don}, and semi-supervised NER \cite{amin2021t2ner}. \subsection{Few-Shot Cross-Lingual Transfer} mBERT \cite{devlin2019bert} has been shown to achieve strong performance for zero-shot cross-lingual transfer tasks, including NER \cite{wu2019beto, pires2019multilingual}. Adversarial learning has been applied with limited gains \cite{keung2019adversarial} in unsupervised approaches to improve zero-shot NER transfer, whereas feature alignments have shown better results \cite{wang2019cross}. Meta-learning with minimal resources \cite{wu2020enhanced} and word-to-word translation \cite{wu2021unitrans} have shown further performance gains. The current state-of-the-art approach \cite{chen2021advpicker} combines token-level adversarial learning with self-labeled data selection and knowledge distillation. \begin{table} \centering \resizebox{5cm}{!}{ \begin{tabular}{cc} \toprule \textsc{CoNLL (EN)} $\rightarrow$ \textsc{CoNLL (ES)} & \textsc{F1} \\ \midrule \citet{pires2019multilingual} & 73.59 \\ \citet{wu2019beto} & 74.96 \\ \citet{keung2019adversarial} & 74.30 \\ \citet{wang2019cross} & 75.77 \\ \citet{wu2020enhanced} & 77.30 \\ \citet{wu2021unitrans} & 76.75 \\ \citet{chen2021advpicker} & \textbf{79.00} \\ \midrule \textit{few-50 (or pretrain-50)} & 78.30 \\ \bottomrule \end{tabular} } \caption{ % Cross-lingual transfer results on CoNLL. \textit{few-50} represents our fine-tuning of EN trained mBERT with 50 random labeled samples from ES. % } \label{table:few_en_es_transfer} \end{table} To investigate the few-shot transferability of mBERT, we consider two pairs of datasets with English as the source language and Spanish as the target language: the CoNLL-2003/CoNLL-2002 \cite{tjong-kim-sang-de-meulder-2003-introduction, tjong-kim-sang-2002-introduction} in the \emph{general domain} and i2b2/MEDDOCAN \cite{stubbs2015annotating, marimon2019automatic} in the \emph{clinical domain}. We report results of our preliminary study in \cref{fig:few_shot_conll_i2b2}. We observed that with as few as 50 random labeled training samples from the target language, we obtain substantial gains for both datasets, with near state-of-the-art on CoNLL (\cref{table:few_en_es_transfer}). We refer to this as \emph{few-shot cross-lingual transfer} property of mBERT for NER. Our study highlights that the property holds for different domains (general and clinical), where the latter focuses on the de-identification task. We leave a large-scale study on more datasets with different languages and domains as future work. Compared to supervised (unsupervised) methods, which use complete labeled (unlabeled) target data, our few-shot approach is \emph{sample-efficient} and alleviates the need of complex pipelines \cite{wu2020enhanced,wu2021unitrans,chen2021advpicker} and large-scale annotations. Furthermore, \citet{keung2020don} highlights the spurious effects of using source data as a development set and recommends using target data as a development set for model selection in NER transfer. Our findings and those in \citet{hartman2020customization} motivate us to \emph{(a)} propose an optimal \emph{few-shot cross-lingual transfer} strategy (outlined in \cref{fig:transfer_strategy}), \emph{(b)} annotate a target development set, and \emph{(c)} construct an annotated \emph{few-shot target corpus} for effective cross-lingual transfer learning. \begin{figure}[!t] \includegraphics[width=1.0\linewidth]{figures/fig_transfer_strategy_anon.png} \centering \caption{ % Our \textit{few-shot cross-lingual transfer} strategy for clinical text de-identification. % } \label{fig:transfer_strategy} \end{figure} \section{Data and Annotation} \label{sec:guttmann_data} Our dataset consists of stroke patient records collected at Instiut Guttmann.\footnote{\url{https://www.guttmann.com/ca/institut-universitari-guttmann-uab}} \cref{table:raw_data_stats} summarizes the raw data statistics and \cref{table:clinical_topics} in \cref{app:data_desc} describes the topics present in the texts. We set aside 100 randomly sampled notes for out-of-sample generalizability evaluation and consider the remaining notes for our development and few-shot corpora sampling; 396$k$ sentences are tokenized in the process. Following the protocol in \citet{gao2021manual} for constructing manually annotated distantly supervised relation extraction test sets, we train mBERT on the MEDDOCAN corpus, using coarse-grained PHI categories $\{$DATE, AGE, LOCATION, NAME, CONTACT, PROFESSION, ID$\}$ with the BIO scheme \cite{farber2008improving}, for evaluation and few-shot training data selection. We use the trained model to make predictions on the dataset and observe that the model predicts PHI on only 50$k$ out of the 396$k$ sentences. A dataset of 5000 sentences ($<$ 2\% of raw sentences) is constructed from a mix of randomly sampled 2500 sentences from this 50$k$ and 2500 from the remaining sentences. We split the dataset into two partitions of 2500 sentences for independent annotation by two annotators. The annotation is performed one sentence at a time by applying one of the 7 coarse-grained PHI labels to each token using the \textsc{T2NER-annotate} toolkit \cite{amin2021t2ner}. Each annotator's confidence level between 1-5 is recorded for the token-level labels for each sample. To record the inter-annotator agreement, we use token-level Cohen's kappa \cite{cohen1960coefficient} statistic reaching a value of 0.898. In total, the two annotators agreed on 3924 sentences, resulting in our final evaluation set. To save annotation costs for developing a \textit{few-shot target corpus}, we resolved the disagreements to obtain a 384-sentence few-shot corpus for training (see \cref{app:data_anno} for annotation details). Our source dataset (the MEDDOCAN corpus) consists of 1000 synthetically generated clinical case studies in Spanish \cite{marimon2019automatic}. The corpus was selected manually by a practicing physician and augmented with PHI from discharge summaries and clinical records. In contrast, our target corpus focuses on the stroke domain and contains PHI from real-world records. Since the target data is code-mixed between Spanish and Catalan, with the majority (53\%) being Catalan, the transfer from Spanish source data (MEDDOCAN) is cross-lingual.\footnote{Although similar, Spanish and Catalan are distinct languages. The domain of MEDDOCAN is missing an explicit mention in \citet{marimon2019automatic}.} \begin{table}[!t] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{ccccc} \toprule \textbf{Patients} & \textbf{Notes} & \textbf{ES} & \textbf{CA} & \textbf{Other} \\ \midrule 1,500 & 327,775 & 42.8\% & 53.0\% & 4.2\% \\ \bottomrule \end{tabular} } \caption{ Raw statistics of the Spanish (ES)-Catalan (CA) data from stroke domain. } \label{table:raw_data_stats} \end{table} \begin{table*}[!t] \centering \resizebox{10cm}{!}{ \begin{tabular}{lccc} \toprule \textbf{Transfer Strategy} & \textbf{Precision} & \textbf{Recall} & \textbf{F1} \\ \midrule \textsc{Fine-tune} (\texttt{M}) & 80.1 & 68.2 & 73.7 \\ \textsc{Fine-tune} (\texttt{M}) $\rightarrow$ \textsc{Fine-tune} (\texttt{F}) & 83.5 & 94.2 & 88.6 \\ \midrule \textsc{Multi-task} (\texttt{M} + \texttt{F}) & 86.0 & 93.3 & 89.5 \\ \textsc{Multi-task} (\texttt{M} + \texttt{F}) $\rightarrow$ \textsc{Fine-tune} (\texttt{F}) & \textbf{87.7} & \textbf{95.0} & \textbf{91.2} \\ \bottomrule \end{tabular} } \caption{ % Results on the development set from the code-mixed stroke data. % \texttt{M} denotes the MEDDOCAN \cite{marimon2019automatic} training set (source) normalized to 7 PHIs (see \cref{app:meddocan_normalization}) at sentence level and \texttt{F} denotes our few-shot target corpus. Here multi-task learning refers to the joint fine-tuning on two datasets. % } \label{table:main_results} \end{table*} \section{Experiments and Results} We conduct our experiments with the \textsc{T2NER} framework \cite{amin2021t2ner}.\footnote{\url{https://github.com/suamin/T2NER}} For the baseline, we consider zero-shot performance on the evaluation set of the mBERT encoder fine-tuned on the MEDDOCAN training set consisting of 16,299 samples. We then fine-tune it on the few-shot target corpus as outlined in \cref{fig:transfer_strategy}. Following the multi-task learning \cite{lin2018multi} approach in \textsc{T2NER}, we jointly fine-tune mBERT on the MEDDOCAN and few-shot target corpora. Since the few-shot corpus is much smaller, the multi-task learning helps the model transfer. It further acts as a regularization approach by sharing parameters between the datasets. To improve performance on the target data, we further fine-tune with the few-shot target corpus after the first step of fine-tuning to have improved target performance; for the model to be an expert in target \cite{cao2020unsupervised}. All the models are trained for 3 epochs with a learning rate of 3e-5 and linear warm-up of 10\%. For few-shot fine-tuning only, the model is trained for 25 epochs. \cref{table:main_results} shows our results. Fine-tuning the baseline mBERT model with the few-shot target corpus improves the F1-score from 73.7\% to 88.6\%, a substantial gain of 14.9\%, highlighting the effectiveness of \emph{few-shot cross-lingual transfer} with mBERT. The significant increase in recall (26\% points) compared to precision (3.4\% points) suggests an increase in the model's capacity to recognize domain-specific entities. Multi-task fine-tuning improves the F1-score to 89.5\%; further fine-tuning on the few-shot target corpus boosts the best model's performance to 91.2\%. \cref{fig:barplot} shows per-PHI-label scores on the development set, along with their frequency. The model performs almost perfectly on DATE and AGE, since most DATE and AGE labeled segments are similar between Spanish and Catalan as they are simple numbers (for DATE) and numbers followed by the word (for AGE; `\emph{edad}' in both Spanish and Catalan). There are some differences in time expressions, e.g., day of the week, as the words are distinctly dissimilar. However, structurally there is only a slight difference. Further, the model struggles with the ID class due to low sample size (5 instances in the few-shot corpus), and it is generally challenging to disambiguate between an alphanumeric string and a PHI ID, as also noted by the ID class' high recall. Our error analysis reveals high false positives for the PROFESSION label in Catalan, e.g.: `\emph{Coloma de Gramenet}' (a LOCATION) and `\emph{Dialogant}' (being able to communicate) are both labeled as PROFESSION. To test the model's generalizability, we tokenize the 100 out-of-sample notes into sentences and make predictions with our best model. The resulting annotated sentences are reconstructed into patient notes, which are manually evaluated by two reviewers (one external and one annotator) for occurrences of true and false positives and negatives. The model achieves precision, recall, and F1-scores of 95.1\%, 99.3\%, and 97.1\% respectively on the out-of-sample notes, highlighting the effectiveness of our approach. \begin{figure}[!t] \includegraphics[width=1.0\linewidth]{figures/fig_results_by_entity.png} \centering \caption{NER metrics on the evaluation set for each entity type with their frequency (dev/few-train).} \label{fig:barplot} \end{figure} \section{Conclusion} We address the task of clinical notes de-identification in a low-resource scenario. By investigating the \emph{few-shot cross-lingual transfer} property of mBERT, we propose a strategy that significantly boosts zero-shot performance while keeping the number of required annotated samples low. Our results highlight the effectiveness of the proposed strategy for the task with a potential for future applications in other low-resource scenarios. \section*{Acknowledgments} The authors would like to thank the anonymous reviewers and Josef van Genabith for their helpful feedback. The work was partially funded by the European Union (EU) Horizon 2020 research and innovation programme through the project Precise4Q (777107), the German Federal Ministry of Education and Research (BMBF) through the project CoRA4NLP (01IW20010), the grant RTI2018-099039-J-I00 funded by MCIN/AEI/10.13039/5011000110033/ and “FEDER”, by the EU. The authors also acknowledge the cluster compute resources provided by the DFKI.
{'timestamp': '2022-04-12T02:27:27', 'yymm': '2204', 'arxiv_id': '2204.04775', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04775'}
arxiv
\section{Introduction} \label{intro} The problem of discovering the causal relationships that govern a system through observing its behavior, either passively (observational data) or by manipulating some of its variables (interventional data), lies at the core of many scientific disciplines, including medicine, biology, and economics. By using the graphical formalism of causal Bayesian networks (CBNs) \cite{kollerl2009probabilistic,pearl2009causality}, this problem can be framed as inducing the graph structure that best represents the relationships. Most approaches to causal structure induction are based on an unsupervised learning paradigm in which the structure is directly inferred from the system observations, either by ranking different structures according to some metrics (score-based approaches) or by determining the presence of an edge between pairs of variables using conditional independence tests (constraint-based approaches) \cite{drton2017structure,heinze2018causal,heinze2018invariant,glymor2019review,ke2020dependency} (see Fig. \ref{fig:(Un)Supervised}(a)). The unsupervised paradigm poses however some challenges: score-based approaches are burdened with the high computational cost of having to explicitly consider all possible structures and with the difficulty of devising metrics that can balance fit to the data with constraints for differentiating causal from a purely statistical relationships (e.g. sparsity of the structure or simplicity of the generation mechanism); constraint-based methods are sensitive to failure of independence tests and require faithfulness, a property that does not hold in many real-world scenarios \cite{koski2012review,mabrouk2014efficient}. In this work, we propose a supervised learning paradigm in which a model is first trained on synthetic data generated using different CBNs to learn a mapping from data to graph structures and then used to induce the structures underlying datasets of interests (see Fig. \ref{fig:(Un)Supervised}(b)). The model is a novel variant of a transformer neural network that receives as input a dataset consisting of observational and interventional samples corresponding to the same CBN and outputs a prediction of the CBN graph structure. The mapping from the dataset to the underlying structure is achieved through an attention mechanism which alternates between attending to different variables in the graph and to different samples from a variable. The output is produced by a decoder mechanism that operates as an autoregressive generative model on the inferred structure. The proposed approach can be viewed as a form of meta-learning, as the model learns about the relationship between datasets and structures underlying them. Supervised learning methods based on observational data have been shown to be feasible by \citet{lopez2015randomized,lopez2015towards} and \citet{li2020supervised}. By allowing the use of both observational and interventional data, the proposed method enables greater flexibility. \begin{figure*} \centering \includegraphics[width=0.90\linewidth]{figures/method_figure.png} \caption{(A). Standard unsupervised approach to causal structure induction: Algorithms use a predefined scoring metric or statistical independence tests to select the best candidate structures. (B). Our supervised approach to causal structure induction (\CSIVA): A model is presented with data and structures as training pairs and learns a mapping between them.} \label{fig:(Un)Supervised} \end{figure*} A requirement of a supervised approach would seem to be that the distributions of the training and test data match or highly overlap. Obtaining real-world training data with a known causal structure that matches test data from multiple domains is extremely challenging. We show that meta-learning enables the model to generalize well to data from naturalistic CBNs even if trained on synthetic data with relatively few assumptions. We show that the proposed model can learn a mapping from datasets to structures and outperform unsupervised approaches on classic benchmarks such as the Sachs \citep{sachs2005causal} and Asia \citep{lauritzen1988local} datasets, despite never directly being trained on such data. Our contributions can be summarized as follows: \begin{itemize} \item We tackle causal structure induction with a supervised approach (\CSIVA) that maps datasets composed of both observational and interventional samples to structures. \item We introduce a variant of a transformer architecture whose attention mechanism is structured to discover relationships among variables across samples. \item We show that {\textsc{CSIvA}}\ generalizes to novel structures, whether or not training and test distributions match. Most importantly, training on synthetic data transfers effectively to naturalistic CBNs. \end{itemize} \section{Background} \label{sec:background} In this section we give some background on causal Bayesian networks (CBNs) and on transformer neural networks, which form the main ingredients of {\textsc{CSIvA}}\ (more details are given in Appendix \ref{sec:app-transformers}). \textbf{Causal Bayesian networks.} A \emph{Bayesian network} \citep{pearl1988probabilistic,cowell2001probabilistic,kollerl2009probabilistic,pearl2009causality} is a pair $\mathcal M=\langle\mathcal G, p\rangle$, where $\mathcal G$ is a \emph{directed acyclic graph} (DAG) whose nodes $X_1,\ldots, X_N$ represent random variables and edges express statistical dependencies among them, and where $p$ is a joint distribution over all nodes that factorizes into the product of the conditional probability distributions (CPDs) of each node $X_n$ given its \emph{parents} ${\text{pa}}(X_n)$ (namely all nodes with an edge onto $X_n$), i.e. $p(X_1, \ldots, X_N) = \prod_{n=1}^N p(X_n \,|\, {\text{pa}}(X_n))$. The structure of $\mathcal G$ can be represented by an adjacency matrix $A$, defined by setting the $(k,l)$ entry, $A_{k,l}$, to 1 if there is an edge from $X_l$ to $X_k$ and to 0 otherwise. Therefore, the $n$-th row of $A$, denoted as $A_{n,:}$, indicates the parents of $X_n$ while the $n$-th column, denoted as $A_{:,n}$, indicates the \textit{children} of $X_n$. A BN $\mathcal M$ can be given causal semantic by interpreting an edge between two nodes as expressing causal rather than statistical dependence. For the experiments, we consider datasets whose elements are \emph{observational data samples}, namely samples from $p(X_1, \ldots, X_N)$, and \emph{interventional data samples}, namely samples from $p_{\text{do}(X_{n'}=x)}(X_1, \ldots, X_N) = \prod_{n=1,n\neq n'}^N p(X_n \,|\, {\text{pa}}(X_n))\delta_{X_{n'}=x}$, where $\delta_{X_{n'}=x}$ is a delta function, corresponding to an \emph{atomic intervention} on variable $X_{n'}$ that forces the variable to take on value $x$. Two adjacency matrices $A^i$ and $A^j$ can be compared using the \emph{Hamming distance} ($\mathcal H$), defined as the norm of the difference between them, ${\cal H}=|A^i-A^j|_1$. \textbf{Transformer neural network.} A transformer \cite{vaswani2017attention,devlin2018bert} is a neural network equipped with layers of self-attention mechanisms that make them well suited to modelling structured data. In traditional applications of transformers, attention is used to account for the sequential nature of the data, such as e.g. for a sentence being a stream of words. In {\textsc{CSIvA}}, each input of the transformer is a dataset of observational or interventional samples corresponding to the same CBN, the attention is used to account for the structure induced by the CBN graph structure and by having different samples from the same node. Transformers are permutation invariant with respect to the positions of the input elements, which ensures that the prediction of a graph structure does not depend on the node and sample position. \section{Causal Structure Induction via Attention (CSIvA)} The proposed approach is to treat causal structure induction as a supervised learning problem, by training a neural network to learn to map observational and interventional data to the graph structure of the underlying CBN. Obtaining diverse, real-world, data with known causal relationships in amounts sufficient for supervised training is not feasible. The key contribution of this work is to introduce a method that uses synthetic data generated from CBNs with different graph structures and CPDs~that is robust to shifts between the training and test data distributions. \iffalse \begin{algorithm}[t] \footnotesize \caption{Training}\label{trainingloops} \begin{algorithmic}[1] \Procedure{Train}{Data $\{(A^i, \mathcal D^i)\}_{i=1}^I$, learning rate $\alpha$} \State Randomly initialize parameters $\Theta_0$ \For{$m=1,\ldots M$} \State Sample $i\in\{1,\ldots,I\}$ \State \hskip-0cm $\Theta_m=\Theta_{m-1} - \alpha \nabla_{\Theta} \sum_l\text{CE}(A^i_l,f_{\Theta_{m-1}}(A^i_{1, \ldots, (l-1)}, \mathcal{D}^i)))$ \end{algorithmic} \label{alg:supervised} \end{algorithm} \fi \setlength{\textfloatsep}{10pt \subsection{Supervised approach} The proposed approach is to learn a distribution of graphs conditioned on observational and interventional data as explained below. We generate training data from a joint distribution $t(\mathcal{G}, \mathcal{D})$ between a graph $\mathcal{G}$ and a dataset $\mathcal{D}$ comprising of $S$ observational and interventional samples from a CBN associated to $\mathcal{G}$ as follows. We first sample a set of graphs $\{\mathcal G^i\}_{i=1}^I$ with nodes $X^i_1,\ldots,X^i_N$ from a common distribution $t(\mathcal{G})$ as described in Section \ref{sec:StructureDistribution} (to simplify notation, in the remainder of the paper we omit the graph index $i$ when referring to nodes), and then associate random CPDs~to the graphs as described in Section \ref{sec:CPDs}. This results in a set of CBNs $\{\mathcal M^i\}_{i=1}^I$. For each CBN $\mathcal M^i$, we then create a dataset $\mathcal D^i=\{x^s\}_{s=1}^S$, where each element $x^s:=(x^s_1,\ldots, x^s_N)^\mathsf{T}$ is either an observational data sample or an interventional data sample obtained by performing an atomic intervention on a randomly selected node in $\mathcal G^i$. \textbf{Model definition and training objective.} The proposed model defines a distribution $\hat{t}(\mathcal{G} \,|\, \mathcal{D}; \Theta)$ over graphs conditioned on observation and interventional data and parametrized by $\Theta$. Specifically, $\hat{t}(A \,|\, \mathcal{D}; \Theta)$ has the following auto-regressive form: $\hat{t}(A \,|\, \mathcal{D}; \Theta) = \prod_{l=1}^{N^2} \sigma(A_{l}; \hat{A}_l = f_{\Theta}(A_{1, \ldots, (l-1)}, \mathcal{D}))$, where $\sigma(\cdot; \rho)$ is the Bernoulli distribution with parameter $\rho$, which is a function $f_{\Theta}$ built from an encoder-decoder architecture explained in Section \ref{sec:model_arcitecture} taking as input previous elements of the adjacency matrix $A$ (represented here as an array of $N^2$ elements) and $\mathcal{D}$. \textbf{Model training.}\label{sec.training} The proposed model is trained via maximum likelihood estimation (MLE), i.e as $\Theta^* = \text{argmin}_{\Theta} \mathcal{L}(\Theta)$, where $\mathcal{L}(\Theta)= -\mathbb{E}_{(\mathcal{G}, \mathcal{D}) \sim t}[\ln \hat{t}(\mathcal{G} \,|\, \mathcal{D}; \Theta)]$, which corresponds to the usual cross-entropy (CE) loss for the Bernoulli distribution. Training is achieved using a stochastic gradient descent (SGD) approach in which each gradient update is performed using a pair $(\mathcal D^i, A^i)$. The data-sampling distribution $t(\mathcal{G}, \mathcal{D})$ and the MLE objective uniquely determine the target distribution learned by the model. In the infinite capacity case, $\hat{t}(\cdot \,|\, \mathcal{D}; \Theta^*) = t(\cdot \,|\, \mathcal{D})$. To see this, it suffices to note that the MLE objective $\mathcal{L}(\Theta)$ can be written as $\mathcal{L}(\Theta) = \mathbb{E}_{\mathcal{D} \sim t}[ \text{KL}(\hat{t}(\cdot \,|\, \mathcal{D}; \Theta); t(\cdot \,|\, \mathcal{D})) ] + c$, where KL is the Kullback-Leibler divergence and $c$ is a constant. In the finite-capacity case, the distribution defined by the model $\hat{t}(\cdot \,|\, \mathcal{D}; \Theta^*)$ is only an approximation of $t(\cdot \,|\, \mathcal{D})$. \subsection{Model architecture} \label{sec:model_arcitecture} The function $f_{\Theta}$ defining the model's probabilities is built using two transformer networks. It is formed by an encoder transformer and by a decoder transformer (which we refer to as ``encoder'' and ``decoder'' for short). At training time, the encoder receives as input dataset $\mathcal D^i$ and outputs a representation that summarizes the relationship between nodes in $\mathcal G^i$. The decoder then recursively outputs predictions of the elements of the adjacency matrix $A^i$ using as input the elements previously predicted and the encoder output. This is shown in \figref{fig:main_fig} (where with omitted index $i$, as in the remainder of the section). At test time we obtain deterministic predictions of the adjacency matrix elements by taking the argmax of the Bernoulli distribution and use those as inputs to the decoder. \begin{figure} \centering \includegraphics[scale=0.17]{figures/main_model_figure.png} \caption{The proposed model architecture and the structure of the input and output at training time. The input is a dataset $\mathcal D=\{x^s:=(x^s_1,\ldots, x^s_N)^\mathsf{T}\}_{s=1}^S$ of $S$ samples from a CBN and its adjacency matrix $A$. The output is a prediction $\hat A$ of $A$. Even though the model receives a set of observations $\mathcal D$ at each gradient update, this is a single-example SGD approach because each update has only a single target $A$. The attention in a transformer normally only operates over different columns. We instead also take attention over the different rows, in alternating layers. } \label{fig:main_fig} \end{figure} \subsubsection{Encoder} The encoder in the proposed model is structured as an $(N+1) \times (S+1)$ lattice. The $N \times S$ part of the lattice formed by the first $N$ rows and first $S$ columns receives a dataset $\mathcal D=\{(x^s_1,\ldots, x^s_N)^\mathsf{T}\}_{s=1}^S$. This is unlike standard transformers which typically receive as input a single data sample (e.g., a sequence of words in neural machine translation applications) rather than a set of data samples. Row $N+1$ of the lattice is used to specify whether each data sample is observational, through value $-1$, or interventional, through integer value in $\{1,\ldots,N\}$ to indicate the intervened node. The goal of the encoder is to infer causal relationships between nodes by examining the set of samples. The transformer performs this inference in multiple stages, each represented by one transformer layer, such that each layer yields a $(N+1) \times (S+1)$ lattice of representations. The transformer is designed to deposit its summary representation of the causal structure in column $S+1$. \textbf{Embedding of the input.} Each data-sample element $x^s_n$ is embedded into a vector of dimensionality $H$. Half of this vector is allocated to embed the value $x^s_n$ itself, while the other half is allocated to embed the unique identity for the node $X_n$. The value embedding is obtained by passing $x^s_n$, whether discrete or continuous, through an MLP \footnotemark \footnotetext{Using an MLP for a discrete variable is a slightly inefficient implementation of a node value embedding, but it ensures that the architecture is general.} encoder specific to node $X_n$. We use a node-specific embedding because the values of each node may have very different interpretations and meanings. The node identity embedding is obtained using a standard 1D transformer positional embedding over node indices. For column $S+1$ of the input, the value embedding is a vector of zeros. \textbf{Alternating attention.} Traditional transformers discover relationships among the elements of a data sample arranged in a one-dimensional sequence. With our two-dimensional lattice, the transformer could operate over the entire lattice at once to discover relationships among both nodes and samples. Given an encoding that indicates the position $n,s$ in the lattice, the model can in principle discover stable relationships among nodes over samples. However, the inductive bias to encourage the model to leverage the lattice structure is weak. Additionally, the model is invariant to sample ordering, which is desirable because the samples are iid. Therefore, we arrange the transformer in {\textsc{CSIvA}}\ in alternating layers. In the first layer of the pair, attention operates across all nodes of a single sample $(x^s_1,\ldots,x^s_N)^\mathsf{T}$ to encode the relationships among two or more nodes. In the second layer of the pair, attention operates across all samples for a given node $(x^1_n,\ldots,x^S_n)$ to encode information about the distribution of node values. \textbf{Encoder summary.} The encoder produces a \emph{summary} vector $e^{\text{sum}}_{n}$ with $H$ elements for each node $X_n$, which captures essential information about the node's behavior and its interactions with other nodes. The decoder uses this summary information to produce a final graph structure. The summary representation is formed independently for each node and involves combining information across the $S$ samples (the columns of the lattice). This is achieved with a method often used with transformers that involves a weighted average based on how informative each sample is. The weighting is obtained using the embeddings in column $S+1$ to form queries, and embeddings in columns $1,\ldots,S$ to provide keys and values, and then using standard key-value attention. \subsubsection{Decoding the adjacency matrix} The decoder generates a prediction of the adjacency matrix $A$ of the underlying $\mathcal G$. It operates sequentially, at each step producing a binary output indicating the prediction $\hat A_{k,l}$ of $A_{k,l}$, proceeding row by row. The decoder is an autoregressive transformer, meaning that each prediction $\hat A_{kl}$ is obtained based on all elements of $A$ previously predicted, as well as the summary produced by the encoder. {\textsc{CSIvA}}\ does not enforce acyclicity. Although this could in principle yield cycles in the graph, in practice we observed strong performance regardless. Nevertheless, one could likely improve the results using post-processing \citep{lippe2021efficient} or by extending the method with an accept-reject algorithm \citep{castelletti2022bcdag,alphacode}. \textbf{Auxiliary loss.} We found that autoregressive decoding of the flattened $N\times N$ adjacency matrix is too difficult for the decoder to learn alone. To provide additional inductive bias to facilitate learning of causal graphs, we added the auxiliary task of predicting the parents $A_{n,:}$ and children $A_{:,n}$ of node $X_n$ from the encoder summary, $e^{\text{sum}}_{n}$. This is achieved using an MLP to learn a mapping $f_n$, such that $f_n(e^{\text{sum}}_{n})=(\hat A_{n,:},\hat A_{:,n}^{\mathsf{T}})$. While this prediction is redundant with the operation of the decoder, it short circuits the autoregressive decoder and provides a strong training signal to support proper training of the decoder. \vspace{-2mm} \section{Synthetic data} \vspace{-2mm} In this section, we describe how we generated the data from different distributions over BNs structures and CPDs used for training and for testing in Sections \ref{sec:in_distribution_exp} and \ref{sec:ood_experiments}, and for training in Section \ref{sec:sim_to_real}. \subsection{Graph distribution}\label{sec:StructureDistribution} We specified a distribution over $\mathcal G$ in terms of the number of nodes $N$ (graph size) and number of edges (graph density) present in $\mathcal G$. As shown in \citet{zheng2018dags,yu2019dag,ke2020dependency}, larger and denser graphs are more challenging to learn. We varied $N$ from $5$ to $10$. The current implementation of the transformer scales quadratically with $N$, and therefore does not allow much larger graphs. However, we could readily incorporate transformer architectures that scale linearly with $N$ \citep{goyal2021coordination,jaegle2021perceiver}. We used the Erdős–Rényi (ER) metric to vary density and evaluated {\textsc{CSIvA}}\ on ER-1 and ER-2 graphs, as in \citet{yu2019dag,scherrer2021learning}. We generated an adjacency matrix $A$ by first sampling a lower-triangular matrix to ensure that it represents a DAG, and by then permuting the order of the nodes to ensure random ordering. \subsection{Conditional probability distributions}\label{sec:CPDs} We perform ancestral sampling on the underlying BN. If there is an intervention, it is on a single randomly sampled node (see Section~\ref{sec:background}). We allow both continuous and discrete nodes. For continuous nodes with interventions, values are sampled from the uniform distribution $U[-1,1]$. For ones without interventions, we generated \emph{continuous data} following a similar setup to \citet{zheng2018dags} and \citet{yu2019dag}. Specifically, let $X$ be a $N\times S$ matrix representing $S$ samples of a CBN with $N$ nodes and weighted adjacency matrix $A$, and let $Z$ be a random matrix of elements in $\mathcal{N}(0, 0.1)$. We generated data as $X_{n,:} = A_{n,:} X + Z_{n,:}$. For discrete nodes with interventions, values are randomly and independently sampled from ${U}\{1,\ldots,K\}$ where $K$ indicates the number of categories of the discrete variable. For ones without interventions, we generate discrete data using two different methods: MLP and Dirichlet conditional-probability table generators, which we refer to as \emph{MLP data} and \emph{Dirichlet data}, respectively. The MLP had two fully connected layers of hidden dimensionality $32$. Following past work \citep{ke2020dependency,scherrer2021learning}, we used a randomly initialized network. The biases were initialized using $U[-0.5, 0.5]$, and the individual weights were initialized using a truncated normal distribution with standard deviation of $1.5$. The Dirichlet generator filled in the rows of a conditional probability table by sampling a categorical distribution from a Dirichlet prior with symmetric parameters $\alpha$. Values of $\alpha$ smaller than 1 encourage lower entropy distributions; values of $\alpha$ greater than 1 provide less information about the causal relationships among variables. We note that this generative procedure is performed prior to node ordering being randomized for presentation to the learning model. \section{Related work} Methods for inferring causal graphs from observational and interventional data can broadly be categorized into score-based (continuous optimization methods included), constraint-based, and asymmetry-based methods. Score-based methods search through the space of possible candidate graphs, usually all DAGs, and ranks them based on some scoring function \citep{heckerman1995learning,cooper1999causal,chickering2002optimal,tsamardinos2006max,hauser2012characterization,goudet2017causal,zhu2019causal}. Recently, \citet{zheng2018dags,yu2019dag,lachapelle2019gradient} framed the structure search as a continuous optimization problem, which can be seen as a way to optimize for the scoring function. There also exist score-based methods that use a mix of continuous and discrete optimization \citep{bengio2019meta,ke2020dependency,lippe2021efficient,scherrer2021learning}. Constraint-based methods \citep{spirtes2000causation, sun2007kernel, zhang2012kernel,monti2019causal,zhu2019causal} infer the DAG by analyzing conditional independencies in the data. \citet{eatonuai} use dynamic programming techniques to accelerate Markov Chain Monte Carlo sampling in a Bayesian approach to structure learning for DAGs. Asymmetry-based methods such as \citet{shimizu2006linear, hoyer2009nonlinear, Peters2011b, daniusis2012inferring, Budhathoki17, mitrovic2018causal} assume asymmetry between cause and effect in the data and use this information to estimate the causal structure. \citet{peters2016causal, ghassami2017learning,rojas2018invariant,heinze2018causal} exploit invariance across environments to infer causal structure. \citet{mooij2016joint} propose a modelling framework that leverages existing methods while being more powerful and applicable to a wider range of settings. Several learning-based methods have been proposed \citep{guyoncause,guyonchalearn, lopez2015towards,kalainathan2018sam,goudet2018learning,bengio2019meta,ke2020dependency,ke2020amortized}. Neural network methods equipped with learned masks exist in the literature \citep{douglas2017universal,ivanov2018variational,yoon2018gain,li2019flow,alias2021neural}, but only a few have been adapted to causal inference. These works are mainly concerned with learning only one part of the causal induction pipeline, such as learning the scoring function. Therefore, these methods are significantly different from the proposed method, which uses an end-to-end supervised learning approach to learn to map from datasets to graphs. Two supervised learning approaches have been proposed, one framing the task as a kernel mean embedding classification problem \citep{lopez2015randomized,lopez2015towards} and one operating directly on covariance matrices \citep{li2020supervised}. Both of these models accept observational data only, and because causal identifiability requires both observational and interventional data, {\textsc{CSIvA}}\ is in principle more powerful. \vspace{-2mm} \section{Experiments} \vspace{-2mm} \begin{figure*} \centering \begin{subfigure}[t]{0.42\textwidth} \raisebox{-\height}{\includegraphics[width=\textwidth]{figures/continuous_results.png}} \caption{\textbf{Results on continuous data.}} \end{subfigure} \begin{subfigure}[t]{0.42\textwidth} \raisebox{-\height}{\includegraphics[width=\textwidth]{figures/mlp_results.png}} \caption{\textbf{Results on MLP data.}} \end{subfigure} \caption{Hamming distance $\mathcal H$~between predicted and ground-truth adjacency matrices on the continuous and MLP data, compared to DAG-GNN \citep{yu2019dag} and non-linear ICP \citep{heinze2018causal}, averaged over 128 sampled graphs. Both non-linear ICP and \CSIVA~performs well on the easier (linear) continuous data. However, \CSIVA~significantly outperforms all other baselines on the more challenging MLP data.} \label{fig:continous_mlp_results} \end{figure*} We report on a series of experiments of increasing challenge to our supervised approach to causal structure induction. First, we examined whether CSIvA generalizes well on synthetic data in the case in which the training and test distributions are identical (Section~\ref{sec:in_distribution_exp}). This experiment tests whether the model can learn to map from a dataset to a structure. Second, we examined generalization to an out-of-distribution (OOD) test distribution, and we determined hyperparameters of the synthetic data generating process that are most robust to OOD testing (Section~\ref{sec:ood_experiments}). Third, we trained {\textsc{CSIvA}}\ using the hyperparameters from the second experiment, and evaluated it on a different type of OOD test distribution from two naturalistic CBNs (Section~\ref{sec:sim_to_real}). This last experiment is the most important test of our hypothesis that causal structure of synthetic datasets can be a useful proxy for discovering causal structure in realistic settings. \paragraph{Hyperparameters.} For all of our experiments (unless otherwise stated) {\textsc{CSIvA}}\ was trained on $I=15,000$ pairs $\{(\mathcal D^i,A^i)\}_{i=1}^{I}$, where each dataset $\mathcal D^i$ contained $S=1500$ observational and interventional samples. For experiments on discrete data, a data-sample element $x^s$ could take values in $\{1, 2, 3 \}$. Details of the data generating process can be found in Section \ref{sec:CPDs}. For evaluation in Sections~\ref{sec:in_distribution_exp} and \ref{sec:ood_experiments}, {\textsc{CSIvA}}\ was tested on $I'=128$ (different for the training) pairs $\{(\mathcal D^{i'}, A^{i'})\}_{i'=1}^{I'}$, where each dataset $\mathcal D^{i'}$ contained $S=1500$ observational and interventional samples. For the Sachs and Asia benchmarks, {\textsc{CSIvA}}\ was still tested on $I'=128$ (different for the training) pairs $\{(\mathcal D^{i'}, A^{i'})\}_{i'=1}^{I'}$, however, $A^{i'}=A^{j'}$ since there is only a single adjacency matrix in each one of the benchmarks. Each setting of the experiment was run with $3$ random seeds. We present test results averaging performance over the $128$ datasets and the $3$ runs. The model was trained for $500,000$ iterations using the Adam optimizer \citep{kingma2014adam} with a learning rate of $1\mathrm{e}{-4}$. We parameterized {\textsc{CSIvA}}\ such that inputs to the encoder were embedded into $128$-dimensional vectors. The encoder transformer had $12$ layers and $8$ attention-heads per layer. The final attention step for summarization had $8$ attention heads. The decoder was a smaller transformer with only $4$ layers and $8$ attention heads per layer. Discrete inputs were encoded using an embedding layer before passing into {\textsc{CSIvA}}. \vspace{-1mm} \textbf{Comparisons to baselines.} For Section \ref{sec:in_distribution_exp}, we compared CSIvA to two strong baselines in the literature, namely non-linear ICP \citep{heinze2018causal} and DAG-GNN \citep{yu2019dag}. Non-linear ICP can handle both observational and interventional data, while DAG-GNN can only use observational data. These two baselines are unsupervised methods, i.e., they are not tuned to a particular training dataset but instead rely on a general-purpose algorithm. We also compared to an all-absent model corresponding to a zero adjacency matrix, which acts as a sanity check baseline. We also considered other methods \citep{chickering2002optimal,hauser2012characterization,zhang2012kernel,gamella2020active}, but only presented a comparison with non-linear ICP and DAG-GNN as these have shown to be strong performing models in other works \citep{ke2020dependency,lippe2021efficient,scherrer2021learning}. For Section \ref{sec:sim_to_real}, we also compared to additional baselines from \citet{chickering2002optimal,hauser2012characterization,zheng2018dags,gamella2020active}. Note that, methods from \citet{chickering2002optimal,zheng2018dags,yu2019dag} take observational data only. DAG-GNN outputs several candidate graphs based on different scores, such as evidence lower bound or negative log likelihood, we chose the best result to compare to {\textsc{CSIvA}}\. Note that non-linear ICP does not work on discrete data, i.e. on the MLP and Dirichlet data, therefore a small amount of Gaussian noise $\mathcal{N}(0,0.1)$ was added to this data in order for the method to run. \vspace{-3mm} \subsection{In-distribution experiments}\label{sec:in_distribution_exp} \vspace{-2mm} In this set of experiments, we investigated whether \CSIVA~can learn to map from data to structures in the case in which the training and test distributions are identical. In this setting, {\textsc{CSIvA}}\ (proposed supervised approach) has an advantage over unsupervised ones, as it can learn about the training distribution and leverage this knowledge during testing. We examined the performance on data with increasing order of difficulty, starting with linear (continuous data), before moving to non-linear cases (MLP and Dirichlet data). \begin{figure} \centering \includegraphics[width=0.42\textwidth]{figures/dirichlet_results.png} \vspace*{-.3\baselineskip} \caption{\textbf{Results on Dirichlet data}. Hamming distance $\mathcal H$~~between predicted and ground-truth adjacency matrices on the Dirichlet data, averaged over 128 sampled graphs. } \label{fig:dirichlet_results} \end{figure} \textbf{Continuous data.} Results on continuous data are presented in Figure \ref{fig:continous_mlp_results}(a). \CSIVA~achieves Hamming distance ${\cal H}<2$ on all evaluated graphs. Similar to previous findings \citep{yu2019dag,ke2020dependency}, larger and denser graphs are more challenging to learn. Non-linear ICP achieves fairly good performance, at times approaching that of \CSIVA, but required a modification \footnotemark \footnotetext{Without this modification, the method achieved near chance performance.} to the dataset wherein multiple samples were collected from the same modified graph after a point intervention (20 samples per intervention), while other methods only sampled once per intervention. \textbf{MLP data.} Results on MLP data are shown in Figure \ref{fig:continous_mlp_results}(b). {\textsc{CSIvA}}\ significantly outperforms non-linear ICP and DAG-GNN. Differences become more apparent with larger graph sizes ($N=10$) and denser graphs (ER-2 vs ER-1), as these graphs are more challenging to learn. \textbf{Dirichlet data.} The Dirichlet data requires setting the values of the parameter $\alpha$. Hence, we run two sets of experiments on this data. In the first set of experiments, we investigated how different values of $\alpha$ impact learning in \CSIVA. As shown in Table \ref{table:dirichlet_data_1} in the appendix, \CSIVA~performs well on all data with $\alpha \leq 0.5$, achieving $\mathcal H<2.5$ in all cases. \CSIVA~still performs well when $\alpha=1.0$, achieving $\mathcal H<5$ on size $10$ graphs. Learning with $\alpha>1$ is more challenging. This is not surprising, as $\alpha>1$ tends to generate more uniform distributions, which are not informative of the causal relationship between nodes. In the second set of experiments, we compared \CSIVA~to non-linear ICP and DAG-GNN. To limit the number of experiments to run, we set $\alpha=1.0$, as this gives the least amount of prior information to \CSIVA. As shown in Figure \ref{fig:dirichlet_results}, {\textsc{CSIvA}}\ significantly outperforms non-linear ICP and DAG-GNN. {\textsc{CSIvA}}\ achieves ${\mathcal H}<5$ on size $10$ graphs, almost half of the error rate compared to non-linear ICP and DAG-GNN, both achieving a significantly higher Hamming distance (${\mathcal H}=9.3$ and ${\mathcal H}=9.5$ respectively) on larger and denser graphs. \textbf{Amount of samples.} We evaluated \CSIVA~on different amount of samples ($100,200,500,1000, 1500$) per CBNs. Results for Dirichlet data sampled from $N=10$ graphs are shown in Figure \ref{fig:num_samples_results}. We can see that $1000$ samples are sufficient for ER-$1$ graphs, whereas having $1500$ samples gives slightly better results compared to $1000$ samples for ER-$2$ graphs. \begin{figure} \centering \includegraphics[scale=0.42]{figures/seqlen_results.pdf} \vspace*{-1\baselineskip} \caption{\textbf{Results on varying amount of samples}. Hamming distance $\mathcal H$~between predicted and ground-truth adjacency matrices for synthetic data. Results for \CSIVA~ trained on Dirichlet data with $N=10$ and $\alpha=0.5$ with different numbers of samples per CBNs. $1000$ samples are sufficient for ER-$1$ graphs, whereas $1500$ samples give a small improvement on ER-$2$ graphs. } \label{fig:num_samples_results} \end{figure} \subsection{Out-of-distribution experiments}\label{sec:ood_experiments} In this set of experiments, we evaluated \CSIVA's ability to generalize to aspects of the data generating distribution that are often unknown, namely graph density and parameters of the CPDs, such as the $\alpha$ values of the Dirichlet distribution. Hence, these experiments investigate how well \CSIVA~generalizes when graph sparsity and alpha values for the Dirichlet distribution of the training data differ from the test data. \begin{table}[t] \centering \begin{tabular}{llrrr} \toprule {\bf \small Train} & & ER-1& ER-2 & ER-3 \\ \midrule & {ER-1} & {1.2} & \colorbox{lightmintbg}{0.9} & 1.3 \\ {\bf \small Test} & {ER-2} & 3.3 & \colorbox{lightmintbg}{1.8} & 2.1 \\ & {ER-3} & 5.0 & \colorbox{lightmintbg}{2.8} & {2.8} \\ \bottomrule \end{tabular} \caption{\textbf{Results on varying graph density for MLP data:} Hamming distance $\mathcal H$~ between predicted and ground-truth adjacency matrices.} \label{table:ood_generalization_mlp} \end{table} \begin{table}[t] \centering \begin{tabular}{llrrr} \toprule {\bf \small Train} & & ER-1& ER-2 & ER-3 \\ \midrule & {ER-1} & \colorbox{lightmintbg}{0.19} & 0.21 & 0.28 \\ {\bf \small Test} & {ER-2} & 0.86 & 0.29 & \colorbox{lightmintbg}{0.25} \\ & {ER-3} & 1.61 & 0.60 & \colorbox{lightmintbg}{0.23} \\ \bottomrule \end{tabular} \caption{\textbf{Results on generalization on graph sparsity for Dirichlet data ($\alpha=1$):} Hamming distance $\mathcal H$~~between predicted and ground-truth adjacency matrices.} \label{table:ood_generalization_ER_dirichlet} \end{table} \textbf{Varying graph density.} We evaluate how well {\textsc{CSIvA}}\ performs when trained and tested on CBNs with varying graph density on MLP and $\alpha=1$ Dirichlet data. We fixed the number of nodes to $N=7$, with variables able to take on discrete values in $\{1, 2, 3 \}$. The graphs in training and test datasets can take ER degree $\in \{1, 2, 3 \}$. Results are shown in Table \ref{table:ood_generalization_mlp} for the MLP data and Table \ref{table:ood_generalization_ER_dirichlet} for the Dirichlet data. For the MLP data, models trained on ER-$2$ graph generalizes the best. For Dirichlet data, there isn't one value of graph density that consistently generalizes best across graphs with different densities. Nevertheless, ER-$2$ graphs give a balanced trade-off and generalizes well across graphs with different sparsity. \textbf{Varying $\alpha$.} We evaluate {\textsc{CSIvA}}\ on training and test data coming from Dirichlet distributions with $\alpha \in \{0.1, 0.25, 0.5\}$. Results for ER-$1$ graphs with $N=7$ are found in Table \ref{table:ood_generalization_alpha}. There isn't a value of $\alpha$ that performs consistently well across different values of $\alpha$ for the test data. Nevertheless, $\alpha=0.25$ is a balanced trade-off and generalizes well across test data with $0.1 \leq \alpha \leq 0.5$. \begin{table}[h] \centering \begin{tabular}{llrrr} \toprule {\bf \small Train} & & $\alpha=0.1$ &$\alpha=0.25$ & $\alpha=0.5$ \\ \midrule & {$\alpha=0.1$ } & \colorbox{lightmintbg}{0.31} & 0.33 & 0.52 \\ {\bf \small Test} & {$\alpha=0.25$ } & 0.72 & \colorbox{lightmintbg}{0.40} & 0.41 \\ & {$\alpha=0.5$ } & 1.8 & 0.71 & \colorbox{lightmintbg}{0.35} \\ \bottomrule \end{tabular} \caption{\textbf{Results on varying graph density for Dirichlet data:} Hamming distance $\mathcal H$~between predicted and ground-truth adjacency matrices.} \label{table:ood_generalization_alpha} \end{table} \subsection{Sim-to-real experiments}\label{sec:sim_to_real} In this final set of experiments, we evaluated \CSIVA's ability to generalize from being trained on MLP and Dirichlet data to being evaluated on the widely used Sachs \citep{sachs2005causal} and Asia \citep{lauritzen1988local} CBNs from the BnLearn repository, which have $N=11$ and $N=8$ nodes respectively. We followed the established protocol from \citet{ke2020dependency,lippe2021efficient,scherrer2021learning} where we sampled observational and interventional data from the CBNs provided by the repository. These experiments are the most important test of our hypothesis that causal structure of synthetic datasets can be a useful proxy for discovering causal structure in realistic settings. We emphasize that all hyperparameters for the MLP and Dirichlet data generation and for the learning procedure were chosen without using the Sachs and Asia data; only after the architecture and parameters were finalized was the model tested on these benchmarks. Furthermore, to keep the setup simple, we trained on data sampled from a single set of hyperparameters instead of a broader mixture. Findings in Section \ref{sec:ood_experiments} suggest that ER-$2$ graphs with $\alpha=0.25$ generalize well overall and hence were chosen. \begin{table}[t] \centering \begin{tabular}{lrr} \toprule & Sachs & Asia \\ \midrule All-absent Baseline & 17 & 8 \\ \midrule { \small GES \citet{chickering2002optimal}} & 19 & 4\\ { \small DAG-notears \citet{zheng2018dags}} & 22 & 14 \\ { \small DAG-GNN \citet{yu2019dag}} & 13 & 8\\ \midrule { \small GES \citet{hauser2012characterization}} & 16 & 11 \\ { \small ICP \citet{peters2016causal}} & 17 & 8 \\ {\small Non-linear ICP \citet{heinze2018invariant}} & 17 & 7 \\ \midrule CSIvA~(MLP data) & \colorbox{lightmintbg}{\textbf{6}} & \colorbox{lightmintbg}{\textbf{3}}\\ CSIvA~ (Dirichlet data) & \colorbox{lightmintbg}{\textbf{5}} & \colorbox{lightmintbg}{\textbf{3}}\\ \bottomrule \end{tabular} \caption{\textbf{Results on Sachs and Asia data:} Hamming distance $\mathcal H$~between predicted and ground-truth adjacency matrices. } \label{table:real_baseline_hamming} \end{table} We report the results in Table \ref{table:real_baseline_hamming}. We compare to a range of baselines from \citet{heinze2018causal,yu2019dag,gamella2020active} and others. Note that we do not compare to the method in \citet{ke2020dependency}, as this method needs at least $500,000$ data samples (which is more than $300$ times the amount required by {\textsc{CSIvA}}). \CSIVA~trained on both the MLP data and on the Dirichlet data significantly outperforms all other methods on both the Asia and the Sachs dataset. This serves as strong evidence that {\textsc{CSIvA}}\ can learn to induce causal structures in the more realistic real-world CBNs, while only trained on synthetic data. \vspace{-4mm} \section{Discussion} \vspace{-4mm} In this paper, we have presented a novel approach towards causal graph structure inference. {\textsc{CSIvA}}\ is based on learning from synthetic data in order to obtain a strong learning signal (in the form of explicit supervision), using a novel transformer-based architecture which directly analyzes the data and computes a distribution of candidate graphs. We demonstrated that even though only trained on synthetic data, {\textsc{CSIvA}}\ generalizes on out-of-distribution. We see several possible extensions to {\textsc{CSIvA}}. The distribution of the synthetic data used for training determines the inductive bias of the trained network. Identifying which priors lead to the best performance in real-world scenarios and how to convert informal prior knowledge into better priors would potentially improve robustness of our solution. Another venue of improvement would be to combine supervised learning on synthetic data with score optimization. Note that since {\textsc{CSIvA}}\ offers a probabilistic distribution of possible graphs, it is in principle possible to train it by reinforcement learning (RL) methods such as REINFORCE \citep{williams1992simple} on any score function that can be computed on a graph. An even more intriguing alternative is to leverage the output distribution of a trained network as a guide for a search-based method which optimizes a well designed score function. This would in particular enable {\textsc{CSIvA}}\ to become less black-box, as the trained network would only be used to generate proposals for plausible causal graphs, which can then be evaluated by and chosen on the basis of more interpretable metrics. On the computational side of things, {\textsc{CSIvA}}\ is based on transformers, which uses self-attention. Standard transformer implementation that uses self-attention scales quadratically with the length of the inputs. This makes it challenging for {\textsc{CSIvA}}\ to scale to larger graphs. However, methods such as \citet{jaegle2021perceiver,goyal2021coordination} enable transformers to scale linearly with the number of inputs (and outputs), which can be readily incorporated into our framework. Further work is required to scale our method to very large datasets. Finally, another possible direction of future work would be to use the proposed framework for learning causal structure from raw visual data. This could be useful, e.g., in an RL setting in which an RL agent interacts with the environment via observing low level pixel data. Such an agent would need to infer the causal variables underlying the observations, as well as their relationships \citep{ahmed2020causalworld, ke2021systematic,wang2021alchemy}. \clearpage
{'timestamp': '2022-04-12T02:32:50', 'yymm': '2204', 'arxiv_id': '2204.04875', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04875'}
arxiv
\section{Introduction}\IEEEPARstart{P}{erson} re-identification (Re-ID) , as a fine-grained instance recognition problem, aims to re-identify a query person-of-interest across disjoint camera views \cite{leng2020a, AYe2020, Liu2021a}. Since the surge of deep representation learning, great boosts of Re-ID performance have been witnessed in an idealistic supervised learning testbed: the rank-1 matching rate has reached 96.4\% \cite{Li2019} on Market1501 dataset, even surpassing human-level recognition rate. However, this success relies heavily on an ideal scenario where both probe and gallery images are captured by multiple groups of visible cameras. In real-world scenarios, criminals always appear during the day and commit crimes at night, in which case, visible cameras are incapable of capturing valid appearance information of persons. To overcome this obstacle, many surveillance cameras automatically toggle their mode from the visible modality to infrared. Accordingly, a new task that associates visible and infrared person images captured by dual-mode cameras for cross-modality image retrieval (VI-ReID) has raised \cite{Wu2017}. \begin{figure}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{Fig1.pdf}\vspace{-0.4cm} \end{center} \caption{A high-level overview of homogeneous modality learning strategy. Our method first converts visible images into grayscale images, and then uses a style transfer model to transfer infrared images into the grayscale images. In this manner, both modality and luminance gaps are reduced in image-level. Best viewed in color.\vspace{-0.6cm}} \label{fig:smalltarget} \end{figure}\label{sec:introduction} \begin{figure*}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{VIReID.pdf}\vspace{-0.4cm} \end{center} \caption{ Example images from the SYSU-MM01 dataset showing that in addition to the modality discrepancy across visible and infrared modalities, different infrared images also suffer from distinctive luminance variations. \vspace{-0.6cm}} \label{fig:smalltarget} \end{figure*}\label{sec:introduction} Except for the person's appearance discrepancy involved in single-modality ReID, VI-ReID encounters the additional modality discrepancy resulting from the different imaging processes of spectrum cameras. In an effort to minimize such modality gap, one representative method-of-choice is to embed heterogeneous images into a shared feature space so as to align feature distribution using feature-level constraints \cite{Wu2017, Ye2018, Ye2020, Ye2018a}. However, feature-optimization based model in practice is often constrained in a homogeneous feature space. While for heterogeneous images, it is always a suboptimal problem. Another line is image synthesis methods \cite{Wang2019, Wang2020, Xia2021, Wang2019a}, which exploit generative adversarial networks (GANs) as a style transformer to generate multi-spectral images. However, due to the insufficient amount of cross-modality paired examples, the generative pipeline often leads to low-fidelity generations (incomplete local structure or unavoidable noise). If we directly use these low-quality synthetic images to train an Re-ID model, a novel gap between the original data and the synthetic data would be introduced to the learning process, thereby undermining the training process. Above liminations promote us to consider: if there exists one high-fidelity shared image space that the different modality information can be treated equally? In other words, we only need to eliminate person apperance discrepancy in such space, just same as the goal of conventional single-mode Re-ID methods. Motivated by this train of thought, in this paper, we explore the correlation between two modalities and formulate a unified spectral to improve the similarity of feature distributions, called Aligned Grayscale Modality (AGM). As shown in Fig. 1, our method is divided into two steps. First, we obtain grayscale images from visible images directly by image graying operation. Second, with generated grayscale images, we train a style transfer model to transfer the style of infrared images into grayscale. In this way, heterogeneous modality data are aggregated into homogeneous modality data. Comprared to existing GAN-based algorithms, the proposed AGM 1) perfectly persists the discriminative information of orignial images, 2) really and truly actualizes the modality discrepancy elimination in image-level, and 3) is easy to implement without dizzy training strategies. In addition to fulfil visible-infrared modality alignment, AGM also suppresses the gap of infrared image brightness changes. Specifically, as shown in Fig. 2(a), the left infrared images present a highlighted appearance, while the right show the low brightness. The same observation can also be seen in Fig. 2(b): the top row presents bight spectrum, yet the bottom row of the same identity presents dark spectrum. We formulate this phenomenon as `luminance gap', which produces terrible influence. In this paper, AGM defuses such luminance gap using CycleGAN, that all infrared images are normalized into homogeneous grayscale images. We call this process as the Grayscale Normalization (GN). Benefiting from the unique grayscale style, the normalized infrared images can perfectly clear up the luminance gap. Then, to reduce the remaining appearance discrepancy, we propose to leverage the head-shoulder information to assit global features. The head-shoulder area possesses abundant discriminative information, such as hair-style, face and neckline style, that play an important role in inferring the interested target person. In particular, as shown in Fig. 3, we design a two-stream cascade structure to encode both finer-granularity (head-shoulder) and coarser-granularity (global) appearance information. Then, we concatenate two types of features for generating the final person representation and back-propagate the supervised loss to all specific and joint branches. Mutual interaction of head-shoulder and global information can obviously enhance the feature representation ability, however, this behaviour is always conducted as an asynchronous learning scheme in different branches. Therefore, in order to ensure synergistically correlated feature learning at different branches, we also develop a synchronous learning strategy (SLS). It explicitly optimises the underlying complementary advantages across granularities via imposing a closed-loop cross-branch interactive regularisation. Under such balance between individual learning and correlation learning in a closed-loop form, we allow all branches to be learned concurrently in an end-to-end fashion. To summarize, we make the following contributions: $\bullet$ we attempt an under-explored but significant research path for addressing cross-modality problem. In particular, we creat a unified middle modality image space to embed the homogeneous modality information, which builds a connection between visible and infrared domains. It is worth recalling that, our middle modality space (AGM) is fully visual, high-fidelity and easily reproduced. We believe AGM has great potential to further boost cross-modality retrieval performnce. $\bullet$ To further make clear cross-modality matching challenges, we for the first time introduce a new concept called Luminance Gap. This leads to Grayscale Normalization (GN), a style-based normalized approach capable of suppressing the luminance varitions of infrared images and further alleviates the modality discrepancy. $\bullet$ We investigate the multi-granularity feature learning problem and formulate a more robust head-shoulder descriptor to support person Re-ID matching. Head-shoulder part effectively augments person information with discriminative appearance cues to construct high dimensional fusion features, leading to a competitive Re-ID performance. $\bullet$ A synchronous learning strategy (SLS) with a well-designed closed-loop interactive regularisation is developed to optimize the underlying complementary advantages of both global and head-shoulder information, that urges the network to obtain more discriminative features for correct classification. \section{Related Work} \subsection{Visible-Visible Re-ID Methods.} Visible-visible person Re-ID studies typically tackle a single-modality case, that is, both query and gallery images are captured by visible cameras. It usually suffers from the large intra-class variations caused by different views \cite{Zhu2020}, poses \cite{Liu2018} and occlusions \cite{Miao2019}. Nowadays, substantial research efforts \cite{Sun2019, Lin2019, Luo2019, Zhang2020, Li2019, Wang2018, Varior2016, Fan2019, Hermans2017} have been constructed to extract discriminative features or learn effective distance metrics. For a instance, the work of \cite{Lin2019} exploits attributes as complementary information to help recognize the target person. Self-attention based methods \cite{Luo2019, Zhang2020} incorporate attention techniques to let the network concentrate on discriminative regions. Part-based approaches \cite{Sun2019, Li2019, Wang2018} treat person Re-ID as a partial feature learning task, dividing person images into multiple horizontal strips and applying independent classifiers to suprvise each local strips. Other methods are based on metric learning, focusing on desgining proper loss functions for optimizing feature distances between different samples, like the contrastive loss \cite{Varior2016}, sphere loss \cite{Fan2019} and triplet loss \cite{Hermans2017}. The overwhelming majority of techniques in these literature have achieved considerable success in visible-to-visible matching, while they are ill-suited for cross-modality image retrieval in poor lighting environments \cite{Wu2017}, limiting applicability in practical 24-hour surveillance situations. \subsection{Visible-Infrared Re-ID Methods.} Visible-infrared person Re-ID task is proposed to achieve 24-hour continuous surveillance. In addition to conventional appearance discrepancy, it also suffers from the modality discrepancy originating from different wavelength ranges of spectrum cameras \cite{Wu2017}. To handle such cross-modality discrepancies, early works try to learn a modality-sharable feature representation using feature-level constraints \cite{Wu2021, Ye2018, Ye2018a, Ye2020, Liu2021}. They design novel classification and/or triplet losses for pointing at optimizing cross-modality samples. Specifically, \cite{Ye2020} uses modality-sharable and modality-specific classifiers to learn identity information in the classifier level and introduce a collaborative ensemble learning scheme to collaboratively optimize the feature learning with multiple classifiers. \cite{Ye2018} propose a bi-directional top-ranking loss, which samples positive and negative pairs from different modalities and optimizes such cross-modality triplets with a bi-directional interactive iteration manner. More recently, some other works adopt adversarial training strategies to reduce the cross-modality distribution divergence in image-level \cite{Wang2019, Wang2020, Xia2021, Wang2019a, Zhong2021, Zhang2021}. For a instance, they transfer stylistic properties of visible images to their infrared counterpart, with an identity-preserving constraint \cite{Wang2019a,Wang2019} or cycle consistency \cite{ Wang2020, Xia2021}. However, due to the lack of paired cross-modality training data, GAN-based methods always involve much randomness, which may lead to identity inconsistency during the complicated adversarial training proces \cite{Xia2021, Wang2019a}. In contrast, our method proposes to exploit aligned grayscale modality space (AGM) to reduce the cross-modality distribution divergence in image-level. It is no longer the pattern of transfering A to B or B to A, but projecting A and B to C, where the space of C treats the different modality information equally. \begin{figure*}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{GrayReID.pdf}\vspace{-0.6cm} \end{center} \caption{The proposed framework for VI-ReID which contains modality alignment module, multi-granularity feature extraction module and multi-branch synchronous learning module. The grayscale features generated via modality alignment module are directly exploited for modality-sharable feature learning. For multi-granularity feature extraction, both gobal and head-shoulder appearance information are encoded by two branches for producing the specific features, and the multi-granularity fusion branch produces the final Re-ID features for learning the consensus on identity classes across two sub branches. The training of each branch is supervised by the same identity class label and triplet constraints concurrently.\vspace{-0.4cm}} \label{fig:smalltarget} \end{figure*}\label{sec:introduction} \subsection{Finer-granularity Information.} Finer-granularity information, such as clothing, hair style, etc., produce abundant discriminative feature representations for contributing the person Re-ID, especially when color information is entirely uninformative in visible-infrared and gray-gray matching problem. However, as we know, it has been rarely explored and remains an open issue. The literature \cite{Sun2019} is the pioneering work to attempt to improve Re-ID performance with part features. It generates part-level features by partitioning the convolutional tensor and calculates the cross-entropy loss for every achieved part-level column vector. To make the model make robust in crowded conditions, another work \cite{Li2018} focuses solely on head-shoulder part instead of the whole body for person Re-ID. It splits head-shoulder images into groups by pose pairs and trains similarity classifier for each. Due to different pose features are ambiguous for naive classifiers, an ensemble conditional probability is leaned for excavating relationship among multiple poses. Inspired by the basic idea of head-shoulder information \cite{Li2018}, we present a two-stream cascade structure to simultaneously encode global and head-shoulder part features for gray-gray Re-ID problem, revolutionizing the method of local feature assisting global feature in the existing literature. \section{Proposed method.} In this section, we present the structure of the proposed aligned grayscale modality (AGM) learning model, which is aimed at learning robust modality-invariant feature representations for visible-infrared person Re-ID. As shown in Fig. 3, we first formulate a unified middle modality space to overcome modality discrepancy. Then, we introduce our two-stream cascade network for learning high-level semantic features of both coarser-granularity global and finer-granularity head-shoulder inputs. Finally, to discover and capture correlated complementary combination between the global and head-shoulder features, we supervise each branches with the same identity class label and further introduce a synchronous learning strategy (SLS) to regulate iterative learning behaviour together. \subsection{Aligned Grayscale Modality Generation Module.} \subsubsection{Visible to Grayscale Image Transformation} Like the visible image, the description of grayscale image still reflects the distribution and characteristics of global and local chromaticitys of the whole image, simultaneously well approximating the style of infrared image. Therefore, when conventional appearance cues such as colors and textures get unreliable for the person matching, grayscale image is the best choice to replace visible images for feature learning. Given a visible image $x_v^i$ with three channels $\mathcal{R,G,B}$, we read the each pixel point $\mathcal{R}(x)$, $\mathcal{G}(x)$ and $\mathcal{B}(x)$ values of the visible image $x_v^i$ in turn. The corresponding grayscale pixel point $\mathcal{G}(x)$ then can be calculated as: \begin{equation} \mathcal G(x)= \alpha_1 \mathcal R(x) + \alpha_2 \mathcal G(x) + \alpha_3 \mathcal B(x), \end{equation} where $\alpha_1$, $\alpha_2$ and $\alpha_3$ are set to $0.299$, $0.587$ and $0.114$, respectively. The generated grayscale value $\mathcal G(x)$ is averagely distributed to each channels ($\mathcal{R}$, $\mathcal{G}$, $\mathcal{B}$) of the original visible image, so that all grayscale images still have three channels that can be fed into the deep model. \subsubsection{Infrared to Grayscale Image Transformation} In this section, we present the process of infrared image to grayscale image transformation, which is also called gray noramlization (GN). This is achieved by cycle-consistent adversarial networks (CycleGAN) \cite{Zhu2017}. GN can significantly address two following problems for VI-ReID task: (1) smoothing the luminance disparities of different infrared images, and (2) further alleviating the slight modality discrepancy between infrared and grayscale domains. \textbf{Formulation.} We define two sets of training images $X^g$ and $X^t$, collected from two different domains $\mathcal{A}$ (grayscale) and $\mathcal{B}$ (infrared), where $X^g \in \mathcal{A}$ and $X^t \in \mathcal{B}$. Specifically, $X^g$ contains images from the grayscale modality (denoted by $X^g = \{x_i^g\}_{i=1}^\mathcal{M}$) and $X^t$ contains images from the infrared (thermal) modality (denoted by $X^t = \{x_i^t\}_{i=1}^\mathcal{N}$). $\mathcal{M}$ and $\mathcal{N}$ represent the number of grayscale and infrared images in their training set respectively. Additionly, we also denote the sample distribution of grayscale and infrared domains as: $x^g \sim p_{data}(x^g)$ and $x^t \sim p_{data}(x^t)$. Two mapping generators are defined as: $G: \mathcal{A} \rightarrow \mathcal{B}$, $F: \mathcal{B} \rightarrow \mathcal{A}$, and two adversarial discriminators are defined as: $D_{\mathcal{A}}$, $D_{\mathcal{B}}$. Our goal is to learn a mapping function such that the generated distribution of images $G(X^t)$ is indistinguishable from the target distribution $p_{data}(x^g)$. \textbf{Adversarial Loss.} We apply adversarial losses \cite{Goodfellow2014} to both mapping functions by using the cross-reconstructed images with different modalities. In the case of grayscale modality, the discriminator $D(\mathcal{A})$ distinguishes the real image $x^g$ and the generated fake image $G(x^t)$. Similarly, in the case of infrared modality, the discriminator $D(\mathcal{B})$ distinguishes the real image $x^t$ and the generated fake image $G(x^g)$. Here, the generator $G(.)$ ($F(.)$) try to synthesize more realistic images that look similar to images from domain $\mathcal B$ ($\mathcal A$). Formally, adversarial losses involve finding a Nash equilibrium to the following two player min-max problem: \begin{equation} \begin{split} \mathcal{L}^{adv}_{x^g\rightarrow x^t} (G, D_{\mathcal{B}}) = &\mathbb E_{x^t \sim p_{data}(x^t)}[logD_{\mathcal{B}}(x^t)] \\ +&\mathbb E_{x^v \sim p_{data}(x^v)}[1-logD_{\mathcal{B}}(G(x^g))], \end{split} \end{equation} \begin{equation} \begin{split} \mathcal{L}^{adv}_{x^t\rightarrow x^g} (F, D_{\mathcal{A}}) = &\mathbb E_{x^g \sim p_{data}(x^g)}[logD_{\mathcal{A}}(x^g)] \\ +&\mathbb E_{x^t \sim p_{data}(x^t)}[1-logD_{\mathcal{A}}(G(x^t))], \end{split} \end{equation} where $x^g\rightarrow x^t$ ($x^t\rightarrow x^g$) means mapping grayscale (infrared) domain to infrared (grayscale) domain, respectively. The discriminative networks ($D_{\mathcal{A}}$ and $D_{\mathcal{B}}$) are trained in an alternating optimization alongside with the generators $G, F$. Especially, the parameters of the discriminator are updated when the parameters of the generator are fixed. \begin{figure*}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{Examples.pdf}\vspace{-0.6cm} \end{center} \caption{Contrast visualization between the raw modality images (a) and the aligned grayscale modality images (b). From left to right, the two images of a column share the same identity. It can be obviously observed that the raw visible-infrared image space suffers from both large modality and luminance gap. In contrast, our proposed AGM image space perfectly construct a modality discrepancy free space for cross-modality matching. \vspace{-0.4cm}} \label{fig:smalltarget} \end{figure*}\label{sec:introduction} \textbf{Cycle Consistency Loss.} Adversarial training strategy, in practice, forces generators $G$ and $F$ to produce outputs identically distributed as target domains $\mathcal{A}$ and $\mathcal{B}$. However, for cross-modality image-to-image translation issue, we hope transfered images only change its style to fit the target domain, while the whole semantic information is still retained throughout the conversion process. Thus, inspired by CycleGAN \cite{Zhu2017}, we apply a cycle consistency loss: \begin{equation} \begin{split} \mathcal{L}_{cyc}(G, F) = &\mathbb E_{x^g \sim p_{data}(x^g )}[||F(G(x^g) )-x^g ||_{1}] \\ + & \mathbb E_{x^t \sim p_{data}(x^t)}[||G(F(x^t))-x^t||_{1}], \end{split} \end{equation} where $F(G(x^g))$ and $G(F(x^t))$ are the cycle-reconstructed images, respectively. \textbf{Identity mapping loss.} Additionally, to encourage mapping to maintain the consistency of input and output colors, we adopt an identity regularization term to assit the generator to be near an identity mapping when using real images of the target domain as input, which is defined as: \begin{equation} \begin{split} \mathcal{L}_{identity}(G, F) = &\mathbb E_{x^t \sim p_{data}(x^t )}[||G(x^t) -x^t ||_{1}] \\ + & \mathbb E_{x^g \sim p_{data}(x^g)}[||F(x^g)-x^g||_{1}]. \end{split} \end{equation} These lead to the final objective functions: \begin{equation} \begin{split} \mathcal{L} (G,F, D_{\mathcal{A}}, D_{\mathcal{B}}) = &\mathcal{L}^{adv}_{x^g\rightarrow x^t} (G, D_{\mathcal{B}}) \\ +&\mathcal{L}^{adv}_{x^t\rightarrow x^g} (F, D_{\mathcal{A}})\\ +& \lambda_1 \mathcal{L}_{cyc}(G, F)\\ +& \lambda_2 \mathcal{L}_{identity}(G, F), \end{split} \end{equation} where $\lambda_1$ and $\lambda_2$ control the relative importance of the two objectives. In Fig. 4, we show more qualitative results of our aligned grayscale modality generation images. \subsection{Multi-Granularity Feature Extraction Module.} \subsubsection{Data Extraction of Head-shoulder Area} We directly collect person head-shoulder data cropped from benchmarks and form them into an independent training set. Specifically, assume that the size of a global training image $x$ is $\mathcal W \times \mathcal H$. We generate corresponding head-shoulder image with retaining the upper third of the original image, the size of which is $\mathcal W \times (\mathcal H/3)$. Take the upper left corner of the global image $x$ as the origin and establish a rectangular coordinate system in pixels, the coordinate of $x$ can be formulated as [0, 0, $\mathcal W$, $\mathcal H$]. Then, we directly crop image according to the coordinate of head-shoulder point [0, 0, $\mathcal W$, $\mathcal H/3$]. The above process is repeated until every global images have its corresponding head-shoulder images. \subsubsection{Network Structure} As shown in Fig. 3, our multi-granularity feature extraction framework consists of two learnable branches with independent parameters. The first branch is set as global feature extractor to encode coarser-granularity appearance information, while the second branch undertakes the work of extracting finer-granularity head-shouler features. For preciseness in presentation, we denote the global stream feature extraction network as function $\mathcal F_g(.)$ and the head-shoulder stream feature extraction network as as function $\mathcal F_h(.)$. Given a global input image $x_i^g (i\in \mathcal{N})$, the global stream feature extraction network outputs a convolutional feature map $F_i^g \in \mathbb{R}^{C\times H_1 \times W_1}$, which meets: \begin{equation} F_i^g = \mathcal F_g(x_i^g;\boldsymbol{\theta}_{\mathcal F_g}), \end{equation} where $\mathcal{N}$ is the number of global training images in a mini-batch and $\boldsymbol{\theta}_{\mathcal F_g}$ represents the parameter of the global branch $\mathcal F_g(.)$. $C, H_1$ and $W_1$ denote the channel, height and width dimension of global output feature maps. Similarly, for a head-shoulder input image $x_i^h$, the head-shoulder stream feature extraction network also outputs a corresponding convolutional feature map $F_i^h \in \mathbb{R}^{C\times H_2 \times W_2}$, \begin{equation} F_i^h = \mathcal F_h(x_i^h;\boldsymbol{\theta}_{\mathcal F_h}), \end{equation} where $\boldsymbol{\theta}_{\mathcal F_h}$ represents the parameter of the head-shoulder branch $\mathcal F_g(.)$. $C, H_2$ and $W_2$ denote the channel, height and width dimension of the head-shoulder output feature maps. Then, inspire by the work \cite{AYe2020}, generalized mean pooling layer (GeM) is employed on the top of feature extractors to acquire a compact embedding vector in the common space. The extracted embedding vectors ($\mathcal V_i^g$, $\mathcal V_i^h$) from two global and head-shoulder branches are formulated as: \begin{equation} \mathcal V_i^g = \mathrm{GeM}(F_i^g); \mathcal V_i^h = \mathrm{GeM}(F_i^h), \end{equation} where $\mathrm{GeM}(.)$ denotes the operator of the generalized mean pooling layer. Finally, we merge these embedding vectors of both the global and head-shoulder branches into a new joint branch to obtain the fused person feature, that is: \begin{equation} \mathcal V_i^{joint} = \mathcal V_i^g \oplus \mathcal V_i^h, \end{equation} where $\mathcal V_i^{joint}$ denotes the joint feature and $\oplus$ means concatenate method. Note that $\mathcal V_i^{joint}$ is used as the final representation for Person Re-ID. \subsubsection{Common Feature Space Constraints} \ \textbf{Hard Mining Triplet Loss:} The motivation of the triplet loss \cite{Schroff2015} is to optimize the distance threshold for separating positive and negative objects, making embedding vectors from same classes produce more obvious clustering results in the common feature space. Here, for three extracted embedding vectors $\mathcal V^{joint}$, $\mathcal V^{g}$, $\mathcal V^{h}$, we adopt a batch hard mining triplet loss \cite{Hermans2017} to optimize the relative distance between positive and negative pairs of themselves simultaneously. Given a mini-batch of global person embedding vectors $\{\mathcal V^g_i \}_{i=1}^{\mathcal{N}}$, we sample a feature triplet ($\mathcal V^g_a$, $\mathcal V^g_p$, $\mathcal V^g_n$) where the hardest positive point $\mathcal V^g_p$ is from the same class with the anchor point $\mathcal V^g_a$ and the hardest negative point $\mathcal V^g_n$ is from different identities with $\mathcal V^g_a$. Hard mining triplet loss forces all points belonging to the same class to form a single cluster and pushes other negative samples forward: \begin{equation} \begin{split} \mathcal{L}_{t}^{g}(\boldsymbol{\theta}_{\mathcal F_g}) &= \frac{1}{\mathcal{N}}\sum_{(a,p,n)}[\mathop{max}\limits_{\forall a=p} \mathbf{D}((\mathcal V^g_a), (\mathcal V^g_p))\\ & -\mathop{min}\limits_{\forall a\neq n} \mathbf{D}((\mathcal V^g_a), (\mathcal V^g_n))+\xi ]_+, \end{split} \end{equation} where $\mathbf{D}(.)$ represents the Euclidean Distance between two feature vectors and $[ . ]_+ = \mathbf{max}(x,0)$ represents a hinge loss. For learning multi-granularity fused features, we formulate the hard mining triplet loss for other branches as the following: \begin{equation} \begin{split} \mathcal{L}_{t}^{h}(\boldsymbol{\theta}_{\mathcal F_h}) &= \frac{1}{\mathcal{N}}\sum_{(a,p,n)}[\mathop{max}\limits_{\forall a=p} \mathbf{D}((\mathcal V^h_a), (\mathcal V^h_p))\\ & -\mathop{min}\limits_{\forall a\neq n} \mathbf{D}((\mathcal V^h_a), (\mathcal V^h_n))+\xi ]_+, \end{split} \end{equation} \begin{equation} \begin{split} \mathcal{L}_{t}^{joint}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h}) &= \frac{1}{\mathcal{N}}\sum_{(a,p,n)}[\mathop{max}\limits_{\forall a=p} \mathbf{D}((\mathcal V^{joint}_a), (\mathcal V^{joint}_p))\\ & -\mathop{min}\limits_{\forall a\neq n} \mathbf{D}((\mathcal V^{joint}_a), (\mathcal V^{joint}_n))+\xi ]_+. \end{split} \end{equation} Here, $\mathcal{L}_{t}(\boldsymbol{\theta}_{\mathcal F_g})$ and $\mathcal{L}_{t}(\boldsymbol{\theta}_{\mathcal F_h})$ aims to optimize the parameters of global and head-shoulder branches repectively. The joint triplet loss $\mathcal{L}_{t}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})$ can further fine-tune the concatenated features for both global and head-shoulder branches. \textbf{Identity Loss:} The identity loss $\mathcal{L}_{id}$ is a softmax function based cross entropy loss widely used in classification tasks. It utilizes cosine distance to separate the embeded space into different subspaces for optimizing person identity discrimination. Formally, we predict the posterior probability $p(y_i|x^g_i)$ of the global training image $\{x^g_i\}_{i=1}^{\mathcal{N}} $ over the given identity label $y_i$: \begin{equation} p({y_{i}|x_i^g})=\frac{exp(W^T_{y_{i}}\times \mathcal V_i^g)}{\sum_{k=1}^{\mathcal{N}}exp(W^T_{k}\times \mathcal V_i^g)}, k = 1, 2, ..., \mathcal{N}, \end{equation} where $\mathcal V_i^g$ refers to the embedding feature vector of $x_i^g$ from the global branch. $W_k$ is the weight parameter matrix of the last fully connected layer for $k$ th identity. The global branch model identity training loss is computed as: \begin{equation} \mathcal{L}^g_{id}(\boldsymbol{\theta}_{\mathcal F_g})=-\frac{1}{\mathcal N}\sum_{i=1}^{\mathcal N}log(p({y_{i}|x_{i}^g})). \end{equation} Then the head-shoulder and joint branches identity training loss can be calculated as: \begin{equation} \mathcal{L}^h_{id}(\boldsymbol{\theta}_{\mathcal F_h})=-\frac{1}{\mathcal N}\sum_{i=1}^{\mathcal N}log(p({y_{i}|x_{i}^h})), \end{equation} \begin{equation} \mathcal{L}^{joint}_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})=-\frac{1}{\mathcal N}\sum_{i=1}^{\mathcal N}log(p({y_{i}|x_{i}^g \oplus x_{i}^h})), \end{equation} where $\mathcal{L}^{joint}_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})$ optimizes the joint feature $\mathcal{V}^{joint}_i$ for supervising both global and head-shoulder branches. Specifically, the $p({y_{i}|x_{i}^g \oplus x_{i}^h})$ is denoted as: \begin{equation} p({y_{i}|x_{i}^g \oplus x_{i}^h})=\frac{exp(W^T_{y_{i}}\times (\mathcal V_{i}^g \oplus \mathcal V_{i}^h))}{\sum_{k=1}^{\mathcal{N}}exp(W^T_{k}\times (\mathcal V_{i}^g \oplus \mathcal V_{i}^h))}. \end{equation} \textbf{Label Smoothing Regularization:} For the joint embedding vectors $\mathcal V^{joint}$ directly concatenated by $\mathcal V^{g}$ and $\mathcal V^{h}$, their the information distribution are generally inconsistent in the feature space. It leads to an increase in the prediction probability of wrong labels. Conventional cross-entropy loss with one-shot hard label only pay attention to how to produce a higher probability to predict the correct label, rather than reducing the probability of predicting the wrong label. In this work, we employ the label smoothing regularization (LSR) strategy for $\mathcal V^{joint}$ to alleviate this problem. Given a global image $x_i^g$ and its corresponding head-shoulder image $x_i^h$, we denote $y$ as their shared truth identity label. The re-assignment of the label distribution of each joint embedding vector is written as: \begin{equation} \label{eq6} q_{i}=\left\{ \begin{aligned} &1-\epsilon+\dfrac{\epsilon}{C} & (y=i), \\ &\dfrac{\epsilon}{C} & (y\neq i), \end{aligned} \right. \end{equation} where $C$ indicates the number of all identity in the training set. $\epsilon$ is the weight parameter to balance the original ground-truth distribution $p({y_{i}|x_{i}^g \oplus x_{i}^h})$ and adaptive label smoothing distribution $q_{i}$. In this work, $\epsilon$ is set to 0.1. Then, the cross-entropy loss in Eq. (17) can be re-defined as, \begin{equation} \mathcal{ L}^{joint}_{lsr}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})=-\frac{1}{\mathcal N}\sum_{i=1}^{\mathcal N}q_{i}log(p({y_{i}|x_{i}^g \oplus x_{i}^h})). \end{equation} By summing the identity loss and label smoothing regularization term mentioned above, we come up with the final hybrid loss function for supervising the joint branch: \begin{equation} \mathcal{\tilde L}^{joint}_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h}) = \mathcal{ L}^{joint}_{id} + \omega \mathcal{ L}^{joint}_{lsr}, \end{equation} where $\omega$ is a weight coefficient to control the contirbution of label smoothing regularization term. \subsection{Multi-Branch Synchronous Learning Module.} \subsubsection{Multi-Branch Synchronous Learning} We perform multi-branch synchronous learning on person identity classes from global and head-shoulder specific branches. For one global image $x^g$ and its corresponding head-shoulder image $x^h$, we first feed them into the multi-granularity feature extraction module to obtain the highest convolutional feature maps $\mathcal V^g$ ($2048\times n$), $\mathcal V^h$ ($2048\times n$) repectively, where $n$ means the mini-batch size. Then, we perform the feature fusion by an operation of concatenation, that is, the dimension of the joint feature $\mathcal V^{joint}$ is $4096\times n$. Notice that different feature embedding vectors $\mathcal V^g$, $\mathcal V^h$ and $\mathcal V^{joint}$ have different information distributions, we employ three independent batch hard mining triplet losses $\mathcal L^{g}_t$ (Eq. (10)), $\mathcal L^{h}_t$ (Eq. (11)), $\mathcal L^{joint}_t$ (Eq. (12)) for synchronous metric learning. Besides, we also deploy an identity classification layer (i.e. \textit{synchronous learning layer}) for the joint feature to conduct synchronous classification learning. The training of each branch is supervised by the same identity class label constraint $\mathcal L_{id}^g$ (Eq. (15)), $\mathcal L_{id}^h$ (Eq. (16)) and $\mathcal L_{id}^{joint}$ (Eq. (17)) concurrently. \subsubsection{Feature Regularisation by Synchronous Propagation} We propose to regularize the branch-specific and therefore indirectly radiate to the entire feature learning process with multi-granularity person identity synchronization in a closed-loop. Specifically, we propagate the fused knowledge as extra feedback information to regularise the batch learning of all branch-specific branches concurrently. Formally, as shown in Fig. 3, we utilize the fused knowledge probability $\tilde{\mathcal P}$ as the synchronous propagation signal (called as ``soft target" ) to guide the learning process of both global and head-shoulder branches, where $\tilde{\mathcal P}$ is the posterior probability of the joint feature, that is: \begin{equation} \tilde{\mathcal P} = p({y_{i}|x_{i}^g \oplus x_{i}^h}). \end{equation} Then, we enforce an additional regularisation in Eq. (15) and Eq. (16), repectively: \begin{equation} \mathcal{ L}^g_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})=\mathcal{L}^g_{id}(\boldsymbol{\theta}_{\mathcal F_g}) + \lambda_3 \mathcal Z ( \mathcal {\tilde P},\mathcal P_g \end{equation} \begin{equation} \mathcal{\tilde L}^h_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})=\mathcal{L}^h_{id}(\boldsymbol{\theta}_{\mathcal F_h}) + \lambda_4 \mathcal Z ( \mathcal {\tilde P},\mathcal P_h ), \end{equation} where $\mathcal P_g = p({y_{i}|x_i^g})$, $\mathcal P_h = p({y_{i}|x_i^h})$. $\lambda_3$ and $\lambda_4$ are the predefined tradeoff coefficients for balancing the contributions between the two terms. $\mathcal{Z}(.)$ denotes the synchronous regularisation term which aims to calculate the Kullback-Leibler divergence between two distributions ($\mathcal {\tilde P},\mathcal P_g$), ($\mathcal {\tilde P},\mathcal P_h$): \begin{equation} \mathcal{Z}(\mathcal {\tilde P},\mathcal P_g) = \frac{1}{\mathcal N}\sum_{i=1}^{\mathcal N}(\tilde p_iln(\tilde p_i)- \tilde p_iln(p_i^g)), \end{equation} \begin{equation} \mathcal{Z}(\mathcal {\tilde P},\mathcal P_h) = \frac{1}{\mathcal N}\sum_{i=1}^{\mathcal N}(\tilde p_iln(\tilde p_i)- \tilde p_iln(p_i^h)). \end{equation} \begin{algorithm}[t] \caption{\textbf{:} Multi-Granularity Feature Learning} \hspace*{0.02in} {\bf Input:} Input AGM global images $X^g=\{x_i^g\}_{i=1}^{\mathcal N}$; \\ \hspace*{0.46in}Corresponding labels $Y=\{y_i\}_{i=1}^{\mathcal N}$;\\ \hspace*{0.46in}Training iterations $\mathcal{I}$; learning rate $r$; batch size $\mathcal N$.\\ \hspace*{0.02in} {\bf Initialisation:} Initialized network parameters $\boldsymbol{\theta}_{\mathcal F_g}'$ and $\boldsymbol{\theta}_{\mathcal F_h}'$; \\ \hspace*{0.02in} {\bf Output:} Network parameters $\boldsymbol{\theta}_{\mathcal F_g}$ and $\boldsymbol{\theta}_{\mathcal F_h}$. \begin{algorithmic}[1] \State \textbf{for} iteration i in $\mathcal I$; \\ \hspace*{0.20in}Get head-shoulder training samples: $X^h=\{x_i^h\}_{i=1}^{\mathcal N}$;\\ \hspace*{0.20in}Feedforward global and head-shoulder image inputs (Eq. (\textcolor{red}{7}), Eq. (\textcolor{red}{8}) and Eq. (\textcolor{red}{9}));\\ \hspace*{0.20in}Multi-granularity feature fusion (Eq. (\textcolor{red}{10}));\\ \hspace*{0.20in}Update global network parameters $\boldsymbol{\theta}_{\mathcal F_g}$ : $\boldsymbol{\theta}_{\mathcal F_g} \gets \boldsymbol{\theta}_{\mathcal F_g} - r*\nabla( \mathcal{L}_{t}^g(\boldsymbol{\theta}_{\mathcal F_g}))$ \\ \hspace*{0.20in}Update head-shoulder network parameters $\boldsymbol{\theta}_{\mathcal F_h}$: $\boldsymbol{\theta}_{\mathcal F_h} \gets \boldsymbol{\theta}_{\mathcal F_h} - r*\nabla( \mathcal{L}_{t}^g(\boldsymbol{\theta}_{\mathcal F_h}))$ \\ \hspace*{0.20in}Update joint network parameters $\boldsymbol{\theta}_{\mathcal F_g}$ and $\boldsymbol{\theta}_{\mathcal F_h}$: $(\boldsymbol{\theta}_{\mathcal F_g},\boldsymbol{\theta}_{\mathcal F_h}) \gets (\boldsymbol{\theta}_{\mathcal F_g},\boldsymbol{\theta}_{\mathcal F_h}) - r*\nabla(\mathcal{\tilde L}^{joint}_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})$ $+\mathcal{\tilde L}^g_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})+ \mathcal{\tilde L}^h_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})+\mathcal{L}_{t}^{joint}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h}))$ \State \textbf{end} \State \textbf{return} Network parameters $\boldsymbol{\theta}_{\mathcal F_g}$ and $\boldsymbol{\theta}_{\mathcal F_h}$. \end{algorithmic} \end{algorithm} \textbf{Overall Loss Function:} Combining these individual losses, we finally define the total loss for the overall network as follows: \begin{equation} \begin{split} \mathcal{L}_{total} = &\mathcal{\tilde L}^g_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})+ \mathcal{\tilde L}^h_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})+\mathcal{\tilde L}^{joint}_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h}) \\ +&\mathcal{L}_{t}^g(\boldsymbol{\theta}_{\mathcal F_g}) + \mathcal{L}_{t}^h(\boldsymbol{\theta}_{\mathcal F_h})+ \mathcal{L}_{t}^{joint}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h}). \end{split} \end{equation} To this end, we introduce a framework for visible-infrared person Re-ID, in which $\mathcal{\tilde L}^g_{id}(\boldsymbol{\theta}_{\mathcal F_g}$, $\boldsymbol{\theta}_{\mathcal F_h})$ and $ \mathcal{\tilde L}^h_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})$ aim to propagate the learned fused knowledge back to individual specific branches to regulate their mini-batch iterative learning behaviour together. Meanwhile, hard mining triplet loss $\mathcal{L}_{t}^g(\boldsymbol{\theta}_{\mathcal F_g})$, $\mathcal{L}_{t}^h(\boldsymbol{\theta}_{\mathcal F_h})$ and $\mathcal{L}_{t}^{joint}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})$ attempt to enhance the discriminability of learned features. Note that $\mathcal{\tilde L}^{joint}_{id}(\boldsymbol{\theta}_{\mathcal F_g}, \boldsymbol{\theta}_{\mathcal F_h})$ is calculated by both ``soft target" and groundtruth one-hot ``hard target" and is used to update the whole network parameter. The overall algorithm of training the proposed model is presented in Algorithm 1. \section{Experiments} In this section, we present a detailed analysis and measure our method against other VI-ReID approaches on two available public datasets (SYSU-MM01 and RegDB). \subsection{Datasets and Evaluation Metric} \textbf{Datasets.} \textbf{SYSU-MM01} \cite{Wu2017} is a challenging large-scale cross-modality dataset collected at Sun Yat-sen university. It contains images captured by six cameras (two near-infrared and four visible sensors), including both indoor and outdoor environments. Statistically, SYSU-MM01 dataset contains a total of 30,071 visible images and 15,792 thermal images of 491 person identities, where each identity is captured by at least two modality cameras. Follow the \cite{Wu2017}, we conduct our experiment on two different evaluation modes, \textit{i.e.}, all search and indoor-search mode. For all-search mode, 3,803 thermal images from cameras 3 and 6 are used for query, and 301 visible images are randomly selected from cameras 1, 2, 4, and 5 are formulated as gallery set. For indoor-search, only the images captured by two indoor cameras are used. \textbf{RegDB} \cite{Nguyen2017} is collected by a pair of aligned far-infrared and visible camera systems. It is composed of 8,240 images of 412 identities, with 206 identities for training and the rest for testing. For each identity, 10 images are captured by the visible camera, and 10 images are obtained by the thermal camera. We following a previously developed evaluation protocol \cite{Liu2021} that randomly splits the dataset into two halves and alternatively uses all visible/thermal images as the gallery set. \textbf{Evaluation Metric.} To evaluate the cross-modality Re-ID system performance, we adopt the widely used Cumulated Matching Characteristics (CMC) curve and mean Average Precision (mAP) for performance evaluation. In addition, we also introduce mean inverse negative penalty (mINP) metric in this work to measure the retrieval performance. Specifically, CMC (rank-k matching accuracy) measures the probability that a query object appears in the target lists (top-k retrieved results). mAP measures the retrieval performance via calculating average of the maximum recalls for each class in multiple types of tests. Finally, mINP evaluates the ability of Re-ID system to retrieve the hardest correct match, providing a strong supplement for CMC and mAP. \begin{table*} \setlength{\abovecaptionskip}{-0.2cm} \setlength{\belowcaptionskip}{0.5cm} \caption{Ablation study of each component with four different types of training/testing sets on the large-scale SYSU-MM01 dataset. `RGB-IR' means the RGB to infrared modality dataset, `RGB-IR+GN' means the RGB to grayscale modality dataset, `Gray-IR' means the grayscale to infrared modality dataset and `Gray-IR+GN' means the grayscale to grayscale modality dataset. In addition, `HS' denotes using head-shoulder information to assit feature learning and `SLS' denotes the synchronous learning strategy. GeM pooling method is used in this experiment. } \label{tab:1} \begin{center} \renewcommand{\arraystretch}{1.07} \begin{tabular}{l|ccccc|ccccc} \toprule Modes & \multicolumn{5}{c}{All Search} & \multicolumn{5}{c}{Indoor Search} \\ \hline Method &Rank-1 &Rank-10 &Rank-20 &mAP &mINP &Rank-1 &Rank-10 &Rank-20 &mAP &mINP \\ \hline RGB-IR (Baseline-A) &60.35 &91.19 &95.98 &56.31 &43.70 &65.81 &95.83 &99.50 &71.65 &67.32 \\ RGB-IR+HS &\textbf{63.79} &90.93 &95.95 &61.38 &47.93 &\textbf{68.43} &95.88 &99.50 &\textbf{73.41} &\textbf{69.07} \\ RGB-IR+HS+SLS &63.48 &\textbf{92.90} &\textbf{97.82} &\textbf{62.34} &\textbf{48.96} &67.62 &\textbf{96.11} &\textbf{99.55} &72.80 &68.24 \\ \hline RGB-IR+GN &61.35 &91.24 &96.24 &59.72 &46.99 &66.08 &95.15 &99.23 &71.10 &67.73 \\ RGB-IR+GN+HS &64.66 &93.14 &\textbf{97.69} &62.45 &49.28 &68.54 &96.42 &\textbf{99.64} &74.02 &69.65 \\ RGB-IR+GN+HS+SLS &\textbf{65.42} &\textbf{93.64} &97.55 &\textbf{62.82} &\textbf{49.81} &\textbf{69.44} &\textbf{96.97} &99.46 &\textbf{75.73} &\textbf{69.77} \\ \hline \hline Gray-IR (Baseline-B) &63.35 &\textbf{92.77} &97.13 &58.59 &44.49 &69.34 &\textbf{97.51} &\textbf{99.50} &74.51 &70.12 \\ Gray-IR+HS &63.24 &91.77 &\textbf{97.29} &61.27 & \textbf{49.66} &70.83 &96.69 &98.73 &75.28 &70.78 \\ Gray-IR+HS+SLS &\textbf{64.03} &91.98 &96.16 &\textbf{61.55} &48.99 &\textbf{73.91} &96.92 &99.18 &\textbf{77.47} &\textbf{72.87}\\ \hline Gray-IR+GN (AGM) &65.58 &95.42 &98.82 &62.12 &47.74 &69.38 &95.06 &97.46 &73.32 &68.04 \\ Gray-IR+GN+HS &67.13 &95.61 &98.55 &64.11 &50.49 &73.87 &96.92 &99.09 &77.25 &72.74 \\ Gray-IR+GN+HS+SLS &\textbf{69.63} &\textbf{96.27} &\textbf{98.82} &\textbf{66.11} &\textbf{52.24} &\textbf{74.68} &\textbf{97.51} &\textbf{99.14} &\textbf{78.30} &\textbf{74.00} \\ \bottomrule \end{tabular} \end{center} \end{table*} \subsection{Implementation Details} The proposed method is implemented in PyTorch and trained on two 24GB NVIDIA TITAN RTX GPU for acceleration. Before the training stage, all global input images are first resized to 288 $\times$ 144 and corresponding head-shoulder images are resized to 128$\times$144 to obtain sufficient context information from person images. Then we augment training samples with two data augmentation approaches, \textit{i.e.}, Random Cropping and Random Erasing. The total number of training epochs is 80, and the batch size is set to 64. We start training with learning rate 0.01 and linearly increase to 0.1 in the first 10 epochs, then we keep the same value setting until reaching to 20 epochs. In the following 60 epochs, learning rate is set to 0.01 for the first 30 epochs and 0.001 for another 30 epochs. We adopt the SGD optimizer with a weight decay of 5$\times$$10^{-4}$ and a momentum of $0.9$ to update the parameters of the network. The hype-parameters $\lambda_1$ and $\lambda_2$ are set to 10 and 5, repectively. We set the margin parameter $\xi$ to 0.3 in Eq. (11), Eq. (12) and Eq. (13) for the batch hard triplet loss. The dimensions of the last classification layer are 395 for SYSU-MM01 and 206 for RegDB. \subsection{Ablation Study} \begin{table}[t] \centering \setlength{\abovecaptionskip}{0cm} \setlength{\belowcaptionskip}{0.5cm} \caption{Comparison of components over baseline model (Baseline-A) using GeM pooling. Rank-1 (\%), mAP (\%) and mINP (\%) are reported.} \label{Tab03} \renewcommand{\arraystretch}{1} \begin{tabular}{ccccc|ccc} \toprule \multirow{2}*{Base} &\multirow{2}*{Gray} &\multirow{2}*{GN} &\multirow{2}*{HS} &\multirow{2}*{SLS} & \multicolumn{3}{c}{All search} \\ \cmidrule(r){6-8} & & & & &Rank-1 &mAP &mINP \\ \hline \checkmark &-- &-- &--&--&60.35 &56.31 &43.70 \\ \checkmark &\checkmark& -- &--&--&63.35 &58.59 &44.49 \\ \checkmark &\checkmark&\checkmark &--&--&65.58 &62.12 &47.74\\ \checkmark &\checkmark& \checkmark &\checkmark&--&67.13 &64.11 &50.49\\ \checkmark &\checkmark &\checkmark&\checkmark& \checkmark &69.63 &66.11 &52.24 \\ \bottomrule \end{tabular} \end{table} In this section, we investigate the effectiveness of each component in our proposed framework by conducting a series of experiments on the challenging SYSU-MM01 dataset under both all search and indoor search modes. \subsubsection{Effectiveness of the Aligned Grayscale Modality} We first study the effectiveness of our proposed aligned grayscale modality strategy (denoted by `AGM' in TABLE 1 and `Base+Gray+GN' in TABLE 2). In TABLE 1, we utilize the base model w/wo AGM module (Basline-A and AGM) as the baseline for evaluating other components to see how their performance would change. All other settings between the Basline-A and AGM including the network architecture are consistent. Comparing results in row 3 and row 12, we can see that the rank-1, mAP and mINP accuracy of AGM go beyond the `Baseline-A' by 5.23\%, 5.81\% and 4.04\% under the all-search mode. This indicates that eliminating modality discrepancy is critical to boost VI-ReID performance. Then, we add other modules proposed in this work on the top of `Baseline-A' and `AGM', repectively. As expected from the reported results in rows 12-14, our AGM based model also shows very competitive performance improvement against the general RGB-infrared based model (rows 3, 4 and 5), where the improvement of rank-1 accuracy from 65.58\% to 69.63\% on `AGM' versus 60.35\% to 63.48\% on `Basline-A'. \begin{table}[t] \centering \setlength{\abovecaptionskip}{0cm} \caption{Comparison (\%) to related cross-modality image-level Re-ID methods under the same training/tesing setting. Global average pooling is used. } \label{Tab03} \renewcommand{\arraystretch}{1.07} \begin{tabular}{l|ccccc} \toprule & \multicolumn{5}{c}{SYSU-MM01(All-search)} \\ \hline {Methods} & Rank-1 & Rank-10 & Rank-20 & mAP & mINP \\ \hline CoSiGAN \cite{Zhong2020} & 35.55 & 81.54 & 90.43 & 38.33 & -- \\ AlignGAN \cite{Wang2019} & 42.40 &85.00 &93.70 & 40.70 &-- \\ D$^2$RL\cite{Wang2019a} & 28.90 & 70.60 & 82.40 & 29.20 & -- \\ \hline G-modal\cite{Ye2020a} & 47.80 & 86.56 & 94.12 & 45.99 & -- \\ X-modal\cite{Li2020} & 49.92 & 89.79 & 95.96 & 50.73 & -- \\ S-modal\cite{Wei2021} & 59.97 & -- & -- & 56.01 & -- \\ \hline AGM (Ours) & 62.35 & 92.77 & 97.13 & 58.59 & 44.49 \\ \bottomrule \end{tabular} \end{table} In addition, note that AGM reformulates visible-infrared dual-mode learning as the gray-gray single-modality learning paradigm, that falls into the same category with image generation-based methods. Therefore, to validate the superiority of our proposed AGM, we further report comparison results with other classic image-level methods in TABLE 3. Here, we only use global branch to extract person features and supervise the model with standard softmax and triplet losses for the fairness of comparison. From the TABLE 3, we have following observation. (1) \textit{vs modality transfered methods (rows 3-5):} AGM obtains siginificantly competitive results, of which both rank-1 accuracy and mAP value have increased by more than 20.17\%. This indicates using GAN technique to generate modality consistent images (\textit{i.e.} RGB to infrared or infrared to RGB) does significantly harm the performance and demonstrates the necessity of preserving image structure information when performing cross-modality transformation. (2) \textit{vs modality assisted methods (rows 6-8):} Specifically, `G-modal' (row 6) means using grayscale modality to assist the visible-infrared cross-modality feature learning. Similarly, `X-modal' (row 7) and `S-modal' (row 8) denotes using x modality and syncretic modality repectively. As shown in TABLE 3, introducing different auxiliary modalities obviously improve the performance of the model, especially the syncretic modality. However, training new modality images requires extra computation cost, and original modality discrepancy still remains unsolved. In contrast, AGM integrates two heterogeneous modalities into single unified modality for feature learning, effectively alleviating the modality discrepancy and improving the retrieval performance. \begin{figure}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{HS.pdf}\vspace{-0.6cm} \end{center} \caption{Performance evaluation for joint branch on SYSU-MM01 dataset using different classification losses. $\mathcal{ L}_{id}$ means cross-entropy and $\mathcal{ L}_{lsr}$ denotes label smoothing regularization. \vspace{-0.4cm}} \label{fig:smalltarget} \end{figure}\label{sec:introduction} \subsubsection{Effectiveness of the Grayscale Normalization} We evaluate how much improvement can be made by Grayscale Normalization (GN) with baseline learning objective. We first test GN under grayscale-infrared training set. From the second and third rows of TABLE 2, GN brings 2.23\% Rank-1, 3.53\% mAP and 3.25\% mINP increases in all search mode compared with the model without GN (row 2). Similar performance improvement (from 66.20\% to 69.38\%) can be observed under \textit{indoor search} mode in TABLE 1 (row 11 and 14). Then, we further test GN on the conventional RGB-infrared training set. To be fair, all settings including the network architecture are the same as grayscale-infrared training set. As shown by the results (row 3 and 6 in TABLE 1), its CMC top-1, mAP and mINP accuracy increase 1.00\%, 3.41\% and 3.29\% compared with the baseline model, which demonstrates that conducting grayscale normalization operation on infrared images helps align cross-modality feature maps to enhance the performance. Note that applying GN can significantly improve mAP and mINP metrics against CMC accuracy, this is because GN normalizes raw infrared images (with severe luminance gap) into unified grayscale images so as to improve the recognition rate of the overall classes. \begin{figure*}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{lamda.pdf}\vspace{-0.6cm} \end{center} \caption{The effect of parameter $\lambda_3$ and $\lambda_4$ on SYSU-MM01 dataset under the all-search mode. Here, $\omega$ is fixed to 1.0 for evaluation. `Baseline rank-1' and `Baseline mAP' means the rank-1 accuracy and mAP value without using synchronous learning strategy ($\lambda_3 = \lambda_4 =0.0$). \vspace{-0.4cm}} \label{fig:smalltarget} \end{figure*}\label{sec:introduction} \subsubsection{Effectiveness of the Head-shoulder Information} This work introduces additional head-shoulder information to assist to learn discriminative feature representations, that provides a feasible research idea for future person Re-ID task. Here we conduct qualitative experiments to investigate the contribution of head-shoulder part to performance improvement. As shown in TABLE 1, we evaluate head-shoulder module (denoted by `HS') on four different types of testing sets, \textit{i.e.}, RGB-Infrared set (RGB-IR), RGB-Gray set (RGB+GN), Gray-Infrared set (Gray-IR) and Gray-Gray set (Gray+IR). Note that when we applying head-shoulder information to assit model learning, all performance indexes (CMC curve, mAP and mINP) float with varying degrees of improvement. Especially, The rise of mAP and mINP value (3.0\% $\sim$ 5.0\%) is particularly obvious than rank-1 accuracy (- 0.1\% $\sim$ 2.0\%) on four testing sets. This demonstrates that introducing local prior knowledge \textit{(i.e.} face characteristics or head-shoulder information) is profitable to enhance the discriminative and robust power of learned feature representations. We also provide the comparision result when regularizing the joint branch feature using a standard one-hot cross-entropy loss, together with a label smoothing regularization. As shown in Fig. 5, using cross-entropy alone (w/$\mathcal{ L}_{id}$) improves the rank-1 accuracy from 63.48\% to 65.97\% (\textcolor{red}{$\uparrow$}2.49\%). However, replacing cross-entropy with the label smoothing regularization (w/$\mathcal{ L}_{lsr}$), the rank-1 accuracy decreases from 65.97\% to 64.90\% (\textcolor{red}{$\downarrow$}1.07\%). This suggests that using label smoothing regularization alone does not help much, but even decrease the performance. When we concurrently use cross-entropy and label smoothing regularization (w/($\mathcal{ L}_{id}$+$\mathcal{ L}_{lsr}$)), the rank-1 accuracy increases sharply from 63.48\% to 69.63\% (\textcolor{red}{$\uparrow$}6.25\%). Therefore, the fact that applying the label smoothing regularization improves over the baseline is not attributed to label smoothing alone, but to the interaction between the cross-entropy (``hard target") and label smoothing (``soft target"). By this experiment, we justify the necessity of using label smoothing regularization to optimize the concatenate joint feature. \begin{table}[t] \centering \setlength{\abovecaptionskip}{0cm} \caption{The results of different synchronous learning losses on the SYSU-MM01 dataset. `None' means not using the synchronous learning strategy. `Specific-to-Joint' indicates the knowledge transfer from the specific branch to the joint branch. `Joint-to-Specific' indicates the knowledge transfer from the joint branch to the specific branch.} \label{Tab03} \renewcommand{\arraystretch}{1.07} \begin{tabular}{l|ccc|ccc} \toprule & \multicolumn{3}{c}{All search} & \multicolumn{3}{c}{Indoor search} \\ \hline {Settings} & R-1 & mAP & mINP & R-1 & mAP & mINP \\ \hline None & 67.13 &64.11 & 50.49 &69.75 &75.69 & 71.95 \\ Specific-to-Joint & 63.61 &61.11 & 47.33 &66.12 &71.21 &65.99 \\ Joint-to-Specific &69.63 &66.11 & 52.24 &74.68 &78.30 & 74.00 \\ Mutual &66.87 &63.11 & 48.86 &68.89 &72.75 &67.59 \\ \bottomrule \end{tabular} \end{table} \subsubsection{Effectiveness of the Synchronous Learning Strategy} In the synchronous learning process (Subection 3.3), the global and head-shoulder information are concatenated into the high-dimensional fusion features to calculate the person class probability. Meanwhile, the calculated probability is utilized as the teacher signal to guide the learning process of specific branches. To evaluate the effectiveness and necessity of the synchronous learning strategy (SLS), we first design control groups under four types of testbed with or without `SLS'. As shown in TABLE 1, `SLS' brings 0.42\% $\sim$ 1.47\% performance improvement of mAP and mINP metrics, but some fluctuations using rank-1 index (-0.31\% $\sim$ 2.50\%). This indicates SLS can siginificantly improve the system's ability of retrieving all the relevant images. It is noteworthy that when performing SLS in the Gray-IR+GN (AGM) set (rows 13-14), all performance evaluation indexes (CMC, mAP and mINP) perform the best. This suggests that AGM is indeed beneficial for learning discriminative features. Second, we also provide the result when using different knowledge transfer objectives to evaluate the synchronous learning process. From the reported results in TABLE 4, we can observe that only `Joint-to-Specific' setting outperforms the baseline (`None'), of which the rank-1 accuracy increases from 67.13\% to 69.63\%, the mAP value raises from 64.11\% to 66.11\% and mINP raises from 50.49\% to 52.24\%. However, using the other two settings (`Specific-to-Joint' and `mutual') do not help much, or even contribute to severe performance degradation on full-camera systems. For instance, the rank-1 accuracy drops from 67.13\% to 63.61\% when using `Specific-to-Joint' setting for synchronous learning process. This is because the gobal and head-shoulder branches are conducted as an asynchronous learning scheme with a fame. If we treat specific branches as the target distribution, such the learned asynchronous knowledge will propagate to the joint branch, thereby destroying the performance. \subsection{Parameter Analysis} We analyze some important parameters of LSR and SLS introduced in Section 3.2.3 and Section 3.3.2. Once validated, the same parameters are fixed for other experiments. \textbf{Label Smoothing Regularization Analysis.} To evaluate the label smoothing regularization parameter $\omega$, we first fix $\lambda_3$ and $\lambda_4$ to 1.0 and adjust $\omega \in [0,1]$. The results are listed in TABLE 5. From the table, we can observe that \textit{1) In SYSU-MM01 dataset}, both mAP and mINP performance rise with increasing of $\omega$ and achieve the highest performance at 1.0. This indicates the ``soft targets" and ``hard targets" should contribute equally to the learning process of the joint branch. 2) \textit{In RegDB dataset}, both rank-1, mAP performance first show an upward trend and achieve peak performance at 0.7. After that, mINP performance drops drastically while rank-1 and mAP performance show a downward trend with small fluctuations. This indicates the RegDB dataset is more sensitive to parameter $\omega$ the SYSU-MM01 dataset. From the above analysis, it is supposed to set $\omega=1.0$ for SYSU-MM01 dataset and $\omega=0.7$ for RegDB dataset. \textbf{Synchronous Learning Strategy Analysis.} Two weighting parameters, $\lambda_3$ and $\lambda_4$, are involved in our synchronous learning module. Note that we fix one parameter value and change the other parameter in a value range for evaluation. Specifically, when evluating the parameter $\lambda_3$, we first assign a fixed value to $\lambda_4$ and then adjust $\lambda_3 \in [0,2]$ to observe performance changes. Experimental results on SYSU-MM01 dataset are presented in Fig. 6. From these results, we have several observations as follows. First, different weighting parameters contirbute to different effects on model training. In Fig. 6 (a) and Fig. 6 (b), as the parameter value changes, the performance curve of $\lambda_4$ fluctuates drastically, while the performance curve of $\lambda_3$ remains relatively stable. This demonstates that our model is more sensitive to $\lambda_4$ than $\lambda_3$. Therefore, how to balance the contribution of the introduced head-shoulder information is very important for model synchronous learning. Second, our model favors a relatively small value for $\lambda_3$ and a large value for $\lambda_4$. From Fig. 6 (a), we can find that both rank-1 and mAP performance upgrade with increasing of $\lambda_3$ and achieve peak values at 1.0. After that, they show a downward trend. And, in Fig. 6 (b), $\lambda_4$ varies in a similar way with $\lambda_3$, but occuring some fluctuation in value range [0.5, 0.9]. In addition, $\lambda_4$ meets two peak point at 1.2 and 1.5, repectively. Though when $\lambda_4 =1.2$, the rank-1 accuracy is the highest, its mAP value is lower than $\lambda_4 =1.5$ (65.14\% versus 66.11\%). mAP provides a comprehensive assessment of a system's ability, thus we choose the larger value: $\lambda_4=1.5$ for the experiment. Based on the above analysis, the final value of weighting parameters are setted as: $\lambda_3=1.0$ and $\lambda_4=1.5$. \begin{table}[t] \centering \setlength{\abovecaptionskip}{0cm} \caption{ The effect of parameter $\omega$ on SYSU-MM01 and RegDB datasets. $\lambda_3$ and $\lambda_4$ are initialized to 1.0 in this experiment. Note that $\omega$ is used to balance the contributions between hard target cross-entropy loss and soft target label smoothing loss. Rank-1, mAP and mINP (\%) are reported.} \label{Tab03} \renewcommand{\arraystretch}{1.07} \begin{tabular}{c|c|ccc|ccc} \toprule &&\multicolumn{3}{c}{SYSU-MM01} &\multicolumn{3}{c}{RegDB} \\ \hline Loss &$\omega$ & R-1 & mAP & mINP & R-1 & mAP & mINP \\ \hline \multirow{6}*{$\mathcal{\tilde L}^{joint}_{id}$} &0.1 & 65.90 &64.46 &50.01 & 85.44 &80.26 & 69.29 \\ &0.3 & 66.37 &63.38 & 49.30 &85.87 &80.80 & 69.04 \\ &0.5 &\textbf{68.96} &64.97 &50.71 & 86.60 &79.92 & 67.54 \\ &0.7 & 67.26 &64.52 &51.09 & \textbf{87.09} &\textbf{81.24} & \textbf{69.76} \\ &0.9 & 68.68 &65.87 &51.77 & 85.34 &78.14 & 63.68 \\ &1.0 & 68.75 & \textbf{66.01} & \textbf{52.01} & 85.78 &79.05 & 65.27 \\ \bottomrule \end{tabular} \end{table} \begin{table*}[t] \setlength{\abovecaptionskip}{-0.2cm} \caption{Comparison with the state-of-the-art methods under all-search and indoor-search modes on SYSU-MM01 dataset.} \label{tab:1} \begin{center} \renewcommand{\arraystretch}{1.10} \begin{tabular}{l|c|ccccc||cccccc} \toprule & & \multicolumn{5}{c}{All-search} & \multicolumn{5}{c}{Indoor-Search} \\ \hline Method & Venue & Rank-1 & Rank-10 & Rank-20 & mAP & mINP & Rank-1 & Rank-10 & Rank-20 & mAP & mINP \\ \hline Two-Stream \cite{Wu2017}&ICCV2017 & 11.65& 47.99 & 65.50 & 12.85 &- & 15.60& 61.18 & 81.02 & 21.49 &-\\ One-Stream \cite{Wu2017}&ICCV2017 & 12.04& 49.68 & 66.74 & 13.67 &- &16.94&63.55&82.10&22.95 &- \\ Zero-Pad \cite{Wu2017} &ICCV2017 &14.80&54.12&71.33&15.95 &- & 20.58& 68.38 & 85.79 & 26.92 &- \\ cmGAN \cite{Dai2018} &IJCAI2018 & 26.97& 67.51 & 80.56 & 31.49 &- & 31.63& 77.23 & 89.18 & 42.19 &- \\ eDBTR \cite{Ye2019} &TIFS2020 & 27.82& 67.34 & 81.34 & 28.42 &- & 32.46& 77.42 & 89.62 & 42.46 &- \\ D$^{2}$RL \cite{Wang2019a} &CVPR2019 & 28.90& 70.60 & 82.40 & 29.20 &- & -& - & - & - &- \\ CoSiGAN \cite{Zhong2020} &ICMR2020 & 35.55& 81.54 & 90.43 & 38.33 &- &- &- & - &- & - \\ MSR \cite{Feng2019} &TIP2020 & 37.35& 83.40 & 93.34 & 38.11 &- & 39.64& 89.29 & 97.66 & 50.88 &- \\ AlignGAN \cite{Wang2019} &ICCV2019 & 42.40& 85.00 & 93.70 & 40.70 &- & 45.90& 87.60 & 94.40 & 54.30 &- \\ X-Modal \cite{Li2020} &AAAI2020 & 49.92 & 89.79 & 95.96 & 50.73 & - &- &- & - &- &- \\ FBP-AL \cite{Wei2021a} &TNNLS2021 & 54.14&86.04 & 93.03 & 50.20 &- &- &- & - &- & - \\ LLM \cite{Feng2021} &ECCV2020 & 55.25 & 86.09 & 92.69 & 52.96 &- &59.65 &90.85 &95.02 &65.46 &-\\ NFS \cite{Chen2021} &CVPR2021 & 56.91 &91.34 &96.52 &55.45 &- &62.79 &96.53 &99.07 &69.79 &- \\ VSD\cite{Tian2021} &CVPR2021 &60.02 &94.18 &98.14 &58.80 &- &66.05 &96.59 &99.38 &72.98 &-\\ cm-SSFT \cite{Lu2020} &CVPR2020 & 61.60 &89.20 & 93.90 &63.20 &- &70.50 &94.90 &97.70 &72.60 &-\\ GLMC\cite{Zhang2021a} &TNNLS2021 & 64.37&93.90 & 97.53 &63.43 &- &67.35& 98.10 &\textbf{99.77} & 74.02 &-\\ MC-AWL\cite{Ling2021} &IJCAI2021 & 64.82&- & - &60.81 &- &-& - &- &- &-\\ SMCL \cite{Wei2021} &ICCV2021 & 67.39 &92.87 & 96.76 &61.78 &- &68.84 &96.55 &98.77 &75.56 &- \\ \hline AGW \cite{AYe2020} &TPAMI2021 & 47.50 &84.39 & 92.14 &47.65 &35.30 &54.17 &91.14 &95.98 &62.97 &59.20 \\ DDAG \cite{Ye2020b} &ECCV2020 & 54.75 & 90.36 & 95.81 & 53.02 &39.62 &61.02 &94.06 &98.41 &67.98 &62.61\\ IMT \cite{Xia2021} &Neuro2021 & 56.52 & 90.26 & 95.59 & 57.47 &38.75 &68.72 &94.61 &97.42 &75.22 &64.22 \\ HTL \cite{Liu2020} &TMM2020 & 61.68 &93.10 & 97.17 &57.51 &39.54 &63.41 &91.69 &95.28 &68.17 &64.26 \\ MCLNet \cite{Hao2021} &ICCV2021 &65.40 &93.33 &97.14 &61.98 &47.39 &72.56 &96.98 &99.20 &76.58 &72.10\\ \hline \hline AGMNet (Ours) &This work &\textbf{69.63} &\textbf{96.27} &\textbf{98.82} &\textbf{66.11} &\textbf{52.24} &\textbf{74.68} &\textbf{97.51} &99.14 &\textbf{78.30} &\textbf{74.00} \\ \bottomrule \end{tabular} \end{center} \end{table*} \subsection{Comparison to the State-of-the-Art} We compare the performance of the proposed AGM with state-of-the-art methods on two cross-modality benchmark datasets: SYSU-MM01 \cite{Nguyen2017} and RegDB \cite{Wu2017}. We use a single query, and do not use any post-processing techniques (e.g., re-ranking). \subsubsection{Performance Comparisons on SYSU-MM01} According to the properties of the solutions, the comparison methods can be divided into two groups: GAN-based (\textit{i.e.} cmGAN \cite{Dai2018}, D$^{2}$RL \cite{Wang2019a}, CoSiGAN \cite{Zhong2020}, AlignGAN \cite{Wang2019}, X-Modal \cite{Li2020}, \textit{etc}.) and shared feature learning (\textit{i.e.} eDBTR \cite{Ye2019}, AGW \cite{AYe2020}, FBP-AL \cite{Wei2021a}, NFS \cite{Chen2021}, VSD\cite{Tian2021}, MCLNet \cite{Hao2021}, \textit{etc}.) approaches. It is worth noting that we choose more than ten competing methods publsihed in recent two years (2020 or 2021) for comparison. This can fully prove the superiority and advanced nature of our proposed method. Comparison results are reported in TABLE 6. We can see that our AGMNet sets a new state of the art on SYSU-MM01, achieving 69.63\% Rank- 1 accuracy, 66.11\% mAP and 52.24\% mINP under all-search mode and 74.68\% Rank-1 accuracy, 78.30\% mAP and 74.00\% mINP under indoor-search mode. Although some methods (FBP-AL\cite{Wei2021a}, GLMC\cite{Zhang2021a} and HTL \cite{Liu2020}) introduce part-based convolutional features to improve retrieval performance, AGMNet still shows meaningful performance gain in terms of Rank-1/mAP/mINP (69.63\% vs 64.37\%, 66.11\% vs 63.43\% and 52.24\% vs 39.54\%). SMCL \cite{Wei2021} is most similar to ours in that we both draw support from another modality to bridge the cross-modality gap. It generates the syncretic modality with a light-weight network and learns modality-invariant representations with the triple modality interaction learning strategy. Our model on the other hand generates the aligned grayscale modality with image graying and CycleGAN \cite{Zhu2017}. It simultaneously addresses the modality dicrepancy and luminance gap problems by translating two heterogeneous modalities into one homogeneous modality. The results indicate the single modality feature is much more robust than triple modality-shared feature, \textit{i.e.} Rank-1 accuracy 69.63\% vs 67.39\% and mAP value 66.11\% vs 61.78\%. \subsubsection{Performance Comparisons on RegDB} We also compare in TABLE 7 our models with the state of the art methods on RegDB \cite{Nguyen2017}. Similar to the case with the results obtained on SYSU-MM01, our approach consistently outperforms current SOTAs under both evaluation modes. Specifically, for visible-to-thermal mode, AGMNet achieves rank-1 accuracy of 88.40\%, mAP value of 81.45\% and mINP of 68.51\%. Noting that the current top-performing method is CAJL \cite{Ye2021} published in ICCV2021, our approach distinctly improves the Rank-1 accuracy of 3.37\% (from 85.03\% to 88.40\%), mAP of 2.31\% (from 79.14\% to 81.45\%) and mINP of 3.28\% (from 65.33\% to 68.51\%). Similar improvement can be observed under thermal-to-visible mode. For instance, AGMNet beats the SFANet \cite{Liu2021} that adopts the same backbone model and training environment by 15.20\% in terms of Rank-1 accuracy and 17.42\% in terms of mAP. Moreover, It also outperforms the best SOTA method CAJL \cite{Ye2021} by 0.59\%, 3.37\% and 4.20\% respectively in terms of Rank-1 accuracy, mAP and mINP. The above comparison results are consistent with those obtained on the SYSU-MM01 database. These experimental results demonstrate the outstanding performance of AGMNet in bebefits of its ability in discovering the discriminative features for visible-infrared person Re-ID. \begin{figure*}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{AnalysisAGM.pdf}\vspace{-0.6cm} \end{center} \caption{Examples of translated images generated by vanilla image translation models such as CycleGAN (a) and our AGMNet (b). By minimizing heterogeneous modality distances in a unified middle image space, AGM (b) significantly reduce the cross-modality gap. While conventional GAN-based method (a) fails to deal with this issue due to identity inconsistency during the complicated adversarial training process. \vspace{-0.4cm}} \label{fig:smalltarget} \end{figure*}\label{sec:introduction} \begin{table} \setlength{\abovecaptionskip}{-0.2cm} \caption{Comparison with the state-of-the-art methods on the RegDB datasets of different query settings. Here, only `HS' and `SLS' modules are used.} \label{tab:1} \begin{center} \renewcommand{\arraystretch}{1.10} \begin{tabular}{l|ccccc} \toprule Setting & \multicolumn{5}{c}{Visible-Thermal} \\ \hline Method&Rank-1 &Rank-10 &Rank-20 &mAP &mINP\\ \hline Zero-Pad \cite{Wu2017} &17.75&34.21&44.35&18.90 &- \\ eDBTR \cite{Ye2019} & 34.62& 58.96 & 68.72 &33.46 &- \\ D$^{2}$RL \cite{Wang2019a} & 43.40& 66.10 & 76.30 & 44.10 &- \\ CoSiGAN \cite{Zhong2020} &47.18 &65.97 &75.29 &46.16 &- \\ MSR \cite{Feng2019} &48.43 &70.32 &79.95 &48.67 &- \\ FBP-AL \cite{Wei2021a} & 73.98&89.71 & 93.69 & 68.24 &- \\ NFS \cite{Chen2021} &80.54 &91.96 &95.07 &72.10 &- \\ MPANet \cite{Wu2021} &82.80 &- &- &80.70 &- \\ SMCL \cite{Wei2021} &83.93 &- &- &79.83 &- \\ \hline AGW \cite{AYe2020} &70.05 &87.28 &92.04 &66.37 &50.19 \\ DDAG \cite{Ye2020b} &69.34 &86.19 &91.49 &63.46 &49.24 \\ IMT \cite{Xia2021} &75.49 &87.48 &92.09 &69.64 &56.30 \\ SFANet \cite{Liu2021} &76.31 &91.02 &94.27 &68.00 &55.92 \\ MCLNet \cite{Hao2021} &80.31 &92.70 &96.03 &73.07 &57.39 \\ CAJL \cite{Ye2021} &85.03 &\textbf{95.49} &\textbf{97.54} &79.14 &65.33 \\ \hline AGMNet (Ours) & \textbf{88.40}&95.10 & 96.94 &\textbf{81.45} &\textbf{68.51} \\ \hline \hline Setting & \multicolumn{5}{c}{Thermal-Visible} \\ \hline Zero-Pad \cite{Wu2017} &16.63 &34.68 &44.25 &17.82 &-\\ eBDTR \cite{Ye2019} &34.21 &58.74 &68.64 &32.49 &-\\ D$^{2}$RL \cite{Wang2019a} & 43.40& 66.10 & 76.30 & 44.10 &- \\ FBP-AL \cite{Wei2021a} &70.05 &89.22 &93.88 &66.61 & - \\ NFS \cite{Chen2021} &77.95 &90.45 &93.62 &69.79 &- \\ SMCL \cite{Wei2021} &83.05 &- &- &78.57 &- \\ MPANet \cite{Wu2021} &83.70 &- &- &80.90 &- \\ \hline AGW \cite{AYe2020} &68.83 &83.69 &88.35 &64.45 &48.74 \\ DDAG \cite{Ye2020b} &68.06 &85.15 &90.31 &61.80 &48.62\\ SFANet \cite{Liu2021} &70.15 &85.24 &89.27 &63.77 &51.97 \\ IMT \cite{Xia2021} &71.33 &84.52 &88.11 &66.77 &52.28 \\ MCLNet \cite{Hao2021} &75.93 &90.93 &94.59 &69.49 &52.63 \\ CAJL \cite{Ye2021} &84.75 &\textbf{95.33} &\textbf{97.51} &77.82 &61.56 \\ \hline AGMNet (Ours) &\textbf{85.34}&94.56 &97.48 & \textbf{81.19} &\textbf{65.76} \\ \bottomrule \end{tabular} \end{center} \end{table} \begin{table}[t] \centering \setlength{\abovecaptionskip}{0cm} \caption{Quantitative results of AGM using different cross-modality baselines (\textit{i.e.} IDE \cite{Zheng2016}, PCB \cite{Sun2019} and AGW \cite{AYe2020}). Gobal average pooling method is used in this experiment. We report Rank- 1 accuracy(\%), mAP(\%) and mINP(\%) on SYSU-MM01.} \label{Tab03} \renewcommand{\arraystretch}{1.07} \begin{tabular}{l|ccc|ccc} \toprule & \multicolumn{3}{c}{All search} & \multicolumn{3}{c}{Indoor search} \\ \hline {Methods} & R-1 & mAP & mINP & R-1 & mAP & mINP \\ \hline IDE\cite{Zheng2016} & 57.85 &53.42 & 41.20 &64.32 &69.89 & 65.01 \\ PCB \cite{Sun2019} &61.66 &57.84 & 42.23 &66.17 &70.48 & 66.04 \\ AGW\cite{AYe2020} & 60.04 & 58.84 & 46.16 &65.67 &70.91 & 66.32 \\ \hline \hline IDE+AGM &62.35 &58.59 &44.49 & 68.80 &73.84 & 69.16 \\ PCB+AGM & 65.97 &59.75 & 42.73 &71.11 & 73.67 & 67.98 \\ AGW+AGM & 64.45 &61.26 &46.42 &69.38 &73.32 & 68.04 \\ \bottomrule \end{tabular} \end{table} \subsection{Further Study and Depth Analysis} \subsubsection{Evaluation of AGM on Different Baselines} In fact, the proposed Aligned Grayscale Modality (AGM) can be seen as an independent data preprocessing module for cross-modality person re-identification task. It redefines visible-infrared dual-mode learning as a gray-gray single-mode learning problem. Therefore, to evaluate its effectiveness and applicability, we further test it on three commonly used baselines (\textit{i.e.} IDE\cite{Zheng2016}, PCB\cite{Sun2019} and AGW\cite{AYe2020}). For the fairness of comparison, we keep six experimental control group settings consistent during evaluation. The test performance on three different baselines is summarized in TABLE 8. Comparing Baseline without applying AGM, we can observe that the scores of three baselines all hover around 60\%. Interestingly, PCB achieves the highest performance on rank-1 accuracy but fails to keep its advantage in terms of mAP and mINP metrics compared to AGW. Notably, when applying AGM, all metrics on three baselines achieve a remarkable improvement. For instance, under all-search mode, IDE+AGM outperforms IDE with 5.50\% rank-1 accuracy, 5.17\% mAP and 3.29\% mINP value. And when it comes to stronger baselines PCB and AGW, PCB+AGM and AGW+AGM continuously boosts the retrieval performance, indicating that AGM is complementary to various baselines. This result also shows the potential of AGM as an independent data preprocessing method to be combined with other baseline models. \subsubsection{Depth Analysis of AGM and GAN-based Methods} The Aligned Grayscale Modality (AGM) explicitly synthesizes style-consistent grayscale images in the pixel space for highly efficient modality and luminance gap elimination. The major defining difference from other GAN-based methods (\cite{Zhong2020}, \cite{Wang2019}, \cite{Wang2019a}, \cite{Wang2020},\cite{Zhong2021}) is that we propose to utilize a unified middle modality space to reduce modality discrepancy, instead of directly generating its opposite modality. A illustration is shown in Fig. 7. This stratgey enjoys following several merits: \textbf{(1) Realistic synthetic effect.} For existing GAN-based methods, they are non-trivial to accurately choose the suitable target for style transfer due to the separable feature statistics between visible and infrared domains. Here, AGM relys on grayscale images to conduct modality translation. Since the implicit probability distribution of infrared modality is very similar to the target probability distribution of the grayscale domain, the generator thereby can easily transfer infrared images into the target grayscale images with a high fidelity effect. \textbf{(2) Complete elimination of modality gap.} As shown in Fig. 7, although conventional GAN-based methods may relieve modality discrepancy to a certain extent, it incurs a considerable level of structured noise, highlighted by yellow circle. If these low-quality synthetic images are directly used to train an Re-ID model, a novel gap between the original data and the synthetic data will be introduced to the learning process. In contrast, AGM explores a middle modality distribution between visible and infrared domains. That is, we eliminate modality gap by simultaneously aligning the two modality distributions to the grayscale distribution. In this process, two heterogeneous modality information is integrated to one homogeneous modality information, therefore siginificantly smoothing the modality discrepancy. \begin{table}[t] \centering \setlength{\abovecaptionskip}{0cm} \caption{Quantitative results of AGM on near infrared and thermal infrared datasets. Rank- 1 accuracy(\%), mAP(\%) and mINP(\%) are reported.} \label{Tab03} \renewcommand{\arraystretch}{1.10} \begin{tabular}{l|ccc|ccc} \toprule & \multicolumn{3}{c}{SYSU-MM01} & \multicolumn{3}{c}{RegDB} \\ \hline {Methods} & R-1 & mAP & mINP & R-1 & mAP & mINP \\ \hline Baseline & 57.85 &53.42 & 41.20 &\textbf{80.49} &\textbf{75.68} & \textbf{61.22} \\ Bseline+AGM &\textbf{62.35} &\textbf{58.59} & \textbf{44.49} &78.97 &73.10 & 60.15 \\ \bottomrule \end{tabular} \end{table} \begin{figure}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{RegDBAGM.pdf}\vspace{-0.6cm} \end{center} \caption{ Contrast visualization between the raw modality images (a) and the aligned grayscale modality images (b) on RegDB dataset. Compared to raw images, AGM significantly reduces the modality discrepancy, but local feature information is thereby smoothed. \vspace{-0.4cm}} \label{fig:smalltarget} \end{figure}\label{sec:introduction} \subsubsection{Applicable Scenario of AGM} Compared to other modality discrepancy elimination algorithms, AGM shows its unparalleled superiority on image detail preservation. However, some tests prove that it is not applicable to all infrared datasets. That is, AGM is easier to achieve a better performance on near infrared image dataset than thermal infrared dataset. As shown in TABLE 9, using AGM alone on RegDB (thermal infrared dataset) does not help much, or even decrease the performance from 80.49\% to 75.97\% in terms of Rank-1 accuracy. On the contrary, the performance on SYSU-MM01 (near infrared dataset) achieve significantly improvement (from 57.85\% to 62.35\%). This is because near infrared images share similar style with grayscale image, while the style discrepancy between the thermal infrared and grayscale modalities still exists. Besides, it is worth noting that in a thermal image, person area is presented with white pixel points and other irrelevant backgrounds are presented with black pixel points. This imaging process, in fact, is equal to apply a predefined attention pattern map of itself. If we transfer thermal infrared images to grayscale style, as shown in Fig. 8, such the role of attention would be weakened and the loss outweighs the gain. The above analysis shows that AGM, in practice, is more suitable to near infrared datesets, such as SYSU-MM01\cite{Wu2017}, CASIA\cite{Li2007} and CASIA NIR-VIS 2.0 \cite{Li2013},\textit{ etc}. Fortunately, most of commercial infrared cameras are imaged in the form of near-infrared light, which means the poposed AGM has a very far-reaching practical application value. \subsubsection{Head-shoulder Information vs PCB} The proposed head-shoulder information module shares some spirit of Part-based Convolutional Baseline (PCB) by learning discriminative part-informed features. This is because, the head-shoulder information can be considered as a kind of part-level descriptor via proactively cropping from the global image. However, it differs significantly from PCB in the following perspectives: \textit{1) Generation way}: PCB takes a whole image as the input and outputs a convolutional descriptor that contains part-level features. That is, it generates part-level features by partitioning the convolutional tensor. In contrast, head-shoulder information is directly generated from the original image. The rational behind is that the head and shoulder positions contain the most discriminative fine-grained information to depict a person. \textit{2) Learning way}: PCB calculates the cross-entropy loss for every part-level column vector, and minimize the sum losses to optimize the network parameters. It improves the retrieval performance benifiting from its spatial alignment. In contrast, head-shoulder information aims to assit the global feature to form a stronger feature descriptor. In other words, it improves the retrieval performance due to integrate more feature map information. \begin{figure}[tp] \begin{center} \includegraphics[width=0.99\linewidth]{Visualization.pdf}\vspace{-0.6cm} \end{center} \caption{ t-SNE visualization of the distribution of learned representations on SYSU-MM01 dataset. Each color represents an identity in the testing set. The triangles and circles represent different features extracted from the visible and infrared modalities, respectively. \vspace{-0.4cm}} \label{fig:smalltarget} \end{figure}\label{sec:introduction} \subsubsection{Synchronous Learning vs Knowledge Distillation} For synchronous Learning, the consensus feedback propagation can be considered as a kind of knowledge transfer via aligning relative-entropy soft targets. Seemingly, it may share some essence with Knowledge Distillation (KD) that transfers between a static pre-defined teacher and a student in model distillation. However, synchronous Learning differs significantly from KD: \textit{1) Different objectives:} The distil-lation based approaches start with a powerful deep teacher network, and then train a smaller student network to mimic the teacher. The motivation behind it is how to exploit few parameters to train a model that has the same representation capacity as the large network. On the contrary, synchronous learning stratgey aims to obtain more discriminative person representations via multi-branch feature information interaction. \textit{2) Dynamics:} For KD, the teacher model is always a powerful pre-trained network. That is, the teacher's class probabilities are fixed during distillation. Instead, the synchronous learning strategy exploits the per-batch outputs of all student models to generate the teacher signals. Hence, it conveys additional information dynamically in an interactive manner rather than statically as KD. \subsubsection{Visualization analysis} Finally, we give a microscopic interpretation of AGMNet from the perspective of visualization analysis. We examine the internal features captured by baseline model and AGMNet using t-SNE, respectively. As shown in Fig. 9(a), with baseline model, the extracted test features have significant modality discrepancy, in which feature distributions from visible and infrared modalities are fairly farther and less discriminable. Furthermore, the intra-identity modality discrepancy remains still obvious (orange and green triangles). Specifically, the distance between orange and green triangles are closer than that between organe triangles and organe circles, which contributes to the model misjudging orange and green triangles into the same person. In contrast, as shown in Fig. 9(b), feature distributions from visible and infrared modalities are fairly closer and therefore more discriminable. This indicates that AGMNet effectively minimizes the cross-modality gap by aligning distributions of the two modalities, where the learned features of different modalities are grouped by identity instread of modality. \section{Conclusion} This paper presents a novel insight of modality discrepancy elimination for visible-infrared person Re-ID task. The proposed Aligned Grayscale Modality (AGM) explicitly sets up a unified middle image space to integrate multi-modality information, that reformulates heterogeneous modality learning into homogeneous grayscale modality learning problem. Moreover, to reduce the intra-class discrepancy, we propose to utilize the head-shoulder information to assist global features for feature learning. In contrast to models that only employ global appearance features, the proposed AGMNet significantly learns the consensus on identity classes between global and head-shoulder scales with a specially designed identity synchronization regularisation. We have shown the merits of the proposed approach through experimentation on SYSU-MM01 and RegDB datasets, and extensive ablative analysis have been conducted to validate our model design rationale. \section{Acknowledgment} This work is supported by the National Natural Science Foundation of China (No. 62173302). \ifCLASSOPTIONcaptionsoff \newpage \fi
{'timestamp': '2022-04-12T02:30:41', 'yymm': '2204', 'arxiv_id': '2204.04842', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04842'}
arxiv
\subsection{Background} \label{app:background} \subsubsection{Reinforcement Learning} We formulate the RL problem as a Markov Decision Process~(MDP). An MDP consists of the following elements: states $s_{t} \in \mathcal{S}$, actions $a_{t} \in \mathcal{A}$, a dynamics function $p(s_{t+1}|s_{t}, a_{t})$ denoting the transition probability of a state-action combination~$(s_{t}, a_{t})$ and a reward function~$R(s_{t}, a_{t})$. Model-free reinforcement learning algorithm often targets at maximizing the expected return as $J = \sum_{t=0}^{T} \gamma^{t} R(s_{t}, a_{t})$ given a discount factor~$\gamma \in [0,1]$. The state variable for RL from pixels problems are commonly represented as a stack of consecutive image frames to infer the status. Soft Actor-Critic~(SAC)~\cite{haarnoja2018soft} is applied widely to image-based RL problems because of its excellent sampling efficiency and exploration strategy. SAC learns a policy network~$\pi_{\theta}(s_{t})$ and a critic network~$Q_{\phi}^{\pi}(s_{t},a_{t})$ by optimizing the expected return and an entropy regularization term concurrently. The parameters in the critic~$\phi$ are updated by minimizing the squared Bellman error given the transition tuples~$\tau_{t}=(s_{t}, a_{t}, s_{t+1}, r_{t})$ stored in the replay buffer~$D$: \begin{equation} \begin{aligned} \mathcal{L}(\phi) &= \mathbb{E}_{\tau \sim D}[Q_{\phi}(s_{t}, a_{t}) - (r_{t} + y(r_{t}, s_{t+1}))]^{2},\\ y(r_{t}, s_{t+1}) &= \gamma(\min_{i=1,2}Q'_{\phi_{i}}(s_{t+1}, a')-\alpha \log_{\pi_{\theta}}(a'|s_{t+1})) \end{aligned} \end{equation} The parameter $\alpha$ is the temperature value to balance the two terms, which is treated as learned parameter as in~\cite{haarnoja2018softapplications}. $Q'$ is a slowly updated copy of the critic to improve training stability. The actor is learned by maximizing the weighted objective of the expected return and the policy entropy as: \begin{equation} \mathcal{L}(\theta) = \mathbb{E}_{a \sim \pi}[Q_{\phi}(s_{t}, a) - \alpha \log_{\pi_{\theta}}(a|s_{t})]. \end{equation} \subsubsection{Data Augmentation in Reinforcement Learning} Data augmentation has been found to be essential for the performance of RL from pixels. Common data augmentation techniques include random cropping, color jittering, flipping, rotating and gray scaling. We refer the reader to a detailed study for the comparison between different data augmentation strategies~\cite{laskin2020reinforcement}. We adopt the most effective random cropping strategy to the images for all the experiments in this work. Intuitively, random cropping enhances translational invariance to the perception module. In our experiments, the rendered images have 100 $\times$ 100 pixels, which are later randomly cropped to 84 $\times$ 84 pixels. \subsubsection{Vision Transformer} The transformer architecture~\cite{vaswani2017transformer} raised the bar in most domains of machine learning, and have become the state of the art method in NLP tasks. The Vision Transformer (ViT)~\cite{dosovitskiy2020vit} instead takes the transformer architecture and adapts it to make it suitable for images, and has shown incredible results at classification challenges. ViT operates by subdividing an image into fixed-size patches. Each patch is then flattened and linearly transformed into an embedding which is concatenated to a learnable 1D positional embeddings to allow for spatial awareness between the input patches. This embedding is then finally processed through the standard transformer architecture. More recently, ViTs have been used with self-supervised learning to learn good representations, examples of which are Data2Vec~\cite{baevski2022data2vec}, Masked Autoencoders~\cite{he2021masked}. These works apply transformations to the unlabelled images and use losses that try to draw closer together representation of inputs coming from the same original image. A more complete explanation on these methods is described in~\autoref{sec:experimental-design}. \subsection{Extra Discussion on Image Augmentation} \label{app:image-aug} In our work, we apply random cropping to all the experiments as the augmentation technique. The impact of data augmentation with ViT can be further investigated. A corresponding study is conducted with CNN~\cite{laskin2020reinforcement}. Since ViT operates on image patches, diverse augmentation strategies~\cite{cubukpractical,zhang2017mixup, yun2019cutmix, zhong2020random, hoffer2020augment} have been developed to improve training ViT for computer vision tasks. Finding the most effective augmentation technique for RL with ViT is still of great interest to the RL researchers. \subsection{Implementation Details} \label{app:implementation-details} We adopt the soft actor-critic implementation offered by \cite{pytorch_sac}, which tunes the temperature automatically with a constrained optimization~\cite{haarnoja2018softapplications}. We list the hyperparameters in Table.~\ref{tab:hyper}. For experiments using masked images as input, we experiment with masking ratio from $\{30\%, 40\%, 50\%, 60\%, 75\%\}$, and select the $40\%$ and $75\%$ for \emph{Data2Vec} and \emph{MAE} respectively. The mask is represented as a learnable vector optimized by the auxiliary task. We also find that selecting a small batch size for the contrastive learning can stabilize the training. Therefore, the batch size is 512 for the SAC update but 128 for the contrastive objective. In our experiments, the policy is trained jointly with the auxiliary tasks. We adopt the training setup from \emph{SAC+AE}~\cite{yarats2019improving}. \emph{SAC+AE}~\cite{yarats2019improving} blocks the gradient signals from the actor to update the shared encoder while the critic has the privilege to update the encoder, which has been proven to greatly improve the performance. \begin{table} \centering \begin{tabular}{ll} \toprule \textbf{Hyperparameter} & \textbf{Value} \\ \midrule Observation rendering & (100, 100) \\ Observation downsampling & (84, 84) (random cropping)\\ Replay buffer size & 100000 \\ Initial steps & 1000 \\ Stacked frames & 3 \\ \multirow{3}{*}{Action repeat} & 2 FINGER, SPIN; WALKER, WALK \\ & 8 CARTPOLE, SWING \\ & 4 otherwise \\ SAC hidden units(MLP) & 1024 \\ Evaluation episodes & 10 \\ Evaluation frequency & 10000 \\ Optimizer & Adam \\ Encoder learning rate & $1e-3$ \\ Actor learning rate & $1e-3$ \\ Critic learning rate & $1e-3$ \\ Temperature learning rate & $1e-4$ \\ Batch Size & 512 \\ Encoder EMA $\tau$ & 0.05 \\ Critic function EMA $\tau$ & 0.01 \\ Discount factor $\gamma$ & 0.99 \\ Initial temperature & 0.1 \\ Latent dimension & 128 \\ Critic update frequency & 2 \\ Patch size & (12, 12) \\ ViT depth & 4 \\ ViT MLP dimension & 128 \\ Attention head & 8 \\ K in \emph{Data2Vec} & 2 \\ $\beta$ in \emph{Data2Vec} & 2.0 \\ \bottomrule \end{tabular} \caption{Hyperparameters used in the experiments. } \label{tab:hyper} \end{table} The decoder in \emph{Data2Vec} consists of two-layer MLPs with ReLU activation function. We choose a light-weight ViT decoder for \emph{MAE}, which comprises 2 layers with 64 hidden units and 4 heads. Similar to the conclusion in \emph{MAE}, the capacity of the decoder has limited influence on the overall performance. In our implementation of momentum contrastive learning, the queries and keys are generated by a separate head other than the one used for RL, which can be viewed as the decoder in~\autoref{fig:overview}. \section{Conclusion} This paper empirically explored the potential of several ViT methods for RL and compared the results to CNNs trained with RAD, a leading method for image-based RL for CNNs. Specifically, we evaluate vanilla ViTs, as well as the addition of various self-supervised losses (reconstructive and contrastive) to ViT as auxiliary tasks to the RL training. Our results show that ViTs trained with auxiliary tasks (self-supervised losses) are helpful for the RL-from-pixels problem, but they currently still fall short of what can be achieved with CNNs by RAD. \section{Discussion and Future Work} Adding reconstruction-based auxiliary tasks~\cite{baevski2022data2vec,he2021masked} with ViT encoders can significantly enhance performance while encoders built with CNNs still obtain the best performance in the majority of our experiments. \emph{Data2Vec} and \emph{MAE} both predict the features of a masked version of the input. \emph{Data2Vec} reconstructs the deep features encoded by the momentum encoder while \emph{MAE} chooses the original pixel values as the reconstruction target. The contrastive learning framework improves the performance of a plain ViT to a limited extent, which is analogous to the study on CNN~\cite{laskin2020reinforcement,srinivas2020curl}. We suspect that a lack of diversity in the training images could cause the inferior performance of contrastive learning. Unlike the diverse \emph{ImageNet} dataset often used as the baseline for computer vision research, images collected by the RL agent are more similar to each other. As a result, positive and negative keys are sometimes too similar to be distinguished for the contrastive objective. Since transformer-based architectures are notorious for being data-hungry, we are also interested in further improving the sampling efficiency via pre-training. \emph{First pre-train, then finetune} is a well-established paradigm for learning computer vision models to mitigate the issue of insufficient data. Due to a lack of datasets for control tasks, and more specifically RL, what serves as the best dataset for pre-training remains an open question. We plan to investigate the following options: (i) a large, general and diverse dataset such as ImageNet, (ii) a dataset generated from an expert policy, (iii) a dataset generated from a random policy, and (iv) a dataset containing a mixture of expert and non-expert demonstrations. \section{Introduction} Image-based reinforcement learning is an important and growing area, as cameras provide a ubiquitous and inexpensive way to acquire observations in complex and unstructured environments. However, in RL, it remains common to give privileged access to compact state descriptors that may not be available in real-world settings. This is because extending such methods to work with images is non-trivial, usually requiring significant additional computation and algorithmic improvements to cope with the high-dimensional nature of images as inputs. In recent years, end-to-end deep reinforcement learning from visual inputs has yielded impressive results in domains such as robotics control tasks~\cite{levine2016end, 2019-CORL-cassie}, Atari games~\cite{mnih2015human} and autonomous driving~\cite{kendall2019learning}. However, such methods remain data-intensive and are brittle with respect to confounding visual factors, including dynamic backgrounds, other agents, and changing camera perspectives. In principle, end-to-end RL can learn representations directly while learning the policy. However, prior work has observed that RL is bounded by a "representation learning bottleneck" in the sense that a considerable portion of the learning period must be spent acquiring good representations of the observation space. To mitigate this, the learning of good state representations can be aided by auxiliary losses that guide the learning of a suitable representation~\cite{hawke2020urban, yarats2019improving}. They can also be learned fully in advance, in an unsupervised fashion, in support of the subsequent control tasks to be learned~\cite{ha2018recurrent, higgins2017darla, nair2018visual}. Recently, data augmentation techniques, already popular in computer vision, have shown to significantly improve performances in RL from pixels~\cite{yarats2020image, yarats2021image, srinivas2020curl, laskin2020reinforcement}. More recently, computer vision is seeing a potential shift in network architectures from convolutional neural networks (CNNs) to vision transformers (ViT), as the latter are being repeatedly shown to learn good representations for the downstream tasks. Recent advances in Transformers~\cite{vaswani2017transformer} and ViT~\cite{dosovitskiy2020vit} raise the obvious question as to whether or not this type of architecture will also benefit image-based deep reinforcement learning. Since ViT usually requires significantly more data to train on, a common methodology is to first train using a self-supervised objective and then fine-tune the representation as needed for downstream tasks. Motivated by this approach, we investigate whether ViT assisted with the existing self-supervised training objectives can assist in learning image-based RL policies. Our primary contributions are as follows: \begin{itemize}[leftmargin=\parindent] \item We adapt and implement three existing self-supervised learning methods for computer vision tasks as auxiliary tasks for ViT-based RL policies; \item We evaluate and compare the above ViT-based appraoaches with RAD, a leading CNN-based RL method. Our results point to better overall performance for RAD. For the ViT methods, we find that masking-based methods outperform contrastive learning. \end{itemize} \section*{Appendix} \input{appendix/additional_images} \input{appendix/background} \input{appendix/implementation} \input{appendix/image_aug} \bibliographystyle{IEEEtran} \section{Experimental Design} \label{sec:experimental-design} \begin{figure*} \centering \includegraphics[width=0.75\linewidth]{figs/overview.png} \caption{High-level overview of our training pipeline for both ViT and CNN encoders. We keep the standard RL updates unchanged when we switch to ViT auxiliary tasks. We use random cropping as augmentation for RL training. For auxiliary ViT tasks proposed in~\cite{baevski2022data2vec,he2021masked}, we apply random masking as the augmentation stategy, and we adopt another randomly cropped view as augmented sample for contrastive learning~\cite{he2021masked,srinivas2020curl}. } \label{fig:overview} \end{figure*} Convolutional architectures paired with data augmentation techniques have shown great progress in RL from pixels. However, whether ViT can bring any benefit to the problem remains unanswered yet. Therefore, we study the impact of a plain ViT encoder and various self-supervised losses proposed with ViT on the RL from pixels problem. We embed three recently proposed self-supervised objectives with ViT into the standard RL pipeline as auxiliary tasks. More specifically, we employ the idea of \emph{Data2Vec}~\cite{baevski2022data2vec}, \emph{MAE}~\cite{he2021masked}, and momentum contrastive learning~\cite{chen2021empirical,srinivas2020curl}. A high-level summary of our empirical study is illustrated in~\autoref{fig:overview}. We keep the standard RL training fixed at all times, and test the performance of adding different ViT auxiliary tasks, as well as comparing to a CNN-encoder, as implemented for RAD. In this pipeline, the stacked images are first augmented via random cropping, and then embedded to a shared representation using an encoder. This shared representation is then used both for RL training, after being flattened and passed through fully-connected layers, and the auxiliary training tasks, if any. For ViT, we adopt the ViT architecture as both the encoder and decoder. For a fair comparison, we choose a small ViT encoder with a similar order of magnitude of learnable parameters as its convolutional counterpart. We now introduce each self-supervised objective. Please refer to the original paper for more details~\cite{baevski2022data2vec, he2021masked, chen2021empirical, srinivas2020curl}. \begin{figure*} \centering \begin{tabular}{c|c|c} \begin{subfigure}{0.29\textwidth} \includegraphics[width=\linewidth]{figs/data2vec.png} \caption{Data2Vec} \label{fig:data2vec} \end{subfigure}& \begin{subfigure}{0.28\textwidth} \includegraphics[width=\linewidth]{figs/mae.png} \caption{MAE} \label{fig:mae} \end{subfigure}& \begin{subfigure}{0.30\textwidth} \includegraphics[width=\linewidth]{figs/contrastive.png} \caption{Momentum contrastive learning} \label{fig:contrastive} \end{subfigure} \end{tabular} \caption{A detailed representation of the different auxiliary tasks used to guide the learning of the encoder. (a) Data2vec receives two variations of the same image and tries to match the reconstruction. (b) MAE uses an encoder-decoder architecture receiving as input an image with missing patches and tries to reconstruct the original image. (c) The contrastive loss~(InfoNCE) draws together similar image pairs (different augmentations of the same image) while pushing apart dissimilar image pairs.} \label{fig:comparison} \end{figure*} \subsection{Data2Vec} \emph{Data2Vec}~\cite{baevski2022data2vec} is a unified self-supervised model proposed across multiple modalities with different specialized structures, including images, speeches and natural language processing. In this work, we focus on its variant operating on images. Data2Vec adopts the idea of predicting the internal representation of a masked input to match the representation of the original input. A visual depiction is shown in \autoref{fig:data2vec}. The self-supervision task receives the original stack of images~$o_{t}$ and its masked version~$o'_{t}$ as input. The observation~$o_{t}$ is encoded with an encoder~$E_\theta$. The output of the encoder summed with the activation value of the $K$-last layers of the encoder forms the target vector~$t$. Instead, the masked input~$o'_{t}$ is encoded with a momentum encoder~$E'_{\theta'}$ and then passed through a two-layer decoder to form a prediction vector~$p$. The goal is to minimize the difference between the prediction~$p$ and the target~$t$. To avoid learning trivial solutions (i.e., degenerating the representation into a uniform vector), the authors apply parameter-free layer normalization on the output value~$a^{i}$ of the last $i^{th}$ layer. The target~$t$ can be mathematically expressed as: $t = \sum_{i=0}^{K} \text{LayerNorm}(a^{i})$ Given the target~$t$ and prediction~$p$, the parameters of the encoder and the decoder are updated through the Smooth L1 loss as follows: \begin{equation} \mathcal{L}_{Data2Vec}(t, p) = \begin{cases} \frac{1}{2}(t-p)^{2} \// \beta & \text{if} \|t-p\| \leq \beta,\\ \|t-p\|-\frac{1}{2}\beta & \text{otherwise.} \end{cases} \end{equation} The momentum encoder~$E'_{\theta'}$ is updated through Polyak averaging of the encoder~$E_\theta$'s parameters: \begin{equation} \theta' = (1-\tau) \theta + \tau \theta'. \label{eqn:ema} \end{equation} \subsection{Masked Autoencoders} \emph{MAE}~\cite{he2021masked} adopts a simple-yet-effective idea: given an image with masked patches, the self-supervised objective is to reconstruct the original unmasked image. Both the encoder and decoder use a ViT architecture. A visual representation of MAE is depicted in \autoref{fig:mae}. The encoder only operates on the unmasked patches and encodes the unmasked patches to a latent representation~$z_{t}$. The decoder then receives the concatenation of both the unmasked embeddings and the masked patches as input, and transforms the input into images~$p$. All the masked patches are uniformly represented by a learnable vector~$z'$. The positional information of each patch is indicated by the position embedding of the decoder. We implement a lightweight decoder to save computational resources. The reconstruction target $t$ is the pixel value of the masked patches only, and the pixels are normalized per patch to improve the performance as the authors of \cite{he2021masked} suggest. The reconstruction loss~$\mathcal{L}_{MAE}$ is computed as the mean squared error between the target~$t$ and reconstructed images~$p$ only on the masked portion. \subsection{Momentum Contrastive Learning} Contrastive learning~\cite{chen2020simple, he2019moco, henaff2020data, wu2018unsupervised} is designed to learn representations that obey similarity constraints in a self-supervised manner. The process of contrastive learning can be understood as a dictionary look-up task. Given an encoded query~$q$ and a dictionary of encoded keys~$K = \{k_{0},k_{1},k_{2},\dots,k_{n}\}$, among which one key~$k^{+}$, defined as the positive key, matches the query~$q$, the objective of contrastive learning is to ensure the distance between the query~$q$ and the positive key~$k^{+}$ is closer than the distance of the query~$q$ and any other key in the dictionary~$K\setminus{k^{+}}$. The keys are commonly encoded via a momentum encoder~\cite{he2019moco,chen2020improved,he2021masked} to enhance training stability. We adopt the loss design of CURL\cite{srinivas2020curl} where the distance is computed as bilinear products~($q^{T}Wk$) with a learnable matrix $W$. InfoNCE is applied as the loss to ensure the similarity constraints: \begin{equation} \mathcal{L}_{\text{InfoNCE}} = \text{log}\frac{\text{exp}(q^{T}Wk_{+})}{\text{exp}(q^{T}Wk_{+}) + \sum_{i=0}^{K-1}\text{exp}(q^{T}Wk_{i})}, \end{equation} As shown in \autoref{fig:contrastive}, the encoder and momentum encoder compress the two sets of image stacks~$\{o_{t}, o'_{t}\}$ into latent vectors as queries and keys. We treat the image stack yielded from the same image but augmented differently as the positive key~$k^{+}$, and other image stacks in the batch as the negative keys~$K\setminus{k^{+}}$. The momentum encoder is a moving average of the encoder updated according to \autoref{eqn:ema}. \section{Related Work} Reinforcement learning from pixels has been approached using RL algorithms including DQN~\cite{mnih2015human} and DDPG~\cite{lillicrap2015continuous}. These algorithms were applied to Atari environments and not more complex dynamical control environments like the locomotion ones in Mujoco~\cite{todorov2012mujoco}, PyBullet~\cite{coumans2021} or Deepmind Control Suite~(DMControl Suite)~\cite{tassa2020dmcontrol}. These algorithms are not explicitly designed for image-based input, and they learn faster with lower dimensional state representations. In recent years, a focus on RL from pixel-based input has narrowed the gap between learning from compact state observations and high-dimensional observations, generally using CNNs. Learning a representation with an auxiliary decoder is known to improve efficiency in learning good representations~\cite{kendall2019learning, yarats2019improving}. Data augmentation methods have recently been adopted in RL, in contrast to computer vision where this has a longer history. RAD~\cite{laskin2020reinforcement} proposes to augment images with random cropping, and other augmentations to improve data-efficiency. DrQ~\cite{yarats2020image} and DrQ-v2~\cite{yarats2021image} propose to augment both the input image and the Q-function. This acts as a regularization technique and allows efficient learning of action-value approximations for images. Later, stochastic data augmentation is proposed to further stabilize the training of agent~\cite{hansen2021stabilizing}. SUNRISE proposes the use of an ensemble of Bellman back-ups and a novel exploration strategy to enhance the performance~\cite{lee2021sunrise}. Predicting future internal representations has also been demonstrated to be an effective objective for RL from pixels~\cite{schwarzer2020data}. CURL~\cite{srinivas2020curl} uses a contrastive loss~\cite{chen2020simple, van2018representation} to match representations of the same image processed with different augmentations. The contrastive objective for RL is then extended to incorporate temporal prediction~\cite{lee2020predictive,stooke2021decoupling} and curiosity-driven rewards~\cite{nguyen2021sample}. Additionally, model-based approaches learn the latent dynamics corresponding to image-based observations to improve sampling efficiency~\cite{ha2018recurrent, hafner2019learning, hafner2019dream, hafner2020mastering}. Multiple methods have been proposed to learn self-supervised representations with ViT, and later fine tune them for downstream computer vision tasks. Popular ideas include contrasting the visual representations of different augmented views of the images~\cite{he2019moco, chen2021empirical}, discriminating the latent representations~\cite{caron2021emerging, zhou2021ibot}, and predicting targets with masked inputs~\cite{he2021masked, wei2021masked, bao2021beit, baevski2022data2vec}. In this work, we aim to analyze the usage of ViTs for reinforcement learning from pixels. We seek to understand the extent to which additional self-supervised losses can guide the learning of efficient representations in an RL context, and to compare this to CNN-based methods such as RAD. \section{Experiments and Results} \begin{table*} \centering \begin{tabular}{lcccc|c} \midrule \textbf{100K STEP SCORES} & ViT & ViT w/ Data2Vec & ViT w/ Mae & ViT w/ Contrastive & RAD\\ \midrule FINGER, SPIN & $293.06\pm260.74$ & $646.52\pm247.59$ & \textbf{\textit{899.08$\pm$106.28}} & $850.36\pm103.52$ & $823.16\pm169.13$ \\ CARTPOLE, SWING & $852.73\pm15.64$ & $721.91\pm283.46$ & \textit{864.45$\pm$4.90} & $844.48\pm27.11$ & \textbf{871.50$\pm$9.87} \\ REACHER, EASY & $125.72\pm60.36$ & $185.98\pm73.35$ & $383.52\pm234.86$ & \textit{440.52$\pm$88.83} & \textbf{897.56$\pm$73.12} \\ CHEETAH, RUN & $263.54\pm22.79$ & $287.46\pm36.44$ & \textit{366.78$\pm$49.08} & $270.40\pm147.41$ & \textbf{584.30$\pm$15.83} \\ WALKER, WALK & $562.92\pm105.89$ & \textit{587.84$\pm$101.82} & $263.57\pm228.29$ & $377.67\pm258.46$ & \textbf{875.04$\pm$138.11} \\ CUP, CATCH & $172.06\pm182.79$ & $410.50\pm192.20$ & \textbf{\textit{946.34$\pm$21.87}} & $804.28\pm235.83$ & $661.63\pm140.37$ \\ \midrule \textbf{500K STEP SCORES} & & & & & \\ \midrule FINGER, SPIN & $758.82\pm381.72$ & \textbf{\textit{975.54$\pm$8.80}} & $951.62\pm53.20$ & $917.80\pm127.19$ & $843.86\pm166.31$ \\ CARTPOLE, SWING & $861.76\pm14.02$ & $866.74\pm12.31$ & \textit{868.34$\pm$10.96} & $853.49\pm32.11$ & \textbf{872.03$\pm$7.23} \\ REACHER, EASY & $230.08\pm77.42$ & $234.28\pm91.76$ & $362.04\pm83.65$ & \textit{539.70$\pm$119.56} & \textbf{910.26$\pm$50.58} \\ CHEETAH, RUN & $480.15\pm50.48$ & $539.86\pm104.35$ & \textit{551.58$\pm$50.48} & $442.82\pm96.81$ & \textbf{837.36$\pm$26.83} \\ WALKER, WALK & $841.77\pm48.30$ & \textit{895.56$\pm$37.94} & $844.29\pm43.90$ & $892.41\pm78.93$ & \textbf{970.20$\pm$7.08} \\ CUP, CATCH & $486.34\pm394.58$ & $963.04\pm4.82$ & \textbf{\textit{973.64$\pm$5.78}} & $888.18\pm132.07$ & $925.16\pm20.84$ \\ \bottomrule \end{tabular} \caption{Average test reward for the environments in DMControl Suite at 100K and 500K training steps. Method achieving the best performance is highlighted in bold text while the best performance among the ViT variants is labelled in italic text. } \label{tab:reward} \end{table*} We evaluate different choices of self-supervised learning losses, including \emph{Data2Vec}~\cite{baevski2022data2vec}, \emph{MAE}~\cite{he2021masked}, and contrastive learning approaches~\cite{srinivas2020curl,he2019moco} with ViT on continuous control tasks in DMControl Suite~\cite{tassa2020dmcontrol}. We choose a vanilla ViT pipeline without any auxiliary task as the baseline for comparison, and also report the results for RAD~\cite{laskin2020reinforcement}, the state-of-the-art~(SOTA) convolutional architecture for RL from pixels for a complete view. We keep the number of parameters as similar as possible across all the experiments. To make our comparisons as fair as possible we kept the following details fixed in all ViT-based experiments: (i) Soft Actor-Critic (SAC) as RL algorithm, (ii) structure and dimensionality of ViT encoders, (iii) learning rate for auxiliary tasks and RL updates. We use hyperparameter values from the respective original papers and keep hyperparameters unchanged across the experiments, except for the masking ratio used in~\cite{he2021masked,he2019moco}. Random cropping is selected as the image augmentation strategy for all the experiments in the standard RL training. Further implementation and hyperparameter details are described in \autoref{app:implementation-details}. For evaluation, we use the average total reward at 100K and 500K gradient update scores, as listed in \autoref{tab:reward}. Each entry is evaluated by averaging across 5 runs with different random seeds. Corresponding learning curves are illustrated in \autoref{fig:learning_curve}. Compared with a plain ViT model, adding any auxiliary task improves the learning performance. Among the three auxiliary training tasks, the masking-based tasks (\emph{Data2Vec} and \emph{MAE}) are clearly better than the contrastive learning one. \emph{MAE} outperforms \emph{Data2Vec} in most environments except the \texttt{WALKER,WALK} environment. When convolutional models~(\emph{RAD}) are also considered for comparison, \emph{RAD} still achieves the SOTA performance in 4 out of the 6 experiments, while \emph{Data2Vec} and \emph{MAE} with ViT architecture reach the best accumulated reward in the \texttt{FINGER, SPIN} and \texttt{CUP,CATCH} environments.
{'timestamp': '2022-04-12T02:33:45', 'yymm': '2204', 'arxiv_id': '2204.04905', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04905'}
arxiv
\section{Introduction} In computer vision, deep learning models trained on small labeled datasets can benefit greatly from pre-training on labeled datasets such as ImageNet \cite{girshick2014rich}. Even more surprisingly, MoCo \cite{he2020momentum} showed that it is possible to pre-train with unlabeled data and outperform pre-training with supervised learning on several downstream tasks. This led to the rapid development of several Self-Supervised Learning (SSL) methods \cite{caron2020unsupervised,chen2020simple,chen2020improved,he2020momentum}. Representations obtained via SSL have the ability to \emph{generalize} to downstream tasks such as object classification, detection, and segmentation \cite{deng2009imagenet,Everingham2009ThePV,Krizhevsky2009LearningML}. Recent work suggests that representations with a \emph{shape bias} generalize better than those with a texture bias \cite{geirhos2018imagenet,tartaglini2022developmentally}. Such connection takes inspiration from developmental psychology studies, which have shown that children around the age of two prefer to rely more on shape rather than texture to classify novel objects \cite{landau1988importance}. This follows the philosophy where understanding deep learning models may help to understand mechanisms of human vision and vice versa \cite{geirhos2021partial}. However, as we discuss later and show in our experimental evaluation, the ability to generalize on shape-based tasks may not need to suppress texture discrimination. The analysis of how much deep neural networks are biased towards shape or texture is still being debated \cite{geirhos2018imagenet,tartaglini2022developmentally}. Geirhos et al.~\cite{geirhos2018imagenet} propose new datasets and evaluation methods to measure the degree by which a trained model is biased more towards the shape or the texture of an object. Similarly, Tartaglini et al.~\cite{tartaglini2022developmentally} propose alternative versions of these datasets and experiments to evaluate shape bias as done in developmental psychology. These measures of shape bias are proposed as gauges of how well a pre-trained model can be transferred to other tasks. However, transfer learning methods may give unpredictable outcomes. We find that a model with a lower initial shape bias than another one, as measured in \cite{geirhos2018imagenet,tartaglini2022developmentally}, may do better in the transfer learning to a shape-based task, such as $\text{Yoga}_{82}$ (see Fig.~\ref{fig:yoga82}). Thus, we suggest that predicting how well pre-trained models generalize to shape-based tasks may not have to trade off texture for shape discrimination or show a stronger bias towards shape. \begin{figure}[t] \begin{center} \begin{tabular*}{\linewidth}{@{}c@{\extracolsep{\fill}} c c c@{}} \includegraphics[height=0.16\textwidth,trim={0cm 0cm 0cm 0cm},clip]{"figures/dolphin_plank.jpg"} & \includegraphics[height=0.16\textwidth,trim={68cm 0cm 10cm 60cm},clip]{"figures/eight_angle2.jpg"} & \includegraphics[height=0.16\textwidth,trim={0cm 0cm 0cm 0cm},clip]{figures/plank.jpg} & \includegraphics[height=0.16\textwidth,trim={3cm 3cm 3cm 3cm},clip]{"figures/sage_koundinya2.jpg"}\\ Dolphin plank & Eight angle & Plank & Sage Koundinya \end{tabular*} \vspace{-.3cm} \end{center} \caption{$\text{Yoga}_{82}$ is a dataset with a shape-based task. As these examples show, texture alone is not indicative of the pose. Thus, models that perform well in this task may demonstrate a strong shape discriminability.} \label{fig:yoga82} \end{figure} Given the importance of texture discrimination in many tasks, and in particular in problems with natural categories, we propose a method to boost both shape and texture discriminability. Shape differentiation is encouraged by training a model to detect the correct positioning of object parts, a concept already proposed in the context prediction \cite{doersch2015unsupervised} and jigsaw puzzle SSL methods \cite{noroozi2016unsupervised}. We also take inspiration from Electra \cite{clark2020electra}, where some text tokens are replaced by a weak generator and a discriminator is trained to detect them, and the spotting artifacts method \cite{jenni2018self}, which does the same in the visual domain. Texture discrimination is encouraged instead via a contrastive loss~\cite{Geirhos2020OnTS} as in MoCoV3~\cite{chen2021empirical}. In our method (see Fig.~\ref{fig:DILEMMA}), we split an image into a grid of tiles, map them to tokens, combine them with positional embeddings and then feed them to a ViT \cite{dosovitskiy2020image}. However, we corrupt the positional embeddings of a fraction of the tokens. Then, we train the ViT to classify the tokens into those with correct and incorrect positional embeddings. In this way, the pseudo-task of detecting corrupted locations forces the discriminator to learn meaningful associations between the texture in a token and its location relative to the other tokens. The training of SSL methods and transformers poses a major challenge with its demanding computational requirements. One practical technique to reduce the computational load, which we adopt, is to \emph{sparsify} the input tokens as in VATT~\cite{akbari2021vatt} and MAE~\cite{he2021masked}. This technique serves also a second purpose: If we fed all tiles as input, the ViT could detect incorrect positional embeddings just by using the tile borders. This would not lead to the learning of shape-discriminative features. We avoid this behavior thanks to sparsity, because it is unlikely that the selected input tokens are adjacent. We also use a teacher-student architecture as in MoCoV3 \cite{chen2021empirical}. We sparsify only the input to the student network and instead feed all the tiles to the teacher network, since it is used only in evaluation mode and it does not have a significant impact on storage and computing resources. Moreover, the use of a complete set of tiles (a setting that we call \emph{dense}) and without corrupted positional embeddings, allows the teacher to build a better reference for the student network. We call our method DILEMMA, which stands for ``Detection of Incorrect Location EMbeddings with MAsked inputs.''\\ \noindent\textbf{Our contributions can be summarized as follows:} \begin{itemize} \item We introduce a novel SSL method that enhances the shape discriminability of features without sacrificing the ability to represent texture; it is based on the detection of misplaced positional embeddings with a ViT, and a contrastive loss as in MoCo. \item We show that current shape bias measures are not stable predictors of performance on shape-based downstream tasks. \item We propose to randomly sparsify the inputs to: 1) speed up the training, 2) reduce the memory usage, 3) close the gap between training and test times, 4) avoid degenerate learning \item We surpass the performance of MoCoV3 and DINO under the same computational budget. \end{itemize} \section{Related Work} \noindent\textbf{Self-Supervised Learning.} Self-supervised learning gained popularity as a form of unsupervised learning where pretext tasks leverage supervision signals obtained automatically without human labor. Some classic examples are the classification of image patch locations \cite{doersch2015unsupervised,noroozi2016unsupervised}, the reconstruction of color channels \cite{zhang2016colorful} or image patches \cite{pathakCVPR16context}, or the recognition of various image transformations \cite{gidaris2018unsupervised,jenni2018self,jenni2020steering}. While prior patch-based methods inspired our approach of detecting wrongly placed image patches, ours is both simpler and performs better in transfer experiments. Furthermore, due to the input representation of ViTs (disjoint image patches) and our random sparse patch sampling, our approach suffers less from shortcuts or domain gaps between pre-training and transfer.\\ \noindent\textbf{Contrastive Learning.} Efforts to scale up and improve instance discrimination \cite{dosovitskiy2015discriminative,wu2018unsupervised} as a self-supervised pre-training task have established contrastive learning \cite{chen2020simple,he2020momentum,oord2018representation} as the most popular SSL approach in computer vision today. Several modifications of the basic recipe, \emph{i.e.}, learning to discriminate training instances up to data augmentations, have been proposed since. For example, some methods leverage momentum encoded samples for positive and negative sampling \cite{he2020momentum,chen2020improved}, some remove the need for explicit negative pairs \cite{Grill2020BootstrapYO,chen2020exploring}, and others extend the set of positives beyond data-augmentation through clustering \cite{caron2020unsupervised} or nearest-neighbors in feature space \cite{dwibedi2021little}. Another line of work considers contrastive pre-training strategies tailored to dense prediction tasks \cite{o2020unsupervised,wang2021dense,xiao2021region,xie2021propagate,li2021dense,liu2021efficient}. More recently, state-of-the-art contrastive methods leverage novel vision transformer architectures \cite{dosovitskiy2020image,liu2021swin}, \emph{e.g.}, by adapting existing approaches \cite{chen2021empirical,xie2021self}, tailoring architectures \cite{li2021efficient}, or novel objectives \cite{caron2021emerging}. In our approach, we improve upon a well-established contrastive baseline \cite{chen2021empirical} through the addition of a spatial reasoning task and by extending the set of image augmentations through randomized patch dropping.\\ \noindent\textbf{Self-Supervised Pre-Training of Transformers.} The success of the transformer architecture \cite{vaswani2017attention} in natural language is to a great extent due to large-scale self-supervised pre-training tasks. Successful pre-training strategies from NLP like masked token prediction \cite{devlin2018bert} have recently also been adapted to the image domain \cite{bao2021beit,zhou2021ibot,he2021masked,zhou2021ibot}. Our patch misplacement detection is similar to another type of pretext task in NLP, where the goal is to detect corrupted tokens, \emph{i.e.}, words replaced by an imperfect masked language model \cite{clark2020electra,clark2020pre}. However, a key difference in our approach is that we only tamper with the spatial position of the tokens and thus do not require a separate masked token prediction model. In parallel work, Fang et al.~\cite{Fang2022CorruptedIM} use BEiT~\cite{bao2021beit} for that purpose. The method of DABS~\cite{tamkin2021dabs} also uses the idea of patch misplacement, but it does not have a way to handle degenerate learning and it does not show performance improvements. A technique that has proven very beneficial to improve the training efficiency of vision transformers is token dropping \cite{akbari2021vatt,he2021masked,el2021large,chen2022context}. We extend this technique by randomizing the token dropping amount and including the case of no dropping to narrow the domain gap between pre-training and transfer. \section{Training DILEMMA} So far, the analysis of features obtained through representation learning has indirectly promoted the idea that features with a strong shape bias may have to forgo texture discriminability. For example, datasets used to evaluate shape bias are built under the premise that features should be ``prone'' to texture invariance, \emph{i.e.}, they could be easily fine-tuned to artificial datasets, where class discrimination is only based on the class shapes \cite{geirhos2018imagenet,tartaglini2022developmentally}. However, texture carries also important class information (\emph{e.g}, the zebra, jaguar or panda color patterns are very distinctive of their category). Thus, we advocate that shape discriminability should be boosted, while not sacrificing the ability to distinguish texture. To achieve this goal we introduce {DILEMMA}, a novel self-supervised learning method. {DILEMMA} uses two fundamental losses, which we introduce in detail in section~\ref{sec:losses}. We illustrate our training method in Fig.~\ref{fig:DILEMMA}. \begin{figure}[t] \begin{center} \includegraphics[width=\columnwidth,trim={0cm 7cm 3cm 0cm},clip]{figures/ElectraForVision.pdf} \end{center} \caption{DILEMMA: A sample image is augmented twice and split into tiles (we use a $14\times 14$ grid). The Teacher network takes the complete set of tiles as input (dense) and without mismatches in the positional embeddings for each token. The Student takes only a subset of the tiles as input (sparse) and some tiles have incorrect positional embeddings. The Student is then trained under two tasks: one is the contrastive loss of the class tokens (CLS) between the Teacher and the Student, and the other is the binary cross-entropy for each token. } \label{fig:DILEMMA} \end{figure} Let us define an image sample as $x\in \mathbb{R}^{H\times W \times C}$, \emph{i.e.}, $x$ has $H\times W$ pixels and $C$ color channels. We apply two data augmentations \cite{Grill2020BootstrapYO} to $x$ and obtain $\hat{x}_1$ and $\hat{x}_2$. Similarly to ViT, each input $\hat{x}_1$ and $\hat{x}_2$ is divided in $14\times 14$ tiles, flattened and projected to $N$ tokens $t_{1,i}, t_{2,i}\in \mathbb{R}^{D}$, $\forall i \in U\doteq \{1,\dots,N\}$, through a linear projection. We then combine each token $t_{\cdot,i}$, with a positional embedding $p_i\in\mathbb{R}^D$, which can be either learned or fixed. As in MoCoV3 \cite{chen2021empirical}, we define a \emph{Student} $S$ and a \emph{Teacher} $T$ ViTs \cite{dosovitskiy2020image}, where the Teacher, also called \emph{momentum encoder}, is obtained through the exponential moving average (EMA) of the Student's weights (thus, it is not trained). The Teacher receives as input all the tokens $t_{1,1},\dots,t_{1,N}$ with the corresponding positional embeddings $p_1,\dots,p_N$. The Student instead receives as input a sparse set $M\subset U$ of tokens $t_{2,i}$, $i\in M$. For a randomized fraction of these tokens $B\subset M$ the corresponding positional embdeddings $q_{i}$, $i\in M$ are incorrect, \emph{i.e.}, $q_{i} \doteq p_{i}$ if $i\in M\setminus B$ and $q_{i} \doteq p_{j}$ with $j\in U \setminus M$, if $i\in B$. We call the ratio $\theta = \nicefrac{|B|}{|M|}\in [0,1]$, between the cardinalities of $B$ and $M$, the probability of a positional embedding mismatch. We choose a different $M$ and $B$ sets for each sample at each iteration. We define a set of ground truth labels $y_i=0$ (N) if $i\in M\setminus B$ and $y_i=1$ (Y) if $i\in B$. The $i$-th output token from the Student is denoted with $S_i(\{q_j\oplus t_{2,j}\}_{j\in M})$. We indicate the extra classification token with $i=0$ both at the input and output. Also, $q_{0},p_{0}=0$, \emph{i.e.}, no location encoding. Because of the sparsity in the input to the Student network, we also obtain a computational benefit. When we increase the sparsity of the input, we can also increase the mini batch size to fully utilize the GPU RAM. This is particularly significant with ViTs, because of their quadratic scaling with the number of tokens (the memory usage is $O(N^2)$). The fact that we can significantly increase the mini batch size is particularly effective with contrastive learners. Moreover, in this way it is also faster to train our model, because the average mini batch size is much larger than when using dense inputs (in our case it's $2.5\times$ more). \subsection{Enhancing both Shape and Texture Discriminability} \label{sec:losses} We train our model (the Student network) to have both a shape and texture discriminability by using two losses: one is the location-congruence classification of tokens and the other is a contrastive loss between the student extra class token (CLS) and the corresponding class token of the Teacher. The first loss focuses on the shape, while the second focuses more on the texture~\cite{Geirhos2020OnTS}. The first loss can be described as \begin{align} \textstyle {\cal L}_\text{BCE} = \mathbb{E}_x\big[ &\textstyle \sum_{i\in M} y_i \log \left( \sigma(W S_i\left(\{q_j\oplus t_{2,j}\}_{j\in M \cup \{0\}}\right)\right) \\ &\textstyle+ (1-y_i) \log \left(1-\sigma(W S_i\left(\{q_j\oplus t_{2,j}\}_{j\in M \cup \{0\}}\right)\right)\big],\nonumber \end{align} where $\mathbb{E}[\cdot]$ is the expectation over image samples, $\sigma$ is the sigmoid function and $W$ is a linear projection. The second loss is instead the contrastive loss \begin{align} \textstyle {\cal L}_\text{CNT} = \mathbb{E}_x\big[ \textstyle L_\text{CE}\left(S_0\left(\{q_j\oplus t_{2,j}\}_{j\in M \cup \{0\}}\right), T_0\left(\{p_j\oplus t_{1,j}\}_{j=0,\dots,N}\right)\right) \big], \end{align} where \begin{align} \textstyle L_\text{CE}\left(A, V\right) = -2\tau\sum_n z_n\log \text{softmax}\left(\frac{A_n^\top V}{\tau}\right) \end{align} and $A$ and $V$ are $G\times m$ matrices, with $m$ the minibatch size and $G$ the vector size after the projection $W$, $z_j$ is the one-hot vector with $1$ at the $j$-th position and the index $n$ indicates the class token within the minibatch. Finally, we combine both losses into a single cost \begin{align} {\cal L}_\text{DILEMMA} = \lambda_\text{DILEMMA}{\cal L}_\text{BCE} + {\cal L}_\text{CNT}, \end{align} which we minimize and where $\lambda_\text{DILEMMA}>0$ is a tuning parameter. As pointed out in Electra~\cite{clark2020electra}, we believe that our per-token positional-congruence loss ${\cal L}_\text{BCE}$ provides a richer ``dense'' feedback to the model during training, as opposed to when only the CLS token is used in the contrastive loss, and this might help convergence. As in MoCoV3 we use a symmetrized loss. \subsection{Implementation} \noindent\textbf{Architecture.} We use Vision Transformers (ViT)~\cite{dosovitskiy2020image} with a patch size of $16\times 16$ pixels and an input image size of $224\times 224$ pixels, which gives a total of $(224/16)^2 = 196$ tokens. Due to computational limitations, we only use the small variant of the Vision Transformer (ViT-S) which has $12$ transformer blocks and $384$ channels. Following MoCoV3~\cite{chen2021empirical} we use $12$ attention heads in each attention layer. This is different from most ViT-S implementations, which use 6 heads. This does not change the total number of parameters of the model, but incurs a slight speed penalty. We use a 3-layer MLP for the projection and prediction heads with synchronized batch normalization. We also freeze the weights of the patch embedding layer for better stability.\\ \noindent\textbf{Pre-training Setup.} We pre-train {DILEMMA} on ImageNet-1K~\cite{deng2009imagenet} with the exact same hyper-parameters (including learning rate, learning rate scheduler, optimizer, and warm-up epochs) of MoCoV3 using three GeForce RTX 3090 GPUs for 100 epochs with a base batch size of 345. We set the $\lambda_\text{DILEMMA}$ to 0.4 and the probability of positional embedding mismatch $\theta=0.2$. We use sparsity ratios of 0\%, 40\%, 55\%, 65\% with $1\times$, $2\times$, $3\times$, $4\times$ base batch size and disable the {DILEMMA} loss when the input is dense. To compare with DINO~\cite{caron2021emerging}, we trained a DINO network with a batch size of $480$ for $100$ epochs without multi-cropping. For the sake of completeness we also trained a {DILEMMA} for 150 epochs which takes the same amount of time as training MoCov3 for 100 epochs.\\ \noindent\textbf{Linear Probing.} To evaluate the pre-trained features for image classification, we train a simple linear layer on top of \underline{frozen features}, without any data augmentation (Linear$_{F}$). Note that it is different from the standard linear probing, and we opt to use this method for its simplicity and speed. It is also more aligned with the end goal of representation learning. In all the linear probing experiments, we use the embedding of the CLS token of the last layer (unlike in DINO~\cite{caron2021emerging}, which uses the CLS token of the last four attention layers of the network and concatenates them) and perform a coarse grid search over learning rates, batch sizes and whether to normalize the data before feeding them to the linear layer or not (similarly to the added BatchNorm layer~\cite{ioffe2015batch} in MAE~\cite{he2021masked}). \section{Experiments} We evaluate {DILEMMA} on several datasets, compare it to existing methods in SSL, perform ablations to show the role of each loss function and analyze its shape vs texture bias. We refer to MoCoV3~\cite{chen2021empirical} as our baseline. \subsection{Classification on ImageNet-1K} \noindent\textbf{k-NN and Linear Probing.} In order to evaluate the quality of the pre-trained features, we either use a weighted $k$ nearest neighbor classifier (we always use $k=20$)~\cite{Wu2018UnsupervisedFL} or a simple linear layer on top of a frozen backbone and \underline{frozen features}. In Table~\ref{tab:imagenet_fast}, {DILEMMA} outperforms the base model by 1.5\% after 2/3 of the training time. It also outperforms DINO in similar settings when multi-crop training is disabled (multi-crop training could also improve the results of MoCoV3 and {DILEMMA}, but this is beyond the focus of this work). We also show {DILEMMA} trained for the same amount of time as MoCoV3 in gray and denote it with the $(\uparrow)$ symbol. In either case, {DILEMMA} shows a consistent and significant improvement. Note that Table~\ref{tab:imagenet_others} includes all the results from other methods with their reported numbers. Reported numbers for the linear accuracy are based on a linear layer trained with data augmentation.\\ \begin{table}[t] \begin{minipage}[c]{.45\linewidth} \captionsetup{width=0.98\linewidth} \caption{$k$-NN and linear probing on ImageNet-1K. The $(\uparrow)$ model was trained for 150 epochs, which takes the same amount of time as training MoCoV3 for 100 epochs} \label{tab:imagenet_fast} \centering \begin{tabular*}{\linewidth}{cccc} \toprule Method & {$k$-NN} & Linear$_{F}$ & Linear\\ \midrule DINO & 61.66 & 64.60 & -\\\midrule MoCoV3 & 60.11 & 63.81 & 65.1\\ \midrule DILEMMA & \bf 61.73 & \bf 65.30 & \bf 66.6\\ \midrule \rowcolor{Gray} DILEMMA($\uparrow$) & 63.42 & 67.24 & -\\ \bottomrule \end{tabular*} \end{minipage} \hfill \begin{minipage}[c]{.5\linewidth} \captionsetup{width=0.98\linewidth} \caption{Low-shot learning on ImageNet-1K. The $(\uparrow)$ model was trained for 150 epochs, which takes the same amount of time as training MoCoV3 for 100 epochs} \label{tab:imagenet_semisupervised} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular}{@{}lcccc@{}} \toprule {} & \multicolumn{2}{c}{IN-1\%} & \multicolumn{2}{c}{IN-10\%}\\ Method & {$k$-NN} & Linear$_{F}$ & {$k$-NN} & Linear$_{F}$\\ \midrule DINO & \bf 40.60 & 45.24 & \bf 52.95 & 58.35\\ \midrule MoCoV3 & 38.77 & 44.48 & 51.03 & 57.90\\ \midrule DILEMMA & 40.27 & \bf 45.69 & 52.75 & \bf 59.22\\ \midrule \rowcolor{Gray} DILEMMA($\uparrow$) & 42.45 & 48.67 & 54.83 & 61.47\\ \bottomrule \end{tabular} } \end{minipage} \end{table} \noindent\textbf{Low-shot learning.} To simulate transfers to small datasets, we use the model pre-trained on the whole unlabeled ImageNet dataset and then train a linear layer on top of the frozen features of the 1\% or 10\% subsets \cite{chen2020simple} of ImageNet and then evaluate the results on the whole ImageNet validation set. Results in Table~\ref{tab:imagenet_semisupervised} show that {DILEMMA} is more label efficient than MoCoV3. Notice that in this implementation {DILEMMA} is based on MoCoV3, which, as was observed in DINO~\cite{caron2021emerging}, has a consistently worse $k$-NN accuracy than DINO. Nonetheless, {DILEMMA} is able to almost compensate for the gap deficit.\\ \noindent\textbf{ImageNet-*.} To measure the out of distribution (OOD) generalization of the representation, we use a linear layer trained on the non augmented training set of ImageNet-1K and evaluate it on different OOD datasets. Results in Table~\ref{tab:imagenet_variants} show that {DILEMMA} has a better OOD generalization than the baseline. \begin{table*}[t] \centering \caption{Accuracy on out of domain datasets. We show the transfer learning accuracy of an ImageNet frozen linear classifier to other test sets} \label{tab:imagenet_variants} \resizebox{1.0\textwidth}{!}{ \begin{tabular}{@{}lcccccc@{}} \hline Method & IN-A \cite{hendrycks2021natural}& IN-O (AUPR)~\cite{hendrycks2021natural} & IN-R \cite{hendrycks2021many} & IN-Sketch \cite{wang2019learning} & IN-ReaL \cite{beyer2020we} & ObjectNet \cite{barbu2019objectnet}\\ \hline MoCoV3 & 2.57 & 16.49 & 26.77 & 14.28 & 71.30 & 20.33 \\ DILEMMA & \bf 3.35 & \bf 17.32 & \bf 28.62 & \bf 15.91 & \bf 72.31 & \bf 20.51\\ \hline \end{tabular} } \end{table*} \subsection{Downstream Tasks} \noindent\textbf{Semantic Segmentation on ADE20K.} Semantic segmentation is a task that strongly relates to the shape of objects. Thus, we expect to see a significant improvement from a boost in the shape discriminability. The semantic segmentation capability of self-supervised methods is usually evaluated by fine-tuning the model with an extra decoder. For that we use UPerNet~\cite{xiao2018unified} on the ADE20K~\cite{zhou2017scene} dataset and train the model for $64K$ iterations with a batch size of 12. We also follow the evaluation protocol of iBOT~\cite{zhou2021ibot} and just train a linear layer (for $64K$ iterations and a batch size of 16) for semantic segmentation with a frozen backend to directly assess the per token representation. Results in Table~\ref{tab:semantic_segmentation} show that {DILEMMA} is also better than the base model for dense classification tasks and yields a remarkable mIoU gap of $4.6$ percentage points between {DILEMMA} and MoCoV3 in the linear settings. \begin{table*}[t] \centering \caption{Semantic Segmentation on ADE20K} \label{tab:semantic_segmentation} \centering \setlength{\tabcolsep}{4.0pt} \resizebox{0.6\textwidth}{!}{ \begin{tabular}{@{}lcccccc@{}} \toprule \multirow{2}{*}{Method} & \multicolumn{3}{c}{Seg. w/ Lin.} & \multicolumn{3}{c}{Seg. w/ UPerNet} \\ \cmidrule(lr){2-4}\cmidrule(lr){5-7} & mIoU & mAcc & aAcc & mIoU & mAcc & aAcc \\ \toprule MoCoV3 & 11.23 & 14.56 & 65.31 & 33.80 & 44.71 & 77.65\\ \midrule DILEMMA & \bf 15.90 & \bf 20.08 & \bf 67.46 & \bf 33.97 & \bf 44.73 & \bf 77.95\\ \bottomrule \end{tabular} } \end{table*}\\ \noindent\textbf{Transfer Learning.} In order to evaluate the transfer capability of our representations we do image classification on a diverse set of datasets. We again train a linear layer on top of the frozen features to accelerate the process. The results are in Table~\ref{tab:many_shot_evaluation}. As can be seen {DILEMMA} performs well in transfer learning across all datasets and significantly outperforms the base model in Yoga$_{82}$~\cite{verma2020yoga} (a yoga position classification dataset). Correctly classifying Yoga$_{82}$ images requires a solid understanding of object shape and texture alone is not sufficient. \begin{table*}[t] \centering \caption{Transfer learning for image classification} \label{tab:many_shot_evaluation} \resizebox{1.0\textwidth}{!}{ \begin{tabular}{clcccccccccccc|c} \toprule & & Aircraft & Caltech$_{101}$ & Cars & CIFAR$_{10}$ & CIFAR$_{100}$ & DTD & Flowers$_{102}$ & Food$_{101}$ & INat$_{19}$ & Pets & STL$_{10}$ & Yoga$_{82}$ & \multirow{2}{*}{Avg.} \\ & & \cite{maji13fine-grained} & \cite{FeiFei2004LearningGV} & \cite{KrauseStarkDengFei-Fei_3DRR2013} & \cite{Krizhevsky2009LearningML} & \cite{Krizhevsky2009LearningML} & \cite{cimpoi14describing} & \cite{Nilsback2008AutomatedFC} & \cite{bossard14} & \cite{inaturalist19} & \cite{parkhi12a} & \cite{Coates2011AnAO} & \cite{verma2020yoga} \\ \midrule \multirow{2}{*}{\rot{$k$-NN}} & MoCoV3 & 23.82 & 79.31 & 19.67 & \bf 90.87 & 70.98 & 59.84 & 81.40 & 57.89 & 26.67 & 74.22 & 94.08 & 32.73 & 59.29 \\ {} & DILEMMA & \bf 24.18 & \bf 80.72 & \bf 19.85 & 90.60 & \bf 72.60 & \bf 62.55 & \bf 84.45 & \bf 58.97 & \bf 28.68 & \bf 78.82 & \bf 94.75 & \bf 38.81 & \bf 61.14 \\ \midrule \midrule \multirow{2}{*}{\rot{Lin.$_{F}$}} & MoCoV3 & 43.53 & 87.77 & 48.39 & \bf 92.49 & 76.74 & \bf 64.89 & 93.07 & 70.38 & 44.09 & 84.55 & 95.72 & 59.92 & 71.79 \\ {} & DILEMMA & \bf 45.09 & \bf 89.37 & \bf 48.87 & 92.30 & \bf 77.50 & 64.41 & \bf 93.66 & \bf 71.41 & \bf 45.12 & \bf 86.02 & \bf 96.09 & \bf 63.49 & \bf 72.77 \\ \bottomrule \end{tabular} } \end{table*}\\ \noindent\textbf{Nearest Neighbor Retrieval.} Following the evaluation protocol of DINO~\cite{caron2021emerging}, we report the Mean Average Precision (mAP) for the Medium (M) and Hard (H) subsets of revisited Oxford and Paris retrieval datasets~\cite{radenovic2018revisiting} using a $k$-NN retriever. Results in Table~\ref{tab:retrieval} show that our results are comparable to the baseline, but, as it is explained in iBOT~\cite{zhou2021ibot}, this evaluation metric is hyper-parameter sensitive (image resolution, whether to use multi-scale evaluation or not) and we do not investigate it further. \begin{table}[t] \begin{minipage}[t]{.44\linewidth} \captionsetup{width=0.98\linewidth} \caption{Image retrieval. mAP on medium and hard subsets of the revisited Oxford and Paris retrieval datasets~\cite{radenovic2018revisiting}} \label{tab:retrieval} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular}{@{}l cc cc@{}} \toprule & \multicolumn{2}{c}{$\mathcal{R}$Ox} & \multicolumn{2}{c@{}}{$\mathcal{R}$Par} \\ \cmidrule{2-3} \cmidrule{4-5} Method & M & H & M & H\\ \midrule MoCoV3 & 26.02 & 7.16 & \bf 49.25 & \bf 19.52 \\ DILEMMA & \bf 26.14 & \bf 7.26 & 48.15 & 18.84 \\ \bottomrule \end{tabular} } \end{minipage} \hfill \begin{minipage}[t]{.5\linewidth} \captionsetup{width=0.98\linewidth} \caption{Unsupervised object segmentation. For DAVIS we report mean region similarity $\mathcal{J}_m$ and mean contour-based accuracy $\mathcal{F}_m$. For VOC12 we report Jaccard similarity} \label{tab:video} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular}{@{}lcccc@{}} \toprule {} & \multicolumn{3}{c}{DAVIS} & VOC12 \\ Method & $ (\mathcal{J}$\&$\mathcal{F})_m$ & $\mathcal{J}_m$ & $\mathcal{F}_m$ & Jac.$_{sim.}$\\ \midrule MoCoV3 & 58.28 & 57.46 & 59.09 & 46.50 \\ DILEMMA & \bf 60.00 & \bf 57.99 & \bf 62.02 & \bf 48.89 \\ \bottomrule \end{tabular} } \end{minipage} \end{table}\\ \noindent\textbf{Unsupervised Object Segmentation.} For single frame object segmentation we use the mask generated from the attention of the CLS token (thresholded to keep 0.9 of the mass) as in DINO~\cite{caron2021emerging} and report the Jaccard similarity between the ground truth and the mask evaluated on the validation set of PASCAL-VOC12~\cite{Everingham2009ThePV}. For the videos we use the DAVIS-2017 video instance segmentation benchmark~\cite{Pont-Tuset_arXiv_2017} and by following the protocol introduced in Space-time by Jabri et al.~\cite{jabri2020space} we segment scenes via the nearest neighbor propagation of the mask. Results in Table~\ref{tab:video} show that {DILEMMA} performs well also in these dense tasks. \subsection{Shape vs Texture Bias} We also evaluate the shape bias of {DILEMMA} according to the metrics defined by Geirhos et al.~\cite{geirhos2018imagenet} and Tartaglini et al.~\cite{tartaglini2022developmentally}. In Table~\ref{tab:shape_bias} (Texture Bias column) we fine-tune our ViT model pre-trained with {DILEMMA} on ImageNet and then measure the shape vs texture bias on the Cue-Conflicting dataset \cite{geirhos2018imagenet}. The reported Texture Bias indicates how often the model has preferred class discrimination based on texture rather than shape. The Linear Accuracy is obtained through fine-tuning on half of the Cue-Conflicting dataset and then tested on the other half. In Fig.~\ref{fig:shape_bias_analysis} we use instead a dataset \cite{tartaglini2022developmentally}, where the parameter \texttt{Alpha} indicates the degree of removal of the background ($0$ no removal, $1$ full removal). These metrics could be used as predictors of the quality of pre-trained models. This would allow the ranking of models without the need for extensive experimental validation, which now requires the transfer to several downstream tasks. However, the results in Table~\ref{tab:shape_bias} and Fig.~\ref{fig:shape_bias_analysis} seem to contradict this conclusion. In fact, {DILEMMA} appears to be more texture biased than the baseline, but its performance on a wide range of new tasks and in particular on shape-based tasks seems to be consistently better (see all other experiments). In fact, in the Linear Accuracy column we see that as soon as {DILEMMA} is trained on a shape-based task, it delivers a better performance than the baseline. We argue that perhaps the ability of a model to classify objects based on shape does not necessarily imply that they must have a weaker texture discriminability. In conclusion, to have a better predictor for generalization based on shape, it would be more desirable to have a shape discriminability measure that is somehow unrelated to texture. \begin{table*}[t] \begin{minipage}{0.45\linewidth} \centering \caption{Shape Bias. The Texture Bias is evaluated on the Cue-Conflicting dataset \cite{geirhos2018imagenet}. The Linear Accuracy is obtained through fine-tuning on half of the Cue-Conflicting dataset and then tested on the other half} \label{tab:shape_bias} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular}{@{}lcc@{}} \toprule Method & Texture Bias (\%) & Linear Acc. \\ \toprule MoCoV3 & \bf 63.58 & 59.89\\ \midrule DILEMMA & 69.10 & \bf 62.68\\ \bottomrule \end{tabular} } \end{minipage} \hfill \begin{minipage}{0.5\linewidth} \begin{subfigure}[b]{0.95\linewidth} \centering \includegraphics[width=\linewidth]{figures/alpha.png} \end{subfigure} \captionof{figure}{Shape bias Analysis \cite{tartaglini2022developmentally}. \texttt{Alpha} indicates the transparency of the background ($1$ means full transparency).} \label{fig:shape_bias_analysis} \end{minipage} \end{table*} \subsection{ViT Properties} In this section, we carry out experiments that are unique to the ViT architecture. \noindent\textbf{Robustness against Occlusions and Shuffle.} Since our model was trained with sparse inputs, we should expect a gradual loss of performance with increased sparsity. Fig.~\ref{fig:drop} shows that the performance drop for MoCoV3 is more severe than in {DILEMMA}. Moreover, {DILEMMA} is able to preserve its accuracy with larger sparsity ratios. In Table~\ref{tab:shuffle} we see that {DILEMMA} can be fed with completely wrong position encodings and still obtain a reasonable classification accuracy compared to MoCoV3. We explain this result as the consequence of training the model with mismatched positional embeddings. \begin{figure}[t] \centering \begin{minipage}{0.5\textwidth} \centering \begin{subfigure}[b]{1.0\textwidth} \centering \includegraphics[width=\linewidth]{figures/random_drop.png} \end{subfigure} \caption{Token Dropping Analysis. Classification accuracy of a pre-trained head as a function of input sparsity ratio.} \label{fig:drop} \end{minipage} \hfill \begin{minipage}{0.45\linewidth} \centering \captionsetup{type=table} \caption{Input shuffling effect. Classification accuracy of a pre-trained head with correct or random position encodings} \label{tab:shuffle} \centering \begin{tabularx}{\linewidth}{@{}l@{\hspace{1.5em}}c@{\hspace{1.5em}}c@{}} \toprule Method & Correct & Random \\ \toprule MoCoV3 & 63.8 & 26.1\\ \midrule DILEMMA & \bf 65.3 & \bf 45.1\\ \bottomrule \end{tabularx} \end{minipage} \end{figure} \noindent\textbf{Robustness against Background Change.} Following the background challenge evaluation metric~\cite{xiao2020noise}, we compute the classification accuracy of the model on a subset of ImageNet (IN-9) by changing the background and foreground. As shown in Table~\ref{tab:background}, in O/N.F. (Only/No Foreground), M.S/R/N. (Mixed Same/Random/Next), where the foreground is visible or accurately masked out, we outperform the base model. When the foreground is not visible (O.BB. (Only Background with foreground box Blacked out) and O.BT. (Only Background with foreground replaced with Tiled background)) the model performs correctly and does not just rely on the background for image classification. \begingroup \setlength{\tabcolsep}{4.pt} \begin{table}[t] \caption{Robustness of pre-trained models against background changes} \label{tab:background} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular}{@{}lcccccccc@{}} \multirow{2}{*}{Method} & \multicolumn{7}{c}{Background Change} & Clean \\ \cmidrule(lr){2-8}\cmidrule(lr){9-9} & \it O.F.$(\uparrow)$ & \it M.S.$(\uparrow)$ & \it M.R.$(\uparrow)$ & \it M.N.$(\uparrow)$ & \it N.F.$(\uparrow)$ & \it O.BB.$(\downarrow)$ & \it O.BT.$(\downarrow)$ & IN-9$(\uparrow)$\\ \toprule MoCoV3 & 77.26 & 78.05 & 64.96 & 64.07 & 38.02 & 9.36 & 10.72 & 91.53 \\ DILEMMA & \bf 77.75 & \bf 79.43 & \bf 67.63 & \bf 64.84 & \bf 38.79 & \bf 8.64 & \bf 9.33 & \bf 91.75 \\ \bottomrule \end{tabular} } \end{table} \endgroup \subsection{Ablations} Ablation studies are conducted either on ImageNet100 or ImageNet-1K. For the smaller dataset we train the dense models for 300 epochs and the sparse models for 450 epochs (with the same hardware and time settings). For ImageNet-1K experiments we train all models for 50 epochs unless stated otherwise.\\ \noindent\textbf{Image Size.} We compare a model trained on $112\times112$ images and a sparse model trained on $25\%$ of the tokens of $224\times224$ images. Results in Table~\ref{tab:image_size} show that simply feeding smaller images is worse than feeding sparse large inputs.\\ \noindent\textbf{Token Dropping Policy.} We tried dropping the tokens that were less important based on the attention of the teacher network~\cite{li2021mst} compared to randomly dropping the tokens. Results in Table~\ref{tab:drop_policy} show that simple random dropping works well and there is no need to introduce extra complexity to the model. \begin{table*}[t] \begin{minipage}[t]{0.45\linewidth} \caption{Sparsity vs smaller inputs. Results are evaluated on IN100} \label{tab:image_size} \centering \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}cr@{}} \toprule Input & $k$-NN & Linear\\ \hline Low Res. & 72.86 & 75.18\\ Sparse & \bf 73.98 & \bf 77.78\\ \bottomrule \end{tabular*} \end{minipage} \hfill \begin{minipage}[t]{0.5\linewidth} \caption{Token dropping policy. Results are evaluated on IN100} \label{tab:drop_policy} \centering \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}cr@{}} \toprule Sampling Method & $k$-NN & Linear\\ \hline Importance Based & 71.88 & 76.76\\ Random & \bf 73.98 & \bf 77.78\\ \bottomrule \end{tabular*} \end{minipage} \end{table*} \noindent\textbf{Random Dropping Ratio.} To verify that a random dropping ratio is better than a constant one, we conducted two experiments: one on IN100 and one on IN-1K. The results in Table~\ref{tab:random_drop_ratio} show that a random dropping ratio performs better than a constant one. On the more difficult IN-1K dataset just applying the sparsity is worse than using the dense model. Only with a random dropping ratio the sparse model can outperform the dense model.\\ \noindent\textbf{Mismatch Detection.} To verify that mismatch detection helps, we trained a dense model with the mismatch detection task. Results are in Table~\ref{tab:electra_helps}. Surprisingly, even though this is a trivial task (note that since only 20\% of the positions are mismatched, a model can easily achieve an 80\% accuracy in detecting the mismatches), the dense model can still improve the performance of the model. The performance improvement for a task like in $\text{Yoga}_{82}$, which requires a better understanding of shape, is quite significant. \begin{table*}[t] \begin{minipage}[t]{0.45\linewidth} \caption{Random Dropping Ratio. Results on the left are evaluated on IN100 and on the right on IN-1K} \label{tab:random_drop_ratio} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}cc|cc@{}} \toprule {} & \multicolumn{2}{c}{IN100} & \multicolumn{2}{c}{IN-1K}\\ Sparsity & $k$-NN & Linear & $k$-NN & Linear\\ \hline 0\% (Dense) & \bf 76.16 & 77.50 & 53.27 & 58.20\\ 75\% & 73.98 & 77.78 & 52.99 & 57.90\\ Random & 74.46 & \bf 78.82 & \bf 55.71 & \bf 59.55\\ \bottomrule \end{tabular*} } \end{minipage} \hfill \begin{minipage}[t]{0.5\linewidth} \caption{Mismatch Detection (MD)} \label{tab:electra_helps} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}cc|cc|c@{}} \toprule {} & \multicolumn{2}{c}{IN-1K} & \multicolumn{2}{c}{Yoga82} & {}\\ {} & $k$-NN & Linear & $k$-NN & Linear & MD Acc.\\ \hline Dense & 53.27 & 58.20 & 31.60 & 51.27 & -\\ +MD & 54.18 & 58.78 & 35.78 & 54.53 & 100.00\\ \hline Rand. & \bf 55.71 & 59.55 & 32.73 & 50.9 & -\\ +MD & 55.63 & \bf 59.84 & \bf 35.94 & \bf 57.26 & 96.21\\ \bottomrule \end{tabular*} } \end{minipage} \end{table*} \noindent\textbf{Skip Dense.} In order not to encourage the model to use the tile edge shortcut, we disabled the calculation of the {DILEMMA} loss when the sparsity ratio is zero (the input is dense). Table~\ref{tab:skip_dense} shows that this choice helps (though only marginally). Thus, we use it in all of our main results.\\ \noindent\textbf{{DILEMMA} Variants.} We also tried some variants of DILEMMA. Instead of just detecting the misplaced tokens, we predict the right position (as a classification task of $196$ classes). The other variant, which we call \emph{Partial Jigsaw}, is to feed some tokens without position encoding and ask the network to predict their position given the other (sparse) correctly position-encoded tokens. Lastly, instead of corrupting the position, one can corrupt the content of a patch. Instead of using complex methods like inpainting we simply horizontally flip some of the patches and use the binary cross-entropy as our loss. Table~\ref{tab:task_variants} shows that even though all of these methods do help in terms of shape discrimination, {DILEMMA} is the one with the best performance both on IN-1K and $\text{Yoga}_{82}$. \begin{table*}[t] \begin{minipage}[t]{0.35\linewidth} \caption{Skip Dense. Results are evaluated on IN100} \label{tab:skip_dense} \centering \begin{tabular}{lcc} \toprule {} & $k$-NN & Linear\\ \midrule No Difference & 76.04 & 79.94\\ Skip on Dense & \bf 76.34 & \bf 80.56\\ \bottomrule \end{tabular} \end{minipage} \hfill \begin{minipage}[t]{0.6\linewidth} \caption{Variants of the loss. Although the variants improve the performance wrt the base dense model, {DILEMMA} is the most effective one} \label{tab:task_variants} \centering \begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}cc|cc@{}} \toprule {} & \multicolumn{2}{c}{IN-1K} & \multicolumn{2}{c}{Yoga82}\\ Task & $k$-NN & Linear & $k$-NN & Linear\\ \hline Pos. Correction & 54.77 & 58.95 & 35.74 & 56.15\\ Partial Jigsaw & \bf 55.72 & 59.19 & 34.77 & 56.79\\ Flip Detection & 55.69 & 59.59 & 35.09 & 55.00\\ DILEMMA & 55.63 & \bf 59.84 & \bf 35.94 & \bf 57.26\\ \bottomrule \end{tabular*} \end{minipage} \end{table*} \noindent\textbf{Mismatch Probability.} The probability of mismatch $\theta$ is one of the most important hyper-parameters of {DILEMMA}. Early in our experiments, we found out that 20\% is much better than 15\%. In Table~\ref{tab:mismatch_prob} we show that 30\% yields worse performance than the default 20\%.\\ \noindent\textbf{Timing.} We measure the time for an epoch of pre-training on ImageNet100 with three GeForce RTX 3090 GPUs and the maximum batch size possible. Note that we multiply the number of batches proportional to the sparsity ratio and the reported number is for dense batches. Results in Table~\ref{tab:timing} show that {DILEMMA} is $1.5\times$ faster than MoCoV3 due to a larger average batch size. \begin{table*}[t] \begin{minipage}[t]{0.5\linewidth} \caption{Mismatch Probability} \label{tab:mismatch_prob} \centering \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}cc|cc@{}} \toprule {} & \multicolumn{2}{c}{IN-1K} & \multicolumn{2}{c}{Yoga82}\\ Prob. & $k$-NN & Linear & $k$-NN & Linear\\ \hline 0.3 & 55.34 & 59.79 & 34.95 & 56.63\\ 0.2 & \bf 55.63 & \bf 59.84 & \bf 35.94 & \bf 57.26\\ \bottomrule \end{tabular*} \end{minipage} \hfill \begin{minipage}[t]{0.45\linewidth} \caption{Training Times} \label{tab:timing} \centering \resizebox{1.0\textwidth}{!}{ \begin{tabular*}{\linewidth}{@{}l@{\extracolsep{\fill}}|c|c@{}} \toprule Method & Time(Sec.) & Batch Size\\ \hline DINO & 218 & 480\\ MoCoV3 & 335 & 345\\ DILEMMA & 223 & 345\\ \bottomrule \end{tabular*} } \end{minipage} \end{table*} \section{Conclusions} We introduced a novel SSL method based on a location classification pseudo-task and a contrastive loss. We showed that awareness of the relative location of tiles of the input image is important for generalization and in particular when fine-tuning on shape-based downstream tasks. We observe also that current indicators of shape bias for pre-trained models may not always be predictive of the performance of such models on novel shape-based tasks. Our method is based on the ViT architecture. We introduce sparsity in the input (\emph{i.e.}, dropping image tiles), to both speed up the training and also to avoid trivial degenerate learning. \begin{table*}[t] \centering \caption{ImageNet classification results on 224$\times$224 Images w/o extra data. An epoch is calculated based on the number of full images processed during pre-training~\cite{zhou2021ibot}, and non integer multipliers indicate usage of multi cropping~\cite{caron2020unsupervised}. AUG means extra data augmentations (different from~\cite{Grill2020BootstrapYO}), HED means more heads in the vision transformer compared to the base model, CLS indicates usage of more than just the last CLS token as the representation of the image, DAL indicates usage of DALLE's encoder~\cite{ramesh2021zero}, and RRC indicates only random resized cropping and random horizontal flipping as data augmentations. $\dagger$ indicates a linear layer trained without data augmentation} \label{tab:imagenet_others} \resizebox{0.91\textwidth}{!}{ \begin{tabular}{lccccccc|c} \toprule Method & Architecture & EffectiveEpoch & BatchSize & $k$-NN & Linear & Fine-tune & Source & Notes \\ \midrule DINO & ViT-S & 100x2 & 128 & 57.9 & - & - & \cite{caron2021emerging} & - \\ DINO & ViT-S & 100x2 & 256 & 59.1 & - & - & \cite{caron2021emerging} & - \\ MoCoV3 & ViT-S & 100x2 & 345 & 60.1 & 65.1 & - & - & HED \\ DILEMMA & ViT-S & 100x2 & 345 & 61.7 & 66.6 & - & - & HED \\ DILEMMA & ViT-S & 150x2 & 345 & 63.4 & 67.2$^\dagger$ & - & - & HED \\ DINO & ViT-S & 100x2 & 480 & 61.6 & 64.6$^\dagger$ & - & - & - \\ DINO & ViT-S & 100x2 & 512 & 59.6 & - & - & \cite{caron2021emerging} & - \\ DINO & ViT-S & 100x2 & 1024 & 59.9 & 67.8 & - & \cite{caron2021emerging} & CLS \\ \midrule \midrule SimCLR & ViT-S & 300x2 & 1024 & - & 69.0 & - & \cite{chen2021empirical} & HED \\ BYOL & ViT-S & 300x2 & 1024 & 66.6 & 71.4 & - & \cite{caron2021emerging} & - \\ SwAV & ViT-S & 300x2 & 1024 & 60.5 & 68.5 & - & \cite{caron2021emerging} & - \\ SwAV & ViT-S & 300x3.1 & 1024 & 64.7 & 71.8 & - & \cite{caron2021emerging} & - \\ MoBY & ViT-S & 300x2 & 512 & - & 72.8 & - & \cite{xie2021self} & - \\ MoCoV2 & ViT-S & 300x2 & 1024 & 62.0 & 71.6 & - & \cite{caron2021emerging} & - \\ MoCoV2 & ViT-S & 300x3.1 & 1024 & 65.4 & 73.4 & - & \cite{caron2021emerging} & - \\ MoCoV3 & ViT-S & 300x2 & 1024 & - & 72.5 & - & \cite{chen2021empirical} & HED \\ MoCoV3 & ViT-S & 300x2 & 4096 & - & 73.2 & 81.4 & \cite{chen2021empirical} & HED \\ MoCoV3 & ViT-S & 600x2 & 1024 & - & 73.4 & - & \cite{chen2021empirical} & HED \\ TWIST & ViT-S & 300x3.1 & 1024 & - & 76.3 & - & \cite{wang2021self} & - \\ DINO & ViT-S & 300x2 & 1024 & 67.9 & 72.5 & - & \cite{caron2021emerging} & - \\ DINO & ViT-S & 100x3.5 & 512 & 69.3 & 74.0 & - & \cite{caron2021emerging} & CLS \\ DINO & ViT-S & 300x3.1 & 1024 & 72.7 & 75.9 & - & \cite{caron2021emerging} & - \\ DINO & ViT-S & 300x3.5 & 1024 & 73.3 & 76.0 & - & \cite{caron2021emerging} & CLS \\ DINO & ViT-S & 800x3.8 & 1024 & 74.5 & 76.1 & 82.0 & \cite{caron2021emerging} & - \\ DINO & ViT-S & 800x3.8 & 1024 & 74.5 & 77.0 & 82.0 & \cite{caron2021emerging} & CLS \\ iBOT & ViT-S & 800x2 & 1024 & 72.4 & 76.2 & - & \cite{zhou2021ibot} & CLS \\ iBOT & ViT-S & 800x3.8 & 1024 & 75.2 & 77.9 & 82.3 & \cite{zhou2021ibot} & CLS \\ SplitMask & ViT-S & 300x2 & 1024 & - & - & 81.5 & \cite{el2021large} & RRC \\ CIM & ViT-S & 300x1 & 2048 & - & - & 81.6 & \cite{Fang2022CorruptedIM} & DAL, RRC \\ BEiT & ViT-S & 300x1 & 1024 & - & - & 81.7 & \cite{zhou2021ibot} & DAL \\ CAE & ViT-S & 300x1 & 2048 & - & 50.8 & 81.8 & \cite{chen2022context} & RRC \\ \midrule Supervised & ViT-S & 300x1 & 1024 & - & - & 79.8 & \cite{touvron2021training} & - \\ \midrule \midrule DINO & ViT-B/8 & 300x3.8 & 1056 & 77.4 & 80.1 & - & \cite{caron2021emerging} & - \\ DINO & XCiT-M/8 & 300x3.5 & 1024 & 77.9 & 80.3 & - & \cite{ElNouby2021XCiTCI} & - \\ SimCLRv2 & ResNet152x3-SK & 800x2 & 4096 & - & 79.8 & 80.5 & \cite{chen2020big} & - \\ ReLICv2 & ResNet200x2 & 1000x4.4 & 4096 & - & 80.6 & - & \cite{tomasev2022pushing} & AUG \\ MoCoV3 & ViT-L/16 & 300x2 & 4096 & - & 77.6 & 84.1 & \cite{chen2021empirical} & - \\ MoCoV3 & ViT-BN/7 & 300x2 & 4096 & - & 81.0 & - & \cite{chen2021empirical} & - \\ EsViT & Swin-B/w14 & 300x3.5 & 1536 & 79.3 & 81.3 & - & \cite{li2021efficient} & CLS, AUG \\ iBOT & ViT-L/16 & 250x3.8 & 1024 & 77.7 & 81.3 & 85.0 & \cite{zhou2021ibot} & CLS \\ MAE & ViT-H & 1600x1 & 4096 & - & 77.2 & 86.9 & \cite{he2021masked} & - \\ PeCo & ViT-H & 800x1 & 2048 & - & - & 87.5 & \cite{dong2021peco} & - \\ \bottomrule \end{tabular} } \end{table*} \begin{ack} This work was supported by grant 200020\_188690 of the Swiss National Science Foundation. \end{ack} \clearpage \bibliographystyle{splncs04}
{'timestamp': '2022-04-12T02:28:05', 'yymm': '2204', 'arxiv_id': '2204.04788', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04788'}
arxiv
\section{Introduction} Many models of scientific computing and engineering are very expensive to evaluate, and yet the number of points needed to explore the entire area can be prohibitive, especially in high dimensional space, which is the famous \emph{curse of dimensionality problem}. The model complexity and computational cost both increase dramatically in this situation. At this point, dimension reduction techniques come to our rescue by discovering and employing the low-dimensional structure in the problem itself. A brief description about dimension reduction is that if the conditional distribution of the quantities of interest $Y$ given inputs $X$ depends on $X$ only through a matrix $\beta$ in the form of $\beta^TX$. Then the so-called dimension reduction space is spanned by the column of matrix $\beta$. The central subspace is the smallest such dimension reduction space. The details can be found in \cite{dimensionreduction}. There are various methods on finding such central space. For example, the principle component analysis (PCA) in \cite{pca} is the most famous unsupervised dimension reduction method. Many other techniques are developed based on different constructions to deal with different tasks. In this paper, we consider the supervised dimension reduction problems, in which the response $Y$ is often a scalar. Previous works relating to this type of problems can be found in \cite{acs, cr, SIR, InReUQ, save, GPbDR}. The sliced inverse regression (SIR) proposed in \cite{SIR} and the sliced average variance estimation (SAVE) proposed in \cite{save} type of methods are very popular among all supervised dimension reduction techniques. Interested readers may refer to \cite{dimensionreduction} for a more comprehensive review of this topic. However those methods may not work well in the situation where available data come from models of different fidelity levels, thus high-fidelity data are insufficient and expensive to obtain. The authors in \cite{BIRsd} proposed a Bayesian approach to compute the conditional distribution $\pi(\bold{x}|y)$ of the predictors $\bold{x}$ given the response variable $y$ in order to perform dimension reduction. The likelihood function in their method is obtained by using the Gaussian process regression model. Then $\pi(\textbf{x}|y)$ can be computed by Monte Carlo sampling. However, the Gaussian process model may not work well when the accurate observations are vary rare or the observations come from different fidelity levels thus affecting the performance of the dimension reduction. In this paper a rotated multi-fidelity Gaussian process is combined with SAVE type of methods to perform dimension reduction in this situation and a more accurate surrogate model can be obtained afterwards. Multi-fidelity modelling aims at combining the information in the low-fidelity models that can be inaccurate but inexpensive with that in the high-fidelity model which is computationally demanding. Peherstorfer et al. \cite{Pesurvey} give a complete review of multi-fidelity modelling methods with a focus on the application of uncertainty propagation, statistical inference and optimization. Among all different multi-fidelity modelling approaches, the one based on the Gaussian process regression \cite{CEGP} has been frequently used. The auto-regressive scheme put forth by Kennedy and O'Hagan \cite{autoregressive} exploits the linear correlation between the high-fidelity and low-fidelity models to improve the prediction accuracy. An efficient recursive implementation by Le Gratiet and Garnier \cite{Le} considerably reduces the complexity of the original auto-regressive scheme. However, there exists no simple linear correlations between different fidelity models or the linear correlations only exist in a specific range of inputs in many practical problems of interest. In those cases, the auto-regressive scheme tends to ignore the low-fidelity data and may return inaccurate predictions. To address this type of problems, Perdikaris et al. \cite{NARGP} proposed a nonlinear information fusion algorithm based on the auto-regressive scheme and the idea of Le Gratiet and Garnier \cite{Le}. It not only allows to learn complex nonlinear correlations between different fidelity models but also works in situations where only linear correlation exists. Since the high-fidelity model are usually computationally demanding, an active learning scheme is often needed for the problem with limited budget. The previous works relate to active learning can be found in \cite{AL1, AL3, AL2, AL4}. For simplicity, only two fidelity levels are considered in this paper but the method can be easily extended to the cases more than two fidelity levels. In the first step of our method, a rotation matrix can be obtained based on the training data from low-fidelity model by using SAVE method and all training data are rotated by this matrix. This step aims at extracting some meaningful information from the low-fidelity data before feeding training data into the proposed multi-fidelity model and is proved to be useful in the numerical examples. Now, the nonlinear information fusion algorithm by Perdikaris et al. \cite{NARGP} is used as the building block of our multi-fidelity model and the predictions on pre-set test points can be obtained. With those predictions, SAVE method is employed again to find a rotation matrix. At this point, our trained multi-fidelity model can be less accurate due to lack of high quality data or it can be improved by expanding the realizations of high-fidelity model if the budget permits. This can be achieved by introducing an active learning scheme based on the problem setting. Once the stop criterion in the active learning scheme is reached, the rotation matrix in this step can be determined. The final dimensional reduction matrix and a surrogate model for the original problem will be deduced differently depending on an user defined parameter $flag$. If $flag = 0$, then the data for the final surrogate model are simply rotated by the rotation matrix from the last step and fed into a Gaussian process model. If $flag = 1$, the number of sufficient dimensions can be computed by Bayesian information criterion(BIC) method based on the trained rotated multi-fidelity model. The final dimensional reduction matrix is computed by combining the previous model and a Gaussian process dimension reduction technique with similar idea in \cite{GPbDR}. However the method in \cite{GPbDR} cannot be directly applied to our problem because the amount of high-fidelity data is not enough for the optimization process. The previous RMFGP model first reduced the number of original dimensions $p$ to $s$. Then a two-step Gaussian process optimization process is performed to find a reduction matrix to further reduce the number of dimensions to $d$ which is pre-computed by BIC. In the end, a new surrogate model for the original supervise dimension reduction problem, i.e. a Gaussian process model can be constructed using the data pre-processed by the final dimension reduction matrix. In this way, a rotated multi-fidelity Gaussian process model(RMFGP) is obtained and the inference process can be performed in two ways depending on the needs of the user. Our objective of this paper: \begin{enumerate} \item Find the intrinsic dimension in supervised dimension reduction problems with relatively small data set. \item Build an accurate surrogate model for high-dimensional problems with limited high-fidelity data. \end{enumerate} Our contribution in this paper: \begin{enumerate} \item A rotated multi-fidelity Gaussian process(RMFGP) model is proposed for high-dimensional problems with insufficient training data and the general workflow(Figure $1$) is developed. \item The RMFGP model is combined with a two-step Gaussian process optimization process(Algorithm $3$) to find the final dimension reduction matrix. The BIC method(Section $2.4$) is applied to determine the reduced dimension. \item An active learning scheme(Section $2.6$) in multi-fidelity GP is performed to improve the prediction accuracy of the RMFGP model. In the situation when high-fidelity data are rare and expensive to obtain, this is crucial for model performance. \item Depending on the needs of the user, an accurate surrogate Gaussian process model for the original problem can be built based on the proposed dimension reduction method (Algorithm $4$). If the parameter $flag=0$, then the inputs are simply rotated by the matrix deduced from RMFGP. Otherwise the parameter $flag=1$, the inputs are projected onto a low-dimensional space by the final dimension reduction matrix. The model performance is illustrated in four numerical examples. \end{enumerate} The paper is organized as follows. In Section 2, we give a brief introduction to the famous Gaussian process regression(GPR) and the multi-fidelity GPR model with nonlinear auto-regressive scheme. Then the SAVE dimension reduction method and Bayesian active learning scheme are briefly reviewed. In Section 3, our algorithm is proposed and in Section 4, four different numerical examples are presented to illustrate our methods. The uncertainty propagation analysis in two stochastic PDE examples are also conducted. We summarize our findings and provide some discussions in Section 5. \begin{figure} \centering \includegraphics[scale=0.35]{flowchart_tmp1.png} \caption{\textbf{A general framework for solving high-dimensional problems with insufficient data - an overview of the workflow.} In this work, we first propose a rotated multi-fidelity Gaussian process model, in which the training data are rotated using the matrix computed by SAVE method before feeding to multi-fidelity GP model. Then, a generalization error analysis is performed. If the criterion is not fulfilled, a Bayesian active learning scheme is applied to add more high-fidelity data to training data set. Otherwise we obtain our RMFGP model. This model can be used to generate samples for computing a rotation matrix by SAVE method. If reduction parameter $flag=0$, a final GP model is built with input data rotated by this rotation matrix. If reduction parameter $flag=1$, the BIC method is used to compute the final reduced dimension and then a two-step GP dimension reduction process is conducted to find the final reduction matrix. In this way, a GP model can be built with input data which are first projected onto a low-dimensional space by the final reduction matrix.} \label{fig:flowchart} \end{figure} \section{Methodology} Let $f: \mathcal{R}^p \rightarrow \mathcal{R}$ be a multivariate scalar function of $\bold{x}$ with input dimension $p>> 1$. Assume $f$ can be measured by a series of physical experiments with different accuracy or models with different computational cost. Furthermore, we allow for noisy measurements. So the observations have different levels of fidelity $t = 1,\cdots,r$. At each fidelity level $t$, the set of inputs is denoted by $D_t$. The set $D_r$ is the highest level and the corresponding response function $f_r$ is referred to as high-fidelity model. In this work, suppose $f_r$ has or can be approximated by the form, $$ f_r(\bold{x}) \approx g(\bold{A}\bold{x}) $$ where the matrix $A$ projects $\bold{x}$ to a low dimensional subspace. The goal of this paper is to construct an accurate model to determine the dimensional reduction matrix $A$ and a surrogate for the low dimensional map $g$. This is a supervised dimension reduction problem and we assume the observation set $D_r$ is relatively small and directly applying SAVE type of methods can perform poorly due to the lack of information in a limited high-fidelity data set. The first step is to construct an accurate rotated multi-fidelity model for the original high dimensional problem. The building blocks are the famous Gaussian process and the so-called nonlinear information fusion algorithm in \cite{NARGP}. \subsection{Gaussian process regression framework} The introduction in this section is based on \cite{CEGP}. Interested readers can find a more thorough discussion in this book. Suppose there is an unknown mapping $z$: $$y = z(\mathbf{x})$$ where $\mathbf{x} \in \mathcal{R}^p$ and $p$ is the input dimension. The observations set can be denoted by $D = \{\mathbf{x}_i, y_i\}_{i=1}^n = (\mathbf{X}, \mathbf{y})$. In the Gaussian process framework, $z(\mathbf{x})$ is assumed to be a zero mean GP, i.e. $z \sim \mathcal{GP}(\mathbf{z}|\mathbf{0}, k(\mathbf{x}, \mathbf{x}';\mathbf{\theta})) $, where $k$ is an appropriate kernel function with a set of hyper-parameters $\mathbf{\theta}$. This assumption essentially reflects our prior belief about the function $z$. If we assume a Gaussian likelihood, the optimal hyper-parameters in the kernel can be found by maximizing the marginal log-likelihood of the model, $$ \mbox{log} p(\mathbf{y} | \mathbf{x}, \theta) = -\frac{1}{2} \mbox{log} |\mathbf{K}| - \frac{1}{2} \mathbf{y}^T \mathbf{K}^{-1} \mathbf{y} - \frac{n}{2} \mbox{log} 2\pi $$ where $\mathbf{K} = (K_{ij})_{i,j = 1}^n$ and $K_{ij} = k(\mathbf{x}_i,\mathbf{x}_j;\theta)$. The posterior distribution is thus tractable and the prediction for a new output $z_*$ at a new input $\mathbf{x}_*$ is given as $$ p(z_* | \mathbf{y}, \mathbf{X}, \mathbf{x}_*) = \mathcal{N}(z_*|\mu_*(\mathbf{x}_*), \sigma^2_*(\mathbf{x}_*)) $$ \begin{equation} \mu_*(\mathbf{x}_*) = \mathbf{k}_{*n} \mathbf{K}^{-1} \mathbf{y} \end{equation} \begin{equation} \sigma^2_*(\mathbf{x}_*) = \mathbf{k}_{**} - \mathbf{k}_{*n} \mathbf{K}^{-1} \mathbf{k}_{*n}^T \end{equation} where $\mathbf{k}_{**} = k(\mathbf{x}_*, \mathbf{x}_*)$ and $\mathbf{k}_{*n} = [k(\mathbf{x}_*, \mathbf{x}_1), \cdots, k(\mathbf{x}_*, \mathbf{x}_n)]$. The posterior mean $\mu_*(\mathbf{x}_*)$ is the output of the model and the posterior variance quantified the uncertainties of the model about the predictions. \subsection{Multi-fidelity Gaussian process with linear auto-regressive scheme} To this end, suppose the data have $r$ levels of fidelity. At each level $t$, the output $y_t(\mathbf{x}_t)$ corresponding to each input $\mathbf{x}_t$ can be modeled by a Gaussian processes $Z_t(\mathbf{x}), t = 1, \cdots, r$. Then, the linear auto-regressive scheme is $$ Z_t(\mathbf{x}) = \rho Z_{t-1}(\mathbf{x}) + \delta_t(\mathbf{x}), \hspace{2mm} t = 2,\cdots, r$$ where $\rho$ is the correlation coefficient between level $t-1$ and level $t$, $\delta_t(\mathbf{x})$ is a Gaussian process with mean $\mu_{\delta_t}$ and covariance function $k_t$. This construction implies the Markov property according to Kennedy and O'Hagan \cite{autoregressive}, which means there are nothing more about $Z_t(\mathbf{x})$ can be learned from other model $Z_{t-1}(\mathbf{x'})$, for $\mathbf{x'} \neq \mathbf{x}$. A more numerically efficient recursive scheme is proposed by Le Gratiet and Garnier \cite{Le}. Suppose that the data sets have a nested structure, $i.e. D_1 \subseteq D_2 \subseteq \cdots \subseteq D_r$, this special scheme is derived by replacing the GP prior $Z_{t-1}(\mathbf{x})$ with the previous inference posterior $Z_{*t-1}(\mathbf{x})$. In this way, the problem becomes $r$ standard Gaussian process regression problems. So the resulting multi-fidelity posterior distribution can be denoted by $p(Z_t | \mathbf{y}_t, \mathbf{x}_t, Z_{*t-1}(\mathbf{x})), t = 1, \cdots, r$. The predictive mean and variance at each level are \begin{equation} \mu_{*t}(\mathbf{x}_*) = \rho \mu_{*t-1}(\mathbf{x}_*) + \mu_{\delta_t} + \mathbf{k}_{*n_t}\mathbf{K}^{-1}_t[\mathbf{y}_t - \rho \mu_{*t-1}(\mathbf{x}_t) - \mu_{\delta_t}] \end{equation} and \begin{equation} \sigma_{*t}^2(\mathbf{x}_*) = \rho^2 \sigma_{*t-1}^2(\mathbf{x}_*) + \mathbf{k}_{**} - \mathbf{k}_{*n_t} \mathbf{K}^{-1}_t \mathbf{k}_{*n_t}^T \end{equation} where $n_t$ is the number of training points in data $D_t$ and $t$ denote the fidelity level. \subsection{Multi-fidelity Gaussian process with nonlinear information fusion algorithm} The above linear auto-regressive scheme is generalized in \cite{NARGP} as $$ Z_t(\mathbf{x}) = g_{t-1}(Z_{t-1}(\mathbf{x})) + \delta_t(\mathbf{x}), $$ where $g_{t-1}$ is an unknown function quantifying the correlation between lower fidelity model and the higher one. Another GP prior is assigned to this function. However, the posterior distribution of $Z_t$ is not Gaussian anymore. This is the so-called deep GP in \cite{dGP2,dGP1}. At this point, the GP prior $Z_{t-1}$ is replaced by the previous inference result $Z_{* t-1}(\mathbf{x})$. In this way, using the additive structure of the scheme and the independence assumption between GPs $Z_{t-1}$ and $\delta_t$, which follows the construction assumption in \cite{autoregressive}, the above equation can be summarized as $$ Z_t(\mathbf{x}) = h_t(\mathbf{x}, Z_{*t-1}(\mathbf{x})), $$ where $h_t \sim \mathcal{GP}(\mathbf{Z}_t|\mathbf{0}, k_t((\mathbf{x}, Z_{*t-1}(\mathbf{x})), (\mathbf{x}', Z_{*t-1}(\mathbf{x}'));\mathbf{\theta}_t))$. Essentially, this is a $(p+1)$ dimensional map which represents the relationship between the input space, the outputs of lower fidelity level model and the outputs of higher fidelity level model. The covariance kernel of the GP $h_t$ has a corresponding structure: $$ k_{t_h} = k_{t_{rho}}(\mathbf{x}, \mathbf{x}';\theta_{t_{rho}}) \cdot k_{t_z}(Z_{*t-1}(\mathbf{x}), Z_{*t-1}(\mathbf{x}');\theta_{t_z}) + k_{t_{\delta}}(\mathbf{x}, \mathbf{x}';\theta_{t_{\delta}}) $$ The predictive posterior distribution of the first level of the above scheme is Gaussian but this is not the case for the remaining levels. So the predictive mean and variance are computed by using Monte Carlo integration of this following posterior distribution for $t \geq 2$: \begin{equation} \begin{split} p(Z_{*t}(\mathbf{x}_*)) & := p(Z_t(\mathbf{x}_*, Z_{*t-1}(\mathbf{x}_*))| Z_{*t-1}, \mathbf{x}_*,\mathbf{y}_t, \mathbf{x}_t) \\ & = \int p(Z_t(\mathbf{x}_*, Z_{*t-1}(\mathbf{x}_*))|\mathbf{x}_*,\mathbf{y}_t, \mathbf{x}_t) p(Z_{*t-1}(\mathbf{x}_*)) d\mathbf{x}_* \end{split} \end{equation} More details can be found in \cite{NARGP}. \subsection{Dimension reduction methods} Dimension reduction is a popular topic in uncertainty quantification. Most dimension reduction methods are aimed at estimating the central sufficient dimension reduction subspace. \begin{definition}{Dimension reduction:} given a response scalar function $y = f(\bold{\xi})$, where $\xi=[\xi_1\dots\xi_p]^T$, a dimension reduction can be defined as a mapping from the $p$-dimensional input to a $d$-dimensional vector, i.e. $\eta = A\xi$, where $A\in R^{d \times p}, d<p$ and $AA^T = I$ is the identity matrix. \end{definition} \theoremstyle{definition} \begin{definition}{Sufficient dimension reduction subspace (SDR subspace):} let $X:\Omega\rightarrow R^p$ be a random vector. Let $Y:\Omega\rightarrow R$ be a random variable. The matrix $span(\beta)\in R^{p \times d}$ where $d<p$ is called a SDR subspace if $$ X\perp \!\!\! \perp Y|\beta^TX$$ \end{definition} \begin{definition}{Central SDR subspace:} the central SDR subspace or the central subspace is defined as the intersection of all SDR subspaces, and is written as $S_{Y|X}$. \end{definition} Once an estimation of central subspace matrix $A$ is obtained. We can define $\eta = A\xi$, then the function $y=f(\xi)$ can be rewritten into: $$ y = f(\xi) \approx f(A^TA\xi) = f(A^T\eta) = g(\eta) $$ So the original model is reduced into a $d$-dimensional model where $d<p$ in this way. Sliced inverse regression(SIR) and Sliced average variance estimation(SAVE) are two commonly used methods to estimate central subspace by approximating the conditional expectation $E(\xi|Y)$ and conditional variance $E(\xi\xi^T|Y)$. The detail information and the software package implementation is available at \cite{SReduR}. The two methods are shown in Algorithm 1 and Algorithm 2. In all numerical examples, we use SAVE method to conduct necessary computations but it can be easily replaced with SIR or other similar methods. \begin{algorithm} \caption{Sliced Inverse Regression(SIR)} \begin{algorithmic} \STATE 1. Compute the sample mean and sample variance:$$\hat{\mu}=E_n(X),\hat{\sigma}=var_n(X).$$ and compute the standardized random vectors $$Z_i=\hat{\Sigma}^{-1/2}(X_i-\hat{\mu}), i=1,\dots,n.$$ \STATE 2. Discretize $Y$ as $\hat{Y} = \sum_{h=1}^H hI(Y\in J_h)$, where a collection of intervals $\{ J_1,\dots,J_h\}$ is a partition of $Y_i$. \STATE 3. Approximate $E[Z|\hat{Y}\in J_h]$ or $E[Z|Y\in J_h]$ by $$ E_n(Z|Y\in J_h) = \frac{E_n[ZI(Y\in J_h)]}{E_n[I(Y\in J_h)]}, l=1,\dots,H $$ \STATE 4. Approximate $var[E(Z|\hat{Y})]$ by $$ M=\sum_{h=1}^H E[I(Y\in J_h)]E_n(Z|Y\in J_h)E_n(Z^T|Y\in J_h)$$ \STATE 5. Let $\hat{v}_1,\dots,\hat{v}_d$ be the first $d$ eigenvectors of $M$, let $\hat{\beta}_k = \hat{\Sigma}^{-1/2}\hat{v}_k$,$k=1,\dots,d$. The SDR predictors are $[\hat{\beta}_1^T(X_1-\hat{\mu}),\dots, \hat{\beta}_d^T(X_d-\hat{\mu})]$. \end{algorithmic} \end{algorithm} \begin{algorithm} \caption{Sliced Average Variance Estimation(SAVE)} \begin{algorithmic} \STATE 1. Standardize $X_1,\dots, X_n$ to obtain $Z_i$ as in Algorithm 1. \STATE 2. Discretize $Y$ as $\hat{Y} = \sum_{h=1}^H hI(Y\in J_h)$, where a collection of intervals $\{ J_1,\dots,J_h\}$ is a partition of $Y_i$. \STATE 3. For each slice $J_h$, compute the sample conditional variance of $Z$ given $Y\in J_h$: $$ var_n(Z|\hat{Y}=h)= \frac{E_n[ZZ^TI(\hat{Y}=h)]}{E_n[I(\hat{Y}=h)]} $$ \STATE 4. Compute the sample version of $M$:$$ M = H^{-1}\sum_{h=1}^H E_nI(\hat{Y}=h)[I_p - var_n(Z|\hat{Y}=h)]^2 $$ \STATE 5. Let $\hat{v}_1,\dots,\hat{v}_d$ be the first $d$ eigenvectors of $M$, let $\hat{\beta}_k = \hat{\Sigma}^{-1/2}\hat{v}_k$,$k=1,\dots,d$. The SDR predictors are $[\hat{\beta}_1^T(X_1-\hat{\mu}),\dots, \hat{\beta}_d^T(X_d-\hat{\mu})]$, where $\hat{\mu} = E_n(X)$. \end{algorithmic} \end{algorithm} A challenge in the dimension reduction problem is the determination of the reduced dimension $d$. In this paper we choose the Bayesian information criterion (BIC) introduced in \cite{SReduR}. Let $\lambda_1\geq\lambda_2\geq\dots\geq\lambda_p$ be the eigenvalues of the $\hat{V} + I $, where $\hat{V}$ is the co-variance matrix in SIR/SAVE algorithm. Assume $\hat{V}$ is positive semi-definite, we have $\lambda_i\geq 1$ for all $i\leq p$. Let \begin{equation} G(k) = \frac{n}{2} \sum_{l=1+k}^p (log\lambda_l + 1 -\lambda_l) - C_nk(2p-k+1)/2 \end{equation} where $C_n$ is a sequence satisfying the condition in Theorem 2 of \cite{Ona}. Then the number of dimensions $d$ is approximated by: $$ d = arg max{G(k): k = 1,\cdots, p-1} $$ In the last step of our proposed model, if the parameter $flag = 1$, the number of original dimensions $p$ is reduced to some number slightly larger than $d$ depending on the number of high-fidelity training data. Then the Gaussian process dimension reduction technique is applied to compute another reduction matrix in order to reduce the number of dimensions to $d$. \subsection{Gaussian process dimension reduction technique} A similar approach is proposed in \cite{GPbDR} and based on a novel covariance function of Gaussian process, $$ k_s(\bold{x}, \bold{x}'; \bold{W},\bold{\phi}) = k_d(\bold{W}^T \bold{x}, \bold{W}^T \bold{x}';\bold{\phi}) $$ where $k_s$ is a standard covariance function and $k_d$ is the corresponding covariance function on a low-dimensional space. So, the inputs are first projected to a low-dimensional space before feeding to the Gaussian process covariance function. Note that the newly constructed kernel $k_s$ has both the projection matrix $\bold{W}$ and the original kernel parameters $\bold{\phi}$ as its parameters. Those hyper-parameters are joint optimized in Gaussian process regression using maximizing the marginal log-likelihood function. The process for this method is shown in Algorithm 3. \begin{algorithm} \caption{Gaussian process dimension reduction technique} \begin{algorithmic} \STATE 1. Input: high-fidelity data set $\{X_H,y_H\}$ and validation data set $\{X_T,y_T\}$, iteration number $N$, input dimension $s$, output dimension $d$, initial guess of reduction matrix $A_0$ and hyper-parameters $\bold{\theta}_0$ for GP kernel. \STATE 2. Project the high-fidelity data set $\{X_H,y_H\}$ to a low-dimensional space using $A_0$ to get a new data set $\{\hat{X_H},y_H\}$. \STATE 3. Build a Gaussian process model with $\{\hat{X_H},y_H\}$ from previous step and optimization the model using maximum likelihood method with the initial guess $A_0$ and $\bold{\theta}_0$. \STATE 4. Fix the reduction matrix $A$ as parameters of the GP kernel and optimize the hyper-parameters $\bold{\theta}$. \STATE 5. Unfix parameters $A$ and fix the hyper-parameters $\bold{\theta}$, then optimize $A$ again. \STATE 6. Repeat step 4 and 5 for $N$ times. \STATE 7. Output: a reduction matrix $M_2$ with size $s \times d$ which is the optimal parameter $A$ in the GP optimization process. \end{algorithmic} \end{algorithm} For small set of high-fidelity training data, the method in \cite{GPbDR} can not be directly applied to the original high-dimensional problem to obtain accurate results. For instance, if the number of original dimensions is $p$ and true number of reduced dimensions is $d$. Then we have $p \times d$ additional parameters to optimize except original hyper-parameters in a standard Gaussian process regression. In our method, the number of original dimensions $p$ is first reduced to $s$ with our rotated multi-fidelity Gaussian process model. Then Gaussian process dimension reduction technique can be effectively applied to reduce the number of dimensions from $s$ to $d$. Here, $s$ depends on the number of high-fidelity samples in the problem and can be chosen by the user. In our numerical examples, the number of dimensions $s$ is chosen to be $3$ to better demonstrate our method. For other values of $s$, it can be implemented similarly. \subsection{Bayesian active learning} Active learning aims at maximizing information acquisition with limited data. It is also known as optimal experimental design or sequential design in statistic literatures. As Sverchkow and Craven(2017) stated in \cite{ReAC}, informative experiments are first proposed according to the hypotheses generated from the model. Then the model is updated by the data obtained from the experiments. In this way, the model is gradually improved from such an iterative process which is called active learning. More recent works on this topic includes \cite{AL1}, \cite{AL3}, \cite{AL2}. In the problem setting of this paper, the training data come from the low-fidelity models are rich and easy to obtain and it is denoted by, $$D_L = (X_L, Y_L) $$ But data from the high-fidelity model are time consuming or very expensive, which is denoted by, $$D_H = (X_H, Y_H)$$ In order to make accurate inference, more training data points need to be selected and added to the high-fidelity data set. The candidate pool is chosen to be the low-fidelity observation set. With the help of Bayesian active learning, the additional data points to augment the original high-fidelity observations can be efficiently determined. This can greatly reduce the model uncertainties in the problem setting under limited budget. Assuming the training data set consists of $N_L$ low-fidelity observations $D_L$ and $N_H$ high-fidelity observations $D_H$. So the training data set $D$ can be expressed as, $$ D = \{ D_L, D_H\} $$ This represents the current state of knowledge and a multi-fidelity model can be built as stated in the previous sections. Now, the most informative sample in the low-fidelity observations is picked by maximizing an acquisition function $a_N(x)$, \begin{equation} \mathbf{x}_{N_H+1} = \textit{argmax}_{\mathbf{x} \in D_L} a_N(\mathbf{x}) \end{equation} The acquisition function actually quantifies how much information we can get to evaluate or perform an expensive experiment at this data point. Then $(x_{N_H+1}, y_{N_H+1})$ is added to the high-fidelity observation set $D_H$. At this point, the process stops if a pre-set problem related stop criterion is achieved. Otherwise, the process repeats iteratively until it satisfies the stop criterion or reaches the maximal number of times permitted. There are several common acquisition functions in Bayesian active learning, including maximum upper interval, probability of improvement and expected improvement, based on different problem settings. In our multi-fidelity setting, the prediction variance quantifies how much uncertainties the model has for the current predictions. This guides us to choose the acquisition function to be the predictive variance of the model: \begin{equation} a_N(\mathbf{x}) = \sigma^2_*(\mathbf{x}) \end{equation} As for the stop criterion, the Bayesian active learning process stops if the relative error of the predictions of the proposed rotated multi-fidelity model on the test set is less than a chosen small value $\eta$. \section{Algorithm} In this section, the rotated multi-fidelity Gaussian process(RMFGP) model and dimension reduction process built on it is introduced. In the proposed method and the numerical results in the following, we consider two layers of fidelity. The deeper layer problems share the similar principle. Given the low and high-fidelity training data $\{X_L,y_L\}$, $\{X_H,y_H\}$ and the test data $\{X_T, y_T\}$, Algorithm 4 summarizes the process. \begin{algorithm} \caption{Rotated multi-fidelity Gaussian process model(RMFGP)} \begin{algorithmic} \STATE 1. Input: low-fidelity data sets $\{X_L,y_L\}$, high-fidelity set $\{X_H,y_H\}$ and validation data set $\{X_T,y_T\}$, threshold $\xi$, maximum iteration number $I$, reduction parameter $flag = 0$ or $1$. \STATE 2. Apply SAVE method(Alg. 2) only on the low-fidelity data to compute the first rotation matrix $A_T$ to extract the principle direction information in the low-fidelity data. Then apply $A_T$ to all $X= (X_L, X_H, X_T)$. \STATE 3. Perform NARGP on new training data $\{\hat{X_L},y_L\}$, $\{\hat{X_H},y_H\}$ from step 1 to get the prediction $\hat{y_T}$ at $\hat{X_T}$. Then perform SAVE method again on new $\{\hat{X_T}, \hat{y_T}\}$ to compute the rotation matrix $\hat{A}$ and apply $\hat{A}$ to all $X$s. \STATE 4. Check whether the threshold of the generalization error meet. If not, perform Bayesian active learning method to locate $x^*$ where the prediction variance achieves maximum. Sample $\{x^*, y_H^*\}$ and add them into the high-fidelity training set. \STATE 5. Repeat step 2 and 3 until the generalization error threshold fulfilled or the maximum iteration number is reached. \STATE 6. Compute the rotation matrix $M_1 = A_T\prod_i \hat{A_i}$. and build the rotated model. \STATE 7. If dimension reduction parameter $flag = 1$, compute the intrinsic dimension $d$ through BIC and compute the reduction matrix $\hat{M}_1$ consisting of the first $s$ principle columns of $M_1$, where $d < s < p$. \STATE 8. Apply Gaussian processes dimension reduction technique(Alg. 3) to compute reduction matrix $M_2$ which is $s \times d$. Then build the reduced model with final reduction matrix $M = \hat{M}_1 M_2$. \end{algorithmic} \end{algorithm} \section{Numerical Results} In this section, four examples are present to demonstrate the effectiveness of RMFGP model. We first measure the accuracy of the approximated rotation matrix $\hat{A}$ by the distance metric defined in \cite{Ona}: \begin{equation} m(A, \hat{A}) = ||P - \hat{P}|| \end{equation} where $A$ and $\hat{A}$ are the true and estimated central subspace matrices, $P$ and $\hat{P}$ are projection matrices of $A$ and $\hat{A}$, $|| \cdot ||$ is the Frobenius norm. To illustrate the effectiveness of our method, the reduction matrix computed by RMFGP when $flag=1$ and the method introduced in \cite{BIRsd} are compared using the same number of high-fidelity samples. Once the rotation matrix is computed, new training and test set are generated to build and evaluated a new Gaussian process model. To compare the accuracy between final surrogate models under the fair setting, two cases are considered depending on the reduction parameter $flag$. If $flag = 0$, the proposed method and the standard Gaussian process regression(GPR) are performed on the origin and rotated data set respectively and the results are compared. If $flag = 1$, the reduced model is performed on the data set with the reduction matrix found in RMFGP model. It is then compared to the GP-SAVE method introduced in \cite{BIRsd}. The accuracy of the models is measured by the relative error defined in \cite{EnSp}: \begin{equation} e = \frac{||u - \hat{u}||_2}{||u||_2} \end{equation} where $u$, $\hat{u}$ are the exact and approximated values of the high-fidelity model on the test set and $|| \cdot ||_2$ is the $L_2$ norm. \subsection{Linear example: Poisson's equation} The first example illustrates the situation where the high-fidelity function has a linear relationship with the low-fidelity function. This can be seen as the simplest form of relationship between the high-fidelity and low-fidelity functions. Consider the equations: $$ f_H(\bold{x}) = sin(\pi (x_1 + x_3)) + sin(\pi (x_1 + x_2)) + 2 $$ $$ f_L(\bold{x}) = f_H(\bold{x}) + x_3 x_4 x_5 x_6 $$ where $x_i$, $i = 1,\dots,6$, are i.i.d uniformly distributed random variables on $[0,1]$. In this example, the high-fidelity and low-fidelity function are a solution of a Poisson's equation according to different force terms respectively, \begin{equation} \nabla^2 f = h(x) \end{equation} $$ h_H(x) = 2\pi^2sin(\pi(x_1 + x_3)) + 2\pi^2sin(\pi(x_1 + x_2)) $$ $$ h_L(x) = h_H(x) + \frac{1}{6}(x_3^3x_4x_5x_6 + x_3x_4^3x_5x_6 + x_3x_4x_5^3x_6 + x_3x_4x_5x_6^3)$$ From this point of view, one can also think the difference between high and low-fidelity function comes from the complicated high dimensional noise in the force term $h_L$. The input dimension is $p=6$. It is easily seen from the expression that the inputs for $f_H$ are actually in a subspace of dimension $d = 2$. The actual dimension reduction matrix $A = span\{\beta_1, \beta_2\}$, where $\beta_1 = (1,0,1,0,0,0)^T, \beta_2 = (1,1,0,0,0,0)$. The number of low-fidelity training points is set to be $N_L = 200$ and the number of test points is set to be $N_T = 500$. For all cases, the high-fidelity sample size starts at $(N_H-10)$ and two iterations in Bayesian active learning process are involved with $5$ samples added per iteration. The results are shown in Table $1$ and Table $2$. \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H=25$ & $N_H=30$ & $N_H=35$ & $N_H=40$ \\ [0.5ex] \hline RMFGP ($flag=1$) & 0.133262 & 0.112705 & 0.066355 & 0.043337 \\ \hline GP-SAVE & 0.396780 & 0.243222 & 0.221707 & 0.202306 \\ \hline \end{tabular} \caption{Accuracy of the dimension reduction matrix measured by the metric $m(A,\hat{A})$ with different number of high-fidelity samples for linear examples - Equation (11). The number of low-fidelity samples is fixed to be $N_L = 200$. There are two iterations to add high-fidelity samples in Bayesian active learning process with $5$ points added per iteration. For RMFGP method, the number of dimensions of the inputs is first reduced to $s = 3$ from the number of original dimensions $p=6$. Then Gaussian process dimension reduction technique is applied to reduce the dimension from $s=3$ to $d=2$. The additional number of hyper-parameters needed to optimized in this step is $6$.} \label{table:1} \end{table} \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H= 25$ & $N_H=30$ & $N_H=35$ & $N_H=40$ \\ [0.5ex] \hline RMFGP ($flag=0$) & 0.051382 & 0.030260 & 0.019012 & 0.007531 \\ \hline GP & 0.060513 & 0.043898 & 0.027694 & 0.023358 \\ \hline RMFGP ($flag=1$) & 0.051358 & 0.039532 & 0.026999 & 0.020309 \\ \hline GP-SAVE & 0.084310 & 0.077906 & 0.072945 & 0.066365 \\ \hline \end{tabular} \caption{Relative error $e$ of RMFGP model compared to standard GP for linear examples - Equation (11). If $flag=0$, the inputs are simply rotated by the rotation matrix from RMFGP model before fed into a new GP surrogate model. It is compared to a standard GP model. If $flag=1$, the inputs are reduced to dimension $d=2$. For comparison, the inputs for the standard GP are reduced to dimension $d=2$ by a reduction matrix computed by SAVE method using the same number of high-fidelity training points.} \label{table:2} \end{table} Table $1$ summarizes the distance between the approximate reduction matrix and true reduction matrix measured by (9) based on four different sample sizes with the reduction parameter $flag = 1$. The accuracy of estimating the central subspace for both methods increases with the sample size showing that the methods are consistent. The proposed method performs better across all sample sizes. This is because of the information provided by the low-fidelity data and the improvement of the prediction performance through the active learning. This indicates a better accuracy of our method than traditional dimension reduction method, especially when we have only limited budget for acquiring high-fidelity data. Table $3$ is the BIC results illustrating the value of $G(k)$ in Equation (6) with different k. The approximated reduced dimension is $\hat{d} = 2$ according to (6), which is the same as the one obtained from the expression of $f_H$ directly. \begin{table}[h!] \centering \begin{tabular}{||c c c c c c c||} \hline & k=1 & k=2 & k=3 & k=4 & k=5 & k=6 \\ [0.5ex] \hline G(k) & 0.9366920 & $\textbf{0.9592096}$ & 0.9272198 & 0.8946359 & 0.8609161 & 0.8267321 \\ \hline \end{tabular} \caption{BIC: G(k) for linear examples - Equation (11)} \label{table:3} \end{table} Table $2$ shows the relative errors on the test set as measured by (10) for each combination of the four models involved and four different sample sizes $n_H=25,30,35,40$. The first two rows represent the comparison between the proposed method and the standard Gaussian process regression(GPR) when the dimension reduction parameter $flag = 0$. The last two rows represent the comparison between the proposed method when $flag = 1 $ and the GP method with the dimension reduction using SAVE method (GP-SAVE). For our RMFGP method, we first project the original inputs $X$ from the number of dimensions $p=6$ to the reduced dimension $s=3$. Then, Gaussian process dimension reduction technique is utilized to further reduce the number of dimensions from $s=3$ to $d=2$. Notice that there are $6$ additional parameters we need to optimize in this step, so the requirement for number of high-fidelity data can be relaxed in order to achieve certain accuracy. All models illustrate the consistency that the relative error decreases with the increase value of $N_H$. The proposed RMFGP method performs better in both situations. Figure $2$ shows the mean square error(MSE) of different models with respect to the size of high-fidelity data. The red curve represents the proposed methods and the blue curve represents the comparison methods. Both figures reveal the fact that the proposed method has a smaller MSE and a faster convergence, especially when $N_H$ is small. \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{MSE_linear1.png} \label{fig:MSE_linear1}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{MSE_linear2.png} \label{fig:MSE_linear2}} \caption{MSE of linear examples - Equation (11): (a) Models without dimension reduction: RMFGP ($flag=0$) vs. GP; (b) Models with dimension reduction: RMFGP ($flag=1$) vs. GP-SAVE. For both (a) and (b), axis x is the number of high-fidelity samples $N_H$ and the number of low-fidelity sample $N_L$ is fixed to be 200. The number of original dimensions is $p = 6$. } \label{fig:MSE_linear} \end{figure} Figure $3$ represents the correlation between the prediction and the true observation at $N_H = 30$. The figure on the left demonstrates the correlation of the RMFGP model when $flag = 0$ and GP with the original data $X$, while the figure on the right shows the correlation of the RMFGP model when $flag = 1$ and GP-SAVE with the reduced input $\hat{X}$. The red dots represent the results of RMFGP. The blue squares are the results of the comparison methods. The black solid line represents the perfect correlation between the predictions and true observations. As shown in Figure $3$, the red dots stay close to the perfect correlation while the blue squares are around but somehow off the black solid line, which indicates a better prediction on the test set for the proposed method. Hence, we can conclude that the proposed method estimate both the central subspace and the model predictions better than the traditional methods. The user can decide whether to use the rotated model or the reduced model based on the needs of the real application by controlling the reduction parameter $flag$ in the inputs of Algorithm 4. \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{LinearCorSAVE1-30.png} \label{fig:LinearCorSAVE1-30}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{LinearCorSAVE2-30.png} \label{fig:LinearCorSAVE2-30}} \caption{Correlation plots of linear examples - Equation (11) at $N_H=30$: (a) RMFGP ($flag=0$) vs. GP; (b) RMFGP ($flag=1$) vs. GP-SAVE. For all figures, axis x is the exact values and axis y is the predictions at the test points. The black solid line is the perfect correlation. } \label{fig:LinearCor} \end{figure} \subsection{Nonlinear example} The second example demonstrates that RMFGP can predict model with more complicated relationship between high and low-fidelity data, which can not be predicted by the linear auto-regressive model. Consider the following function: $$ f_H(\bold{x}) = exp(0.2 \sum_{i=1}^{10} x_i) $$ $$ f_L(\bold{x}) = x_4 f_H(\bold{x}) $$ where $x_i$, $i = 1,\dots,10$ are i.i.d uniformly distributed random variables on $[0,1]$. Based on the expression of $f_H$ and $f_L$, the actual number of dimensions of the inputs for low-fidelity function is $2$ while it is $1$ for high-fidelity function. This can happen in the real world applications where the low-fidelity data contain various noises. The original number of input dimensions is $p=10$. The actual dimension reduction matrix $A = span\{\beta_1\}$, where $\beta_1 = (1,1,1,1,1,1,1,1,1,1)^T$. In this experiment, the number of low-fidelity training points used is $N_L = 200$ and the number of test points is set to be $N_T = 500$. For all the cases, the start number of high-fidelity samples is $(N_H - 5)$, the active learning scheme is then employed to add $2$ points in first iteration and $3$ points in last iteration before it reaches the stopping criterion. Table $4$ shows the distance as measured by (9) for this experiment. As expected, both RMFGP and GP illustrate the consistency. Note that RMFGP gains a high accuracy of the estimated central subspace with a relatively small high-fidelity data set. In this example, the low-fidelity data contains full information about high-fidelity data but with some noises as a multiplier in front of it. The $G(k)$ values are presented in Table $5$. It reaches maximum at $k=1$, which indicates the estimated reduced dimension is $\hat{d}=1$. It is the same as the one obtained from the expression of $f_H$ directly. It suggests the capability of RMFGP to identify the intrinsic dimension under the effect of some noises. So if the reduction parameter $flag=1$, we first reduced the number of dimensions from $p=10$ to $s=3$ and then apply the Gaussian process dimension reduction technique to further reduce the dimension to $d=1$. \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H=10$ & $N_H=15$ & $N_H=20$ & $N_H=25$ \\ [0.5ex] \hline RMFGP ($flag=1$) & 0.375618 & 0.217788 & 0.032944 & 0.019125 \\ \hline GP-SAVE & 1.234884 & 1.004467 & 0.177209 & 0.080237 \\ \hline \end{tabular} \caption{Accuracy of the dimension reduction matrix measured by the metric $m(A,\hat{A})$ with different number of high-fidelity samples for nonlinear examples. The number of low-fidelity samples is fixed to be $N_L = 200$. There are two iterations to add high-fidelity samples in Bayesian active learning process with $2$ points added in first iteration and $3$ points added in the second. For RMFGP method, the number of dimensions of the inputs is first reduced to $s = 3$ from the number of original dimensions $p=10$. Then Gaussian process dimension reduction technique is applied to reduce the dimension from $s=3$ to $d=1$. The additional number of hyper-parameters needed to optimized in this step is $3$. } \label{table:4} \end{table} \begin{table}[h!] \centering \begin{tabular}{||c c c c c c||} \hline & k=1 & k=2 & k=3 & k=4 & k=5 \\ [0.5ex] \hline G(k) & $\textbf{0.9622132}$ & 0.9355113 & 0.9061465 & 0.8764734 & 0.8466059 \\ \hline & k=6 & k=7 & k =8 & k=9 & k = 10\\ [0.5ex] \hline G(k) & 0.8163634 & 0.7852849 & 0.7539464 & 0.7221620 & 0.6893825 \\ \hline \end{tabular} \caption{BIC: G(k) for nonlinear examples} \label{table:5} \end{table} Table $6$ and Figure $4$ are the relative error and the MSE plots of four models with different sizes of $N_H$. RMFGP outperforms GP on both cases which $flag=0$ or $1$. It has smaller errors on all sample sizes and it converges faster than the comparison method. This concludes the RMFGP dimension reduction model can successfully identify the accurate central subspace and achieve a low relative error. \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H= 10$ & $N_H=15$ & $N_H=20$ & $N_H=25$ \\ [0.5ex] \hline RMFGP ($flag=0$) & 0.037386 & 0.008324 & 0.001096 & 0.000810 \\ \hline GP & 0.171120 & 0.139623 & 0.034945 & 0.024370 \\ \hline RMFGP ($flag=1$) & 0.080942 & 0.045254 & 0.006634 & 0.003374 \\ \hline GP-SAVE & 0.175399 & 0.133578 & 0.026675 & 0.021621 \\ \hline \end{tabular} \caption{Relative error $e$ of RMFGP model compared to standard GP for nonlinear examples. If $flag=0$, the inputs are simply rotated by the rotation matrix from RMFGP model before fed into a new GP surrogate model. It is compared to a standard GP model. If $flag=1$, the inputs are reduced to dimension $d=1$. For comparison, the inputs for the standard GP are reduced to dimension $d=1$ by a reduction matrix computed by SAVE method using the same number of high-fidelity training points.} \label{table:6} \end{table} \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{MSE_nonlinear1.png} \label{fig:mse_nonlinear1}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{MSE_nonlinear2.png} \label{fig:mse_nonlinear2}} \caption{MSE of nonlinear examples: (a) Models without dimension reduction: RMFGP ($flag=0$) vs. GP; (b) Models with dimension reduction: RMFGP ($flag=1$) vs. GP-SAVE. For both (a) and (b), axis x is the number of high-fidelity samples $N_H$ and the number of low-fidelity sample $N_L$ is fixed to be 200. The number of original dimensions is $p = 10$. } \label{fig:mse_nonlinear} \end{figure} The correlation between the predictions and the true observations is presented in Figure $5$. The number of high-fidelity training data used is $N_H = 20$. The color settings are the same as that in Example $4.1$. The proposed method acts well under all situations since the red dots are very close to the perfect correlation line while GP can not predict the test set well with small $N_H$. \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{nonlinearCorSAVE1-20.png} \label{fig:NonlinearCorSAVE1-20}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{nonlinearCorSAVE2-20.png} \label{fig:NonlinearCorSAVE2-20}} \caption{Correlation plots of nonlinear examples at $N_H=20$: (a) RMFGP ($flag=0$) vs. GP; (b) RMFGP ($flag=1$) vs. GP-SAVE. For all figures, axis x is the exact values and axis y is the predictions at the test points. The black solid line is the perfect correlation.} \label{fig:NonlinearCor} \end{figure} Figure $6$ is the prediction plot at $N_H=20$. The black star line is the exact prediction with $x_d$ computed by the true dimension reduction matrix. The red circle line obtained by RMFGP ($flag=1$) fits the curve well. The blue square line has a large error at some locations of $x_d$. The successful estimation of central subspace as well as the predictions on test set proves the ability of our method to exclude the effect of noises with relatively small set of highly accurate data, which is useful in many real world applications where the high-fidelity data is expensive or hard to collect. \begin{figure}[h] \centering \includegraphics[width=0.6\textwidth]{nonlinearplotSAVE-20.png} \label{fig:NonlinearplotSIR-20} \caption{Prediction plots of nonlinear example at $N_H=20$: RMFGP ($flag=1$) vs. GP-SAVE. The axis x is the test inputs after dimension reduction represented by $x_d$ and the axis y is the corresponding observations. The number of original dimensions is $p=10$. The number of training data is $N_L = 200$ and $N_H = 20$.} \label{fig:nonlinearplot} \end{figure} \subsection{Advection equation} This example is aimed to exam the performance of RMFGP in the stochastic partial differential equation problems. Consider the one dimensional differential equation: \begin{equation} \frac{\partial}{\partial t} u(x, t; \xi)+ \frac{a}{4} \sum_{i=1}^5 \bold{\xi}_i \frac{\partial}{\partial x} u(x, t; \xi) = 0 \end{equation} with the initial condition: $$ u(x, 0; \xi) = sin(\pi (x + 1)) + 1 $$ where $a$ is a constant coefficient, $x \in [0,1]$ and $\bold{\xi} = (\xi_1, \cdots, \xi_5) \in [0,1]^5$ is a random vector. Under this setting we have analytical solution for this equation denoted as $u_H$: $$ u_H(x) = sin(\pi (x - \frac{a}{4} t \sum_{i=1}^5 \bold{\xi}_i + 1)) + 1 $$ The low-fidelity data is sampled from the following function: $$ u_L(x) = sin(\pi (x - \frac{a}{4} t \sum_{i=3}^5 \bold{\xi}_i + 1)) + 1 $$ The input random vector $\xi$ is generated by i.i.d uniformly distribution in $[0,1]^5$ and the constant $a$ is fixed to be $1$. Compared to the previous two examples, there is some missing information in $u_L$ in this example. The high and low-fidelity function values are computed at $x=0.5$ and $t=1$. The true reduced dimension is $d=1$ from the analytical solution of the equation. The true reduction matrix is $A = span\{\beta_1\}$, where $\beta_1 = (1,1,1,1,1)$. Table $7$ shows the $G(k)$ values computed by BIC method. It reaches maximum at $k=1$, which indicates the estimated reduced dimension is $\hat{d}=1$. In the numerical experiment, the number of low-fidelity training data is set to be $N_L=200$ and the number of test data is $N_T = 500$. For all four cases with different number of $N_H$, the experiment starts at $(N_H-10)$ and the active learning process add $5$ samples per iteration with $2$ iterations before stopping. \begin{table}[h!] \centering \begin{tabular}{||c c c c c c||} \hline & k=1 & k=2 & k=3 & k=4 & k=5 \\ [0.5ex] \hline G(k) & $\textbf{0.8753940}$ & 0.8464151 & 0.8165653 & 0.7861532 & 0.7552568 \\ \hline \end{tabular} \caption{BIC: G(k) for advection equation - Equation (12)} \label{table:7} \end{table} Table $8$ summarize the distance defined in (9). As expected, both methods demonstrate the consistency but the proposed RMFGP($flag=1$) method outperforms GP-SAVE on all sample sizes. Note that when $N_H$ is not sufficient, GP-SAVE can not detect central subspace well. The relative error in Table $9$ and the MSE plot in Figure $7$ confirms this conclusion. RMFGP has a smaller error and converge faster compared to GP. The correlation plot in Figure $8$ and the prediction plot in Figure $9$ shows that RMFGP achieves a smaller generalization error and regresses the curve better than GP with SAVE method. This example indicates the capability of RMFGP to successfully approximate the central subspace in a stochastic differential equation problem with missing information in low-fidelity model $u_L$. \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H=20$ & $N_H=25$ & $N_H=30$ & $N_H=35$ \\ [0.5ex] \hline RMFGP ($flag=1$) & 0.249067 & 0.114606 & 0.072898 & 0.066792 \\ \hline GP-SAVE & 1.410894 & 1.269664 & 0.483262 & 0.450924 \\ \hline \end{tabular} \caption{Error of the dimension reduction matrix measured by the metric $m(A,\hat{A})$ with different number of high-fidelity samples for advection equation - Equation (12). In this experiment, constant $a$ is set to be 1 and $x=0.5$, $t=1$ are fixed. The number of low-fidelity samples is fixed to be $N_L = 200$. There are two iterations to add high-fidelity samples in Bayesian active learning process with 5 points added per iteration. For RMFGP method, the number of dimensions of the inputs is first reduced to dimension $s = 3$ from the number of original dimensions $p=5$. Then Gaussian process dimension reduction technique is applied to reduce the dimension from $s=3$ to $d=1$. The additional number of hyper-parameters needed to optimized in this step is $3$.} \label{table:8} \end{table} \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H= 20$ & $N_H=25$ & $N_H=30$ & $N_H=35$ \\ [0.5ex] \hline RMFGP ($flag=0$) & 0.645469 & 0.084900 & 0.068312 & 0.061210 \\ \hline GP & 1.025144 & 0.964663 & 0.705019 & 0.672353\\ \hline RMFGP ($flag=1$) & 0.277659 & 0.260726 & 0.216323 & 0.084661 \\ \hline GP-SAVE & 0.743488 & 0.665575 & 0.406130 & 0.384018 \\ \hline \end{tabular} \caption{Relative error $e$ of RMFGP model compared to standard GP for advection equation - Equation (12). If $flag=0$, the inputs are simply rotated by the rotation matrix from RMFGP model before fed into a new GP surrogate model. It is compared to a standard GP model. If $flag=1$, the inputs are reduced to dimension $d=1$. For comparison, the inputs for the standard GP are reduced to dimension $d=1$ by a reduction matrix computed by SAVE method using the same number of high-fidelity training points.} \label{table:9} \end{table} \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{MSE_adv1.png} \label{fig:MSE_adv1}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{MSE_adv2.png} \label{fig:MSE_adv2}} \caption{MSE of advection equation - Equation (12): (a) Models without dimension reduction: RMFGP ($flag=0$) vs. GP; (b) Models with dimension reduction: RMFGP ($flag=1$) vs. GP-SAVE. For both (a) and (b), axis x is the number of high-fidelity samples $N_H$ and the number of low-fidelity sample $N_L$ is fixed to be 200. The number of original dimensions is $p = 5$. Constant $a=1$, $x=0.5$ and $t=1$ are fixed.} \label{fig:MSE_adv} \end{figure} \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{AdvCorSAVE1-30.png} \label{fig:AdvCorSAVE1-30}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{AdvCorSAVE2-30.png} \label{fig:AdvCorSAVE2-30}} \caption{Correlation plots of advection equation - Equation (12) at $N_H = 30$: (a) RMFGP ($flag=0$) vs. GP; (b) RMFGP ($flag=1$) vs. GP-SAVE. For all figures, axis x is the exact values and axis y is the predictions at the test points. The black solid line is the perfect correlation. } \label{fig:AdvCor} \end{figure} \begin{figure}[h] \centering \includegraphics[width=0.6\textwidth]{AdvplotSAVE-30.png} \label{fig:AdvplotSAVE-30} \caption{Prediction plots of advection equation - Equation (12) at $N_H = 30$: RMFGP ($flag=1$) vs. GP-SAVE. The axis x is the test inputs after dimension reduction represented by $x_d$ and the axis y is the corresponding observations. The number of original dimensions is $p=5$. The number of training data is $N_L = 200$ and $N_H = 30$.} \label{fig:Adv prediction} \end{figure} The proposed method gives us a dimension reduction matrix $M$ if $flag=1$. Then, we can build a new Gaussian process surrogate with $M$ by pre-processing all training data with $M$ to reduce the input dimension to $d=1$. In order to perform an uncertainty propagation analysis for this model, we fix $t=1$ and chose $50$ evenly spaced locations in $[0,1]$ for $x$ in advection equation. Then, 2000 samples for $\bold{\xi}$ are drawn from an i.i.d uniformly distribution. Figure $10$ presents the average of means and standard deviations(std) of those 2000 cases along with $50$ different $x$ values in $[0,1]$. The ground truth is the black line. We can see our RMFGP method represented by red square line outperforms the comparison GP method represented by blue star line for both mean and std values. The green diamond line is obtained by pure SAVE method using large enough training data, i.e. $10000$ high-fidelity data samples, while there are only $35$ high-fidelity samples in our proposed method. \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=1\textwidth]{AdvUQmean40.png} \label{fig:AdvUQmean40}} \\ \qquad \subfloat[b][]{ \includegraphics[width=1\textwidth]{AdvUQstd40.png} \label{fig:AdvUQstd40}} \caption{Average prediction means and standard deviations of advection equation - Equation (12) at $N_H = 35$: (a) average mean; (b) average standard deviation. For all figures, the axis $x$ represents the indexes of different $x$ values in $[0,1]$ and the axis $y$ represents the average mean or std values. The ground truth is the black line. The green diamond line is obtained by pure SAVE method with $10000$ high-fidelity data points. The blue star line is results of GP-SAVE method. Our RMFGP method with $flag=1$ is represented by the red square line. Both those two methods are using $35$ high-fidelity samples. } \label{fig:AdvUQ} \end{figure} \subsection{Elliptic Equation} The last example illustrates the performance of RMFGP in a more complicated stochastic partial differential equation. Consider the one-dimensional elliptic differential equation with a random high-order coefficient: \begin{equation} -\frac{d}{dx}(a(x;\xi)\frac{du(x;\xi)}{dx})=1,\quad x\in(0,1) \end{equation} $$u(0)=u(1)=0,$$ where $a(x;\xi)$ has the form: $$a_H(x;\xi) = \frac{1}{(\xi_1 + sin(x(\xi_1 + \xi_2 + \xi_3 + \xi_4)) + 1)}$$ $$a_L(x;\xi) = \frac{1}{(0.1 + sin(x(\xi_1 + \xi_2 + \xi_3 + \xi_4)) + 1)} $$ For this elliptic equation, there is a deterministic solution as: $$u(x) = u(0) + \int_0^x \frac{a(0)u(0)' - y}{a(y)}dy$$ Applying the boundary condition $u(0) = u(1) = 0$ we have: $$a(0)u(0)' = \frac{\int_0^1 \frac{y}{a(y)}dy}{\int_0^1 \frac{1}{a(y)}dy}$$ In this example, the input $\xi$ is generated by i.i.d uniformly distributed random variables in $[0,1]^{6}$ and $u_H$ is computed at $x=0.7$. The high-fidelity function $u_H$ and low-fidelity function $u_L$ are obtained by applying corresponding $a_H$ and $a_L$ in the deterministic solution respectively. The integrals in the deterministic solution are computed by highly accurate numerical integrations. Unlike the previous example, there is no analytical expression for $u$. The exact central subspace can not be concluded by the expression of the equation directly. Instead, it is computed by traditional SAVE method using $10000$ samples from the true distribution. The true reduced dimension is computed through these samples by BIC and the result of $G(k)$ is shown in Table $10$. The estimated dimension turns out to be $\hat{d}=2$. In this example, the number of low-fidelity points is set to be $N_L = 200$ and the number of test points is set to be $N_T=500$. For all different cases, the start number of high-fidelity samples is $(N_H-5)$ with $2$ points added in the first iteration and $3$ points added in the second. \begin{table}[h!] \centering \begin{tabular}{||c c c c c c c||} \hline & k=1 & k=2 & k=3 & k=4 & k=5 & k=6 \\ [0.5ex] \hline G(k) & 0.7018816 & $\textbf{0.7323037}$ & 0.7094890 & 0.6859600 & 0.6621426 & 0.6379765 \\ \hline \end{tabular} \caption{BIC: G(k) for elliptic equation - Equation (13)} \label{table:9} \end{table} Table $11$ summarize the accuracy of the estimated central subspace. Table $12$ shows the relative error at various high-fidelity samples sizes on two type of methods RMFGP and GP. Figure $11$ is the MSE plot for RMFGP model with $flag=0$ or $1$ compared to corresponding GP and GP-SAVE model. Figure $12$ denotes the correlation between true observations and the prediction values at $N_H=25$. All figures shows that RMFGP has a better performance in estimating both central subspace and prediction on test set in the similar manner as in previous examples. When the number of high-fidelity data increases, the RMFGP with $flag=0$ performs the best. This is because the identification of principle directions can improve the prediction performance. The difference between rotated model with $flag=0$ and reduced model wit $flag=1$ will reduce with the increase of the accuracy for estimated central subspace. \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H=20$ & $N_H=25$ & $N_H=30$ & $N_H=35$ \\ [0.5ex] \hline RMFGP ($flag=1$) & 0.159129 & 0.141972 & 0.122867 & 0.120856 \\ \hline GP-SAVE & 0.921045 & 0.387880 & 0.250663 & 0.238877 \\ \hline \end{tabular} \caption{Error of the dimension reduction matrix measured by the metric $m(A,\hat{A})$ with different number of high-fidelity samples for elliptic equation - Equation (13). In this experiment, $x=0.7$ is fixed. The number of low-fidelity samples is fixed to be $N_L = 200$. There are two iterations to add high-fidelity samples in Bayesian active learning process with 5 points added per iteration. For RMFGP method, the number of dimensions of the inputs is first reduced to dimension $s = 3$ from the number of original dimensions $p=6$. Then Gaussian process dimension reduction technique is applied to reduce the dimension from $s=3$ to $d=2$. The additional number of hyper-parameters needed to optimized in this step is $6$.} \label{table:11} \end{table} \begin{table}[h!] \centering \begin{tabular}{||c c c c c||} \hline & $N_H=20$ & $N_H=25$ & $N_H=30$ & $N_H=35$ \\ [0.5ex] \hline RMFGP ($flag=0$) & 0.015076 & 0.007989 & 0.004557 & 0.001545 \\ \hline GP & 0.060633 & 0.008441 & 0.006939 & 0.004409 \\ \hline RMFGP ($flag=1$) & 0.014057 & 0.011540 & 0.011276 & 0.010667 \\ \hline GP-SAVE & 0.059538 & 0.026454 & 0.020915 & 0.014822 \\ \hline \end{tabular} \caption{Relative error $e$ of RMFGP model compared to standard GP for elliptic equation - Equation (13). If $flag=0$, the inputs are simply rotated by the rotation matrix from RMFGP model before fed into a new GP surrogate model. It is compared to a standard GP model. If $flag=1$, the inputs are reduced to dimension $d=2$. For comparison, the inputs for the standard GP are reduced to dimension $d=2$ by a reduction matrix computed by SAVE method using the same number of high-fidelity training points.} \label{table:12} \end{table} \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{MSE_elliptic1.png} \label{fig:MSE_elliptic1}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{MSE_elliptic2.png} \label{fig:MSE_elliptic2}} \caption{MSE of elliptic equation - Equation (13): (a) Models without dimension reduction: RMFGP ($flag=0$) vs. GP; (b) Models with dimension reduction: RMFGP ($flag=1$) vs. GP-SAVE. For both (a) and (b), axis x is the number of high-fidelity samples $N_H$ and the number of low-fidelity sample $N_L$ is fixed to be $200$. The number of original dimensions is $p = 6$. } \label{fig:MSE_elliptic} \end{figure} \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=0.45\textwidth]{EllipticCorSAVE1-25.png} \label{fig:AdvCorSAVE1-15}} \qquad \subfloat[b][]{ \includegraphics[width=0.45\textwidth]{EllipticCorSAVE2-25.png} \label{fig:EllipticCorSAVE-25}} \caption{Correlation plots of elliptic equation - Equation (13) at $N_H = 25$: (a) RMFGP ($flag=0$) vs. GP; (b) RMFGP ($flag=1$) vs. GP-SAVE. For all figures, axis x is the exact values and axis y is the predictions at the test points. The black solid line is the perfect correlation. } \label{fig:EllipticCor} \end{figure} The uncertainty propagation analysis is also performed for this model. With the dimension reduction matrix $M$ obtained by RMFGP model with $flag=1$, a new Gaussian process surrogate can be built by pre-processing all training data with $M$ to reduce the input dimension to $d=2$. Then, 2000 samples for $\bold{\xi}$ are drawn from an i.i.d uniformly distribution. Figure $13$ presents the average of means and standard deviations(std) of those $2000$ cases along with $50$ different $x$ in $[0,1]$. The $x$-axis represents the indexes of different $x$ values. The $y$-axis is the average mean for $(a)$ and std for $(b)$ in each case. The ground truth is the black line. The green diamond line is obtained by pure SAVE method if we give large enough training data, i.e. high-fidelity data samples. Here, we give $10000$ samples in order to get this results. Note that there are only $35$ high-fidelity samples in RMFGP model. From Figure $13(a)$, all four method have similar performance. However, Figure $13(b)$ shows that our RMFGP method has smaller std compared to GP-SAVE method. This shows RMFGP is more confident about the predictions. \begin{figure}[h] \centering \subfloat[a][]{ \includegraphics[width=1\textwidth]{EllipticUQmean40.png} \label{fig:EllipticUQmean40}} \\ \qquad \subfloat[b][]{ \includegraphics[width=1\textwidth]{EllipticUQstd40.png} \label{fig:EllipticUQstd40}} \caption{Average prediction means and standard deviations of elliptic equation - Equation (13) at $N_H=35$: (a) average mean; (b) average standard deviation. For all figures, the axis $x$ represents the indexes of different $x$ values in $[0,1]$ and the axis $y$ represents the average mean or std values. The ground truth is the black line. The green diamond line is obtained by pure SAVE method with $10000$ high-fidelity data samples. The blue star line is results of GP-SAVE method. Our RMFGP method with $flag=1$ is represented by the red square line. Both those two methods are using $35$ high-fidelity samples. } \label{fig:EllipticUQ} \end{figure} \section{Conclusion} In this paper, a new dimension reduction framework based on the multi-fidelity Gaussian process, the SAVE dimension reduction method and Gaussian process dimension reduction technique is established to estimate the central subspace and increase the prediction accuracy under the condition where only limited precise data is available. Two different approaches to build a final surrogate model can be chosen based on the $flag$ parameter in the algorithm. Based on the property that the uncertainties can be naturally quantified in a Gaussian process regression, Bayesian active learning is involved to enhance the efficiency of the method. Four numerical examples are presented in order to illustrate the ability of the proposed RMFGP model to extract the principle directions and build a corresponding surrogate model to increase the prediction accuracy under different situations. The dimension reduction methods to computed the rotated matrices in this paper are SAVE type of methods. Other methods such as SIR, active subspace\cite{acs} can also be fed to the algorithm based on different tasks. In particular, investigating the regression tasks with missing data or labels can be interesting in the future works. Another potential future work is to find an approach to determined the optimal dimension $s$ if parameter $flag=1$ in the algorithm. With the proposed RMFGP model, one can build up an accurate surrogate model with lower dimensional inputs than the original data. As shown in the numerical examples, This model can be used to exclude the effect of various noises. It can also help some applications where only few indexes are allowed to represent the system. Additionally, this model requires fewer precise data to construct in a high-dimensional problem, which can save up computational resources in many applications. \bibliographystyle{abbrv}
{'timestamp': '2022-04-12T02:29:19', 'yymm': '2204', 'arxiv_id': '2204.04819', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04819'}
arxiv
\section{Introduction} Word embeddings (WE's) are one of the most popular outcomes of deep learning algorithms in the realm of natural language processing. They are applied in a broad range of downstream applications such as question answering, word sense disambiguation, reading comprehension, summarization, etc. This is largely due to their success in capturing semantics of words in terms of finite and relatively low dimensional vectors. In a simple way, they are able to capture meaning of words without feeding any external knowledge, just by going through a raw corpus of words. In fact they do keep track of each word's context. In addition to this influential characteristic, WE's seem to have yet another, almost neglected characteristic of capturing rhythmic similarity between words, especially in the literature corpora. But what does that mean? To answer this question, it is needed to first define Rhythmic Similarity and then determine what's the meaning of capturing. \subsection{What is Rhythmic Similarity (RS)?} For the purpose of this project, we define two given words as rhythmically similar, if they are said (pronounced) with similar sounds, specially at their ending or beginning. For example, the words 'doom' and 'gloom' have rhythmic similarity because they both are ended with the sound: /\textipa{u:m}/, another example is 'cheese' and 'peas' \footnote{The example is taken from BBC website: \href{https://www.bbc.co.uk/bitesize/topics/zjhhvcw/articles/zqjgrdm}{https://www.bbc.co.uk/bitesize/topics/zjhhvcw/articles/zqjgrdm}}. Even words like 'tend' and 'tell' are rhyming words, to a lesser degree though. Thus we will need a metric to assess this degree, and this will be introduced in section \ref{sec:metrics} Having defined RS in the above terms, this research tries to investigate if WE's can capture RS? Here by capturing we mean, if the geometric relationship between vectors do represent any other relation as well? In particular, if the proximity of vectors represents the RS as well? and if yes, to what extent? This is analogous to the famous concept of capturing semantic similarities, whereby we have witnessed that vectors embedded in a neighboring space tend to have similar meanings. Considering the above question as the topic of this research, the next step is to describe how we want to seek an answer for it. Thus we define a short hypothesis to make our research process more clear. \subsection{Hypothesis} \label{sec:hypothesis} The hypothesis we are going to investigate in this study is that "Word embeddings assign similar vectors to the words which are rhythmically similar". We want to see if this is true and if yes, to what extent? We investigate this on several datasets and texts including literature and non-literature ones. We also examine this from the perspective of several WE's to see how different they act on this regard. In the remaining of this paper, a review on the literature is presented in the section \ref{sec:literature}, the methodology is explained in section \ref{sec:methodology}, the experiments are introduced in section \ref{sec:experiments}, section \ref{sec:results} demonstrates their results, and finally section \ref{sec:conclude} concludes the discussion and presents some future works. \section{Literature Review} \label{sec:literature} Digital representation of natural language (mostly words and sentences) for computer processing has been a major challenge from the early days of research in this area\cite{camacho2018word}. Simple intuitive solutions such as one-hot encoding had left researchers with sparse vectors of long length, at the order of millions, which were challenging to process. Used as features, such trivial vectors were representing nothing but the presence of words. Then, semantic space models, LDA, LSI, and LSA emerged and led to the use of more compact vectors \cite{blei2003latent}, \cite{dumais1994latent}, \cite{landauer1998introduction}. Later on, the introduction of Neural Networks triggered the development of hugely successful models such as Word2vec \cite{Mikolov2013} and GloVe \cite{pennington2014glove}. And more recently, with the boom of Deep Learning, many more embeddings are brought about, among which BERT\cite{devlin2018bert}, ELMO\cite{Peters2018}, and GPT\cite{radford2019language} have gained a huge reputation. Getting inspiration from the primitive models and making revisions of WE’s for different purposes, has been a major trend in recent years. For example, Jameel and Schockaert in \cite{jameel2016d} presented D-GloVe which represents each words with a probabilistic density to reflect the uncertainty of meaning based on both the frequency of words in the corpus and their informativeness. In another work\cite{shi2017jointly}, Bei Shi et.al proposed STE model which learns WE’s and topic models at the same time. Their architecture utilizes a generating function to represent topics with vectors, and also improves the traditional skip-gram model of Word2vec by EM-negative sampling. They demonstrated that such a model is able to generate more meaningful WE’s which also represent coherent topics. However, all of the above mentioned systems are centered around semantics. Consequently, the phrases "word similarity" and "similar words" are extensively used in the literature. In this work, we aim to add a finer level of precision, and draw attentions to the fact that the notion of similarity can be defined from different perspectives. Although the above terms are used normally for referring to "word semantic similarity" and "semantically similar words" respectively, there are other aspects such as "morphological" or "rhythmic" similarity as well. And these other aspects are important to be studied.  In regard to the importance of various types of similarity, it would be useful to take a look at one of the groundbreaking papers of the field. In the very famous paper of Mikolov et.al \cite{Mikolov2013} by which Word2vec was introduced to the scientific community, they have written:  \begin{quote} \textit{ "We use recently proposed techniques..., with the expectation that not only will similar words tend to be close to each other, but that words can have \textbf{multiple degrees of similarity}" } \end{quote}.  And then, to exemplify another degree of similarity (in addition to semantics), Mikolov mentions the "similarity of endings":  \begin{quote} \textit{ "This has been observed earlier in the context of inflectional languages - for example, nouns can have multiple word endings, and if we search for similar words in a subspace of the original vector space, it is possible to find words that have similar endings".  } \end{quote} Although, this paper has been one of the top referenced and most influential studies in the literature, this particular statement has been rarely noticed. To the best of our knowledge, no further expansion on this direction has been done, neither by the authors of that paper nor by any other researchers. Even earlier observations cited in the above statement, didn't try to quantify this claim and assess its statistical significance. Thus, we think this is a valuable and novel contribution to pursue. \section{Methodology} \label{sec:methodology} In this section we're going to elucidate in details how we will try to verify our hypothesis (section \ref{sec:hypothesis}). First, we formulate our method and then introduce RS metrics as it is the the core concept of this work. In order to verify our hypothesis for a specific WE on a specific corpus C, we first generate WE vectors for C. Then using a clustering method, we put the nearer vectors and corresponding words into $k$ clusters. Then we propose some metrics to quantify the degree of Rhythmic Similarity (RS). Using that metric, we measure RS of each pair of words inside a cluster $c_i$, $0<i\leq k$, and then calculate the average RS of each cluster, $\overline{RS_{c_i}}$, $0<i\leq k$. \begin{equation} \label{eq-cluster-rs} \overline{RS_{c_i}} = \frac{\sum_{x=1}^{n_i}\sum_{y=x+1}^{n_i}RS(w_{i,x}, w_{i,y})}{\frac{n_i*(n_i-1)}{2}} \end{equation} where $n_i$ is number of words inside $i$th cluster, $w_{i,j}$ is the $j$th word of the $i$th cluster, and $RS(w_i, w_j)$ is a real number between 0 to one representing how similar the words $w_1$ and $w_2$ are to each other from rhythm perspective. See section \ref{sec:metrics} for a formal definition. Then we can take an average over all clusters, to have an overall sense of how homogeneous the clusters are in terms of RS. \begin{equation} \label{eq-curpus-rs} \overline{RS} = \frac{\sum_{i=1}^{k}\overline{RS_{c_i}}}{k} \end{equation} where $k$ is total number of clusters. If this number tends towards one, this means that the majority of clusters have a high degree of RS, which in turn means the majority of words inside each cluster have high RS. However, since this average is taken over many numbers ($k$ is in the order of thousands or more), many numbers might neutralise each other, and we lose information. Thus, we can divide the range from 0 to 1 into some bins, and count the number of clusters which fall in the same bin in terms of $RS_{c_i}$. Drawing the histogram, if bins near 1 are occupied by more clusters, this proves that WE has been successful in assigning vectors near each other in the embedding spaces to the rhymes and assonances. In order to assess the extent of this behaviour better, a baseline is needed. Therefore, we randomly put words inside $k$ new clusters, and compute the average RS of random clusters $\overline{RS_{rc_i}}$ , $0<i\leq k$. In other words, we compute the equation (\ref{eq-cluster-rs}) again, but this time over the random clusters instead of clusters based on WE. Then, comparing the $\overline{RS_{c_i}}$ with the baseline, if they tend to have larger values, this means that WE clusters have higher RS compared to random clusters and this proves our hypothesis. If we found that a majority of WE clusters have the same or lower RS as that of random clusters, this means that WE vectors aren't able to capture RS significantly. Many parameters of the above experiment can be altered to investigate their effect on the hypothesis. For example we can use different corpora, different clustering methods, different WE's with different parameters, and so on. But more important than any other aspect, a metric for measuring RS can affect our evaluation. Thus it is needed to define some metrics first. \subsection{Metrics for Rhythmic Similarity} \label{sec:metrics} In the early observations of this project, we witnessed that words whose vectors have fallen within the same cluster, are almost similar in their ending or beginning letters. But how similar they are? And how we can compare two clusters in this regard? In order to answer this question we devised a simple formula that acts on the basis of corresponding letters in the input pair. Specifically, it takes number of common letters in the same positions into account, starting from the end of words. This is then divided by total number of letters. \begin{equation} \label{eq-rs-basic} RS _{}(w_1,w_2)= {\frac { \sum _{i=1}^{cl} \begin{cases} \mbox{1,} & \mbox{if } letter(w_1, i)==letter(w_2, i) \\ \mbox{0,} & \mbox{otherwise} \end{cases} } {max(length(w_1), length(w_2)) } } \end{equation} where $cl$ is the common length of $w_1$ and $w_2$ i.e. $min(length(w_1) , length(w_2))$ and $letter(w, i)$ is the $i$th letter of $w$ starting from the end. So for example, $RS(h\textcolor{teal}{ustle}, b\textcolor{teal}{ustle})=5/6=0.83$, $RS(h\textcolor{teal}{o}l\textcolor{teal}{y}, technol\textcolor{teal}{o}g\textcolor{teal}{y})=2/10=0.2$ $RS(rotation, positions)=0/9=0$ because starting from the end, they have no letter in common. The range of values this metric produces is from 0 (entirely dissimilar) to 1 (totally similar). These values can be multiplied by 100 and expressed in terms of percentage. Clearly, this metric is naive and not very precise, since it is too sensitive to the location of letters. As we saw in the last example, a single s letter in the end of the word, made all other letters misaligned and set RS to zero, whilst they are highly similar, intuitively. This metric also does not distinguish between consonants and vowels, whereas we know that vowels play a more significant role in rhythm compared to consonants. Consider for example, $RS(r\textcolor{teal}{e}f\textcolor{teal}{i}n\textcolor{teal}{e}, d\textcolor{teal}{e}v\textcolor{teal}{i}s\textcolor{teal}{e})=3/6=0.5$ which by intuition seems relatively low, but if we consider only vowels, the new $RS$ would be $3/3=1$ which seems more realistic. Syllabification is also a very influential parameter in measuring assonance between words, but is not considered in this primitive metric. Another idea is to compare IPA transcription of the words since they represent phonetic similarities better. For example, for words "cheese" and "peas", $RS(che\textcolor{teal}{e}se, p\textcolor{teal}{e}as)=1/6=0.17$ but if we define: \begin{equation} \label{eq-rs-ipa} RS_{IPA}(w_1, w_2)=RS(IPA(w_1), IPA(w_2)) \end{equation} where $IPA(w)$ means IPA representation of the word $w$, then we have $RS_{IPA}(cheese , peas) = RS($\textipa{tS\textcolor{teal}{i:z}} $,$ \textipa{p\textcolor{teal}{i:z}}$)=3/5=0.6$ and this value seems more reasonable. However, for the purpose of this study, the basic metric (\ref{eq-rs-basic}) is adequate and preferable in terms of performance in run time. \section{Experiments} \label{sec:experiments} In this section we describe what experiments are designed to verify hypothesis practically. \subsection{Corpora} The early observations of this project were based on Quran corpus \cite{zeroual2016new}, whereby we witnessed that words whose vectors have fallen within the same cluster, are almost similar in their ending or beginning letters\cite{linkedin}. However, we evaluated our experiments on two other corpora as well to see if the same phenomenon can be witnessed in other texts or not. The second corpus is taken from a collection of poetic texts in English, from Gutenberg dataset \cite{bird2009natural}. The third corpus is taken from CNN news \cite{lins2019cnn}, which we know contains less rhythmic content. Since Quran contains around 17K unique words, we taken the size of the other datasets in a way to cover, roughly, the same number of unique words, so to keep our comparison balanced and unbiased. See table (\ref{tab:corpora} for more details. \begin{table} \caption{Overview of corpora} \centering \begin{tabular}{llll} \cmidrule(r){1-4} Name & \#All words & \#Unique words & Average Word Length \\ \midrule Quran & 82,624 & 17,627 & 9.77 \\ Gutenberg & 166,000 & 16,545 & 6.63 \\ CNN & 529,359 & 26,279 & 7.45 \\ \bottomrule \end{tabular} \label{tab:corpora} \end{table} \subsection{Word Embeddings} In this study we examined Word2Vec \cite{Mikolov2013} and GloVe \cite{pennington2014glove} to see how they capture RS between words. Nevertheless the same methodology can be applied to other WE's as well. For generating Word2Vec vectors, we used the Gensim library in Python and for GloVe, the original implementation by \cite{pennington2014glove}. For both methods we set the size of vectors=100, size of window is set to 15, and min\_count=1 which means all words are taken into account. Other parameters are set to default as defined in version 4.1.2 of Gensim and latest version of GloVe\footnote{see \href{https://github.com/stanfordnlp/GloVe/blob/d470806c6c23c6698a02d533c0497f4c25c98a77/demo.sh}{https://github.com/stanfordnlp/GloVe/blob/d470806c6c23c6698a02d533c0497f4c25c98a77/demo.sh}}. \subsection{Clustering} For clustering, we used K-means with k = 1000 and cosine distance as the measure for the geometric distance of vectors in the embedding space. However, other clustering methods, other values for k, and other distance measures can be investigated in future works. \section{Results} \label{sec:results} The results of the experiments can be demonstrated in two forms. The simplest way is to compare $\overline{RS}$ of clusters when made by WE's with the same metric when clusters are made randomly. This is shown in table \ref{tab:result}. As you can see, the $\overline{RS}$ of random clusters is approximately 5$\sim$6, meaning that on average, words inside each cluster have been 5 to 6\% similar to each other in terms of rhythm and assonance. Considering these numbers as the baseline, it is obvious that clusters of Word2Vec and GloVe have been more homogeneous rhythmically, as their $\overline{RS}$ have been higher than baseline. If we compare corpus-wise, we expect the Gutenberg clusters to bear more $\overline{RS}$ because they are more poetic, and this is the case for both random clusters and GloVe. For Word2vec, however, this isn't true which can be attributed to the global nature of Word2Vec and proximity of rhymes in poems. In other words, in poetic texts, rhymes occur near each other, but Word2Vec mixes all words of the corpus and doesn't care about the relative position of words. In contrast, GloVe, using a local context window moving over words, makes it possible for the $RS$ of neighboring words to be reflected in the vectors. This trend is more obvious in Quran, as GloVe clusters have gained $\overline{RS}=12$, as twice as Word2Vec and random clusters. This can be also due to the fact that Quran contains more rhythmic content, as almost all adjacent sentences end with rhymes. An evidence for this is that even $\overline{RS}$ of random clusters of Quran is 6.90, visibly higher than that of CNN and Gutenberg, which are 5.48 and 5.80, respectively. \begin{table} \caption{Average RS ($\overline{RS}$) of clusters} \centering \begin{tabular}{llll} \cmidrule(r){1-4} Name & Quran & CNN & Gutenberg \\ \midrule Word2Vec & 7.26 & 6.73 & 6.03 \\ GloVe & 12.16 & 7.03 & 7.20 \\ Random & 6.90 & 5.48 & 5.80 \\ \bottomrule \end{tabular} \label{tab:result} \end{table} The above method, i.e. computing average, has a drawback that even if some clusters have high $\overline{RS}$, their effect on average might be neutralised by other clusters having low $\overline{RS}$. Therefore, another way to demonstrate the results, is to count how many WE clusters have $\overline{RS}$=100\% and compare this value with that of random clusters. Repeating this over all possible values of RS ($0\le{RS}\le 100$) gives us a sense of how well that WE is performed in assigning nearer vectors to rhymes. Such data can be best represented with histograms. For drawing them, we broken the range from zero to 100 into 100 bins, and counted the number of clusters whose $\overline{RS}$ falls inside the range of each bin. This stats is computed for both random clustering and WE clustering. Regarding CNN corpus, the figures \ref{fig:cnn-w2v} and \ref{fig:cnn-glove} show this stats for Word2Vec and GloVe respectively. For Gutenberg corpus, figures \ref{fig:poems-w2v} and \ref{fig:poems-glove} and for Quran, figures \ref{fig:quran-w2v} and \ref{fig:quran-glove} show the similar stats, respectively. The same patterns as we saw in mean RS, can be discerned here. In all charts, the random clusters (in orange color) hardly spread beyond 15. This means that when we cluster words randomly, the $\overline{RS}$ of clusters is at most 15\% (the red line). Contrastingly, when clustered by Word2Vec or GloVe (the blue bars), the $\overline{RS}$ spreads over a wider range and the area below the bars is noticeably larger. This means that WE clusters are more homogeneous in terms of rhymes. And overall, we can say that WE's tend to assign similar vectors to the rhyming words and thus caused them to be placed in the same clusters. \begin{figure} \centering \includegraphics[width=0.6\textwidth]{images/cnn/WordToVec.jpg} \caption{The bottom chart in orange shows that all random clusters have had $\overline{RS}$ below 10\%. In contrast, the blue chart shows that Word2Vec clusters are more distributed over higher ranges of RS. The chart is log-scaled.} \label{fig:cnn-w2v} \end{figure} \begin{figure} \centering \includegraphics[width=0.6\textwidth]{images/cnn/Glove.jpg} \caption{The blue chart is more spread over x axis compared with the orange one and also compared with the blue chart of figure \ref{fig:cnn-w2v}. This suggests that GloVe clusters have more RS than random or Word2Vec clusters.} \label{fig:cnn-glove} \end{figure} \begin{figure} \centering \includegraphics[width=0.6\textwidth]{images/gutenberg/WordToVec.jpg} \caption{Results for the Gutenberg corpus. RS is more distributed for Word2Vec clusters (the blue chart), compared with random clusters (the orange chart).} \label{fig:poems-w2v} \end{figure} \begin{figure} \centering \includegraphics[width=0.6\textwidth]{images/gutenberg/Glove.jpg} \caption{Outcome of Gutenberg corpus for GloVe. Again, compared with random clusters and compared with Word2Vec in figure \ref{fig:poems-w2v}, this chart demonstrates that GloVe performs better in capturing RS.} \label{fig:poems-glove} \end{figure} \begin{figure} \centering \includegraphics[width=0.6\textwidth]{images/quran/WordToVec.jpg} \caption{Output of experiment for Quran corpus. Although the spread is not as much as previous corpora (figures \ref{fig:cnn-w2v} and \ref{fig:poems-w2v}), but the area below the blue chart is clearly larger than that of random chart. } \label{fig:quran-w2v} \end{figure} \begin{figure} \centering \includegraphics[width=0.6\textwidth]{images/quran/Glove.jpg} \caption{Output of experiment for the Quran corpus and the GloVe clusters. The same trend can be seen, as in the other two corpora.} \label{fig:quran-glove} \end{figure} \section{Conclusion} \label{sec:conclude} In this study, we tried to figure out if WE's are capable of capturing RS and how much? We discussed that this property of WE's is mentioned in the pioneering works of the field but never got enough attention. We formulated a hypothesis and investigated it on several corpora and several WE's. The results showed that when we cluster words based on their WE vectors, word having higher RS tend to be in the same clusters. Even though the words in a cluster aren’t absolute rhymes, but the probability of a rhyme pair to be in a WE cluster is more than that of random clusters. As future works, one can examine more WE's and verify the same hypothesis on them. Also more fine-grained RS metrics can be proposed, specifically to take syllabification into account. Another interesting line of research is to develop new WE's that intentionally capture RS, i.e. their objective function would be maximizing RS between words. The code of this research is publicly available at Github\footnote{see \href{https://github.com/HRezaei/rhymes}{https://github.com/HRezaei/rhymes}}. \newpage \bibliographystyle{unsrt}
{'timestamp': '2022-04-15T02:13:41', 'yymm': '2204', 'arxiv_id': '2204.04833', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04833'}
arxiv
\section{Introduction} \IEEEPARstart{I}{n} emerging mobile communication systems, various techniques introduces additional degrees of freedom to the transmission systems in order to exploit the multiplexing gain and boost the achievable rate, e.g. large-scale MIMO systems. However, the achievable rate is actually upper bounded by the correlation among the antennas. To introduce higher degrees of freedom, a new technology known as Intelligent Reflecting Surface (IRS) has recently been proposed to shift the phase of the incident signal by a controllable amount \cite{Chongwen19}. IRS consists of a metamaterial integrated with electronic circuits, including a controller, that can alter some of the electronic component properties in such a way as to achieve the desired phase shift amount \cite{Samith20}. IRS thus provides the ability to enhance the throughput of the wireless communication system by adjusting the phase shifts dynamically as required to achieve the constructive interference of the received signal at the destination \cite{LiYou21}. Numerous studies have considered the use of IRS in improving the throughput of wireless network. For example, Xiu et al. \cite{YueXiu21} maximized the secrecy rate of an IRS-aided millimeter-wave system with low-resolution digital-to-analog converters (DACs). Wang et al. \cite{JunWang21} considered a two-way relay network wherein an IRS was deployed to enhance the minimum capacity of the two users. Guo et al. \cite{Guo20} examined the problem of maximizing the weighted sum-rate in an IRS-assisted multiuser MISO system subject to both perfect and imperfect channel state information (CSI). To reduce the computational complexity, {\color{black}the authors in \cite{Boyu20} derived a simplified criterion, namely sum-path-gain maximization (SPGM), and utilized} and alternating direction method of multipliers (ADMM) algorithm to {\color{black} enhance} the sum rate of the IRS-aided MIMO systems \cite{Boyu20}. Although the ADMM method reduced the computational complexity, it came with the price of the degraded sum rate {\color{black}since the ADMM maximizes sum-path-gain indirectly}. With this regard, we propose a novel algorithm designated as Dimension-wise Sinusoidal Maximization (DSM) to solve the {\color{black}SPGM} problem in \cite{Boyu20}, in order to boost the sum rate. For the well-known of an IRS phase-shift of $\phi=e^{j\theta}$, DSM operates directly on the variable of interest $\theta$, which is real, rather than $\phi$, which is complex and restricted by a unity absolute value. Notably, by regarding $\theta$ as the variable of interest, the problem can be solved using the traditional zero-gradient technique. Hence, {\color{black}As demonstrated by the simulation results, the proposed DSM algorithm achieves near maximal sum capacity with faster convergence and lower complexity.} \section{System Model and Problem Formulation} Consider a MIMO communication system wherein a $K$ antenna-equipped source (S) transmits $U$ parallel data streams, denoted by $\mathbf{u} \in \mathbb{C}^{U\times 1}$ with $\mathbb{E}\left[\mathbf{u}\uu^H\right] =\mathbf{I}_U$, $U\leq K$, to an $L$ antenna-equipped destination (D) with the assistance of an IRS consisting of $N$ reflecting elements (see Fig. \ref{fig:SystemModel}). S processes the signal through linear precoding, $\mathbf{T}\in\mathbb{C}^{K\times U}$, and then broadcasts it to IRS and D simultaneously. Let $\mathbf{H}\in\mathbb{C}^{N\times K}$, $\mathbf{G}\in\mathbb{C}^{L\times N}$ and $\mathbf{F}\in\mathbb{C}^{L\times K}$ be the channels from S to IRS, IRS to D, and S to D, respectively. The IRS shifts the phases of the incident signal by an amount $\boldsymbol{\theta}=[\theta_1,\cdots,\theta_N]^T\in\mathbb{R}^N$. The post-processed received signal at D is thus obtained as \begin{figure} \centering \includegraphics[width=0.55 \columnwidth]{SystemModel} \caption{System Model.} \label{fig:SystemModel} \end{figure} \begin{equation} \mathbf{y} = \left(\sqrt{P/U}\right) \mathbf{R}\left(\mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)\mathbf{T}\mathbf{u} + \mathbf{n}, \end{equation} where $P\geq 0$ is the total transmitted power, $\mathbf{\Phi}=\text{diag}\left[\phi_1, \cdots, \phi_N\right]$ with $\phi_n=e^{j\theta_n}, \forall n\in\mathcal{N} =\left\{1,\cdots,N\right\}$, $\mathbf{R}\in\mathbb{C}^{U\times L}$ is the linear post-coding matrix at D, and $\mathbf{n}\sim\mathcal{CN} \left(0,\mathbf{I}_L\right)$ is zero-mean additive Gaussian noise. This letter aims to maximize the end-to-end rate by jointly optimizing the pre-coding $\mathbf{T}$, post-coding $\mathbf{R}$, and IRS phase shifts (PSs) $\boldsymbol{\theta}$ subject to the available power $P$ at S. The value of $U$ is set to be $U=\text{rank}(\HH_{\text{eff}})$ in order to maximally exploit the MIMO spatial diversity, where $\HH_{\text{eff}} = \mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}$. The end-to-end capacity from S to D is then given by \begin{equation} \label{eq:capacity1} R = \log_2 \det\left(\mathbf{I}_L + \frac{P}{\sigma^2 U} \HH_{\text{eff}}\mathbf{T} \mathbf{T}^H\HH_{\text{eff}}^H \right). \end{equation} In a MIMO system, the pre-coding matrix $\mathbf{T}$ and post-coding matrix $\mathbf{R}$ can be obtained from the singular value decomposition (SVD) of the given $\HH_{\text{eff}}$. Specifically, let the SVD of $\HH_{\text{eff}}$ be given by $\HH_{\text{eff}}=\mathbf{U}\mathbf{\Lambda}\mathbf{V}^H$, where $\mathbf{U}\in\mathbb{C}^{L\times L}$ and $\mathbf{V}\in\mathbb{C}^{K\times K}$ are unitary, and $\mathbf{\Lambda}\in\mathbb{R}^{L\times K}$ is diagonal with positive diagonal entries given by the singular values in descending order, i.e., $\lambda_1 \geq\lambda_2 \geq\cdots \geq\lambda_U$. Hence, the optimal post-coding and pre-coding matrices are given by $\mathbf{R}^{\text{opt}}=\mathbf{U}^H$ and $\mathbf{T}^{\text{opt}}=\mathbf{V}\hat{\PP}^{1/2}$, respectively, where $\hat{\PP}=\left[\text{diag}(p_1, \cdots, p_U), \mathbf{0}_{U\times K-U}\right]^T \in\mathbb{R}^{K\times U}$, and $p_u\geq0$ denotes the transmitted power allocation (PA) to the $u$-th data stream, $u\in\mathcal{U}=\left\{1,\cdots,U\right\}$. According to this scheme, the effective channel, $\HH_{\text{eff}}$, is equivalent to $U$ parallel single-input single-output (SISO) spatial paths, with $\lambda_u$ being the channel of the $u$-th path. The capacity of the $u$-th eigen-channel can be re-expressed as $\hat{R}_u = \log_2\left(1+\frac{Pp_u\lambda_u^2}{\sigma^2 U}\right)$. The problem of maximizing the end-to-end rate of the system thus turns into that of maximizing the sum capacity of the equivalent SISO channels. That is, \begin{align} \label{prob:main} \begin{array}{rrclll} \displaystyle \max_{\hat{\PP},\boldsymbol{\theta}} & \multicolumn{3}{l} {R = \sum_{u=1}^{U} \log_2\left(1+\frac{Pp_u\lambda_u^2}{\sigma^2 U}\right)} \\ \textrm{s.t.} & \mathbf{U}\mathbf{\Lambda}\mathbf{V}^H & = & \mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}, & \lambda_u = \left[\mathbf{\Lambda}\right]_{uu}, & \\ & \left[\mathbf{\Phi}\right]_{nn} & = & e^{j\theta_n}, & \forall n\in\mathcal{N}, & \\ & \sum_{u=1}^{U} p_u& = & U. & & \end{array} \end{align} The optimal power allocation, $\hat{\PP}$, can be obtained by the water-filling (WF) procedure for a fixed $\boldsymbol{\theta}$ \cite{Proakis2007}. Specifically, the optimal $p_u$ can be obtained as \begin{equation} p_u = \max\left(\eta - \frac{\sigma^2 U}{P\lambda_u^2}, 0\right), \end{equation} where $\eta$ is a constant set in such a way as to meet the sum power constraint which can be found numerically. It can be seen from (\ref{prob:main}) that $\lambda_u, \forall u\in\mathcal{U}$ indicates the quality of the effective channel, $\HH_{\text{eff}}$, since $\hat{R}_u$ monotonically increases with $\lambda_u, \forall u\in\mathcal{U}$. However, it is difficult to find the optimal value of $\boldsymbol{\theta}$ in (\ref{prob:main}) due to its implicit relation with $\lambda_u, \forall u\in\mathcal{U}$ via the SVD of $\HH_{\text{eff}}$ and the non-linear operation of the power allocation (PA). Thus, to determine the value of $\boldsymbol{\theta}$ which maximizes the sum rate of the considered MIMO system, this letter uses the sum-path-gain maximization (SPGM) criterion proposed in \cite{Boyu20} to tackle this implicit relation. \section{Phase Shifts Design under SPGM Criterion} \label{sec:methods} To facilitate the optimization problem, this article employs the SPGM criterion, which aims to maximize the sum of the eigen-channel gains, i.e. $\sum_{u=1}^{U} \lambda_u^2$, to enhance the quality of the effective channel $\HH_{\text{eff}}$. It is noted that this criterion was shown in \cite{Boyu20} to be the lower bound of the sum-rate in (\ref{prob:main}) under an equal PA assumption. Since $\lambda_u^2$ is the $u$-th eigenvalue of $\HH_{\text{eff}}^H \HH_{\text{eff}}$, it follows that $\sum_{u=1}^{U} \lambda_u^2 = \text{tr}\left(\HH_{\text{eff}}^H \HH_{\text{eff}}\right)$. Accordingly, the optimization of $\boldsymbol{\theta}$ can be formulated as \begin{align} \label{prob:theta} \begin{array}{rrclll} \displaystyle \max_{\boldsymbol{\theta}} & \multicolumn{4}{l} {\psi\left(\boldsymbol{\theta}\right) = \text{tr}\left[\left(\mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H \left(\mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)\right]} \\ \textrm{s.t.} & \left[\mathbf{\Phi}\right]_{nn} & = & e^{j\theta_n}, & \forall n\in\mathcal{N}. & \end{array} \end{align} The problem in (\ref{prob:theta}) is not convex since the equality constraint is not affine. Thus, this article solves (\ref{prob:theta}) using a self-developed algorithm, designated as the 'Dimension-wise Sinusoidal Maximization' (DSM) algorithm, whose concept is similar to that of the well-known Block Coordinate Descent algorithm \cite{Xu13}. In particular, DSM exploits the fact that, for a particular $n$, $\psi(\boldsymbol{\theta})$ is sinusoidal w.r.t. $\theta_n$ given fixed $\theta_{\hat{n}}, \forall \hat{n}\in\mathcal{N}\backslash n$ (see Lemma \ref{lem:1} below). DSM hence alternately maximizes $\psi(\boldsymbol{\theta})$ w.r.t. each element of $\boldsymbol{\theta}$, i.e. $\theta_n, \forall n\in\mathcal{N}$. It is shown later in this article that $\psi(\boldsymbol{\theta})$ is block-sinusoidal w.r.t. $\theta_n$, and the optimal $\theta_n$ can be obtained by a closed-form solution {\color{black}when the other phases are given.} {\color{black}To facilitate the DSM algorithm, let us start with} a {\color{black}more general} case wherein $\mathbf{\Phi}\in \mathbb{C}^{M\times N}$ is a full matrix rather than a diagonal matrix. Under this more stringent assumption, Lemma \ref{lem:1} and Theorem \ref{thm:1} are developed, which can then be applied to more general scenarios. The proposed DSM algorithm is then introduced to solve the optimization problem in (\ref{prob:theta}) by incorporating the Theorem \ref{thm:1} with a diagonal constraint on $\mathbf{\Phi}$. It is noted that the underlying equations that construct DSM for both cases of $\mathbf{\Phi}$ are quite similar except the element-indices. \begin{lemma} \label{lem:1} Consider the following problem \begin{align} \label{prob:thetaLemma} \begin{array}{rrclll} \displaystyle \max_{\mathbf{\Theta}} & \multicolumn{4}{l} {\hat{\psi}\left(\mathbf{\Theta}\right) = \normalfont{\text{tr}}\left[\left(\mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H \left(\mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)\right]} \\ \textrm{s.t.} & \left[\mathbf{\Phi}\right]_{mn} & = & e^{j\theta_{mn}}, & \forall m\in\mathcal{M}, n\in\mathcal{N}, & \end{array} \end{align} where $\mathbf{F}\in\mathbb{C}^{L\times K}$, $\mathbf{G}\in\mathbb{C}^{L\times M}$, $\mathbf{\Theta}\in\mathbb{R}^{M\times N}$, $\mathbf{H}\in\mathbb{C}^{N\times K}$, $\mathcal{M}=\left(1,\cdots, M\right)$ and $\mathcal{N}=\left\{1,\cdots,N\right\}$. The objective function $\hat{\psi}\left(\mathbf{\Theta}\right)$ is block-sinusoidal w.r.t. $\theta_{mn}, \forall m\in\mathcal{M}, \forall n\in\mathcal{N}$, with a period of $2\pi$, {\color{black} \textit{i.e.}, $\tilde{\psi}\left(\theta_{mn}\right) = \hat{\psi}(\mathbf{\Theta}) \rvert_{\theta_{\hat{m}\hat{n}}}$ is sinusoidal w.r.t. $\theta_{mn}$ given $\theta_{\hat{m}\hat{n}}, \forall \hat{m}\neq m, \forall\hat{n}\neq n$.} \end{lemma} \begin{proof} See appendix \ref{apx:Lem1}. \end{proof} {\color{black}From the proof in Appendix A, it shows that $\tilde{\psi}(\theta_{mn})$ has two extrema within one block-period, which satisfy the following conditions: \begin{subequations} \begin{align} \theta_{mn}^{(\normalfont{\text{opt}})} &= \angle\left[\mathbf{G}^H\left(\mathbf{F}+ \mathbf{G}\tilde{\mathbf{\Phi}}_{mn}\mathbf{H}\right)\mathbf{H}^H\right]_{mn}, \label{eq:lem1:a}\\ \theta_{mn}^{(\normalfont{\text{opt}})} &= \angle\left[\mathbf{G}^H\left(\mathbf{F}+ \mathbf{G}\tilde{\mathbf{\Phi}}_{mn}\mathbf{H}\right)\mathbf{H}^H\right]_{mn} + \pi, \label{eq:lem1:b} \end{align} \end{subequations} where $\tilde{\mathbf{\Phi}}_{mn}\in\mathbb{C}^{M\times N}$ is a matrix with entries of $\mathbf{\Phi}$ with the exception of that the $(m, n)$-th entry being zero. Because of the sinusoidal property of $\tilde{\psi}(\theta_{mn})$, one extremum is a maximum and the other is minimum. Theorem 1 further specifies the extrema by exploring their convexity/concavity. } \begin{theorem} \label{thm:1} {\color{black}Among two extrema described in Lemma 1, the one satisfying (\ref{eq:lem1:a}) achieves global maximum, while the other satisfying (\ref{eq:lem1:b}) achieves global minimum.} \end{theorem} \begin{proof} See appendix \ref{apx:Thm1}. \end{proof} Based on the derived solution of the optimization problem in (\ref{prob:thetaLemma}), the problem in (\ref{prob:theta}) can be regarded as a special case of that in (\ref{prob:thetaLemma}), wherein $M=N$ and $\mathbf{\Theta}$ is diagonal. Adopting the result in Theorem \ref{thm:1}, the off-diagonal entries in $\mathbf{\Theta}$ are set as zero and the $n$th diagonal entries, $\theta_n$, are iteratively updated using (\ref{eq:lem1:a}), $n=\{1,\cdots,N\}$. The updating procedure can be viewed as optimizing the individual variables $\theta_n, \forall n\in\mathcal{N}$ which are coupled within $\boldsymbol{\theta}$, where the optimal $\theta_n$ in each step is obtained via a closed-form solution. Since $\mathbf{\Theta}$ is a diagonal matrix, {\color{black}(\ref{eq:lem1:a}) can be re-expressed as \begin{align} \label{eq:update theta n} \theta_n^{(i)} = &\angle \Bigg[ f_{nn} + \sum_{\hat{n}=1}^{n-1} \exp \left(j\theta_{\hat{n}}^{(i)}\right) g_{n\hat{n}}h_{\hat{n} n} \nonumber \\ &+ \sum_{\hat{n}=n+1}^{N} \exp \left(j\theta_{\hat{n}}^{(i-1)}\right) g_{n\hat{n}}h_{\hat{n} n}\Bigg], \end{align} where $f_{nn} \triangleq \left[\mathbf{G}^H\mathbf{F}\mathbf{H}^H\right]_{nn}$, $g_{n\hat{n}} \triangleq \left[\mathbf{G}^H\mathbf{G}\right]_{n\hat{n}}$, $h_{\hat{n} n} \triangleq \left[\mathbf{H}\HH^H\right]_{\hat{n} n}, \forall n,\hat{n}\in\mathcal{N}$, and $i$ denotes the iteration index. Eq (\ref{eq:update theta n}) has a complexity of $\mathcal{O}\left(N-1\right)$ since it comprises $N-1$ multiplications and $N-1$ additions. } {\color{black}Because the condition of $\theta_n$ in (\ref{eq:update theta n}) is comprised of all the remaining angle $\theta_{\hat{n}}$, $\forall \hat{n}\neq n$, we propose Algorithm 1 to approach the optimal solution iteratively.} Algorithm \ref{alg:main} illustrates the basic steps in the method proposed in the present study for maximizing the sum capacity of the system shown in Fig. \ref{fig:SystemModel}. As shown, the algorithm consists of two one-time-executed procedures, namely DSM to obtain the optimal phase-shift, $\boldsymbol{\theta}$, (line \ref{alg:main:startDSM} - \ref{alg:main:endDSM}) and water filling (WF) to determine the optimal power allocation ,$\hat{\PP}$, and the desired output $R$ (line $\ref{alg:main:WF}$). Lines {\color{black} \ref{alg:main:startfor}-\ref{alg:main:endfor} consists of $N$ times execution of (\ref{eq:update theta n}), thus DSM has a complexity of $\mathcal{O}\left(N\left(N-1\right)\right)$ for each iteration $i$. } WF (line \ref{alg:main:WF}) has a linear complexity, $\mathcal{O}\left(N\right)$, when using the method proposed in \cite{Khakurel14}. \begin{algorithm} \caption{Finding The Global Maximum of Problem \ref{prob:main}} \label{alg:main} \SetAlgoLined \KwIn{$\mathbf{G}, \mathbf{H}, \mathbf{F}, P/\sigma^2$.} \KwOut{$R$.} Initialize $i=0$. Set an initial $\boldsymbol{\theta}$. \label{alg:main:startDSM}\\ Compute $f_{nn}=\left[\mathbf{G}^H\mathbf{F}\mathbf{H}^H\right]_{nn}$, $g_{n\hat{n}}=\left[\mathbf{G}^H\mathbf{G}\right]_{n\hat{n}}$, and $h_{\hat{n} n}=\left[\mathbf{H}\HH^H\right]_{\hat{n} n}$. \label{alg:main:cons}\\ \While{$\left|\psi\left(\boldsymbol{\theta}^{(i)}\right) - \psi\left(\boldsymbol{\theta}^{(i-1)}\right)\right| > \varepsilon$}{ Increase $i$.\\ \For{$n=1:N$}{ \label{alg:main:startfor} Update $\theta_{n}^{(i)}$ using (\ref{eq:update theta n}). \label{alg:main:eq}\\ } \label{alg:main:endfor} }\label{alg:main:endDSM} Compute $\HH_{\text{eff}} = \mathbf{F}+\mathbf{G}\mathbf{\Phi}\mathbf{H}$. $U=\text{rank}(\HH_{\text{eff}})$. Get $\mathbf{U}, \mathbf{\Lambda}, \mathbf{V}$ via SVD of $\HH_{\text{eff}}$. \label{alg:main:Heff} \\ Obtain $R$ by solving (\ref{prob:main}) with $\hat{\PP}$ as the variable of interest using WF procedure. \label{alg:main:WF} \end{algorithm} \section{Numerical Results} This section compares the performance, convergence rate, and complexity of the {\color{black}existing} methods for solving the optimization problem in (\ref{prob:theta}), namely DSM (the proposed method), Gradient Ascent (GA) \cite{Boyd04}, {\color{black}and} Alternating Direction Method of Multipliers (ADMM) \cite{Boyu20}. The steps required to solve (\ref{prob:theta}) using GA are the same as those given in Algorithm \ref{alg:main} with the exception of replacing the statements in lines \ref{alg:main:startfor} to \ref{alg:main:endfor} with $\boldsymbol{\theta}^{(i)} = \boldsymbol{\theta}^{(i-1)} \pm \alpha \cdot \partial \psi(\boldsymbol{\theta})/\partial \boldsymbol{\theta}$, where $\partial \psi(\boldsymbol{\theta})/\partial \boldsymbol{\theta}$ is deducted from (\ref{eq:df1/dtheta 2}) as \begin{equation} \label{eq:dpsi dthetaVect} \frac{\partial \psi(\boldsymbol{\theta})}{\partial \boldsymbol{\theta}} = -2\, \text{diag}\left(\Im \text{m}\left\{\mathbf{\Phi}\circ\left[\mathbf{H}\left(\mathbf{F} +\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H\mathbf{G}\right]^T\right\}\right). \end{equation} {\color{black}The detailed procedure to solve (\ref{prob:theta}) using ADMM} {\color{black}has been} explained in \cite{Boyu20}. {\color{black}Since SPGM criterion may lead to sub-optimal solution to the maximization of sum capacity in the problem (3), we apply exhaustive grid search that maximizes the sum capacity directly, in order to provide a benchmark of the global optimum. Particularly, the phase of each entry in $\boldsymbol{\theta}$ is quantized with step size $2\pi/Q$ in the exhaustive grid search. In the following simulations, the value of $Q$ is set as $Q=2049$.} {\color{black}Because it is highly possible that the channel from S to IRS or the channel from IRS to D exists the line-of-sight (LOS) path, the channel matrices $\mathbf{G}$ and $\mathbf{H}$ are modeled as Rician fading channel, containing LOS and Non-LOS components. On the other hand, the channel from S to D is assumed Rayleigh fading channel, which simply contains Non-LOS term. In the following simulations, antenna numbers are set as $K=16$ and $L=12$. The LOS component is set as the uniform linear array configuration, while the entries in the Non-LOS components are i.i.d. complex Gaussian distributed with zero mean unit variance. The Rician factors for both $\mathbf{G}$ and $\mathbf{H}$ are set as $\beta =10$ dB \cite{Boyu20}}. The other parameters are assigned the specific values shown in the figures. \begin{figure} \centering \includegraphics[width=0.75 \columnwidth]{rev2_SE_vs_Ps} \caption{{\color{black}Comparison of spectrum efficiency} given $N=64$ and $N=16$.} \label{fig:SE vs P} \end{figure} \begin{figure} \centering \includegraphics[width=0.75 \columnwidth]{rev2_IterNum_vs_N} \caption{{\color{black}Comparison of the average} iteration {\color{black}numbers} {\color{black}required to achieve} two termination criteria {\color{black} $\varepsilon=10^{-2}$ and $\varepsilon=10^{-3}$}.} \label{fig:nIter} \end{figure} The performance of the {\color{black}four} methods was evaluated in terms of three metrics, namely {\color{black}the spectral efficiency, the complexity, and the convergence rate}. Figure \ref{fig:SE vs P} demonstrates the spectral efficiency of the {\color{black}four} schemes as a function of SNR for $N=16$ and $N=64$. It shows that the DSM and GA methods achieve comparable spectral efficiency and both outperform the ADMM method at all SNR and $N$. The performance gap between them increases with $N$. {\color{black} It shows that the proposed DSM and GA method achieve tight performance gap compared with the exhaustive grid search.} {\color{black} {\color{black}Because the procedures of the DSM and GA are similar, the complexities of the} DSM and GA {\color{black}are of the same order, equal to} $\mathcal{O} \left( (L+K)N^2 +KL(L+N) +I_D N(N-1)\right)$ and $\mathcal{O} \left( (L+K)N^2 +KL(L+N) +I_G N^2\right)$, respectively, where $I_D$ and $I_G$ are the iteration {\color{black}numbers} for DSM and GA, respectively. On the other hand, {\color{black}the} ADMM has a complexity of $\mathcal{O} \left(KL(L+N^2) +N^3 +I_A N^3 \right)$, where $I_A$ is the iteration number for the {\color{black} ADMM \cite{Boyu20}. In general, the DSM, ADMM and GA methods demand polynomial complexity in terms of $K$, $L$ and $N$. It shows that} per-iteration complexity of {\color{black}the} DSM is {\color{black}slightly} lower than that of GA and {\color{black}much lower than that of } ADMM. The {\color{black} exhaustive grid search} has a complexity of $\mathcal{O} \left( Q^N KL(L+N)\right)$.} To evaluate the convergence rate, Figure \ref{fig:nIter} shows the average iteration {\color{black}numbers} of the {\color{black}three} considered methods {\color{black}i.e., the values of $I_D$, $I_G$, and $I_A$} as a function of $N$ for two different termination criteria: {\color{black}$\varepsilon=10^{-2}$ and $\varepsilon=10^{-3}$}. Note that to ensure fairness, $\mathbf{F}$, $\mathbf{G}$, $\mathbf{H}$ and the initial values of $\boldsymbol{\theta}$ are assigned the same values in all three schemes for each channel realization. In the GA method, the step-size $\alpha$ used in Fig. \ref{fig:nIter} is chosen from a pre-defined set to minimize the required iteration number for each value of $N$ \cite{Boyd04}. The result shows that DSM converges with {\color{black}the fewest iterations} for both termination criteria. Furthermore, ADMM requires fewer iterations than GA. The slope of GA is steeper than that of either DSM or ADMM, which indicates that GA is unsuitable for systems with large $N$. Notably, GA has step-size issue and thus $\alpha$ must be properly assigned in order to avoid slow convergence or even divergence. \begin{figure} \centering \includegraphics[width=0.75 \columnwidth]{rev2_Time_vs_N} \caption{\color{black} Comparison of the execution time to achieve two termination criteria.} \label{fig:time} \end{figure} {\color{black}To corroborate the low complexity of the proposed method, Figure \ref{fig:time} {\color{black} compares} the execution time of {\color{black} the} DSM {\color{black}with} others given a channel realization. {\color{black}Although the DSM and GA methods have similar per-iteration complexity, the proposed DSM converges faster and requires much lower number of iterations. As a result, the DSM demands the shortest execution time, while the complexity of the GA significantly increases with $N$. The} ADMM consumes stably increasing time with $N$, but its execution time is still longer than that of the DSM. The {\color{black}exhaustive} grid search undoubtedly demands {\color{black}prohibitively} high computation time {\color{black}since its complexity grows exponentially with $N$}.} In summary, the results show that DSM outperforms GA and ADMM in solving (\ref{prob:theta}) in terms not only of an improved solution performance, but also a faster convergence speed and a lower complexity. \section{Conclusion} This letter has proposed a novel low-complexity Dimension-wise Sinusoidal Maximization (DSM) algorithm for determining the optimal IRS phase shifts which maximizes the sum capacity of a single-point MIMO system. The proposed algorithm follows the same principal as the well-known Block Coordinate Descent (BCD) method in decoupling the variable of interest and then optimizing each variable in turn. The numerical results have shown that compared to the ADMM method proposed in \cite{Boyu20} and the general Gradient Ascent method, DSM not only achieves a better solution for the IRS phase shift optimization problem, but also has a faster convergence speed and a lower complexity in each iteration. \appendices \section{Proof of Lemma \ref{lem:1}} \label{apx:Lem1} {\color{black} To prove the function $\hat{\psi} (\theta_{mn})$ is sinusoidal, let us first explore the first derivative given by \begin{align} \frac{\partial \hat{\psi}\left(\mathbf{\Theta}\right)}{\partial \theta_{mn}} =& \text{tr}\left[\mathbf{H}^H \frac{\partial \mathbf{\Phi}^H}{\partial \theta_{mn}}\mathbf{G}^H\left(\mathbf{F} +\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)\right] \nonumber \\ & +\text{tr}\left[\left(\mathbf{F} +\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H\mathbf{G}\frac{\partial \mathbf{\Phi}}{\partial \theta_{mn}}\mathbf{H}\right] \nonumber \\ =& 2\Re \text{e}\left\{\text{tr}\left[je^{j\theta_{mn}}\left(\mathbf{F} +\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H \mathbf{G} \mathbf{e}_m\mathbf{e}_n^T \mathbf{H}\right]\right\} \label{eq:df1/dtheta 1} \\ =& -2\Im \text{m}\left\{e^{j\theta_{mn}}\left[\mathbf{H}\left(\mathbf{F} +\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H\mathbf{G}\right]_{nm}\right\} \label{eq:df1/dtheta 2} \end{align} Eq. (\ref{eq:df1/dtheta 2}) exploits the fact that the trace of matrix multiplication is invariant under cyclic permutations and $\Re \text{e} \left\{jc_1\right\} =-\Im \text{m}\left\{c_1\right\}$ for any complex $c_1$. The matrix $\mathbf{\Phi}$ can be further decomposed as $\mathbf{\Phi} =\tilde{\mathbf{\Phi}}_{mn} + e^{j\theta_{mn}}\mathbf{E}_{mn}$, where $\mathbf{E}_{mn} = \mathbf{e}_m \mathbf{e}_n^T \in \mathbb{R}^{M\times N}$, $\mathbf{e}_m$ is a basis vector with the $m$th entry being one and the others being zero, and $\tilde{\mathbf{\Phi}}_{mn}$ is an $M\times N$ matrix with entries of $\mathbf{\Phi}$ with the exception of the $(m, n)$-th entry being zero. Hence, the first derivative of $\hat{\psi}(\theta_{mn})$ can be written by \begin{align} \frac{\partial \hat{\psi}\left(\mathbf{\Theta}\right)}{\partial \theta_{mn}} =&-2\Im \text{m}\Biggl\{e^{j\theta_{mn}}\Big[\mathbf{H}\left(\mathbf{F} +\mathbf{G}\tilde{\mathbf{\Phi}}_{mn}\mathbf{H}\right)^H \mathbf{G} \nonumber\\ &+e^{-j\theta_{mn}}\mathbf{H}\left(\mathbf{G}\mathbf{E}_{mn}\mathbf{H}\right)^H\mathbf{G}\Big]_{nm}\Biggr\} \nonumber \\ = & -2\Im \text{m}\left\{e^{j\theta_{mn}} \left[\mathbf{G}^T\left(\mathbf{F} +\mathbf{G} \tilde{\mathbf{\Phi}}_{mn}\mathbf{H}\right)^*\mathbf{H}^T\right]_{mn}\right\} \label{eq:df1/dtheta 3} \end{align} Eq. (\ref{eq:df1/dtheta 3}) exploits the fact that $\left[\mathbf{H}\left(\mathbf{G}\mathbf{E}_{mn} \mathbf{H}\right)^H\mathbf{G}\right]_{nm} =\mathbf{e}_n^T \mathbf{H}\left(\mathbf{G}\mathbf{e}_m\mathbf{e}_n^T\mathbf{H} \right)^H\mathbf{G}\mathbf{e}_m =\left[ \mathbf{H}\HH^H\right]_{nn} \left[ \mathbf{G}^H\mathbf{G}\right]_{mm} \triangleq r_{mn}$ is real, and $\Im \text{m}\left\{c_2+r_{mn}\right\} = \Im \text{m}\left\{c_2\right\}$ for any complex $c_2$. Denote $z_{mn} = \left[\mathbf{G}^T\left(\mathbf{F} +\mathbf{G} \tilde{\mathbf{\Phi}}_{mn}\mathbf{H}\right)^*\mathbf{H}^T\right]_{mn}$, then (\ref{eq:df1/dtheta 3}) can be simplified as \begin{equation} \label{eq:df1/dtheta 4} \frac{\partial \hat{\psi}\left(\mathbf{\Theta}\right)}{\partial \theta_{mn}} = -2\Im \text{m}\left\{e^{j\theta_{mn}} z_{mn}\right\}. \end{equation} Note that $z_{mn}$ depends on all angles except $\theta_{mn}$. Hence, given all angles except $\theta_{mn}$, the first derivative of $\partial \hat{\psi} / \partial \theta_{mn}$ is sinusoidal w.r.t. $\theta_{mn}$ with a period of $2\pi$. Each block period contains two extrema points, which are the global maximum and minimum due to the nature of the sinusoidal function. In addition, the extrema points can simply be found from the fact that the solutions to $\Im \text{m}\left\{e^{j\theta_{mn}} z_{mn}\right\}=0$ are $\theta_{mn} = \angle z_{mn}^* +2\pi k$ or $\theta_{mn} = \angle z_{mn}^* +\pi +2\pi k$ where $k$ is an integer. } \section{Proof of Theorem \ref{thm:1}} \label{apx:Thm1} Taking the second derivative of $\hat{\psi}\left(\mathbf{\Theta}\right)$ w.r.t. $\theta_{mn}$ (by taking the first derivative of (\ref{eq:df1/dtheta 1})) yields {\color{black} \begin{align} \frac{\partial^2 \hat{\psi}\left(\mathbf{\Theta}\right)}{\partial \theta_{mn}^2} =& 2\Re \text{e}\Bigl\{-e^{j\theta_{mn}}\mathbf{e}_n^T\mathbf{H}\left(\mathbf{F} +\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H\mathbf{G}\mathbf{e}_m \nonumber \\ & +je^{j\theta_{mn}}\mathbf{e}_n^T\mathbf{H}\HH^H(-je^{-j\theta_{mn}})\mathbf{E}_{mn}^T \mathbf{G}^H\mathbf{G}\mathbf{e}_m\Bigr\} \nonumber \\ =& 2\Re \text{e}\Bigl\{-e^{j\theta_{mn}}\left[\mathbf{H}\left(\mathbf{F} +\mathbf{G}\mathbf{\Phi}\mathbf{H}\right)^H\mathbf{G}\right]_{nm} \nonumber \\ & +\left[\mathbf{H}\HH^H\right]_{nn}\left[\mathbf{G}^H\mathbf{G}\right]_{mm}\Bigr\} \nonumber \\ =& -2\Re \text{e} \Bigl\{ e^{j\theta_{mn}} \left[\mathbf{H}\left(\mathbf{F} +\mathbf{G}\tilde{\mathbf{\Phi}}_{mn} \mathbf{H}\right)^H\mathbf{G}\right]_{nm} \Bigr\} \nonumber \\ & -2\Re \text{e} \Bigl\{ e^{j\theta_{mn}} \left[\mathbf{H}\left( \mathbf{G} e^{j\theta_{mn}} \mathbf{E}_{mn} \mathbf{H}\right)^H\mathbf{G}\right]_{nm} \Bigr\} \nonumber \\ &+ 2\Re \text{e} \Bigl\{ \left[\mathbf{H}\HH^H\right]_{nn}\left[\mathbf{G}^H\mathbf{G}\right]_{mm} \Bigr\} \label{eq:d2psi dtheta2 before cancel} \\ =& -2\Re \text{e} \left\{ e^{j\theta_{mn}} z_{mn}\right\}, \label{eq:d2psi dtheta2 final} \end{align} where (\ref{eq:d2psi dtheta2 final}) holds since the second and third terms of (\ref{eq:d2psi dtheta2 before cancel}) cancel each other. To get the extremum maximum, $\partial^2 \hat{\psi}\left(\mathbf{\Theta}\right) / \partial \theta_{mn}^2$ must be negative since it is located in the concave region. Hence, the requirement to obtain $\theta_{mn}$ that maximize $\hat{\psi}(\mathbf{\Theta})$ is expressed as \begin{equation} \label{eq:real zero 1} \Re \text{e}\left(e^{j\theta_{mn}} z_{mn}\right) > 0, \end{equation} with {\color{black}an opposite sign} to obtain the extremum minimum. } To determine which expression ((\ref{eq:lem1:a}) or (\ref{eq:lem1:b})) leads to the global maximum or global minimum, $\theta_{mn}$ given by (\ref{eq:lem1:a}) or (\ref{eq:lem1:b}) can be substituted into (\ref{eq:real zero 1}) and a check then made of the satisfied inequality. For example, suppose that $\theta_{mn}$ is given by (\ref{eq:lem1:a}), {\color{black}i.e., $\theta_{mn} =\angle z_{mn}^*$}, then (\ref{eq:real zero 1}) yields \begin{equation} \Re \text{e}\left\{e^{j\theta_{mn}} z_{mn}\right\} =\Re \text{e}\left\{e^{j\theta_{mn}}|z_{mn}|e^{-j\theta_{mn}}\right\} = |z_{mn}|>0. \end{equation} In other words, (\ref{eq:lem1:a}) is the condition to obtain the global maximum. Substituting $\theta_{mn}$ obtained from (\ref{eq:lem1:b}), {\color{black}i.e., $\theta_{mn} =\angle z_{mn}^* +\pi$}, into (\ref{eq:real zero 1}) yields \begin{align} &\Re \text{e}\left\{e^{j\theta_{mn}} z_{mn}\right\} =\Re \text{e}\left\{e^{j\theta_{mn}}|z_{mn}|e^{-j\left(\theta_{mn} -\pi\right)}\right\} \nonumber \\ &=-|z_{mn}| <0. \end{align} Hence, (\ref{eq:lem1:b}) is the condition required to obtain the global minimum. \bibliographystyle{IEEEtran}\vspace{-0.25em}
{'timestamp': '2022-04-12T02:34:15', 'yymm': '2204', 'arxiv_id': '2204.04915', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04915'}
arxiv
\section{Introduction and Overview} \IEEEPARstart{O}{ne} of Shannon's outstanding achievements in source coding is to point out the ultimate data compression limit. This result has been widely and successfully applied in the stream data compression. But for image compression, it is still a challenging issue. This paper is an attempt to analyze the ultimate limit theory of image compression. \subsection{Preliminaries} Data compression is one of the basis of digital communications and helps to provide efficient and low-cost communication services. Image is the most important and popular medium in the current information age. Hence, image compression is naturally an indispensable part of data compression. Moreover, its coding efficiency directly affects the objective quality of the communication network and the subjective experiences of users. As a compression method with strict requirements, image lossless coding focuses on reducing the required number of bits to represent an image without losing any quality. It guarantees to cut down the occupation of communication and storage resources as much as possible under a certain system or scenario constraints. In the area of big data, image lossless coding may play a more significant role for applications where errors can not be allowed, such as in intelligent medical treatment, digital library, etc. Entropy rate is one of the important metrics in information theory, which extends the meaning of entropy from a random variable to a random process. It also characterizes the generalized asymptotic equipartition property of a stochastic process. In this paper, we shall employ entropy rate to explain the best achievable data compression. It is well known that the entropy rate of a stochastic process $\{Z_i\}$ is defined as \begin{equation} \label{Eq:entropy rate-1} H(\mathcal{Z}) = \lim_{t\to \infty} \sup {1 \over t} H(Z_1,Z_2,...,Z_t). \end{equation} If the limit exists, then $H(\mathcal{Z})$ is the per symbol entropy of the $t$ random variables, reflecting how the entropy of the sequence increases with $t$. Moreover, the entropy rate can also be defined as \begin{equation} \label{Eq:entropy rate-2} H'(\mathcal{Z})= \lim_{t \to \infty} H(Z_t|Z_{t-1},Z_{t-2},...,Z_1). \end{equation} $H'(\mathcal{Z})$ is the conditional entropy of the last random variable given all the past random variables. For a stationary stochastic process, the limits in Eq. (\ref{Eq:entropy rate-1}) and (\ref{Eq:entropy rate-2}) exist and are equal \cite{cover1999elements}. That is, $H(\mathcal{Z})$ = $H'(\mathcal{Z})$. In addition, for a stationary Markov chain, the entropy rate is \begin{align} \label{Eq:markov-1} H(\mathcal{Z})&=H'(\mathcal{Z})=\lim_{t\to \infty} H(Z_t|Z_{t-1},...,Z_1) \\ &=\lim_{t \to \infty} H(Z_t|Z_{t-1}). \label{Eq:markov-2} \end{align} The entropy rate is a long-term sequence metric. Even if the initial distribution of the Markov chain is not a stable distribution, it will still tend to converge as in Eq. (\ref{Eq:markov-1}) and (\ref{Eq:markov-2}). Moreover, for a general ergodic source, the Shannon-McMillan-Breiman theorem points out its asymptotic equipartition property. If $\{Z_i\}$ is a finite-valued stationary ergodic process, then \begin{equation} -{1 \over t} \log p(Z_0,...,Z_{t-1}) \to H(\mathcal{Z}) \text{ with probability 1}. \end{equation} This indicates that the convergence relationship between the joint probability density and entropy rate for the general ergodic process. Following a similar idea as that of the analysis of entropy rate, we investigate the asymptotic property of shape based coding for stationary ergodic processes. \subsection{Shape Coding} A digital image is composed of lots of pixels arranged in order. This form is fixed and if the size of an image is determined, the number and arrangement mode of pixels are also determined. On the other hand, shape coding extends the basic components of images from pixels to shapes, which is a more flexible coding method. Furthermore, it will no longer limit the number and position of shapes. Shape coding has three main characteristics: (1) The image is formed by filling shapes; (2) The position arrangement of shapes changes from a fixed mode to a random variable; (3) The shape database and codebook are generated in a data-driven way. Consider a binary digital image $Z$, whose length and width are $M$ and $N$, respectively, then the total number of pixels is $t=M\times N$. Suppose it is divided into $c(t)$ shapes $\{s_1,s_2,...,s_{c(t)}\}$, where $s_i$ is the $i$-th shape. We use $\mathcal{D}$ to denote the shape database. The image with shape coding can be described as \cite{xin2020soft} \begin{align} \min&~~\sum_{i=1}^{c(t)} [l(s_i)+l_p(x_i,y_i)] \\ &\text{s.t.}~~Z=\sum_{i=1}^{c(t)}F_i(s_i) \end{align} where $l(s_i)$ and $l_p(x_i,y_i)$ represent the bit length of the shape $s_i$ and its corresponding location at $(x_i,y_i)$, respectively. The constraint condition indicates that the binary image $Z$ can be reconstructed through $c(t)$ filling operations, which is exactly the same as the original image. On this premise, shape coding tries to reduce the cost of representing an image as much as possible. The codebook plays an important role in shape coding. It reflects the statistical characteristics and correlation of the data source. Fig. \ref{Fig:framework} illustrates the structure of shape coding. It consists of two parts, namely the generation and use of the codebook. On the one hand, one searches and matches the shape of images in the dataset through data-driven. At the same time, the frequency statistical analysis is carried out to generate a shape database. On the other hand, the codebook can be used repeatedly in communication and storage tasks to reduce the occupation of resources. The transmitter/compressor encodes the original image with the codebook. After transmission or storage through the channel/storage medium, the receiver/decompressor can decode the compressed file with the same codebook. In this way, one can reconstruct the original image in lossless mode. \begin{figure*} \centerline{\includegraphics[width=6.5in]{framework.pdf}} \caption{The structure of shape coding. It consists of two parts, namely the generation and use of the codebook. The former makes use of the characteristics of the data source, while the latter improves the compression efficiency.} \label{Fig:framework} \end{figure*} \subsection{Relations to Previous Work} The objective of this work is to present the performance limits from the viewpoint of information theory, which is related to our previous works in \cite{xin2020soft,xin2021soft,xin2021lossless}. An image encoding method through shapes and data-driven can provide improvements for image lossless compression. In some known databases, \emph{soft compression} outperforms the most popular methods such as PNG, JPEG2000 and JPEG-LS. However, there was no theoretical support for how shape-based \emph{soft compression} methods can reach the ultimate performance limit. That is, gap between soft compression and its compression limit, namely the entropy rate is not theoretically known. On the other hand, the entropy rate associated with the asymptotic equipartition property analysis of images can help us design efficient encoding and decoding algorithms in the viewpoint of Shannon information theory. The earliest multi-pixel joint coding method can be traced back to Symbol-Based coding \cite{ascher1974a}, which transmits or stores only the first instance of each pattern class and thereafter substitutes this exemplar for every subsequent occurrence of the symbols. It achieved a degree of bandwidth reduction on a scan-digitized printed text. Fractal theory \cite{jacquin1992image,8683203} is also related to block based coding. Fractal block coding approximates an original image by relying on the assumption that image redundancy can be efficiently exploited through self-transformability on a blockwise basis. On the other hand, \emph{soft compression} generates shape database in a data-driven manner, so as to make the codebook used in the encoder and decoder. Image processing based data-driven methods such as \cite{begaint2017region,zhang2020image,chen2019toward} can explore the essential features of images and even eliminate semantic redundancy. The method of using side information to assist data compression has also been used and analyzed by Kieffer \cite{yang2001universal} and Kontoyiannis \cite{gavalakis2021fundamental}. Verd\'{u} \cite{8283787} provided upper and lower bounds on the optimal guessing moments of a random variable by taking values on a finite set when the side information may be available. Another connection to this paper is the Lempel-Ziv coding schemes \cite{ziv1978compression}. It proposed the concept of compressibility. For every individual infinite sequence $x$, a quantity $\rho(x)$ is defined. It is shown to be the asymptotically attainable lower bound on the compression ratio that can be achieved for $x$ be any finite-state encoder. Wyner \cite{wyner1989some} derived theorems concerning the entropy of a stationary ergodic information source and used the results to obtain insight into the workings of the Lempel-Ziv data compression algorithm. The main contribution in this paper is that we will be able to present a sufficient condition which will allow us to show that the performance limit of soft image coding can be asymptotically achievable in terms of entropy rate. \subsection{Paper Outline} The rest of this paper is organized as follows. Section \ref{sec:asymptotic} contains our main results, giving asymptotic properties on shape-based image coding in terms of entropy rate. Moreover, it indicates the relationship between the numbers of shapes and coding performance. In Section \ref{sec:numerical}, we present sample numerical results with concrete examples. In Section \ref{sec:conclusion}, we give some complementary remarks and conclude this paper. \section{The Asymptotic Properties of Image Sources Composed of Shapes} \label{sec:asymptotic} The encoding method with shapes can take advantage of the characteristics of the data and eliminate redundancy in the spatial and coding domains simultaneously. This section theoretically analyzes the performance of image coding with shapes. It will show that when the numbers of shapes and pixels have a reciprocal logarithm relationship, the average code length will asymptotically approach the entropy rate. To best of our knowledge, this is the first result on image compression in information theory. The framework of this proof is similar to \cite{cover1999elements} \cite{wyner1989some}, but there are some important differences. The average number of bits needed to represent the image $Z$ with shapes are $B_Z$. Specifically, \begin{align} \label{Eq:Bz-1} B_{Z} & ={1 \over t} \sum_{i=1}^{c(t)} [l(s_i)+l_p(x_i,y_i)] \\ &\overset{(a)} \leq {{c(t)\log c(t) + \sum_{i=1}^{c(t)}l(s_i)} \over t} \\ & \overset{(b)} \leq { {c(t)\log t + c(t)\log |\mathcal{D}|} \over t} \label{Eq:Bz-2} \end{align} where (a) and (b) follow from the fact that the uniform distribution has maximum entropy and the number of shapes is less than the number of pixels (because one shape is at least composed of one pixel). That is, $\bar{l}(s_i) \leq \log \mathcal{D}$ and ${c(t) \over t} \leq 1$. $B_Z$ is the average cost of encoding $Z$, which reflects the coding requirements of bits. In the sequel, we use Eq. (\ref{Eq:Bz-2}) instead of (\ref{Eq:Bz-1}) to scale $B_Z$. Let $\{Z_i\}_{i=-\infty}^{\infty}$ be a strictly stationary ergodic process with finite states and $ z_i^j \triangleq (z_i,z_{i+1},\ldots,z_j)$. Due to the invariance of time, $P(Z_t|Z_{t-k}^{t-1})$ is an ergodic process, where the $k$th-order Markov approximation is used to make an approximation. We will then have \begin{equation} Q_k(z_{-(k-1)},\ldots,z_0,\ldots,z_t) \triangleq P(z_{-(k-1)}^0)\prod_{j=1}^t P(z_j|z_{j-k}^{j-1}) \label{eq:markov} \end{equation} where $z_{-(k-1)}^0$ is the initial state. In this way, one can use the $k$-th order Markov entropy rate to estimate the entropy rate of $\{Z_i\}$. That is, \begin{align} -{1 \over t} \log Q_k(Z_1,Z_2,\ldots,Z_t|Z_{-(k-1)}^0) &= -{1 \over t} \log \prod_{j=t}^t P(Z_j|Z_{j-k}^{j-1}) \\ &= -{1 \over t} \sum_{j=1}^t \log P(Z_j|Z_{j-k}^{j-1}) \\ &\to -E \log P(Z_j|Z_{j-k}^{j-1}) \\ &=H(Z_j|Z_{j-k}^{j-1}). \end{align} When $k\to \infty$, the entropy rate of the $k$th-order Markov approximation converges to the entropy rate of the original random process. Suppose that $z_1^t$ is decomposed into $c(t)$ shapes $s_1,s_2,\ldots,s_{c(t)}$. We define $w_i$ as the $k$ bits before $s_i$, where $w_1=z_{-(k-1)}^0$. Let $c_{lw}$ denote the number of shapes whose size is $l$ and its previous state $w_i=w$, $w\in \mathcal{Z}^k$. \begin{lemma} \label{lemma:11} For $\{Z_i\}$, the joint transition probability and shape size satisfy the following inequality \label{lemma:1} \begin{equation} \log Q_k (z_1,z_2,\ldots,z_t|w_1) \leq \sum_{l,w} c_{lw} \log {\alpha \over c_{lw}} \end{equation} \end{lemma} \begin{proof} Suppose that for fixed $l$ and $w$, the sum of the transition probabilities is less than a constant, i.e., \begin{equation} \label{Eq:Suppose A} \sum_{i:|s_i|=l,w_i=w} {1 \over c_{lw}} P(s_i|w_i) \leq \alpha. \end{equation} Then, \begin{align} \log Q_k (z_1,z_2,\ldots,z_t|w_1) &= \log Q_k(s_1,s_2,\ldots,s_c|w_1) \\ &\overset{(a)} = \sum_{i=1}^c \log P(s_i|w_i) \\ &= \sum_{l,w} \sum_{i:|s_i|=l,w_i=w} \log P(s_i|w_i) \\ &= \sum_{l,w} c_{lw} \sum_{i:|s_i|=l,w_i=w} {1 \over c_{lw}} \log P(s_i|w_i) \\ & \overset{(b)} \leq \sum_{l,w} c_{lw} \log \sum_{i:|s_i|=l,w_i=w} {1 \over c_{lw}} P(s_i|w_i) \\ & \leq \sum_{l,w} c_{lw} \log {\alpha \over c_{lw}} \end{align} where (a) follows from Eq. (\ref{eq:markov}) and (b) follows from Jensen's inequality, thanks to the convexity of $\log x$ for $x>0$. \end{proof} Lemma \ref{lemma:11} links the conditional probability $Q_k(z_1,z_2,...,z_t|w_1)$ to $c_{lw}$, connecting the concepts before and after decomposing $\{ Z_i\}$. We will continue to explore the quantitative relationship between shapes and pixels. \begin{lemma} For $\{Z_i\}$, the number and size of its shapes meet the following relationship \label{lemma:2} \begin{equation*} \sum_{l,w} c_{lw} \log {c_{lw} \over t\alpha} \geq c \cdot \log {1 \over t \alpha} \end{equation*} \end{lemma} \begin{proof} \begin{align} \sum_{l,w} c_{lw} \log {c_{lw} \over t \alpha} &\overset{(a)} \geq \sum_{l,w} c_{lw} \log {\sum_{l,w}c_{lw} \over \sum_{l,w} t \alpha} \\ & \overset{(b)}= \sum_{l,w} c_{lw} \log {c \over \sum_{l,w}t \alpha} \\ &\geq c \cdot \log {1 \over t \alpha} \end{align} where (a) follows from the log sum inequality. (b) uses the fact $\sum_{l,w}c_{lw} = c$. \end{proof} Based on these two lemmas, we will further analyze the condition under which the entropy rate can be reached asymptotically. \begin{theorem} \label{theorem:1} When the numbers of shapes and pixels meet the reciprocal relation of the logarithm, then the average encoding length will asymptotically approximate the entropy rate. That is, \\ if \begin{equation} \label{Eq:relationship} {c(t) \over t} = \mathcal{O} ({1 \over {\log t}}) \end{equation} then \begin{equation} \label{Eq:result} \lim\limits_{t \to \infty} {l(Z_1,Z_2,...,Z_t) \over t} = H(\mathcal{Z}). \end{equation} \end{theorem} \begin{proof} From Lemma \ref{lemma:1}, one can write \begin{align} \log Q_k (z_1,z_2,...,z_t|w_1) & \leq \sum_{l,w} c_{lw} \log {\alpha \over c_{lw}} \\ &= -\sum_{l,w}c_{lw}\log {{t\cdot c_{lw}} \over {t \cdot \alpha}} \\ &= -c \log t-\sum_{l,w} c_{lw} \log {c_{lw} \over {t\alpha}} \end{align} Thus, \begin{align} {c \over t} \log t \leq -{1 \over t} \log Q - {1 \over t} \sum_{l,w} c_{lw} \log {c_{lw} \over t \alpha} \label{Eq:middle} \end{align} From Lemma \ref{lemma:2}, it follows that \begin{align} -{1 \over t} \sum_{l,w} c_{lw} \log {c_{lw} \over t \alpha} &\leq -{c \over t} \log {1 \over t\alpha} \\ &={c \over t} \log {t \over c} + {c \over t} \log c +{c \over t} \log \alpha \label{Eq:three component}. \end{align} When ${c \over t} = \mathcal{O} ({1 \over {\log t}})$ and $t \to \infty$, the three terms in the right hand side of Eq. (\ref{Eq:three component}) will all tend to 0. Combining Eq. (\ref{Eq:middle}) and (\ref{Eq:three component}), we obtain \begin{equation} -{1 \over t} \sum_{l,w} c_{lw} \log {c_{lw} \over t \alpha} \to 0,~~\textit{when}~t\to \infty. \end{equation} Then, \begin{align} \lim\limits_{t\to \infty} \sup {{c(t) \log t }\over t} &\leq \lim\limits_{t \to \infty} {-{1 \over t}\log Q_k(Z_1,Z_2,...,Z_t|Z_{-(k-1)}^0}) \\ &\to H(\mathcal{Z}). \end{align} The asymptotic property of the second term in the right hand side of Eq. (\ref{Eq:Bz-2}), \begin{align} \lim\limits_{t \to \infty} {{c(t) \log |\mathcal{D}|} \over t} = 0. \end{align} Thus, \begin{align} \lim\limits_{t \to \infty} {l(Z_1,Z_2,...,Z_t) \over t} &= \lim\limits_{t \to \infty} ({c(t)\log t \over t} + {c(t) \log |\mathcal{D}| \over t}) \\ &= \lim\limits_{t \to \infty} {c(t)\log t \over t} \\ &= H(\mathcal{Z}). \end{align} This shows that when $c(t)$ and $t$ meet the condition in Eq. (\ref{Eq:relationship}), the average coding length of $\{Z_i\}$ will asymptotically approximate the entropy rate $H(\mathcal{Z})$. \end{proof} Theorem \ref{theorem:1} sets up a bridge between the shapes and the entropy rate for image sources with ergodic properties. It theoretically indicates what order of magnitude we should have the shapes and pixels. When one encodes images with shapes, the average cost will asymptotically tend to the entropy rate if the numbers of shapes and pixels satisfy the reciprocal relation of the logarithm. Moreover, it gives new insights into designing image compression algorithms in theory. \section{Numerical Analysis} \label{sec:numerical} \begin{table} \renewcommand\arraystretch{1.2} \caption{The numerical analysis of shapes and pixels on MNIST dataset ($R_{avg}$ is the average compression ratio)} \setlength{\tabcolsep}{7pt} \small \begin{center} \begin{tabular}{ccccccccccc} \toprule Class& 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\ \midrule $R_{avg}$ & 2.84 & 6.02 & 3.17 & 3.20 & 3.77 & 3.40 & 3.20 & 4.05 & 2.81 & 3.52 \\ ${1 \over t}{c(t)\log t}$ & \textbf{0.200} & \textbf{0.080} & \textbf{0.178} & \textbf{0.175} & \textbf{0.149} & \textbf{0.163} & \textbf{0.175} & \textbf{0.136} & \textbf{0.202} & \textbf{0.157} \\ \bottomrule \end{tabular} \end{center} \label{Tab:analysis} \end{table} Section \ref{sec:asymptotic} points out the asymptotic property of encoding methods based on shapes. When ${c(t) \over t} \to \mathcal{O}({1 \over \log t})$, the average encoding length will asymptotically approximate the entropy rate. It indicates the relationship between the shape-pixel number ratio and coding performance. In this section, we present some numerical results to illustrate that for each ergodic process of an image source, if ${c(t) \over t} \to \mathcal{O}({1 \over \log t})$ as $t \to \infty$, one can get the result of Eq. (\ref{Eq:result}). Table \ref{Tab:analysis} reveals the numerical results on the MNIST dataset. It includes encoding results $R_{avg}$ and ${1 \over t}c(t)\log t$ in ten categories with the soft compression algorithm \cite{xin2020soft}. What can be clearly seen in this table is that ${1 \over t}c(t)\log t <1$ for all classes. It is on the order of $\mathcal{O}(1)$, which is consistent with Theorem \ref{theorem:1}. Now we focus on simulated images as an alternative analysis. We use the birth and death processes of two states to simulate a stationary ergodic process. For each case, 5000 $\{Z_i\}$ with $M=100,N=100$ are generated, respectively. We encode $\{ Z_i\}$ with fixed size shapes and observe the effect of ${c(t) \over t}$ on coding performance. Fig. \ref{Fig:curve} illustrates the shape coding working mechanism of the image source. It indicates the performance of the encoding method with shapes, in bits per pixel (bpp). In different cases, the change trend of these curves is the same. The bpp decreases with the increase of shape size (i.e., the shape-pixel number ratio decreases), which reflects the gain brought by shape. Moreover, as the shape-pixel number ratio continues to decrease, bpp enters the smoothing region. It also shows that the reduction of the number ratio will not always improve the encoding performance. This is due to the fineness of the model itself, which dose not take advantage of the additional statistical information of larger shapes. Note that, the numerical difference between the curves is essentially the difference of the entropy rate. \begin{figure} \centerline{\includegraphics[width=3.2in]{curve.pdf}} \caption{The performance of encoding method with shapes, in bits per pixel (bpp).} \label{Fig:curve} \end{figure} \section{Concluding Remarks} \label{sec:conclusion} In this paper, we investigated the performance limit of shape-based image compression. Our works answered the open problem on the relationship between image decomposition and lossless compression, which reflects the performance variation in general. Specifically, when the numbers of shapes and pixels have a reciprocal relation of logarithm, the average code length will asymptotically approach the entropy rate. For image coding algorithms, one should give full attention to the superiority of shapes in image processing. Likewise, it is necessary to take advantage of the characteristics of the image dataset. Through shapes and data-driven, one can use the high-dimensional information of images to help coding. Moreover, the asymptotic analysis of entropy rate can also be extended to gray image and multi-component image with some adjustments. Finally, it is noted that this paper focuses on the source part, without considering the natural robustness of images in the communication process. In a future work, we will explore the theory of joint source-channel image coding in the finite blocklength regime. \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:31:25', 'yymm': '2204', 'arxiv_id': '2204.04857', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04857'}
arxiv
\section{Introduction} Linguistic style (i.e., how something is said) is an integral part of natural language. Style is relevant for natural language understanding and generation \cite{nguyen-etal-2021-learning, ficler-goldberg-2017-controlling} as well as the stylometric analysis of texts \cite{el2014authorship, Goswami_Sarkar_Rustagi_2009}. % Applications include author profiling \cite{10.1145/1871985.1871993} and style preservation in machine translation systems \cite{niu-etal-2017-study, rabinovich-etal-2017-personalized}. While authors are theoretically able to talk about any topic and (un-)consciously choose to use many styles (e.g., designed to fit an audience \cite{bell-audience-design}), it is typically assumed that there are combinations of style features that are distinctive for an author (sometimes called an author's {idiolect}). Based on this assumption, the \textit{authorship verification} task (AV) aims to predict whether two texts have been written by the same author \cite{coulthard2004author, neal_aa-survey, utility_content_AA}. Recently, training objectives based on the AV task have been used to train style representations \cite{AV_SimilarityLearning, hay-etal-2020-representation,zhu-jurgens-2021-idiosyncratic}. % Training objectives on AV are especially promising because they do not require any additional labeling when author identifiers are available. Similar to the distributional hypothesis, the assumption underlying the AV training task (same author approximates same writing style) enables extensive self-supervised learning. % \begin{figure}[t] \centering \small \begin{tabular}{p{0cm} p{0.2cm} p{4cm} p{0.2cm}} & \color{blue} $A_1$ & \cellcolor{green!25} \textcolor{black}{don’t suggest an open relationship if you’re not ready} \tikzmark{A_end} \\ \end{tabular} \vspace{1\baselineskip} \begin{tabular}{p{0.2cm} p{2cm} p{0.2cm} p{0.01cm} p{3.5cm} p{0.01cm}} \color{blue} $A_2$ \tikzmark{SA_start} & \tikzmark{SA_top} \cellcolor{green!25} it’s clear that these are wildly different situations & \tikzmark{SA_end} & \ \ \ \color{blue} $B$ \tikzmark{DA_start} & \textcolor{gray}{Aren\textquotesingle t open relationships usually just about fixing something in the relationship?} & \tikzmark{DA_end} \\ \end{tabular} \begin{tikzpicture}[overlay, remember picture] \draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=4pt}] ($(DA_start.west) - (-0.1,0.3)$) --node[below=14pt]{\color{blue} % CC - Same Topic as $A_1$} ($(DA_end.east) - (0.4,1)$); \draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=4pt}] ($(SA_start.west) - (-0.1,0.45)$) --node[below=14pt]{\color{blue} Same Author as $A_1$} ($(SA_end.east) - (0.2,1)$); \end{tikzpicture} \vspace{2.5\baselineskip} \caption{\textbf{Contrastive Authorship Verification (CAV) Setup and Content Control (CC) Variable.} % The CAV task is to match $A_1$ with the utterance $A_2$ that was written by the same author. % Contrary to the traditional authorship verification task (AV), this is complemented by a third ``constrastive'' utterance that was written by a different author ($B$). % In addition to the CAV variation to AV, we experiment with content control (CC) by selecting $B$ and $A_1$ to have the same approximate content with the help of a topic proxy. As topic proxies we use conversation and domain information. % } \label{fig:Task} \end{figure} Style and content are often correlated \cite{gero-etal-2019-low,bischoff2020importance}: For example, people might write more formally about their professional career % but more informally about personal hobbies. % As a result, style representations might encode spurious content correlations \cite{poliak-etal-2018-hypothesis}, especially when their AV training objective does {not control for content} \cite{Halvani_AV_bad-topic-control, sundararajan-woodard-2018-represents}. Current style representation learning methods either use no or only limited control for content \cite{hay-etal-2020-representation} or use domain labels to approximate topic \cite{AV_SimLearning_Attention}. \newcite{zhu-jurgens-2021-idiosyncratic} work with 24 domain labels (here: product categories) for more than 100k \texttt{Amazon} reviews to improve generalizability. However, using a small set of labels might be too coarse-grained to fully represent and thus control for content. In this paper, we use ``content'' and ``topic'' to refer to different concepts. We assume same content (fulfilled if two utterances are paraphrases of each other) implies same topic (e.g., two utterances that discuss personal hobbies), while same topic does not necessarily imply same content. % \textbf{Approach.} We introduce two independent variations to the AV task (see Figure \ref{fig:Task}): adding a contrastive sentence (CAV setup) and addressing content correlation with a topic proxy (CC). % We train several siamese BERT-based neural networks \cite{reimers-gurevych-2019-sentence} to compare style representations learned with the new variations to the AV task. % We train on utterances from the platform \texttt{Reddit} but % our approach could be applied to any other conversation dataset as well. While previous work mostly aimed for learning representations that represent an author's individual style \cite{AV_SimilarityLearning, hay-etal-2020-representation,zhu-jurgens-2021-idiosyncratic}, we aim for general-purpose style representations. As a result, we evaluate the generated representations on (a) whether known style dimensions (e.g. formal vs. informal) are present in the embedding space (Section \ref{sec:eval-STEL}) and preferred over content information (Section \ref{sec:eval-t-a-STEL}) and (b) whether sentences written by the same author are closer to each other even when they have different content (Section \ref{sec:eval-TT}). \textbf{Contribution.} With this paper, we (a) contribute an extension of the AV task that aims to control for content (CC) with conversation labels, % (b) introduce a novel variation of the AV setup by adding a contrastive utterance (CAV setup), % (c) compare style representations trained with different levels of content control (CC) on two task setups (AV and CAV), (d) introduce a variation of the \texttt{STEL} framework \cite{wegmann-nguyen-2021-capture} to evaluate whether representations prefer content over style information and (e) demonstrate found stylistic features via agglomerative clustering. We find that representations trained on the conversation topic proxy are better than representations trained with domain or no content control at representing style independent from content. % Additionally, combining the conversation topic proxy with the CAV setup leads to better results than combining it with the AV setup. We show that our representations are sensitive to stylistic features like punctuation and apostrophe types such as ’ vs. \textquotesingle \ using agglomerative clustering. We hope to further the development of content-controlled style representations. Our code and data are available on GitHub.\footnote{\url{https://github.com/nlpsoc/Style-Embeddings}} \section{Related Work} Recently, deep learning approaches have been used in authorship % verification \cite{shrestha-etal-2017-convolutional, AV_CNN, AV_SimLearning_Attention, AI_SimilarityLearning_Siamese, hay-etal-2020-representation, Hu_AA-Style-Embedding_Triplet, zhu-jurgens-2021-idiosyncratic}. Training on transformer architectures like BERT has been shown % to be competitive with other neural as well as non-neural approaches in AV and style representation \cite{zhu-jurgens-2021-idiosyncratic, wegmann-nguyen-2021-capture}. AV methods have controlled for content by restricting the feature space to contain ``content-independent'' features like function words or character n-grams \cite{neal_aa-survey, masking-topic_AA, sundararajan-woodard-2018-represents}. However, even these features have been shown to not necessarily be content-independent \cite{litvinova_context-stylometric}. Semantic sentence embeddings are typically trained using supervised or self-supervised learning \cite{reimers-gurevych-2019-sentence}. For supervised learning, models are often trained on manually labelled natural language inference datasets \cite{conneau-etal-2017-supervised}. For self-supervised learning, \textit{contrastive} learning objectives \cite{contrastive-learning} have been increasingly used. Contrastive objectives push semantically distant sentence pairs apart and pull semantically close sentence pairs together. Different strategies for selecting sentence pairs have been used, e.g., same sentences as semantically close % vs. randomly sampled as semantically distant sentences \cite{giorgi-etal-2021-declutr, gao-etal-2021-simcse}. \newcite{reimers-gurevych-2019-sentence} also experiment with a \textit{triplet loss}, which pushes an anchor closer to a semantically close sentence and pulls the same anchor apart from a semantically distant sentence. Semantic representations are typically first evaluated on the task that they have been trained on, e.g., binary tasks for binary contrastive objectives and triplet tasks (similar to Figure \ref{fig:Task}) for triplet objectives \cite{reimers-gurevych-2019-sentence}. Semantic representations are often also evaluated on the STS benchmark \cite{cer-etal-2017-semeval} or semantic downstream tasks like semantic search, NLI \cite{bowman-etal-2015-large, williams-etal-2018-broad} or SentEval \cite{conneau-kiela-2018-senteval}. Typically, objective functions that are known from semantic embedding learning have been used % \cite{hay-etal-2020-representation, zhu-jurgens-2021-idiosyncratic} with AV training tasks to learn style representations. \newcite{zhu-jurgens-2021-idiosyncratic} address possible spurious correlations by sampling half of the different and same author utterances from the same and the other half from different domains (e.g., subreddits for \texttt{Reddit}). % Style representations are often trained and evaluated on the AV task \cite{AV_SimLearning_Attention, zhu-jurgens-2021-idiosyncratic, bischoff2020importance}. \section{Style Representation Learning} We describe the new Contrastive Authorship Verification setup (CAV) and our approach to content control (CC) in Section \ref{sec:task}. Then we describe the generation of training tasks % (Section \ref{sec:task-generation}) and the hyperparameters for model training (Section \ref{sec:models}). \subsection{Training Task} \label{sec:task} The authorship verification (AV) task is the task of predicting whether two texts are written by the same or different authors. In the following, we introduce two independent variations to the AV task: Adding (1) contrastive information with the CAV setup and (2) content control via topic proxies. \textbf{CAV setup.} We introduce an adaption of the Authorship Verification task --- the Contrastive Authorship Verification setup (CAV, Figure \ref{fig:Task}): Given an anchor utterance $A_1$ and two other utterances $A_2$ and $B$, the task is to identify which of the two sentences were written by the same author as $A_1$. Using a contrastive AV setup adds learnable information to the task (namely the contrast between $A_2$ and $B$ w.r.t.~$A_1$) and enables the use of learning objectives that require three input sentences and have been successful in semantic embedding learning \cite{reimers-gurevych-2019-sentence}. We experiment with both CAV and AV setups for style representation learning. In the future, it is also possible to adapt this setup to include several instead of just one contrastive ``negative'' different author utterance (similar to contrastive semantic learning, e.g., in \newcite{gao-etal-2021-simcse}). % One task with the CAV setup, which consists of three utterances ($A_1$, $A_2$, $B$), can be split up into two AV tasks: ($A_1$, $A_2$) and ($A_1$, $B$). We compare the CAV and AV setups during evaluation (Section \ref{sec:eval}). \textbf{Content Control (CC).} Models optimized for AV have been known to make use of semantic information % \cite{sari-etal-2018-topic, sundararajan-woodard-2018-represents, Stamatatos_av-w-topic} and to perform badly in cross-topic settings \cite{Halvani_AV_bad-topic-control, bischoff2020importance}. Recent studies use AV tasks to train style representations and address possible correlations by controlling for domain \cite{zhu-jurgens-2021-idiosyncratic, AV_SimilarityLearning}. % However, it is unclear to what extent these domain labels are better (or worse) than other ways of controlling for content. We compare three different levels of content control by approximating content with the help of a topic proxy. We sample the utterance pairs written by different authors ($B$ and $A_1$ for CAV, c.f.~Figure \ref{fig:Task}) (i) from the same \textit{conversation}, (ii) from the same \textit{domain} (e.g., subreddit for \texttt{Reddit} as in \newcite{zhu-jurgens-2021-idiosyncratic}) or (iii) \textit{randomly} (as a baseline, similar to \newcite{hay-etal-2020-representation}). % Our newly proposed use of the same conversation ``topic proxy'' is inspired by semantic sentence representation learning, where conversations have previously been used as a proxy for semantic information encoded in utterances \cite{yang-etal-2018-learning, liu-etal-2021-dialoguecse}. % We test to what extent the three different topic proxies are contributing to content-independent style representations during evaluation (Section \ref{sec:eval-t-a-STEL}). % \begin{table*}[t] \small \centering \begin{tabular}{l l | r r | r | r r | r r | r r} \toprule & & \multicolumn{2}{l|}{\ \ \ \ \ \ \ \ \ \ \ \ \textbf{ Setup }} & \multicolumn{1}{l|}{\textbf{Uttterance}} & \multicolumn{2}{l|}{\ \ \ \ \ \textbf{Author}} & \multicolumn{2}{c|}{\textbf{($A_1$, $A_2$)}} & \multicolumn{2}{c}{\textbf{($A_1$, $B$)}} \\ \textbf{CC level} & \textbf{Data Split} & \# AV & \# CAV & \# & \# & ma & co & do & co & do \\ \midrule \multirow{3}{*}{\textbf{Conversation}} & train set & $420{,}000$ & $210{,}000$ & $546{,}757$ & $194{,}836$ & $9$ & $0.27$ & $0.56$ & $1.00$ & $1.00$ \\ & dev set & $90{,}000$ & $45{,}000$ & $116{,}451$ & $41{,}848$ & $8$ & $0.26$ & $0.55$ & $1.00$ & $1.00$ \\ & test set & $90{,}000$ & $45{,}000$ & $116{,}621$ & $41{,}902$ & $8$ & $0.27$ & $0.55$ & $1.00$ & $1.00$ \\ \midrule \multirow{3}{*}{\textbf{Domain}} & train set & $420{,}000$ & $210{,}000$ & $544{,}587$ & $240{,}065$ & $9$ & \multicolumn{2}{c|}{same pairs} % & $0.01$ & $1.00$ \\ & dev set & $90{,}000$ & $45{,}000$ & $116{,}490$ & $50{,}939$ & $8$ & \multicolumn{2}{c|}{as} % & $0.02$ & $1.00$ \\ & test set & $90{,}000$ & $45{,}000$ & $116{,}586$ & $51{,}182$ & $8$ & \multicolumn{2}{c|}{conversation}% & $0.02$ & $1.00$ \\ \midrule \multirow{3}{*}{\textbf{No}} & train set & $420{,}000$ & $210{,}000$ & $548{,}082$ & $270{,}079$ & $9$ & \multicolumn{2}{c|}{same pairs} % & $0.00$ & $0.01$ \\ & dev set & $90{,}000$ & $45{,}000$ & $117{,}149$ & $57{,}352$ & $8$ & \multicolumn{2}{c|}{as} % & $0.00$ & $0.01$ \\ & test set & $90{,}000$ & $45{,}000$ & $117{,}434$ & $57{,}726$ & $8$ & \multicolumn{2}{c|}{conversation} % & $0.00$ & $0.02$ \\ \bottomrule \end{tabular} \caption{\textbf{Data Split Statistics.} Per content control (CC) level, we display the number of tasks per setup (\# CAV, \# AV), unique utterances and authors for each split. We also show the maximum number of times an author occurs as $A_1$'s author (ma) and the fraction of same author ($A_1$, $A_2$) and utterance pairs of different authors ($A_1$, $B$) that occur in the same conversation (co) and domain (do). % } \label{table:split-statistics} \end{table*} \subsection{Task Generation} \label{sec:task-generation} We use a 2018 \texttt{Reddit} sample with utterances from 100 active subreddits\footnote{ \url{https://zissou.infosci.cornell.edu/convokit/datasets/subreddit-corpus/subreddits_small_sample.txt} } % extracted via \texttt{ConvoKit} \cite{chang-etal-2020-convokit}\footnote{MIT license}. Per subreddit, we sample 600 conversations with at least 10 posts (which we call utterances). All subreddits are directed at an English audience, which we infer from the subreddit descriptions. \textbf{Generation.} We removed all invalid utterances\cprotect\footnote{Utterance of only spaces, tabs, line breaks or\\of the form: \verb+""+, \verb+" [removed] "+, \verb+"[ removed ]"+,\\\verb+"[removed]"+, \verb+"[ deleted ]"+, \verb+"[deleted]"+, \verb+" [deleted] "+}. Then, we split the set of authors into a non-overlapping 70\% train, 15\% development and 15\% test author split. For each CC level (conversation, domain, no) and each author split, we generated a set of training tasks, i.e., nine sets in total (see Table \ref{table:split-statistics}). First, we generated the tasks for the train split of the dataset with conversation content control. % We sampled 210k distinct utterances $A_1$ from the train author split. We use a weighted sampling process to not overrepresent authors that wrote more utterances than others. The maximum time one author wrote $A_1$ is 9 (c.f. ``ma'' in Table \ref{table:split-statistics}). Then, for each utterance $A_1$, we randomly sampled an utterance $B$ that was part of the same conversation as $A_1$ but written by a different author. Then, for all 210k ($A_1$, $B$)-pairs, an utterance $A_2$ was sampled randomly from all utterances written by the same author as $A_1$ and for which $A_1 \neq A_2$ holds. We equivalently sampled 45k tasks for the dev and test. For the domain and no CC level, we reuse $A_1$ and $A_2$, to keep as many correlating variables constant as possible. Thus, we only resampled 210k utterances $B$ written by a different author from $A_1$ by sampling from the same domain or randomly. We make sure that each combination of ($A_1$, $A_2$, $B$) occurs only once. Thus there are no repeating CAV tasks.\footnote{Due to the sampling process, there might be same author ($A_1$, $A_2$) pairs that occur twice. However, this remains unlikely due to the high number of authors and utterances. Overall, the share of repeating pairs remains lower than 1\%.} % However, it is possible that some utterances occur more than once across tasks. In total, we generate 210k train, 45k dev and 45k test tasks for each CC level (see Table \ref{table:split-statistics}), corresponding to a total of 420k, 90k and 90k AV-pairs when splitting the CAV task into (A, SA) and (A, DA) pairs (c.f.~Section \ref{sec:task}). \begin{table*}[th] \small \centering \begin{tabular}{l r | l l l | l l l} % \toprule & & \multicolumn{6}{c}{\textbf{\underline{Testing Task}}} \\ & & \multicolumn{3}{c|}{\textbf{AV}} & \multicolumn{3}{c}{\textbf{CAV}} \\ % \multicolumn{2}{c|}{{\textbf{\underline{Training Task}}}} & \multicolumn{1}{c}{\textbf{Conversation}} & \multicolumn{1}{c}{\textbf{Domain}} & \multicolumn{1}{c|}{\textbf{No}} & \multicolumn{1}{l}{\textbf{Conversation}} & \multicolumn{1}{c}{\textbf{Domain}} & \multicolumn{1}{l}{\textbf{No}} \\ \textbf{Setup} & \textbf{CC level} & AUC $\pm\sigma$ & AUC $\pm\sigma$ % & AUC $\pm\sigma$ & acc $\pm\sigma$ % & acc $\pm\sigma$ & acc $\pm\sigma$ % \\ \midrule \multicolumn{2}{c|}{RoBERTa base} & $.53$ & $.57$ & $.61$ & $.53$ & $.58$ & $.63$ \\ \midrule \multirow{3}{*}{{\textbf{AV}}} & {\textbf{Conversation}} % & $\mathbf{.69}\pm.02$ & ${.70}\pm.02$ & $.71\pm.02$ % & $\mathbf{.68}\pm.02$ & ${.69}\pm.02$ & $.70\pm.02$ \\ & {\textbf{Domain}} & ${.68}\pm.01$ & $\mathbf{.71}\pm.01$ & ${.73}\pm.02$ % & ${.67}\pm.01$ & $\mathbf{.70}\pm.01$ & ${.73}\pm.00$ \\ & {\textbf{No}} & $.58\pm.01$ & $.63\pm.02$ & $\mathbf{.79}\pm.00$ % & $.59\pm.01$ & $.66\pm.01$ & $\mathbf{.78}\pm.00$ \\ \midrule \multirow{3}{*}{{\textbf{CAV}}} & {\textbf{Conversation}} & $\mathbf{.69}\pm.00$ & ${.70}\pm.00$ & ${.71}\pm.00$ % & $\mathbf{.68}\pm.00$ & ${.69}\pm.00$ & ${.70}\pm.00$ \\ & {\textbf{Domain}} % & ${.68}\pm.00$ & ${.70}\pm.00$ & ${.72}\pm.00$ % & $\mathbf{.68}\pm.00$ & $\mathbf{.70}\pm.00$ & ${.72}\pm.01$ % \\ & {\textbf{No}} % & $.58\pm.00$ & $.63\pm.03$ & $.77\pm.00$ % & $.59\pm.00$ & $.65\pm.00$ & ${.77}\pm.00$ \\ \bottomrule \end{tabular} % \caption{\textbf{Test Results.} Results for 6 different fine-tuned RoBERTa models on the test sets. % We display the accuracy of the models for the contrastive authorship verification setup (CAV) and the AUC for the authorship verification task (AV) with different content control approaches (CC). We display the standard deviation ($\sigma$). Best performance per column is boldfaced. Models generally outperform others on the CC level they have been trained on. } \label{fig:test-task-results} \end{table*} \subsection{Training} \label{sec:models} We use the \texttt{Sentence-Transformers}\footnote{\url{https://sbert.net/}} python library \cite{reimers-gurevych-2019-sentence}\footnote{with Apache License 2.0} to fine-tune several siamese networks % based on (1) `bert-base-uncased', (2) `bert-base-cased' \cite{devlin-etal-2019-bert} and (3) `roberta-base' \cite{liu2019roberta}. We expect those to perform well based on previous work \cite{zhu-jurgens-2021-idiosyncratic, wegmann-nguyen-2021-capture}. We compare using (a) contrastive loss \cite{contrastive-learning} with the AV setup (Section \ref{sec:task}) tasks and (b) triplet loss \cite{reimers-gurevych-2019-sentence} with the CAV setup (Figure \ref{fig:Task}). The binary contrastive loss function uses a pair of sentences as input while the triplet loss expects three input sentences. For the loss functions, we experiment with three different values for the margin hyperparameter (i) 0.4, (ii) 0.5, (iii) 0.6. % We train with a batch size of 8 over 4 epochs using 10\% of the training data as warm-up steps. We use the Adam optimizer with the default learning rate (0.00002). % We leave all other parameters as default. We use the BinaryClassificationEvaluator on the AV setup with contrastive loss and the TripletEvaluator on the CAV setup with triplet loss from \texttt{Sentence-Transformers} to select the best model out of the 4 epochs. The BinaryClassificationEvaluator calculates the accuracy of identifying similar and dissimilar sentences, while the TripletEvaluator checks if the distance between A and SA is smaller than the distance between A and DA. We use cosine distance as the distance function. \section{Evaluation} \label{sec:eval} We evaluate the learned style representations on the Authorship Verification task (i.e., the training task) in Section \ref{sec:eval-TT}. Then, we evaluate whether models learn to represent known style dimensions via the performance on the \texttt{STEL} framework \cite{wegmann-nguyen-2021-capture} in Section \ref{sec:eval-STEL}. Last, we evaluate representations on their content-independence with an original manipulation of \texttt{STEL} (Section \ref{sec:eval-t-a-STEL}). \subsection{Authorship Verification} \label{sec:eval-TT} We display the AV and CAV performance of trained models in Table \ref{fig:test-task-results}. On the development sets, RoBERTa models consistently outperformed the cased and uncased BERT models. Also, different margin values only led to small performance differences (Appendix \ref{sec:app_dev-results}). % Consequently, in Table \ref{fig:test-task-results}, we only display the performance of the six fine-tuned RoBERTa models on the test sets using the three different content controls (CC) and two different task setups (AV and CAV setups) with constant margin values of 0.5. AV performance is usually calculated with either (i) AUC or (ii) accuracy using a predetermined threshold \cite{zhu-jurgens-2021-idiosyncratic,KestemontEtAl:CLEF-2021}. % We use cosine similarity to calculate the similarity between sentence representations. Thus, there is no clear constant default threshold to decide between same and different author utterances. A threshold could be fine-tuned on the development set, however for simplicity we use AUC to calculate AV performance instead.% We use accuracy for the CAV task --- here no threshold is necessary (cosine similarity is calculated between $A_1$, $A_2$ and $A_1$, $B$ and the highest similarity utterance is chosen). This makes the performance scores on the test sets less comparable across setups -- however, comparability of the CAV and AV performance scores are limited in any case as the AV vs. CAV setups are fundamentally different. % Performance scores can be compared across the same column, i.e., within the same AV and CAV setup. We aggregate performance with mean and standard deviation for three different random seeds per model parameter combination.\footnote{We used seeds 103-105. A total of 5 out of 18 models did not learn. We re-trained those with different seeds.} % Overall, the AV \& CAV training task setup (rows in Table \ref{fig:test-task-results}) lead to similar performance on the test sets. As a result, we do not distinguish between them in this section's discussion. Generally, the representations tested on the CC level they were trained on (diagonal) outperform other models that were not trained with the same CC level. For example, representations trained with the conversation CC level, perform better on the test set with the conversation CC than representations trained with the domain or no CC. \textbf{Tasks with the conversation label are hardest to solve.} For all models, the performance is lowest on the conversation test set and increases on the domain and further on the random test set. This is in line with our assumption that the conversation test set has semantically closer different author utterance ($A_1$, $B$)-pairs that make the AV task harder due to reduced spurious content cues (Section \ref{sec:task}). % \textbf{Representations trained with the conversation CC might encode less content information.} The average performance across the three CC levels is slightly higher for the models trained with domain than conversation CC level and lowest for no CC. Across the three test sets with the different CC levels, the standard deviation in performance is biggest for models trained without CC and smallest for models trained with the conversation CC. Representations trained with domain or no CC might latch on to more semantic features because they are more helpful on the no and domain CC test sets. Models learned with the conversation CC might in turn learn more content-agnostic representations. Overall, a representation that performs well on the AV task alone % might do so by latching on to content (not style) information. As a result, a good AV performance alone might not be indicative of a good representation of style. We further evaluate the quality of style representations and their content-independence in Sections \ref{sec:eval-STEL} and \ref{sec:eval-t-a-STEL}. \begin{table*}[t] \small \centering \begin{tabular}{p{0.001cm} p{1mm}| p{2.5mm} p{4mm} | l l | l l | l l | l l } \toprule & & \multicolumn{2}{c|}{\textbf{all}} & \multicolumn{2}{c|}{\textbf{formal, $\mathbf{n=815}$}} & \multicolumn{2}{c|}{\textbf{complex, $\mathbf{n=815}$}} & \multicolumn{2}{c|}{\textbf{nb3r, $\mathbf{n=100}$}} & \multicolumn{2}{c}{\textbf{c'tion, $\mathbf{n=100}$}} \\ & & \multicolumn{1}{c}{o} & \multicolumn{1}{c|}{o-c} & \ \ \ \ \ \ \ o & \ \ \ \ \ \ o-c & \ \ \ \ \ \ \ o & \ \ \ \ \ \ o-c & \ \ \ \ \ \ \ o & \ \ \ \ \ \ o-c & \ \ \ \ \ \ \ o & \ \ \ \ \ \ o-c \\ & & & & \ acc$\pm\sigma$ & \ acc$\pm\sigma$ & \ acc$\pm\sigma$ & \ acc$\pm\sigma$ & \ acc$\pm\sigma$ & \ acc$\pm\sigma$ & \ acc$\pm\sigma$ & \ acc$\pm\sigma$ \\ \midrule \multicolumn{2}{c|}{{org}} & \textbf{.80} & .05 % & .83 & .09 % & \textbf{.73} & .01 % & \textbf{.94} & \textbf{.13} % & \textbf{1.0} & .00 % \\ \midrule \multirow{3}{*}{\textbf{A}} & {\textbf{c}} % & .71 & ${.35}$ % & ${.83}\pm.02$ & ${.64}\pm.00$ % & $.57\pm.02$ & ${.13}\pm.04$ % & $.61\pm.02$ & $.04\pm.01$ % & ${.91}\pm.10$ & ${.00}\pm.01$ % \\ & {\textbf{d}} & $.73$ & $.28$ % & ${.84}\pm.01$ & ${.56}\pm.04$ % & ${.69}\pm.05$ & $.05\pm.02$ % & $.61\pm.02$ & $.03\pm.02$ % & ${.98}\pm.03$ & $.00\pm.00$ % \\ & {\textbf{n}} & $.72$ & $.22$ % & $\mathbf{.85}\pm.01$ & ${.46}\pm.04$ % & $.57\pm.01$ & $.03\pm.01$ % & $.62\pm.04$ & $.05\pm.02$ % & ${.98}\pm.01$ & $.00\pm.00$ % \\ \midrule \multirow{3}{*}{\parbox{1cm}{\textbf{C}}} & {\textbf{c}} & $.71$ & $\mathbf{.42}$ % & ${.81}\pm.02$ & $\mathbf{.69}\pm.02$ % & ${.59}\pm.01$ & $\mathbf{.24}\pm.02$ % & ${.65}\pm.09$ & ${.03}\pm.01$ % & ${.99}\pm.02$ & $\mathbf{.04}\pm.02$ % \\ & {\textbf{d}} & $.71$ & $.32$ % & ${.82}\pm.01$ & ${.61}\pm.02$ % & $.57\pm.01$ & $.12\pm.01$ % & $.64\pm.05$ & $.03\pm.01$ % & ${.99}\pm.01$ & ${.01}\pm.01$ % \\ & {\textbf{n}} & $.71$ & $.24$ % & $\mathbf{.85}\pm.00$ & $.50\pm.02$% & ${.56}\pm.01$ & ${.04}\pm.01$ % & ${.59}\pm.03$ & ${.06}\pm.01$ % & ${.98}\pm.04$ & ${.00}\pm.00$ % \\ \bottomrule \end{tabular} \caption{\textbf{\texttt{STEL} and \texttt{STEL}-Or-Content Results.} We display \texttt{STEL} accuracy across 4 style dimensions ($n=$number of instances) for the same RoBERTa models as in Table \ref{fig:test-task-results}: % Per task setup (AV - A, CAV - C) and content control level (conversation - c, domain - d, none - n), the performance on the original (o) and the \texttt{STEL}-Or-Content task instances (o-c) are displayed. Per column, the best performance is boldfaced. % For the fine-tuned RoBERTa models, performance generally increases on the \texttt{STEL}-Or-Content task compared to the original RoBERTa model (org). } \label{table:results-stle-models} \end{table*} \begin{figure}[t] \centering \small \begin{tabular}{p{45pt} p{60pt} p{1pt} p{60pt}} & \hspace*{20pt} \color{blue} 1 & & \hspace*{20pt} \color{blue} 2 \\ \color{blue} Anchor (A) & \cellcolor{green!25} r u a fan of them or something? & & \textcolor{black}{Are you one of their fans? \tikzmark{A2_end} } \\ & & \\ \color{blue} Sentence (S) & \tikzmark{A2_top} \textcolor{gray}{\st{Oh, and also that young physician got an unflattering haircut}} & & \cellcolor{green!25} Oh yea and that young dr got a bad haircut \\ \end{tabular} \begin{tikzpicture}[overlay, remember picture] \draw [->,very thick, red]($(A2_end.east) - (1.6,0.2)$) -- ($(A2_top.east) - (-2.35,-0.3)$) ; \end{tikzpicture} \caption{\textbf{\texttt{STEL}-Or-Content Task.} We take the original \texttt{STEL} instances (figure without manipulations) and move A2 to the sentence position with the different style (here: the more formal A2 replaces the more formal S1). These resulting triple tasks % can test if a model prefers style over content cues.} \label{tab:t-a-STEL} \end{figure} \subsection{STEL Task} \label{sec:eval-STEL} We calculate the performance of the representations on the \texttt{STEL} framework \cite{wegmann-nguyen-2021-capture}\footnote{\url{https://github.com/nlpsoc/STEL}, with data from \newcite{rao-tetreault-2018-dear, xu-etal-2016-optimizing} and with permission from Yahoo for the ``L6 - Yahoo! Answers Comprehensive Questions and Answers version 1.0 (multi part)'': \url{https://webscope.sandbox.yahoo.com/catalog.php?datatype=l}. Data and code available with MIT License with exceptions for proprietary Yahoo data.}. Here, models are evaluated on whether they are able to measure differences in style across four known dimensions of style (formal vs. informal style, complex vs. simple style, contraction usage and number substitution usage). % Models are tested on 1830 tasks of the same setup: Two ``sentences'' S1 and S2 have to be matched to the style of two given ``anchor'' sentences A1 and A2. The task is binary. Sentences can either be matched without reordering (A1-S1 \& A2-S2) or with reordering (A1-S2 \& A2-S1). For example, consider the sentences in Figure \ref{tab:t-a-STEL} before alterations. The correct solution to the task is to reorder the sentences, i.e., to match A1 with S2 because they both exhibit a more informal style and A2 with S1 because they both exhibit a more formal style. The \texttt{STEL} sentence pairs (S1, S2) and (A1, A2) are always paraphrases of each other % (in contrast to $A_1$ and $B$ for the AV task which are only chosen to be about the same approximate topic, c.f.~\ref{sec:task}). The anchor pairs and sentence pairs are randomly matched and are thus otherwise expected to have no connection in content or topic. Representations can thus not make use of learned content features to solve the task. % We display the \texttt{STEL} results for the RoBERTa models in Table \ref{table:results-stle-models}. \textbf{\texttt{STEL} performance is comparable across all fine-tuned models --- for all different CC levels and AV \& CAV setups.} Surprisingly, the overall \texttt{STEL} performance for the fine-tuned models is lower than that of the original RoBERTa base model \cite{liu2019roberta}. Thus, models may have `unlearned' some style information. In the remainder of this subsection, we analyze possible reasons for this \texttt{STEL} performance drop. Performance stays approximately the same or improves for the formal/informal and the contraction dimensions, but drops for the complex/simple and the nb3r substitution dimensions. Based on manual inspection, we notice nb3r substitution to regularly appear in specific conversations and for specific topics. Future work could investigate whether the use of nb3r substitution is less consistent for one author than other stylistic dimensions. As the nb3r dimension of \texttt{STEL} only consists of 100 instances, future work could increase the number of instances. % Further, we perform an error analysis to investigate the \texttt{STEL} performance drop in the complex/simple dimension. We manually look at consistently unlearned (i.e., wrongly predicted by the fine-tuned but correctly predicted by the original RoBERTa model) or learned (i.e., wrongly predicted by the RoBERTa model and correctly predicted by the fine-tuned model) \texttt{STEL} instances (see details in Appendix \ref{sec:app_STEL-error-analysis}). We find several problematic examples where the correct solution to the task is at least ambiguous. We display two such examples in Table \ref{table:err-analysis-unlearned_qualitative}. % The share of examples with problematic ambiguities is higher for the unlearned (50/55) than for the newly learned \texttt{STEL} instances (29/41). Generally, the number of complex/simple \texttt{STEL} instances with ambiguities is surprisingly high for both the learned as well as the unlearned instances, consistent with the lower performance of the models in this category. Several of the found ambiguities should be relatively easy to correct in the future (e.g., spelling mistakes or punctuation differences). \subsection{Content-Independence of Style Representations} \label{sec:eval-t-a-STEL} We tested whether models are able to distinguish between different authors (in Section \ref{sec:eval-TT}) and represent styles when the content remains the same (Section \ref{sec:eval-STEL}). However, we have not tested whether models learn to represent style independent from content. % Different approaches have been used to test whether style representations encode unwanted content information, including (a) comparing performance on the AV task across domain \cite{AV_SimilarityLearning, zhu-jurgens-2021-idiosyncratic}, (b) assessing performance on function vs. content words \cite{hay-etal-2020-representation, zhu-jurgens-2021-idiosyncratic} and (c) predicting domain labels from utterances using their style representations \cite{zhu-jurgens-2021-idiosyncratic}. However, these evaluation methods have limitations: Domain labels usually come from a small set of coarse-grained labels and function words have been shown to not necessarily be content-independent \cite{litvinova_context-stylometric}. Additionally, next to content, AV might include other spurious features that help increase performance without representing style. % \begin{table*}[th] \centering \small \begin{tabular}{c c p{23mm} p{23mm} p{29mm} p{31mm} p{13mm}} \toprule \textbf{Agg.} & \textbf{GT} & \textbf{Anchor 1 (A1)} & \textbf{Anchor 2 (A2)} & \textbf{Sentence 1 (S1)}& \textbf{Sentence 2 (S2)} &\textbf{Ambiguity} \\ \midrule \textbf{un} & \cmark & TDL Group announced in March 2006, in response to a request [...] % & % [...] storm names Alberto Helene Beryl Isaac Chris [...] & Palestinian voters in the Gaza Strip [...] were eligible to participate in the election. & 1. Palestinian voters in the Gaza Strip [...] were eligible to participate in the election. & A1/A2 have different content \\ \midrule \textbf{l} & \xmark & [...] % 51 Phantom [...] % received nominations in that same category. & [...] % 1 phantom [...] % received nominations in the same category. & [...] % the Port Jackson District Commandant could exchange with all military land with buildings on the harbor. & [...] % the Port Jackson District Commandant could communicate with all military installations on the harbour. & A2 spelling mistake, S1 sounds unnatural \\ \bottomrule \end{tabular} \caption{\label{table:err-analysis-unlearned_qualitative} \textbf{\texttt{STEL} Error Analysis.} For the complex/simple \texttt{STEL} dimension, we display examples of ambiguous instances that were learned (l) or unlearned (un) the fine-tuned RoBERTa models. % A ground truth (GT) of \cmark \ means that S1 matches with A1 and S2 with A2 in style, while \xmark \ means S1 matches with A2 and S2 with A1. } \end{table*} To test if models learn to prefer style over content, we introduce a variation to the \texttt{STEL} framework --- the \textit{\texttt{STEL}-Or-Content} task: From one original \texttt{STEL} instance (Section \ref{sec:eval-STEL}), % we take the sentence that has the same style as A2 and replace it with A2. In Figure \ref{tab:t-a-STEL}, this leads to S1 being replaced by A2. The new task is to decide whether A1 matches with the new S1 (originally A2) or with S2. The task is more difficult than the original \texttt{STEL} task as S2 is written in the same style as A1 but has different content and the new S1 is written in a different style but has the same content. The representations will have to decide between giving `style or content' more weight. This setup is similar to the CAV task (Figure \ref{fig:Task}). The main differences to the CAV task are (i) that we do not use same author as a proxy for same style but instead use the predefined style dimensions from the \texttt{STEL} framework and (ii) that we control for content with the help of paraphrases (instead of using ony a topic proxy). We display the \texttt{STEL}-Or-Content results in Table \ref{table:results-stle-models}. The performance for the new task is low ($<0.5$ which corresponds to a random baseline). However, the task is also very difficult as lexical overlap is usually high between the anchor and the false choice (i.e., the sentence that was written in a different style but has the same content). Nevertheless, performance should only be considered in combination with other evaluation approaches (Sections \ref{sec:eval-TT} and \ref{sec:eval-STEL}) as on this task alone models might perform well because they punish same content information. % \textbf{Models trained on the CAV task with the conversation CC level are the best at representing style independent from content.} The performance increases from an accuracy of $0.05$ for the original RoBERTa model to up to $0.42\pm.01$ for the representation trained with the CAV task and the conversation CC. % This `CAV conversation representation' did not just learn to punish same content cues because of its performance on the AV task and the \texttt{STEL} framework: (1) On the AV task, the representation performed comparably on all three test sets. If the model had learned to just punish same content cues, we would expect a clearer difference in performance as confounding same content information should be more prevalent for the random than the conversation test set. (2) The representation performed comparably to the other representations on the \texttt{STEL} framework, where style information is needed to solve the task but content information cannot be used. \section{Style Representation Analysis} We want to further understand what the style representations learned to be similar styles. We take the best-performing style representation (RoBERTa trained on the CAV task with the conversation CC and seed 106) and perform agglomerative clustering on a sample of 5.000 CAV tasks of the conversation test set resulting in 14,756 unique utterances. We use 7 clusters based on an analysis of Silhouette scores (Appendix \ref{sec:app_silhouette}). Out of all utterance pairs that have the same author, $46.2\%$ appear in the same cluster. % This is different from random assignments among 7 clusters\footnote{Calculated mean and standard deviation of 100 random assignments of utterances to the 7 clusters of the same size.} which corresponds to $20.1\%\pm .00$. As authors will have a certain variability to their style, a perfect clustering according to general linguistic style would not assign all same author pairs to the same cluster. \begin{table}[t] \renewcommand{\arraystretch}{1.2} \small \begin{tabular}{c p{14mm} p{47mm}} % \toprule \textbf{C \#} & \textbf{Consistent} & \textbf{Example} \\ % \midrule \textbf{3} % & no last punct. & I am living in china, they are experiencing an enormous baby boom \\ \midrule \textbf{4} % & punctuation / ca\-sing & huh thats odd i\textquotesingle m in the 97\% percentile on iq tests, the sat, and the act \\ \midrule \textbf{5} % & ’ vs \ \textquotesingle & I assume it’s the blind lady? \\ \midrule \textbf{7} % & line\-breaks & I admire what you\textquotesingle re doing but [...] % \newline \newline I know I\textquotesingle m [...] % \\ \bottomrule \end{tabular} \caption{\textbf{Clusters for RoBERTa Trained on CAV with Conversation Content Control.} We display one example for 4 out of 7 clusters. We mention noticeable consistencies within the cluster (Consistent). % } \label{tab:clusters} \end{table} In Table \ref{tab:clusters}, we display examples for 4 out of 7 clusters. We manually looked at a few hundred examples per cluster to find consistencies. % We found clear consistencies within clusters in the punctuation (e.g., 97\% of utterances have no last punctuation mark in Cluster 3 vs. an average of $37\%$ in the other clusters), casing (e.g., $67\%$ of utterances that use \textit{i} instead of \textit{I} appear in Cluster 4), contraction spelling (e.g., 22 out of 27 utterances that use \textit{didnt} instead of \textit{didn't} appear in Cluster 4), the type of apostrophe used (e.g., $90\%$ of utterances use {`} vs {\textquotesingle} \ in Cluster 5 vs. an average of $0\%$ in the other clusters) and line breaks within an utterance (e.g., $72\%$ of utterances in Cluster 7 include line breaks vs. an average of $22\%$ in the other clusters). We mostly found letter-level consistencies --- likely because they are easiest to spot manually. We expect representations to also capture more complex stylometric information because of their performance on the AV and \texttt{STEL} tasks (Section \ref{sec:eval}). Future work could analyze whether and what other stylistic consistencies are represented by the models. % For comparison we also cluster with the base RoBERTa model (see Appendix \ref{sec:app_cluster}). The only three interesting RoBERTa clusters (i.e., clusters 2,3,4 that contain more than three elements and not as many as $86.7\%$ of all utterances), seem to mostly differ in utterance length (average number of characters are 15 in Cluster 2 vs. in 1278 in Cluster 3) % and in the presence of hyperlinks ($84\%$ of utterances contain `https://' in Cluster 4 vs. an overall average of $2\%$). % Average utterance lengths are not as clearly separated by the clusters of the trained style representations. % \section{Limitations and Future Work} We propose several directions for future research: First, conversation labels are already inherently available in conversation corpora like \texttt{Reddit}. However, it remains a difficulty to transfer the conversation CC to other than conversation datasets. Moreover, even when using the conversation CC, content information might still be useful for AV: If one person writes ``my husband'' and another writes ``my wife'' within the same conversation, it is highly unlikely that those utterances have been generated by the same person. % With the recent advances in semantic sentence embeddings, it might be interesting to train style representations on CAV tasks with a new content control level: Two utterances could be labelled as having the same content if their semantic embeddings are close to each other (e.g., when cosine similarity is above a certain threshold). Second, for the \texttt{STEL}-Or-Content task, the so-called ``triplet problem'' \cite{wegmann-nguyen-2021-capture} remains a potential problem. Consider the example in Figure \ref{tab:t-a-STEL}. Here, the \texttt{STEL} framework only guarantees that A1 is more informal than A2 and S2 is more informal than S1. Thus, in some cases A2 can be stylistically closer to A1 than S2. However, we expect this case to be less prevalent: A2 would need to be already pretty close in style to A1, or both S2 and S1 would need to be substantially more informal or formal than A1. % In the future, removing problematic instances could alleviate a possible maximum performance cap. Third, the representation models may learn to represent individual stylistic variation as we use utterances from the same individual author as positive signals (c.f.~\newcite{zhu-jurgens-2021-idiosyncratic}). However, because the representation models learn with same author pairs that are generated from thousands of authors, it is likely that they also learn consistencies along groups of authors that use similar style features (e.g., demographic groups based on age or education level, or subreddit communities). Future work could explore how different CC levels and training tasks influence the type of styles that are learned. \section{Conclusion} Recent advances in the development of style representations have increasingly used training objectives from authorship verification \cite{hay-etal-2020-representation,zhu-jurgens-2021-idiosyncratic}. % However, representations that perform well on the Authorship Verification (AV) task might do so not because they represent style well but because they latch on to spurious content correlations. We train different style representations by controlling for content (CC) using conversation or domain membership as a proxy for topic. We also introduce the new Contrastive Authorship Verification setup (CAV) and compare it to the usual AV setup. % We propose an original adaptation of the recent \texttt{STEL} framework \cite{wegmann-nguyen-2021-capture} to test whether learned representations favor style over content information. We find that representations that were trained on the CAV setup with conversation CC represent style in a way that is more independent from content than models using other CC levels or the AV setup. % We demonstrate some of the learned stylistic differences via agglomerative clustering --- e.g., the use of a right single quotation mark vs. an apostrophe in contractions. We hope to contribute to increased efforts towards learning general-purpose content-controlled style representations. \section*{Ethical Considerations} We use utterances taken from 100 subcommunities (i.e., subreddits) of the popular online platform \texttt{Reddit} to train style representations with different training tasks and compare their performance. % With our work, we aim to contribute to the development of general style representations that are disentangled from content. Style representations have the potential to increase classification performance for diverse demographics and social groups \cite{hovy-2015-demographic}. The user demographics on the selected 100 subreddits are likely skewed towards particular demographics. For example, locally based subreddits (e.g., canada, singapore) might be over-represented. Generally, the average \texttt{Reddit} user is typically more likely to be young and male.\footnote{\small {https://www.journalism.org/2016/02/25/reddit-news-users-more-likely-to-be-male-young-and-digital-in-their-news-preferences/}} Thus, our representations might not be representative of (English) language use across different social groups. However, experiments on the set of 100 distinct subreddits should still demonstrate the possibilities of the used approaches and methods. We hope the ethical impact of reusing the already published \texttt{Reddit} dataset \cite{Baumgartner_Zannettou_Keegan_Squire_Blackburn_2020, chang-etal-2020-convokit} to be small but acknowledge that reusing it will lead to increased visibility of data that is potentially privacy infringing. As we aggregate the styles of thousands of users to calculate style representations, we expect it to not be indicative of individual users. We confirm to have read and that we abide by the ACL Code of Ethics. \section*{Acknowledgements} We thank the an anonymous ARR reviewers for their helpful comments. This research was supported by the ``Digital Society - The Informed Citizen'' research programme, which is (partly) financed by the Dutch Research Council (NWO), project 410.19.007. Dong Nguyen was supported by the research programme Veni with project number VI.Veni.192.130, which is (partly) financed by the Dutch Research Council (NWO).
{'timestamp': '2022-04-12T02:33:50', 'yymm': '2204', 'arxiv_id': '2204.04907', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04907'}
arxiv
\section{Introduction}\label{sec:introduction}} \newcommand{\RNum}[1]{\lowercase\expandafter{\romannumeral #1\relax}} \IEEEPARstart{U}{nderstanding} the semantics of an image and recognizing objects in it are vital processes in computer vision systems. These tasks involve semantic segmentation, in which a semantic label is allocated to each pixel of an image, and object localization, otherwise known as single-object detection, which locates a target object in \jmrv{the} form of a bounding box. Although deep neural networks (DNNs) have facilitated tremendous progress in both tasks~\cite{chen2017deeplab, huang2019ccnet, chen2018encoder, ren2015faster, redmon2016you, lin2017focal}, it has come at the cost of annotating thousands of training images with explicit localization cues. In particular, for semantic segmentation, pixel-level annotation of images containing an average of 2.8 objects takes about 4 minutes per image~\cite{bearman2016s}; and a single large (2048$\times$1024) image depicting a complicated scene requires more than 90 minutes for pixel-level annotation~\cite{cordts2016cityscapes}. The need for such expensive annotations is sidestepped by weakly supervised learning, in which a DNN is trained on images with \jmrv{some form of abbreviated annotation \rvt{that} is cheaper than explicit localization cues.} Weakly supervised semantic segmentation methods can use scribbles~\cite{tang2018normalized}, points~\cite{bearman2016s}, bounding boxes~\cite{khoreva2017simple, song2019box, lee2021bbam}, or class labels~\cite{lee2019ficklenet, lee2022weakly, ahn2018learning, chang2020weakly, kim2022bridging} as annotations. The last of these are the cheapest and most popular option, largely because the images in many public datasets are already annotated with class labels~\cite{deng2009imagenet, everingham2010pascal}, and automated web searches can also provide images with class labels~\cite{lee2019frame, hong2017weakly, shen2018bootstrapping}. Likewise, in weakly supervised object localization, class labels are a popular choice of annotation for localizing target objects with bounding boxes. Weakly supervised semantic segmentation and object localization share the same goal, inasmuch as their aim is to generate informative localization cues that allow the regions occupied by a target object to be identified with class labels. \input{Figures/overview} Most weakly supervised semantic segmentation and object localization methods depend on attribution maps obtained from a trained classifier, such as a Class Activation Map (CAM)~\cite{zhou2016learning} or a Grad-CAM~\cite{selvaraju2017grad}. An attribution map identifies the important, or discriminative, regions of an image on which the classifier has concentrated. But these regions tend to be relatively small, and most attribution maps do not identify the whole region occupied by \jmrv{the} target object. Therefore, many researchers have tried to extend attributed regions to cover more of \jmrv{the} target object, by manipulating either the image~\cite{wei2017object, li2018tell, singh2017hide, babar2021look} or the feature map~\cite{lee2019ficklenet, zhang2018adversarial, hou2018self, choe2020attention, ki2020sample}. One popular method of manipulation is erasure, which iteratively removes the discriminative regions which have already been identified, forcing the classifier to find new regions of the target object~\cite{wei2017object, li2018tell, babar2021look, singh2017hide, hou2018self, zhang2018adversarial, mai2020erasing, ki2020sample}. Erasure is effective, but if the image from which the discriminative region has been erased crosses the decision boundary, as shown in Fig.~\ref{overview}(a), an erroneous attribution map may be generated. \rvt{An alternative manipulation method} is \rvt{a} stochastic perturbation, shown in Fig.~\ref{overview}(b): FickleNet~\cite{lee2019ficklenet} produces diverse attribution maps from an image by applying random dropout to the feature maps obtained by a \rvt{DNN and} then aggregates them into a unified map. We propose a new manipulation method for extending the attributed regions of a target object. Our method is a benign twist on the established technique of adversarial attack~\cite{goodfellow2014explaining, kurakin2016adversarial}, which operates by finding a small perturbation of an image that pushes it across the decision boundary to change the classification result. Our method operates in a reversed, or `anti-adversarial' manner: it aims to find a perturbation that drives the manipulated image \textit{away from} the decision boundary, as shown in Fig.~\ref{overview}(c). \rv{This manipulation is realized by `adversarial climbing', which perturbs an image along pixel gradients so as to increase the logit of the target class produced by the classifier before its \rvt{softmax or sigmoid} layer. From here on, we refer to the value of this logit as the classification score of the target class.} As a result of iterative adversarial climbing, the CAM of the manipulated image gradually identifies more regions of the target object, as shown in Fig.~\ref{overview}(d). The attribution maps obtained from images that have been iteratively manipulated in this way can be used as localization cues for weakly supervised semantic segmentation and object localization. While ascending the gradient ensures that the classification score increases, excessive ascent may cause problems: (\RNum{1}) irrelevant \rv{regions}, such as parts of the background or regions of other objects, can also be activated, or (\RNum{2}) the attribution scores of some parts of the target object can \rv{get unreasonably large}. We address these problems by introducing regularization terms that suppress the scores of classes other than the target class and limit the attribution scores of regions that already have high scores. Existing methods that aim to expand the identified region of a target object require additional modules~\cite{wang2020self, lee2019ficklenet, lu2020geometry, mai2020erasing} or a different training technique~\cite{chang2020weakly, zhangsplitting, ki2020sample, zhang2020inter}. Our method is a post-hoc analysis of the trained classifier, and therefore can be used to improve the performance of existing methods without modification. It achieves a new state-of-the-art performance on the PASCAL VOC 2012~\cite{everingham2010pascal} and \rv{MS COCO 2014}~\cite{lin2014microsoft} datasets in both weakly and semi-supervised semantic segmentation. In weakly supervised object localization, our method \rvt{again} achieves a new state-of-the-art performance on the CUB-200-2011~\cite{wah2011caltech} and ImageNet-1K~\cite{deng2009imagenet} datasets. This paper is an extended version of our previous \rv{publication}~\cite{lee2021anti}. In this paper, (\RNum{1}) we include more detailed explanations of our method\rv{;} (\RNum{2}) we propose a new technique, which seamlessly integrates a salient object detector into adversarial climbing for weakly supervised semantic segmentation\rv{;} (\RNum{3}) we present additional experimental results on weakly supervised semantic segmentation, including tests \rv{on more backbones and an additional dataset (\rv{MS COCO 2014}~\cite{lin2014microsoft})}\rv{;} (\RNum{4}) we also test our algorithm on weakly supervised object localization with the ImageNet-1K~\cite{deng2009imagenet} and CUB-200-2011~\cite{wah2011caltech} datasets, with the intention of demonstrating the wide applicability of adversarial climbing\rv{; and (\RNum{5}) we analyze our method from various viewpoints and provide deeper insights into the properties of AdvCAM}. The main contributions of this paper can be summarized as follows: \begin{itemize} \vspace{-3pt} \item[$\bullet$] We propose AdvCAM, an attribution map of an image that is manipulated to increase the classification score, allowing it to identify more of the \rv{region} occupied by an object. \rv{\item[$\bullet$] We demonstrate the generality of our method by showing that 1) it can be seamlessly integrated with saliency supervision; 2) it can be applied to multiple tasks, namely weakly and semi-supervised semantic segmentation and weakly supervised object localization; and 3) it improves the performance of several existing methods for weakly supervised semantic segmentation and object localization, without modification or re-training of their networks.} \rv{\item[$\bullet$] We show that our method produces a significantly better performance on the PASCAL VOC 2012 and MS COCO 2014 datasets than existing methods, in both weakly and semi-supervised semantic segmentation. We also achieve new state-of-the-art results on the CUB-200-2011 and ImageNet-1K datasets in weakly supervised object localization.} \rv{\item[$\bullet$] We analyze our method from various viewpoints, providing deeper insights into the properties of AdvCAM.} \end{itemize} \section{Related Work} \subsection{Weakly Supervised Semantic Segmentation}\label{re_weak} \rv{The common pipeline for weakly supervised semantic segmentation \rvt{consists of three main processes}: 1) obtaining initial seed regions, \textit{e.g.,} by using a CAM~\cite{zhou2016learning}, 2) producing pseudo ground truth masks by refining the initial seed, and 3) training a segmentation network with the resulting pseudo ground truth.} \textbf{Obtaining a High-Quality Seed:} Several methods have been proposed to improve the quality of the initial seed regions obtained from classifiers. Wei \textit{et al.}~\cite{wei2017object} obtain new attribution maps using images from which \rv{the previously identified discriminative regions} have been erased. Other researchers have embedded this erasure technique into \rv{their} training \rv{schemes}~\cite{li2018tell, hou2018self}. Wang \textit{et al.}~\cite{wang2020self} use equivariance regularization during the training of their classifier, so that the attribution maps obtained from differently transformed images are equivariant to those transformations. Chang \textit{et al.}~\cite{chang2020weakly} improve feature learning by using latent semantic classes that are sub-categories of annotated parent classes, which can be pseudo-labeled by clustering image features. Zhang \textit{et al.}~\cite{zhangsplitting} produce two different attribution maps from different classifiers and aggregate them into a single map. Fan \textit{et al.}~\cite{fan2018cian} and Sun \textit{et al.}~\cite{sun2020mining} capture information shared among several images by considering cross-image semantic similarities and differences. \rv{Zhang \textit{et al}.~\cite{zhang2020causal} analyze \jmrv{the} co-occurrence context problem in multi-label classification and propose context adjustment (CONTA) to remove the confounding bias, resulting in a CAM seed free \jmrv{of} spurious correlations.} Wei \textit{et al.}~\cite{wei2018revisiting} and Lee \textit{et al.}~\cite{lee2018robust} consider the target object in several contexts by combining multiple attribution maps obtained from differently dilated convolutions or from different layers of \rvt{a} DNN. \textbf{Growing the Object Region:} Some researchers expand an initial seed using a method analogous to region growing, in which they examine the neighborhood of each pixel. They first use a CAM~\cite{zhou2016learning} to identify seed \rv{regions} \rvt{that} can confidently be associated with the target object. Semantic labels are then propagated from those confidently identified regions to ambiguous regions of the CAM which initially had low confidence scores. SEC~\cite{kolesnikov2016seed} and DSRG~\cite{huang2018weakly} allocate pseudo labels to those ambiguous regions using \rv{a conditional random field (CRF)}~\cite{krahenbuhl2011efficient} during the training of the segmentation network. PSA~\cite{ahn2018learning} and IRN~\cite{ahn2019weakly} train a DNN to capture the relationship between pixels and then propagate the semantic labels of confidently identified regions to semantically similar \rv{regions} by a random walk. \rv{BES}~\cite{chenweakly} synthesizes a pseudo boundary from a CAM~\cite{zhou2016learning} and then uses a similar semantic propagation process to that of PSA~\cite{ahn2018learning}. \subsection{Semi-Supervised Semantic Segmentation}\label{re_semi} In semi-supervised learning, a segmentation network is trained using a small number of images with pixel-level annotations, together with a much larger number of images with weak or no annotations. \jmrv{Cross-consistency training (CCT)~\cite{ouali2020semi} enforces \rv{the} invariance of predictions over a range of perturbations such as random noise and spatial dropout.} Lai \textit{et al.}~\cite{Lai2021semi} enforce consistency among the features of the same object occurring in different contexts. Luo \textit{et al.}~\cite{luosemi} introduce a network equipped with two separate branches, one of which is trained with strong labels and the other with weak labels. Zou \textit{et al.}~\cite{Lai2021semi} design a pseudo-labeling process to calibrate the confidence score of pseudo labels for unlabeled data. Souly \textit{et al.}~\cite{souly2017semi} use images synthesized by a generative adversarial network~\cite{goodfellow2014generative}, which improves feature learning. Hung \textit{et al.}~\cite{hung2019adversarial} adopt an adversarial training scheme that increases the similarity of the distribution of the predicted segmentation maps to that of ground-truth maps. \subsection{Weakly Supervised Object Localization}\label{re_wsol} \rv{Weakly supervised object localization aims to predict the bounding box of a target object using class labels.} Most methods for weakly supervised object localization use \jmrv{a similar type of the CAM~\cite{zhou2016learning} \rvt{to} that used in weakly supervised semantic segmentation.} HaS~\cite{singh2017hide} removes random rectangular patches \rv{from} a training image, forcing the classifier to \rv{examine} other regions of the target object. ACoL~\cite{zhang2018adversarial} has two separate branches: \jmrv{one branch identifies the discriminative regions of an object and erases them based on features, and the other branch finds complementary regions from those erased features.} ADL~\cite{choe2020attention} and the technique introduced by Ki \textit{et al.}~\cite{ki2020sample} perform erasure realized by dropout during the training of a classifier. Babar \textit{et al.}~\cite{babar2021look} combine the information from two intermediate images produced by regional dropout at complementary spatial locations. CutMix~\cite{yun2019cutmix} is a data augmentation technique that combines two patches from different images and \jmrv{assigns} a new class label, which reflects the areas of the patches, to the resulting image. Most methods of weakly supervised object localization share a single network for classification and detection, but GC-Net~\cite{lu2020geometry} uses a separate network for each task. \section{Preliminaries} \subsection{Adversarial Attack}\label{adv_attack_method} An adversarial attack attempts to fool a DNN by presenting it with images that have been manipulated with intent to deceive. Adversarial attack can be applied to classifiers~\cite{goodfellow2014explaining, moosavi2016deepfool}, semantic segmentation networks~\cite{arnab2018robustness}, or object detectors~\cite{xie2017adversarial}. Not \jmrv{only} the predictions of a DNN, but \jmrv{also the} attribution maps can be altered by adversarial image manipulation~\cite{dombrowski2019explanations} or model parameter manipulation~\cite{heo2019fooling}. These types of \rvt{attacks} try to make the DNN produce a spurious attribution map \rvt{that} identifies \jmrv{a} wrong location in the image, or a map \rvt{that} might have been obtained from a completely different image, without significantly changing the output of the DNN. An adversarial attack on a classifier aims to find a small pixel-level perturbation that can change its \jmrv{decision.} In other words, given an input $x$ to the classifier, the adversarial attack aims to find the perturbation $n$ that \rvt{satisfies} $\texttt{NN}(x) \neq \texttt{NN}(x+n)$, where $\texttt{NN}(\mathord{\cdot})$ is the classification output \jmrv{from} the DNN. A representative method~\cite{goodfellow2014explaining} of constructing $n$ for an attack starts by constructing the vector normal to the decision boundary of $\texttt{NN}(x)$, which can be realized by finding the gradients of $\texttt{NN}(x)$ with respect to $x$. A manipulated image $x'$ can then be obtained as follows: \vspace{-0.2em} \begin{linenomath}\begin{align}\label{adv_attack} x' = x - \xi \nabla_x \texttt{NN}(x), \vspace{-0.8em} \end{align}\end{linenomath} where $\xi$ determines the extent of the change to the image. This process can be understood as performing gradient descent on the image. PGD~\cite{kurakin2016adversarial}, which is a popular method of adversarial attack, performs the manipulation of Eq.~\ref{adv_attack} iteratively. \subsection{Class Activation Map}\label{CAM_method} A CAM~\cite{zhou2016learning} identifies the region of an image on which a classifier has concentrated. It is computed from the class-specific contribution of each channel of the feature map to the classification score. A CAM is based on a convolutional neural network that has global average pooling (GAP) before its last classification layer. \jmrv{This process can be expressed as follows:} \begin{linenomath}\begin{equation}\label{cam} \texttt{CAM}(x) = \mathbf{w}^\intercal_c f(x), \end{equation}\end{linenomath} where $x$ is the image, $\mathbf{w}_c$ is the weight of the final classification layer for class $c$, and $f(x)$ is the feature map of $x$ prior to GAP. A CAM bridges the gap between image-level and pixel-level annotation. However, the regions obtained by a CAM are usually much smaller than the full extent of the target object, since the small discriminative regions provide sufficient information for classification. \section{Proposed Method} \subsection{Adversarial Climbing}\label{Advcam_method} AdvCAM is an attribution map obtained from an image manipulated using adversarial climbing, which perturbs the image in an anti-adversarial manner that is designed to increase the classification score of the image. This is the reverse of an adversarial attack based on Eq.~\ref{adv_attack}, which manipulates the image to reduce the classification score. Inspired by PGD~\cite{kurakin2016adversarial}, iterative adversarial climbing of an initial image $x^{0}$ can be performed using the following relation: \vspace{-0.1em} \begin{linenomath}\begin{equation}\label{sgd} x^{t} = x^{t-1} + \xi \nabla_{x^{t-1}} y_c^{t-1}, \vspace{-0.2em} \end{equation}\end{linenomath} where $t$ ($1\leq t \leq T$) is the adversarial step index, $x^{t}$ is the manipulated image after step $t$, and $y_c^{t-1}$ is the classification logit of $x^{t-1}$ for class $c$, which is the output of the classifier before the final softmax or sigmoid layer. This process enhances non-discriminative yet class-relevant features, which previously made insufficient contributions to the attribution map. Therefore, the attribution map obtained from an image manipulated by iterative adversarial climbing gradually identifies more regions of the target object. More details of how adversarial climbing improves CAMs as intended are provided in Section~\ref{how_advcam}. \rv{Noise can be expected to be introduced during late adversarial iterations, and this can be suppressed by producing the final localization map\footnote{\rv{Note that we will refer to an attribution map that has been subject to further processing as a localization map.}} $\mathcal{A}$ from an aggregation of the CAMs obtained from the manipulated images produced at each iteration $t$, as follows:} \vspace{-0.3em} \begin{linenomath}\begin{align}\label{aggregate} \mathcal{A} = \frac{\sum_{t=0}^{T} \texttt{CAM}(x^{t})}{\max \sum_{t=0}^{T} \texttt{CAM}(x^{t})}. \vspace{-0.5em} \end{align}\end{linenomath} \subsection{How Can Adversarial Climbing Improve CAMs?}\label{how_advcam} When adversarial climbing increases $y_c$, it also increases the pixel values in the CAM, \jmrv{as can be} inferred from the relationship between a classification logit $y_c$ and a CAM (\textit{i.e.} $y_c = \text{GAP}(\texttt{CAM})$~\cite{zhang2018adversarial}). Subsequently, we see from Eq.~\ref{cam} that an increase in the pixel values in the CAM will enhance some features. \rv{If it is to produce better localization, adversarial climbing must meet \rvt{the} following conditions:} (\RNum{1}) it enhances non-discriminative features, and (\RNum{2}) those features are class-relevant from a human point of view. We analyze these two aspects of adversarial climbing in the following sections. \subsubsection{How are non-discriminative features enhanced?} \label{nondisc_enahnce} As the DNN's receptive field grows with an increasing number of layers, a change to one pixel in an input image \rvt{propagates} to many intermediate features. \rv{This} propagation may affect both discriminative and non-discriminative features. \jmrv{Using the concept of strongly and weakly correlated features introduced by Tsipras \textit{et al.}~\cite{tsipras2018robustness} and Ilyas \textit{et al.}~\cite{ilyas2019adversarial}, we investigate how adversarial climbing can enhance non-discriminative features.} \rv{Individually, each} weakly correlated feature may be of little importance to the corresponding class, but an accumulation of such features can greatly influence \rv{the classification result}. It has been argued~\cite{tsipras2018robustness, ilyas2019adversarial} that an adversarial attack is made possible because a small change along the pixel gradient to an image changes many weakly correlated features to produce an erroneous classification. Because adversarial climbing is the reverse of an adversarial attack, it can also be expected to \rv{significantly influence weakly correlated} (or non-discriminative) features. We support this analysis empirically. We define the discriminative region $R_\text{D} \!=\! \{i|\texttt{CAM}(x^{0})_i\!\geq\!0.5\}$ and the non-discriminative region $R_{\text{ND}} \!=\! \{i|0.1\!<\!\texttt{CAM}(x^{0})_i\!<\!0.5\}$\footnote{\rv{We set the lower bound to 0.1 because this value was found to exclude most of the background, which should not be considered in this analysis.}}, where $i$ is the location index. The pixel amplification ratio $s^i_t$ is $\texttt{CAM}(x^{t})_i/\texttt{CAM}(x^{0})_i$ at location $i$ and step $t$. Fig.~\ref{fig_amp}(a) shows that adversarial climbing \rv{causes} both $s^{i \in {R_\text{D}}}_t$ and $s^{i \in {R_{\text{ND}}}}_t$ \rv{to} grow, but \rv{it also} enhances non-discriminative features more than discriminative ones, producing a descriptive CAM that identifies more regions of the target object. \input{Figures/figure_amplification} \subsubsection{Are these enhanced features class-relevant?} We now \rv{examine} whether the non-discriminative features identified by our technique are class-relevant from a human point of view. \jmrv{When} considering a loss landscape with respect to an input, Moosavi \textit{et al.}~\cite{moosavi2019robustness} argued that a sharply curved loss landscape makes the input vulnerable to an adversarial attack. Conversely, inputs that exist on a flat loss landscape are known~\cite{moosavi2019robustness, qin2019adversarial} to be robust against adversarial manipulations. And these robust inputs have also been shown to produce features that \jmrv{are better aligned} with human perception and are easier to understand~\cite{santurkar2019image, tsipras2018robustness, ilyas2019adversarial}. We can therefore expect that images manipulated by adversarial climbing will similarly produce features that \jmrv{are aligned} with human perception, because adversarial climbing drives the input towards a flatter \rv{region} of the loss landscape. We support this assertion \rv{by visualizing} the loss landscape of our trained classifier (Fig.~\ref{landscape}), following Moosavi \textit{et al.}~\cite{moosavi2019robustness}. We obtain a normal (manipulation) vector $\vec{n}$ from the classification loss $\ell$ computed from an image, and a random vector $\vec{r~}$. We then plot classification loss values computed from manipulated images using vectors \rvt{that} are interpolated between $\vec{n}$ and $\vec{r}$ using a range of interpolation ratios. Inputs perturbed by adversarial climbing (Fig.~\ref{landscape}(a)) lie on a flatter loss landscape than those perturbed by an adversarial attack (Fig.~\ref{landscape}(b)). Therefore, it is fair to expect that adversarial climbing will enhance the \rvt{class-relevant features} from the human viewpoint. \input{Figures/Figure_landscapes} \input{Figures/grad_sample} We provide further empirical evidence in support of this assertion. Fig.~\ref{grad_sample} shows saliency maps produced by a classifier from values of $|\nabla_{x^{t}} \texttt{NN}(x^{t}) / \max \nabla_{x^{t}} \texttt{NN}(x^{t})|$ at each iteration $t$. These maps show the regions of an image that were particularly influential in the classification~\cite{zeiler2014visualizing, simonyan2013deep}. When $t=0$, the gradients are very noisy, but as $t$ increases, the map identifies the target object more clearly. We infer that, as adversarial climbing progresses, the classifier increasingly focuses on the regions which are regarded as class-relevant from the human viewpoint. \subsection{Regularization}\label{reg_sec} \rv{If} adversarial climbing is \rv{performed to excess}, regions corresponding to objects \rv{in the wrong classes} may be activated, or the attribution scores of regions that already have high scores may be unintentionally increased. We address these issues by (\RNum{1}) suppressing the logits associated with classes other than the target class, and (\RNum{2}) restricting the attribution scores of discriminative regions, which already have high scores. \input{Figures/suppressing_reg} \textbf{Suppressing Other Classes:} Several objects of different classes in an image can simultaneously influence one another's \rv{logits}. Thus, even if adversarial climbing increases the logit of the target class, it can also \rv{\rvt{increase} the attribution scores of} regions \rvt{corresponding to} objects of other classes that frequently appear together \rv{with objects of the target class} in an image. For example, a chair and a dining table often \rv{appear} together in an image, and \rv{therefore}, increasing the logit \rv{of the} chair by adversarial climbing can cause regions corresponding to the dining table to be incorrectly identified (the blue boxes in Fig.~\ref{ex_supp_other_classes}). Therefore, we perform regularization to reduce \rv{the logits of all the classes} except the target class $c$\rv{; this regularization process} allows only the region corresponding to the target class to be activated, as shown in Fig.~\ref{ex_supp_other_classes}. \textbf{Restricting High Attributions:} As shown in Fig.~\ref{fig_amp}(a), adversarial climbing increases the attribution scores of both discriminative and non-discriminative regions \rv{in} the feature map. The excessive growth of attribution scores \rv{associated with} discriminative regions is problematic for two reasons: it prevents new regions from being attributed to the classification score; and, if \rv{the maximum attribution score} increases during adversarial climbing, the normalized scores of the remaining \rv{regions} \rv{are likely to} decrease (blue boxes in Fig.~\ref{mask_ex}(b)). Therefore, during adversarial climbing, we limit the growth \rvt{of} attribution scores in regions \rv{already with high scores}, so that the attribution scores of those regions remain similar to those of $x^{0}$. We realize this scheme by introducing a restricting mask $\mathcal{M}$ that contains the regions with attribution scores in $\texttt{CAM}(x^{t-1})$ that are higher than \rv{a} threshold $\tau$. The restricting mask $\mathcal{M}$ can be represented as follows: \begin{equation}\label{mask} \mathcal{M} = \mathbbm{1}(\texttt{CAM}(x^{t-1}) > \tau), \end{equation} where $\mathbbm{1}(\mathord{\cdot})$ is an indicator function. An example mask $\mathcal{M}$ is shown in Fig.~\ref{mask_ex}(a). We add a regularization term so that the values in $\texttt{CAM}(x^{t-1})$ \rv{which} correspond to the regions of $\mathcal{M}$ are forced to be equal to \rv{those of} same regions in $\texttt{CAM}(x^{0})$. This regularization keeps $s^{i \in {R_\text{D}}}_t$ fairly constant, but $s^{i \in {R_\text{ND}}}_t$ still grows during adversarial climbing (Fig.~\ref{fig_amp}(b)). Fig.~\ref{fig_amp} shows that adversarial climbing enhances non-discriminative features \rvt{rather} than discriminative features (by a factor of less than 2), and regularization magnifies this difference (to a factor of 2.5 or more). As a result, new regions of the target object are found more effectively, as shown in Fig.~\ref{mask_ex}(b). The two regularization terms introduced above modify Eq.~\ref{sgd} as follows: \vspace{-0.5em} \begin{equation}\label{sgd_reg} x^{t} = x^{t-1} + \xi \nabla_{x^{t-1}} \mathcal{L}, ~~\text{where} \end{equation} \begin{align}\label{reg_loss} \begin{split} \mathcal{L} = &~ y_c^{t-1} - \sum_{k \in \mathcal{C} \setminus c} y_k^{t-1} - \lambda \left\lVert \mathcal{M} \odot |\texttt{CAM}(x^{t-1}) - \texttt{CAM}(x^{0})|\right\lVert_1. \end{split} \end{align} $\mathcal{C}$ is the set of all classes, $\lambda$ is a hyper-parameter that controls the influence of the regularizing mask, and $\odot$ is element-wise multiplication. \input{Figures/figure_masking} \subsection{External saliency supervision}\label{method_sal} In weakly supervised semantic segmentation, we can optionally utilize a salient object detector~\cite{hou2017deeply, jiang2013salient, liu2019simple}, which provides boundary information about the salient objects in an image. Since it is difficult to obtain the exact boundary of the target object using \rv{\rvt{the} image label alone}, a salient object detector is very useful \rv{in} weakly supervised semantic segmentation. A salient object detector \rvt{that} works in a class-agnostic manner meets the basic assumptions of weakly supervised semantic segmentation. Many previous \rv{methods of} weakly supervised semantic segmentation~\cite{sun2020mining, lee2019ficklenet, lee2019frame, zhangsplitting, fan2018cian, fanemploying, wei2017object, wei2018revisiting} have used a salient object detector, but \rvt{its use has generally been limited} to the post-processing step, \rv{in which} explicit background cues \rv{are obtained}, and the initial seed \rv{is refined}. We seamlessly integrate a salient object detector \rv{into} adversarial climbing without significant modifications to our method. We use it to prevent excessive expansion of the CAM during adversarial climbing. With the integration of the salient object detector, Eq.~\ref{mask} is modified as: $\mathcal{M} = \mathbbm{1}(\texttt{CAM}(x^{t-1}) > \tau) \cup \mathcal{D}$, where $\mathcal{D}$ denotes the \rv{region} of an image identified as background by the salient object detector. This new $\mathcal{M}$ is then used in Eq.~\ref{reg_loss}. It restricts any \rvt{further} increase in the attribution scores of the region $\mathcal{D}$ during adversarial climbing, so that the \rv{attribution scores of regions} outside the object \rvt{do not increase}. \subsection{Weakly Supervised Semantic Segmentation}\label{train_segnet} \textbf{Generating pseudo ground truth:} Since a CAM is obtained from down-sampled intermediate features produced by the classifier, it localizes the target object coarsely and cannot represent its exact boundary. \rv{Therefore, many weakly supervised semantic segmentation methods~\cite{chang2020weakly, chang2020mixup, wang2020self, zhang2020causal, liu2020weakly} regard their localization map as \rv{an} initial seed, and construct pseudo ground truths by modifying their initial seeds using established \rv{refinement} methods~\cite{huang2018weakly, ahn2018learning, ahn2019weakly}.} Similarly, we obtain \rv{pseudo ground truths} by applying seed refinement to the coarse map $\mathcal{A}$. We can further refine the resulting pseudo ground \rv{truths} with a saliency map obtained from a salient object detector. When a foreground pixel in a pseudo label is marked as background on \rv{this saliency} map, or a background pixel is marked as foreground, we change the pseudo label of that pixel to `ambiguous'. Regions labeled as `ambiguous' are subsequently ignored in the training of the segmentation network. \textbf{Training segmentation networks:} In weakly supervised learning, we use the pseudo ground truth\rv{s obtained in the manner described above} for training DeepLab-v2, pre-trained on the \rvt{ImageNet-1K} dataset~\cite{deng2009imagenet}. For semi-supervised learning, we employ CCT~\cite{ouali2020semi}, which uses IRN~\cite{ahn2019weakly} to generate pseudo ground truth masks; we replace these with our masks, constructed as described above. \subsection{Weakly Supervised Object Localization}\label{wsol_method} Adversarial climbing can also be extended to weakly supervised object localization. \rv{This extension demonstrates the generality of our method in two aspects: 1) The datasets used for weakly supervised semantic segmentation and object localization differ significantly. The datasets used for weakly supervised object localization contain images intended for use in fine-grained classification (CUB-200-2011~\cite{wah2011caltech}) or images with 1,000 object classes (ImageNet-1K~\cite{deng2009imagenet}), which is far more diverse than that used for weakly supervised semantic segmentation, which usually involves between 20 or 80 classes. 2) It allows us to compare \rvt{the localization capability of our method against that of other recent weakly supervised object localization methods,} which share the same goal with us. } We apply \rv{adversarial} climbing to the baseline methods CAM~\cite{zhou2016learning} and CutMix~\cite{yun2019cutmix} because they use a vanilla classifier. We manipulate an input image by adversarial climbing and obtain $\mathcal{A}$, as described in Sections~\ref{Advcam_method} and \ref{reg_sec}. We do not use seed refinement or a salient object detector \rv{in this context} to \rv{allow for} a fair comparison with other methods. We then generate bounding boxes from $\mathcal{A}$, following Choe \textit{et al.}~\cite{choe2020evaluating}. For all \rv{the} hyper-parameters except $\lambda$, we use the same settings \rv{as those used for} adversarial climbing with weakly supervised semantic segmentation. The classifiers used in weakly supervised semantic segmentation and weakly supervised object localization are trained using different loss functions: sigmoid-based cross-entropy loss (multi-label classification) was used for the former, and softmax-based cross-entropy loss (single-label classification) for the latter. Since these two loss functions yield different distributions of classification logits, the value of $\lambda$ is adjusted for each task (but not between datasets). \section{Experiments on Semantic Segmentation} \subsection{Experimental Setup}\label{setup_sec} \textbf{Datasets:} We conducted experiments on the PASCAL VOC 2012~\cite{everingham2010pascal} and MS COCO 2014~\cite{lin2014microsoft} datasets. The images in these datasets come with masks for fully supervised semantic segmentation, but we only used these masks for evaluation. The PASCAL VOC dataset, as augmented by Hariharan \textit{et al.}~\cite{hariharan2011semantic}, contains 10,582 training images, depicting objects of 20 classes. In a weakly supervised setting, we trained our network on all 10,582 training images using their class labels. In a semi-supervised setting, we used 1,464 training images \rvt{that} have pixel-level annotations and the remaining 9,118 training images with \rv{their} class labels, following previous work~\cite{lee2019ficklenet, ouali2020semi, wei2018revisiting, luosemi}. The MS COCO 2014 dataset has 80K training images depicting objects of 80 classes. We evaluated our method on 1,449 validation images and 1,456 test images from \rv{PASCAL VOC 2012} and on 40,504 validation images from \rv{MS COCO 2014}, by calculating mean intersection-over-union (mIoU) values. \textbf{Reproducibility:} For both the \rv{PASCAL VOC 2012} and \rv{MS COCO 2014} datasets, we performed iterative adversarial climbing with $T=27$ and $\xi=0.008$. We set $\lambda$ to 7 and $\tau$ to 0.5. To generate the initial seed, we followed the procedure of Ahn \textit{et al.}~\cite{ahn2019weakly}, including the use of ResNet-50~\cite{he2016deep}. For final segmentation, we used DeepLab-v2-ResNet101~\cite{chen2017deeplab} as the backbone network. We used the default settings of DeepLab-v2~\cite{chen2017deeplab} in training \rv{with} the \rv{PASCAL VOC 2012} dataset. For the \rv{MS COCO 2014} dataset, we cropped the training images to 481$\times$481 pixels, rather than 321$\times$321, \rv{to make better use of the larger images in this dataset}. We used \rv{the} salient object detector provided by Hou \textit{et al.}~\cite{hou2017deeply}, following previous work~\cite{li2020group, yao2021nonsalient}. In a semi-supervised setting, we used the same \rv{setup} as Ouali \textit{et al.}~\cite{ouali2020semi}, including the ResNet-50 backbone. \rv{This does not include a \rvt{salient} object detector.} \input{Figures/coco_cam_samples} \input{Tables/table_seed} \input{Tables/table_coco_seed} \subsection{Quality of the Initial Seed}\label{initialseedexp} \textbf{Results on \rv{PASCAL VOC 2012}.} Table~\ref{table_seed} compares, in terms of mIoU, the initial seed and pseudo ground truth masks obtained by our method and by other recent techniques. Both seeds and masks were generated from training images from the \rv{PASCAL VOC 2012} dataset. We determined the best initial seeds by applying a range of thresholds to separate the foreground and background in the map $\mathcal{A}$, following SEAM~\cite{wang2020self}. Our initial seeds are 6.8\%p better than \rv{the baseline provided by} the original CAMs~\cite{zhou2016learning}, and our seeds outperform those produced by other methods. In particular, we obtained better initial seeds than SEAM~\cite{wang2020self}, which uses an auxiliary self-attention module to perform pixel-level refinement of the initial CAM by considering the relationship between pixels. \input{Tables/table_weak_sem_pascal} \input{Tables/table_res2net} We applied a post-processing method for pixel refinement, based on a CRF, to the initial seeds produced by the method of Chang \textit{et al.}~\cite{chang2020weakly}, SEAM~\cite{wang2020self}, IRN~\cite{ahn2019weakly}, and our method. CRF improved the seeds by more than 5\%p on average, except for the seeds from SEAM, which \rvt{is} only improved by 1.4\%p: we believe \rv{that} this is because the seed from SEAM had already been refined by the self-attention module. After applying CRF, the seed produced by our method is 5.3\%p better than that from SEAM. We also compared the pseudo ground truth masks extracted after seed refinement, with the masks produced by other methods, most of which refine their initial seeds with PSA~\cite{ahn2018learning} or IRN~\cite{ahn2019weakly}. For a fair comparison, we produced pseudo ground truth masks using both of these seed refinement techniques. Table~\ref{table_seed} shows that our method outperforms the others by a large margin, independent of the seed refinement technique. Finally, we assessed the quality of the initial seed and the pseudo ground truth mask obtained using the salient object detector introduced in Section~\ref{method_sal}\footnote{\rv{The results are obtained from the pseudo ground truths before introducing the ambiguous regions mentioned in Section~\ref{train_segnet}.}}. Table~\ref{table_seed} shows that this improved the initial seed and the pseudo ground truth mask by 5.2\%p and 2.4\%p respectively. \rv{In addition, our method obtains better pseudo ground truth masks than EPS~\cite{lee2021railroad}, a recently introduced method \rvt{that} is considered to be state-of-the-art.} \input{Figures/figure_seg_samples} \input{Figures/figure_sag_samples_coco} \textbf{Results on \rv{MS COCO 2014}.} For \rv{MS COCO 2014} experiments, we implemented IRN~\cite{ahn2019weakly} using the official code. Since the results from IRN reported by Zhang \textit{et al.}~\cite{zhang2020causal} differ from \rv{those} that we obtained, we \rvt{compared} relative improvements. Table~\ref{coco_seed_table} shows that our method improved the initial seed and pseudo ground truth masks by 3.7\%p and 3.1\%p respectively compared to IRN, while CONTA~\cite{zhang2020causal} \rv{improved them by} 1.3\%p and 1.2\%p respectively. \rv{Fig.~\ref{cococamsamples} shows examples of the final localization maps obtained from the CAM and our method for MS COCO 2014 training images. These examples demonstrate that our method successfully \rv{identifies} more exact regions of the target object. For small objects (\textit{e.g.,} `fork' and `handbag' examples), the CAM~\cite{zhou2016learning} tends to mistakenly activate some \rv{regions} of the background, while our method mainly focuses on the \rv{region} corresponding to the target object. For large objects, the CAM~\cite{zhou2016learning} is not able to \rv{identify all} of the target object, but our method can encompass them. In short, our method obtains high-precision results for small objects and high-recall results for large objects. For a more detailed analysis and discussion, please refer to Section~\ref{classwise_analysis}. } \subsection{Weakly Supervised Semantic Segmentation} \textbf{Results on \rv{PASCAL VOC 2012}.} Table~\ref{table_semantic} compares our method with other recently introduced weakly supervised semantic segmentation methods with various levels of supervision: fully supervised pixel-level masks \rv{($\mathcal{F}$)}, bounding boxes ($\mathcal{B}$) and image class labels ($\mathcal{I}$), with and without salient object masks ($\mathcal{S}$). All the results in Table~\ref{table_semantic} were obtained using a ResNet-based backbone~\cite{he2016deep}. The results for the test images were obtained from the official \rv{PASCAL VOC 2012} evaluation server. With image-level annotation alone, our method achieved mIoU values of 68.1 and 68.0 for the PASCAL VOC 2012 validation and test images respectively. This is significantly better than the other methods under the same level of supervision. In particular, the mIoU value for validation images was 4.6\%p higher than that achieved by IRN~\cite{ahn2019weakly}, which is our baseline. CONTA~\cite{zhang2020causal} performed best among our competitors, and achieved an mIoU value of 66.1; but CONTA uses SEAM~\cite{wang2020self}, which is known to outperform IRN~\cite{ahn2019weakly}. \rv{When CONTA is used in \rvt{conjunction} with IRN, it yields the mIoU value of 65.3, which is 2.8\%p worse than our method.} Fig.~\ref{segsample} shows examples of semantic masks produced by FickleNet~\cite{lee2019ficklenet}, IRN~\cite{ahn2019weakly}, and our method. \rv{These examples suggest that our method tends to capture the extent of the target object more exactly than previous methods. In addition, our method seldom misses a target object even in a complicated scene (\textit{e.g.,} the cow in the second row). More examples are presented in the Appendix.} \rv{Even when our method was implemented only with class labels,} it outperformed other methods with auxiliary salient object mask supervision and those that require extra web images or videos~\cite{sun2020mining, lee2019frame}, except Li \textit{et al.}~\cite{li2020group} and Yao \textit{et al.}~\cite{yao2021nonsalient}, \rv{which are contemporaries of our method.} When we used saliency information, our segmentation results on the \rv{PASCAL VOC 2012} validation and test images were significantly better than those of Li \textit{et al.}~\cite{li2020group} and Yao \textit{et al.}~\cite{yao2021nonsalient}. The performance of our method is also comparable to that of methods~\cite{song2019box, khoreva2017simple, lee2021bbam} based on bounding box supervision. \rv{Table~\ref{res2net_result} compares our method with other recently introduced methods using Res2Net-based backbones~\cite{gao2019res2net}. Our method achieved \rv{an} mIoU value of 72.0 for the PASCAL VOC 2012 validation images, which is significantly better than that of the other methods under the same level of supervision \textit{i.e.,} image-class labels and saliency supervision. When \rv{the} more powerful Res2Net-152~\cite{gao2019res2net} is used, the performance of our method is further improved to 73.0 mIoU.} \textbf{Results on \rv{MS COCO 2014}.} Table~\ref{table_semantic_coco} compares weakly supervised semantic segmentation results from our method on the \rv{MS COCO 2014} dataset with \rvt{the results} from other recently introduced methods. Our method achieved an mIoU of 44.4 for the \rv{MS COCO 2014} validation images, which is significantly better than the mIoUs from the other methods. In particular, our method was 3.0\%p better than IRN~\cite{ahn2019weakly}, which is our baseline. Fig.~\ref{segsample_coco} shows examples of predicted semantic masks for \rv{MS COCO 2014} validation images produced by IRN~\cite{ahn2019weakly} and by our method. \rv{Because our initial seed covers the target object more precisely, it captures regions of the target object that IRN does not, leading to a more accurate boundary. The last column of Fig.~\ref{segsample_coco} shows an example of the well-known class bias problem~\cite{li2019guided}, which is still largely open. The baseball player and the glove usually occur together, and as a result, the body of the player is sometimes mistakenly recognized as a glove. Nonetheless, we observe that our method is capable of partially addressing the class bias problem by suppressing the other classes through regularization. } \input{Tables/table_coco} \subsection{Semi-Supervised Semantic Segmentation} Table~\ref{tabsemi} compares the mIoU scores achieved by our method on the \rv{PASCAL VOC 2012} validation and test images with those from other recent semi-supervised segmentation methods. All \rvt{of} these methods were implemented on the ResNet-based backbone~\cite{he2016deep}, except for the first four, which used the VGG-based backbone~\cite{simonyan2014very}. Our method achieved mIoU scores of 77.8 and 76.9 on the PASCAL VOC 2012 validation and test images respectively, which are higher than those of the other methods under the same level of supervision. \rv{These methods include PseudoSeg~\cite{zou2020pseudoseg} and Lai \textit{et al.}~\cite{Lai2021semi}, which are contemporary with our method.} In particular, the performance of our method on the validation images was 4.6\%p better than that of CCT~\cite{ouali2020semi}, which is our baseline. Our method even outperformed the method of Song \textit{et al.}~\cite{song2019box}, which uses bounding box labels, which are stronger annotations than class labels. Fig.~\ref{segsample} compares examples of semantic masks produced by CCT~\cite{ouali2020semi} and by our method, \rv{which shows that our method captures the regions occupied by the target object more accurately than CCT~\cite{ouali2020semi}.} \section{Experiments on Object Localization} \subsection{Experimental Setup} \textbf{Datasets:} For weakly supervised object localization, we used the CUB-200-2011~\cite{wah2011caltech} and ImageNet-1K~\cite{deng2009imagenet} datasets. The CUB-200-2011 dataset contains 6,033 training images and 5,755 test images. \rv{These images depict birds of 200 species, and each species is a class.} The ImageNet-1K dataset contains about 1.3M training images and 50,000 test images, \rv{depicting} 1000 classes of everyday objects. For both datasets, we determine the model and hyper-parameters with validation images provided by Choe \textit{et al.}~\cite{choe2020evaluating}, and report Top-1 classification accuracy, Top-1 localization accuracy, and \texttt{MaxBoxAccV2}~\cite{choe2020evaluation} for a range of IoU thresholds on test images. Note that \texttt{MaxBoxAccV2} at an IoU threshold of 0.5 is equivalent to the GT-known localization accuracy. \textbf{Reproducibility:} We set the value of $\lambda$ to 0.01 for both datasets. We used the ResNet-50~\cite{he2016deep} \rv{and Inception-V3~\cite{szegedy2016rethinking} backbone networks} pre-trained on the ImageNet dataset. \input{Tables/table_semi} \input{Tables/wsol_sota} \input{Figures/figure_wsol_cub} \subsection{Experimental Results} \textbf{Results on CUB-200-2011.} Table~\ref{table_wsol} compares results \rv{from} our method and \rv{from} existing methods on the CUB-200-2011~\cite{wah2011caltech} dataset, \rv{using a ResNet-50~\cite{he2016deep} backbone.} Our method achieves a 7.3\%p improvement in Top-1 localization accuracy over CutMix~\cite{yun2019cutmix}, which is our baseline, \rvt{while maintaining the} same classification accuracy. In addition, the \texttt{MaxBoxAccV2} scores for IoU thresholds of 0.5 and 0.7 increase by 9.9\%p and 9.1\%p respectively, indicating that adversarial climbing produces more exact bounding boxes. Table~\ref{table_wsol} shows that our method also yields significantly better results than those \rv{from} other recently published methods. Since adversarial climbing can be performed on any differentiable model, we expect our method to be applicable to methods other than CAM and CutMix without sacrificing classification accuracy. \rv{In addition, we compare \texttt{MaxBoxAccV2}~\cite{choe2020evaluation} scores obtained by the above methods using the Inception-V3~\cite{szegedy2016rethinking} backbone. Table~\ref{table_inception_wsol} shows that this improves the \texttt{MaxBoxAccV2} scores for IoU thresholds of 0.5 and 0.7 by over 10\%p, compared to our CutMix baseline~\cite{yun2019cutmix}. Table~\ref{table_inception_wsol} also shows that our method outperforms even the most recent methods by a large margin. In particular, the \texttt{MaxBoxAccV2} score is 3.7\%p higher than that of IVR~\cite{kim2021normalization}, the best-performing method among our competitors. } \textbf{Results on ImageNet-1K.} Table~\ref{table_wsol} compares results \rv{from} our method and \rv{from} existing methods on the ImageNet-1K dataset~\cite{deng2009imagenet}, \rv{using a ResNet-50~\cite{he2016deep} backbone.} Our method achieved a new state-of-the-art performance on the ImageNet-1K dataset, with a 3.1\%p increase in Top-1 localization accuracy and a 4.4\%p increase in \texttt{MaxBoxAccV2}, \rv{compared to our CAM baseline~\cite{zhou2016learning}.} Fig.~\ref{wsol_sample_cub_imagenet} shows examples of localization maps and bounding boxes generated by CutMix~\cite{yun2019cutmix} and by our method, on the CUB-200-2011 and ImageNet-1K datasets. We see that the more accurate masks provided by adversarial climbing lead to more accurate bounding boxes. \input{Figures/figure_each_iter} \input{Figures/figure_each_iter_examples} \section{Discussion} \subsection{Iterative Adversarial Climbing}\label{iterative} We analyzed the effectiveness of the iterative adversarial climbing and regularization technique introduced in Section~\ref{reg_sec} by evaluating the initial seed for each adversarial iteration using images from the \rv{PASCAL VOC 2012} dataset. Fig.~\ref{eachiter}(a) shows the resulting mIoU scores: they rise steeply in the beginning, with or without regularization, but without regularization, the curves peak around iteration 8. \rv{To take a closer look at this observation}, we evaluated the quality of the newly localized region at each \rv{iteration of} adversarial climbing in terms of the proportion of noise, which we define to be the proportion of pixels that \rvt{are classified as the foreground but actually belong in the background.} Without regularization, the proportion of noise rises steeply after around 15 iterations, as shown in Fig.~\ref{eachiter}(b): \rv{this implies that the new regions identified in subsequent iterations belong mostly in \rvt{the} background.} Regularization \rv{brings the proportion of noise below that in the original CAM,} indicating that new regions of the target object are \rv{still} being found \rv{during} as many as 30 adversarial \rvt{iterations}. We also see that employing a salient object detector during adversarial climbing provides a better initial seed in terms of mIoU and \rvt{the} proportion of noise. Fig.~\ref{adv_climb_ex_voc} shows \rv{examples of localization maps} at each adversarial iteration with and without regularization. \rv{As adversarial climbing proceeds, the localization maps gradually cover more of the target object, whether there is regularization or not.} \rv{However, without regularization, some regions of a target object (\textit{e.g.,} the legs of a dog) \rvt{may} have greatly raised attribution scores, and thus the other regions corresponding to the target object (\textit{e.g., }the dog's head) are suppressed by \rvt{the} normalization effect. Regularization allows the target object to be activated evenly, without over-activation on specific parts.} We will now look at the effectiveness of adversarial climbing and regularization in weakly supervised object localization on the CUB-200-2011 dataset. We obtained localization results from CutMix~\cite{yun2019cutmix}\rv{, and then} applied adversarial climbing and the \rv{proposed regularization technique}. Table~\ref{ablation_wsol} shows that adversarial climbing improved both the Top-1 localization accuracy and the \texttt{MaxBoxAccV2} scores, and that regularization \rvt{further improved both of} them. \rv{The improvement to the} \texttt{MaxBoxAccV2} scores is particularly noticeable at high IoU thresholds, \rv{showing that the bounding boxes produced by our method are closer approximations to the ground-truth boxes.} As we have already noted, our method is a post-hoc analysis of a trained classifier, so its classification results are not affected. \subsection{Hyper-Parameter Analysis}\label{hyperparam} Having looked at the effect of the number of adversarial iterations (Figs.~\ref{eachiter}(a) and (b)), we now analyze the sensitivity of the mIoU of the initial seed to the other three hyper-parameters involved in adversarial climbing. All the results reported in this section were obtained without using a salient object detector to focus on the sensitivity of adversarial climbing to each hyper-parameter. \input{Tables/table_wsol_inception} \textbf{Regularization Coefficient $\boldsymbol{\lambda}$:} Eq.~\ref{reg_loss} shows how $\lambda$ controls the strength of the regularization that limits the extent to which adversarial climbing can increase the attribution scores of regions that already have high scores. Fig.~\ref{eachiter}(c) shows the mIoU of the initial seed for different values of $\lambda$. Regularization improves the quality of initial seeds by more than 5\%p (50.43 for $\lambda=0$, when there is no regularization, \textit{vs.} 55.55 for $\lambda=7$). The curve \rvt{plateaus} after $\lambda=5$, suggesting that it is not difficult to select a good value of $\lambda$. \textbf{Masking Threshold $\boldsymbol{\tau}$}: By controlling the size of the restricting mask $\mathcal{M}$ in Eq.~\ref{mask}, \rv{the hyper-parameter} $\tau$ determines how many pixels \rv{will retain} attribution values \rvt{similar} to those of the original CAM during adversarial climbing. Fig.~\ref{eachiter}(d) shows the mIoU of the initial seed for different values of $\tau$. We can see that $\tau$ influences the quality of the initial seeds less than $\lambda$: varying $\tau$ from 0.3 to 0.7 produces a change of less than 1\%p in mIoU. Again, it should be straightforward to select a good value of $\tau$. \input{Tables/table_figure_failure_together} \textbf{Step Size $\boldsymbol{\xi}$}: This determines the extent of the adversarial manipulation of the image in Eq.~\ref{sgd_reg}. Fig.~\ref{eachiter}(e) shows the mIoU of the initial seed for different values of $\xi$. A broad range of step sizes are satisfactory. \input{Tables/ablation_wsol} \input{Tables/table_finalloc_design} \input{Tables/table_pseudo_gt} \subsection{\rv{Design Choice of the Final Localization Map $\mathcal{A}$}}\label{finalmap} \rv{We analyze the effects of the design choice of the final localization map $\mathcal{A}$. As mentioned in Section~\ref{Advcam_method}, we compute the final localization map by aggregating the CAMs produced during all the adversarial climbing iterations ($\mathcal{A} = \sum_{t=0}^{T} \texttt{CAM}(x^{t})$) to suppress the noise that occurs in the later iterations. Alternatively, a final localization map could be obtained just from the CAM produced during \rvt{the last} adversarial climbing iteration ($\mathcal{A} = \texttt{CAM}(x^{T})$). Table~\ref{design_choice_table} compares the mIoU, precision, recall, and F1-score values that result from each method of computing the final localization map. The final localization map computed from $\texttt{CAM}(x^{T})$ alone achieves high recall but very low precision, indicating that a lot of \rvt{the} background is receiving a high attribution score. Aggregating CAMs over adversarial climbing iterations ($\mathcal{A} = \sum_{t=0}^{T} \texttt{CAM}(x^{t})$) achieves much higher precision while maintaining recall; this demonstrates that the aggregation process largely prevents background regions from being identified. } \subsection{Generality of Our Method}\label{generality} Most of our experiments with adversarial climbing were based on IRN~\cite{ahn2019weakly}. However, we also applied adversarial climbing to two state-of-the-art methods of generating an initial seed for weakly supervised semantic segmentation: that \rvt{of} Chang \textit{et al.}~\cite{chang2020weakly}, and SEAM~\cite{wang2020self}. We used \rv{the} pre-trained classifiers provided by Chang \textit{et al.} and the authors of SEAM. However, we had to train IRN's classifier since the authors~\cite{ahn2019weakly} do not provide a pre-trained one. We also followed the authors' experimental settings, including their choice of \rvt{the} backbone network and \rvt{the} mask refinement method. Thus, we used PSA~\cite{ahn2018learning} to refine the initial seed \rv{obtained} from the method of Chang \textit{et al.} and from SEAM, when these were combined with adversarial climbing. Table~\ref{tab:baselines} \rvt{provides} mIoU values for the initial seed and the pseudo ground truth mask obtained when each method was combined with adversarial climbing, which was found to improve the quality of the initial seed by more than 4\%p on average. Our approach does not require initial seed generators to be modified or retrained. We also thought that it would be appropriate to assess the effect of adversarial climbing on attribution methods other than the CAM~\cite{zhou2016learning}. We experimented with Grad-CAM++~\cite{chattopadhay2018grad} because Grad-CAM~\cite{selvaraju2017grad} is essentially \rv{equivalent to} CAM for ResNet~\cite{he2016deep}. Adversarial climbing improved the results from Grad-CAM++ by 3\%p, as shown in Table~\ref{tab:baselines}. \input{Figures/per_class_gain} \input{Tables/table_size_precisionrecall_coco} \subsection{\rv{Analysis of Failure Cases}} \rv{In this section, we analyze the cases where our method did not work properly. Fig.~\ref{fig_failure} presents some common examples of failures \rvt{within} each dataset. Objects that are not part of the target class but are related to that class (\textit{e.g.,} train and rail in Fig.~\ref{fig_failure}(a) or toilet and sink in Fig.~\ref{fig_failure}(b)) can be also activated by adversarial climbing, which will reduce precision. This is a long-standing problem that commonly occurs in other recent methods as well. To analyze this quantitatively, we compare the precision, recall, and F1-score of our method with those of the other methods in Table~\ref{table_precrecall}. Chang \textit{et al.}~\cite{chang2020weakly} achieve high recall, at the cost of a large drop in precision. SEAM~\cite{wang2020self} avoids this loss of precision through pixel-level refinement using an additional module mentioned in Section~\ref{initialseedexp}. Our method achieves better recall and precision without an external module. AdvCAM--Sal further improves precision with the help of auxiliary salient object mask supervision. We also provide some examples of failures in weakly supervised object localization in Figs.~\ref{fig_failure}(c) and (d). Again, parts of the background are sometimes activated together with the foreground (Fig.~\ref{fig_failure}(c)). When several objects of the target class appear in an image from the ImageNet-1K dataset, only one of them is labeled with a bounding box (see the blue box in Fig.~\ref{fig_failure}(d)). If adversarial climbing appropriately identifies all the target class regions in an image, then the IoU between the predicted box and the box label can actually be reduced, even though AdvCAM has appropriately identified all the target class regions. } \input{Figures/cub_bg_suppress} \input{Figures/figure_tsne} \subsection{\rv{Analysis of Results by Class}}\label{classwise_analysis} \rv{The objects in the images in the \rv{MS COCO 2014} dataset are of various classes with various object sizes. We will now discuss the degree of improvement in the initial seed for each object class. Fig.~\ref{perclassgain} shows the improvement in mIoU produced by adversarial climbing over the initial seed for each class. The classes are listed in ascending order \rvt{according to} the average size of the target objects in each class (smallest $\rightarrow$ largest). Adversarial climbing improves mIoU values for the majority of classes, regardless of their average object size. When considering specific classes, we observed a large drop in the seed quality for the `dining table' class, which is anomalous. We believe that this is due to the ambiguity of the ground truth label of the `dining table'. In \rvt{the MS COCO 2014 dataset}, the `dining table' label includes all the items on the table. The suppression of other classes by the regularization prevents objects such as bowls and bottles on the table from being identified as part of a `dining table', resulting in a localization map that does not entirely match the ground truth. To take a closer look at how adversarial climbing affects the performance of each class with various object sizes, we \rvt{report} precision, recall, and F1-score values averaged across all classes, the classes corresponding to the 10 smallest objects, and the classes corresponding to the 10 largest objects in Table~\ref{tab_size_pr}. Our method improves precision, recall, and F1-score of the initial seed, averaged across all classes. Recall was slightly reduced (-12\%) for the classes corresponding to the 10 smallest objects, but precision increased significantly (67\%), resulting in \rvt{a} largely improved F1-score. This indicates that, for small objects, adversarial climbing effectively suppresses unwanted high attribution scores in the background, as can be seen in the `fork' and `handbag' examples in Fig.~\ref{cococamsamples}. We believe that there are two causes \rvt{of} these improved results on small objects: 1) During adversarial climbing, the logits associated with classes other than the target are reduced, as described in Section 4.3, and thus patterns which are irrelevant to the target class are effectively suppressed; and 2) since adversarial climbing increases the scores of regions relevant to the target class, the scores of background regions are suppressed due to normalization. \rvt{Interestingly}, the latter effect is also observed with larger objects. Fig.~\ref{fig_bg_suppress} shows two examples in which adversarial climbing suppresses background regions of images from the CUB-200-2011~\cite{wah2011caltech} dataset. Even when the target object is relatively large, we see that the (normalized) attribution score of the background is suppressed as that of the target object is increased. \jmrv{Fig.~\ref{fig_bg_suppress} shows distributions of attribution scores of each pixel for an AdvCAM and CAM, which are sorted in decreasing order. Adversarial climbing widens the gap between the scores of the highly activated regions and those of the remaining regions, which will make the attribution scores of \rvt{the} background reduced after normalization.} Adversarial climbing improves both precision and recall for large objects, but recall increases by a much larger margin. This indicates that adversarial climbing effectively raises the attribution scores of regions of target objects that had not previously been identified. These observations support our arguments described in Section~\ref{initialseedexp}, namely that our method \rvt{improves} precision for small objects and recall for large objects. We will now look at how the hyper-parameters interact with the object size. Table~\ref{tab_size_pr} shows the precision, recall, and F1-score values obtained using different values of $T$ and $\tau$. Across all classes, neither $T$ nor $\tau$ had a significant influence, which accords with the results presented in Section~\ref{hyperparam}. Looking at the 10 classes containing the largest target objects, we see a similar picture. However, the 10 classes containing the smallest objects seem to be a little more sensitive to the values of the hyper-parameters, but not sufficiently to be a cause for concern. } \subsection{Manifold Visualization} The trajectory of adversarial climbing can be visualized at the feature level \rv{by} using t-SNE~\cite{maaten2008visualizing} to reduce the dimensionality of each feature. We assembled a set of images that contain a single object, which is recognized as a `cat' or a `bird' by the classifier. We then constructed a set $\mathcal{F}$ containing the features extracted from those images before the final classification layer. \rv{Next,} we chose a representative image from each class, and constructed a set $\mathcal{F}~'$ containing the features of those two images together with the features of the 20 versions of each image that resulted from successive manipulations by adversarial climbing. Fig.~\ref{fig_tsne} shows the features in $\mathcal{F} \cup \mathcal{F}~'$, after dimensional reduction by t-SNE. We can see that adversarial climbing pushes the features away from the decision boundary that separates the two classes, without causing them to deviate significantly from the feature manifold of their class, even after 20 steps of adversarial climbing. \section{Conclusions} We have proposed adversarial climbing, a novel manipulation method to improve localization of a target object by identifying whole regions of the target object from class labels. An image is perturbed along the pixel gradients of the classifier's output for that image, in a direction that increases the classification score, resulting in \rv{an} attribution map of the manipulated image \rv{that} includes more of the target object. Because adversarial climbing is a post-hoc analysis of the output of a trained classifier, no modification or re-training of the classifier is required. Therefore, adversarial climbing can be readily combined with existing methods. We have shown that an AdvCAM, the attribution map generated from adversarial climbing, can indeed be combined with recently developed networks for weakly supervised semantic segmentation and object localization. The resulting hybrids achieved a new state-of-the-art performance on both weakly and semi-supervised semantic segmentation. In addition, the use of adversarial climbing yielded a new state-of-the-art performance on weakly supervised object localization. \bigskip \vspace{-0.5em} \noindent\textbf{Acknowledgements:} This work was supported by Institute of Information \& communications Technology Planning \& Evaluation (IITP) grant funded by the Korea government (MSIT) [NO.2021-0-01343, Artificial Intelligence Graduate School Program (Seoul National University)], AIRS Company in Hyundai Motor and Kia through HMC/KIA-SNU AI Consortium Fund, and the BK21 FOUR program of the Education and Research Program for Future ICT Pioneers, Seoul National University in 2022. \ifCLASSOPTIONcaptionsoff \newpage \fi { \footnotesize \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:33:14', 'yymm': '2204', 'arxiv_id': '2204.04890', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04890'}
arxiv
\section{Introduction} Unmanned Aerial Vehicles (UAVs) are increasingly being sought in applications such as surveillance, environmental monitoring, and agriculture due to their ability to monitor large areas in a short period of time. {One bottleneck in practice that limits their application is the limited battery capacity, especially for multi-rotor UAVs. One way to overcome this bottleneck is to use a team of aerial and ground vehicles for such tasks, in which the UGV can work as a mobile recharging station and will recharge the UAV during long-range operations. The key to achieving such cooperation on the decision-making level is to design efficient routing algorithms that can tell robots \textit{which task node to visit next}, and \textit{when and where the UAV should be recharged}. Moreover, the rate of battery discharge of a UAV is stochastic in the real world. The routing algorithm should be able to deal with such uncertainties, e.g., trade off task performance with failure risks.} {In this paper, we consider the cooperative routing problem with a team of a single UGV that can work as a mobile charger and a single energy-constrained UAV, in which the UAV and UGV need to complete a task by visiting task nodes distributed throughout the task area. The UGV can only move on the road network but the can directly fly between any pair of nodes (assuming it has enough charge). Given the task nodes to visit and the stochastic energy consumption model of the UAV, we are interested in finding a routing strategy for the UAV and the UGV such that the expected time to finish the task is minimized and the probability of running out of charge less than a user-defined tolerance. Such problems can be formulated within the stochastic programming (SP) framework \cite{du2020cooperative}. However, since we need to consider not only routes but also recharge decisions and chance constraints, SP-based formulation would involve too many variables, rendering the formulation only solvable for very small instances.} \begin{figure} \centering \includegraphics[scale=0.65]{figures/rendezvous.pdf} \caption{An illustrative example of the rendezvous problem considered in this paper. When the UAV and UGV are executing tasks, they need to decide when and where to rendezvous to replenish the battery of the UAV while minimizing the travel time of the UAV and satisfying the risk constraint induced by stochastic energy consumption. When they need to rendezvous, they will deviate from their task and meet at a chosen rendezvous location.} \label{fig:illustrative_example} \end{figure} {In this paper, we propose to find the routing strategy in two decoupled phases. In the first phase, a higher-level planner finds deterministic routes for the UAV and the UGV without considering stochasticity in energy consumption based on the task requirement. In the second phase, a risk-aware planner will refine the routes generated from the previous phase to find when and where to rendezvous to satisfy the chance constraint while minimizing the time to finish the UAV task\footnote{We focus on minimizing the time taken for the UAV task instead of the total time which would be the maximum of the UAV and UGV travel times. If the UGV task takes longer than the UAV, then once the UAV's task is done, the UGV simply executes the remaining portion of its route. Therefore, optimizing the UAV time is appropriate. Furthermore, In many applications \cite{yu2018algorithms}, the UGV's task is to simply act as a mobile recharging station}. Our focus in this paper is mainly on the second phase. We formulate our risk-aware refinement as a CMDP, in which the chance constraint is modeled as the secondary cost in the constraint. To the best of our knowledge, this is the first CMDP-based formulation for the UAV-UGV routing problems under energy consumption uncertainty. We use Linear Programming (LP) to find the optimal stationary policy. We validate our formulation and the solution in an Intelligence Surveillance and Reconnaissance (ISR) mission.} { The main contributions of this paper are: \begin{itemize} \item We show how to formulate the stochastic cooperative UAV and UGV rendezvous problem with energy constraint as a CMDP and use LP to solve the problem optimally in polynomial time. \item Demonstrate the effectiveness of the formulation and the solution using realistic models that are obtained using field data. \end{itemize} } The rest of this paper is organized as follows. We first give a brief overview of the related work in Section \ref{sec:rel_wrk}. Then we discuss the general problem definition along with its mathematical formulation as a Chance-Constrained Markov Decision Process (CCMDP) in Section \ref{sec:prb_frml}. Next in Section \ref{sec:sol}, we discuss the solution to this problem as an LP instance. Finally, we present the results from numerical simulations in Section \ref{section:numerical simulation} with conclusions in Section \ref{section:conclusion}. \section{Related Work} \label{sec:rel_wrk} The routing of energy-constrained UAVs with stationary recharging stations or assistive UGVs has been studied extensively \cite{otto2018optimization, li2021ground, choudhury2021efficient, maini2018persistent}. Even with deterministic environmental changes or stationary conditions, this problem can be reduced to the Traveling Salesman Problem (TSP), \cite{yu2019coverage, mathew2015planning} making it an NP-hard problem. The cooperative UAV and UGV routing problem has been studied from different perspectives and thus received various formulations in the literature. It is most commonly formulated as a type of vehicle routing problem. Manyam et al.~\cite{manyam2019cooperative} use a team of one UAV and one UGV with communication constraints to cooperatively visit targets. Along with an exact solver to Mixed Integer Linear Programming (MILP) formulation, they also provide heuristic reduction to the generalized traveling salesman problem (GTSP). Maini et al. \cite{maini2019cooperative} present a two-fold strategy: first, they identify feasible rendezvous points, then they formulate a MILP to find the optimal routes for the UAV and UGV. Thayer et al.~\cite{thayer2021adaptive} present a solution to the Stochastic Orienteering Problem, where the objective is to maximize the sum of rewards associated with each visited node while constrained by the maximum budget over edges with stochastic cost. Murray and Chu~\cite{murray2015flying} introduced the flying sidekick TSP (FSTSP) for parcel delivery systems, which was later adopted in last-mile delivery applications using drones~\cite{agatz2018optimization, ha2018min}. In literature, the term multi-echelon scheme is often used for systems where delivery consists of multiple layers. Specifically, the two-echelon vehicle routing problem (2E-VRP) is concerned with finding minimal cost routes to deliver packages with trucks/UGVs and drones~\cite{li2021ground, liu2019cooperative}. An important differentiation from the original vehicle routing problem is the synchronization of UAV and UGV tasks. Learning-based approaches have been used to address cooperative UAV and UGV routing problems. Ermugan et al.~\cite{ermaugan2022learning} also propose a two-phase approach. First, they find a route for UAVs without taking into account the energy constraints. Then, the planner learns to insert into the route recharging stations and replans a new TSP route. Reinforcement learning has also proven to be a possible approach to solving this problem \cite{wu2021reinforcement}. In our previous work, we studied cooperative planning with a single UGV and an energy-constrained UAV as well~\cite{tokekar2016sensor, yu2018algorithms, yu2019coverage}. Our proposed approach in~\cite{tokekar2016sensor} demonstrated how to maximize the number of sites visited in a single charge in conjunction with the ability to land a UAV on top of a UGV to be transported to the next take-off site. We extended this in~\cite{yu2018algorithms} to allow the UAV to also be recharged while either being transported or stationary on the UGV\@. We extended the latter to the area coverage path planning problem by formulating it as a GTSP~\cite{yu2019coverage}. Here, we extend this body of work by introducing the stochasticity of the UAV’s energy consumption and by assuming that the UGV has its own required set of tasks to be carried out. To the best of our knowledge and based on the presented literature review, none of the works takes into account the stochastic nature of energy consumption. \section{Problem Formulation} \label{sec:prb_frml} The cooperative routing problem studied in this paper involves one UAV and one UGV\@. The UAV and the UGV are executing tasks, which are given by some task planners as shown in Section \ref{subsection: UAV_task_planning}. The UAV needs to visit a sequence of task nodes in order to finish the task, but its battery may not be enough for it to finish the task in a single flight without recharging. Also, the energy consumption of the UAV is stochastic. The UAV needs to decide \textit{when} and \textit{where} it should rendezvous with the UGV to replenish the battery while minimizing the total travel time to finish the task. When the UAV decides to rendezvous with the UGV to replenish power, both the UAV and the UGV will take a detour from their respective tasks and go back to their tasks after recharging. At a high level, the problem studied in this paper is stated below. \begin{problem}[Risk-aware UAV-UGV rendezvous]\label{problem:risk-aware-rendezvous} Given a route of nodes for the UAV $\mathcal{T}_A$, a route of nodes for the UGV $\mathcal{T}_G$, and the stochastic energy consumption model and battery capacity of the UAV, find a policy for the UAV to decide when and where to rendezvous with the UGV for recharging such that the total travel time is minimized and the probability of running out of charge during flight is less than a given tolerance. \end{problem} Next, we will present the setup and the assumptions that we use in this paper. Then we will present our CCMDP based formulation and show how to transform a CCMDP into a CMDP\@. \subsection{Environment and Task Model} Our problem considers a two-dimensional Euclidean space, which consists of a road network graph $G=(V_r, E)$ and a set of task points $V_t$ for the UAV to visit. The UGV has to move on the road network and its task is specified as a sequence of nodes of the road network. UAV's task is specified by some task planners using nodes in $V_t$. More details on the task planner will be discussed in the Section \ref{subsection: UAV_task_planning}. Both UAV and UGV should follow the task specification to visit the task nodes in order and they will deviate from the task route to rendezvous when necessary. \subsection{Vehicle Motion Model} The UGV will move at a fixed speed $v_g$ when it transits between two nodes in the road network. When the UAV transits between two nodes, it will fly with either the best endurance speed, $v_{be}$, or the best range speed, $v_{br}$. The best endurance speed is the speed at which the energy consumption rate is minimized. At this speed, the propellers of the multirotor operate more efficiently than in hover, and the UAV is capable of the greatest flight duration. By contrast, when a UAV flies at the best range speed, it minimizes the derivative of energy consumption rate with respect to velocity. This flight speed results in a lower flight duration than operation at $v_{be}$, but will allow a greater range to be traveled per unit of energy. For a no-wind condition, the velocity of the best range is always better than the velocity of best endurance. \subsection{Recharging and Stochastic Energy Consumption Model} We assume that it takes constant time $T$ to finish the recharging process, which includes the landing/take-off time and battery-swapping time. In this paper, we only consider the power consumption when a UAV traverses the route with the assumption that the power needed for computation, takeoff, and landing has been reserved by the power management system. As described in the transition model, the UAV will fly at a fixed speed when it transits between two nodes in the environment. However, given that constant speed, the energy consumption is stochastic considering the disturbances in the environment. \iffalse One example is \begin{equation*} P_{\bm{\Theta}}(v)=\bm{\xi}_0 + \bm{\xi}_1 v + \bm{\xi}_2 v^2 + \bm{\xi}_3 v^3, \end{equation*} where $\bm{\Theta}=[\bm{\xi}_0, \bm{\xi}_1, \bm{\xi}_2, \bm{\xi}_3]$. \fi Given the distance $l$ between two task nodes and the flying speed $v$, the energy consumption can be computed as \begin{equation}\label{equation:energy_consumption} e_{l, v} = \int_{t=0}^{\frac{l}{v}} P_{\bm{\Theta}}(v) dt, \end{equation} where $P_{\bm{\Theta}}(v)$ is the power consumption of the UAV when it flies at a speed $v$, and $\bm{\Theta}$ is a vector of parameters for stochastic variables. \subsection{Rendezvous Model} \begin{figure} \centering \includegraphics[scale=0.75]{figures/rendezvous_process.pdf} \caption{First step in the rendezvous process. The UGV (blue triangle) needs to deviate from its task node to rendezvous with the UAV at the rendezvous point (pink star). The rendezvous paths are in dashed lines.} \label{fig:rendezvous_process} \end{figure} \iffalse \subsubsection{No communication} When the UAV reaches a node and decides to rendezvous with the UGV, it will not send a rendezvous request to UGV. Instead, it will decide the rendezvous position and time based on the deterministic motion model of the UGV\@. Let $\mathcal{P}_g: T \to \mathbb{R}^2$ be the path executed by the UGV and $d: \mathbb{R}^2 \times \mathbb{R}^2 \to \mathbb{R}_{+}$ be the distance metric between two points. We use $p_a(t_0) \in \mathbb{R}^2$ and $p_g(t_0) \in \mathbb{R}^2$ to denote the position of the UAV and UGV when UAV decides to rendezvous at time $t$. The task node after $p_a(t)$ for the UAV is denoted as $p_a(t^{+})$. Then problem to find the rendezvous point can be formulated as \begin{align} \min_{p_r \in \mathcal{P}_g(t:\rm{end})} & \Delta t + \frac{d(p_r, p_a(t^{+}))}{v_a} \\ \rm{s.t.}~& p_g(t_0 + \Delta t) = p_r \\ & \frac{d(p_a(t_0), p_r)}{v_a} \leq \Delta t \end{align} \fi When the UAV reaches a node in $\mathcal{T}_A$ and decides to rendezvous with the UGV, the UAV and UGV will deviate from their task temporarily to finish the rendezvous process. There are two steps in the rendezvous process. In the first step, the UAV and UGV will meet at a rendezvous point as shown in Fig. \ref{fig:rendezvous_process} and in the second step, they will go to the next task node in $\mathcal{T}_a$ and $\mathcal{T}_g$ respectively. We want to optimize the time consumed in these two steps to find the optimal rendezvous points. Let $d: \mathbb{R}^2 \times \mathbb{R}^2 \to \mathbb{R}_{+}$ be the distance metric between two points in the Euclidean space. We use $d_G: V_r \times V_r \to \mathbb{R}_{+}$ to denote the length of the shortest path between two nodes in the road network. We use $\mathcal{T}_a(k)$ to denote the position of the UAV when it decides to rendezvous at the $k$th node in its task route and $\mathcal{T}_a(k+1)$ to denote the next position to visit for UAV after the rendezvous. With a slight abuse of notation, we use $\mathcal{T}_g(k)$ to denote the position of the UGV in the road network when the UAV decides to rendezvous at the $k$th node in its task route. With the above notations, the problem to find the rendezvous point can be stated below. \begin{problem}[Where to rendezvous]\label{problem:where_to_rendezvous} Given the positions of UAV ($\mathcal{T}_a(k)$) and UGV ($\mathcal{T}_g(k)$) at the beginning of the rendezvous process, UAV's next position to go $\mathcal{T}_a(k+1)$, UAV's flight speed $v_a$, UGV's transition speed $v_g$, and the road network $G$, we want to find a rendezvous point $p_r \in G$ such that the time consumed in the rendezvous process is minimized. Mathematically, \begin{align} & \min_{\Delta \geq 0, ~p_r \in G} ~ \Delta + \frac{d(p_r, ~\mathcal{T}_a(k+1))}{v_a} \\ &\text{s.t.}~ \Delta = \max (\frac{d_G(\mathcal{T}_g(k), ~p_r)}{v_g}, ~\frac{d(\mathcal{T}_a(k), ~p_r)}{v_a}). \iffalse \fi \end{align} \end{problem} In the first step of the rendezvous process, if the UAV or UGV reaches the rendezvous first, it has to wait for the other vehicle. Therefore, the time consumed in the first step is decided by the vehicle that reaches the rendezvous point later than the other. We encode this fact in the optimization problem by introducing the variable $\Delta$, which describes the maximum time needed for both UAV and UGV to reach the rendezvous point. The time consumed in the second step of the rendezvous process is the time needed for the UAV to fly back to its next task node. Problem \ref{problem:where_to_rendezvous} can be solved by iterating over the nodes in the road network as what we do in the case study. But such a method will increase the time to extract transition information for the CMDP\@. More efficient way to solving Problem \ref{problem:where_to_rendezvous} is left for our future work. \iffalse \subsection{Stochastic Energy Model of UAV} \iffalse Given a trajectory $\xi: \left [0, t_f \right ] \to \mathbb{R}^3 \times SO(2) \times \mathbb{R}^3 \times \times SO(2), \xi(t) = [p_x, p_y, p_z, \psi, v_x, v_y, v_z, \dot{\psi}]$ and the corresponding trajectory tracking controller, we are interested in finding the distribution of the energy consumption to track this trajectory. Suppose the stochastic motion model of the UAV is given by \begin{equation} \ddot{x}_t = f(x_t, u_t, \eta) + \omega_t, \end{equation} and the energy consumption can be characterized as a function of velocity $P(v)$. We can get the distribution of the energy consumption by running forward simulations. By running one forward simulation, we can get one actual trajectory $\Tilde{\xi}$. Then the energy consumption of this trajectory can be computed as \begin{equation} e(\Tilde{\xi}) = \int_{t=0}^{t_f} P(v_{\Tilde{\xi}}(t)) dt. \end{equation} Statistical information of different $e(\Tilde{\xi})$ can be used to obtain the distribution of the energy consumption. \fi In this paper, we only consider the power consumption when a UAV traverses the route with the assumption that the power needed for computation, takeoff, and landing has been reserved by the power management system. As described in the motion model, UAV will fly at a fixed speed when it transits between two points in the environment. But to achieve that constant speed, the energy consumption is stochastic considering the disturbances in the environment. Specifically, we use $P_{\bm{\Theta}}(v)$ to denote the power consumption of the UAV when it flies at a speed $v$, where $\bm{\Theta}$ is a vector for stochastic parameters and can be obtained through experiments. One example is \begin{equation*} P_{\bm{\Theta}}(v)=\bm{C}_0 + \bm{C}_1 v + \bm{C}_2 v^2 + \bm{C}_3 v^3, \end{equation*} where $\bm{\Theta}=[\bm{c}_0, \bm{c}_1, \bm{c}_2, \bm{c}_3]$. Given the distance, $l$ between two observation points and the flying speed $v$, the energy consumption can be computed as \begin{equation} e_{l, v} = \int_{t=0}^{\frac{l}{v}} P_{\bm{\Theta}}(v) dt. \end{equation} \fi \subsection{Chance-Constrained Markov Decision Process} \begin{figure} \centering \includegraphics[scale=0.65]{figures/state_transition.pdf} \caption{State transition graph in CMDP.} \label{fig:state_transition} \end{figure} One natural choice to model the sequential decision-making problems described in Problem \ref{problem:risk-aware-rendezvous} is to use MDP\@. In this section, we first show how to formulate Problem \ref{problem:risk-aware-rendezvous} as a CCMDP and then show how to transform a CCMDP into a CMDP in the following section. The rigorous definition of an MDP can be found in \cite{bertsekas2012dynamic}. Here we define the MDP from the perspective of the application. The MDP corresponding to Problem \ref{problem:risk-aware-rendezvous} is defined as a tuple $\mathcal{M} = (S, A, T, C, s_0)$, where \begin{itemize}[leftmargin=*] \item $S = \mathcal{T}_a \times S_g \times \mathcal{T}_g \times \mathcal{B} ~\cup~ \{s_{ob}, ~s_l\}$ is the state space of the problem, where $\mathcal{T}_a$ here is used as an un-ordered set, which describes all possible positions of UAV in a task route; $S_g$ is the set of positions of UGV and this information is needed when we compute the rendezvous points; $\mathcal{T}_g$ here is used as an un-ordered set, which describes the task nodes UGV will visit. $\mathcal{T}_g$ is included in the state space to inform the MDP about the next node the UGV needs to visit after a rendezvous. Without this information, the system will be non-Markovian; $\mathcal{B}$ is a discretized variable for describing the state of the charge of the UAV; $s_{ob}$ is one failure state representing the out-of-charge state and the UAV will transit to this state whenever it cannot finish its task route; $s_{l}$ is added as an absorbing state and UAV will transit to this state when it either finishes UAV's route or runs into a failure state. {One illustrative example of state transitions is given in Fig. \ref{fig:state_transition}.} \ item $A$ is the action space of the UAV\@. If the UAV has not finished its route and is not in a failure state, there are four actions for the UAV to choose: \begin{enumerate*} \item $v_{be}$: move to the next node in $\mathcal{T}_a$ with the best endurance velocity. \item $v_{br}$: move to the next node in $\mathcal{T}_a$ with the best range velocity. \item $v_{be\_be}$: rendezvous with the best endurance velocity. \item $v_{br\_br}$: rendezvous with the best range velocity. \end{enumerate*} When UAV is in a failure state or has finished its route, there is only one action that makes the system transit to the terminal state $s_l$. \item $T_a(s, s^{\prime}, a) = P( s^{\prime} \mid s, a)$ is the transition function, which depends on the stochastic energy consumption model. When UAV chooses to move forward to its next task node, its battery state at the destination node is a random variable that depends on the current battery state and Equation (1). Since we have discretized the battery charging levels at each node, the probability of reaching the destination node with a given battery charge can be calculated using Equation \eqref{equation:energy_consumption}. When it cannot reach the next task node, i.e., with non-zero probability, it will run out of charge, it transits to the failure state $s_{ob}$. When UAV chooses to rendezvous, a rendezvous point is first computed by solving the Problem \ref{problem:where_to_rendezvous}. Then the distribution of battery remaining when it reaches the rendezvous point can be computed based on Equation \eqref{equation:energy_consumption}. The non-positive portion of the distribution corresponds to the failure probability. After recharging, UAV will transit to its next task node starting with a full battery. When the UAV transits to the failure state or it finishes the task route, it will transit to the terminal state $s_l$ with probability 1 as shown in Fig. \ref{fig:state_transition}. In the terminal state $s_l$, the system will loop over this state. \item $C(s, s^{\prime}, a)$ is the cost function for the UAV\@. We define it as the time needed to transit between two states. If the UAV chooses to move to the next node, the cost will be time consumed during that transition. If a UAV chooses to rendezvous, the cost will be the sum of the time consumed in two steps of the rendezvous process. When the state transits to the failure state or to the terminal state, it takes zero cost. \item $s_0$ is the initial state of the system. \end{itemize} \begin{definition}[Risk] Let $\pi$ be a policy, the risk of the policy given initial state $s_0$ is defined as \begin{equation} \rho^{\pi} (s_0) = \mathbf{P}(\exists ~t ~s_t = s_{ob} \mid s_0). \end{equation} \end{definition} We seek the optimal policy $\pi^*$ that satisfies \begin{align} \pi^* = & \argmin_{\pi} \mathbb{E}\left [ \sum_{i=0}^{\infty} C(s_i, \pi(s_i)) \right ] \\ \rm{s.t.}~&~ \rho^{\pi}(s_0) \leq \delta, \end{align} where $\delta$ is the user-specified risk tolerance. \subsection{Constrained Markov Decision Process} We can transform a CCMDP into a CMDP by introducing a new cost function $\overline{C}: S \times S \times A \to \{0, 1\}$ \cite{geibel2005risk}. As shown in Fig. \ref{fig:state_transition}, when the system transits from a non-failure state to the failure state $s_{ob}$, it will incur a cost of one and other transitions will incur zero cost. The new cost function $\overline{C}$ is defined as \begin{equation} \overline{C}(s, a, s^{\prime}) = \begin{cases*} 1 & \rm{if}~$s \neq s_{ob}$ and $s^{\prime}=s_{ob}$ \\ 0 & \rm{else}. \end{cases*} \end{equation} As shown in \cite{geibel2005risk} [Proposition 4.1], the risk can be defined using the new cost function $\overline{C}$ as \begin{equation} \rho^{\pi}(s_0) = \mathbb{E} \left [ \sum_{i=0}^{\infty} \overline{C}(S_i, \pi(S_i)) \mid s_0 \right]. \end{equation} As a result, the CCMDP problem can be formulated as \begin{align} \pi^* = & \argmin_{\pi} \mathbb{E}\left [ \sum_{i=0}^{\infty} C(s_i, \pi(s_i)) \right ] \\ \rm{s.t.}~&~ \mathbb{E} \left [ \sum_{i=0}^{\infty} \overline{C}(S_i, \pi(S_i)) \mid s_0 \right] \leq \delta. \end{align} \section{Solutions to CMDP} \label{sec:sol} A CMDP can be solved using Linear Programming (LP) \cite{altman1999constrained, thiebaux2016rao}. The decision variables $y$ in LP are the occupancy measure for each state-action pair and are defined as \begin{equation} y(s, a) = \sum_{t} \text{Pr} (S_t = s, A_t = a). \end{equation} The LP is formulated as: \begin{align} & \min_{y(s, a), \forall s, a} \sum_{(s, a) \in S \times A} y(s, a) C(s, a) \\ \rm{s.t.}~ & \sum_{s, a} y(s, a) \overline{C}(s, a) \leq \delta \label{problem:LP_cost_constraint}\\ &\begin{aligned} \sum_{a^{\prime}} y(s^{\prime}, a^{\prime}) = \mathbb{I}(s^{\prime}, s_0)+\sum_{s, a} y(s, a) \rm{Pr}(s^{\prime} \mid s, a)~\\ \forall s^{\prime} \in S \setminus \{s_l\} \end{aligned}\label{problem:LP_flow_constraint}\\ & y(s, a) \geq 0 ~ \forall s, a \label{problem:LP_occupancy_measure_constraint}, \end{align} where $\mathbb{I}(s^{\prime}, s_0)$ is a Dirac delta function that returns 1 when $s^{\prime}=s_0$ and 0 otherwise. This LP corresponds to the dual linear program for MDPs \cite{altman1999constrained} with one extra cost constraint \eqref{problem:LP_cost_constraint}, which enforces that the cost of entering the failure state be lower than the predefined risk tolerance. Constraint \eqref{problem:LP_flow_constraint} is a flow conservation constraint to define valid occupancy measures and is defined by the initial state and the transition probability (see \cite{altman1999constrained}, ch. 8 for details). The last constraint \eqref{problem:LP_occupancy_measure_constraint} is added to guarantee that $y(s, a)$ is non-negative. If LP admits a solution, we can construct the policy from the occupancy measures by normalizing them: \begin{equation}\label{policy_traction} \pi^*(s, a) = \frac{y(s, a)}{\sum_{a^{\prime}} y(s, a^{\prime})}~ \forall (s, a) \in S \times A, \end{equation} where $\pi^*(s, a)$ is the probability of taking action $a$ in the state $s$ in the optimal stationary randomized policy. If Eq. \eqref{policy_traction} has a zero denominator, which suggests that state $s$ is not reachable from $s_0$, the policy for $(s, a)$ can be defined arbitrarily. An illustrative example to explain the policy extracted from the solution of LP is given in Fig. \ref{fig:different_risk_tolerance_policy}. When the UAV reaches $s_{k}^a$, it has 20\% battery remaining. It can choose to rendezvous to replenish itself or move forward to its next task node $s_{k+1}^a$. If the UAV chooses to rendezvous, the distribution of the battery remaining at the rendezvous point is shown in Fig. \ref{fig:different_risk_tolerance_policy}.(a). The distribution corresponding to forward action is given in Fig. \ref{fig:different_risk_tolerance_policy}.(b). If we set $\delta=0.01$, the policy constructed from LP results in rendezvous with a probability 0.997 and forward with 0.003. Otherwise, if the UAV were to choose to move forward, it would have less than 10\% battery charge remaining with a probability of 0.2, which is not enough to ensure a rendezvous or forward action at $s_{k+1}^a$, suggesting the failure probability is at least 0.2. By contrast, if we set the $\delta=0.5$, the policy becomes that rendezvous with a probability 0.504 and move forward with 0.496. One reason for such a policy is that with a probability of 0.8 the UAV will have 10\% battery remaining when it moves to $s_{k+1}^a$, where a rendezvous process with a shorter travel distance may be possible with a lower failure probability than the risk tolerance as shown in Fig.\ref{fig:different_risk_tolerance_policy}.(c). \begin{figure} \centering \includegraphics[width=0.38\textwidth]{figures/different_risk_tolerance.pdf} \caption{An illustrative example to explain the policy constructed with occupancy measures from LP\@. When the UAV is at state $s_{k}^a$ with State of Charge (SOC) equal 20\%, it has two actions: move forward (blue dashed line) to its next task node $s_{k+1}^a$ or rendezvous with the UGV (red dashed line) to recharge itself. The distribution of SOC after taking rendezvous is shown in (a) and that for forward action is shown in (b). (c) shows the distribution of SOC if the UAV first chooses forward action at $s_{k}^a$ and then chooses rendezvous $s_{k+1}^a$. } \label{fig:different_risk_tolerance_policy} \end{figure} \section{Experiments}\label{section:numerical simulation} \begin{figure*}[t] \centering \subfloat[]{ \includegraphics[width=0.25 \textwidth]{figures/task_scenario.pdf} \label{fig:rendezvous_input} } \subfloat[]{ \includegraphics[width=0.28\textwidth]{figures/UAV_sample_route_qualitative_example0.1.pdf} \label{fig:rendezvous_output_uav} } \subfloat[]{ \includegraphics[width=0.28\textwidth]{figures/UGV_sample_route_qualitative_example0.1.pdf} \label{fig:rendezvous_output_ugv} } \caption{ A qualitative example to illustrate how UAV and UGV rendezvous with each other under the policy $\pi$ that is obtained by solving the CMDP\@. The risk tolerance is set to be $\delta=0.1$ in this case study. (a) The input of the risk-aware rendezvous problem. (b) One sample route of UAV when it executes the policy $\pi$. (c) The route of UGV corresponds to the route of UAV\@. Lower case letters with or without prime denote the same road node that is visited at different times} \label{fig:rendezvous_illustrative_example} \end{figure*} In this section, we first present a qualitative example to show what the input and output look like for our problem. Next, we study how system parameters (different risk tolerances) influence the rendezvous behaviors between the UAV and the UGV\@. Then, we present quantitative results for the ISR application that motivates our research. Specifically, we will use Monte Carlo (MC) simulations to evaluate \begin{enumerate*} \item the satisfaction of the risk constraint for the policy constructed from LP; \item the effectiveness of the policy in minimizing the expected task duration; \item the risk tolerance-task duration Pareto curves. \end{enumerate*} Moreover, the running time of LP for CMDP is empirically evaluated. All experiments are conducted using Python 3.8 in a PC with i9-8950HK processor. LP is solved using Gurobi 9.5.0. \subsection{{Task route planner}} \label{subsection: UAV_task_planning} {The task routes $\mathcal{T}_a$ and $\mathcal{T}_g$ used in Problem \ref{problem:risk-aware-rendezvous} can be either generated jointly by some existing task planners \cite{manyam2019cooperative, yu2018algorithms} or can be generated by separately by different task planners. In our case study, the task for the UGV is to persistently monitor nodes A, B, and C (blue squares in Fig. \ref{fig:rendezvous_illustrative_example}). The task nodes for the UAV are red dots in Fig. \ref{fig:rendezvous_illustrative_example} and the task route (from node 0 to 18 and back to 0) is generated by a planner for Traveling Salesman Problem (TSP). } \subsection{System Models} \begin{table}[ht] \centering \caption{Coefficients for stochastic energy consumption model} \begin{tabular}[t]{lcccccc} \toprule &$b_0$ &$b_1$ &$b_2$ &$b_3$ &$b_4$ &$b_5$\\ \midrule {Value} &-88.77 &3.53 &-0.42 &0.043 &107.5 &-2.74\\ \bottomrule \end{tabular} \label{table:coefficient} \end{table} The UAV task and UGV tasks are from our ongoing project on intelligence, surveillance, and reconnaissance (ISR) as shown in Fig. \ref{fig:rendezvous_input}. In this project, we are interested in the case where $\delta=0.1$. UAV has about 240 KJ energy and its best range speed and best endurance speed are 14 m/s and 9.8 m/s respectively. UGV moves at 4.5 m/s. The rendezvous process will take 300 seconds. We consider two sources of stochasticity in the energy consumption model of UAVs: weight and wind velocity contribution to longitudinal steady airspeed. The deterministic energy consumption model of the UAV is a polynomial fit constructed from analytical aircraft modeling data, given as \begin{equation} P(\bm{v_\infty}) = b_0 + b_1 \bm{v_\infty} + b_2 \bm{v_\infty}^2 + b_3 \bm{v_\infty}^3 + b_4 \bm{w} + b_5\bm{v_\infty} \bm{w}, \end{equation} where $b_0$ to $b_5$ are coefficients, and their experimental values are listed in Table \ref{table:coefficient}. Figure~\ref{fig:power_consumption} shows the agreement between the polynomial regression fit model and the analytical data that it was derived from. Weight is randomly selected following a normal distribution with a mean of 2.3 kg and a standard deviation of 0.05 kg, $\bm{w} \sim \mathcal{N}(\mu_{\bm{w}}, \sigma^2_{\bm{w}})$. Vehicle airspeed, $v_\infty$, is the sum of the vehicle ground speed, $v$, and the component of the wind velocity that is parallel to the vehicle ground speed, ignoring sideslip angle and lateral wind components. \begin{equation} v_\infty = \lvert \Bar{v_g} + \rm{cos}(-\psi)\bm{\xi}_{a, b} \rvert \end{equation} The longitudinal wind speed contribution is derived from two random parameters; wind speed, and wind direction. Wind speed is modeled using the Weibull probability distribution model of wind speed distribution, $\bm{\xi}_{a, b}$, with a characteristic velocity $a=1.5$ m/s and a shape parameter $b=3$. This is representative of a fairly mild steady wind near ground level. Wind direction $\psi$ is the heading direction of the wind, and is uniformly randomly selected on a range of $[0,360)$ degrees. \begin{figure} \centering \includegraphics[width=0.28 \textwidth]{figures/powermod.pdf} \label{fig:power_model_fit} \caption{ Comparison of analytical data used to derive the polynomial regression fit model of UAV power requirement at three weights and across 11 airspeeds. } \label{fig:power_consumption} \end{figure} \begin{figure*} \centering \subfloat[Low risk tolerance ($\delta=0.01$)]{ \includegraphics[width=0.26\textwidth]{figures/UAV_sample_route_risk_level_example_0.01-1.pdf} \label{fig:risk_example0.01_UAV} } \subfloat[Medium risk tolerance ($\delta=0.2$)]{ \includegraphics[width=0.26\textwidth]{figures/UAV_sample_route_risk_level_example_0.2-2.pdf} \label{fig:risk_example0.2_UAV} } \subfloat[High risk tolerance ($\delta=0.5$)]{ \includegraphics[width=0.26\textwidth]{figures/UAV_sample_route_risk_level_example_0.5-3.pdf} \label{fig:risk_example0.5_UAV} } \\ \subfloat[UGV route corresponding to Fig. \ref{fig:risk_example0.01_UAV}]{ \includegraphics[width=0.26\textwidth]{figures/UGV_sample_route_risk_level_example_0.01-1.pdf} \label{fig:risk_example0.01_UGV} } \subfloat[UGV route corresponding to Fig. \ref{fig:risk_example0.2_UAV}]{ \includegraphics[width=0.26\textwidth]{figures/UGV_sample_route_risk_level_example_0.2-2.pdf} \label{fig:risk_example0.2_UGV} } \subfloat[UGV route corresponding to Fig. \ref{fig:risk_example0.5_UAV}]{ \includegraphics[width=0.26\textwidth]{figures/UGV_sample_route_risk_level_example_0.5-3.pdf} \label{fig:risk_example0.5_UGV} }\\ \subfloat[Quantitative results.]{ \begin{tabular}[t]{lccc} \toprule UAV data &$\delta=0.01$ &$\delta=0.2$ &$\delta=0.5$ \\ \midrule {Empirical failure rate} &0.00975 &0.201 &0.497 \\ Average route travel time &11330 s &{10418} s &10404 s \\ route travel time overhead &160.2\% &139.2 \% &138.9\% \\ Average route travel distance &96.8 km &97.8 km &97.6 km \\ Travel distance overhead &58.2\% &60.5\% &60.3\% \\ Average \# of rendezvous &8.5 &6.4 &6.3 \\ \bottomrule \end{tabular} \label{table:risk_example_table} } \caption{ How different risk thresholds influence the rendezvous behaviors. UAV route time with the best range speed is 4354 s and the route distance is 61.0 km. (a) UAV is very risk-averse to failures with a risk threshold equal to 0.01. (b) UAV is less risk-averse to failures with a risk threshold equal to 0.2. (c) UAV is neutral to the failures with a risk threshold equal to 0.5.} \label{fig:risk_averse_example} \end{figure*} \subsection{Simulation Results} An illustrative example of the input and the output of the problem considered is shown in Fig. \ref{fig:rendezvous_illustrative_example}. The input of the problem is shown in Fig. \ref{fig:rendezvous_input}, which consists of UAV task nodes (red dots), UGV task nodes (blue square), and road network (black nodes). Fig. \ref{fig:rendezvous_output_uav} and \ref{fig:rendezvous_output_ugv} shows one sample route of UAV and UGV respectively when the system executes the policy computed by LP. UAV's route starts from node 0. When the UAV reaches node 4, it will choose to rendezvous with UGV using the best range speed in a rendezvous point, which is denoted as a star, and then go to its next task node 5. Similarly, the UAV will rendezvous with the UGV when it reaches nodes 7, 8, 11, 14, and 15. The corresponding route of UGV is presented in Fig. \ref{fig:rendezvous_output_ugv}. Next, we show how different risk tolerances influence the rendezvous behaviors under our CMDP formulation. In these experiments, we set the risk tolerance $\delta$ to be 0.01, 0.2, and 0.5. {Results shown in Fig. \ref{fig:risk_averse_example}} includes sample routes for the UAV and the UGV and statistical data of the policies. Fig. \ref{fig:risk_example0.01_UAV}, \ref{fig:risk_example0.2_UAV}, and \ref{fig:risk_example0.5_UAV} are sample routes for the UAV when it executes the policy. Fig. \ref{fig:risk_example0.01_UGV}, \ref{fig:risk_example0.2_UGV}, and \ref{fig:risk_example0.5_UGV} are corresponding routes of the UGV\@. The rendezvous point is denoted as a star. The SOC is annotated in red text close to the task node at which the UAV decides to rendezvous. Some statistical data are summarized in table \ref{table:risk_example_table}. In general, we observe that when the risk tolerance is set to be small, the UAV tends to rendezvous more often, and the average route travel time is higher. Here the average route travel time is computed by considering only trials in which the UAV finishes its task route. By contrast, as the risk tolerance is relaxed to a larger value, the average route travel time will decrease, which comes at the cost of a high failure probability. We also conducted several quantitative experiments to validate our formulation. The first experiment is to use MC simulation to check whether the failure probability is upper bounded by the set risk tolerance of 0.1. We use FR to denote the empirical failure rate. As can be seen in Table \ref{table:MC_convergence}, as MC increases, the empirical failure rate is close to and below the theoretical PF 0.1. In the following experiments, we will use $N_{\scaleto{MC}{3pt}}=2000$ for simulation. \begin{figure} \centering \includegraphics[width=0.35\textwidth]{figures/comparison0.1_short.pdf} \caption{Results comparisons for the CMDP policy and the greedy policies with $\delta=0.1$. The dashed black line represents the task duration if the UAV moves with the best range speed without considering battery limitation. } \label{fig:comparison} \end{figure} \begin{table}[t] \centering \caption{Empirical evaluation of failure probability. $\delta =0.1$. } \begin{tabular}[t]{lcccc} \toprule $N_{\scaleto{MC}{3pt}}$ (\# of MC trials)&$500$ &$1000$ &$3000$ &$5000$\\ \midrule {Failure rate} &0.108 &0.105 &0.099 &0.097\\ \bottomrule \end{tabular} \label{table:MC_convergence} \end{table} \begin{figure} \centering \includegraphics[scale=0.40]{figures/task_duration_risk_tolerance.pdf} \caption{Risk tolerance vs task duration Pareto Curve. } \label{fig:pareto_curve} \end{figure} To validate that the policy constructed from LP can minimize the expected travel distance. We compare our policy with a greedy baseline. The greedy policy is set as: always flies with the best range speed and chooses to rendezvous when state-of-charge drops below a set value. {What we observe in experiments is that when the route of a UAV is long, for example, there are more than 15 nodes, the probability of finishing the route is close to zero for the greedy baseline no matter what threshold we set. To have a more informative comparison, we use only nodes 0 to 11 for the task route in the following experiments.} We consider four-set values $40\%$, $50\%$, $60\%$, and $70\%$, and the corresponding policies are denoted as \textit{Greedy-40}, \textit{Greedy-50}, \textit{Greedy-60}, \textit{Greedy-70}. As shown in Fig.\ref{fig:comparison}, our policy can guarantee success probability above the set value of 0.9 and the expected travel time of UAV is shorter compared to the baseline. Though the baseline can achieve a higher success probability in some cases as shown in Fig.\ref{fig:comparison}, its expected task duration is still longer than our policy. The empirical Pareto curve for risk tolerance and the task duration is shown in Fig. \ref{fig:pareto_curve}. The green curve is the mean value and the shaded area is formed using one standard deviation from the mean. When the risk level is set to be a higher value, the UAV will tend to make more risky decisions, leading to a lower travel time at the cost of a higher failure probability. \iffalse \begin{table}[ht] \centering \caption{The gap between task duration and conditional task duration.} \begin{tabular}[t]{lccccc} \toprule &$\delta = 0.01$ &$\delta = 0.03$ &$\delta = 0.05$ &$\delta = 0.08$ &$\delta = 0.1$\\ \midrule Error &0.18\% &1.95\% &3.01\% &5.6\% &6.18\%\\ \bottomrule \end{tabular} \label{table:objective_gap} \end{table} \subsubsection*{Discussion} In this paper, the objective for CMDP is to minimize the task duration the same as those in the related work \cite{chow2015trading}. One alternative objective is to minimize the task duration that only considering the route that the UAV successfully finishes its task route. However, as suggested \cite{chow2015trading}, when the risk level is small, for example, $\delta \leq 0.1$, the solution gap between these two formulations is small. We empirically compare these two formulations. As shown in Table \ref{table:objective_gap}, the gap is only about $6\%$ when $\delta \leq 0.1$, which is the case we are interested in for applications. {One way to remove this gap for our application is to modify the CMDP formulation. Instead of letting the state transit to the terminal state when the UAV runs out of battery, we allow the UAV and UGV to transit back to their tasks with an additional cost added to the main objective, which in practice represents the time consumed to do failure recovery for the UAV\@. Another direction to remove the gap would be to find new algorithms that can minimize the expected length of only those successful routes. } \fi The running time for the proposed routing problem consists of three parts. The first part is devoted to extracting transition information for LP\@. The second part is about constructing an LP model with Gurobi and the last part is for solving the LP\@. In our case study, there are about 54000 states and it takes about 6 min to extract transition information, 9 minutes to create an LP model, and about 1 second to solve the LP\@. \iffalse $$ \begin{aligned} \mathbb{E} \left [ \rm{task~duration} \right ] = \mathbb{E} \left [ \rm{task~duration} \mid \rm{success} \right]P(\rm{success}) \\ + \mathbb{E} \left [ \rm{task~duration} \mid \rm{failure} \right]P(\rm{failure}) \end{aligned} $$ $$ \begin{aligned} \frac{\mathbb{E} \left [ \rm{task~duration} \right ]}{P(\rm{success})}= \mathbb{E} \left [ \rm{task~duration} \mid \rm{success} \right] \\ + \mathbb{E} \left [ \rm{task~duration} \mid \rm{failure} \right]\frac{P(\rm{failure})}{P(\rm{success})} \\ \leq \mathbb{E} \left [ \rm{task~duration} \mid \rm{success} \right] + \\ \mathbb{E} \left [ \rm{task~duration} \mid \rm{success} \right]\frac{P(\rm{failure})}{P(\rm{success})} \end{aligned} $$ $$ \begin{aligned} \frac{\frac{\mathbb{E} \left [ \rm{task~duration} \right ]}{P(\rm{success})} - \mathbb{E} \left [ \rm{task~duration} \mid \rm{success} \right]}{\mathbb{E} \left [ \rm{task~duration} \mid \rm{success} \right]} \\ \leq \frac{P(\rm{failure})}{P(\rm{success})} \end{aligned} $$ \fi \section{Conclusion} In this paper, we study a variant of the cooperative aerial-ground routing problem with energy chance constraint on the UAV\@. We formulate the problem as a CMDP and use LP to find the optimal policy for the CMDP\@. We validate our formulation and the solution in one ISR application. In future work, one direction we will explore is to extend one UAV one UGV routing problems to multiple UAVs and UGVs and consider the distributed solution for such types of risk-aware routing problems. \label{section:conclusion} \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:26:47', 'yymm': '2204', 'arxiv_id': '2204.04767', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04767'}
arxiv
\section{Introduction} \input{sections/Introduction} \section{Problem Statement} \input{sections/Problem_Statement} \section{Metrics} \input{sections/Metrics} \section{Results} \input{sections/Results} \section{Conclusion} \input{sections/Conclusion} \clearpage \Urlmuskip=0mu plus 1mu\relax \printbibliography \clearpage \begin{appendices} \input{sections/Appendix} \end{appendices} \end{document} \section{Results of metrics on train data} The following are tables for attacks and metrics on train data. \input{tables/Train_gradient_masking_table} \input{tables/Train_metrics_table} \clearpage \section{Per Metric plots} The following are plots with each of the metrics' scores across the different networks. They should allow for a more clear visual comparison of the metrics and models. The results are calculated with 5000 samples for each of the models. Histograms summarizing these samples are shown where they revealed distinguishing characteristics amongst the different models beyond what is summarized in the bar plots. \subsection{Gradient Norm} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Train_gradient_norm_plot.png} \caption{Gradient norm on training data} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Test_gradient_norm_plot.png} \caption{Gradient norm on testing data} \end{figure} \clearpage \subsection{FGSM PGD Cosine Similarity} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Train_fgsm_pgd_cos_plot.png} \caption{FGSM PGD Cosine Similarity on training data} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Test_fgsm_pgd_cos_plot.png} \caption{FGSM PGD Cosine Similarity on testing data} \end{figure} \clearpage \subsection{PGD Collinearity} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Train_pgd_collinearity_plot.png} \caption{PGD Collinearity on training data} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Test_pgd_collinearity_plot.png} \caption{PGD Collinearity on testing data} \end{figure} \clearpage \subsection{Robustness Information} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Train_gradient_information_plot.png} \caption{Robustness information on training data} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Test_gradient_information_plot.png} \caption{Robustness information on testing data} \end{figure} \clearpage \subsection{Linearization Error} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Train_linearization_error_plot.png} \caption{Linearization error on training data} \end{figure} \begin{figure}[ht] \centering \includegraphics[scale=0.35]{figures/Test_linearization_error_plot.png} \caption{Linearization error on testing data} \end{figure} \section{Discussion} One may find it strange that for some of these metrics an undefended model scores very similarly to the Step-ll defense, raising the possibility of false positives. However, the consideration of gradient masking for a model only makes sense once the model has shown good adversarial accuracy against at least single step attacks. If this is not the case then the gradients are clearly not masked. Addressing this issue should be as simple as ensuring that these metrics are analysed together with adversarial accuracy for each network using single step and iterative attacks. A more serious limitation is the need for a benchmark such as PGD for these results. This is an issue as these metrics cannot be considered architecture agnostic. Thus, for each neural network architecture being considered, a reliable benchmark from a robust model must first be established in order to extract any meaning from metrics on the target model. Another concern is that some of these metrics may not apply universally. Indeed, they are not based on hard theoretical evidence, but rather intuition and empirical results. For instance, while models that use gradient masking as a strategy will be less linearizable, a priori, a model that is not linearizable is not necessarily not robust. Metrics like the linearization error or PGD collinearity may indicate that a model is gradient masking in this case. However, research has shown that model robustness can be associated with models that are more linear around the data points. Our own results across these metrics support the idea that highly non-linear loss surfaces are in general not desirable or usual in a neural network. An interesting group of results are those for the Jacobian regularization models. While our benchmarks did not recognize signs of gradient masking, it is nonetheless interesting that this defense performed similarly to gradient masked models in some metrics. While it could be a testament to the ineffectiveness of some metrics, it could also signal that these models may rely, to some extent, on gradient masking. Finally, we can address the disappointing results of the robustness information metric. Interestingly, this metric clearly identifies the Step-ll defense with $\epsilon = 16/255$ as gradient masking. This defense had been the most elusive for other metrics to clearly identify as such. However, PGD models actually achieve a lower score than the problematic FGSM models, which are the most evident cases of gradient masking, removing some credibility from this metric. While we do not believe the intuition behind the metric to be fundamentally flawed, there are some possible reasons for its relative failure. First of all, the metric completely relies on DeepFool. It is possible that the final result is highly dependent on how effective DeepFool is on each separate network. The second consideration is that, in models that are more robust, such as those trained using PGD, we would expect the decision boundary to be further away from the data point. Thus, it may be somewhat unfair that we are comparing the direction given at a boundary which is further away to be as reliable as that given at a boundary which is much closer to the data point. \subsection{Gradient Norm} The first metric we try is the mean norm of the gradients of the loss function with respect to the input. The norm of the gradient is a natural way to capture the smoothness of the loss surface at a point in the direction of the gradient. This is a crucial factor for gradient-based attacks to succeed, as they ultimately rely on linearizing the loss function. The lack of smoothness seen in Table \ref{plotAlongGrad} (c), (d), (k) should manifest itself in this measure. Formally, we compute: $$\mathbb{E}_{(\mathbf{x}, y)\sim D} \left[ \lVert \nabla_x L(x, y) \rVert_2 \right]$$ One may think that, given a gradient with a large norm, by following its direction, and thus presumably increasing the loss, we would easily find an adversarial example. However, it is important to recall that this increase in the norm is caused by a defense which intended to make the model stronger against adversarial attacks. If the defense indeed works against at least single step gradient based attacks, we can reason that, in the majority of cases, these attacks will not find an adversarial example. We thus expect that a larger norm of gradients indicates a loss surface which is less linear, with less informative gradients. \subsection{FGSM-PGD Cosine Similarity} The next natural direction to explore is that of the reliability of the direction of gradients. By reliability we mean how aligned the gradient at the data point is to a vector that leads to a point of maximal loss within the distortion bound. To measure this, we can take the cosine similarity between the gradient and this optimal vector. As an approximation to the optimal direction, we settle for the perturbation provided by a PGD attack with more iterations. PGD has proven to be a very good approximator to the max operator for the loss in adversarial training, (Formula \ref{adversarial loss}) and is generally accepted as the strongest attack utilizing first order gradients\cite{pgdGood}. Formally, with $\text{FGSM}(x, y) \in \mathbb{R}^D$ and $\text{PGD}(x, y) \in \mathbb{R}^D$ denoting the perturbation vectors returned by an FGSM and PGD attack respectively on a data point $(\mathbf{x}, y)$, we compute: $$\mathbb{E}_{(\mathbf{x, y)\sim D}} \left[ \text{Cosine Similarity} (\text{FGSM}(x, y), \text{PGD}(x, y)) \right]$$ We use a PGD attack with 10 iterations and a relative step size of $1/4$. Ultimately, this value is the cosine similarity between an FGSM attack and a PGD attack, which was been briefly mentioned by \cite{ensemble}. We extend their work by clearly motivating this value as a potential way of measuring gradient masking, and validate it with more extensive empirical testing. A small value for this metric suggests that the gradient at the data point is a poor indicator of the global loss landscape. Following its direction to increase the loss is only effective very locally, leading to the failure of single-step attacks, while high loss regions may still exist. \subsection{Robustness Information} The next metric we experiment with assesses how informative gradients are at assessing the robustness at a data point. Recall from the previous section that our measure for robustness relates to the distance from a point to the nearest decision boundary. Intuitively, we want to know how accurately gradients can lead us to the nearest point on a decision boundary. To do this, we rely on the DeepFool\cite{deepfool} attack. DeepFool is a gradient based method that attempts to find the smallest perturbation that leads to an adversarial example - in other words, it approximately finds the nearest point from the data on the decision boundary. Although it is an approximation, in practice, this method tends to find small perturbations which are believed to be good approximations to the minimal ones. Assuming DeepFool returns the nearest point at a boundary, the normal to the decision boundary provides the optimal direction to take from the data point to reach this adversarial example. Let $x'$ denote the point returned by DeepFool. Additionally, let $f(z) = \nabla_{z} \left( l_{\hat{k}(x')}(z) - l_{\hat{k}(x)}(z) \right)$, where $z \in \mathbb{R}^D$. We calculate: $$\mathbb{E}_{(\mathbf{x}, y)\sim D} \left[ \text{Cosine Similarity} (f(x'), f(x)) \right]$$ Since, by definition, points $z$ at the decision boundary form a level set of $l_{\hat{k}(x')}(z) - l_{\hat{k}(x)}(z)$, $f(x')$ will be orthogonal to the boundary and point towards the adversarial class region. Thus, this measure computes how closely gradients align themselves with this "optimal" shortest path to the boundary. \subsection{Linearization Error} In \cite{ensemble}, the approximation-ratio between a single-step attack, Step-ll, and the true maximum loss within a region, lower bounded by PGD, is shown as an argument that adversarial training with Step-ll admits a degenerate global minimum. In the paper, they conclude that a non-linearizable loss function is an instance of gradient masking. We thus use the linearization error of the network as an explicit measure of this phenomenon. The function $l_c$ is a multi-variable scalar valued function, and as such, we can use a first-order Taylor expansion to linearly approximate its value at any perturbation from the data point. \begin{comment} \begin{equation} f(\mathbf{x} + \boldsymbol{\delta}) \approx f(\mathbf{x}) + \sum_{j=1}^N \frac{\partial f(\mathbf{x})}{\partial x_j} \delta_j \label{taylor} \end{equation} \end{comment} Let $\hat{l}_{\hat{k}(\mathbf{x})}(\mathbf{x}')$ represent the linear approximation for $l$ obtained with a taylor expansion for $\mathbf{x}' = \mathbf{x} + \boldsymbol{\delta}$ around $\mathbf{x}$. Our metric follows as: $$\mathbb{E}_{(\mathbf{x}, y)\sim D} \left[ \frac{\lvert \hat{l}_{\hat{k}(\mathbf{x})}(\mathbf{x}') - l_{\hat{k}(\mathbf{x})}(\mathbf{x}') \rvert}{\lvert l_{\hat{k}(\mathbf{x})}(\mathbf{x}') \rvert} \right]$$ Beyond proposing this as a metric for gradient masking and empirically testing it, our work extends \cite{ensemble} by directly measuring the "linearizability" of the network. Seeing as the loss is a function of the logits, this method avoids the reliance on a specific attack as well as the need for an approximation of the true maximum loss. An increase in the linearization error when a defense is applied indicates that the function learned is more irregular around the data points. While this may thwart single step attacks, the model is not necessarily more robust. \subsection{PGD Collinearity} When gradient masking takes place, there is a sharp curvature near the data points that causes the gradient direction to be misleading. This is clearly illustrated in Table \ref{plotAlongGrad}. Indeed, in this Figure, we see a steep decrease in the value of the loss still quite close to the data point in (c) and (d). This steep decrease, together with the fact that iterative methods such as PGD are still able to find adversarial examples using gradients, suggests that there should be a better direction, at that point, in order to increase the loss. One way to measure gradient masking could then be precisely how much iterative attacks must correct their trajectories on subsequent iterations in order to maximize the loss. We take this measurement by calculating the mean cosine similarity between the perturbations of consecutive iterations of PGD. If a model’s gradients are informative, we would expect the model to not deviate much from the initial gradient step, leading to a high score in this metric. More formally, let the perturbation vector returned at the i\textsuperscript{th} iteration of PGD on data point $\mathbf{x}$ with label $y$ be denoted as $p^{(i)}$. Given a PGD attack with $I$ iterations on a dataset $D$, we compute: $$ \mathbb{E}_{(\mathbf{x}, y)\sim D} \left[ \frac{1}{I-1} \sum_{i=1}^{I-1} \text{Cosine Similarity} \left(p^{(i)}, p^{(i + 1)} \right) \right]$$ \subsection{Model Choice} All the experiments were done using ResNet-18 and WideResNet-28 architectures on the CIFAR-10 dataset. We chose these as ResNet architectures are the most widely used for tasks involving image datasets such as CIFAR-10. The chosen defenses can be divided into two groups. The first are simpler methods, some of which form the basis for robust models, and are listed in Table \ref{model specs}. These are the models that were used during the development of our metrics, as their simplicity provides us with results that are more easily interpretable. The second group of defenses are taken from recent papers \cite{Carmon2019Unlabeled, CURE, feature_scatter, gowal2021uncovering, Wang2020Improving, Wong2020Fast,Wu2020Adversarial, zhang2020adversarial, zhang2021geometryaware, sehwag2020hydra, hendrycks2019pretraining}. In order to select these, we took into account how diverse their approaches are, as well as how well they preformed on the Autoattack \cite{autoattack} and Robustbench \cite{robustbench} leaderboards in comparison with their own reported robustness. Running our metrics on a diverse set of published defenses will show if our work is applicable and useful in current research. Within the first group of defenses, there are adversarial training algorithms that adapt the traditional empirical risk minimization to that shown in Equation \ref{adversarial loss}, following \cite{madry2019deep}, for a set of allowed perturbations $S$. \begin{equation} \label{adversarial loss} \min \mathbb{E}_{(\mathbf{x}, y)\sim D} [\max_{\boldsymbol\delta\in S} L(\mathbf{x}+\boldsymbol\delta, y; \theta)] \end{equation} They effectively augment the training set with adversarial examples, with the only distinguishing variable being the attack algorithm used to approximate the max in Formula \ref{adversarial loss}. These are FGSM \cite{fgsm}, Step-ll \cite{ensemble} and PGD \cite{madry2019deep}, each with an $\epsilon$ of 8/255 and 16/255. From these attacks, Step-ll may be less well known. It works in the same way as FGSM except, instead of maximizing the loss with respect to the target class, we minimize the loss with respect to the least likely class - the class that has the smallest logit. Single step methods are known to be poor choices for adversarial training, particularly with large epsilons. As previously pointed out, the authors in \cite{ensemble} suggest that “adversarial training with single-step methods admits a degenerate global minimum, wherein the model’s loss can not be reliably approximated by a linear function”. This would be an instance of gradient masking. PGD has been suggested as the best approximator to the point of maximum loss within an L-infinity region \cite{pgdGood}, and serves as the gold standard within this first group. There are also those defenses that attempt to regularize the loss surface during training. They include input Jacobian regularization as in \cite{jacobian} and Gradient Clipping \footnote{Model provided by Rahul Rade}, from another ongoing project. Jacobian regularization adapts regular training by adding a regularization term to the cross-entropy loss, as shown in Equation \ref{regularization}, where $\lambda$ controls the trade off between minimizing the cross entropy loss and the regularization term and $R$ is the regularization term. \begin{equation} \label{regularization} \min \mathbb{E}_{(\mathbf{x}, y)\sim D} [L(\mathbf{x}, y; \theta) + \lambda R] \end{equation} Jacobian regularization underpins many proposals for robustness in networks, even if they are somewhat more sophisticated \cite{facebookJacobian}, making this defense an interesting one to study. We try it at different values of the $\lambda$ parameter, as described in \cite{jacobian}, which controls the trade-off between minimizing the Frobenius Norm of the Jacobian ($R$ in this case) and the cross-entropy loss. As described by \cite{hofmann}, the Frobenius Norm of the Jacobian approximates an upper bound on the maximum change in the output logits (in euclidean distance) that can arise from a small change in the inputs, making it a natural objective to minimize. However, these defenses are also prime candidates for an investigation on gradient masking, as they directly minimize the model’s gradients. In gradient clipping, the only adaptation to regular training is that the update gradients with respect to the network parameters are clipped. \input{tables/models} \subsection{Gradient Masking Benchmarks} In order to interpret the metrics we will propose, we need to understand which of these defenses exhibit gradient masking. To do this, we make use of the behaviours described in the introduction \cite{obfuscated} as a checklist, in addition to another one we propose: there should not be a large difference between reasonable single-step gradient-based attacks and other attacks, including multi-step gradient-based attacks. We defend this as another sign of gradient masking as, if this is the case, then the direction provided by the gradient at the point is not useful. (I am not super sure about this next part). In essence, if a model is truly robust, and not simply masking its gradients, switching to a stronger attack should not lead to a large drop in accuracy. Black-box attacks are methods that treat neural networks as opaque functions, not having access to any gradient information. They are therefore not affected by gradient masking. White-box attacks, on the other hand, typically rely on the gradients of the network to find an adversarial perturbation using optimization techniques. Black-box attacks are a subset of white-box attacks, and should be outperformed by them. Following \cite{pgdGood}, we choose SPSA as our black-box attack, which we compare against FGSM, PGD and Step-ll as our white-box attacks. SPSA is run with 256 samples and 15 iterations. PGD is run with 25 iterations and a relative step size of $1/10$. For each of these attacks we use a distortion bound $\epsilon$ of $8/255$ and $16/255$. All of these attacks should outperform SPSA for a network without masked gradients. To check the effectiveness of unbounded attacks, we use PGD but do not project back to an L-infinity ball at any point. We expect non-gradient masked networks to have an accuracy of 0\% against this attack, as every pixel in any image can be set to a value of 0.5, impeding any classification attempt. The strongest attack is Autoattack, which we take as our state-of-the-art reference. We interpret this score as the closest thing to a true measure of robustness we can get currently. The results are shown in Table \ref{TestBenchmarks}. We also plot FGSM vs AutoAttack accuracy in Figure \ref{FGSM AA}. We can clearly identify a correlation between FGSM and AutoAttack accuracies for models which are not masking their gradients, as we would expect. The outliers in this plot are the networks we identify as masking their gradients. \begin{comment} We can see the change in test adversarial accuracy as the distortion bound is increased in Figure \ref{FGSM Random}. For comparison, we include a random attack, where a perturbation direction is chosen uniformly at random, resulting in a random point on the distortion bound. Despite being uninformed by the network, this random attack is gradient-free. We would expect it to always be outperformed by an informed attack such as FGSM, except in the case of heavy gradient masking. The shape of these curves proves very informative, and can give us insights into how the models are behaving. In a normal model, we would expect accuracy to somewhat rapidly drop as the distortion bound increases for each attack. However, for a few of the models, we see something quite different happening. In the single-step defenses we had identified as gradient masking, we see that the attack actually becomes weaker as we increase the distortion bound, with accuracy only dropping approximately after the distortion size exceeds the one the method was defended with. In the most extreme case, shown by the FGSM model with $\epsilon = 16/255$, a random perturbation becomes a \textit{stronger} attack than FGSM, and, in fact, the model achieves higher accuracy on perturbed inputs than the original model had on unperturbed inputs. In the gradient clipped model, we observe that, while the accuracy for a random attack is the highest out of any model with a very small distortion bound, it very quickly drops to the lowest once the distortion bound is increased, signaling a worrying lack of robustness. \end{comment} From these results, by following the checklist, we identify the models that we would expect to perform poorly on our metrics. These are both of the single-step methods trained with $\epsilon = 16/255$ and the gradient clipped model. Additionally, we observe that FGSM training with an $\epsilon = 8/255$ is extremely unstable, sometimes resulting in a phenomenon known as catastrophic overfitting(CO) \cite{Wong2020Fast}, and thus relying on gradient masking as well, so we include such an instance in our study. As for the models from published papers, we note that Adversarial Interpolation and Feature Scatter show the same signs of gradient masking mentioned above. Notably, PGD Accuracy with an unbounded distortion bound does not reach 0\% for Adversarial Interpolation, and both models show a very large difference between FGSM and AutoAttack accuracies. The other models do not seem to suffer from this phenomenon. \input{tables/Test_gradient_masking_table} { \begin{figure}[t] \centering \includegraphics[width=0.7\linewidth]{figures/FGSM_Accuracy_eps_003_AA.png} \caption{FGSM vs AutoAttack Accuracy.} \label{FGSM AA} \end{figure} } These results prompted a further investigation through visualization, where we plot the values of the loss as the direction of the gradient is followed from a data point. This is done for several data points, for which the mean and standard deviation are shown in Table \ref{plotAlongGrad}, allowing us to inspect a cross-section of the loss surface. This cross-section gives us an intuition as to what is happening in gradient masked networks which will be useful in motivating our metrics. For an undefended model, as we move in the direction of the gradient, the loss quickly increases, and remains high - a gradient based attack that follows this direction will surely find an adversarial example. For a defended network with no masked gradients, following this same direction yields a much smaller increase in the loss - the fact that the decision boundary has been pushed further out from the point demonstrates that robustness has been gained. For a network with masked gradients, we see a sharp increase in the loss near the data points, followed by a very rapid decrease. This sharp increase prompts gradient based methods to follow this direction, which ends up proving to be a very poor one to increase the loss in the long term. Thus, single-step methods, which must follow this initial direction, are left helpless. Despite thwarting single-step attacks, the SPSA results show that these models fail to truly become more robust. \begin{comment}We see a sharp increase in the loss near the data points in (c) and (d), followed by a very rapid decrease. This sharp increase prompts gradient based methods to follow this direction, which ends up proving to be a very poor one to increase the loss in the long term. Thus, single-step methods, which must follow this initial direction, are left helpless. Despite thwarting single-step attacks, the SPSA results show that these models fail to truly become more robust. (f), (g), (h), (i) also appear to be less smooth than other models, potentially indicating some gradient masking. The gradient clipped model shown in (k) shows a particularly different result. It is clarifying to look at the pale blue lines, showing plots for a few individual data points. We see that, for many of these plots, the loss sharply increases to around the same value, from where it simply plateaus. Plots from other data points that do not follow this trajectory are instead very irregular, showing a highly non-linear loss surface which characterizes gradient masked models \cite{ensemble}. \end{comment} These observations suggest that networks with masked gradients have abnormal loss surfaces. Measuring these abnormalities may be a way to identify the extent of gradient masking. We explore different ways to make this measurement in the next section. \begin{comment} { \centering \begin{figure}[ht] \includegraphics[width=0.5\linewidth]{figures/Test_benchmarks_plot.png} \caption{FGSM and Random Attack test accuracy at varying $\epsilon$. The random attack consists of choosing a point on the L-$\infty$ ball determined by $\epsilon$ uniformly at random.} \label{FGSM Random} \end{figure} } \end{comment} \input{figures/plot_along_grad_3} \subsection{Limitations and Project Goal} While the behaviours described in \citep{obfuscated} can serve as a checklist to confirm whether the network under consideration suffers from gradient masking, they are quite crude tools for the task. Looking for certain characteristic behaviours in a checklist manner is inherently opaque, not providing insights into what is happening to the loss surface in gradient masked networks. Furthermore, these tests are mostly binary in output, disregarding the extent to which gradient masking takes place. This leads to a further problem in establishing insightful comparisons between models and evaluating potential proposed improvements to defenses with regard to gradient masking. These methods are also very time consuming, with black box attacks in particular tending to require excessive computational resources and being very sensitive to the chosen hyperparameters. As for the measures mentioned by \citet{ensemble}, sufficient empirical evidence and results on different defenses are lacking to establish their usefulness beyond interesting figures. \subsection{Limitations} One limitation of these metrics is that they cannot be considered architecture agnostic - the values achieved by the same defense on a certain metric may vary according to the architecture it is employed on. Thus, for each neural network architecture being considered, a reliable benchmark from a robust model must first be established. We do not consider this a serious limitation as, realistically, there are relatively few network architectures used at the state-of-the-art across different tasks, and, once such a robust network exists, computing its score on these metrics is very fast. (should I remove this paragraph?) Another concern is that some of these metrics may not apply universally. Indeed, they are not based on hard theoretical evidence, but rather intuition and empirical results. For instance, while models that use gradient masking as a strategy will be less linearizable, a priori, a model that is not linearizable is not necessarily not robust. Metrics like the Linearization Error or PGD collinearity may indicate that a network's gradients are masked. However, research has shown that model robustness can be associated with models that are more "quasi-linear" around the data points \cite{CURE}. Our own results across these metrics support the idea that highly non-linear loss surfaces are in general not desirable or usual in a neural network. \begin{comment} \subsection{Best Performing Metrics} We consider \textbf{FGSM PGD cosine similarity} and \textbf{PGD collinearity} to be the most accurate discriminators of the gradient masked networks we tried. Both appear to be able to effectively capture properties of the loss surface of gradient masked networks, with the marked defenses achieving values which are considerably lower than the remaining ones. Another positive sign is that models that scored well on these metrics also had the highest accuracy against PGD attacks, arguably the strongest in our arsenal. Additionally, both metrics discriminate networks equally well on training and testing data. On the cosine similarity metric, all gradient masking models appear with values not only much smaller than the PGD benchmark, but also significantly smaller than the undefended model, which we consider to be positive. As for PGD collinearity, it is important to understand the low result for the undefended model within the context given by Figure \ref{plotAlongGrad}. The score tells us that, at some point, the direction given by the gradient at the data point becomes suboptimal to increase the loss, so, PGD changes from this direction. However, as we can see in Figure \ref{plotAlongGrad}, this direction is still informative enough to lead to a good increase in the loss, often finding adversarial examples. Thus, the model is not gradient masking. With other cases, for example, Step-ll with $\epsilon = 16/255$, the value on this metric is low, and the gradient direction is not informative enough to lead to an increase in the loss, suggesting that the direction of the gradient is misleading. With the PGD defense, the gradient direction similarly does not lead to an increase in the loss, but PGD collinearity is high, suggesting that the direction is not misleading, rather, the model has truly achieved some form of robustness. \subsection{Gradient Norm} Regarding the Gradient Norm metric, on training data, single step methods have a significantly higher value than PGD, being clearly discriminated by this metric. However, Jacobian regularization models appear at similar levels to step-ll with a large $\epsilon$, suggesting the potential for false positives. Furthermore, all models appear with norms much larger than the undefended model, except for the gradient clipped trained model, which is actually smaller. On testing data, the results are drastically different. The metric now clearly exposes the gradient clipped model as gradient masking, and shows a large difference between Jacobian regularization and gradient masking models. However, the undefended model scores very similarly to step-ll with a large $\epsilon$, and above gradient clipped. \subsection{Linearization Error} Using the PGD trained model as a benchmark, the Linearization Error metric with an $\epsilon = 16/255$ very clearly exposes the gradient clipped model as well as single step defenses with large epsilons as gradient masking, especially using test data. However, it is somewhat concerning that an FGSM defense with large steps outperforms PGD in this metric. Furthermore, once again, Jacobian regularization methods are grouped with gradient masking networks under this metric, and the undefended model is measured at a very high value. \end{comment}
{'timestamp': '2022-04-12T02:27:37', 'yymm': '2204', 'arxiv_id': '2204.04778', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04778'}
arxiv
\section{Introduction} \label{sec:introduction} The independence polynomial, also known as the partition function of the hard core lattice gas in the statistical physics literature, is the graph polynomial given by \begin{displaymath} Z_G(\lambda) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \sum_{I:\text{independent set in $G$}}\lambda^{|I|}. \end{displaymath} An independent set in a graph $G$ is subset of its vertices no two of which are adjacent in $G$. In statistical mechanics, the polynomial arises in the modeling of adsorption phenomena (usually with $G$ being a lattice); while in combinatorics, it is the natural generating function of independent sets of graphs, and offers a natural generalization to the problem of counting independent sets in a graph. These connections have led to the polynomial being studied extensively in the setting $\lambda > 0$, both in statistical physics and in computational complexity, and, in particular, has led to some very tight connections between the two fields~\cite{sly12,Weitz}. The setting $\lambda < 0$, and more generally, of complex $\lambda$ is also of interest. In particular, the problem of understanding where the complex zeros of $Z_G$ lie for graphs $G$ in a given class is of special interest. In statistical mechanics, it relates to the Yang-Lee theory of phase transitions~\cite{leeyan52}. In the special case when $G$ is a lattice, the work of Dobrushin and Shlosman~\cite{DS85,DS87} also related the question to other, more probabilistic notions of phase transitions. In combinatorics, the behavior of $Z_G$ at negative and complex $\lambda$ plays an important role in the study of the Lov\'asz local lemma; for a detailed discussion of this connection, we refer to the work of Shearer~\cite{shearer_problem_1985} as elucidated by Scott and Sokal~\cite{ScottSokal}. For our purposes, we start with the following result proved in the above two papers. We denote by $\mathcal G_\Delta$ the set of finite graphs with vertex degrees at most $\Delta$, for some fixed $\Delta \geq 3$. \begin{theorem}[\textbf{see~\cite{shearer_problem_1985,ScottSokal}}] Let $d \geq 2$ be an integer. If $\lambda \in \mathbb{C}$ is such that $\abs{\lambda} \leq \lambda^*(d) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{d^d}{(d + 1)^{d+1}}$ then $Z_G(\lambda) \neq 0$ for all graphs $G \in \mathcal G_{d+1}$. Further, for any negative real $\lambda_1 < -\lambda^*(d)$, there exists a graph $G \in G_{d+1}$ and $\lambda'$ satisfying $\lambda_1 < \lambda' < -\lambda^*(d)$ such that $Z_G(\lambda') = 0$.\label{thm:shearer} \end{theorem} The above theorem gives a full description of the zero-free region of $Z_G$, as $G$ varies over $\mathcal G_{d+1}$, on the negative real line. However, fully characterizing this zero-free region in the complex plane remains open. Nevertheless, significant progress has been made in recent years. Peters and Regts~\cite{peters_conjecture_2019}, in their work on proving a conjecture of Sokal, considered $Z_G$ as $G$ varies over spherically symmetric $d$-ary trees, and proved that it is non zero as long as $\lambda \in U_d$, where $U_d$ is the open region containing the origin bounded by the curve \begin{equation} \partial U_d \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \inb{\left.\kappa(\alpha) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{-\alpha d^d}{(d + \alpha)^{d+1}} \right\vert \abs{\alpha} = 1}.\label{eq:12} \end{equation} Perhaps the first natural question to ask is whether this region is zero-free for $Z_G$ even as $G$ varies over \emph{all} graphs in $\mathcal G_{d+1}$. The answer to this is no: Buys~\cite{buys_location_2019} showed that one can obtain a counterexample for $3\le d+1\le 9$ by considering spherically symmetric trees in which the arity of each vertex depends upon the distance from the root of the tree. Let $\lambda_c(d) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{d^d}{(d - 1)^{d + 1}}$ be the unique point of intersection of the curve $\partial U_d$ with the positive real line. Peters and Regts~\cite{peters_conjecture_2019} showed that for any positive $\lambda' < \lambda_c(d)$, there is an $\epsilon' = \epsilon'(\lambda') > 0$ such that for any $z$ satisfying $\abs{\Im z} \leq \epsilon'$ and $\Re z = \lambda'$, $Z_G(z) \neq 0$ for all $G \in \mathcal G_{d+1}$. They also gave explicit lower bounds on $\epsilon'(\lambda')$ for $\lambda' \in (0, \tan (\pi/(2d)))$ (note that $\tan (\pi/2(2d)) > \lambda^*(d)$ for $d \geq 2$, so these results are not implied by \Cref{thm:shearer}). Bencs and Csikv\'ari~\cite{bencs18:_note}, using different methods, improved on the latter lower bounds, and thereby significantly extended the known zero-free region inside $U_d$ in the right half-plane. However, these results did not provide any new zero-free regions in the left half-plane beyond the half-disk in \Cref{thm:shearer}. The problem of understanding the location of zeros in $U_d$ of the independence polynomial of graphs in $\mathcal G_{d+1}$ has also become of interest in computational complexity theory. Polynomial time approximation algorithms for $Z_G(\lambda)$ for $G \in \mathcal G_{d+1}$ and $\abs{\lambda} < \lambda^*(d)$ where given by Patel and Regts~\cite{patel2017deterministic} and Harvey, Srivastava and Vondr\'ak~\cite{10.5555/3174304.3175407}. Using the results of Peters and Regts~\cite{peters_conjecture_2019} on the existence of zeros near the boundary of $\partial U_d$, Bezáková, Galanis, Goldberg, and Štefankovič~\cite{Bezakova_Inapproximability_2018} showed that for every $\lambda$ outside the closure of $U_d$, the problem of approximating $Z_G(\lambda)$ for graphs $G$ in $\mathcal G_{d+1}$ is NP-hard. On the other hand, due to the results of Barvinok~\cite{barvinok2017combinatorics} and Patel and Regts~\cite{patel2017deterministic}, the same problem admits a polynomial time algorithm for any complex rational $\lambda$ if for some $\epsilon > 0$, the $\epsilon$-neighborhood of the line segment $[0, \lambda]$ is zero-free for the polynomials $Z_G$ for all $G \in \mathcal G_{d+1}$. More recently, de Boer, Buys, Guerini, Peters, and Regts~\cite{de2021zeros} establish strong formal connections between computational complexity of the hard core model, complex dynamics, and zero-freeness of the partition function (see Main Theorem of~\cite{de2021zeros}): in particular they prove that the zeros of $Z_G$ for graphs in $\mathcal G_{d+1}$ are dense in the complement of $U_d$. The limit shapes of the zero-free regions have also been studied: Bencs, Buys, and Peters~\cite{bencs2021limit} show that in the $d\to \infty$ limit, a rescaled version of zero-free region tends to a bounded 0-star shaped region, whose boundary intersects $\lim_{d\to \infty}d\cdot \partial U_d$ only at real parameters. In particular, the results of~\cite{bencs2021limit} show that for large enough $d$ the zero-free region is strictly contained in $U_d$ except for the two real parameters. However, the problem of explicitly describing the zero-free region of $Z_G$ for $G\in\mathcal G_{d+1}$ in the complex plain still remains open. \subsection{Contributions} In this paper, we give two geometric criteria (\Cref{thm:Simons-result,thm:init-curve}) which together give a framework for rigorously establishing (connected) zero-free regions as well as a way to carry out semi-rigorous numerical explorations. We provide several examples of the (rigorous) use of these criteria. We establish two new zero-free regions in the left half plane: \Cref{thm:critical-vicinity} gives a better result in the vicinity of the negative real line, while \Cref{thm:lhp} gives a better result near the imaginary line. When restricted to the imaginary axis, the latter region agree with the result of Bencs and Csikv\'ari~\cite{bencs18:_note} for the right half-plane. We also improve upon the previous zero-freeness results of Bencs and Csikv\'ari~\cite{bencs18:_note} for the right-half plane using the geometric criteria developed in this paper (\cref{lem:righthalfplane_better}, see also \cref{rem:right-improvement}). Following the template provided by the results of Barvinok~\cite{barvinok2017combinatorics} and Patel and Regts~\cite{patel2017deterministic}, these new zero-freeness results also immediately lead to new polynomial-time algorithms for the approximation of $Z_G(\lambda)$ for $\lambda$ lying in the interior of these regions on graphs $G \in \mathcal G_{d+1}$ of maximum degree at most $d + 1$. We also show that our framework gives a new proof of the Sokal conjecture, which was first proved by Peters and Regts via a potential function argument~\cite{peters_conjecture_2019} (\Cref{thm:sokal-conj}). \begin{figure}[h!] \centering \includegraphics[width=0.8\textwidth]{images/new_regions} \caption{New zero free regions for $d=9$ (graphs of degree at most $10$). In the left half plane, the red region corresponds to \cref{thm:critical-vicinity}, while the blue region corresponds to \cref{thm:lhp}. In the right half plane, the yellow region corresponds to \cref{lem:righthalfplane_better}. The smaller grey circle around the origin has radius $\lambda^*(d)$, and the points $\pm\iota\tan(\pi/(2d))$ are marked on the imaginary axis. The outer black ``cardioid-shaped'' curve is the boundary $\partial U_d$ as defined in \cref{eq:12}. A magnified version of the red region (corresponding to \cref{thm:critical-vicinity}) is given in \Cref{fig:1}.} \label{fig:d9} \end{figure} \subsection{Organization of the paper.} After a short section of preliminaries, in Section~\ref{relaxed_recurrence} we introduce various simple criterions to prove that a $\lambda \in \mathbb{C}$ is in the zero-free region of independence polynomial of graphs of bounded degree. Building on this work in Section~\ref{sec:crit-orig-compl} we introduce two new criteria in terms of curves to prove zero-free regions. The remaining sections are direct applications of these criterions, and are independent of each other. Since some of the proofs are somewhat technical, these sections are arranged in increasing order of difficulty. In Section~\ref{sec:sokal-conjecture} we give a new proof of Sokal's conjecture originally proven by Peters and Regts. In Section~\ref{sec:zero-free-region-negative-real-line} we give a new zero-free region in the vicinity of the critical point $\frac{d^d}{(d+1)^{d+1}}$. In Section~\ref{sec:zero-free-region-imaginary-axis} we provide a zero-free region close the imaginary axis. Finally, in Section~\ref{sec:right-half-plane} we prove a zero-free region in the right half plane. For those readers who are interested in the ideas in general, but want to avoid technical difficulties we recommend reading the paper till the end of Section~\ref{sec:sokal-conjecture} and omitting Theorem~\ref{thm:Simons-result} and its proof. \section{Preliminaries} \subsection*{Branch cuts} We adopt the following convention for defining fractional powers and complex logarithms. Given $z = re^{\iota \theta}$ with $r > 0$ and $\theta \in (-\pi, \pi]$, we define \begin{align} \log z &\,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \log r + \iota \theta\text{, and}\label{eq:5}\\ z^\delta &\,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil r^{\delta}\exp(\iota \delta \theta)\text{, for any $\delta > 0$}.\label{eq:6} \end{align} We leave the functions undefined when $z = 0$ (except that we adopt the usual convention that $0^0 = 1$). Note that with the above definition, $\log$ and $z^\delta$ for non-integral $\delta$ are defined but discontinuous on the negative real line. However, we do have the following identity for all $z \neq 0$ and $\delta \geq 0$: \begin{displaymath} z^\delta = \exp(\delta \log z). \end{displaymath} Further, for $z \neq 0$, we use the convention $\arg z = \Im (\log z)$. \section{A relaxed recurrence for the independence polynomial} \label{relaxed_recurrence} We study the possible location of the complex roots of the (univariate) independence polynomial, $$ Z_G(\lambda) = \sum_{I \subseteq V(G) \mbox{ independent}} z^{|I|}.$$ We focus on the class of graphs $\mathcal G_\Delta$ with degrees at most $\Delta$ for some fixed $\Delta \geq 3$. We also set $d = \Delta-1$. From previous work, we know the following characterization. \begin{definition} For $\lambda \in \mathbb C$, define $S_\lambda \subseteq \mathbb C$ as the set of points that can be generated by the following rules: \begin{itemize} \item $0 \in S_\lambda$, \item If $z_1,\ldots,z_d \in S_\lambda$ are such that $z_i \neq -1$ for $1\leq i \leq d$, then \begin{equation} \label{eq:basic-recurr} f(z_1,\ldots,z_d) = \frac{\lambda}{\prod_{i=1}^{d} (1+z_i)} \end{equation} is also in $S_\lambda$. \end{itemize} \end{definition} (The definition of $S_\lambda$ depends on $d$ which we omit from the notation.) The following lemma is well known, and has been used in previous work on the subject (e.g.~\cite{peters_conjecture_2019,bencs18:_note}). See especially the work of Bencs~\cite{bencs_trees_2018}, where a more precise version of this is proved. \begin{lemma} \label{original} $Z_G(\lambda) = 0$ for some graph $G \in \mathcal G_{d+1}$ if and only if $-1 \in S_\lambda$. \end{lemma} A standard application of Lemma~\ref{original} is to define a trapping region $T_{\lambda}$ such that $0\in T_{\lambda}$, $-1\notin T_{\lambda}$ and $f$ maps $T_{\lambda}^d$ to $T_{\lambda}$. For instance, if $|\lambda|\leq \frac{d^d}{(d+1)^{d+1}}$, then $T_{\lambda}=\{z \in \mathbb C\ |\ |z|\leq \frac{1}{d+1}\}$ is such a region: $$\left|\frac{\lambda}{\prod_{i=1}^d(1+z_i)}\right|\leq \frac{d^d}{(d+1)^{d+1}}\prod_{i=1}^d\frac{1}{1-\frac{1}{d+1}}=\frac{1}{d+1}$$ showing Shearer's result. In general, it is not easy to handle $d$ variables at the same time. So in what follows we try to find sufficient conditions that only require the understanding of a univariate map. \bigskip In the following, we relax the recurrence $f(z_1,\ldots,z_d)$ to allow fractional powers and more than $d$ arguments. As we will see, this in fact leads to a simplification of the problem. \begin{definition} For $\lambda \in \mathbb C$, define $\tilde{S}_\lambda \subseteq \mathbb C$ as the set of points that can be generated by the following rules: \begin{itemize} \item $0 \in \tilde{S}_\lambda$, \item If $z_1,\ldots,z_k \in \tilde{S}_\lambda$ and $\delta_1,\ldots,\delta_k \geq 0$ are such that $\sum_{i=1}^{k} \delta_i \leq d$ and $z_i \neq -1$ for $1 \leq i \leq k$, then \begin{equation} \label{eq:ext-recurr} f_{\delta_1,\ldots,\delta_k}(z_1,\ldots,z_k) = \frac{\lambda}{\prod_{i=1}^{k} (1+z_i)^{\delta_i}} \end{equation} is also in $\tilde{S}_\lambda$. \end{itemize} \end{definition} Clearly, we have $S_\lambda \subseteq \tilde{S}_\lambda$, since the new generation rule subsumes $f(z_1,\ldots,z_d)$. Hence we obtain the following. \begin{lemma} If $-1 \notin \tilde{S}_\lambda$, then $Z_G(\lambda) \neq 0$ for every $G \in \mathcal G_{d+1}$. \end{lemma} The main advantage of the relaxed recurrence is that it allows us to replace the multivariate recurrence by a univariate one. We do this as follows: Consider the set $\{ \log (1+z): z \in \tilde{S}_\lambda \}.$ Note that this is well defined if $-1 \not \in \tilde{S}_\lambda$. If we write $w_i = \log (1+z_i)$, then the recurrence $$f_{\delta_1,\ldots,\delta_k}(z_1,\ldots,z_k) = \frac{\lambda}{\prod_{i=1}^{k} (1+z_i)^{\delta_i}} $$ can be rewritten by substitution as $$ g_{\delta_1,\ldots,\delta_k}(w_1,\ldots,w_k) = \log (1 + f_{\delta_1,\ldots,\delta_k}(e^{w_1}-1,\ldots,e^{w_k}-1)) $$ $$ = \log \left(1 + \lambda \prod_{i=1}^{k} e^{-\delta_i w_i} \right) = \log \left( 1 + \lambda e^{-\sum_{i=1}^{k} \delta_i w_i} \right).$$ Hence, a combination of fractional powers in $f_{\delta_1,\ldots,\delta_k}$ corresponds to a linear combination of the points $w_i = \log (1+z_i)$. If we normalize the linear combination by $\frac{1}{d}$, and use the fact that $0$ is always a possible choice for $w_i$, we obtain a convex linear combination of $w_1,\ldots,w_k$ in the exponent. This motivates the following characterization. Note that the characterization is in terms of the behavior of a function of only one complex variable. \begin{theorem} \label{thm:w-criterion} The number $-1$ is not contained in $\tilde{S}_\lambda$ if and only if there is a convex set $T \subset \mathbb C$ containing $0$ such that for every $w \in T$, $$ g(w) = \log (1 + \lambda e^{-dw}) $$ is well-defined and $g(w) \in T$. \end{theorem} \begin{proof} Suppose first that $-1 \not\in \tilde{S}_\lambda$. We define \begin{displaymath} T = \conv{\log(1+z) | z \in \tilde{S}_\lambda}. \end{displaymath} Note that since $-1 \not\in \tilde{S}_\lambda$, $T$ is well-defined, and further, is convex by definition. Also, $0 \in T$, since $0 \in \tilde{S}_\lambda$. Now consider $w \in T$. By Caratheodory's theorem, there exist $\delta_1, \delta_2, \delta_3 \geq 0$ summing up to $d$, and $z_1, z_2, z_3 \in \tilde{S}_\lambda$, such that $w = \frac{1}{d}\sum_{i=1}^3\delta_i\log(1+z_i)$. We thus have $\lambda\exp(-dw) = f_{\delta_1, \delta_2, \delta_3}(z_1, z_2, z_3) \in \tilde{S}_\lambda$. Thus, $\lambda\exp(-dw) \neq -1$ and hence $g(w) = \log (1 + \lambda\exp(-dw))=\log(1+f_{\delta_1, \delta_2, \delta_3}(z_1, z_2, z_3))$ is well-defined and lies in $T$. Conversely, suppose that $T$ is a convex set containing $0$, on which the map $g(w) = \log (1 + \lambda \exp(-dw))$ is well defined, and satisfies $g(w) \in T$ for all $w \in T$. We claim that if $-1 \in \tilde{S}_\lambda$, then there exists $w \in T$ such that $-1 = \lambda\exp(-dw)$. To see this, define the \emph{depth} of every $z\in \tilde{S}_\lambda$ as follows: $\mathrm{depth}(0) = 0$, and for $z \neq 0$, $\mathrm{depth}(z)$ is the smallest integer $D$ such that $z$ can be written as $f_{\delta_1, \delta_2, \dots, \delta_k}(z_1, z_2, \dots, z_k)$ where $k$ is a positive integer, $\delta_i \geq 0$ sum to at most $d$, and $z_i \in \tilde{S}_\lambda$ have depth at most $D-1$. Note that $\mathrm{depth}(z) \geq 1$ for $z \neq 0$. Now, if $-1 \in \tilde{S}(\lambda)$, let $D_{-1} = \mathrm{depth}(-1)$. We claim now that for all $z \in \tilde{S}_\lambda$ of depth at most $D_{-1} - 1$, $\log(1+z) \in T$. This is proved by induction on the depth of $z$: it is true in the base case $\mathrm{depth}(z) = 0$ (so that $z = 0$), since $0 \in T$. Otherwise, from the definition of depth, we can find $z_1, z_2, \dots z_k$ of depth strictly smaller than $z$, and $\delta_i \geq 0$ summing up to at most $d$, such that \begin{equation} z = f_{\delta_1, \delta_2, \dots, \delta_k}(z_1, z_2, \dots, z_k) = \lambda\exp\inp{-d\sum_{i=1}^k\frac{\delta_i}{d}\log(1+z_i)}.\label{eq:7} \end{equation} Thus, we have $\log(1 + z) = g(w)$ where $w$ is a convex combination of $0$ and the quantities $\log(1 + z_i)$. The latter quantities are all inductively in $T$, so that $w$ is also in $T$ (as $T$ is convex). But since $T$ is closed under applications of $g$, this implies that $g(w) = \log(1+z)$ is also in $T$. This establishes the claim. Using the claim, we conclude that there exists a $w \in T$ such that $-1 = \lambda\exp(-dw)$. But this contradicts the hypothesis that $g(w) = \log(1 + \lambda\exp(-dw))$ is well-defined on $T$. Thus, it cannot be the case that $-1 \in \tilde{S}_\lambda$. \end{proof} For natural reasons, we call a $T$ as in the statement of the above theorem a {\em trapping region} for $\lambda$. \ {\em Remark:} Sometimes it is desirable to avoid $-1$ even in the closure of $S_\lambda$, or $\tilde{S}_\lambda$. By our transformation, this corresponds to the property that there is a convex set $T$ containing $0$ and closed under $g(w) = \log (1 + \lambda e^{-dw})$, such that $\Re(w) \geq -K$ for every $w \in T$ and some constant $K>0$. This is equivalent to saying that every point $z \in \tilde{S}_\lambda$ satisfies $|1+z| \geq e^{-K}$. \section{Criterion in the original complex plane} \label{sec:crit-orig-compl} The previous section shows that we get a rather clean picture when we study the behavior of the extended recurrence (\cref{eq:ext-recurr}) after a change of variable, $w = \log (1+z)$. However, we can also formulate a criterion using trapping regions in the original variable $z$. This criterion looks more intuitive, but it seems we lose a bit in the transition (in particular, we do not get an equivalence here). \begin{theorem} \label{thm:z-criterion} If there is a convex set $S \subset \mathbb C$ containing $0$, not containing $-1$, such that $f(z) = \frac{\lambda}{(1+z)^d} \in S$ for every $z \in S$, then $Z_G(\lambda) \neq 0$ for every $G \in \mathcal G_\Delta$. \end{theorem} In order to prove this statement, we need the following fact about the behavior of arithmetic vs.~geometric averages in the complex plane. While we believe this fact to be standard, we are unable to find an exact reference, and hence provide a proof for completeness.\footnote{Note that, despite the title, the lemma does not contradict the usual inequality between the arithmetic and the geometric means of positive reals. The lemma is in fact a trivial statement for the case of positive reals.} \begin{lemma}[``geometric averages dominate arithmetic averages''] \label{lem:AMGM} For any two points $z_1, z_2 \in \mathbb C \setminus \{0\}$ satisfying $\abs{\arg(z_1) - \arg (z_2)} \leq \pi$, and $\alpha \in [0,1]$, there exist $\beta \in [0,1]$ and $t \in [0,1]$ such that $$ t z_1^\alpha z_2^{1-\alpha} = \beta z_1 + (1-\beta) z_2.$$ \end{lemma} \begin{proof} We reduce to the case where $z_2 = 1$, by dividing by $z_2$ and substituting $z = z_1/z_2$. Our goal then is to find $t, \beta \in [0,1]$ such that $$ t z^\alpha = \beta z + (1-\beta).$$ We can also assume that $\arg z \in [0, \pi]$, by complex conjugation if this is not the case. Now, if $\arg z = 0$ the claim is trivially true because, then, if $z = \Re z \geq 1$, we can take $\beta = 0, t = z^{-\alpha}$, while when $0 < z = \Re z < 1$, we can take $\beta = 1, t = z^{1-\alpha}$. Similarly, when $\arg z = \pi$, $z$ is a strictly negative real number, so that we can choose $t = 0$ and $\beta = \frac{1}{1-z} \in [0, 1]$. We can thus assume that $ \theta \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \arg(z) \in (0,\pi)$ and $r \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \abs{z} > 0$. Note that $\arg(z^\alpha) = \alpha\theta$. Let $y(\alpha)$ be the unique point with argument $\alpha\theta$ on the line segment joining $1$ and $z$. From an elementary geometric argument, we then have \begin{displaymath} \abs{y(\alpha)} = \frac{r \sin \theta}{r\sin((1-\alpha)\theta) + \sin \alpha\theta}. \end{displaymath} We now define the function $f(x): [0, 1] \rightarrow \R$ as \[f(x) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \log \frac{\abs{y(x)}}{\abs{z^x}} = \log \frac{r^{1-x}\sin \theta}{r\sin((1-x)\theta) + \sin x\theta}. \] Note that the claim of the lemma is equivalent to showing that $f(x) \leq 0$ for all $x \in [0, 1]$ (the quantity $t$ can then be taken to $e^{f(\alpha)} \in [0,1]$ and $\beta \in [0,1]$ is such that $\beta z + 1 - \beta = y(\alpha)$). To this end, we first note that $f(0) = f(1) = 0$, so the claim would follow if $f$ is convex on $[0, 1]$. We verify this by directly computing the second derivative of $f$ and checking that it is non-negative in $[0, 1]$: \begin{displaymath} f''(x) = \frac{\theta^2 (1 + r^2 - 2r \cos \theta)}{\inp{r\sin((1-x)\theta) + \sin x\theta}^2} \geq 0, \text{ when $x \in [0, 1]$}.\qedhere \end{displaymath} \end{proof} \begin{proof}[Proof of \cref{thm:z-criterion}] Suppose that there is a convex set $S$ containing $0$, not containing $-1$, and closed under the map $f(z) = \frac{\lambda}{(1+z)^d}$. We will transform $S$ into a convex set $T$ satisfying the assumptions of \cref{thm:w-criterion}. Define $$ T = \conv{\log (1+z): z \in S}.$$ By construction, $T$ is convex and it contains $0$ (since $0 \in S$). We need to prove that $g(w) = \log (1+\lambda e^{-dw})$ is well-defined on $T$ and preserves membership in $T$. Consider $w \in T$, i.e., $w = \sum_{i=1}^{k} \alpha_i \log (1+z_i)$, a convex combination of points $\log (1+z_i)$ such that $z_i \in S$. We can set $\delta_i = d \alpha_i$, hence $w = \frac{1}{d} \sum_{i=1}^{k} \delta_i \log (1+z_i)$. Then, $$ g(w) = \log (1 + \lambda e^{-dw}) = \log \left(1 + \frac{\lambda}{\prod_{i=1}^{k} (1+z_i)^{\delta_i}} \right).$$ Now, we appeal to \cref{lem:AMGM}. Note first that $1 + S \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \inb{1 + z \vert z \in S}$ is a convex set containing $1$ and not containing $0$, so that by the separating hyperplane theorem, all of $1 + S$ lies in a halfplane defined by a line passing through $0$, and therefore $\abs{\arg(1 + u) - \arg(1 + v)} \leq \pi$ is true for all $u, v \in S$. Now, we take one pair $z_i, z_j$ of points at a time, and consider $u_{ij} = (1+z_i)^{\frac{\delta_i}{\delta_i+\delta_j}} (1+z_j)^{\frac{\delta_j}{\delta_i+\delta_j}}$. By \cref{lem:AMGM}, there is $\beta \in [0,1]$ such that $1+z_{ij} = \beta (1+z_i) + (1-\beta) (1+z_j)$ is a point of the same argument and smaller-or-equal modulus as $u_{ij}$. Hence we can replace both $z_i$ and $z_j$ by $z_{ij}$ and continue. We maintain the property that the argument of $\prod (1+z_i)^{\delta_i}$ remains preserved and the modulus can only decrease. Eventually, we obtain a point $\tilde{z} \in \conv{z_1,\ldots,z_k} \subseteq S$ such that $\arg((1+\tilde{z})^d) = \arg(\prod (1+z_i))$ and $|(1+\tilde{z})^d| \leq | \prod (1+z_i) |$. Hence, we can write $$ g(w) = \log \left( 1 + \frac{c\cdot \lambda}{(1+\tilde{z})^d} \right),$$ where $c \leq 1$ is a non-negative real number. Now, note that since $\tilde{z} \in S$, we have $f(\tilde{z}) = \frac{\lambda}{(1 + \tilde{z})^d} \in S$, as $S$ is closed under applications of $f$. Then, since $0 \in S$, and $S$ is convex, we get $y \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{c\cdot \lambda}{(1+\tilde{z})^d} \in S$, and further that $y \neq -1$, as $-1 \not\in S$. Thus, by definition of $T$, $g(w) = \log (1 + y) \in T$, as $y \in S$. This proves that $T$ satisfies the assumptions of \cref{thm:w-criterion} and hence $-1$ is not contained in $\tilde{S}_\lambda$, which implies that $Z_G(\lambda) \neq 0$. \end{proof} Next, we present a more abstract extended version of this criterion, where we allow a ``convex'' initial segment $h(t), t \in [0,1]$ rather than a line segment. First we define the following notion: \begin{definition} \label{def:-1-cover} A point $z \in \mathbb C$ is \emph{$-1$-covered} by $z' \in \mathbb C$ if $\arg(1+z) = \arg(1+z')$ and $|1+z| \geq |1+z'|$. More generally, a set $T$ is $-1$ covered by a set $S$ if for every $z \in T$, there is a point $z' \in S$ such that $z$ is $-1$-covered by $z'$. \end{definition} \noindent Geometrically, the above notion captures $z$ being ``covered'' by $z'$ when ``viewed'' from the point $-1$. The utility of this definition for our purposes comes from the following simple observation. \begin{observation} \label{obv:covering} Fix an integer $d \geq 2$ and a $\lambda \in \mathbb{C}$, and consider $f(z) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{\lambda}{(1 + z)^d}$. If $z\in \mathbb{C}$ is $-1$-covered by $w \in \mathbb{C}$, then $f(z) = \alpha f(w)$ for some $\alpha \in [0, 1]$. \end{observation} \begin{proof} If $\lambda = 0$, there is nothing to prove, so assume $\lambda \neq 0$. Since $z$ is $-1$-covered by $w$, we have $\abs{1 + z} \geq \abs{1 + w}$ and $\arg (1+w) = \arg(1+z)$. It follows that $\arg(f(z)) = \arg(f(w))$, and $\abs{f(z)} \leq \abs{f(w)}$. Thus, $f(z)$ lies on the segment joining the origin to $f(w)$, and the claim follows. \end{proof} Next we prove a criterion that we will use in the subsequent sections. \begin{theorem} \label{thm:init-curve} For $\lambda \in \mathbb C$, assume that there is a curve $\{ h(t): t \in [a,b]\}$, where $a < b$ are real numbers, such that \begin{itemize} \item $h(t) = 0$ for some $t \in [a,b]$, \item $\arg(1+h(t))$ is strictly increasing for $t \in [a,b)$, \item $h(t)$ is ``convex'' in the sense that for any $t_1,t_2 \in [a,b], \alpha \in [0,1]$, $\alpha h(t_1) + (1-\alpha) h(t_2)$ is $-1$-covered by $h(t)$ for some $t \in [t_1,t_2]$. \item for every $t \in [a,b]$, $f(h(t)) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{\lambda}{(1+h(t))^d}$ is $-1$-covered by $h(t')$ for some $t' \in [a,b]$. \end{itemize} Then $Z_G(\lambda) \neq 0$ for any $G \in \mathcal G_{d+1}$. \end{theorem} We remark that it is possible to prove \cref{thm:Simons-result} from this theorem by considering the curve from the proof of \cref{thm:Simons-result} on the interval $[0,\tau]$. The curve in \cref{thm:init-curve} represents the portion of the curve in \cref{thm:Simons-result} ``visible from $-1$"; i.e., the points $h(t)$ that are not $-1$-covered by any other point $h(t')$. \begin{proof} By an affine reparametriztion of the curve $h$, if necessary, we assume that $a = 0$ and $b = 1$. Given the curve $h(t), t \in [0,1]$, we define a trapping region, in the sense of \Cref{thm:z-criterion}, as a ``shadow of the curve $h(t)$ when illuminated from the point $-1$": $$ S = \{z \in \mathbb C: \exists t \in [0,1] \textrm{ such that } z \mbox{ is $-1$-covered by } h(t) \}.$$ This is a convex set, since for any $z_1, z_2 \in S$, $z_1$ and $z_2$ are $-1$-covered by $h(t_1), h(t_2)$ respectively, $z = \alpha z_1 + (1-\alpha) z_2$ is $-1$-covered by $z'= \alpha' h(t_1) + (1-\alpha') h(t_2)$ (for some $\alpha' \in [0, 1]$), and $z'$ in turn is covered by $h(t)$ for some $t \in [t_1,t_2]$ by the convexity of $h(t)$. Also, $0$ is contained in $S$ because $h(t) = 0$ for some $t \in [0,1]$; $-1$ is not contained in $S$, since $0$ is the only real value on the curve $h(t)$ (this follows since $\arg (1 + h(t))$ is assumed to be a strictly increasing function of $t$), so that $S$ contains only nonnegative real numbers. To apply \Cref{thm:z-criterion} in order to conclude the proof, it remains to prove that $S$ is closed under the map $f(z) = \frac{\lambda}{(1+z)^d}$. For any $z \in S$, there is a $t \in [0,1]$ such that $z$ is $-1$-covered by $h(t)$. \Cref{obv:covering} then implies that $f(z) = \alpha f(h(t))$ for some $\alpha \in [0, 1]$. By the assumptions of the theorem, we know that $f(h(t))$ is $-1$-covered by some point $h(t')$, $t' \in [0,1]$, which implies that $f(h(t)) \in S$. Hence by convexity, since $0 \in S$, we also get $f(z) = \alpha f(h(t)) \in S$, as required. \end{proof} Next, we formulate a more concrete sufficient condition which can be used in numerical experiments.\footnote{This was the result stated in a talk at the Simons Institute for the Theory of Computing, UC Berkeley, on March 18, 2019.} \begin{figure}[t] \centering \includegraphics[scale=0.8]{images/h-curve} \caption{The $h$ curve from \cref{thm:Simons-result}. We set $d=9$, and $\lambda^*(d)$ is the Shearer threshold described in \Cref{thm:shearer}. $\theta(d)$ is chosen to be $\cos^{-1}\frac{1}{d + 0.5}$, while $r(d) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \min\inb{d\log (1 + \frac{1}{d}), \frac{2d(d+1)\sin^2(\theta/2)}{d^2 + 4(d+1)\sin^2(\theta/2)}}$. The choice of these parameters is based on their use in the later \cref{thm:critical-vicinity}, which applies \cref{thm:Simons-result}.} \label{fig:h-curve} \end{figure} \begin{theorem} \label{thm:Simons-result} For $\lambda \in \mathbb C$, $\Im(\lambda) > 0$, define a curve \begin{itemize} \item $h(t) = t \lambda$ for $t \in [0,1]$, \item $h(t) = \frac{\lambda}{(1+h(t-1))^d}$ for $t > 1$. \end{itemize} If $\Im(h(t)) \geq 0$ for all $t \geq 0$, then $Z_G(\lambda) \neq 0$ for all $G \in \mathcal G_{d+1}$. (See also \Cref{fig:h-curve} for an example of the curve $h$ in the statement of the theorem. ) \end{theorem} \begin{proof} Note that the curve $h(t)$ is continuous since it is continuous at $t\leq 1$: since at $t=1$ we have $\lim_{t\to 1-}h(t)=\lim_{t\to 1+}h(t)=\lambda$, and by the recursion $h$ is continuous at $t$ if it is continuous at $t-1$. By continuity and the assumption $\Im(h(t)) \geq 0$ for all $t \geq 0$ thus implies that the continuous functions $\arg (h(t))$ and $\arg(1 + h(t))$ are also non-negative for $t \geq 0$. The identity $\arg(h(t)) = \arg(\lambda) - d \arg(1+h(t-1))$ for $t \geq 1$ (valid whenever the right hand side lies in $(-\pi, \pi]$) then implies that $\arg(1+h(t-1))$ cannot exceed $\frac{1}{d} \arg(\lambda)$, because if $t$ is the infimum of points for which $\arg(1+h(t-1)) > \frac{1}{d} \arg(\lambda)$ then the identity gives a contradiction to $\arg(h(t + \epsilon)) \geq 0$ for some small enough positive $\epsilon$. Since $\arg(1+h(t-1)) \geq 0$, the identity then also implies that $$ 0 \leq \arg(h(t)) = \arg(\lambda) - d \arg(1+h(t-1)) \leq \arg(\lambda).$$ Hence the argument of any point of the curve is contained in $[0,\arg(\lambda)]$. In order to define a trapping region, we start by defining the following quantity: \[ \tau^\star \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \sup \{ t': \arg(1+h(t)) \text{ is non-decreasing for all } t \in [0,t'] \}. \] Note that $\tau^\star \geq 1$. We also allow $\tau^\star=\infty$, although this cannot really happen. We will now show that the region $S$ in the upper half plane bounded by the line segments $[0, h(1)]$ and $[0, h(\tau^\star + 1)]$ and the curve $\inb{h(t + 1) | 0 \leq t \leq \tau^\star}$ is a trapping region in the sense of \Cref{thm:z-criterion}. Note that by definition $0 \in S$, while $-1 \not\in S$ (since, from the observations above, $\arg z \in [0, \arg \lambda]$ for all $z \in S$). It remains to show that (1) $S$ is convex, and (2) $f(z) = \lambda/(1+z)^d \in S$ for all $z$ in $S$. \newcommand{\Dr}[1][]{\ensuremath{D^+\notblank{#1}{\inp{#1}}{}}} \newcommand{\Dl}[1][]{\ensuremath{D^-\notblank{#1}{\inp{#1}}{}}} We start by proving that $S$ is convex. This will follow if we establish the following two facts: \begin{enumerate} \item $\arg (h(t))$ is non-increasing for $t \in [1, \tau^\star + 1]$.\label{item:5} \item The curve $\inb{h(t) : t \in [1, \tau^\star + 1]}$ is ``turning to the right''. More formally, for any $t \in [1, \tau^\star + 1)$, there is a small enough neighborhood $N_t$ of $t$ such that for $t_1 \leq t_2$ in $N_t$, $\arg (\Dl[h](t_1) / \Dr[h](t_2)) \geq 0$. Here $\Dr$ and $\Dl$ denote the right and left one-sided derivatives.\label{item:6} \end{enumerate} We first prove \cref{item:5}. This follows since in the interval $t \in [1,\tau^\star+1]$, we have $\arg(h(t)) = \arg(\lambda) - d \arg(1+h(t-1))$, which is non-increasing by the definition of $\tau^\star$. We now consider \cref{item:6}. Note that $h(t)$ is continuously differentiable in the neighborhood of any $t$ which is not an integer. Further, for such a $t$, we have $h'(t) = \frac{-\lambda d}{(1 + h(t-1))^{d+1}}h'(t-1)$. We now prove the claim for such $t$ (i.e., non-integral $t$) using an induction on $\ceil{t}$. In the base case, when $\ceil{t} = 1$, we have $h'(t) = \lambda$, so $\arg (\Dl[h](t_1)/\Dr[h](t_2)) = \arg(1) = 0$ for $t_1, t_2$ in any small enough neighborhood of $t$. In the inductive case, we have, for $t_1 \leq t_2$ in a small enough neighborhood of $t$, \begin{displaymath} \arg \frac{\Dl[h](t_1)}{\Dr[h](t_2)} = (d+1) \arg \frac{1 + h(t_2 - 1)}{1 + h(t_1 - 1)} + \arg \frac{\Dl[h](t_1-1)}{\Dr[h](t_2-1)}. \end{displaymath} The claim now follows since the first term is non-negative due to the definition of $\tau^\star$, while the second is non-negative by the inductive hypothesis. We now consider the case of integral $t$. Here, we find via a direct induction that \begin{displaymath} \arg \frac{\Dl[h](t)}{\Dr[h](t)} = \arg \frac{\Dl[h](1)}{\Dr[h](1)} = \arg \frac{\lambda}{(-d\lambda^2)} = \pi - \arg \lambda \geq 0. \end{displaymath} The proof for \cref{item:6} now follows from the already proved case of non-integral $t$ and the fact that the derivative $h'$ is a well-defined continuous function except at integral $t$. As noted earlier, this proves that $S$ is convex. In fact, from the definition of $\tau^\star$, we also obtain that $0 = \arg (1 + h(0)) \leq \arg (1 + z) \leq \arg (1 + h(\tau^\star))$ for all $z \in S$. Since $\arg(1 + h(t))$ is non-decreasing for $t \in [0, \tau^\star]$ and $S$ is convex, it follows that if a line is drawn from $z \in S$ in the direction of $-1$, it will intersect the boundary of $S$ at some point $h(t)$ for $0 \leq t \leq \tau^\star$. We can now prove that $S$ satisfies the remaining requirement for being a trapping region, which is, that it is closed under application of $f$. Consider any point $z \in S$. As noted above, if a line is drawn from $z$ towards $-1$, then it must intersect the boundary of $S$ on a point $\tilde{z}$ of the form $h(t)$ for $t \in [0,\tau^\star]$. Hence, there is a point $\tilde{z} = h(t), t \in [0,\tau^\star]$ such that $\arg(1+h(t)) = \arg(1+z)$ and $|1+h(t)| \leq |1+z|$. By construction, $$ f(h(t)) = \frac{\lambda}{(1+h(t))^d} = h(t+1) $$ which is still in $S$ (since $t \in [0,\tau^\star]$). Finally, $f(z) = \frac{\lambda}{(1+z)^d}$ has the same argument as $h(t+1)$, and possibly smaller modulus, hence $f(z) \in S$ by convexity (since $0 \in S$). Thus, $S$ as defined above is a trapping region, and this concludes the proof. \end{proof} We note that the proof of \cref{thm:Simons-result} also indicates a numerical approach to check this criterion, see Figure~\ref{fig:Full_power_iterated_spiral}. We do not have to track the curve for $t \rightarrow \infty$. It is sufficient to compute $h(t)$ for $t \in [0,\tau^\star+1]$ as defined above. If $\arg(1+h(\tau^\star)) \leq \frac{1}{d} \arg(\lambda)$ and $\arg(1+h(t))$ is non-increasing for $t \in [\tau^\star,\tau^\star+1]$, the argument above implies that $S$ is a trapping region and the entire curve is contained in the upper half-plane. \begin{figure} \centering \includegraphics[width=0.8\textwidth]{images/iterated_spiral} \caption{Points that satisfy the condition of Theorem~\ref{thm:Simons-result} for $d=9$. Colors represent the value of $\lfloor\tau^\star\rfloor$.} \label{fig:Full_power_iterated_spiral} \end{figure} \section{Derivation of the Sokal conjecture for $\Re \lambda > 0$} \label{sec:sokal-conjecture} Here we provide a short proof using \cref{thm:init-curve} that there are no complex roots close to the positive real axis, up to the critical point $\lambda^* = \frac{d^d}{(d-1)^{d+1}}$. This was first proved by Peters and Regts \cite{peters_conjecture_2019}. \begin{figure}[t] \centering \includegraphics[scale=0.8]{images/sokal-h-curve} \caption{A sketch of the $h$ curve in the proof of \cref{thm:sokal-conj}. In the notation of the theorem, the sketch corresponds to $d \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 3$, $\epsilon \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 0.1$ and $\delta \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 0.01$. $\theta$ has been set to $0$ for simplicity. As before, $f$ is the map $z \mapsto \lambda/(1+z)^d$. The aspect ratio in the figure has been chosen to be different from $1$ to accentuate features close to the real line.} \label{fig:sokal-h} \end{figure} \begin{theorem} For every fixed $d \geq 2$, and every $\epsilon \in (0, 1)$, there is an $\epsilon' > 0$ such that $Z_G(\lambda) \neq 0$ for $G$ of maximum degree at most $d + 1$ when $\lambda = (1-\epsilon)\frac{(d-\epsilon)^d}{(d-1)^{d+1}}\exp(\iota \theta)$ with $\abs{\theta} \leq \epsilon'$.\label{thm:sokal-conj} \end{theorem} \begin{proof} Note that $z_0 \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{1-\epsilon}{d-1}$ is a fixed point of the map $z \mapsto \frac{\lambda_0}{(1+z)^d}$ where $\lambda_0 = (1-\epsilon)\frac{(d-\epsilon)^d}{(d-1)^{d+1}}$. Note also that $\lambda_0 \rightarrow \lambda^*$ as $\epsilon \rightarrow 0$. We consider two complex conjugate points $z_\pm = \frac{1-\epsilon \pm \iota \delta}{d-1}$ for some $\delta>0$ to be fixed later. We have $\lambda = \lambda_0\exp(\iota\theta)$ where $\theta > 0$ is small enough (as a function of $\epsilon$ and $\delta$) to be fixed later. We will now use \Cref{thm:init-curve} for the curve defined by \begin{equation} h(t)= \begin{cases} -t z_- & \text{if } t \in [-1, 0)\\ t z_+ & \text{if } t \in [0, 1] \end{cases}. \end{equation} The first three conditions required of the curve $h$ in \Cref{thm:init-curve} are satisfied by construction (see \cref{fig:sokal-h} for an example sketch). We now proceed to verify the fourth condition. To start with, a direct computation reveals that \begin{align} f(z_-) = \frac{\lambda}{(1+z_-)^d} &= (1-\epsilon) \frac{(d-\epsilon)^d}{(d-1)^{d+1}} \left(1 + \frac{1-\epsilon-\iota \delta}{d-1}\right)^{-d}\exp(\iota \theta)\\ &= \frac{1-\epsilon}{d-1} \left(1 - \frac{\iota \delta}{d-\epsilon} \right)^{-d} \exp(\iota \theta).\label{eq:13} \end{align} We have $\arg(1 - \frac{\delta i}{d-\epsilon}) = -\tan^{-1} (\frac{\delta}{d-\epsilon}) = -\frac{\delta}{d-\epsilon} + O(\delta^2)$. Therefore, \begin{equation} \arg(f(z_-)) = -d \arg \inp{1 - \frac{\iota \delta}{d-\epsilon}} + \theta = \frac{d \delta}{d-\epsilon} + O(\delta^2) + \theta.\label{eq:17} \end{equation} In comparison, \begin{equation} \arg z_+ = \tan^{-1} \left( \frac{\delta}{1-\epsilon} \right) = \frac{\delta}{1-\epsilon} + O(\delta^2). \label{eq:19} \end{equation} Thus, for all $\delta>0$ small enough (depending on $\epsilon$ and $d$) and all $\theta \geq 0$ small enough (depending on $d \geq 2$, $\delta$ and $\epsilon$), we have \begin{equation} \arg z_+ > \arg f(z_-) > 0.\label{eq:16} \end{equation} Observe also that $|f(z_-)| < | \frac{1-\epsilon}{d-1} | < |z_+|$. This implies that $f(z_-)$ is $-1$-covered by some point on the line segment from $0$ to $z_+$, and in particular, $0 \leq \arg(1 + f(z_-)) \leq \arg(1 + z_+)$. An essentially symmetric argument shows that $f(z_+)$ is also $-1$-covered by some point on the line segment between $0$ and $z_-$, and in particular, $0 \geq \arg(1 + f(z_+)) \geq \arg(1 + z_-)$. The inequality analogous to \cref{eq:16} for $f(z_+)$ is (again, provided that $\theta$ has small enough magnitude) \begin{equation} \arg z_- < \arg f(z_+) < 0.\label{eq:20} \end{equation} For later use, we also record the following computation. For small positive $\theta$ and $\delta$, we have, by a direct computation, \begin{align} \label{eq:25} \arg \frac{f(z_+)}{1 + f(z_+)} &= -\frac{d(d-1)}{(d-\epsilon)^2}\delta + O(\delta^2) + O(\theta), \text{ and }\\ \label{eq:26} \arg \frac{z_+}{1 + z_+} &= \frac{d-1}{(d-\epsilon)(1-\epsilon)}\delta + O(\delta^2). \end{align} In particular, since $d \geq 2$, we have \begin{equation} \label{eq:27} \arg \frac{f(z_+)}{1 + f(z_+)} + \arg \frac{z_+}{1 + z_+} \geq 0 \end{equation} for all small enough $\delta > 0$ and $\theta > 0$. At this point, we specify our choice of $\theta$ and $\delta$: we choose $\delta < 1$ and $\theta < \pi/10$ positive and small enough that (i) \cref{eq:16}, its analogue \cref{eq:20} for $f(z_+)$, and \cref{eq:27} are all valid, and (ii) $\abs{\arg{z_+}} = \abs{\arg{z_-}} \leq \pi/10$. In the following, we use these conditions imposed on $\delta$ and $\theta$ without comment. We now claim that the curve $\{ f(t z_+): 0 \leq t \leq 1 \}$ is also $-1$-covered by the curve $h$ defined above. To prove this, we define $\gamma(t) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 1 + f(tz_+)$, and note that we have (for $s \in (0, 1)$) $\diff{}{s} \arg\gamma(s)\vert_{s = t} = \Im \frac{\gamma'(t)}{\gamma(t)}$. We begin by noting that as $t$ increases from $0$ to $1$, $\arg f(tz_+)$ decreases from $\theta = \arg f(0)$ to $\arg f(z_+) > \arg z_-$ (since $\arg\inp{1 + tz_+}$ increases as $t$ increases), while $\abs{f(tz_+)}$ decreases from $\lambda_0$ to $\abs{f(z_+)} < \abs{z_-}$ (again, since $\abs{1 + tz_+}$ increases as $t$ increases). We now compute \begin{equation} \diff{}{t} \arg\gamma(t) = \Im \frac{\gamma'(t)}{\gamma(t)} = -d\Im \inp{\frac{z_+}{1 + tz_+}\cdot\frac{f(tz_+)}{1 + f(tz_+)}}.\label{eq:18} \end{equation} We will now show that $\diff{}{t} \arg \gamma(t) \leq 0$ for all $t \in (0, 1)$. For any particular $t$, if $\arg f(tz_+) \geq 0$, then \cref{eq:18} immediately implies that $\diff{}{t} \arg \gamma(t) < 0$ (since $\arg z_+ > 0$). For any other $t \in (0, 1)$, we must have $\arg f(z_+) \leq \arg f(t z_+) \leq 0$. We then get \begin{align*} \arg{\frac{f(tz_+)}{1 + f(tz_+)}} &= \tan^{-1} \frac{ \sin \arg f(tz_+) }{ \abs{f(tz_+)} + \cos \arg f(tz_+) }\\ &\ge \tan^{-1} \frac{ \sin \arg f(z_+) }{ \abs{f(tz_+)} + \cos \arg f(z_+) }\quad \text{ since } \arg f(t{z_+}) \geq \arg f(z_+),\\ &\ge \tan^{-1} \frac{ \sin \arg f(z_+) }{ \abs{f(z_+)} + \cos \arg f(z_+) }\quad \text{ since } \abs{f(t{z_+})} \geq \abs{f(z_+)} \text{ and } \arg f(z_+) \leq 0,\\ & = \arg \frac{f(z_+)}{1 + f(z_+)} \geq -\arg\frac{z_+}{1 + z_+}. \end{align*} Here, the last inequality comes from \cref{eq:27}. Combining this with the observation that $\arg \frac{z_+}{1 + t z_+}$ is strictly decreasing in $t$ for $t \in (0, 1)$, and substituting in \cref{eq:18}, we get the required claim that $\diff{}{t} \arg \gamma(t) \leq 0$ for all $t$ in $(0, 1)$. Thus, $\arg(1 + f(tz_+))$ \emph{decreases} as $t$ increases from $0$ to $1$. An essentially symmetrical argument shows that $\arg(1 + f(tz_-))$ \emph{increases} as $t$ increases from $0$ to $1$. Since we already established that $f(z_+)$ and $f(z_-)$ are $-1$-covered by $h$, and also that $\arg z_- < \arg f(h(t)) < \arg z_+ $ for all $t \in [-1, 1]$, this establishes that the whole curve $\inb{f(h(t)) \; \vert \; t \in [-1, 1]}$ is $-1$-covered by $h$. We thus see that the fourth condition of \Cref{thm:init-curve} is also satisfied for the curve $h$. We conclude therefore that $Z_G(\lambda) \neq 0$ for all graphs $G$ of maximum degree at most $d+1$. \end{proof} \section{A new zero-free region in the vicinity of the critical point} \label{sec:zero-free-region-negative-real-line} In this section, we use \Cref{thm:Simons-result} to establish a new zero-free region for the independence polynomial in the vicinity of the negative real line. The result in this section applies more generally to points in the left half-plane away from the imaginary axis; we consider points close to the imaginary axis in \Cref{sec:zero-free-region-imaginary-axis}. We recall that $\lambda^* = \lambda^*(d) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{d^d}{(d+1)^{d+1}}$ is the Shearer threshold. Consider the boundary $\partial U_d$ of the ``cardioid-shaped'' region $U_d$ (\cref{eq:12}) of Peters and Regts~\cite{peters_conjecture_2019}. Near the negative real line, one can calculate that the curve $\partial U_d$ follows a power law of the following form. Let $R_U(\theta)$ denote the polar equation of $\partial U_d$, and let $(X_U(\theta), Y_U(\theta))$ denote the corresponding Cartesian coordinates $(R_U(\theta)\cos\theta, R_U(\theta)\sin\theta)$. In the vicinity of the point $-\lambda^*(d)$ on $\partial U_d$, a somewhat tedious but straightforward calculation shows that for small $\phi$, \begin{displaymath} X_U(\pi + \phi) = -\lambda^*(d) - c_d \cdot \abs{\phi}^{2/3} + o(\abs{\phi)}^{2/3}), \end{displaymath} where $c_d$ is a positive constant depending only on $d$. While we cannot prove that the true root-free region matches this exact power law, we have the following result which gives a weaker power law (see \cref{fig:1} for a pictorial description). \begin{theorem} \label{thm:critical-vicinity} Fix an integer $d \geq 2$. If $\lambda = -\lambda^*\exp(r - \ensuremath{\iota} \theta)$, where $\theta \in (0, \cos^{-1}\frac{1}{d + 0.5}]$ and $0 \leq r \leq \min\inb{d\log (1 + \frac{1}{d}), \frac{2d(d+1)\sin^2(\theta/2)}{d^2 + 4(d+1)\sin^2(\theta/2)}}$, then $Z_G(\lambda) \neq 0$ for any graph $G$ of degree at most $d + 1$. \end{theorem} \begin{figure}[t] \centering \includegraphics[width=0.6\textwidth]{images/critical} \caption{The red region is the zero-free region in \cref{thm:critical-vicinity}, plotted here for $d = 9$ (i.e., for graphs of degree at most $10$). The black circle around the origin has radius $\lambda^*(d)$, and the markings are according to polar coordinates.} \label{fig:1} \end{figure} Before proving the theorem, we briefly describe the power law (analogous to the one stated above for $\partial U_d$) that the region described in the theorem follows. Again, we denote by $\tilde{R}(\theta)$ the polar equation of the boundary of the region described by the theorem, and let $(\tilde{X}(\theta), \tilde{Y}(\theta))$ denote the corresponding Cartesian coordinates $(\tilde{R}(\theta)\cos\theta, \tilde{R}(\theta)\sin\theta)$. In the vicinity of the point $-\lambda^*(d) = R_U(\pi) = \tilde{R}(\pi)$, a similar computation as above then shows that for small $\phi$, \begin{displaymath} \tilde{X}(\pi + \phi) = -\lambda^*(d) - \tilde{c}_d\cdot \abs{\phi}^{2} + o(\abs{\phi}^{2}), \end{displaymath} where $\tilde{c}_d = \frac{\lambda_*(d)}{2d}$ is a positive constant depending only on $d$. \begin{proof}[Proof of \Cref{thm:critical-vicinity}] We use \Cref{thm:Simons-result}. In particular, we will show that the curve $h(t)$ defined there lies in the upper half plane $\inb{z | \Im z \geq 0}$ for every $t \geq 0$. (See \Cref{fig:h-curve} for an example of this curve for a particular setting of the parameters $d, r$ and $\theta$.) In fact, we will prove by an induction on $\ceil{t}$ that for all $t \geq 0$, \begin{enumerate} \item \label{item:1} $\abs{h(t)} \leq \tau \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{1}{d + 1 - \delta} \leq \frac{1}{d + 0.5} \leq \frac{1}{2}$, and \item \label{item:2} $\arg{h(t)} \in [0, \pi - \theta]$, \end{enumerate} where $\delta = \delta(d, r, \theta) < 1/2$ is a fixed non-negative constant. We first verify these for the base case $\ceil{t} = 1$. In this case, we have $\abs{h(t)}$ = $t\abs{\lambda} \leq \exp(r)\frac{d^d}{(d+1)^{d+1}} \leq \frac{1}{d+1} \leq \tau$ since $r \leq d\log(1+1/d)$. Further, $\arg{h(t)} = \arg{\lambda} = \pi - \theta$. We now proceed with the induction. For ease of notation, we denote $\abs{h(t-1)}$ as $\rho$ and $\arg h(t-1)$ as $\pi - \alpha$. From the induction hypothesis, we have $\rho \leq \tau$ and $\alpha \in [\theta, \pi]$. This gives \begin{align} \abs{1 + h(t-1)} &= \sqrt{1 + \rho^2 - 2\rho\cos\alpha} \geq \sqrt{1 + \rho^2 - 2\rho\cos\theta} \nonumber\\ &\geq\sqrt{1 + \tau^2 - 2\tau\cos \theta} = (1-\tau)\sqrt{1 + 2\tau\cdot\frac{2\sin^2(\theta/2)}{(1-\tau)^2}}\nonumber\\ &\geq \frac{d-\delta}{d+1-\delta}\cdot\sqrt{1 + \frac{4(d+1)\sin^2(\theta/2)}{d^2}}.\label{eq:3} \end{align} Here, for the second inequality we use the fact that the quantity inside the square-root is decreasing in $\rho$ since $\rho \leq \tau \leq \frac{1}{d + 0.5} \leq \cos \theta$, since $\theta \in [0, \cos^{-1}(1/(d+0.5))]$. Similarly, the last inequality uses $\tau \geq \frac{1}{d+1}$. Now, note that since $\arg h(t-1) \in [0, \pi]$, $\abs{h(t-1)} \leq \tau \leq 1$ and $\abs{1 + h(t-1)} > 0$, we have \begin{equation} \arg (1 + h(t-1)) \geq 0,\label{eq:2} \end{equation} and also \begin{align*} \arg(1+h(t-1)) &\leq \frac{\Im h(t-1)}{1 + \Re h(t-1)} = \frac{\rho\sin \alpha}{1 - \rho \cos\alpha} \leq \frac{\tau\sin \alpha}{1 - \tau \cos\alpha}\\ &=\frac{\sin \alpha}{d + 1 - \delta - \cos \alpha}. \end{align*} From this, using the fact that $d \sin \alpha + \cos \alpha \leq \sqrt{d^2 + 1}$ for $\alpha \in [0, \pi]$, we deduce that \begin{equation} \arg(1+h(t-1)) \leq 1/d,\label{eq:1} \end{equation} provided that $\delta \leq 1/2$. Now, we have \begin{displaymath} \arg h(t) = \arg \lambda - d\arg (1 + h(t-1)) = \pi - \theta - d\arg(1+h(t-1)), \end{displaymath} so that \cref{eq:1,eq:2} imply \cref{item:2} of the induction hypothesis (since $\theta \leq \pi/2$ so that $\pi - \theta - 1 \geq 0$). For \cref{item:1}, we use \cref{eq:3} to calculate \begin{align*} \log \abs{h(t)} + \log (d + 1 - \delta) & = r + d\log d - (d+1)\log(d+1) - d \log \abs{1 + h(t-1)} + \log (d + 1 - \delta) \\ &\leq r + (d+1)\log\inp{1 - \frac{\delta}{d+1}} - d\log \inp{1 - \frac{\delta}{d}}\\ &\qquad\qquad - \frac{d}{2}\log \inp{1 + \frac{4 (d+1) \sin ^2 (\theta/2)}{d^2}}\\ &< r - \delta + \frac{d\delta}{d - \delta} - \frac{2d(d+1)\sin^2(\theta/2)}{d^2 + 4(d+1)\sin^2(\theta/2)}\\ &= r - \frac{2d(d+1)\sin^2(\theta/2)}{d^2 + 4(d+1)\sin^2(\theta/2)} + \frac{\delta^2}{d-\delta} \leq 0, \end{align*} provided $r \leq \frac{2d(d+1)\sin^2(\theta/2)}{d^2 + 4(d+1)\sin^2(\theta/2)}$ and $\delta$ is chosen to be a small enough non-negative constant depending only upon $r, d$ and $\theta$ (note that the second inequality above is strict when $\delta$ is positive). \end{proof} \section{A zero-free region close to the imaginary axis} \label{sec:zero-free-region-imaginary-axis} The analysis in the previous section was devoted to understanding the behavior of the zero-free region close to the negative real line. We now turn to understanding the behavior of the zero region close to the imaginary axis. The theorem below, while it covers all arguments in the third argument, is most interesting when the argument of the activity $\lambda$ is closer to $\pi/2$ than to $\pi$. \begin{figure}[t] \centering \includegraphics[scale=0.8]{images/close-to-imaginary-h-curve} \caption{A sketch of the $h$ curve in the proof of \cref{thm:lhp}. In the notation of the theorem, the sketch corresponds to $d \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 3$ and $\varphi \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 2\pi/3$, and $r$ has been chosen to be $0.99$ times the value on the right hand side of \cref{eq:b}. As before, $f$ is the map $z \mapsto \lambda/(1+z)^d$.} \label{fig:close-to-imaginary-h} \end{figure} \begin{theorem} Let $d \geq 2$. Suppose that $\lambda = r e^{\iota \varphi}$ where $\varphi \in [\frac{\pi}{2}, \pi)$ and \begin{align}\label{eq:b} r < \frac{\sin(\varphi/d)\sin^d(\varphi)}{\sin((d-1)\varphi/d-d\psi^*)\sin^d(\varphi-\psi^*)}, \end{align} where $\psi^*= \max\left(\frac{1}{d+1}\left((2-1/d)\varphi-\pi\right),0\right)$. Then $Z_G(\lambda) \neq 0$ for any graph of degree at most $d+1$.\label{thm:lhp} \end{theorem} \begin{proof} For a given $\varphi$, let us choose $r_*,\lambda_*$ so that $\arg(1+\lambda_*)=\varphi/d$ and $\arg(\lambda_*)=\arg(\lambda)=\varphi$. Note that for $t\in[0,1]$, $\varphi/d\ge \arg(1+t\lambda_*)\ge 0$. As before denote $f(z)=\frac{\lambda}{(1+z)^d}$. We claim that the function $h(t)=t\lambda_*$ satisfies the conditions of \cref{thm:init-curve}. The first three conditions of the theorem are satisfied trivially, thus we only have to show that the points $f(t\lambda_*)$, $t \in [0, 1]$ are $-1$-covered by the segment \begin{equation} \{t\lambda_* ~:~t\in[0,1] \}.\label{eq:28} \end{equation} Further, as $\arg(f(t\lambda_*))=\varphi-d\arg(1+t\lambda_*)$ decreases monotnically from $\varphi$ to $0$ as $t$ goes from $0$ to $1$, it would be sufficient to prove that $\arg(1+f(t\lambda_*))$ is at most $\varphi/d$ for all $t\in [0,1)$. (See the example sketch in \cref{fig:close-to-imaginary-h}.) To prove this, we investigate the curve $\gamma(t)=1+f(t\lambda_*)$ for $t\in[0,1]$. Note first that we have $0 \leq \arg(\gamma(t)) \leq \arg(f(t\lambda_*)) \leq \varphi$ for all $t \in [0,1]$. Further, for all $t \in [0, 1)$, we have (here, we denote by $\gamma'(t)$ the right one-sided derivative of $\gamma$ at $t$) \begin{equation} \gamma'(t)=-\frac{d\lambda\lambda_*}{(1+t\lambda_*)^{d+1}}.\label{eq:29} \end{equation} Since $\varphi/d \ge \arg(1+t\lambda_*)\ge 0$ and $\arg(-\lambda\lambda_*)=2\varphi-\pi$, we have that as $t$ increases from $0$ to $1$, \begin{equation} \arg \gamma'(t) =2\varphi-\pi-(d+1)\arg(1+t\lambda_*)\label{eq:35} \end{equation} decreases monotonically from $2\varphi-\pi \in [0, \pi)$ to $(1-1/d)\varphi-\pi \geq -\pi+\varphi/d$. Next, we compute that $\diff{}{s} \arg\gamma(s)\vert_{s = t} = \Im \frac{\gamma'(t)}{\gamma(t)}$ has the same sign as $\sin(\arg \gamma'(t) - \arg \gamma(t))$: note that the existence of this derivative follows since $\gamma(t)$ and $\gamma'(t)$ are non-zero, and since $\arg \gamma(t) \in [0, \pi)$ for $t \in [0, 1)$. We now claim that $\arg(\gamma(t)) \leq \varphi/d$ for all $t \in [0, 1]$. For the sake of contradiction let us assume that $\arg\gamma(t)$ can be bigger than $\varphi/d$. As $\arg\gamma(1)=0$, we then see that there must exist a $t_* \in [0, 1)$ such that $\arg \gamma(t_*) =\varphi/d$ and $\diff{}{s} \arg \gamma(s) \vert_{s = t_*} \leq 0$. Using the fact (noted just below \cref{eq:35}) that $\pi > \arg \gamma'(t_*) \geq -\pi + \varphi/d$ and the expression for the sign of $\diff{}{s} \arg(\gamma(s))\vert_{s = t_*}$ noted above, these conditions can be written as \begin{equation} \arg \gamma(t_*) =\varphi/d \qquad \textrm{and}\qquad \arg\gamma'(t_*) \leq \varphi/d.\label{eq:36} \end{equation} Define $\alpha\,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil\arg(1+t_*\lambda_*)\geq 0$. \Cref{eq:36}, along with the expression for $\arg \gamma'(t)$ in \cref{eq:35}, and the fact $\arg \gamma(t_*) \leq \arg f(t_*\lambda_*) = \phi - d\alpha$ noted above, gives \begin{equation} \alpha \leq \frac{\varphi}{d}(1-1/d) \qquad \textrm{and}\qquad \alpha \geq \psi^*.\label{eq:32} \end{equation} The standard sine rule applied to the triangle with vertices $0,1,\gamma(t_*)$ gives us that (see \cref{fig:triangle-sine-rule}) \begin{equation} \frac{\abs{\gamma(t_*) - 1}}{\sin \arg \gamma(t_*)} = \frac{1}{\sin \inp{\arg \inp{\gamma(t_*) - 1} - \arg \gamma(t_*)} }. \label{eq:31} \end{equation} \begin{figure}[t] \centering \begin{tikzpicture} \draw (0, 0) coordinate (a) node[left] {$0$} -- (5,0) coordinate (b) node[below] {$1$} -- (7,4) coordinate (c) node[above right] {$\gamma(t_*)$} -- (a) pic["$\varphi/d$",draw=orange,<->,angle eccentricity=1.5,angle radius=1cm] {angle=b--a--c}; \draw [->, gray] (b) -- (10,0) coordinate (d) node[right] {}; \draw pic["$\varphi-d\alpha$",draw=orange,<->,angle eccentricity=1.5,angle radius=1.2cm] {angle=d--b--c}; \end{tikzpicture} \caption{Angles appearing in \cref{eq:32}.} \label{fig:triangle-sine-rule} \end{figure} Using the facts that (i) $\abs{\gamma(t_*) - 1} = \abs{f(t_*\lambda_*)} = r/\abs{1 + t_*\lambda_*}^d$, (ii) $\arg\inp{\gamma(t_*) - 1} = \arg f(t_*\lambda_*) = \varphi - d\alpha$, and (iii) $\arg \gamma(t_*) = \varphi/d$, we get \begin{align} \nonumber \sin(\varphi/d)&=\frac{r\sin^d(\varphi-\alpha)}{\sin^d\varphi}\sin((1-1/d)\varphi-d\alpha)\\ &< \sin(\varphi/d)\frac{\sin^d(\varphi-\alpha)\sin((1-1/d)\varphi-d\alpha)}{\sin^d(\varphi-\psi^*)\sin((1-1/d)\varphi-d\psi^*)}. \label{eq:ineq} \end{align} But, in conjunction with \cref{eq:32}, this contradicts the fact that the function \begin{equation} x \mapsto \sin^d(\varphi-x)\sin((1-1/d)\varphi-dx)\label{eq:33} \end{equation} is a strictly decreasing function on $(\psi^*,(1-1/d)\varphi/d)$, since its derivative is \begin{equation} -{d\sin^{d-1}(\varphi-x)}\cdot\sin\inp{(2-1/d)\varphi - (d+1)x}<0. \label{eq:34} \end{equation} Here, we use the condition $x \in (\psi^*,(1-1/d)\varphi/d)$ and the definition of $\psi^*$ as $\max\left(\frac{1}{d+1}\left((2-1/d)\varphi-\pi\right),0\right)$ to deduce the last inequality. \end{proof} \section{Zero free regions in the right half plane} \label{sec:right-half-plane} In this section, we use the framework of \Cref{sec:crit-orig-compl} to establish a zero free region for the independence polynomial in the right half plane. The results here improve upon those in the manuscript~\cite{bencs18:_note} when $\lambda$ is close to the real axis and match those results when $\lambda$ is on the imaginary axis: see \Cref{rem:right-improvement} for a more detailed discussion. We start with some notation. For any integer $d \geq 2$, let $\theta_d\in(\pi/(2(d+1)),\pi/2)$ be the unique solution of \[ {\tan(2x/d)}=\frac{\tan((\pi/2-x)/d)}{1-\frac{\tan((\pi/2-x)/d)}{\tan(x)}}. \] To see that $\theta_d$ exists and is unique, we first note that the left hand side of the above equation is monotone increasing while the right hand side is monotone decreasing, so that it has at most one solution in the given interval. To show existence, we note that as $x \downarrow \pi/(2(d+1))$, we have \[ \lim_{x \downarrow \pi/(2(d+1))} \tan (2x/d) = \tan(\pi/(d(d+1))) < \lim_{x \downarrow \pi/(2(d+1))} \frac{\tan((\pi/2-x)/d)}{1-\frac{\tan((\pi/2-x)/d)}{\tan(x)}}=\infty, \] while as $x \uparrow \pi/2$ we have \[ \lim_{x\uparrow\pi/2} \tan(2x/d) = \tan(\pi/d) >\lim_{x\uparrow\pi/2} \frac{ \tan((\pi/2-x)/d) }{ 1 -\frac{\tan((\pi/2-x)/d)}{\tan(x)}} = 0. \] Together, these show that there is a unique solution $\theta_d$, such that for all $x$ such that $\pi/(2(d+1)) < x < \theta_d$, we have \begin{equation} \label{eq:10} \frac{\tan(2x/d)}{\sin x} < \frac{\tan ((\pi/2-x)/d)}{\sin(x) - \cos(x)\tan((\pi/2-x)/d)}, \end{equation} while for $\theta_d < x < \pi/2$, \begin{equation} \label{eq:11} \frac{\tan(2x/d)}{\sin x} > \frac{\tan ((\pi/2-x)/d)}{\sin(x) - \cos(x)\tan((\pi/2-x)/d)}, \end{equation} For later comparison with results of \cite{bencs18:_note}, we also note that at $x=\pi/6$ we have (assuming $d \geq 3$) \begin{equation} \frac{\tan(2x/d)}{\sin x} = \frac{\tan(\pi/(3d))}{\sin (\pi/6)} < \frac{\tan(\pi/(3d))}{\sin(\pi/6)-\cos(\pi/6){\tan(\pi/(3d))}},\label{eq:37} \end{equation} which implies that $\pi/6<\theta_d$ for all $d \geq 2$ (this conclusion is trivially true for $d = 2$). We are now ready to state the main result describing zeros in the right half plane. \begin{theorem}\label{lem:righthalfplane_better} Let $\theta\in(0,\pi/2]$ and $0\le r\le r_{1,d}(\theta)$, where \[ r_{1,d}(\theta)=\left\{ \begin{array}{cc} \frac{\tan(2\theta/d)}{\sin(\theta)} & \textrm{if $\theta \leq \theta_d$}\\ \frac{\tan((\theta+\beta^*)/d)}{\sin(\theta)} & \textrm{if $\theta > \theta_d$} \end{array} \right. , \] and where $\beta^*\in (0,\theta)$ is defined as the unique solution of \[ \frac{\tan((\theta+x)/d)}{\sin (\theta)}=\frac{\tan((\pi/2-\theta)/d)}{\sin(x)-\cos(x)\tan((\pi/2-\theta)/d)}, \] when $\theta \in [\theta_d, \pi/2)$ and as $\beta^* \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 0$ when $\theta = \pi/2$. If $\lambda=r\exp(\iota\theta)$, then $Z_G(\lambda)\neq 0$ for any graph $G$ with degree at most $d+1$. \end{theorem} The proof of this theorem is based on the following technical lemma, which employs the framework of \Cref{thm:init-curve}. \begin{lemma} \label{lem:generic-right-half-plane} Let $\lambda=r\exp(\iota \theta)$ with $\theta\in(0,\pi/2]$ and $r > 0$. Suppose that there exist $r_2 \geq 0$ and $\beta, \psi \in[0,\pi/2)$ satisfying \begin{enumerate} \item $\theta-d\psi\ge -\beta$,\label{item:7} \item $r_2 \geq r$, \label{item:8} \item $r \sin(\theta) \le \tan \psi$,\label{item:9} \item $\theta+d\arg(1+r_2\exp(\iota \beta))\le \pi/2$,\label{item:10} and \item $\theta \geq \beta$.\label{item:11} \end{enumerate} Then the curve \[ h(t) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \begin{cases} -t\cdot r_2\exp(-\iota\beta) &\textrm{if $t\in[-1,0]$}, and\\ t\cdot \tan(\psi)\iota &\textrm{if $t\in[0,1]$} \end{cases} \] satisfies the conditions of \Cref{thm:init-curve}. \end{lemma} \begin{figure}[t] \centering \includegraphics[scale=0.6]{images/right-half-plane-h-curve} \caption{An example sketch of the $h$ curve from \cref{lem:generic-right-half-plane}. In the notation of the lemma, the sketch corresponds to $d \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 3$, $\beta \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \theta \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \pi/(2(d+1))$, $\psi \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil 2\theta/d$, $r_2 \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil r \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \tan(2\theta/d)/\sin \theta$ and $\lambda \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil r\exp(\iota \theta)$. As before, $f$ is the map $z \mapsto \lambda/(1+z)^d$.} \label{fig:right-half-plane-h} \end{figure} \begin{proof} Let $A$ denote the point $r_2\exp(-\iota\beta)$, $B$ the point $\iota \tan \psi$, and $O$ the origin. (See \cref{fig:right-half-plane-h} for an example sketch.) Since $h(0) = 0$, $h$ satisfies the first condition of \Cref{thm:init-curve}. Further, the curve $h(t)$ traverses the directed line segment $AO$ as $t$ varies from $-1$ to $0$ and the line segment $OB$ as $t$ varies from $0$ to $1$, and this establishes the second condition of \Cref{thm:init-curve} (since $\beta \in [0, \pi/2)$ and $\psi \geq 0$). A convex combination of any two points $h(t_1)$ and $h(t_2)$, where $t_1 < t_2$, lies either on the curve $h$ (when $0 \not\in (t_1, t_2)$), or on the boundary of the triangle with vertices $h(t_1) \in AO, h(0) = 0$ and $h(t_2) \in OB$ (when $0 \in (t_1, t_2)$). It is therefore $-1$ covered by $h(t)$ for some $t \in [t_1, t_2$]. This establishes the third condition of \Cref{thm:init-curve}. Note that the segment $OB$ of the curve $h$ $-1$-covers every point in the set \[L_1\,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \inb{z: \Re z \geq 0 \text{ and } 0 \leq \Im z \leq \Im B = \tan \psi \geq 0},\] while the segment $AO$ $-1$-covers every point in the set \[L_2\,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \inb{z: -\pi/2 < -\beta \leq \arg z \leq 0 \text{ and } \Im z \geq \Im A = -r_2\sin \beta \leq 0}.\] It remains to verify the fourth condition of \Cref{thm:init-curve}, which is that for every $t \in [0, 1]$, $f(h(t))$ is $-1$-covered by some point on the curve $h$. We do so by proving that for all $t \in [-1, 1]$, $f(h(t)) \in L_1 \cup L_2$. Consider first a point $f(h(t))$ for $t \in [0, 1]$. Note that as $t$ increases from $0$ to $1$, $\arg(1 + h(t))$ increases from $0$ to $\psi$. From \cref{item:7} in the statement of the lemma, we thus get that $\arg f(h(t)) \in [-\beta, \theta]$, while \cref{item:8} gives $\abs{f(h(t))} \leq r \leq r_2$. Together with \cref{item:9}, these imply that for $t \in [0, 1]$, \begin{enumerate} \item $0 \leq \Im f(h(t)) \leq r\sin \theta \leq \tan \psi$ (when $\arg f(h(t)) \geq 0$), and \item $0 \geq \Im f(h(t)) \geq -r\sin\beta \geq -r_2\sin\beta$ (when $\arg f(h(t)) \leq 0$). \end{enumerate} Thus, for all $t \in [0, 1]$, $f(h(t)) \in L_1 \cup L_2$, and thus is $-1$-covered by the curve $h$. Now, consider a point $f(h(t))$ for $t\in [-1, 0]$. Define $g(t) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil f(h(t))$. From \cref{item:10}, we get that $\arg g(t) \in [\theta, \pi/2]$ for all $t \in [-1, 0]$. We also have $g(0) = \lambda \in L_1$ (where the last inclusion follows from \cref{item:9}). Thus, in order to establish that $g(t) \in L_1$ for all $t \in [-1, 0]$, it suffices to prove that $k(t) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \Im g(t)$ has a non-negative right derivative at every $t \in [-1, 0)$. The latter in turn would follow if we establish that $\arg g'(t) \in [0, \pi)$ for all $t \in [-1, 0)$, where $g'(t)$ denotes the right derivative of $g$ at $t$. We now compute, for $t \in [-1, 0)$, \[ g'(t) = d \cdot r_2\cdot\frac{\lambda}{(1 - t\cdot r_2\exp(-\iota \beta))^d} \frac{\exp(-\iota\beta)}{(1 - t\cdot r_2\exp(-\iota \beta))} \] so that (after multiplying denominators with conjugates and ignoring positive real factors) \[ \arg g'(t) = \arg\inp{\underbrace{\insq{\exp(\iota \theta) \cdot (1 - t\cdot r_2\exp(\iota \beta))^d}}_{=: \mu} \cdot \underbrace{ \insq{\exp(-\iota \beta) - t \cdot r_2} }_{=:\nu} }. \] Since $t \in [-1, 0)$, \cref{item:10} in the statement of the lemma then implies that $\arg \mu \in [\theta, \pi/2]$. Further, $\arg \nu \in [-\beta, 0]$. Together with $\theta \geq \beta$ (\cref{item:11} in the statement of the lemma), this implies that $\arg g'(t) = \arg\inp{\mu \cdot \nu} \in [0, \pi/2] \subseteq [0, \pi)$. Given the above discussion about the relationship between the functions $k$ and $g$, this completes the proof. \end{proof} With the above lemma, we can now complete the proof of \Cref{lem:righthalfplane_better}. \begin{proof}[Proof of \Cref{lem:righthalfplane_better}] We will prove that if $r\leq r_{1,d}(\theta)$, then we can find $\beta, \psi\in[0,\pi/2)$ and $r_2>0$, such that the conditions of \Cref{lem:generic-right-half-plane} hold. By applying \cref{thm:init-curve} for the curve $h$ obtained from the lemma, we get the desired statement. \begin{enumerate} \item Consider first the case $\theta \leq \theta_d$. Then, let \begin{equation} \beta=\theta,~\qquad \psi=\frac{2\theta}{d}, \qquad r_2=\argmax\limits_{t\ge 0} \left(\arg(1+t\exp(\iota \theta))\le \frac{\pi/2-\theta}{d}\right)\le\infty.\label{eq:21} \end{equation} \Cref{item:7,item:9,item:10,item:11} in \Cref{lem:generic-right-half-plane} are satisfied by construction (as discussed below, we might have to redefine $r_2$ to make sure it is finite). We now show that \cref{item:8} holds: \begin{itemize} \item If $\theta \leq \pi/(2(d+1))$, then $r_2=\infty\ge r$. In this case, we redefine $r_2 = r$, and all of the conditions continue to hold. \item Otherwise $\theta> \pi/(2(d+1))$. In this case, we have $r_2=\frac{\tan((\pi/2-\theta)/d)}{\sin(\theta)-\cos(\theta)\tan((\pi/2-\theta)/d)} \geq \frac{\tan(2\theta/d)}{\sin(\theta)}=r_{1,d}(\theta) \geq r$, where the first inequality follows from \cref{eq:10} since $\pi/(2(d+1)) < \theta \leq \theta_d$. \end{itemize} \item Consider now the case $\theta >\theta_d$. Then let $\beta$ be $\beta^*\in [0,\theta]$ as described in the statement of the theorem. By definition, $\beta^* = 0$ when $\theta = \pi/2$, so we first show that even when $\theta \in (\theta_d, \pi/2)$, this $\beta^*$ exists and is unique. To see this, note that \begin{equation} \gamma_1(x) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{\tan((\theta+x)/d)}{\sin (\theta)}\label{eq:22} \end{equation} is continuous, monotone increasing and positive on $[0,\theta]$ (when $0 < \theta < \pi/2$). On the other hand, \begin{equation} \gamma_2(x) \,:=\,} \newcommand{\ceil}[1]{\left\lceil #1 \right\rceil \frac{\tan((\pi/2-\theta)/d)}{\sin(x)-\cos(x)\tan((\pi/2-\theta)/d)}\label{eq:23} \end{equation} is continuous in $\left[0, (\pi/2-\theta)/d)\right) \cup \left((\pi/2-\theta)/d, \theta\right]$, negative in $\left[0, (\pi/2-\theta)/d)\right)$, and monotone decreasing in $\left((\pi/2-\theta)/d,\theta\right]$. Further, in the interval $\left((\pi/2-\theta)/d,\theta\right]$ we also have \begin{equation} \gamma_1((\pi/2-\theta)/d) <\infty, \qquad \textrm{and} \qquad \lim_{x\downarrow (\pi/2-\theta)/d}\gamma_2(x) = \infty,\label{eq:24} \end{equation} at the left endpoint, while at the right endpoint, $\theta>\theta_d$ implies $\gamma_1(\theta) > \gamma_2(\theta)$ (due to \cref{eq:11}). The above observations imply that when $\theta \in (\theta_d, \pi/2)$, $\gamma_1(x) = \gamma_2(x)$ has exactly one solution $\beta^* \in [0, \theta]$, which lies in $((\pi/2-\theta)/d, \theta]$. Then, we define \begin{equation} \begin{gathered} \beta = \beta^*, \qquad \psi=(\theta+\beta)/d,\\ r_2= \begin{cases} \argmax\limits_{t\ge 0} \left(\arg(1+t\exp(\iota \beta))\le \frac{\pi/2-\theta}{d}\right)<\infty & \text{ when } \theta \in (\theta_d, \pi/2),\\ \tan (\pi/(2d)) & \text{ when } \theta = \pi/2. \end{cases} \end{gathered}\label{eq:14} \end{equation} Note that $r_2$ is finite when $\theta \in (\theta_d, \pi/2)$ since $\beta = \beta^* > (\pi/2-\theta)/d$. Again, \cref{item:7,item:9,item:10,item:11} in \Cref{lem:generic-right-half-plane} are satisfied by construction. We now show that \cref{item:8} holds. To see this, we first note that when $\theta_d < \theta < \pi/2$, \cref{item:8} holds since in that case, \cref{eq:14} and the definition of $\beta^*$ give $r_2=\frac{\tan((\pi/2-\theta)/d)}{\sin(\beta^*)-\cos(\beta^*)\tan((\pi/2-\theta)/d)}= \frac{\tan((\theta+\beta^*)/d)}{\sin(\theta)}=r_{1,d}(\theta) \geq r$. In the remaining case $\theta = \pi/2$, \cref{item:8} holds since in that case, \cref{eq:14} gives again $r_2 = \tan(\pi/(2d)) = r_{1,d}(\pi/2) \geq r$. \qedhere \end{enumerate} \end{proof} \begin{remark}\label{rem:right-improvement} We remark that the zero-free region established in \Cref{lem:righthalfplane_better} contains the zero-free region described in the manuscript \cite{bencs18:_note} when $\arg \lambda = \theta \leq \theta_d$ (recall also from the paragraph just before the statement of \Cref{lem:righthalfplane_better} that $\theta_d$ is always greater than $\pi/6$). For such $\theta$, the above theorem gives zero-freeness for all $\lambda$ with $\abs{\lambda} < \tan(2\theta/d)/\sin(\theta)$ and $\arg(\lambda) = \theta$. On the other hand, the zero-free region in Theorem 1.4 of~\cite{bencs18:_note} requires at least that $\abs{\lambda} \leq \tan(\pi/(2d))$. But when $d \geq 2$ and $\theta \in (0, \pi/2)$, elementary arguments involving the convexity of the function $\theta \mapsto \tan(2\theta/d) - \sin(\theta)\tan(\pi/(2d))$ in the interval $(0, \pi/ 2)$ imply that $\tan(\pi/(2d))< \tan(2\theta/d)/\sin(\theta)$, showing that \cref{lem:righthalfplane_better} gives a larger zero-free region. For the case $\theta = \pi/2$, we compute directly that $r_{1, d}(\pi/2) = \tan(\pi/(2d))$. For the case $\theta_d < \arg \lambda < \pi/2$, the zero-free region in \cite{bencs18:_note} has only an implicit description, and numerical calculations show that even in this case, the zero free region described in \cref{lem:righthalfplane_better} is better than the one in \cite{bencs18:_note}, except possibly in the close vicinity of $\theta = \pi/2$. \end{remark}
{'timestamp': '2022-04-12T02:32:24', 'yymm': '2204', 'arxiv_id': '2204.04868', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04868'}
arxiv
\section{Introduction} \subsection{Background and Motivations} Driven by the Covid-19 pandemic, the Metaverse has gained huge interest recently from different industry and public sectors~\cite{Jeong_2022, Papyshev2021ExploringCD, Minerva_2020}. Considered as the next generation of the Internet, the Metaverse enables users and objects to experience near real-life interaction with each other in the virtual environment through their avatars. The Metaverse is made up from different emerging technologies such as virtual reality (VR), augmented reality (AR) and haptic sensors. Furthermore, other emerging technologies such as beyond 5G and 6G are driving the Metaverse from imagination and fiction towards real world implementation as they enable users to access the Metaverse from anywhere, anytime instantly~\cite{Chen_2018}. Digital twin modeling of the physical world in the Metaverse have a number of benefits for different application scenarios. For example, creating a virtual copy of the workplace enables employers to bridge the gap between working from office and working from home. Another example appears in the smart vehicles area, where several companies face significant challenges to train their autonomous vehicles (AVs) in the real world. A digital twin of the road, vehicles and other objects can be created, and then the AVs are trained in the Metaverse. Instead of training the AVs on the real road network which is a high risk task, training in the Metaverse is much safer as road accidents in the Metaverse are not reflected to the real world, but the experiences are identical. More importantly, the experiences faced in the Metaverse are learnable by the learning model of the AVs~\cite{Amini_2020}. An agriculture company can enable smart farming by creating a digital twin of the farm. IoT devices deployed in the field can collect several types of data about the plants and the soil, and then send it back to the edge server of the company through an unmanned aerial vehicle base station (UAV-BS) relay~\cite{Verdouw_2021_farming}. This enables farmers to simulate and observe effects of interventions with real-time data before physical interventions can take place. As the digital twins are required to replicate the physical real-world system to the finest details~\cite{Minerva_2020}, generating an accurate 3D model of the physical system is the first step towards this goal. However, the creation of an accurate 3D digital copy is challenging for several reasons. First, the collection of data about the environment requires different types of sensors, e.g., cameras, radars and LIDARs, which are required to be located at the region of interest of the VSP. It will be costly for the VSP to deploy IoT devices equipped with the aforementioned sensors for each task which are dynamic in both time and location. Second, the collected data by the IoT devices is huge in size and the available bandwidth for data transmission will quickly exceed the system limitation. To enable a real-time construction of the digital twin in the Metaverse, the communication system needs to be carefully designed as to maximize successful data transmission while minimizing the latency of packet delivery. \subsection{Contribution} In this paper, we study the paradigm of digital twin construction over wireless channels from the communication and computation perspective. As the study of the Metaverse is still in its infancy, only few works addressed the aspect of wireless resource allocation for the Metaverse. In~\cite{Han2021ADR}, an IoT-assisted Metaverse sync problem is studied in which an evolutionary game is formulated to enable the IoT devices to select VSPs to work for. However, the volume of the data and the limited bandwidth problem was not addressed. In contrast, our work mainly focuses on addressing the issue faced during data transmission from IoT devices to the VSP. Specifically, we propose the transmission of only semantic information to the VSP instead of raw data. Since the semantic extraction from raw data depends heavily on the data type, we focus in this work on the case of camera and radar sensors for AV systems~\cite{Yang_2022, Ouaknine_2021_ICCV}. This is motivated by the fact that camera and radar sensors produce data with high volume and consume a large amount of bandwidth for transmission. However, our framework is straightforwardly to apply to other sensor types (e.g., voice recording) and other use cases of the Metaverse with changes only to the semantic valuation function. We then leverage existing IoT devices such as existing AVs and smart phones to transmit their data to the VSP (Figure~\ref{fig:sys_model}). The VSP sends a UAV-BS to its region of interest to collect data. Beside the cost efficiency, this solution is scalable as it enables the VSP to hire IoT devices to satisfy the targeted QoS. However, IoT devices might take advantage of the importance of their semantic information to the VSP and increase their revenues by selling their data much higher than their true value. To overcome this manipulation of the strategic interaction, we develop a reverse auction mechanism that incentivizes IoT devices to make their bids to sell semantic information to the VSP truthfully. Our main contributions are as follows: \begin{itemize} \item We propose a novel design for digital twin construction in the Metaverse by leveraging semantic information extraction algorithms. The obtained semantic information are sent to the VSP instead of the raw data, reducing the size of the transmitted data and consequently the latency. \item To collect data from IoT devices, we propose that the VSP sends a UAV-BS to its region of interest. A reverse auction mechanism is developed then to select the set of IoT devices that can access the wireless bandwidth and sell their semantic information to the VSP. \item We conduct extensive simulations to validate our proposed model. The major finding is that the use of semantic information transmission enables more IoT devices to transmit their data to the VPS compared to traditional raw data transmission. This enables the VSP to have a variety of data sources and fast rendering of the digital twin in the Metaverse. \end{itemize} In Section~\ref{sec:system_moedl}, we describe our proposed semantic information marketing model. In Section~\ref{section:SW_max} we formulate the social welfare maximization problem. Simulation results are presented in Section~\ref{section:simulation} and Section~\ref{section:conclusion} concludes the paper. \section{System Model: semantic information Market}\label{sec:system_moedl} \subsection{Preliminaries About semantic information} As illustrated in Figure~\ref{fig:sys_model}, we consider a Metaverse market which consists of a virtual service provider (VSP) and a set of $\mathcal{N} = \{1, \dots, N\}$ IoT devices, i.e., data owners. The VSP is responsible for the construction of the digital twin in the Metaverse based on the collected data from the selected set of IoT devices. Each IoT device has a set of sensors to collect geo-spatial data from the surrounding environment and has a machine learning (ML) model to extract semantic information from the collected raw data. Different from traditional crowd-sensing platforms that collect all the raw data from the IoT devices, the VSP obtains only semantic information (e.g., semantic mask for each object with its corresponding class), which is motivated by the following reasons: \begin{itemize} \item The number of channels available to the VSP are limited. Hence, if the VSP allows transmission of raw data by the IoT devices, only few devices will be able to transmit their data which might be of less importance than the data of other non-selected IoT devices. \item Raw data is large in size in general (e.g. video and images), which can increase the transmission delay making the rendering of the digital twin very slow and obsolete. \item The quality of the constructed digital twin will be higher as more semantic information about the physical world will be available to the VSP. \end{itemize} \begin{figure}[ht!] \centering \includegraphics[width=.40\textwidth,height=4.5cm]{mataverse_auction.eps} \caption{Exemplary use cases of semantic information for the Metaverse.} \label{fig:sys_model} \end{figure} \subsection{Service Cost in the Metaverse Market} The IoT device needs to calculate the cost of collecting data, extracting the semantics from raw data and the communication costs required to transmit the semantic information to the edge server. \subsubsection{Computation Cost} The computation cost for data collection for IoT device $i$ is defined as follows~\cite{Yutao_2020_TMC}: \begin{equation}\label{eq:c_i_R} c_i^R = \sum\limits_{k=1}^{m_i} d_{ik}^R \alpha_{ik}^R \end{equation} \noindent where $d_{ik}^R$ is the size of the collected raw data and $\alpha_{ik}^R$ is the per unit computation cost for sensor $k$ by the IoT device $i$. $m_i$ is the number of sensors supported by the IoT device $i$. The cost of the semantic extraction is primarily based on the amount of energy required to perform the semantic extraction which can be formulated as \begin{equation} c_i^{S} = \Delta t \gamma_i \end{equation} \noindent where $\Delta t$ is the time required for the semantic extraction given the input raw data and $\gamma_i$ is the per time step computation cost. The total computation cost is then \begin{equation}\label{eq:c_i_p} c_i^p = c_i^R + c_i^{S} = \sum\limits_{k=1}^{m_i} d_{ik}^R \alpha_{ik}^R + \Delta t \gamma_i . \end{equation} \subsubsection{Communication Cost} When transmitting semantic information to the VSP on $C_i$ channels with capacity $r$ for each channel\footnote{For simplicity, we consider a frequency-division multiple-access (FDMA) communication scheme, with other schemes straightforwardly applicable with appropriate adjustment to the cost function.}, the resulting communication cost to the IoT device $i$ is defined as~\cite{Yutao_2020_TMC} \begin{equation}\label{eq:c_i_m} c_i^m = r C_i \beta_i \end{equation} \noindent where $\beta_i$ is the per unit energy cost for transmission. By summing~\eqref{eq:c_i_p} and~\eqref{eq:c_i_m}, the total service cost is \begin{equation} c_i = c_i^p + c_i^m = \sum\limits_{k=1}^{m_i} d_{ik}^R \alpha_{ik}^R +\Delta t \gamma_i + r C_i \beta_i . \end{equation} \subsubsection{Semantic Information Value} Not all the extracted semantic information have the same value. For instance, if the IoT device has predicted a car collision, the device should value this information more and hence increase its price when selling the semantic information to the VSP. Therefore, the IoT device should include the valuation of the derived semantic information based on the sensitivity of its content in the final service cost valuation. The semantic information value/reward is then defined as follows: \begin{equation}\label{eq:R_i_S} R_i^{S} = \left[ \sum\limits_{j=1}^{O_t} \left( \delta^{j}_1 + \delta^{j}_2 + \delta^{j}_3 + \delta^{j}_4\right) q(j) \right] \frac{1}{w_t} + \frac{1}{d^R_i} \end{equation} \noindent where $O_t$ is the number of objects detected at time $t$, $\delta^{j}_1$, $\delta^{j}_2$, $\delta^{j}_3$ and $\delta^{j}_4$ are binary variable that reflects the existence of semantic information about the relative speed, size, relative position and moving direction for the object $j$, respectively. $q(j)$ is the model quality for the detected object $j$. For example, the quality function can be the intersection over unit (IoU) for image segmentation or the accuracy for object detection. Finally, $w_t$ is the weather condition at time $t$ scaled between zero and one. If the weather condition is bad, i.e., close to zero, the derived semantic information valuation $R_i^S$ will increase, reflecting its high value to the VSP. The last term $\frac{1}{d^R_i}$ indicates the importance of data size to the VSP. For example, if two IoT devices have the same semantic value for certain data, the IoT device that provides this data with a smaller size is preferred by the VSP. \subsection{Auction Based Metaverse Service Market} In our considered system model, as there are several sellers (the IoT devices) and one buyer (the VSP), a reverse auction, where the traditional roles of buyer and sellers is reversed, is appropriate for our system design~\cite{Nisan_2007}. Therefore, to select the set of IoT devices to collect data from, the VSP conducts a reverse auction. Each IoT device bids for the price it is willing to sell its semantic information to the VSP. This is modeled as a competition on the channels provided by the VSP through its UAV-BS. Therefore, the IoT devices tries to increase their bids $\mathbf{b} =( b_{1}, b_{2}, \dots, b_{N})$ to gain access to the minimum number of channels required to transmit their data. Since all sensors do not have the same data quality due to their location and hardware specifications, the VSP needs to choose the winners based on their semantic information quality in addition to data size and bid value. The IoT device $i$ reports its type $t_i=\{b_i, R_i^S \}$ and the number of channels $C_i$ required to transmit its data. The IoT device is single minded, i.e., it either take all the request set of channels or any~\cite{Nisan_2007}. Additionally, The VSP requires information freshness, i.e., the transmitted data should not exceed a certain time threshold $t_{max}$ which is broadcasted before the beginning of the auction. The IoT devices use this threshold to determine the required number of channels to transmit their local data within the specified threshold. \section{Social Welfare Maximization Reverse Auction}\label{section:SW_max} The IoT device's utility is the difference between its payment and service cost (computation cost and communication cost), which is expressed as \begin{equation}\label{eq:u_i} u_i = p_i - R_i^{S} - b_i \end{equation} \noindent where $b_i=c_i$. The utility of the VSP is the sum of all IoT devices' semantic information rewards minus the cost $\hat{c}$ of allocating the channels from the wireless service provider and the sum of payments to the winners, which is written as \begin{equation} \hat{u} = \sum\limits_{i=1}^{\mathcal{|N|}}\xi_i R_i^S - \sum\limits_{i=1}^{\mathcal{|N|}}\xi_i p_i - \hat{c} \end{equation} \noindent where $\xi_i$ is a binary decision variable that indicates if IoT device $i$ is chosen among the winners ($\xi_i=1$) or not ($\xi_i=0$). The social welfare of the system is defined as the sum of the utilities of all the system entities (the VSP and the IoT devices), which is written as \begin{equation} S(\xi) = \sum\limits_{i=1}^{\mathcal{|N|}}\xi_i u_i + \hat{u} = - \sum\limits_{i=1}^{\mathcal{|N|}} \xi_i b_i - \hat{c} . \end{equation} The social welfare is regarded as the system efficiency~\cite{Zhang_2017_welfare} and hence, maximizing the social welfare implies an efficient Metaverse market system. The social welfare maximization is formally written as an integer linear programming (ILP) problem as follows: \begin{subequations} \label{eq:optz_1} \begin{align} \begin{split} \max_{\xi} S(\xi) = - \sum\limits_{i\in \mathcal{N}} \xi_i b_i - \hat{c}, \label{eq:MaxA} \end{split}\\ \begin{split} \hspace{1cm} s.t. \sum_{i\in \mathcal{N}} \xi_i C_i \leq B \label{eq:MaxB} \end{split}\\ \begin{split} \hspace{1cm} \xi_i \in \{0,1\}, \forall i\in \mathcal{N} \label{eq:MaxC} \end{split} \end{align} \end{subequations} \noindent where $B$ is the number of channels provided by the VSP. The ILP presented in~\eqref{eq:optz_1} can be solved using a deterministic off-the-shelf solver or using a heuristic algorithm~\cite{Ismail_2021_Globecomm}. In Section~\ref{section:experiments}, we implement and compare both solutions. To avoid manipulation of the market by malicious IoT devices, e.g., gaining a higher utility than deserved or getting a negative utility, the mechanism should guarantee the properties of incentive compatibility (IC) and individual rationality (IR). Therefore, in the following, we present the payment rule for winning IoT devices and prove the properties of IC and IR. \subsubsection{Payment Rule} The payment rule for winning IoT devices is based on VCG mechanism payment~\cite{Zhang_2017_welfare} and is represented as follows: \begin{equation}\label{eq:payment} p_k = S(\xi^*) - S_{\mathcal{N}\backslash\{k\}}(\varphi^*) + (R_i^{S} +b_k)\xi_k, \end{equation} \noindent where $\xi^*$ is the optimal allocation for IoT devices given the bidding and demand vectors, and $S(\xi^*)$ is the corresponding maximal social welfare obtained from~\eqref{eq:optz_1}. $S_{\mathcal{N}\backslash\{k\}}(\varphi^*)$ is the maximal social welfare when IoT device $k$ is not among the participant in the auction where $\varphi^*$ represents the corresponding optimal allocation strategy. \subsubsection{Incentive Compatibility and Individual Rationality} \begin{theorem}\label{them_1} The proposed VCG-based reverse auction mechanism is incentive compatible. \end{theorem} \begin{IEEEproof} We consider two cases for the IoT device $k$ in the set of bidders:\\ \textit{Case 1:} The submitted bid $b_k$ by the IoT device $k$ is equal to its true valuation $c_k$. In this case, by substituting~\eqref{eq:payment} in~\eqref{eq:u_i}, the utility is written as \begin{equation}\label{eq:u_k_truthfull} u_k = S(\xi^*) - S_{\mathcal{N}\backslash\{k\}}(\varphi^*) \end{equation} \textit{Case 2:} The submitted bid $b_k^{'}$ by the IoT device $k$ is different from its true valuation, i.e., $b_k^{'} \neq c_k$ and the utility is written as \begin{equation} u_k^{'} = S(\xi^*{'}) - S_{\mathcal{N}\backslash\{k\}}(\varphi^*{'}) + \xi_k^*{'}b_k^{'} - \xi_k^*{'}c_k \end{equation} \noindent We note that the optimal allocation strategy in the absence of the IoT device $k$ in the auction in both cases is the same, i.e., $S_{\mathcal{N}\backslash\{k\}}(\varphi^*) = S_{\mathcal{N}\backslash\{k\}}(\varphi^*{'})$. The difference between the utilities of the above two cases is then calculated by: \begin{equation*} u_k^{'} - u_k = S(\xi^*{'}) - S(\xi^*) + \xi_k^*{'}b_k^{'} - \xi_k^*{'}c_k \end{equation*} \begin{equation*} = \left[ - \sum\limits_{i\neq k}^{\mathcal{|N|}} \xi_i^*{'} b_i - \xi_k^*{'} b_k^{'} \right] - \left[ - \sum\limits_{i=1}^{\mathcal{|N|}} \xi_i^* b_i \right] + \xi_k^*{'}b_k^{'} - \xi_k^*{'} c_k \end{equation*} \begin{equation} = \left[ - \sum\limits_{i=1}^{\mathcal{|N|}} \xi_i^*{'} b_i \right] - \left[ - \sum\limits_{i=1}^{\mathcal{|N|}} \xi_i^* b_i \right] \end{equation} If $u_k^{'} - u_k > 0$, then the IoT device has an incentive to deviate from $\xi^*$. However, since $\xi^*$ is the optimal solution for the ILP in~\eqref{eq:optz_1}, and hence better than any other solution (e.g., $\xi^*{'}$), we have $u_k^{'} \leq u_k$. Therefore, the IoT devices cannot obtain any benefit by misreporting their true valuation of their data. Note that the IoT device might submit a higher semantic value than its true value to gain access to the channels and sell its data with higher price. However, both the ILP problem in~\eqref{eq:optz_1} and the utility of the IoT device in~\eqref{eq:u_k_truthfull} are independent from the value of the submitted semantic value $R_i^{S}$, giving no incentive to the IoT device to submit untruthful value of $R_i^{S}$, concluding the proof. \end{IEEEproof} \begin{theorem}\label{them_2} The proposed VCG-based reverse auction mechanism has the property of individual rationality. \end{theorem} \begin{IEEEproof} Given that the mechanism is truthful, we consider two cases: \textit{Case 1:} $S(\xi^*) \geq S_{\mathcal{N}\backslash\{k\}}(\varphi^*)$, then based on~\eqref{eq:u_k_truthfull}, $u_k \geq 0$. Hence, the IoT device $k$ will get non-negative utility after joining the auction. \textit{Case 2:} $S(\xi^*) < S_{\mathcal{N}\backslash\{k\}}(\varphi^*)$. In this case, since $\mathcal{N}\backslash\{k\} \subset \mathcal{N}$, the VSP will have much more options to choose from with $\mathcal{N}$ rather than with $\mathcal{N}\backslash\{k\}$ implying that $S(\xi^*) \geq S_{\mathcal{N}\backslash\{k\}}(\varphi^*)$ and $u_k \geq 0$. Therefore, Case 2 cannot be realized and the proposed VCG-based reverse auction mechanism has the property of individual rationality. \end{IEEEproof} \section{Experiments}\label{section:experiments}\label{section:simulation} In this section, we conduct experiments on real world data and present numerical results to evaluate the performance of our proposed reverse auction mechanism. Unless otherwise stated, we consider that $N=20$, $t_{max}=1s$, and that the channel's capacity for each IoT device is fixed to $r= 10 kbps$. \begin{figure} \centering \begin{subfigure}{.45\textwidth} \centering \includegraphics[width=.89\linewidth,height=1.75cm]{sem_camera.eps} \caption{Camera view.} \label{fig:sem_camera} \end{subfigure}\\ \begin{subfigure}{.45\textwidth} \centering \includegraphics[width=.89\linewidth,height=2.0cm]{sem_RD.eps} \caption{Range-Doppler view.} \label{fig:sem_RD} \end{subfigure}\\ \caption{A scene from CARRADA dataset from different views with their respective semantic segmentation, with a cyclist and a pedestrian. The blue mask in (b) represents the pedestrian while the green mask represents the cyclist.} \label{fig:sem_views} \end{figure} \subsection{Dataset and Experimentation's Settings} We conduct our experiments on CARRADA dataset~\cite{Ouaknine_CARRADA_2020} which is a recent, open dataset that contains 30 scenes of synchronized sequences of camera and radar images. The radar images consists of the range-angle (RA) and the range-Doppler (RD) views. Figure~\ref{fig:sem_views} illustrates sample images from the CARRADA dataset where a cyclist and a pedestrian are moving into the opposite directions. To extract the semantic information from the raw data, different algorithms are used based on the supported sensors on the IoT device. We consider 4 types of IoT devices that use different semantic extraction algorithms. For devices with camera sensors only, Mask R-CNN algorithm for semantic segmentation and bounding boxes is used~\cite{He_2017_ICCV}. For devices with radar sensors only, RAMP-CNN (for RA view only), FCN-8s (for either RA or RD views) and, TMVA-NET (for RA and RD views) are used~\cite{Ouaknine_2021_ICCV, Ouaknine_CARRADA_2020, Gao_2020_RAMP_CNN}. We adopt simulation settings similar to~\cite{Ouaknine_2021_ICCV}. Each IoT device is considered to use one of the aforementioned algorithms based on a uniform distribution. For devices with both camera and radar sensors, a combination of these algorithms is used instead. As an output for the aforementioned semantic segmentation algorithms, a white background image which contains the masked objects (see Figure~\ref{fig:sem_views}) is produced in addition to a meta-data text file (in JSON format) that contains a mapping between each object in the image with its class and other derived semantic information (e.g., range and shape). The meta-data text file has a maximum size of $d_{meta} = 1 kb$. \subsection{Results} \subsubsection{Impact of The Solver on The Social Welfare} First, we evaluate the efficiency of our proposed ILP reverse auction algorithm. The ILP is solved deterministically using \emph{Gurobi optimizer} and the results are compared to the heuristic auction algorithm proposed in~\cite{Ismail_2021_Globecomm} with the payment rule adjusted to follow~\eqref{eq:payment}. We observe from Figure~\ref{fig:exp_2} that both solvers reach an equivalent optimal solution when the number of channels is higher than $30$. However, when the number of channels is lower, i.e., from $10$ to $25$, the heuristic algorithm is not able to reach the optimality derived by the deterministic optimizer. This is explained by the fact that the heuristic algorithm first sorts the IoT devices (bidders) based on their bids and stops the search for potential winners once the social welfare stops increasing. This makes the algorithm deviate from the optimal solution as other potential combination of winners is not explored. In what follows, we only consider the use of the deterministic optimizer to solve the social welfare maximization problem. \begin{figure}[ht!] \centering \includegraphics[width=.40\textwidth,height=3.8cm]{exp_2.eps} \caption{Impact of the solver on the social welfare.} \label{fig:exp_2} \end{figure} \subsubsection{Impact of semantic information Transmission on The Metaverse} We consider two types of transmission: the first one consists of transmitting raw data, i.e., no semantic information extraction, and the second one consists of transmitting only the semantic information extracted from the raw data. We observe from Figure~\ref{fig:exp_1} that as the number of channels $B$ provided by the VSP increases, the number of winners for the case of semantic information transmission also increases (up to 12 winners). However, in the case where only raw data is transmitted, the number of winners is very low ($1$ to $2$ winners) and almost remain unchanged, making the VSP relies heavily on the inputs of a small set of IoT devices. This result is explained by the fact that raw data has significantly a larger size compared to the size of semantic information and therefore one winner can use up to half of the available channels. Furthermore, even if the channels are fully allocated in both cases, the received data by the VSP might be insignificant in case of raw data transmission (e.g., in case of camera image, the captured image can be taken from an angle where no object is present). Specifically, if the VSP tries to create a copy of the physical world using the received raw data, the constructed virtual world would have a very poor quality and cannot capture the real dynamics of the system (e.g., congestion of the road). However, in case of semantic information transmission, the VSP has a variety of data sources/views which are rich of semantic information, e.g., instances and their shape or relative speeds, showing the importance of semantic information and heterogeneity of data sources. This result also indicates that our formulation of the utility functions is able to select IoT devices with more valuable semantic information as winners and hence, transmit their data to the VSP. An important point to highlight is that as more IoT devices send their data to the VSP, the chances of having redundant information increase, which helps creating a more reliable virtual environment. \begin{figure}[ht!] \centering \includegraphics[width=.40\textwidth,height=3.8cm]{exp_1.eps} \caption{Impact of the number of channels on the number of winners and social welfare.} \label{fig:exp_1} \end{figure} Interestingly, we observe from Figure~\ref{fig:exp_1} that when the number of channels increases from $25$ to $30$, the number of winners drops by $1$. This is due to the fact that some IoT devices that have more valuable information but require a larger number of channels are not selected as winners when fewer channels are available, i.e., $B=25$. However, when the number of channels increases to $30$, the winner list changes to contain fewer IoT devices but they can provide a higher social welfare, which is clearly observable in Figure~\ref{fig:exp_1} (red dotted curve). \subsubsection{Impact of the semantic information Extraction Algorithms and The Input Data on The Winner List} To observe how the winner list changes based on the semantic information extracted from data, we consider two identical groups of IoT devices where each group has 5 IoT devices and use different semantic information extraction algorithms as described in Table~\ref{table:1}. We provide the first group with scenes that contains 3 objects while the second group is provided with scenes which have only one object. The total number of participating IoT devices is then $N=10$ and the number of channels is varied from 3 to 21. We observe from Figure~\ref{fig:exp_3} that the first IoT devices to join the winner list after the number of available channels increases are from group 1. This is justified by the fact that input scenes for group 1 contains more semantic information than group 2. Interestingly, when the number of channels increases to 15, IoT device 5 from group 2 join the winner list leaving one element from group 1 not in the winner list. This is due to fact that IoT device 5 has camera and radar sensors and is using both Mask R-CNN and TMVA-NET algorithms for semantic extraction which have high quality of extracting significant semantic information. The remaining element from group 1 is IoT device 2 uses RAMP-CNN for radar semantic extraction, which has the lowest performance compared to other algorithms~\cite{Ouaknine_2021_ICCV}. \begin{table}[ht!] \begin{center} \caption{Semantic extraction algorithms for different IoT devices.} \begin{tabular}{ ||p{1.3cm}|p{2.20cm}|p{3.5cm}|| } \hline IoT device & Sensor(s) & Semantic algorithm(s) \\ \hline\hline 1 & camera & Mask R-CNN \\ \hline 2 & radar & RAMP-CNN (RA) \\ \hline 3 & radar & FCN-8s (RA) \\ \hline 4 & radar & TMVA-NET (RA and RD) \\ \hline 5 & camera \& radar & Mask R-CNN + TMVA-NET \\ \hline \end{tabular} \label{table:1} \end{center} \end{table} \begin{figure}[ht!] \centering \includegraphics[width=.40\textwidth,height=3.8cm]{Barchart.eps} \caption{Impact of the extracted semantic information on the winner list. Green boxes represent IoT devices from group 1 and red boxes represent IoT devices from group 2.} \label{fig:exp_3} \end{figure} \section{Conclusion}\label{section:conclusion} In this paper, we presented a novel design to address the problem of data transmission over the wireless channels in the Metaverse. Specifically, we considered the scenario where a VSP is collecting data from the physical world using IoT devices in the field to create a digital twin of the road for AV training. We then proposed the use of semantic information extraction algorithms by the IoT devices to transmit only semantic information to the VSP instead of raw data. This significantly reduces the data transmission volume over the wireless network. It also enables more IoT devices to access the channels and the VSP to access a heterogeneity of data sources. As many IoT devices are interested in selling their semantic information to the VSP, we designed a reverse auction mechanism that has the properties of IC and IR to enable the VSP to choose the winners. Simulation results show that our proposed novel design is able to intelligently select IoT devices that have more semantic information and enable the VSP to create a high quality digital copy of the physical world. To further improve our design, we consider as a future work the use of a prediction model by the VSP to be trained on masked images to create scenes which have been lost during communication due to link failures. \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:32:52', 'yymm': '2204', 'arxiv_id': '2204.04878', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04878'}
arxiv
\section{Introduction} \label{sec:intro} State-of-the-art computer vision models are often trained as task-specific models that infer a fixed number of labels. In contrast, \cite{radford2021learning} have demonstrated that by training an image-text matching model that employs Transformers for encoding each modality, tens of downstream tasks can be performed without further training (``zero-shot''), with {comparable accuracy} to the state of the art. {Due to its zero shot capabilities and its semantic latent space,} CLIP~\citep{radford2021learning} has been widely used in recent research to guide pretrained generative networks to create images according to a text prompt~\citep{gal2021stylegannada,vqgan+clip,Liu2021FuseDreamTT} and edit an input image according to a text description~\citep{kim2021diffusionclip,patashnik2021styleclip,Avrahami2021blendeddiffusion}. While CLIP shows great promise in zero-shot image classification tasks and generative network guidance, it suffers from instabilities that often lead to biased similarity scores between non-matching text and image pairs. To mitigate these instabilities, Radford et al. suggest a prompt engineering technique that averages the embeddings of multiple textual templates~\citep{radford2021learning}. Since CLIP summarizes the relation between a given image and a given text with a single similarity score, it can present a myopic behavior and focus on specific elements within the sentence and/or the image. In order to alleviate this issue, it is necessary to rely {on an additional signal}. In this work, we propose using the explainability maps to steer the optimization process towards solutions that rely on the relevant parts of the input, and away from solutions that focus on irrelevant parts, or on a small subset of the relevant parts. We explore two domains in which we guide CLIP to account for the important tokens in an input {prompt:} {one-shot} classification and {zero-shot} text-based image generation. For {one-shot} classification, we incorporate a loss based on the explainability scores of the class name in the prompt engineering method proposed by~\citep{zhou2021coop}. Our results demonstrate that guiding the prompt engineering process using explainability improves performance in both the class-agnostic and the class-specific cases. In the domain of image editing guided by text, we employ a similar explainability-based loss. This loss allows the generative network to avoid local minima caused by focusing on irrelevant words in the input text, by requiring the explainability scores of important tokens to be high. We demonstrate that our method significantly improves the generated images. Additionally, by applying similar principles to the image-side relevancy map, we use the obtained heatmaps to facilitate CLIP-guided text-based image generation with spatial conditioning. As far as we can ascertain, we are the first to present a spatial layout to image method using CLIP. As we demonstrate, a straightforward application of the similarity score over {a requested} bounding box does not guarantee that the entire object will be contained within that bounding box. When relying on the explainability heatmap, our method helps ensure that the object does not deviate from the provided bounding box. \section{Related Work} \textbf{Zero-shot classification\quad} Zero-shot classification in computer vision usually refers to a model's ability to generalize to unseen labels. While several works used weakly labeled Google images as training data~\citep{Berg_animals,Chen2015WeblySL,Fergus,Rubinstein,Tang,Vijayanarasimhan,Wang} the method of \citep{Li_2017_ICCV} was perhaps the first to study zero-shot transfer learning to unseen datasets, which is a broader approach to zero-shot classification. This approach was adopted by CLIP~\citep{radford2021learning}, which trains an image-text matching engine using an image encoder and a text encoder, via contrastive learning. The image encoder architectures used are either ViT~\citep{dosovitskiy2020image} or ResNet~\citep{he2016deep}, and the text encoder is based on a Transformer~\citep{vaswani2017attention} with the modifications of \citep{Radford2019LanguageMA}. CLIP was trained on a set of $400M$ matching image-text pairs, and showed remarkable zero-shot capabilities on the ImageNet dataset~\citep{Deng2009ImageNetAL}. Following CLIP, \citep{zhou2021coop} proposed few-shot prompt engineering to enhance CLIP's classification accuracy on unseen datasets. Their approach opts to learn the textual templates fed to CLIP rather than manually engineering them, as originally done by \citep{radford2021learning}. \smallskip \noindent\textbf{CLIP-guided Generation\quad} Following the success of CLIP in zero-shot classification, several works have used the similarity scores produced by CLIP to guide { pretrained} generative networks. These methods usually construct a similarity-based loss, encouraging a generator to produce the output with the desired semantic attributes. Some of the applications of CLIP for guiding generative networks include image manipulation~\citep{patashnik2021styleclip}, image essence transfer~\citep{chefer2021imagebased}, style transfer~\citep{gal2021stylegannada,Zhu2021MindTG}, 3D object style editing~\citep{Michel2021Text2MeshTN}, and image captioning~\citep{Tewel}. \smallskip \noindent\textbf{Transformer Explainability\quad} Many methods were suggested for generating a heatmap that indicates local relevancy, given an input image and a CNN~\citep{selvaraju2017grad,binder2016layer,lundberg2017unified,shrikumar2016not}. However, the literature on Transformer explainability is relatively sparse and most methods focus on pure self-attention architectures~\citep{abnar2020quantifying,Chefer_2021_CVPR}. The recent method of \citep{Chefer_2021_ICCV}, which we employ in this work, is the first to also offer a comprehensive method for bi-modal networks. \section{Method} \label{sec:method} We begin by describing how to produce relevance values for each word and image patch using CLIP. We then describe how our method is applied to one-shot classification via prompt engineering and to zero-shot image generation. \subsection{Explainability} \label{sec:explainability} Given a pair of text $t$ and image $i$, CLIP produces a score $\text{CLIP}(t,i)$, which determines how semantically similar the textual description $t$ is to the image $i$. The goal of the explainability method is to produce a relevance score for each input text token and image patch in the computation of the similarity score $\text{CLIP}(t,i)$. The score of each token should reflect its impact on the similarity score, and input tokens with the greatest influence on the similarity score should receive a high relevancy score, and vice versa. We employ the method described in \citep{Chefer_2021_ICCV} to produce a relevance score for each image patch and text token, given the calculated similarity score. As the relevance scores are calculated per token, we define the relevance score of a word to be the maximal relevance score among its tokens. For each word $W=w_1,...,w_n$, where $w_1,...w_n$ are the tokens it contains, we define its relevance score $\mathcal{R}_{expl}(W)$ as follows: \begin{align*} \mathcal{R}_{expl}(W) = \max_{k\in w_1,...,w_n}\mathbf{R}[k], \end{align*} where $\mathbf{R}[k]$ is the relevance score of \citep{Chefer_2021_ICCV}. \subsection{Prompt engineering} \label{sec:prompt} Image classification is the task of assigning a label from a set of possible classes $c\in C$ to an input image $i$. In order to adapt CLIP to different classification tasks, \citep{radford2021learning} propose employing prompt templates with each possible class $c\in C$ inserted, e.g. ``A photo of a \{label\}.'' These templates are necessary because in the process of CLIP's pre-training most textual inputs are full sentences rather than single words. Let $i$ be the input image to be classified, and let $t$ denote the textual template. $t(c)$ denotes the template $t$, where the \{label\} placeholder was replaced by the class name $c$. CLIP scores per class are obtained using the similarity score between the input image and the class-template as follows: \begin{align} \label{eq:softmaxclip} \Pr(\text{output}=c | i)=\frac{e^{\text{CLIP}(t(c), i)}}{\sum_{c'\in C}e^{\text{CLIP}(t(c'), i)}}. \end{align} \citep{radford2021learning} found that prompt ensembles are highly beneficial for improving zero-shot accuracy. For example, ImageNet~\citep{Deng2009ImageNetAL} zero-shot classification with CLIP improved by $3.5\%$ when using an ensemble of 80 different textual templates, averaged in CLIP embedding space. This may be due to the sensitivity of CLIP's similarity scores to phrasing, which is mitigated by the ensemble. \citep{zhou2021coop} replace the manual selection of the textual templates with a few-shot learning of it. Given a desired template length $M$, a template $t(\text{label})=v_1,...,\{\text{label}\} ,..., v_M$ is optimized with a cross-entropy loss using Eq.~\ref{eq:softmaxclip} to extract the distribution. Note that the learned templates are prone to overfitting, due to the small number of example images for each label, which can result in prompts that describe distinctive parts of the images that are irrelevant to their class, yielding a similarity score $\text{CLIP}(t(c), i)$ that is not based on the class name. This problem is most prominent in the one-shot scenario where the prompts are optimized based on a single image per class. To help avoid this phenomenon, our method employs a novel explainability-based loss. For each class $c\in C$ and image $i$, the similarity score $\text{CLIP}(t(c), i)$ is produced, and then a normalized explainability score is calculated. This score reflects the relevance of the class $c\in C$ to the similarity of the template and the image: \begin{align} \mathcal{S}_{expl}(c) = \frac{\max_{W\in c} \mathcal{R}_{expl}(W)}{\sum_{U\in t(c)}\mathcal{R}_{expl}(U)} \end{align} where, as above, $W\in c$ are the words comprising the label $c\in C$. The score $\mathcal{S}_{expl}(c)$ encapsulates the impact that the class name $c$ has on the calculated similarity score $\text{CLIP}(t(c), i)$, in comparison to all other words in the sentence. Our explainability-based loss is, therefore: \begin{align*} \mathcal{L}_{expl} = \lambda_{expl}\left( -\mathcal{S}_{expl}(c_{gt}) + \sum_{c\neq c_{gt}\in C} \mathcal{S}_{expl}(c) \right) \end{align*} where $c_{gt}$ is the ground truth label, and $\lambda_{expl}$ is a hyperparameter. The first term, $-\mathcal{S}_{expl}(c_{gt})$ encourages the similarity score for the ground truth class to be based on the class name tokens, in order to avoid focusing on other, irrelevant tokens. The second term, $ \sum_{c\neq c_{gt}\in C} \mathcal{S}_{expl}(c)$ encourages the similarity score for all the counterfactual classes to be based on tokens that are not the false class name, since the class name does not correspond to the image. \subsection{Zero-shot text-guided image manipulation} \label{sec:manipulation} Recent research~\citep{patashnik2021styleclip,kim2021diffusionclip} demonstrates that CLIP can be effective for guiding generative networks that synthesize and edit images, by maximizing the similarity score between the desired text and image. As pointed out by~\citep{Liu2021FuseDreamTT}, methods that integrate a pre-trained generator with the CLIP score to allow text-based editing suffer from instabilities, since similarity-based optimization often reaches local minima that do not reflect the desired semantic meaning of the input query. \begin{figure}[t] \centering \begin{tabular}{cccc@{~~~}l} & Input & StyleCLIP & Ours& Colormap\\ \centering{\begin{footnotesize}\pbox[b][][b]{2cm}{Input or\\Output\\~\\~}\end{footnotesize}} & \includegraphics[width=0.18\linewidth, clip] {motivation/purple_orig.png}& \includegraphics[width=0.18\linewidth,clip] {motivation/purple_sc.png}& \includegraphics[width=0.18\linewidth,clip] {motivation/purple_ours.png}&\\ \centering{\begin{footnotesize}\pbox[b][][b]{2cm}{~~Image\\heatmap\\ ~ \\} \end{footnotesize}}& \includegraphics[width=0.17\linewidth,clip] {motivation/orig_expl_img.png}& \includegraphics[width=0.17\linewidth,clip] {motivation/expl_sc.png}& \includegraphics[width=0.17\linewidth,clip] {motivation/expl_ours.png} & \begin{footnotesize}\pbox[b][][b]{2cm}{red=high relevancy\\blue=low relevancy\\}\end{footnotesize}\\ \\ \centering{\begin{footnotesize}\pbox{20cm}{~~Text\\heatmap} \end{footnotesize}}& \includegraphics[width=0.18\linewidth,clip] {motivation/orig_expl_text.png}& \includegraphics[width=0.18\linewidth,clip] {motivation/purple_sc_text.png}& \includegraphics[width=0.18\linewidth,clip] {motivation/purple_ours_text.png} & \centering{\begin{footnotesize}\pbox{20cm}{green=high \\ relevancy} \end{footnotesize}} \end{tabular} \caption{Results for the text prompt ``A person with purple hair''. StyleCLIP~\citep{patashnik2021styleclip} produces a manipulation that is not consistent with the semantic meaning of the prompt, and the color of the person's shirt and the background are altered. Our method generates an output that is faithful to the input text query, and the high values of the explainability heatmaps are much more correlated with the prompt.\label{fig:motivation}} \end{figure} As shown in Fig.~\ref{fig:motivation}, this shortcoming is often manifested in the explainability scores, and is caused by similarity scores relying only on a partial subset of the semantic tokens in the text query. Thus, our method leverages the explainability scores, to ensure that the output similarity scores are derived from all of the tokens that determine the semantic meaning of the input text. Given a pre-trained generator $G$ (a mapping from a latent vector $z$ to an output image), an input image $i$, and an input text $t$, the goal of the optimization algorithm $A$ is to find a vector $A(G, i,t) = z$ such that $G(z)$ combines the visual appearance of image $i$ with the description in the text query $t$. In order to assess the correlation between the manipulation $G(z)$ and the desired semantic property in $t$, the algorithm $A$ uses the CLIP similarity score between the manipulated image $G(z)$ and the textual prompt $t$ as a loss term: \begin{align} \label{eq:loss_sim} \mathcal{L}_{similarity} = -\text{CLIP}(G(z), t). \end{align} This loss is applied in addition to other loss terms that lead to a high visual similarity between $i$ and $G(z)$. As mentioned, $\mathcal{L}_{similarity}$ can produce biased similarity scores, which do not reflect the semantic meaning in $t$, due to focusing only on a subset of the semantically important words in $t$. Our method remedies this bias by adding a loss term that encourages CLIP to attend to all semantic words in $t$. Let $S$ be the set of semantic words in $t$. Since the textual prompts for image editing are of the format: "a person/ man/ woman with \{\textit{description}\}" or of the format "a \{\textit{description}\} person/ man/ woman", the set $S$ is considered to be the words that comprise the description. Our method adds the following explainability-based loss term to the optimization algorithm $A$: \begin{align} \label{eq:expl_gen_loss} \mathcal{L}_{expl} = -\lambda_{expl}\frac{1}{|S|}\left(\sum_{s \in S} \mathcal{R}_{expl}(s) \right), \end{align} where $\lambda_{expl}$ is a hyperparameter. For example, in Fig.~\ref{fig:motivation}, the set of semantic words is defined to be: $S=\{``purple'', ``hair''\}$. This helps the optimization process to favor results where the similarity score is based on the hair color of the subject of the image. As can be seen in the figure, when our loss is not applied, the optimization results in coloring the shirt and the background. \smallskip\noindent\textbf{Choosing $\lambda_{expl}$\quad} Our modified optimization algorithm has an additional hyperparameter $\lambda_{expl}$. Since CLIP-based optimization is sensitive to the choice of hyperparameters, it is better to set them based specifically on the input image $i$, input text $t$, and generator $G$. In order to provide an automatic mechanism for choosing $\lambda_{expl}$, we consider a range of possible $\lambda_{expl}$, and choose the value of $\lambda_{expl}$ for which the similarity predicted by CLIP for the generated image and the input text is maximal. Note that after applying our method, the similarity scores become more stable, as they consider all semantic tokens in the input. \subsection{Zero-shot text-to-image with spatial conditioning} \label{sec:l2i} While the textual descriptions provided to CLIP can include the spatial positioning of objects, images generated by optimizing CLIP similarity score with such texts tend not to follow these spatial restrictions, as shown in Fig~\ref{fig:l2i}. We attribute this to the nature of the task CLIP was trained on, which is predicting how similar a given image is to a given text. The existence of matching entities in both inputs is a stronger indication of their similarity than the positions of the entities. This intuition is reflected in the distribution by speech parts (POS) of the explainability scores calculated for CLIP, as shown in appendix~\ref{app:relevance-pos}. To alleviate this shortcoming of providing spatial positioning with textual description, we add spatial conditioning as an additional input. As far as we can ascertain, CLIP has not been used before for image generation conditioned on spatial masks. The somewhat related task of CLIP-based zero-shot image inpainting was recently successfully performed by \citep{Avrahami2021blendeddiffusion,bau2021paintbyword}, who point out that a simple masking of the input image presented to CLIP, such that the similarity score is only predicted based on a specific region of the image, does not guarantee that the generated object will not deviate from the provided region. {Preventing the generator from producing objects outside the designated spatial locations requires applying additional losses on the background or restricting the optimization process such that only the parts of the latent vector that affect the desired region {of the image} are optimized.} These methods limit the spatial conditioning to applications that receive an input image to be used as unaltered background. However, since the explainability maps produced for CLIP indicate the location of the objects, we can effectively limit the location of generated objects using explainability. \begin{algorithm}[t!] \caption{Obtain IoU loss from masks and image.}\label{euclid} $\mathbf{Input:}$ (i) $m_1,...,m_k$- bounding boxes of the objects to be generated, (ii) $t_1,...,t_k$- textual descriptions of the objects we wish to generate, (iii) $C$- a pre-trained CLIP model. (iv) the input image $i$, (v) a threshold $T$ over relevancy scores (vi) $temp$ - a temperature for the sigmoid operation (vii) $expl$ - the image explainability algorithm for CLIP, which outputs relevance scores for the image patches for each pair of image and text.\\ $\mathbf{Output:}$ $\mathcal{L}_{IoU}$- an explainability-based IoU loss for the input masks $m_1,...,m_k$, and input image $i$. \begin{algorithmic}[1] \STATE $\mathcal{L}_{IoU} \gets 0$ \STATE \emph{for} $j\in \{1,\dots,k\}$,: \STATE \hspace*{2em}$R_j \gets expl(i, t_j)$ \STATE \hspace*{2em}$R_j \gets R_j / R_j.max()$ \STATE \hspace*{2em}$pred\_mask_j \gets sigmoid((R_j - T) * temp)$ \STATE \hspace*{2em}$intersection \gets \sum_{p\in i}(pred\_mask_j[p] \cdot m_j[p])$ \STATE \hspace*{2em}$\mathcal{L}_{IoU} \gets \mathcal{L}_{IoU} + \frac{2*intersection}{\sum_{p\in i}pred\_mask_j[p]+\sum_{p\in i}m_j[p]}$ \end{algorithmic} \label{alg:segm} \end{algorithm} Our method employs an IoU-inspired loss based on the explainability of the image modality. Alg.~\ref{alg:segm} describes how we produce the loss $\mathcal{L}_{IoU}$ given the input spatial conditioning masks $m_1,...,m_k$ and the input image $i$. For each bounding box $m_j$ and the text $t_j$ describing the object we wish to generate in that location, we generate the explainability for CLIP with the entire image $i$ and text $t_j$ (L.3). This explainability map represents the location in which the object is currently found in the image by CLIP. We then transform the explainability map into a semi-binary mask (L.5) by substracting a threshold value $T$ and passing the output through a sigmoid function with high temperature $temp$. This predicted mask is then used to calculate a Dice Loss with respect to the ground truth object mask (L.7). After calculating the IoU-based loss, we incorporate the similarity-based loss as follows: \begin{align} \label{eq:l2i_loss} \mathcal{L} = -\lambda_{expl}\cdot\mathcal{L}_{IoU} - \sum_{j=1}^k\text{CLIP}(i, t_j), \end{align} where $\lambda_{expl}$ is a hyperparameter, and the sum calculates the CLIP similarity between the image and each object we wish to generate, in order to ensure that all objects in $\{t_1,...,t_k\}$ appear in $i$. $\lambda_{expl}$, $T$ and $temp$ are chosen empirically, using examples from the MSCOCO~\citep{ty2014coco} validation set. \section{Experiments} We evaluate our method in various contexts, including one-shot prompt engineering for image classification based on~\citep{zhou2021coop}, {zero-shot} text-guided image manipulation based on~\citep{patashnik2021styleclip}, and {zero-shot} text-guided image generation with spatial conditioning based on CLIP-guidance for VQGAN~\citep{Esser_2021_CVPR,vqgan+clip}. \begin{table}[t] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{@{}l@{~}l@{~}c@{~}c@{~}c@{~}c@{~}c@{~}c@{~}c@{~}c@{~}c@{~}c@{}} \toprule {Image} &&\multicolumn{2}{c}{ImageNet} & \multicolumn{2}{c}{ImageNetV2} & \multicolumn{2}{c}{INet-Sketch}& \multicolumn{2}{c}{ImageNet-A} & \multicolumn{2}{c}{ImageNet-R} \\ {backbone} && Unified & CSC &Unified & CSC &Unified & CSC &Unified & CSC &Unified & CSC \\ \midrule {ResNet-} &CoOp & 53.32 & 25.42 & 46.65& 21.43& 27.60& 10.28& 19.55 & 9.53& 49.72 & 23.29 \\ 50 &Ours & \textbf{55.55} & \textbf{30.07} & \textbf{48.43} & \textbf{25.19} & \textbf{29.41} & \textbf{12.22} & \textbf{21.02}& \textbf{11.48} & \textbf{54.04}& \textbf{26.10} \\ \midrule {ResNet-} &CoOp & 56.49 & 29.11 & 49.90 & 24.59 &33.38 & 14.53 & 26.01 & 12.28& 57.62 & 30.07 \\ 101&Ours & \textbf{58.73} &\textbf{34.46} & \textbf{52.39} & \textbf{28.80} & \textbf{36.19} & \textbf{16.85} & \textbf{27.46}& \textbf{15.20} & \textbf{61.59}& \textbf{34.05} \\ \midrule \multirow{2}{*}{ViT-B/16} &CoOp & 63.12 & 35.52 & 56.11 & 30.12 & 40.78& 20.42& 44.29&22.23 & 68.15& 40.03 \\ &Ours & \textbf{66.1}& \textbf{39.69} & \textbf{59.07} & \textbf{34.29}&\textbf{45.05} & \textbf{23.32}& \textbf{46.41}& \textbf{25.46} &\textbf{74.21}& \textbf{43.00} \\ \midrule \multirow{2}{*}{ViT-B/32} &CoOp &57.50 &30.90 &50.50 & 25.66& 34.78& 15.51& 28.13 & 13.04 & 59.61& 31.88 \\ &Ours & \textbf{60.32} & \textbf{35.93} & \textbf{53.00} & \textbf{30.25} & \textbf{38.24}& \textbf{18.62}& \textbf{30.52}& \textbf{16.50} & \textbf{65.04}& \textbf{37.19} \\ \bottomrule \end{tabular} } \smallskip \smallskip \caption{1-shot accuracy (in percentage) of CLIP~\citep{radford2021learning} with prompts produced by the method of \citep{zhou2021coop} (CoOp) or with our explainability-guided variant, and various image backbones. Unified stands for training a single prompt for all classes, and CSC (class-specific) stands for optimizing a prompt for each class name. Results are averaged over 3 random seeds.} \label{table:promptengineering} \end{table} \begin{figure*}[t!] \centering \begin{tabular}{c@{~~~~}c@{~~~~}c@{~~~~}c} \begin{small} Ours GT \end{small} & \begin{small} Ours CF \end{small} & \begin{small} CoOp GT \end{small}& \begin{small} CoOp CF \end{small} \\ \includegraphics[width=0.2219\linewidth,clip] {PE/necklace/necklace_ours_gt_text.png}& \includegraphics[width=0.2219\linewidth,clip] {PE/necklace/necklace_ours_cf_text.png}& \includegraphics[width=0.2219\linewidth,clip] {PE/necklace/necklace_bl_gt_text.png} & \includegraphics[width=0.2219\linewidth,clip] {PE/necklace/necklace_bl_text.png}\\ \includegraphics[width=0.2219\linewidth,clip] {PE/jigsaw/jigsaw_ours_gt_text.png}& \includegraphics[width=0.2219\linewidth,clip] {PE/jigsaw/jigsaw_ours_cf_text.png}& \includegraphics[width=0.2219\linewidth,clip] {PE/jigsaw/jigsaw_bl_gt_text.png} & \includegraphics[width=0.2219\linewidth,clip] {PE/jigsaw/jigsaw_bl_text.png} \end{tabular} \caption{A qualitative comparison of prompts created by CoOp~\citep{zhou2021coop} with and without our method on exemplary samples from ImageNetV2~\citep{pmlr-v97-recht19a}. We present the textual relevance for both our method and CoOp for the ground truth (GT) class chosen by our method (``necklace", ``jigsaw"), and the counterfactual (CF) class chosen by CoOp (``bolo tie", ``maraca"). The learned vectors for the prompts are annotated by the letter ``v" in the textual maps, since they do not necessarily represent actual words. While our method produces relevance that is focused on the class name tokens, CoOp templates lead CLIP to focus on irrelevant tokens. \label{fig:prompt-eng}} \end{figure*} \begin{table*}[t!] \centering \resizebox{1.0\linewidth}{!}{ \begin{tabular}{lccccccccc} \toprule & \multicolumn{2}{c}{A man with a beard} & \multicolumn{2}{c}{A person with purple hair}& \multicolumn{2}{c}{A blond man}& \multicolumn{2}{c}{A person with grey hair}\\ \cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9} Method &Quality&Identity &Quality&Identity &Quality&Identity &Quality&Identity\\ \midrule SC & 2.92 & \textbf{3.61} & 1.17 & \textbf{4.13} & 3.93 & \textbf{3.67}& 2.59 & \textbf{3.82} \\ Ours & \textbf{4.28} & 2.23 & \textbf{2.29} & 3.51 & \textbf{4.28}& 2.63 & \textbf{3.27}& 3.10\\ \bottomrule \end{tabular} }\smallskip \smallskip \caption{A user study comparing text-based image editing with StyleCLIP (SC) and our method on 4 different textual prompts: ``A man with a beard'', ``A person with purple hair'', ``A blond man'', ``A person with grey hair''. Quality refers to the similarity between the prompt and the manipulation; Identity refers to the identity preservation of the manipulation. Scores are averaged across 20 random seeds, on a scale of 1-5 (higher is better).} \label{fig:userstudy} \end{table*} \begin{figure*}[t!] \centering \begin{tabular}{c@{~}c@{~}c@{~~~}c@{~}c@{~~~}c@{~}c@{~~~}c@{~}c} \centering{\begin{small}\begin{turn}{90} Original \end{turn}\end{small}} & \includegraphics[width=0.10\linewidth, clip]{user_study/beard/orig.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/beard/orig_2.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/purple/orig.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/purple/original_2.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/blond/orig.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/blond/orig_2.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/grey/orig.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/grey/orig_2.png}\\ \centering{\begin{small}\begin{turn}{90} ~~SC \end{turn}\end{small}} & \includegraphics[width=0.10\linewidth, clip]{user_study/beard/sc}& \includegraphics[width=0.10\linewidth, clip]{user_study/beard/ours_sc_2.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/purple/sc.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/purple/ours_sc_2.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/blond/sc.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/blond/ours_sc_2.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/grey/sc.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/grey/ours_sc_2.png}\\ \centering{\begin{small}\begin{turn}{90} ~Ours \end{turn}\end{small}} & \includegraphics[width=0.10\linewidth, clip]{user_study/beard/ours.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/beard/ours_sc_2.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/purple/ours.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/purple/ours_sc_2.png}& \includegraphics[width=0.10\linewidth, clip]{user_study/blond/ours.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/blond/ours_sc_2.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/grey/ours.png} & \includegraphics[width=0.10\linewidth, clip]{user_study/grey/ours_sc_2.png}\\ \cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule(r){6-7} \cmidrule(r){8-9} &\multicolumn{2}{c}{(a)}~~ & \multicolumn{2}{c}{(b)}~ & \multicolumn{2}{c}{(c)}~ & \multicolumn{2}{c}{(d)} \end{tabular} \caption{A qualitative comparison between StyleCLIP {(SC)} and our method on 4 different textual prompts. (a) ``A man with a beard'', (b) ``A person with purple hair'', (c) ``A blond man'', (d) ``A person with grey hair''. For each prompt we present examples where StyleCLIP is successful (right column), and unsuccessful (left column). For the failure cases, the optimization in StyleCLIP hardly modifies the original image, leading to a high identity preservation score when no semantic change was applied. When StyleCLIP is successful, our method produces similar or identical results. \label{fig:userstudy-examples}} \end{figure*} \begin{figure*}[t!] \centering \begin{tabular}{ccccc} Input & Textual &Similarity- & Similarity- & ours \\ conditioning & conditioning & based & based 2 &\\ \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_1_1.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_1_2.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_1_3.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_1_4.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_1_5.png}\\ \includegraphics[width=0.15\linewidth, clip] {L2I_fig_main/fig_6_1.png}& \includegraphics[width=0.15\linewidth, clip] {L2I_fig_main/fig_6_2.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_6_3.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_6_4.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_6_5.png}\\ \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_5_1.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_5_2.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_5_3.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_5_4.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_5_5.png}\\ \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_3_1.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_3_2.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_3_3.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_3_4.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_3_5.png}\\ \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_2_1.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_2_2.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_2_3.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_2_4.png}& \includegraphics[width=0.15\linewidth,clip] {l2i_fig_supp/n_2_5.png}\\ \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_5_1.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_5_2.png} & \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_5_3.png} & \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_5_4.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_5_5.png}\\ \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_7_1.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_7_2_new.png} & \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_7_3.png} & \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_7_4.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_7_5.png}\\ \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_2_1.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_2_2_new.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_2_3.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_2_4.png}& \includegraphics[width=0.15\linewidth,clip] {L2I_fig_main/fig_2_5.png}\\ \end{tabular} \caption{A qualitative comparison between the two similarity-based baselines and our method for CLIP-guided zero-shot text-based image generation with spatial conditioning. {Textual conditioning refers to specifying the spatial positioning of objects within the text prompts, for example "a vase on a table".\label{fig:l2i}}} \end{figure*} \subsection{One-shot prompt engineering} \label{sec:results-pe} We compare the classification accuracy of CLIP using the prompts optimized with CoOp~\citep{zhou2021coop} and with our method, as described in Sec.~\ref{sec:prompt}. Following~\citep{zhou2021coop}, we evaluate the methods on the ImageNet~\citep{Deng2009ImageNetAL} test set, which is one of the most popular image classification datasets, with $1,000$ classes, as well as on ImageNetV2~\citep{pmlr-v97-recht19a}, which is an alternative test set for ImageNet, designed to avoid biased results caused by overfitting, ImageNet-Sketch~\citep{NEURIPS2019_3eefceb8}, which contains sketch images of the classes in ImageNet, ImageNet-A~\citep{Hendrycks_2021_CVPR}, which contains adversarial examples for models trained on ImageNet, and Imagenet-R~\citep{Hendrycks_2021_ICCV}, which presents out-of-domain examples in order to determine the robustness of the model. Following~\citep{zhou2021coop}, two scenarios are tested: unified prompt engineering and class-specific prompt engineering. In the unified scenario, a single prompt is optimized for all class names. In the class-specific (CSC) case, a different prompt is optimized per class. Note that for all datasets, the prompts are optimized using labeled examples only from the ImageNet training set, in order to test the robustness of the optimized prompts on different ImageNet variations. For both methods we test different backbones for the visual encoder of CLIP (see Tab.~\ref{table:promptengineering}), including variations of ViT~\citep{dosovitskiy2020image} and of ResNet~\citep{he2016deep}. Following~\citep{zhou2021coop}, we optimize a template with $M=16$ tokens. {Two options for positioning the class name tokens in the prompt} were reported in~\citep{zhou2021coop}, with similar outcomes. The first has the class name located in the middle of the prompt, i.e.: $t=v_1,...,v_8, \{\text{label}\}, v_9,...,v_{16},$ where $v_1,...,v_{16}$ are the prompt tokens, and the second has the class name located at the end, i.e.: $t=v_1,...,v_{16},\{\text{label}\}$. In the main text we report the results of the former; for the latter, see appendix~\ref{app:prompt-eng-end}. We use $\lambda_{expl}=7$ for all unified prompt experiments and $\lambda_{expl}=8$ for all class-specific experiments. All other hyperparameters are identical to those used by \citep{zhou2021coop}. As can be seen in Tab.~\ref{table:promptengineering}, our method consistently and greatly outperforms the generalization of the optimized prompts, leading to higher accuracy across all backbones, all datasets, and both scenarios (unified and CSC). A Sensitivity analysis for $\lambda_{expl}$ is presented in Fig. ~\ref{fig:PE_lambda_sensitivity}, showing that the improvement in accuracy is consistent across a large range of $\lambda_{expl}$ values. Fig.~\ref{fig:prompt-eng} presents a qualitative comparison of using CoOp with and without our method. Two exemplary images from ImageNetV2~\citep{pmlr-v97-recht19a} were chosen, such that our method produces the ground truth classification, while CoOp does not. We compare the explainability heatmaps for the ground truth and the counterfactual class chosen by CoOp. As can be seen, the prompts produced by CoOp result in similarity scores that are mostly based on tokens other than the class name tokens, which {indicate overfitting and} can lead to biases. In contrast, our method produces prompts that encourage the scores to be based on the class name tokens, and therefore guarantees a more reliable similarity score. See appendix~\ref{app:prompt-eng-vis} for a full version of Fig.~\ref{fig:prompt-eng} with the image heatmaps. \subsection{Zero-shot text-guided image manipulation} \label{sec:results-styleclip} Next, we compare our explainability-based optimization (Sec.~\ref{sec:manipulation}) with the optimization presented in~\citep{patashnik2021styleclip}. There are three methods for text-based image editing using StyleGAN~\citep{karras2020analyzing} presented by~\citep{patashnik2021styleclip} - latent optimization, mapper training, and global directions extraction. We focus on latent optimization, since our focus is on zero-shot methods and the other two methods employ additional training. As described in Sec.~\ref{sec:manipulation}, we add the explainability-based loss from Eq.~\ref{eq:expl_gen_loss} to the optimization algorithm of~\citep{patashnik2021styleclip}. We choose the set of hyperparameters for our explainability-based loss from the set: $\lambda_{expl} = \{0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5\}$, and use the best value for $\lambda_{expl}$ according to the highest CLIP similarity score. Since the optimization in~\citep{patashnik2021styleclip} requires a different hyperparameter setting for each prompt, we select prompts that appear in the paper or official code, and use the same hyperparameters (in other words, we do not manually select the hyperparameters for our method). Next, we choose 20 random seeds to be used across all our experiments to generate the images to be edited, $i$. For each image $i$, and text prompt $t$ we produce the edited image with StyleCLIP's optimization, and with our modified optimization. For evaluation, we extract all examples where our method produces a different output than StyleCLIP, i.e., all cases where the automatic procedure selected $\lambda_{expl}\neq 0$, and conduct a user study among $46$ users. Users were asked to evaluate each manipulation by the similarity between the manipulated image and the input prompt $t$ and by the loss of identity between the manipulated image and the original image $i$, both on a scale of $1-5$ (higher is better). Fig.~\ref{fig:userstudy-examples} presents sample results from our user study (See appendix~\ref{app:sc} for full results). Notice that for challenging manipulations, such as using the prompt ``a man with a beard'' on a woman, StyleCLIP tends to leave the input image $i$ almost unchanged. In contrast, in many of these cases, our method compels the optimization to reach a solution that fits the required semantic edit. We present the results of the user study for each prompt in Tab.~\ref{fig:userstudy} (see results with standard deviation in appendix~\ref{app:sc}). As can be seen, our method produces results that are consistently rated by users as more similar to the target text. However, StyleCLIP, which, as can be seen in Fig.~\ref{fig:userstudy-examples}, often leaves the images unchanged, obtains a higher identity preservation score. Evidently, the gap in the identity score is much bigger for the prompts ``A \textbf{man} with a beard'' and ``A blond \textbf{man}''. These prompts modify the gender of the subject of the image $i$, thereby requiring a more substantial identity change. \subsection{Zero-shot text-to-image with spatial conditioning} We use CLIP-guided VQGAN as implemented by~\citep{vqgan+clip}. Since, as far as we can ascertain, there is no previous literature on zero-shot CLIP-guided text-to-image generation with spatial conditioning on the location of the generated objects, we use two variations of a similarity-based CLIP loss to create baselines without explainability conditioning. The first baseline employs the following loss: \begin{align} \label{eq:l2i_baseline} \mathcal{L}_{masked} = \sum_{t\in \{t_1,...,t_k\}}\sum_{m\in \{m_1,...,m_k\}}- \text{CLIP}(i_m, t), \end{align} where $i_m$ is the image $i$ masked according to bounding box $m$, i.e. for each mask $m$, we black out all pixels outside $m$, in order to ensure that the objects identified by CLIP reside within the bounding boxes, and $t$ is a prompt of the form ``a photo of \{label\}'' where "label" is the target class to be generated in bounding box $m$. This masking technique has also been employed in previous works~\citep{Avrahami2021blendeddiffusion,bau2021paintbyword}, for CLIP-guided image inpainting. The second similarity-based baseline we consider employs the loss in Eq.~\ref{eq:l2i_baseline} in addition to the similarity loss in the unmasked image: \begin{align} \label{eq:l2i_baseline2} \mathcal{L}_{similarity} = \sum_{t\in \{t_1,...,t_k\}}-\text{CLIP}(i, t). \end{align} This baseline uses the loss: $\mathcal{L} = \mathcal{L}_{similarity} + \mathcal{L}_{masked}$, which considers both the information inside the bounding boxes and the information in the entire image. As mentioned in Sec.~\ref{sec:l2i}, since a simple similarity-based loss has no spatial restrictions, the baselines produce objects outside the input bounding box (see Fig.~\ref{fig:l2i}), while our loss produces objects within the bounding box, thanks to spatial conditioning based on explainability. Moreover, the examples in Fig.~\ref{fig:l2i} demonstrate the ability of our method to generate images in a variety of cases, including multiple bounding boxes {with varying heights and widths} (see appendix~\ref{app:l2i_examples} for additional examples and visualizations of the explainability maps). As smaller bounding boxes require stronger supervision, we set $\lambda_{expl_i}$ for object $i$ to be $\lambda_{expl_i}=\frac{0.15}{\sqrt{r(m_i)}}$, where $m_i$ is the bounding box assigned to object $i$ and $r(m_i)$ is the ratio between the area of the mask and the area of the entire image. {The threshold $T$ is set to 0.1 and $temp$ is set to 20.} \begin{table}[t] \centering \begin{minipage}[c]{0.49\linewidth} \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lccc} \toprule & Similarity- & Similarity- & Ours \\ &based & based 2&\\ \midrule Precision & 46.4 & 26.9 & \textbf{71.7}\\ Recall & 48.3 & 30.5 & \textbf{63.4}\\ F1 & 40.5 & 24.28 &\textbf{62.6} \\ AP & 8 & 5.4 & \textbf{26.2}\\ AR & 21.6 & 19 & \textbf{40}\\ AP$_{0.5}$ & 18 & 15.4 & \textbf{56.5} \\ \bottomrule \end{tabular*} \captionof{table}{Precision, recall, F1, average precision, and average recall for spatially conditioned image generation with our method, and two similarity-based baselines (results in percentage). Metrics were averaged across $100$ random samples from the MSCOCO~\citep{ty2014coco} validation set and four random seeds. Average precision and average recall are calculated using DETR~\citep{carion2020end}.} \label{tab:l2i_metrics} \end{minipage}% \hfill \begin{minipage}[c]{0.49\linewidth} \includegraphics[width=\linewidth, clip] {PE/PE_sensitivity_resized.png}\\ \vspace{-.3cm} \captionof{figure}{1-shot accuracy (in percentage) on the ImageNet test set for different choices of $\lambda_{expl}$ for all visual backbones of CLIP. The accuracy achieved by the baselines ($\lambda_{expl}=0$) is denoted by dashed lines.} \label{fig:PE_lambda_sensitivity} \end{minipage}% \end{table} In order to provide quantitative metrics for our spatially conditioned text-to-image generation, we use the validation set from MSCOCO~\citep{ty2014coco} which contains object bounding boxes for each object in the image. In order to ensure a varying number and size of objects, while maintaining enough background to allow object-free generation, which is challenging for CLIP-guided VQGAN, we filter the layout as follows: we keep the $k$ largest bounding boxes whose commutative area is less than 50\% of the image, where adding the next largest bounding box would result in occupying more than 50\% of the image. By focusing on the largest objects we also help ensure that the size of each bounding box suffices for the CLIP encoder. For our first experiment, we sample 100 MSCOCO images at random, and use our method and the similarity-based baselines to generate images corresponding to the annotated spatial layout. We then produce an explainability map for each text description $t$, as described in Alg.~\ref{alg:segm} (L.2-3). We use these explainability maps as soft semantic segmentation, binarize them using thresholds produced with Otsu's method~\citep{otsu1979threshold}, and calculate the precision, recall, and F1 scores of the binarized maps with the ground truth bounding boxes $m_1,.., m_k$. {Note that both precision and recall are limited and cannot reach $100\%$ due to the square shape of the bounding boxes, which is not suited to non-square objects. Precision is also limited because images often contain more than one instance of a specific class, leading to a high explainability score for the other occurrences as well. } As can be seen from Tab.~\ref{tab:l2i_metrics}, our method significantly outperforms the baselines. Next, we use object detection to evaluate the quality of the generated objects, as well as the overlap between their location and the target spatial condition. DETR~\citep{carion2020end} is used to produce bounding boxes for each object. These bounding boxes are evaluated against the input spatial conditioning masks using the average precision and average recall scores. As can be seen in Tab.~\ref{tab:l2i_metrics}, our method greatly outperforms the baselines {in this evaluation as well, implying that the explainability signal is indeed indicative enough to enforce spatial restrictions over an image.} \section{Discussion} In our experiments, we presented a generic application of explainability to improve classification, image editing, and image synthesis. There are also specific situations in which a limited view of the input is detrimental and where explainability can help ensure a more even distribution of information pooling. One such case, studied in appendix~\ref{app:fusedream}, is that of compound nouns, e.g. ``apple juice'' or ``blueberry muffin''. As we show, state-of-the-art {zero-shot} text-to-image generation engines might overly emphasize or ignore some of the textual input, leading to misinterpretation of the text. The method we present for equalizing the contributions {to avoid such neglect} not only leads to considerably better image outputs for such cases, but also slightly improves the FID score for other sentences. See appendix~\ref{app:fusedream} for full details of the method implementation, visual examples, and the results of a user study conducted against results obtained with a state-of-the-art method. In order to demonstrate the wide applicability of our approach, we have modified multiple zero-shot and one-shot approaches. While the baseline approaches are impressive, we do note that they are not yet ready to replace supervised methods. Prompt engineering is not yet competitive with supervised methods, CLIP-guided VQGAN often generates substandard images, and StyleCLIP optimization method often fails and requires different parameters for each prompt. Therefore, other signals need to be considered to allow zero-shot applications to compete against fully supervised ones. Explainability, as we show, is an example of such beneficial signal. \section{Conclusions} While explainability methods are constantly improving, their use as a feedback mechanism to improve classification or generation methods is still relatively unexplored. As far as we can ascertain, their utilization as such a building block is currently limited to weakly supervised segmentation~\citep{Zabari2021SemanticSI,Chefer_2021_ICCV}. In this work, we show how explainability can help overcome the neglect problem of bi-modal transformers, which have become a cornerstone in the current rapid evolution of zero-shot methods. We demonstrate how preventing neglect, as reflected through the lens of the explainability score, helps improve one-shot classification, zero-shot image editing, and zero-shot layout-conditioned image generation. In the first two domains, neglect is prevented in the text domain, while in the latter, the constraint on the heatmap is placed in the image domain. \section*{Acknowledgments} 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).
{'timestamp': '2022-04-12T02:33:59', 'yymm': '2204', 'arxiv_id': '2204.04908', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04908'}
arxiv
\section{Introduction} News have an essential impact in many areas of society, politics and business. That is why one can see a lot of attempts to produce manipulative and fake news to get a specified response in the society. One of horrible world events is Russian invasion of Ukraine on February, 24 2022. It causes a large informational news flow on social networks, including producing manipulative and fake news to shape a specified explanation and justification of invasion. One of the goals claimed by Russia was the 'denazification' of Ukraine. One of the allegations of Russian propaganda was that Ukraine was developing the biological weapon in special laboratories. Tweets, the messages of Twitter microblogs, have high density of semantically important keywords. It makes it possible to get semantically important information from tweets and generate the features of predictive models for the decision-making support. Different studies of Twitter are considered in the papers~\cite{java2007we,kwak2010twitter,pak2010twitter, cha2010measuring,benevenuto2009characterizing, bollen2011twitter,asur2010predicting,shamma2010tweetgeist, wang2020novel, balakrishnan2020improving, grinberg2019fake,ajao2018fake,helmstetter2018weakly}. In~\cite{pavlyshenko2019forecasting,pavlyshenko2019cantwitter, pavlyshenko2021forming}, we study different approaches for the analysis of messages on Twitter, as well as the use of tweet features for forecasting different kinds of events. In this paper, we consider the methods for the analysis of Twitter trends and for detecting fake news. As fake news, we will consider the news information which is not true as well as the information which can contain real facts, but with incorrectly specified accents, and the focuses that lead to distorted conclusion and incorrect understanding of underlying processes. For our analysis, we considered informational trends caused by Russian invasion of Ukraine in 2022. In the study, we also consider the possible impact of informational trends on different companies working in Russia during this conflict. \section{News Trends on Twitter} For the analysis, we used a combination of keywords related to thematic areas under consideration. The keywords related to the entity under consideration can be treated as a thematic field. The use of semantic and thematic fields for text analytics is considered in~\cite{pavlyshenko2013classification, pavlyshenko2014clustering, pavlyshenko2014genetic, pavlyshenko2021forming}. To load tweets, we have used Twitter API v2. For the 'ukraine nazi' thematic field the following Twitter API query "(ukraine OR ukrainian OR ukraine's) (nazi OR nazism, nazists OR neonazi OR neo-nazi)" has been used. For the 'ukraine biological weapon' thematic field, the query "ukraine biological (weapon OR weapons OR warfare)" has been used. For the analysis, the following main python packages were used: \textit{'pandas', 'matplotlib', 'seaborn', 'tweepy'}. Figures~\ref{ts1}-\ref{ts5} show the time series for tweet counts for different queries. The lower case of query keywords allows searching tweets with the keywords with both lower and upper cases. As the results show, for the 'ukraine nazi' thematic field, the discussion of underlying problems rose dramatically after February 24, the date of Russian invasion of Ukraine. The amount of tweets related to this theme before that date was at the minimum level. That itself leads to the conclusion that the problem with nazi in Ukraine was just a formal reason to justify the invasion. Another claim of Russian propaganda was about biological weapons that were allegedly being developed in Ukrainian laboratories (Figure~\ref{ts4}). For instance, it was claimed that a special virus was being developed and it was meant to be distributed through bats and migratory birds. \begin{figure} \center \includegraphics[width=1\linewidth]{imgs/ukraine_ts.png} \caption{Time series of tweets for the query 'ukraine'} \label{ts1} \end{figure} \begin{figure} \center \includegraphics[width=1\linewidth]{imgs/ukraine_nazi_ts.png} \caption{Time series of tweets for the thematic field 'ukraine nazi'} \label{ts2} \end{figure} \begin{figure} \center \includegraphics[width=1\linewidth]{imgs/ukraine_biological_weapon_ts.png} \caption{Time series of tweets for the thematic field 'ukraine biological weapon' } \label{ts4} \end{figure} \begin{figure} \center \includegraphics[width=1\linewidth]{imgs/noflyzone_ts.png} \caption{Time series of tweets} \label{ts5} \end{figure} \section{Deep Learning Approach for Fake News Detection} Fake news can be detected and revealed by analyzing facts and comparing them with reality and other news sources. Let us consider the methods which make it possible to detect fake news automatically. It is not easy to develop an AI system which can analyze the facts. But for manipulative news, it is typical to amplify them artificially in different ways, e.g. by retweeting manipulative tweets many times using different users' accounts. Some accounts can be bots which were artificially created, others can belong to real users. It makes it possible to detect fake news using an approach which analyzes the patterns of users' behavior. Also, fake news have specific patterns in the text of messages. Both users' behavior and text patterns can be captured by deep machine learning algorithms. As the features for a predictive model, we used tweet texts and the list of users' usernames who retweeted those tweets. For model developing, evaluation and prediction, the Python framework \textit{'pytorch'} was used. The ML model consists of several concatenated neural subnetworks: subnetwork with DistilBERT transformer which ingests tokens of tweet text,s subnetwork with the embedding layer with averaging which ingests the mixture of encoded words of tweet texts and lists of usernames of retweeters, as well as a subnetwork for the components of truncated singular value decomposition of TF-IDF matrix for the list of usernames of retweeters. Figure~\ref{fnmodel} shows the structure of the deep learning model for fake and manipulative news detection. For our case study, the loaded tweets with the thematic fields 'ukraine nazi' and 'ukraine biological weapon' were used. For the model training and evaluation, the tweet datasets with a specified list of users who retweeted those tweets were created. For the analysis, only the tweets with a specified threshold for retweet counts were included. The dataset was labeled using an appropriate tweet id, usernames, hashtags of tweets which can be treated as fake or manipulative. Figure~\ref{fnmodel_evaluation} shows model evaluation results on the validation dataset. \begin{figure} \center \includegraphics[width=1\linewidth]{imgs/fnmodel.png} \caption{Deep learning model structure} \label{fnmodel} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/fnmodel_evaluation.png} \caption{Model evaluation results on the validation dataset} \label{fnmodel_evaluation} \end{figure} The examples of tweets which were recognized by the deep learning model as fake or manipulation news for the thematic fields 'ukraine nazi' and 'ukraine biological weapon' are at~\cite{examplesfndet}. \section{Detecting Artificially Generated News} One of the ways to form manipulative trends is to produce artificially created news tweet messages~\cite{jawahar2020automatic,fagni2021tweepfake, murayama2021dataset}, e.g. by paraphrasing an initial text using Seq2Seq neural network models. For this purpose, GPT-2, and BART transformers can be used. Each pretrained transformer has its own patterns for generating texts using an encoder-decoder approach. These patterns can be detected by other transformers which are fine-tuned on a dataset with an artificialy generated text. For the model fine-tuning, a TweepFake dataset of artificially generated texts~\cite{fagni2021tweepfake} was used. The framework \textit{'pytorch'} was used for the model developing and evaluation. We tried two models -- the neural network with the DistilBERT transformer layer and the neural network with the concatenation of the DistilBERT transformer with embedding layers for the usernames of users who post tweets. Figures~\ref{aitxt1}, ~\ref{aitxt2} show the model evaluation on the validation dataset for these two models. \begin{figure}[H] \center \includegraphics[width=0.75\linewidth]{imgs/aitext_acc.png} \caption{Evaluation results for the model with DisstilBERT transformer layer} \label{aitxt1} \end{figure} \begin{figure}[H] \center \includegraphics[width=0.75\linewidth]{imgs/aitext_acc_usr.png} \caption{Evaluation results for the model with the concatenation DisstilBERT transformer layer and embedding layer for usernames} \label{aitxt2} \end{figure} As the results show, the embedding layer for usernames can improve accuracy scores, it means that usernames have predictive potential for detecting artifitially created tweets. We applied the fine-tuned model to the datasets of tweets of the semantic fields under consideration and have received the following results: human - 80\%, GPT-2-10\%, RNN - 0.3\%, Others - 3\%. \section{The Impact of the Discussion About Company's Behavior On Its Stock Prices} Russian invasion of Ukraine has huge impact on users' attitude to different companies and shapes discussion trends on Twitter. Figure~\ref{twtscomp1} shows time series for tweet counts related to the consideration of different companies in Russia during Russian invasion of Ukraine. For the case study, let us consider McDonald's. Figure~\ref{twtsmcd1} shows the tweet counts in the trend of considering this company, a rolling mean of this time series, with a 7-day window and stock price for the 'MCD' ticker for the McDonald's company. \begin{figure} \center \includegraphics[width=0.95\linewidth]{imgs/companies_ts1.png} \caption{Time series of tweets for trends related to different companies} \label{twtscomp1} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/mcdonalds_ts.png} \caption{Time series of tweets related to McDonald's, rolling mean of the time series, stock price time series for the 'MCD' ticker} \label{twtsmcd1} \end{figure} As a result of public discussion, it is known that McDonald's has stopped its activity in Russia. After this announcement, the stock price for the 'MCD' ticker has returned to almost initial price value before the invasion period (Figure~\ref{twtsmcd1}). The stock price time series for the 'MCD' ticker were loaded using Python package \textit{'yfinance'}. It shows that public consideration of a company's behavior which is reflected on the social networks can have impact on the stock market. It is supposed that consideration has some cumulative effect, that is why the rolling mean of the time series of tweet counts corresponds more precisely to company's stock prices on the stock market. Let us analyze the dependency of stock prices on the tweet counts rolling mean. It is important to estimate the uncertainty of such dependency. For the modeling of such a dependency, the Bayesian regression was applied. The probabilistic model can be considered as follows: \begin{equation} \begin{split} &y \sim Student_t (\nu, \mu, \sigma),\\ &\mu = \alpha + \beta x, \label{eq_1} \end{split} \end{equation} where $\nu$ is a distribution parameter, known as degrees of freedom. Target variable $y$ is described by Student's t-distribution which has fat tails that makes it possible to take into account extreme events and values that enable us to estimate uncertainties more accurately. For Bayesian inference calculations, we used a Python package \textit{'pystan'} for Stan platform for statistical modeling \cite{carpenter2017stan}. For the analysis, as a feature independent variable, we used z-scores for the rolling mean of tweet counts time series, as a target variable, we used z-scores for stock price for 'MCD' ticker. As a result of sampling, the mean value as well as quantiles 0.01, 0.05, 0.95, 0.99 for the target variable were calculated. Figure~\ref{stockpricemcd} shows the results of modeling. Figure~\ref{pdfbetamcd} shows the probability density function for $\beta$ parameter. Quantile 0.05 for predicted target variable can be treated as the value of risk (VaR) that is a quantitative characteristic for risk assessment. \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/mcd_stock_price_modeling_std.png} \caption{Normalized time series of stock price for the 'MCD' ticker (y), prediction for stock price (pred), quantiles for prediction (0.01 - pred\_q01, 0.05 - pred\_q05, 0.95 - pred\_q95, 0.99 - pred\_q99 )} \label{stockpricemcd} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/mcd_pdf_beta.png} \caption{Probability density function for $\beta$ model parameter} \label{pdfbetamcd} \end{figure} \section{Analysis of Tweets Using Frequent Itemsets} The frequent itemsets and associative rules theory is often used in the intellectual analysis~\cite{agrawal1994fast,agrawal1996fast,chui2007mining,gouda2001efficiently, srikant1997mining,klemettinen1994finding,pasquier1999discovering, brin1997beyond}. It can be used in a text data analysis to identify and analyze certain sets of objects, which are often found in large arrays and are characterized by certain features. Let us consider the algorithms for detecting frequent sets and associative rules on the example of processing microblog messages on tweets. Figure~\ref{freq_1} shows keyword frequencies for the specified thematic field 'ukraine nazi'. Using these keywords, one can calculate frequent itemsets. Figure~\ref{fritemsets_nazi_1} shows the graph of frequent itemsets which describes the semantic structure of entities for a specified thematic field. Figure~\ref{fritemsets_nazi_1} shows the graph of the subset of association rules, Figure~\ref{rules_nazi_grouped} shows the association rules represented by a grouped matrix. Figure~\ref{rules_nazi_fake_grouped} shows the association rules which contain the keyword 'fake'. Figures~\ref{freq_bioweopns}--\ref{rules_bioweapon_1} show the similar calculation for the thematic field 'ukraine biological weapon'. Figures~\ref{fritemsets_bioweapon_bird}--\ref{rules_bioweapon_bird_grouped} show the subset of these frequent itemsets and association rules which contain the keyword 'bird'. The quantitative characteristics of frequent itemsets like value of support can be used as a predictive feature in machine learning models. \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/freq_nazi.png} \caption{Keyword frequencies related to the thematic field 'ukraine nazi'} \label{freq_1} \end{figure} \begin{figure} \center \includegraphics[width=1\linewidth]{imgs/fritemsets_nazi_1.png} \caption{Graph of semantic frequent itemsets} \label{fritemsets_nazi_1} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/rules_nazi_1.png} \caption{Graph of association rules} \label{/rules_nazi_1} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/rules_nazi_grouped.png} \caption{Association rules represented by a grouped matrix} \label{rules_nazi_grouped} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/rules_nazi_fake_grouped.png} \caption{Association rules represented by a grouped matrix with the keyword 'fake'} \label{rules_nazi_fake_grouped} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/freq_bioweapons.png} \caption{Keyword frequencies related to the thematic field 'ukraine biological weapon'} \label{freq_bioweopns} \end{figure} \begin{figure} \center \includegraphics[width=1\linewidth]{imgs/fritemsets_bioweapon_1.png} \caption{Graph of semantic frequent itemsets} \label{fritemsets_bioweapon_1} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/rules_bioweapon_1.png} \caption{Graph of association rules} \label{rules_bioweapon_1} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/fritemsets_bioweapon_bird.png} \caption{Graph of semantic frequent itemsets with the keyword 'bird'} \label{fritemsets_bioweapon_bird} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/rules_bioweapon_bird.png} \caption{Graph of association rules with the keyword 'bird'} \label{rules_bioweapon_bird} \end{figure} \begin{figure} \center \includegraphics[width=0.75\linewidth]{imgs/rules_bioweapon_bird_grouped.png} \caption{Association rules with the keyword 'bird' represented by a grouped matrix} \label{rules_bioweapon_bird_grouped} \end{figure} \section{Graph Structure of Tweets} The relationships among users can be considered as a graph, where vertices denote users and edges denote their connections. Using graph mining algorithms, one can detect user communities and find ordered lists of users by various characteristics, such as \textit {Hub, Authority, PageRank, Betweenness}. To identify user communities, we used the \textit{Community Walktrap} algorithm and to visualize them we used \textit{Fruchterman-Reingold} algorithm, which are implemented in the package \textit{'igraph'}~\cite{csardi2006igraph} for the \textit{R} programming language environment. The \textit{Community Walktrap} algorithm searches for related subgraphs, also called communities, by random walk~\cite{pons2005computing}. A graph which shows the relationships between users can be represented by Fruchterman-Reingold algorithm~\cite{fruchterman1991graph}. The qualitative structure of user's connections can be used for aggregating different quantitative time series and, in such a way, creating new features for predictive models which can be used, for example, for predicting target variables. Figure~\ref{usr_graph} shows users connections and revealed communities for the subset of tweets which are related to the trends under consideration. The results show that some communities marked by different colors are highly isolated and have only few connections outside. This kind of communities can be treated as suspicious, since artificially created communities for amplifying manipulative news are also highly isolated and their activity is often concentrated on amplifying by retweeting tweets from a limited set of users. Therefore, the numerical characteristics of users communities can have a predictive potential. \begin{figure} \center \includegraphics[width=0.85\linewidth]{imgs/igraph_usr_comm} \caption{Graph of users' connections} \label{usr_graph} \end{figure} \section{Conclusion} The obtained results show that an effective system for detecting fake and manipulative news can be developed using combined neural network which consist of three concatenated subnetworks: the subnetwork with DistilBERT transformer for tweet texts, the subnetwork with embedding of tweet words and usernames of users who retweeted tweets, and the subnetwork for the components of singular value decomposition of TF-IDF matrix for lists of usernames of users who retweeted tweets. Discussions on social networks about companies behavior has impact on their business and their stock prices on the stock market. To analyze such an impact and make risk assessment, Bayesian regression can be used. Using the theory of frequent itemsets and association rules along with thematic fields of keywords, makes it possible to reveal the semantic structure for entities in news messages. The quantitative characteristics association rules like support and confidence can be used as features for machine learning predictive models. Using the graph theory, the hidden communities of users can be revealed and their characteristics can be used in a machine learning approach for fake and manipulative news detection. \bibliographystyle{ieeetr}
{'timestamp': '2022-04-12T02:33:16', 'yymm': '2204', 'arxiv_id': '2204.04891', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04891'}
arxiv
\section{Introduction} \blfootnote{Emails: [email protected], [email protected], \{vamariy, yenliang, beanurag, alalu, medioni\}@amazon.com} Two main tasks for a fashion outfit recommendation system are fashion {\em compatibility prediction} and large-scale {\em complementary item retrieval}. For compatibility prediction (CP), the task is to determine whether a set of fashion items in an outfit go well together. For complementary item retrieval (CIR), the task is to complete a partial outfit by finding a compatible item from a large database. Given an outfit, we want to predict how well its constituent items go together. Also, given a partial outfit with different items (such as a bag, shoes, and pants) and a target item description (e.g., ``top''), we want to retrieve compatible items to complete the outfit. Figure \ref{fig:fig1} illustrates our proposed method. \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{Figures/figure1.png} \caption{The proposed framework, OutfitTransformer, learns an outfit-level representation for a set of outfit items to address the CP and CIR tasks. For CIR, it learns a single embedding encoding overall compatibility of the partial outfit, and a target item description that is used to retrieve compatible items cohesively matching the entire outfit using KNN search. For CP, our framework learns an outfit-level representation capturing overall outfit compatibility to predict a compatibility score.} \label{fig:fig1} \end{figure} Prior work such as \cite{Veit2015,Veit2017,typeaware2018,scenet2019,Yang2019TransNFCMTN} addresses the pairwise item-level compatibility problem and achieves state-of-the-art results but does not explicitly model outfit-level compatibility. Some methods optimize for compatibility at an outfit-level \cite{hanACMMM2017,Cucurull_2019_CVPR,Hsiao_2017_ICCV,Hsiao_2018_CVPR,POG2019}. However, these approaches are mainly designed for classification tasks: compatibility prediction and fill-in-the-blank (FITB) but they do not address the large-scale CIR task. CSA-Net \cite{compretrieval2020} proposes a method for large-scale CIR, but it does not learn an outfit-level representation that can explicitly capture compatibility of a target item to the outfit as a whole. It searches compatible items for each item in the outfit at a paired-category level (e.g., top to shoe, bottom to shoe) and fuses the ranking scores for different query items to obtain the final rankings. Instead, our idea is to learn an outfit-level representation for both compatibility prediction and large-scale retrieval of complementary items. Here, we investigate a transformer-based architecture to learn the outfit-level embeddings for the CIR task, as this architecture shows better outfit compatibility prediction performance than the Bi-LSTM \cite{hanACMMM2017} and GCN-based \cite{Cucurull_2019_CVPR} architectures (cf. Table \ref{tbl:comp}). Specifically for CIR, the target item should cohesively match all the existing items in an outfit. Using outfit-level representations can more effectively capture complex feature correlations among multiple items in the outfit, as opposed to considering pairs of items at a time. Additionally, users may specify their preference for the target item in the form of a target category (e.g., top) or the text descriptions (e.g., full sleeve shirt with floral design), and our system is able to retrieve the complementary items that match it. We design our framework to learn a target item embedding that operates at the outfit-level and encodes both the overall compatibility of a partial outfit, and the target item specification. We pose this as a set-to-item compatibility learning problem where we model the outfit as a set of items, and extract a single target item embedding to search for complementary items. The outfit representation learnt for both tasks is invariant to the order of the items, i.e., permutation of the order of the outfit items should generate the same representation. The transformer is a suitable choice for our framework because it captures the higher-order relationships (beyond pairwise) between all constituent items in the outfit and is able to take unordered items as input. For the task of CP, we train the OutfitTransformer with a classification loss and design an outfit token to capture a global outfit representation that encodes the compatibility relationships among all the items in the outfit. For CIR, we design a target item token that encodes both the compatibility of the partial outfit and a target item description to generate the embedding of the target item. This embedding is used to retrieve compatible items from a database. We train our framework using a proposed set-wise outfit ranking loss, which encourages compatible items to be embedded closer to the overall representation of a set of outfit items. Our design allows extraction of a single target item embedding, which enables large-scale indexing and retrieval. \footnote{The framework needs to be designed in a way such that it allows individual item embedding extraction (should not depend on the query image during indexing like SCE-Net \cite{scenet2019}) to support large-scale indexing for KNN search. (cf. Sec \ref{sec:indexing_and_retrieval}).} Directly training on the retrieval task leads to poor performance, since the network does not have any prior knowledge regarding compatibility of the partial outfit. To alleviate this problem, we facilitate OutfitTransformer to learn compatibility relationships by pre-training it on the CP task. We find that this improves retrieval performance significantly (cf. Table \ref{tbl:abl_retr}(a)). In addition, we propose a curriculum learning strategy to hierarchically sample more informative negative examples which further boosts retrieval performance (cf. Table \ref{tbl:abl_retr}(b)). We evaluate our method on the public Polyvore Outfits dataset \cite{typeaware2018}. Experimental results show that our approach outperforms state-of-the-art techniques in compatibility prediction, fill-in-the-blank (FITB), and complementary item retrieval tasks. In Section \ref{sec:results}, we demonstrate that our framework can retrieve complementary items based on the target item category or description. In addition, we validate our results for the CIR task using Amazon Mechanical Turk. In summary, our main technical contributions are: \begin{itemize} \item We propose a new framework, OutfitTransformer, that effectively learns outfit-level representations, which is shown experimentally to outperform state-of-the-art methods on both compatibility prediction (CP) and complementary item retrieval (CIR) tasks. \item We propose task-specific tokens to support both CP and CIR. For CP, the outfit token is designed to capture a global outfit representation. For CIR, the target item token additionally takes the target specification (in the form of category or free-form text) into account. \item Our framework learns a single embedding that enables large-scale indexing and retrieval for complementary items, and has smaller indexing size than previous approaches (\cite{compretrieval2020,typeaware2018}) which use subspace embeddings. \item We provide in-depth analysis of different design choices (pre-training and curriculum learning) to improve retrieval performance. \end{itemize} \section{Related Work} \label{sec:related_work} \noindent \textbf{Outfit Compatibility Prediction.} Prior work on fashion outfit compatibility often considers pairwise item comparisons to predict the final compatibility score~\cite{Veit2015,Veit2017,typeaware2018,scenet2019,Yang2019TransNFCMTN}. However, these algorithms usually perform aggregation of item-level scores to compute the entire outift compatibility score. To add global constraints in scoring outfit compatibility, a number of methods \cite{hanACMMM2017,Cucurull_2019_CVPR,Hsiao_2018_CVPR,POG2019} aggregate inputs from all constituent items. Han \emph{et al}\onedot~\cite{hanACMMM2017} use a bidirectional LSTM to model outfit composition as a sequential process, considering outfits as ordered sequences. However, outfit compatibility should be invariant to the order of items in an outfit. Some recent approaches~\cite{Cucurull_2019_CVPR,NGNN2019} use a graph convolutional network (GCN) for outfit compatibility prediction. Cucurull \emph{et al}\onedot~\cite{Cucurull_2019_CVPR} train a graph neural network that generates embeddings conditioned on the representations of neighboring nodes. They use GCN to model the node relationship and predict the outfit compatibility but require large neighbor information for best performance, which is impractical for new items as mentioned in \cite{compretrieval2020}. Cui \emph{et al}\onedot~\cite{NGNN2019} model an outfit as a graph, where each node represents a category and each edge represents interaction between two categories. Chen~\emph{et al}\onedot~\cite{POG2019} (\emph{hrta.} POG) propose a transformer-based encoder-decoder architecture for generating compatible outfits that are specifically designed for personalization based on historical clicks data. All these approaches~\cite{hanACMMM2017,Cucurull_2019_CVPR,NGNN2019,POG2019} are mainly designed for classification tasks (CP and FITB \cite{hanACMMM2017}) but do not address large-scale CIR. \noindent \textbf{Outfit Complementary Item Retrieval.} Although the compatibility prediction score in previous methods can be used for ranking items, it is impractical to do so in a large-scale setting. The framework must support indexing to avoid linearly scanning the entire database. Lin \emph{et al}\onedot~\cite{compretrieval2020} propose a framework to retrieve complementary items that match the entire outfit. Their method retrieves items by considering compatibility between the target item and every item in an outfit in a pairwise manner, and then aggregating the scores. However, they do not consider the outfit as a whole and only use attention at a paired-category level. In contrast, we use a transformer model to capture interactions between all the items in an outfit to learn a global outfit representation. Aso, our method has a much smaller indexing size than \cite{compretrieval2020} which is important for practical applications (cf. Section \ref{sec:indexing_and_retrieval}). Lorbert~\emph{et al}\onedot~\cite{lorbert2021} use a single layer self-attention based framework for outfit generation but do not explicitly model compatibility. \noindent \textbf{Attention-Based Methods and Vision Transformers.} There has been considerable research using transformers in a wide variety of computer vision tasks \cite{ObjectDetectionTransform,segformer,vaswani-vision-traform,super-resolution-transformer}. Vision transformers \cite{vit2021} and related models \cite{vision-transformer-distillation,focal-transformer,CrossViT2021} decompose each image into an ordered sequence of smaller patches to learn image representation of a single image for different tasks. On the contrary, we model outfits as an unordered set of different item images and use a transformer-based architecture to learn a global outfit representation that captures overall outfit compatibility. As discussed earlier in this section, attention mechanisms \cite{compretrieval2020,Meet2021,POG2019,lorbert2021} have also been used in fashion recommendation systems. \cite{compretrieval2020,Meet2021} use attention to understand complementary relationships in a pairwise manner. In contrast, we use a transformer model to learn interactions between all the items in an outfit, which attends to higher-order compatibility relationships~\cite{SetT2018} beyond pairwise~\cite{typeaware2018,compretrieval2020,scenet2019}. Both POG \cite{POG2019} and \cite{lorbert2021} use pretrained ImageNet embeddings, while we learn fashion-specific features by training in an end-to-end manner. \noindent \textbf{Distance Metric Learning:} CIR is a fundamentally different task from visual similarity search because the complementary item is from a different category and is visually dissimilar from the other items in the outfit. We specifically design a negative sampling strategy for CIR where we sample negatives from the same category as positive samples, unlike \cite{facenet2015,Song2016DeepML}. Also, in contrast to \cite{scenet2019,typeaware2018,compretrieval2020}, which consider pair-wise compatibility between target items and each individual item in the outfit, we propose a set-wise outfit ranking loss that compares target items with a single embedding for the entire outfit. \section{Proposed Approach} Figure \ref{fig:Overview} illustrates the overview of our framework. Our framework takes as input each outfit's constituent item images and their text descriptions. For compatibility prediction, we train the transformer encoder to generate a global outfit representation that can capture higher-order compatibility relationships between all items in the outfit beyond pairwise relationships. This global outfit representation can then be used to predict an outfit compatibility score. Details are presented in Section \ref{sec:compat}. \begin{figure*}[t] \centering \begin{minipage}[c]{0.45\textwidth} \includegraphics[width=\textwidth]{Figures/Fig2a_.png} \subcaption{\hspace{0.5in} \small Compatibility prediction} \end{minipage} \hfill \vline \hfill \begin{minipage}[c]{0.49\textwidth} \includegraphics[width=\textwidth]{Figures/Fig2b_.png} \subcaption{\small Complementary item retrieval} \end{minipage} \caption{System overview of our framework for compatibility prediction and complementary item retrieval. We model outfits as an unordered set of items. We use an image encoder ($E_{\mathrm{img}}$) and a text encoder ($E_{\mathrm{text}}$) to extract the image and text features. (a) For compatibility prediction, we train the transformer encoder using a focal loss \cite{focal2020} and learn a global outfit representation to predict an outfit compatibility score. (b) For complementary item retrieval, given an outfit and a target item description, we train the transformer encoder to learn a target item embedding that can be used for retrieving compatible items to complete an outfit. We train the framework using the proposed set-wise outfit ranking loss in an end-to-end manner. The details of set-wise ranking loss are explained in Section \ref{sec:ocloss}. \label{fig:Overview}} \end{figure*} For complementary item retrieval, given a partial outfit and a target item description (e.g., product category or description), we train the transformer encoder to generate a target item embedding, which can be used to retrieve items that are compatible with the partial outfit and match the target item description. The framework is trained using a proposed ranking loss that enforces the target item embedding to move closer to the positive item and further apart from the negative items. The positive item matches the global style of the overall outfit, whereas the negatives are incompatible with the outfit (details in Section \ref{sec:retrieval}). We investigate different training strategies to improve retrieval performance. We employ a pre-training strategy where we first train the model on the compatibility prediction task as mentioned in Section \ref{sec:pretrain}. We also adopt curriculum learning to select more informative negative samples in different training stages. The details are presented in the Section \ref{sec:ocloss}. \subsection{Fashion Outfit Compatibility Prediction} \label{sec:compat} The compatibility prediction task predicts the compatibility of all the items in an outfit. Given an outfit $O=\left\{\left({\text{I}}_i,{\mathrm T}_i\right)\right\}_{i=1}^L$, where ${\mathrm I}_i$ is the image, ${\mathrm T}_i$ is the corresponding text description for an item $i$. We learn a non-linear function that predicts a compatibility score in $[0, 1]$, where $1$ indicates perfect compatibility. The item images and their text descriptions are fed into an image ($E_{\mathrm{img}}$) and text encoder ($E_{\mathrm{text}}$) respectively to extract the image and text feature vectors (see Section \ref{sec:training} for the details about the image and text encoder architecture). We concatenate the extracted image and text feature vectors to generate an item feature vector $u_i= E_{\mathrm{img}}\left({\text{I}}_i\right)\parallel E_\text{text}\left({\mathrm T}_i\right)$, where $\parallel$ denotes a concatenation operation. The set ${F}=\left\{u_i\right\}_{i=1}^L$ represents the feature vectors of all outfit items. Since the goal of vision transformers \cite{vit2021} is to produce a classification score for an image, a classifier token is typically used to capture a single image representation from the input image patches. In contrast, we introduce the outfit token whose state at the output of the transformer encoder serves as the global outfit representation. The goal of introducing this token is to learn a global outfit representation that captures compatibility relationships between items in the outfit using the self-attention mechanism. We model outfits as an unordered set of items as the overall outfit compatibility is invariant to the order of the items. Thus, positional encodings used in NLP~\cite{nlp2017} and ViT~\cite{vit2021} are not required for us. The outfit token (${\mathrm x}_\text{Outfit}$) is a learnable embedding that is prepended to the set of outfit feature vectors $F$ and fed into the transformer encoder ${\mathrm E}_\text{trans}$. The state of the outfit token at the output of the transformer encoder serves as the global outfit representation which is subsequently fed into the MLP that predicts an overall outfit compatibility score: \begin{equation} \mathrm c=\mathrm{MLP}\left({\mathrm E}_\text{trans}\left({\mathrm x}_\text{Outfit},F\right)\right) \end{equation} Our framework ($E_{\mathrm{trans}}, E_{\mathrm{img}}, E_{\mathrm{text}}$) is trained end-to-end using focal loss \cite{focal2020}. \subsection{Complementary Item Retrieval} \label{sec:retrieval} The complementary item retrieval task is to retrieve an item that is both compatible with the partial outfit and matches a specified item description to complete the outfit. Specifically, given a set of partial outfit items and a user provided target item specification, the goal is to generate a target item embedding that can be used to retrieve compatible items. Our framework is trained with a proposed set-wise outfit ranking loss which is discussed in detail in Section \ref{sec:ocloss}. The target item token $\mathrm s$ (cf. Figure \ref{fig:Overview} (b)) includes an item description $\mathrm T$ for the target item that we want to retrieve, and an empty image represented by $\mathrm x_{\mathrm{Img}}$. The target item token is defined as $ \mathrm s=\mathrm x_{\mathrm{Img}}^{}\parallel E_{\mathrm{text}}\left(\mathrm T\right) $. The intuition behind designing the target item token in this manner is that, during inference, the target image is unknown but users can provide a description for the item they are searching for. We simulate a similar setting when training the framework for the retrieval task. We introduce the target item token whose state at the output of the transformer encoder serves as the target item representation that explicitly takes into consideration both compatibility with the partial outfit, and the target item description. Our framework is generic and the target item description can be provided in different forms such as category, text description, tags, etc. The transformer encoder takes as input the set of feature vectors $F$ of the partial outfit, and the target item specification $\mathrm s$, which is subsequently fed into a MLP that generates the target item embedding. \begin{equation} \mathrm t= \mathrm{MLP}\left(E_{\mathrm{trans}}\left(\mathrm s\mathit, F\right)\right) \end{equation} To learn this target item embedding, we train our framework with a proposed set-wise outfit ranking loss which is discussed in Section \ref{sec:ocloss}. \subsubsection{Pre-training on Compatibility Prediction: } \label{sec:pretrain} We pre-train the framework on the compatibility prediction task and use the learned weights to initialize the transformer, image and text encoder for complementary item retrieval. This choice leads to a significant improvement for CIR (cf. Table \ref{tbl:abl_retr}(a)). We conjecture that the reasons might be: 1) the pre-trained transformer encoder captures compatibility relationships, which is helpful for encoding them into the target item embedding to retrieve compatible items, and 2) the image encoder captures fashion-specific features, which is used to extract better feature vectors for positive and negative samples in the set-wise outfit ranking loss. \subsubsection{Set-wise Outfit Ranking Loss:} \label{sec:ocloss} \begin{figure}[t] \centering \includegraphics[width=0.5\textwidth]{Figures/loss_comp.png} \caption{Comparison of pair-wise outfit ranking loss \cite{compretrieval2020} and our set-wise outfit ranking loss. Our framework generates a single target item embedding that captures the compatibility of the entire outfit and does not need pairwise computations with individual items in the outfit as in \cite{compretrieval2020}.} \label{fig:Loss} \end{figure} Previous approaches (\cite{typeaware2018}, \cite{scenet2019}) use a triplet loss to learn relationships only between a pair of items but do not consider the relationship between all items in the outfit. To address this, the outfit ranking loss \cite{compretrieval2020} is proposed which considers the pairwise compatibility of target items with all the items in the outfit, as shown in Figure \ref{fig:Loss} (a). In contrast, our approach generates a single target item embedding $\mathrm t$ that already captures the compatibility relationships for a set of outfit items and hence does not require pairwise comparisons with individual outfit items, as shown in Figure \ref{fig:Loss} (b). This reduces the complexity of \cite{compretrieval2020} from $\mathcal{O}\left(LS\right)$ to $\mathcal{O}\left(S\right)$ during training, where $L$ denotes the outfit length and $S$ denotes the number of positive and negative samples. In practice, only legitimate outfit samples are provided in the dataset, and there are no annotated negative samples. Given an outfit we randomly pick an item as positive and the remaining items as the partial outfit. Here, we investigate a curriculum learning approach to gradually increase the difficulty of negatives for training. Specifically, we train the model in two stages. In the first stage, we sample the negatives from the same high-level category as the positive item. Subsequently in the second stage, we sample harder negatives from more fine-grained categories. Note that since CIR is different from visual similarity search, our negatives are different from the conventional way of constructing triplets (e.g., \cite{facenet2015,Song2016DeepML}), where negatives are sampled from other classes. The set-wise outfit ranking loss is designed to optimize relative distances between samples such that the target item embedding moves closer to the positive embedding and farther apart from the negative embeddings. Note that we use the pre-trained image and text encoders (cf. Sec. \ref{sec:pretrain}) to extract the positive and negative embeddings. Because we have a single target item embedding that encodes the compatibility of the entire outfit, we can directly train our set-wise ranking loss using triplets without requiring pairwise computations as \cite{compretrieval2020}. The set-wise outfit ranking loss is defined as: \begin{equation} L\left(\mathrm t,p,N\right)=\;L{\left(\mathrm t,p,N\right)}_{All}+\;L{\left(\mathrm t,p,N\right)}_{Hard} \label{eq:setwise_outfit_ranking_loss} \end{equation} \noindent \[ L{\left(\mathrm t,p,N\right)}_{All}=\frac1{\left|N\right|}\sum_{j=1}^{\left|N\right|}\left[d\left(\mathrm t,f^p\right)-d\left(\mathrm t,f_j^N\right)+m\right]_+ \] \[ L{\left(\mathrm t,p,N\right)}_{Hard}={\left[d\left(\mathrm t,f^p\right)-\underset{j=1...\left|N\right|}{\text{min}}d\left(\mathrm t,f_j^N\right)+m\right]}_+ \] \noindent where $[]_+$ is the hinge loss, $\mathrm t$ is the target item embedding, $f^p$ is the positive embedding, $f_j^N$ is the $j^{th}$ negative embedding from the pool of negative samples in $N$, and $m$ is the margin. The loss has two components as shown in Equation \eqref{eq:setwise_outfit_ranking_loss}. The first component $L{\left(\mathrm t,p,N\right)}_{All}$ considers all the sampled negatives for the outfit, while the second component $L{\left(\mathrm t,p,N\right)}_{Hard}$ considers the hard negative samples (e.g., \cite{hard2020,Song2016DeepML}). This allows the model to learn discriminatory features to distinguish between items that might have very subtle differences between them. We empirically find that this loss formulation and the hard negative sampling strategy improves complementary item retrieval performance significantly (cf. Tables \ref{tbl:abl_retr}(b), \ref{tbl:abl_negsamp}). There are other sampling methods that could potentially be used (e.g., \cite{sampling2017}), but the investigation thereof is outside the scope of this paper. \subsubsection{Indexing and Retrieval for complementary items:} \label{sec:indexing_and_retrieval} Not all the methods for CP can support indexing for retrieval. For example, SCE-Net \cite{scenet2019} requires pairs of images as inputs, which does not allow single item embedding extraction for indexing. We design our framework in a way that allows extraction of individual item feature vectors during indexing and generate a single item embedding during inference. Based on our design, we can use off-the-shelf KNN search tools (e.g., \cite{bworld,faiss}) to perform indexing and retrieval, which makes the search very efficient even for a large database (e.g., with millions of items). Specifically, during indexing, we use the trained image and text encoder to extract the item features. This does not depend on the query images unlike \cite{scenet2019}. During inference, given the partial outfit and a target item description, our framework generates a single target item embedding, which is then used to search for compatible items from the database using KNN search. Our framework offers two advantages as compared to prior works. First, we require smaller indexing size compared to previous approaches that use subspace embeddings. For indexing, Type-aware \cite{typeaware2018} and CSA-Net \cite{compretrieval2020} generate multiple embeddings of each item for each of the target categories and therefore the indexing size grows linearly with the number of categories. Because we are not learning subspaces, our approach is independent of the number of categories. Second, in \cite{compretrieval2020}, for each item in the outfit, a target category-specific embedding is extracted, which is used to retrieve compatible items from the database. This has to be repeated exhaustively for each item in the query outfit. In contrast, our framework can retrieve items in a single step regardless of outfit length. \begin{table}[b] \centering\caption{Comparison of our model with state-of-the-art methods on the compatibility prediction task using the AUC metric \cite{hanACMMM2017}. The methods are evaluated on Polyvore-Outfits (where -D denotes the disjoint dataset). } \begin{tabular}{@{}llcc@{}} \toprule Method & Features & PO-D & PO \\ \midrule BiLSTM + VSE \cite{hanACMMM2017} & ResNet-18 + Text & 0.62 & 0.65 \\ GCN (k=0) \cite{coherent2019} & ResNet-18 & 0.67 & 0.68 \\ SiameseNet \cite{typeaware2018} & ResNet-18 & 0.81 & 0.81 \\ Type-Aware \cite{typeaware2018} & ResNet-18 + Text & 0.84 & 0.86 \\ SCE-Net \cite{scenet2019} & ResNet-18 + Text & - & 0.91 \\ CSA-Net \cite{compretrieval2020} & ResNet-18 & 0.87 & 0.91 \\ \midrule OutfitTransformer (Ours) & ResNet-18 & 0.87 & 0.92 \\ OutfitTransformer (Ours) & ResNet-18 + Text & \textbf{0.88} & \textbf{0.93} \\ \bottomrule \end{tabular} \label{tbl:comp} \end{table} \subsection{Implementation Details} \label{sec:training} The image encoder uses a ResNet-18 initialized with ImageNet pre-trained weights. The text encoder uses a pre-trained SentenceBERT \cite{SBERT2019}, on top of which we add a fc layer. During training, we finetune the weights of the image encoder and the fc layer of the text encoder. We extract a $64$-dimensional image and a $64$-dimensional text embedding and concatenate them to generate $128$-dimensional item embeddings before feeding them into the transformer encoder. We use a six-layer transformer encoder with $16$ heads. For the retrieval task, we set the margin $m$ for the set-wise outfit ranking loss as $2$ and sample 10 negatives for each outfit. We use a batch size of $50$ and optimize using ADAM with an initial learning rate of $1e-5$ and reducing the learning rate by half in steps of $10$. \begin{table*}[t] \centering \caption{Comparison of our model with state-of-the-art methods on the FITB (using accuracy) and complementary item retrieval tasks (using recall@top-k). The methods are evaluated on Polyvore-Outfit Dataset (where -D denotes disjoint set).} \begin{tabular}{@{}lcccccccc@{}} \toprule \multirow{2}{*}{Method} & \multicolumn{4}{c}{Polyvore Outfits-D} & \multicolumn{4}{c}{Polyvore Outfits} \\ \cmidrule(l){2-5} \cmidrule(l){6-9} & \multicolumn{1}{l}{FITB} & \multicolumn{1}{l}{R@10} & \multicolumn{1}{l}{R@30} & \multicolumn{1}{l}{R@50} & \multicolumn{1}{l}{FITB} & \multicolumn{1}{l}{R@10} & \multicolumn{1}{l}{R@30} & \multicolumn{1}{l}{R@50} \\ \midrule Type-Aware \cite{typeaware2018} & 55.65 & 3.66 & 8.26 & 11.98 & 57.83 & 3.50 & 8.56 & 12.66 \\ SCE-Net Average \cite{scenet2019} & 53.67 & 4.41 & 9.85 & 13.87 & 59.07 & 5.10 & 11.20 & 15.93 \\ CSA-Net \cite{compretrieval2020} & 59.26 & 5.93 & \textbf{12.31} & \textbf{17.85} & 63.73 & 8.27 & 15.67 & 20.91 \\ \midrule OutfitTransformer (Ours) & \textbf{59.48} & \textbf{6.53} & 12.12 & 16.64 & \textbf{67.10} & \textbf{9.58} & \textbf{17.96} & \textbf{21.98} \\ \bottomrule \end{tabular} \label{tbl:retr} \end{table*} \section{Experiments} \label{sec:results} We compare our proposed approach with the state-of-the-art baselines such as Bi-LSTM \cite{hanACMMM2017}, GCN \cite{Cucurull_2019_CVPR}, SiameseNet \cite{Veit2017}, Type-aware \cite{typeaware2018} , SCE-Net \cite{scenet2019} and CSA-Net \cite{compretrieval2020} on the Polyvore Outfits dataset \cite{typeaware2018}. For evaluation, we compare our method with these state-of-the-art baselines on three different tasks: \begin{enumerate}[wide, labelwidth=!, labelindent=0pt] \item {\em Outfit Compatibility Prediction (CP) task} that predicts the compatibility of items in an outfit. \item {\em Fill in the Blank (FITB) task} that selects the most compatible item for an incomplete outfit given a set of candidate choices (e.g., 4 candidates). \item {\em Outfit Complementary Item Retrieval (CIR) task} that retrieves complementary items from the database for a target category given an incomplete outfit. \end{enumerate} The Polyvore Outfits dataset \cite{typeaware2018} has two sets, the disjoint and non-disjoint sets. In the disjoint set, the training split items (and outfits) do not overlap with the validation and test splits. In the non-disjoint set, the training split items can overlap with those of validation and test splits, but outfits do not overlap. The non-disjoint set contains 53306 training and 10000 test outfits, while the disjoint set comprises of 16995 training and 15154 test outfits. For the standard compatibility prediction and FITB tasks, we evaluate our model on the Polyvore Outfits dataset. Since the Polyvore Outfits dataset does not provide the annotations for the complementary item retrieval task, we adopt a modified version of the Polyvore Outfits dataset proposed by CSA-Net \cite{compretrieval2020}. \subsection{Outfit Compatibility Prediction (CP)} The goal of this task is to measure the compatibility of an outfit. Our compatibility model in Figure \ref{fig:Overview} (a) predicts a score that indicates the compatibility of the overall outfit. We compare the performance with the state-of-the-art methods in Table \ref{tbl:comp} by using the standard metric AUC \cite{hanACMMM2017}, which measures the area under the receiver operating characteristic curve.\footnote{~The authors do not report the performance of SCE-Net \cite{scenet2019} on the disjoint dataset.} While Bi-LSTM models outfits as a sequence of items, SiameseNet, Type-Aware, CSA-Net and SCE-Net learn pairwise compatibility of items and aggregates the pairwise compatibility scores for all possible pairs in an outfit to learn the compatibility. On the contrary, we use self-attention to learn high-order compatibility relationships between outfit items. We report the performance of \cite{Cucurull_2019_CVPR} from the paper \cite{coherent2019} as the authors report performance on Maryland Polyvore \cite{hanACMMM2017} but not on Polyvore Outfits dataset \cite{typeaware2018}. \cite{Cucurull_2019_CVPR} requires information from a large number of neighbors in a catalog for best performance, which is impractical for our setting because we do not have prior knowledge about connections between each new item to the existing items, as mentioned in \cite{compretrieval2020}. So, we use k=0 (no neighbors) for a fair comparison. We observe that using just image features; we outperform other methods that use both image and text features on the compatibility prediction task. Using text features boosts performance further. The methods \cite{typeaware2018,scenet2019,compretrieval2020} employ a pairwise model where they require careful selection of negatives and data augmentation. Our approach uses the outfit compatibility data provided without using any additional strategies and still outperforms the state of the art methods. From Table \ref{tbl:comp}, we observe that transformers can learn better compatibility relationships than other methods \cite{Cucurull_2019_CVPR,hanACMMM2017} that learn compatibility at an outfit-level. \subsection{FITB and Complementary Item Retrieval (CIR)} \label{sec:res_retr} FITB and complementary item retrieval tasks deal with completing an outfit. While for FITB, the task is to select the best item among a fixed set of choices that goes well with an outfit, for retrieval, the task is to choose the best item from the entire database. For the FITB task we use accuracy and for retrieval we use recall@top-k (abbreviated as R@k) as the metric. Lobert et al.~\cite{lorbert2021} propose to use pre-trained ImageNet embeddings and category for retrieval using self-attention. For evaluation, we adopt their strategy using our own implementation using a transformer \footnote{~Their code is not publicly available and they did not report numbers on the Polyvore Outfits dataset.} and observe that their FITB accuracy on the Polyvore Outfits dataset is 41.61\%. We investigate several strategies such as pre-training on the compatibility prediction task, curriculum learning, a different loss formulation and observe a significant improvement in FITB performance. Our method yields a FITB performance of 58.92\% when using images and category and 67.10 \% using images and text. \begin{table}[b] \centering \caption{Effect of end-to-end training and using different modalities for the CP task.} \begin{tabular}{@{}lc@{}} \toprule \multicolumn{1}{c}{Training strategy} & \multicolumn{1}{l}{CP-AUC} \\ \midrule ResNet-18 (pre-trained ImageNet) & 0.82 \\ ResNet-18 (end-to-end) & 0.91 \\ ResNet-18 (end-to-end) + Category & 0.92 \\ ResNet-18 (end-to-end) + Text & \textbf{0.93} \\ \bottomrule \end{tabular} \label{tbl:comp_mod} \end{table} \begin{table*}[t] \caption{Comparison of different weight initialization schemes and different components of the set-wise outfit ranking loss for the FITB task (using accuracy)} \centering \begin{tabular}{@{}lcccc@{}} \toprule \multirow{2}{*}{Dataset} & \multicolumn{2}{l}{(a) Pre-training on CP task} & \multicolumn{2}{c}{(b) Ranking Loss Components} \\ \cmidrule(l){2-3} \cmidrule(l){4-5} & without & with & $L_{All}$ & $L_{All} + L_{Hard}$ \\ \midrule \multicolumn{1}{l}{Polyvore Outfits-D} & 49.15 & \textbf{59.48} & 55.34 & \textbf{59.48} \\ \multicolumn{1}{l}{Polyvore Outfits} & 53.96 & \textbf{67.10} & 64.48 & \textbf{67.10} \\ \bottomrule \end{tabular} \label{tbl:abl_retr} \end{table*} \begin{table*}[h] \centering \caption{Comparison of different strategies for sampling negative samples either from the same high-level or fine-grained category as the positive exemplar for the CIR task.} \begin{tabular}{@{}lcccccccc@{}} \toprule \multirow{2}{*}{Negative sampling} & \multicolumn{4}{c}{Polyvore Outfits-D} & \multicolumn{4}{c}{Polyvore Outfits} \\ \cmidrule(l){2-5} \cmidrule(l){6-9} & \multicolumn{1}{l}{FITB} & \multicolumn{1}{l}{R@10} & \multicolumn{1}{l}{R@30} & \multicolumn{1}{l}{R@50} & \multicolumn{1}{l}{FITB} & \multicolumn{1}{l}{R@10} & \multicolumn{1}{l}{R@30} & \multicolumn{1}{l}{R@50} \\ \midrule High-level category & 55.54 & 5.14 & 10.21 & 14.15 & 63.33 & 7.26 & 13.60 & 17.78 \\ Fine-grained category & \textbf{59.48} & \textbf{6.03} & \textbf{12.20} & \textbf{16.51} & \textbf{67.10} & \textbf{9.29} & \textbf{16.94} & \textbf{21.82} \\ \bottomrule \end{tabular} \label{tbl:abl_negsamp} \end{table*} For retrieval, we use the same testing setup as CSA-Net \cite{compretrieval2020}, and compare the performance of our method with the state of the art methods CSA-Net \cite{compretrieval2020}, Type-aware \cite{typeaware2018} and SCE-Net average \cite{scenet2019}\footnote{~Type-aware and SCE-Net were adapted for retrieval as reported in \cite{compretrieval2020}. The performance of \cite{ADDE2021} is not directly comparable to ours, as their method needs to train attributes on another dataset (Shopping100k).} For evaluation, we use the category as our target item description for retrieving complementary items and use recall@top-k metric that measures the rank of the ground-truth item similar to \cite{compretrieval2020}. From Table \ref{tbl:retr}, we observe that we outperform all the methods on the non-disjoint dataset. On the disjoint dataset, our performance on recall@top-10 is better than CSA-Net, but is slightly worse on recall@top-30 and recall@top-50. We conjecture that the reason for the performance drop might be because there are fewer outfits on the disjoint set, and transformers typically require large amounts of training data to generalize well. Also, the authors in CSA-Net discuss that the rank of the ground truth is not a perfect measure for evaluating the retrieval performance. So, we conduct an user study in Section \ref{sec:user_study}. \subsection{Ablation studies} \label{sec:ablations} \noindent \textbf{Effect of end-to-end training on CP:} We compare the effect of end-to-end training and using different input modalities on the CP task in Table \ref{tbl:comp_mod}. We experiment with using pre-computed ResNet18 image embeddings generated as inputs to our transformer model, and observe that training end-to-end improves performance by 9\%. We hypothesize that training end-to-end allows the image encoder to learn better fashion-specific features. This allows the transformer to capture visual relationships between items to learn compatibility better. We observe that using category or text information further boost performance by 1\% and 2\%, respectively. \noindent \textbf{Pre-training:} We compare different weight initialization schemes in Table \ref{tbl:abl_retr}(a): 1) We train our framework for the retrieval task where the transformer-encoder is trained from scratch and the image encoder is initialized with pre-trained ImageNet weights. 2) We first pre-train our framework on the compatibility prediction task (CP) and then fine-tune our model on the retrieval task. We see a significant improvement in FITB accuracy with the pre-training. \noindent \textbf{Set-wise outfit ranking loss components:} As mentioned earlier in Section \ref{sec:ocloss}, the outfit complementarity loss has two components. $L_\text{All}$ optimizes the distances such that the target item embedding is closer to the positive and well separated from the pool of negative samples while $L_\text{Hard}$ focuses specifically on the hard negatives from the randomly sampled pool. From Table \ref{tbl:abl_retr}(b), we observe that $L_\text{Hard}$ improves FITB performance by 3-4\% on both datasets. \begin{table*}[h] \centering \caption{Comparison of using different input information during inference for CIR.} \begin{tabular}{@{}lcccccccc@{}} \toprule \multirow{2}{*}{Method} & \multicolumn{2}{c}{Input information used} & \multicolumn{3}{c}{Polyvore Outfits-D} & \multicolumn{3}{c}{Polyvore Outfits} \\ \cmidrule(l){2-3} \cmidrule(l){4-6}\cmidrule(l){7-9} & Target Item & Outfit Items & \multicolumn{1}{l}{R@10} & \multicolumn{1}{l}{R@30} & \multicolumn{1}{l}{R@50} & \multicolumn{1}{l}{R@10} & \multicolumn{1}{l}{R@30} & \multicolumn{1}{l}{R@50} \\ \midrule CSA-Net \cite{compretrieval2020} & Catg. & Image + Catg. & 5.93 & \textbf{12.31} & \textbf{17.85} & 8.27 & 15.67 & 20.91 \\ \midrule OutfitTransf. (Ours) & Catg. & Image + Catg. & 6.03 & 12.20 & 16.51 & 9.29 & 16.94 & 21.82 \\ OutfitTransf. (Ours) & Catg. & Image + Text & \textbf{6.53} & 12.12 & 16.64 & \textbf{9.58} & \textbf{17.96} & \textbf{21.98} \\ \bottomrule \end{tabular} \label{tbl:abl_retrmod} \end{table*} \noindent \textbf{Negative sampling strategies:} In Section \ref{sec:ocloss}, we proposed a curriculum learning strategy where we first sample negatives from the same high-level category as the positive and subsequently sample harder and more informative negatives from the same fine-grained category. This strategy leads to stable training and improves both FITB and complementary item retrieval performance substantially as shown in Table \ref{tbl:abl_negsamp}. Directly training using the hardest negatives from the beginning leads to poor performance. \noindent \textbf{Comparing different modalities used for retrieval:} The OutfitTransformer for retrieval is trained using image and text information. Since the complimentary outfit retrieval task in \cite{compretrieval2020} is designed for retrieving items given a target category, we feed the category information to our text encoder and use that for our target item query. We experiment with different modalities during inference, such as using an image with either category information or text description for the items in the partial outfit. From Table \ref{tbl:abl_retrmod}, we observe that when using category information, our method outperforms CSA-Net on the non-disjoint dataset, and using text boosts the retrieval performance further. \subsection{Qualitative results} In this section, we demonstrate qualitatively that our framework retrieves compatible items using target category or text-based descriptions. For this, we use the query outfits from the FITB test split provided by the Polyvore Outfits dataset \cite{typeaware2018}. For the complementary item retrieval task based on a target category, we use the dataset proposed by Lin \emph{et al}\onedot \cite{compretrieval2020}. In Fig. \ref{fig:CatgQuery}, we show examples where our method can successfully retrieve the ground truth as one of the top retrieved items. Subsequently, in Fig. \ref{fig:fail_CatgQuery} we show examples where the the ground truth item is not found in the top retrieved results. We observe that this is mainly because there can be multiple items in the dataset that could be a good match for the partial outfit either because it is either very similar in style, color, etc. to the ground truth item as shown in Fig. \ref{fig:fail_CatgQuery}(a) or it might be dissimilar to the ground truth but can still be compatible with the overall outfit as shown in Fig. \ref{fig:fail_CatgQuery}(b). Therefore, the rank of the ground truth item is not a perfect indicator of the practical utility of the system. This is a limitation of the evaluation metric due to the lack of annotated ground truth as mentioned in \cite{compretrieval2020}. Towards this end, we conduct a user study as described in Section \ref{sec:user_study} to further validate the quality of the retrieval results and for a better understanding of the usefulness of our framework. We also use our framework for retrieving complementary items based on a target item description provided as free-form text, as shown in Figs. \ref{fig:textretr} and \ref{fig:jewelryretr}. Since the dataset does not provide any annotated text-based queries, we show qualitative results that demonstrate that our framework can retrieve items that are {\em both} compatible and matches the target item description in Fig. \ref{fig:textretr}. In Fig. \ref{fig:jewelryretr}, we show that for a given list of text-based queries and different partial outfits, our system can retrieve complementary items for each specific outfit. \subsection{User Study} \label{sec:user_study} The recall@top-k metrics reported in the paper rely on the relative rank of the ground-truth item in the complementary item retrieval task. While high values on these metrics indicate that our model performs competitively or better than state-of-the-art, as \cite{compretrieval2020} point out, the rank of the ground-truth item is not a perfect indicator of retrieval performance since the database can contain many complementary items to the query outfits -- some of which may be judged by human experts to be equally-good or even better stylistic matches, as can be seen in Fig. \ref{fig:fail_CatgQuery}. We evaluate this hypothesis by running an A/B test using Amazon Mechanical Turk (c.f. Fig. \ref{fig:UserStudy} showing the question template used for the experiment). If human experts select our retrieved item over the ground truth item about 50\% of the time or higher\footnote{higher than 50\% would indicate that for some partial outfits, our method can find a better match from the database of items belonging to the target category than the original answer provided by the dataset}, that would indicate that even in cases where the ground-truth item is not found in the top-k retrieval results, the retrieved items are a good replacement. For quality control of our annotator pool, we only allow annotators with $>$ 95\% acceptance rate in the past tasks and who have completed at least 1000 tasks. A query outfit from the FITB test split of the Polyvore Outfits dataset is presented, and the annotator is asked to select which of the two items provided better completes the outfit (as shown in Fig. \ref{fig:UserStudy}). We only present questions where the ground-truth item is not found in the top-three retrieved items. One of the presented items is always the ground-truth, and the other — an item retrieved by our model. The total number of questions is 5120, each of which is annotated by 10 subjects. We compute the average number of times the retrieved item was chosen over the ground truth item. We find that 52.5\% of the time annotators select items retrieved by our model over the ground truth. The average rate of 52.5\% denotes that our retrieved results were at least as good as the ground truth items. This provides an additional evidence over and above the offline results that our model is able to retrieve compatible items to the query outfit, and they are as good of a match as the ground truth item. \section{Conclusion} We present a framework to learn outfit-level representations for compatibility prediction and complementary item retrieval. Experimental results demonstrate that our model outperforms several state-of-the-art approaches on the Polyvore Outfits dataset in three established tasks: outfit compatibility, fill-in-the-blank, and complementary item retrieval. We validate that our retrieved results are competitive with the ground truth via a user study, and demonstrate qualitatively that our framework retrieves compatible items using target category or text-based descriptions. In future work, we plan to extend complementary item retrieval to sets of items rather than one-at-a-time. \begin{figure*}[h] \centering \includegraphics[width=0.9\textwidth]{Figures/all_category.png} \caption{Some example complementary item retrieval results using our framework for different top-level categories. Given a partial outfit and a target category, our method retrieves a list of compatible items that match the global style of the outfit. The ground truth item is indicated by the green bounding box. } \label{fig:CatgQuery} \end{figure*} \begin{figure*}[h] \centering \begin{minipage}[c]{0.43\textwidth} \includegraphics[width=\textwidth]{Figures/textj.png} \includegraphics[width=\textwidth]{Figures/textb.png} \caption*{(a) Text-based queries} \end{minipage} \hfill \vline \hfill \begin{minipage}[c]{0.47\textwidth} \includegraphics[width=\textwidth]{Figures/itw.png} \caption*{(b) Conversational queries} \end{minipage} \caption{Some example complementary item retrieval results using our method for different target item descriptions. Given a partial outfit and text-based queries, our approach retrieves a list of compatible items that match both the global style of the outfit and the text description.} \label{fig:textretr} \end{figure*} \newpage \begin{figure*}[h] \centering \includegraphics[width=\textwidth]{Figures/failure_similar.png} \caption*{(a) Retrieved items are very similar in color, texture, style, pattern, etc. to the ground truth item.} \vspace{0.25in} \includegraphics[width=\textwidth]{Figures/failure_diff.png} \caption*{(b) Retrieved items are different in color, style, etc. from the ground truth item but they are also compatible with the partial outfits.} \caption{Some failure cases of complementary item retrieval using our method. The partial outfit and the corresponding ground truth item are shown in the left column, the target category in the middle column and the retrieved items are shown in the right column. The ground truth is highlighted using a green bounding box and the rank of the item is also presented below the box.} \label{fig:fail_CatgQuery} \end{figure*} \begin{figure*}[h] \centering \begin{minipage}[c]{0.49\textwidth} \includegraphics[width=\textwidth]{supp_figs/49.png} \includegraphics[width=\textwidth]{supp_figs/54.png} \includegraphics[width=\textwidth]{supp_figs/693.png} \includegraphics[width=\textwidth]{alternate_figs/164.png} \includegraphics[width=\textwidth]{supp_figs/152.png} \end{minipage} \hfill \begin{minipage}[c]{0.49\textwidth} \includegraphics[width=\textwidth]{supp_figs/36.png} \includegraphics[width=\textwidth]{supp_figs/27.png} \includegraphics[width=\textwidth]{supp_figs/697.png} \includegraphics[width=\textwidth]{supp_figs/190.png} \includegraphics[width=\textwidth]{supp_figs/206.png} \end{minipage} \end{figure*} \begin{figure*}[h] \centering \begin{minipage}[c]{0.49\textwidth} \includegraphics[width=\textwidth]{supp_figs/691.png} \includegraphics[width=\textwidth]{alternate_figs/128.png} \includegraphics[width=\textwidth]{supp_figs/31.png} \includegraphics[width=\textwidth]{supp_figs/705.png} \end{minipage} \begin{minipage}[c]{0.49\textwidth} \includegraphics[width=\textwidth]{supp_figs/417.png} \includegraphics[width=\textwidth]{supp_figs/674.png} \includegraphics[width=\textwidth]{supp_figs/423.png} \includegraphics[width=\textwidth]{alternate_figs/180.png} \end{minipage} \caption{This figure illustrates that our method can retrieve items that are compatible with different partial outfits for the same list of text-based queries. The first query for each partial outfit mentions only the top-level category information whereas the subsequent queries are more descriptive which allows us to further refine search results. } \label{fig:jewelryretr} \end{figure*} \begin{figure*}[tp] \centering \begin{minipage}[c]{0.49\textwidth} \includegraphics[width=\textwidth]{supp_figs/user-study-1.png} \includegraphics[width=\textwidth]{supp_figs/user-study-2.png} \includegraphics[width=\textwidth]{supp_figs/user-study-3.png} \end{minipage} \hfill \begin{minipage}[c]{0.49\textwidth} \includegraphics[width=\textwidth]{supp_figs/user-study-4.png} \includegraphics[width=\textwidth]{supp_figs/user-study-5.png} \includegraphics[width=\textwidth]{supp_figs/user-study-6.png} \end{minipage} \caption{Some examples of the questions presented to the MTurk annotators for the user study. } \label{fig:UserStudy} \end{figure*} \bibliographystyle{ieee_fullname}
{'timestamp': '2022-04-19T02:08:55', 'yymm': '2204', 'arxiv_id': '2204.04812', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04812'}
arxiv
\section*{Acknowledgements} \begin{document} \title{Distributed Hardware Accelerated Secure Joint Computation on the COPA Framework} \author{\IEEEauthorblockN{Rushi Patel\IEEEauthorrefmark{1}, Pouya Haghi\IEEEauthorrefmark{1}, Shweta Jain\IEEEauthorrefmark{3}, Andriy Kot\IEEEauthorrefmark{3}, Venkata Krishnan\IEEEauthorrefmark{3}, \\ Mayank Varia\IEEEauthorrefmark{2} and Martin Herbordt\IEEEauthorrefmark{1}} \IEEEauthorblockA{\IEEEauthorrefmark{1}College of Engineering, Boston University, Boston, MA} \IEEEauthorblockA{\IEEEauthorrefmark{2}Computing \& Data Sciences, Boston University, Boston, MA} \IEEEauthorblockA{\IEEEauthorrefmark{3}Intel Corporation, Hudson, MA} Email: \IEEEauthorrefmark{1}\{ruship,haghi,herbordt\}@bu.edu \IEEEauthorrefmark{2}[email protected] \IEEEauthorrefmark{3}\{shweta.jain,andriy.kot,venkata.krishnan\}@intel.com} \maketitle \IEEEpubidadjcol \begin{abstract} Performance of distributed data center applications can be improved through use of FPGA-based SmartNICs, which provide additional functionality and enable higher bandwidth communication. Until lately, however, the lack of a simple approach for customizing SmartNICs to application requirements has limited the potential benefits. Intel’s Configurable Network Protocol Accelerator (COPA) provides a customizable FPGA framework that integrates both hardware and software development to improve computation and communication performance. In this first case study, we demonstrate the capabilities of the COPA framework with an application from cryptography -- secure Multi-Party Computation (MPC) -- that utilizes hardware accelerators connected directly to host memory and the COPA network. We find that using the COPA framework gives significant improvements to both computation and communication as compared to traditional implementations of MPC that use CPUs and NICs. A single MPC accelerator running on COPA enables more than 17Gb/s of communication bandwidth while using only 1\% of Stratix 10 resources. We show that utilizing the COPA framework enables multiple MPC accelerators running in parallel to fully saturate a 100Gbps link enabling higher performance compared to traditional NICs. \end{abstract} \begin{comment} Distributed data center applications rely on communication through dedicated hardware NICs and specialized communication networks to gain performance improvements in a many node system. The introduction of SmartNICs is a major improvement to communication bottlenecks as they provide additional functionality and higher bandwidth communication. However, the lack of a simple approach for customizing SmartNICs to application requirements limits the potential performance gain. Intel’s Configurable Network Protocol Accelerator (COPA) provides a customizable FPGA framework that integrates both hardware and software development to improve computation and communication. Through the use of programmable hardware logic, applications gain additional performance through the offload of computation to the network attached FPGA, while utilizing the COPA network 100Gbps link to perform communication between nodes. In this first case study, we demonstrate the capabilities of the COPA framework with an application from cryptography utilizing a hardware accelerator connected directly to host memory and the COPA network. Specifically, secure Multi-Party Computation (MPC) utilizing the COPA framework gives significant improvements to both computation and communication as compared to traditional implementations utilizing CPU resources and NICs. A single MPC accelerator running on COPA enables more than 17Gb/s of communication bandwidth utilizing 1\% of Stratix 10 FPGA resources. We show that utilizing the COPA framework enables multiple MPC accelerators running in parallel to fully saturate a 100Gbps link enabling higher performance compared to traditional NICs. \end{comment} \IEEEpeerreviewmaketitle \section{Introduction} Distributed systems utilize many-node environments and communicate through the use of networks to run large-scale applications with large data sets. Data centers provide ideal environments for distributed computing as they offer low-latency communication between nodes but are often limited by network bandwidth through the use of general-purpose NICs. These network bottlenecks drive the need for alternative communication resources to improve performance of large-scale datacenter applications. SmartNICs \cite{zilberman2014netfpga, mellanoxbluefield, mellanoxinnova2} have been introduced to perform the same tasks of standard NICs, but contain additional resources to allow for network function optimization with additional hardware. Microsoft has shown \cite{Caulfield16, firestonensdi2018, bojie2016clicknp} the usage of dedicated SmartNICs with FPGA resources for network function offload and cloud management features. Adoption of SmartNICs continues to increase as a means to accelerate network functions and offload packet processing tasks away from CPU resources \cite{LeSoCC2017UNO, Schonbein19, EranATC19NICA, torkASPLOS20Lynx, GrantSIGCOMM20FairNIC, Sebastiano2019DDOS}. Past avenues of research focus have focused on ASIC-based SmartNICs that utilize soft cores for packet processing, but face challenges in hardware adoption of applications and are limited by network speed. In contrast, SmartNICs with integrated FPGAs address these limitations by offering a reconfigurable environment and enable inline acceleration of network functions. Inline accelerators offer many opportunities to perform packet processing and filtering, however can still be limited in some high performance computing (HPC) applications. SmartNIC accelerated applications generally rely on vendor support in the form of intellectual property (IP) and software development kits. These systems typically are in early stages of development and/or provide only low-level functionality that is inadequate functionality for many use cases. Thus an additional hurdle is the implementation of software application layers which can natively communicate with these SmartNIC resources. Intel's Configurable Network Protocol Accelerator (COPA) \cite{Krishnan20, krishnan2020configurable} was developed to address these issues. COPA utilizes the open source software library, OpenFabric interface (OFI) libfabric \cite{OpenFabrics2015}, for platform-agnostic development and a standard for networking and acceleration invocation. In addition, the COPA hardware framework provides two options to reconfigurable accelerators, inline and lookaside, both of which are directly accessible from the libfabric API. COPA uses the on-board high speed transceivers, e.g., of the Intel Stratix 10 GX, and a uniquely designed architecture to enable high speed remote direct memory access (RDMA) between nodes at 100Gb/S line rate. Unique features include the ability for remote invocation of accelerators and headless operations for host free integration into a distributed data center environment. So far, however, there has been no published work demonstrating or evaluating COPA with respect to a distributed application; that is our goal here. As a candidate application we have selected Multi-Party Computation (MPC), which would greatly benefit from the features available through the COPA framework. MPC is the cryptographic process of performing calculations on confidential data between multiple organizations while maintaining a level of confidentiality, integrity, and assurance of one's own private data. Parties encode and share their own private data between organizations while maintaining an agreed upon level of security guarantee. This form of joint computation is especially important for industries such as healthcare and finance, as user data is typically under protection through laws and regulations. FPGA accelerated Multi-Party Computation continues to be a progressive research topic \cite{Jarvinen2010, Jarvinen2010b, Frederiksen2014, songhori16, hussain18, songhori19, hussain19, Fang2017a, Fang2019, Huang2019a, Leeser2019, Wolfe20, Patel20} as significant performance improvements can be obtained from hardware acceleration. This paper argues that combining the COPA tool-set with state of the art MPC algorithms can achieve a lower communication bottleneck for high performance computation inside a datacenter environment. We show that utilizing the COPA system enables a method of performing low-level MPC operations with minimal CPU interaction while enabling improved performance compared to traditional CPU and NIC implementations. In summary, our contributions are as follows: \begin{itemize} \item Examine the performance available utilizing the 100Gbps network and configurable lookaside accelerator option of the COPA FPGA framework. \item Adapt hardware accelerated MPC operations to the COPA infrastructure utilizing the configurable FPGA lookaside accelerator enabling significant performance improvements compared against CPU and NICs. \item Using only 1\% of the FPGA fabric for secure joint computation, we show that having multiple accelerators running in parallel can saturate the potential 100Gb/s link available through COPA while performing over 6000 MPC operations per second. \end{itemize} \section{Background} \subsection{Configurable Network Protocol Accelerator} The COPA SmartNIC works by using the libfabric software layer with included extensions to queue commands for processing by the hardware. These commands include both RDMA functionality and accelerator specific commands. The RDMA functions use the COPA network TX and RX data paths to perform memory read and write functions without host involvement. Previous work has shown the COPA network can achieve up to 100Gb/S bandwidth with zero-copy direct memory access. The accelerator specific commands include the use of a number of inline accelerators alongside the RDMA functions. Inline functions operate on packets during transit in a bump-in-the-wire method, allowing for data manipulation of packets during egress or ingress of edge nodes. Two examples of inline acceleration are checksum calculation on data in transit or encode/decode functions with pre-shared key pairs. Additionally, commands can be constructed to trigger the lookaside accelerator functions both locally and on remote COPA nodes. Lookaside functions operate on data at rest, in host memory, and have direct connection with the COPA network to perform additional RDMA functions. This enables the lookaside accelerator to perform data transfer tasks without requiring the host to initiate network operations. Both inline and lookaside accelerator options can be reconfigured by users for application specific functions. \subsection{Secure Multi-Party Computation} Secret sharing-based multi party computation (MPC) is a method of secure joint computation that allows any number of party members $N$ to work together to obtain a final output \cite{araki16,DBLP:conf/ndss/Demmler0Z15,dalskov2021fantastic}. Confidential data is distributed to all party members in the form of \emph{shares}, where each individual share does not contain enough information to learn anything about the secret data but all shares collectively can be used to decode the data. Each party member is considered an equal to another, and computation is performed synchronously between all members to maintain accurate share representations of the final value between all members. Each synchronous operation requires members to perform communication rounds of data among all parties, which increases the need for high bandwidth and low latency networks between members. As a consequence, the rate of computation in MPC is bottlenecked by network performance, making this application a prime target for COPA. Secret sharing MPC requires all party members to perform both local and joint computation. With FPGAs secret sharing MPC can obtain performance improvements on both forms of computation tasks \cite{Wolfe20, Patel20}. Prior research shows that a single FPGA can fully saturate a standard 10GigE NIC while only utilizing a fraction of the available resources of the FPGA hardware. In addition, colocated party members in a datacenter provides an optimal environment to reduce communication latency further improving the performance of communication-dependent MPC operations. To the best of our knowledge, we are the first to integrate Multi-Party Computation and SmartNIC functionality to improve upon communication bottlenecks. We believe the combination of MPC and COPA lookaside acceleration enables a significant improvement to both computation and communication performance thus eliminating previous network limitations. Utilizing the many unique features of the COPA framework, including remote accelerator triggering and payload processing before and after transit, allow for a headless behavior of many MPC operations between party members. This enables less CPU utilization during concurrent operations between party members and reduces the need for explicit synchronized commands by each host system. \begin{figure} \centering \includegraphics[width=0.9\linewidth]{COPA_Lookaside_Top.png} \vspace*{-0.1truein} \caption{COPA architecture connected to host system through PCIe. The COPA FPGA contains a lookaside accelerator implementation directly connected to the COPA network allowing for network functions without host interaction.} \label{fig:MPC_LA} \vspace*{-0.1truein} \end{figure} \begin{figure} \centering \includegraphics[width=0.6\linewidth]{COPA_Lookaside_Accel.png} \vspace*{-0.1truein} \caption{Two-stage MPC implementation as single lookaside accelerator.} \label{fig:MPC_LA_Accel} \vspace*{-0.2truein} \end{figure} \section{Architecture Implementation} \subsection{Initial Protocol Requirements} Our initial design uses the host to generate, and COPA unidirectional PUT functions to distribute, shares of private data to the other parties. Each share is generated through of the use of a random number generator and a specific calculation following the agreed upon algorithm protocol. In our implementation, we use the 4-party MPC protocol of Dalskov, et al. \cite{dalskov2021fantastic}; we discuss algorithm specifics in Section \ref{Experiment_Setup}. As all confidential data remains tied to the host, this maintains full privacy of confidential data as any data passing through the COPA network is obfuscated in the form of shares. In addition to distributing shares between parties, a set of keys are also allocated for further computation when pseudorandomly generated numbers must be known by two or more parties. Each party member uses a set of unique keys to generate random numbers concurrently with other party members; however, each party member does not contain knowledge of all keys. This concurrent behavior is important to maintain protocol accuracy between party members during operation and can help avoid additional communication. \subsection{MPC Gate Operations} We focus on arithmetic MPC operations which consist of addition and multiplication. Shares are formed using \emph{128-bit} values and all operations are based around modular arithmetic with a ring module of ${2^{128}}$. For our algorithm of choice, MPC addition consists of local computation only and doesn't require interaction between members. Multiplication requires both local computation of shares and a single round of communication between party members; we thus focus on the performance obtained by improving on these communications. \subsection{Lookaside Accelerator} The COPA lookaside architecture uses separate accelerator logic outside of the COPA network as seen in Figure \ref{fig:MPC_LA}. Acceleration is initially controlled by the host through a unique command containing the source data location, destination location, length of data, and type of operation. A global control unit manages incoming commands in the queue and assigns them to appropriate accelerators. This feature enables a single host to issue commands to different accelerators for added parallelism or unique functions. We use only a single MPC accelerator for our initial tests, but discuss the improvements available with additional accelerators. Each accelerator initially collects the source data through a DMA operation from the host memory. If source data is unavailable locally, i.e., found on a remote COPA node, then a COPA network command is generated and used to obtain data from the remote node prior to DMA operation. Following the local DMA completion, acceleration is performed and final calculations are sent back to host memory through a second DMA operation. If the destination memory location is for a remote node, then the COPA network is again used to send the final completed values to another COPA node on the network. \subsubsection{MPC Accelerator Core} To fully utilize the COPA lookaside accelerator we split up the multiplication operations into the local computation stage and a post communication accumulation stage as seen in Figure \ref{fig:MPC_LA_Accel}. Data is first obtained by the DMA logic and stored into two sets of on-chip memory, Data A and Data B. Data in these two on-chip memory regions are based on the stage of computation being performed. First stage computation takes two lists of values in share form, while the second stage contains the intermediate share data and communication data received from other party members. The local computation stage uses a pseudo random number generator and on-chip resources to perform the initial MPC calculations and save the intermediate share information back to host memory. Addition operations only require the use of the first stage accelerator to perform calculation on input data and generate complete shares. Multiplication operations use the first stage to prepare partial local shares and data for communication to other party members. On completion of the first stage, information required for party members is prepared for communication and passed along appropriately through the use of the COPA network. This prepares the data for processing in the second stage of the multiply operation. On completion of communication from each party member, the locally generated intermediate shares are combined with ingress data from party members and saved back into host memory for future computation. \section{Results} \begin{figure} \centering \includegraphics[width=0.9\linewidth]{Throughput_MPC.png} \vspace*{-0.1truein} \caption{Throughput comparison between base MPC accelerator and MPC with malicious security running at 275 MHz with varying batch sizes of multiply operations. Malicious security requires an additional collision resistant hash value to be transferred. Saturation of the base accelerator is over 17.5Gb/s and with malicious security is over 26.3Gb/s.} \label{fig:MPC_Throughput} \vspace*{-0.1truein} \end{figure} \begin{table} \centering \caption{Single MPC lookaside FPGA utilization} \vspace*{-0.05truein} \begin{tabular}{|c|c|} \hline Stratix 10 FPGA & Raw (Total Percentage) \\ \hline\hline Freq & 250MHz - 275MHz \\ \hline ALM & 10667 (1\%)\\ \hline Memory bits & 5,156,500 (2\%) \\ \hline RAM blocks & 668 (6\%) \\ \hline DSP blocks & 150 (3\%) \\ \hline \end{tabular} \label{fig:FPGA_Utilization} \vspace*{-0.2truein} \end{table} \subsection{Experiment Setup} \label{Experiment_Setup} We focus on the throughput and resource utilization of the multiply operation for a 4-party semi-honest majority MPC algorithm \cite{dalskov2021fantastic}. Our chosen algorithm requires each party member to hold 3-out-of-4 shares of each data element and communicate between all parties equally during calculation. In particular, the key is performing multiplication operations on shares of \emph{128-bit} integer data types which generates three \emph{128-bit} integers for communication to the other party members. To maintain accuracy in multiply operations, each party member must perform the initial local calculations synchronously and participate in a round of communication to obtain all the necessary intermediate data from other party members. For additional security against malicious parties, hashed values of communication data is sent to opposing parties as a method of verification between party members. A mismatch in calculated hashes would indicate an incorrect joint computation and the party members can abort future computation to avoid the risk of data leakage through a malicious actor. We implement our hardware design on the COPA framework using Intel Stratix 10 FPGAs interconnected with 100GigE high speed transceivers. Each party maintains ownership of a single FPGA connected to a host system using the COPA framework for communication between party members. Acceleration is performed through the use of lookaside accelerator commands sent from each host system directly to the FPGA lookaside accelerator through a dedicated queue. The lookaside command format allows for batch operations on a stream of data from a specified source and saves local computation back to host memory while preparing the network data for transfer to each party member. \subsection{Analysis} Resource utilization for a single MPC lookaside accelerator can be found in Table \ref{fig:FPGA_Utilization}. This shows the implementation uses minimal resources which allows for the inclusion of more accelerators into each COPA FPGA; these additional accelerators may include multiple instances of the MPC core operations or additional functionality for High Performance Computing applications such as collectives. With the inclusion of a single MPC accelerator, Figure \ref{fig:MPC_Throughput} shows how much data is available for communication based on the input length of the lookaside accelerator source data. The pipeline implementation of the accelerator allows for data to be processed and ready for communication every cycle, after an initial startup delay accessing host memory. Using a single accelerator and batching multiplication operations over a stream of source data, the accelerator performs enough computation to saturate a traditional 10Gb/s link. These results are similar to past implementations \cite{Wolfe20, Patel20} and show that integration with the COPA system is beneficial to improve the total throughput possible with these hardware implemented MPC operations. Examining the throughput of large batches of multiplication operations, Figure \ref{fig:MPC_Throughput} shows a single accelerator performing the basic algorithm (without abort) can saturate a 17.5Gb/s connection, while the inclusion of additional malicious security for abort requires larger than 26.3Gb/s connection to avoid saturation. We can therefore include up to 6 MPC accelerators without abort, or 4 MPC accelerators with abort, to saturate the COPA network. In addition to the communication improvements, the COPA system enables a set-and-forget method for acceleration and communication which frees up each host processor to perform additional non-MPC functions. Queuing operations into the lookaside accelerator, with knowledge that data will be shared appropriately, allows for final completion of each operation without the need to block the process on each step. \section{Conclusion} The COPA framework enables hardware acceleration and improved network functions for, potentially, many different applications. We show how an MPC implementation fits into the COPA framework and enables improvements to both computation and communication by using the lookaside accelerator features and improved network data transfer. In addition, MPC running on the COPA system enables the use of the an open-source software library, OFI, as an alternative to specialized MPC software used by each party member. We aim to increase the size of our tests with additional MPC algorithms aiming for two party, three party, and four party computation alternatives. We also aim to enable more accelerator options to improve on secure joint computation through the means of memory operations such as scatter/gather. This will enable additional improvements to both MPC throughput and network communication. Our future work will include a full end-to-end method of MPC using the COPA hardware/software infrastructure for cloud/data centers, MPC-as-a-Service. Fully utilizing the COPA features, we aim to create a fully autonomous MPC system allowing for any host to perform trusted operations on the collective data. With COPA remote invocation of target accelerator nodes, we aim to enable complete MPC applications to run with only a single host triggering the operation and each additional party member acting like a headless target node. By using all of these features MPC-as-a-Service can be a viable method of trusted secure joint computation with a minimal barrier to entry. \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:29:11', 'yymm': '2204', 'arxiv_id': '2204.04816', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04816'}
arxiv
\section{Introduction} \label{sec:intro} Causal models based on directed acyclic graphs (DAGs), such as recursive structural equation models \cite{GallesPearl1998, Halpern2000} and causal Bayesian networks \cite{SGS2000, pearl2009causality}, have been vigorously studied and widely applied as powerful tools for causal reasoning. However, from a logical point of view, the syntax underlying such causal models is usually left implicit or even obscure in the literature. This lacuna is fixed in recent category-theoretic work on the subject \cite{Fong:thesis, jacobs2019causal}, where the distinction between syntax and semantics is made clear in the style of F.W. Lawvere's functorial semantics \cite{lawvere1963functorial}. Specifically, the syntax is provided by a monoidal category of a certain kind induced by a DAG, and a distinguished class of morphisms therein can be viewed as {\it syntactic} causal effects, which may then be interpreted in various ways. Causal Bayesian networks, for example, interpret a causal effect of this kind with a stochastic matrix that represents probability distributions over the outcome-variables resulting from interventions on the treatment-variables. In this light, a causal Bayesian network is a functor---a structure-preserving mapping---from the syntax category to a category whose morphisms are stochastic matrices. As another example (and a degenerate case of causal Bayesian networks), deterministic structural equation models interpret a causal effect of this kind as a function that represents how the values of the outcome-variables depend on those of the treatment-variables. Thus, a (recursive) deterministic structural equation model may be viewed as a functor from the syntax category to a category whose morphisms are functions. In this paper we build on this category-theoretic framework and study some important concepts in DAG-based causal reasoning from a syntactic and more abstract perspective. In particular, we work with the categories defined in \cite{Fong:thesis}, called {\it causal theories}, with an extra constraint to make them Markov categories in the sense of \cite{fritz2020synthetic}. We study the morphisms in that category that correspond to what we call syntactic causal effects, using the graphical language of string diagrams as vehicles for our arguments. One of our main results concerns the decomposition or disintegration of causal effect morphisms, or in the terminology of \cite{fritz2020synthetic}, the existence of a conditional for a causal effect morphism. Roughly, this refers to the property that the causal effect of $x$ on $y$ and $z$ can be decomposed into the causal effect of $x$ on $y$ followed by that of $x$ and $y$ on $z$. We derive a condition that is sufficient and necessary for decomposability in a causal theory. Interestingly, the condition is precisely the condition in a specialized version of the second rule of Judea Pearl's do-calculus \cite{pearl2009causality}. This agreement is of course not a coincidence and has, we submit, several instructive implications. The other rules of the do-calculus have more straightforward counterparts in terms of causal effect morphisms, and the upshot is a generic do-calculus at the syntactic level. This generic calculus, we argue, captures the ``causal core'' of reasoning about interventions, and is automatically inherited in all causal models, including but not limited to the popular probabilistic ones. In particular, it induces a simpler and specialized version of Pearl's do-calculus in the context of causal Bayesian networks. Importantly, we show that given the probability calculus, the simpler and specialized version entails the full version of the do-calculus, corroborating our contention that the generic do-calculus corresponds to the purely causal component of the well-known probabilistic do-calculus. The rest of the paper is organized as follows. In Section \ref{sec:cat}, we introduce the basics of category theory and the intuitive language of string diagrams, leading to the notion of a Markov category. In Section \ref{sec:cau}, we define causal theories as an abstraction of causal Bayesian networks and as free Markov categories, and highlight a class of morphisms constructed in \cite{Fong:thesis}, which we call ``causal effect morphisms''. Section \ref{sec:effect} presents some results about causal effect morphisms, which yield a more abstract and syntactic counterpart to Pearl's do-calculus. We show in Section \ref{sec:cal} that the syntactic do-calculus entails a simpler and specialized version of probabilistic do-calculus, and that, despite its simplicity, the specialized version is actually as strong as the full version. \section{Markov categories} \label{sec:cat} For the sake of space and readability, we will only describe the notions of category theory that are essential for understanding this paper, and introduce the axioms for a Markov category using the language of string diagrams. For readers interested in learning more about category theory and string diagrams, we recommend the canonical treatises \cite{MacLane1998} and \cite{selinger2010survey}, among other excellent textbooks and surveys. A category $\cat C$ consists of two types of entities: \memph{objects} $A$, $B$, $C$, $\ldots$ and \memph{arrows} $f$, $g$, $h$, $\ldots$, subject to the following three rules: \begin{itemize} \item For each arrow $f$ there are given two objects $\dom(f)$ and $\cod(f)$, called the \memph{domain} and the \memph{codomain} of $f$. We usually write $f :A \longrightarrow B$ to indicate that $A = \dom(f)$ and $B = \cod(f)$. \item Given two arrows $f : A \longrightarrow B$ and $g: B \longrightarrow C$, that is, $\cod(f) = \dom(g)$, there is a third arrow $g \circ f : A \longrightarrow C$, called the \memph{composition} of $f$ and $g$. \item For each object $A$ there is an arrow $1_A : A \longrightarrow A$, called the \memph{identity} or \memph{unit} arrow of $A$. \end{itemize} In addition, the obvious \memph{unitality} and \memph{associativity} laws hold for compositions: for all $f : A \longrightarrow B$, $g : B \longrightarrow C$, and $h : C \longrightarrow D$, \[ 1_B \circ f = f, \quad f \circ 1_A = f, \quad (h \circ g) \circ f = h \circ (g \circ f). \] An arrow in category theory is also called a \memph{morphism} or a \memph{map}. Here is a more formal definition: \begin{defn}\label{cat:def:2} Let $\cat C$ be a quadruple $(\cat C_0, \cat C_1, \dom, \cod)$, where $\cat C_0$ is referred to as a class of \memph{objects}, $\cat C_1$ is referred to as a class of \memph{morphisms}, and $\dom : \cat C_1 \longrightarrow \cat C_0$, $\cod : \cat C_1 \longrightarrow \cat C_0$ are functions. A morphism $f$ in $\cat C_1$ is usually written as $f : A \longrightarrow B$ with $\dom(f) = A$ and $\cod(f) = B$. For each pair of objects $A$, $B$ in $\cat C_0$, the class of all morphisms $f$ with $\dom(f) = A$ and $\cod(f) = B$ is denoted by $\hom_{\cat C}(A,B)$. Let $\cat C_2 = \set{(f, g) \in \cat C_1 \times \cat C_1 \given \cod(f) = \dom (g)}$. We say that $\cat C$ is a \memph{category} if it also comes with a morphism $1_A : A \longrightarrow A$ for every $A \in \cat C_0$, called the \memph{identity morphism} of $A$, and a function $\circ : \cat C_2 \longrightarrow \cat C_1$, called \memph{composition}, subject to the associativity and unitality laws given above. \end{defn} Often we just write $x \in \cat C$ and let the context determine whether $x$ is an object or a morphism. A paradigmatic example of a category is the category \cat{Set}, containing sets as objects and functions as morphisms. In this category, the composition of morphisms is just the composition of functions and for each object $A$, the identity morphism is just the identity function. It is helpful to think of a morphism as an abstract function, or a box with input wires and output wires, as in the graphical language of string diagrams. The four rudiments of a category are depicted in such a graphical language as follows: \begin{equation}\label{free:graph:def} \begin{tikzpicture}[xscale = .5, yscale = .5, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (42) at (2.6, 2.5) {$A$}; \node [style=none] (110) at (10.275, 2.15) {}; \node [style=none] (113) at (10.275, 0.825) {}; \node [style=small box] (156) at (10.275, 2.5) {$f$}; \node [style=none] (157) at (10.275, 4.3) {}; \node [style=none] (158) at (10.275, 2.925) {}; \node [style=small box] (166) at (24.475, 1.75) {$f$}; \node [style=none] (167) at (24.475, 3.65) {}; \node [style=none] (168) at (24.475, 2.175) {}; \node [style=none] (192) at (3.125, 3.7) {}; \node [style=none] (193) at (3.125, 1.3) {}; \node [style=none] (194) at (3.125, -0.5) {object $A$}; \node [style=none] (195) at (9.725, 1.2) {$A$}; \node [style=none] (196) at (9.725, 3.8) {$B$}; \node [style=none, label={[align=center]center:morphism \\$f : A \longrightarrow B$}] (197) at (10.275, -0.75) {}; \node [style=none] (198) at (17.3, 2.5) {$A$}; \node [style=none] (199) at (17.875, 3.7) {}; \node [style=none] (200) at (17.875, 1.3) {}; \node [style=none] (201) at (17.875, -0.5) {identity $1_A$}; \node [style=small box] (203) at (24.475, 4) {$g$}; \node [style=none] (204) at (24.475, 5.65) {}; \node [style=none] (205) at (24.475, 4.425) {}; \node [style=none] (206) at (24.475, 1.4) {}; \node [style=none] (207) at (24.475, 0.175) {}; \node [style=none, label={[align=center]center:composition \\ $g \circ f$}] (208) at (24.475, -1.3) {}; \node [style=none] (209) at (23.975, 0.5) {$A$}; \node [style=none] (210) at (23.975, 2.925) {$B$}; \node [style=none] (211) at (23.975, 5.05) {$C$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (110.center) to (113.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (167.center) to (168.center); \draw [style=wire] (192.center) to (193.center); \draw [style=wire] (199.center) to (200.center); \draw [style=wire] (204.center) to (205.center); \draw [style=wire] (206.center) to (207.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} Note that string diagrams are parsed in the lower-left to upper-right order. \begin{rem}\label{intro:string} A string diagram is a topological graph in which every edge is labelled with an object and every vertex with a morphism \cite{selinger2010survey}. Object labels such as $A$, $B$ are usually omitted except when they are needed for clarity or emphasis. A labelled vertex is also called a \memph{node}, and is often drawn as a box such as $\begin{tikzpicture}[xscale = 1, yscale = 1, baseline={([yshift=7pt]current bounding box.south)}] \begin{pgfonlayer}{nodelayer} \node [style=small box] (0) at (0, 0) {$f$}; \end{pgfonlayer} \end{tikzpicture}$ for readability. Just as in the usual symbolic formalism, a morphism $f$ may be represented by many string diagrams. \end{rem} Categories may serve as objects in a ``higher'' category, and the morphisms between categories are known as functors: \begin{defn}\label{def:func} Let $\cat C$, $\cat D$ be categories and $F$ a pair of mappings $F_0 : \cat C_0 \longrightarrow \cat D_0$, $F_1 : \cat C_1 \longrightarrow \cat D_1$. Then $F$ is a \memph{functor}, written as $F : \cat C \longrightarrow \cat D$, if the following three conditions, corresponding to the three conditions for a category, are satisfied: \begin{itemize} \item $F$ preserves domains and codomains, that is, $F_1(f: A \longrightarrow B)$ is a morphism $F_0(A) \longrightarrow F_0(B)$ for all morphisms $f \in \cat C_1$. \item $F$ preserves compositions, that is, $F_1(g \circ f) = F_1(g) \circ F_1(f)$ for all compositions $g \circ f \in \cat C_1$. \item $F$ preserves identities, that is, $F_1(1_A) = 1_{F_0(A)}$ for all objects $A \in \cat C_0$. \end{itemize} \end{defn} Compositions of functors may be defined using composition of mappings. Then it is routine to check that categories and functors form a ``higher'' category. We now introduce more structures needed for our purpose. Start with the (strict) monoidal structure: \begin{defn}\label{defn:moncat} A \memph{strict monoidal category} is a category $\cat C$ equipped with a functor $\otimes : \cat C \times \cat C \to \cat C$, called the \memph{monoidal product}, and a distinguished object $\mathbf{I}$, called the \memph{monoidal unit} (of the monoidal product), that satisfy associativity and unitality: \begin{equation}\label{monoidal:def} (A\otimes B)\otimes C = A\otimes (B\otimes C), \quad \mathbf{I}\otimes A = A = A\otimes \mathbf{I} \end{equation} \end{defn} Many commonly encountered monoidal categories are actually not strict because equation \ref{monoidal:def} holds only ``up to isomorphism.'' For example, the category \cat{Set} has an obvious monoidal product, which is just the Cartesian product (of sets and of functions). The monoidal unit is any singleton set, but unitality is a matter of isomorphism rather than strict identity. The formal definition of a (possibly non-strict) monoidal category is rather more complex and requires the notion of a natural transformation, which we omit to keep things simple. The monoidal categories we will focus on in this paper are strict.\footnote{By S. Mac Lane's coherence theorem \cite[Theorem XI.3.1]{MacLane1998}, every monoidal category is monoidally equivalent to a strict monoidal category. So there is a sense in which we can treat monoidal categories as if they are all strict (even though they are not). See \cite{selinger2010survey} for more on how this is justified.} Since the monoidal product is a functor, it applies to both objects and morphisms in the category. Thus the graphical syntax in (\ref{free:graph:def}) is extended for monoidal categories as follows: \begin{equation}\label{mon:free:graph:def} \begin{tikzpicture}[xscale = .55, yscale = .5, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (42) at (1.6, 2.5) {$A$}; \node [style=none] (212) at (3.1, 2.5) {$B$}; \node [style=none] (110) at (16.9, 2.15) {}; \node [style=none] (113) at (16.9, 0.825) {}; \node [style=wide small box] (156) at (17.525, 2.5) {$f$}; \node [style=none] (157) at (16.9, 4.3) {}; \node [style=none] (158) at (16.9, 2.925) {}; \node [style=small box] (166) at (24.475, 2.475) {$f$}; \node [style=none] (167) at (24.475, 4.125) {}; \node [style=none] (168) at (24.475, 2.9) {}; \node [style=none] (192) at (2.125, 3.7) {}; \node [style=none] (193) at (2.125, 1.3) {}; \node [style=none, label={[align=center]center:monoidal product\\of objects}] (194) at (2.875, -0.5) {}; \node [style=none] (195) at (16.35, 1.2) {$A_1$}; \node [style=none] (196) at (16.35, 3.8) {$B_1$}; \node [style=none, label={[align=center]center:monoidal unit\\(empty diagram)}] (197) at (10.275, -0.475) {}; \node [style=none, label={[align=center]center:morphism\\$f : \bigotimes_i A_i \longrightarrow \bigotimes_j B_j$}] (201) at (17.625, -1) {}; \node [style=none] (206) at (24.475, 2.125) {}; \node [style=none] (207) at (24.475, 0.9) {}; \node [style=none, label={[align=center]center:monoidal product\\of morphisms}] (208) at (25.275, -1) {}; \node [style=none] (209) at (23.975, 1.225) {$A$}; \node [style=none] (210) at (23.975, 3.55) {$B$}; \node [style=none] (213) at (3.625, 3.7) {}; \node [style=none] (214) at (3.625, 1.3) {}; \node [style=none] (215) at (18.15, 2.15) {}; \node [style=none] (216) at (18.15, 0.825) {}; \node [style=none] (217) at (18.15, 4.3) {}; \node [style=none] (218) at (18.15, 2.925) {}; \node [style=none] (219) at (18.75, 1.2) {$A_n$}; \node [style=none] (220) at (18.75, 3.8) {$B_m$}; \node [style=none] (221) at (17.6, 1.2) {$\cdots$}; \node [style=none] (222) at (17.6, 3.8) {$\cdots$}; \node [style=small box] (224) at (25.975, 2.5) {$g$}; \node [style=none] (225) at (25.975, 4.15) {}; \node [style=none] (226) at (25.975, 2.925) {}; \node [style=none] (227) at (25.475, 3.55) {$D$}; \node [style=none] (228) at (25.975, 2.125) {}; \node [style=none] (229) at (25.975, 0.9) {}; \node [style=none] (230) at (25.475, 1.225) {$C$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (110.center) to (113.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (167.center) to (168.center); \draw [style=wire] (192.center) to (193.center); \draw [style=wire] (206.center) to (207.center); \draw [style=wire] (213.center) to (214.center); \draw [style=wire] (215.center) to (216.center); \draw [style=wire] (217.center) to (218.center); \draw [style=wire] (225.center) to (226.center); \draw [style=wire] (228.center) to (229.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \begin{nota} We denote by $A^n$ the monoidal product of $n$ copies of an object $A$ itself; this includes the empty product $A^0 = \mathbf{I}$. When an object of the form $A_1 \otimes \ldots \otimes A_k$ is introduced in the discussion, the indices are in general meant to indicate the ordering in which the monoidal product is taken. \end{nota} For the present purpose, the monoidal structure is especially useful because it can be used to express causal processes or mechanisms that run in parallel, as is visualized in (\ref{mon:free:graph:def}), whereas composition is used to express those that run in sequence. A \memph{symmetric} monoidal category is a monoidal category with natural isomorphisms $\sigma_{AB} : A \otimes B \cong B \otimes A$ that satisfy certain coherence conditions (the details do not matter for the present purpose). Graphically, a symmetry isomorphism is depicted as a crossing: \begin{equation}\label{sym:graph} \begin{tikzpicture}[xscale = .5, yscale = .4, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (110) at (-2.475, 4.6) {}; \node [style=none] (112) at (-2.475, 3.775) {}; \node [style=none] (139) at (-2.475, 6.625) {}; \node [style=none] (141) at (-2.475, 5.775) {}; \node [style=none] (246) at (-0.775, 4.55) {}; \node [style=none] (247) at (-0.775, 3.775) {}; \node [style=none] (249) at (-0.775, 6.625) {}; \node [style=none] (250) at (-0.775, 5.775) {}; \node [style=none] (254) at (-0.25, 4.125) {$B$}; \node [style=none] (255) at (-3, 4.125) {$A$}; \node [style=none] (256) at (-0.25, 6.25) {$A$}; \node [style=none] (257) at (-3, 6.25) {$B$}; \node [style=none, label={[align=center]center:symmetry $\sigma_{AB}$}] (258) at (-1.5, 2.8) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (112.center) to (110.center); \draw [style=wire] (141.center) to (139.center); \draw [style=wire] (247.center) to (246.center); \draw [style=wire] (250.center) to (249.center); \draw [style=wire, in=90, out=-90, looseness=0.75] (250.center) to (110.center); \draw [style=wire, in=90, out=-90, looseness=0.75] (141.center) to (246.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} Finally, we can define a Markov category, following the lead of \cite{fritz2020synthetic}. \begin{defn} A \memph{Markov category} is a symmetric monoidal category such that for each object $A$ in $\cat C$ there are distinguished morphisms $\delta_A : A \longrightarrow A \otimes A$, called the \memph{duplicate} on $A$, and $\epsilon_A : A \longrightarrow \mathbf{I}$, called the \memph{discard} on $A$, that satisfy the following: \begin{equation}\label{mon:law} \begin{tikzpicture}[xscale = .65, yscale = .6, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (139) at (-1.625, 5.45) {}; \node [style=none] (141) at (-1.625, 5.325) {}; \node [style=none] (144) at (-2.1, 6.125) {}; \node [style=none] (146) at (-2.1, 5.825) {}; \node [style=none] (246) at (-0.925, 4.8) {}; \node [style=none] (247) at (-0.925, 4.425) {}; \node [style=none] (249) at (-0.2, 6.1) {}; \node [style=none] (250) at (-0.2, 5.325) {}; \node [style=none] (251) at (-1.15, 6.125) {}; \node [style=none] (252) at (-1.15, 5.825) {}; \node [style=none] (281) at (1.15, 5.175) {$=$}; \node [style=none] (298) at (3.85, 5.45) {}; \node [style=none] (299) at (3.85, 5.325) {}; \node [style=none] (300) at (4.325, 6.125) {}; \node [style=none] (301) at (4.325, 5.825) {}; \node [style=none] (302) at (3.15, 4.8) {}; \node [style=none] (303) at (3.15, 4.425) {}; \node [style=none] (304) at (2.425, 6.1) {}; \node [style=none] (305) at (2.425, 5.325) {}; \node [style=none] (306) at (3.375, 6.125) {}; \node [style=none] (307) at (3.375, 5.825) {}; \node [style=none] (314) at (9.6, 5.175) {$=$}; \node [style=none] (315) at (11.875, 5.175) {$=$}; \node [style=none] (316) at (10.75, 6.1) {}; \node [style=none] (317) at (10.75, 4.425) {}; \node [style=none] (318) at (13.05, 6) {$\bullet$}; \node [style=none] (319) at (13.05, 5.575) {}; \node [style=none] (320) at (13.75, 5.05) {}; \node [style=none] (321) at (13.75, 4.425) {}; \node [style=none] (322) at (14.475, 6.1) {}; \node [style=none] (323) at (14.475, 5.575) {}; \node [style=none] (308) at (15.95, 6.25) {}; \node [style=none] (309) at (17.375, 5.2) {}; \node [style=none] (310) at (16.675, 4.65) {}; \node [style=none] (311) at (16.675, 4.275) {}; \node [style=none] (312) at (17.375, 6.25) {}; \node [style=none] (313) at (15.95, 5.2) {}; \node [style=none] (324) at (8.4, 6) {$\bullet$}; \node [style=none] (325) at (8.4, 5.575) {}; \node [style=none] (326) at (7.7, 5.05) {}; \node [style=none] (327) at (7.7, 4.425) {}; \node [style=none] (328) at (6.975, 6.1) {}; \node [style=none] (329) at (6.975, 5.575) {}; \node [style=none] (330) at (20.125, 6.1) {}; \node [style=none] (331) at (20.125, 5.575) {}; \node [style=none] (332) at (20.825, 5.05) {}; \node [style=none] (333) at (20.825, 4.425) {}; \node [style=none] (334) at (21.55, 6.1) {}; \node [style=none] (335) at (21.55, 5.575) {}; \node [style=none] (336) at (18.8, 5.175) {$=$}; \node [style=none, label={[align=center]center: coassociativity\\$(\delta_A \otimes 1_A) \circ \delta_A = (1_A \otimes \delta_A) \circ \delta_A$}] (337) at (1.25, 3.175) {}; \node [style=none, label={[align=center]center:counitality\\$(1_A \otimes \epsilon_A) \circ \delta_A = 1_A = (\epsilon_A \otimes 1_A) \circ \delta_n$}] (338) at (10.95, 3.175) {}; \node [style=none, label={[align=center]center:cocommutativity\\$\sigma_{AA} \circ \delta_A = \delta_A$}] (339) at (18.8, 3.175) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (141.center) to (139.center); \draw [style=wire] (146.center) to (144.center); \draw [style=wire] (247.center) to (246.center); \draw [style=wire] (250.center) to (249.center); \draw [style=wire] (252.center) to (251.center); \draw [style=wire, bend right=90, looseness=1.25] (141.center) to (250.center); \draw [style=wire, bend right=90, looseness=1.25] (146.center) to (252.center); \draw [style=wire] (299.center) to (298.center); \draw [style=wire] (301.center) to (300.center); \draw [style=wire] (303.center) to (302.center); \draw [style=wire] (305.center) to (304.center); \draw [style=wire] (307.center) to (306.center); \draw [style=wire, bend left=90, looseness=1.25] (299.center) to (305.center); \draw [style=wire, bend left=90, looseness=1.25] (301.center) to (307.center); \draw [style=wire] (311.center) to (310.center); \draw [style=wire] (317.center) to (316.center); \draw [style=wire] (319.center) to (318.center); \draw [style=wire] (321.center) to (320.center); \draw [style=wire] (323.center) to (322.center); \draw [style=wire, bend right=90, looseness=1.25] (319.center) to (323.center); \draw [style=wire, in=-90, out=90] (309.center) to (308.center); \draw [style=wire] (311.center) to (310.center); \draw [style=wire, in=-90, out=90, looseness=0.75] (313.center) to (312.center); \draw [style=wire, bend left=90, looseness=1.25] (309.center) to (313.center); \draw [style=wire] (325.center) to (324.center); \draw [style=wire] (327.center) to (326.center); \draw [style=wire] (329.center) to (328.center); \draw [style=wire, bend left=90, looseness=1.25] (325.center) to (329.center); \draw [style=wire] (331.center) to (330.center); \draw [style=wire] (333.center) to (332.center); \draw [style=wire] (335.center) to (334.center); \draw [style=wire, bend right=90, looseness=1.25] (331.center) to (335.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \begin{equation}\label{fins:frob} \begin{tikzpicture}[xscale = .55, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (42) at (7.725, -0.75) {$=$}; \node [style=none] (108) at (4.275, 0.4) {}; \node [style=none] (110) at (6.275, 0.4) {}; \node [style=none] (111) at (5.275, -1.825) {}; \node [style=none] (112) at (4.275, -0.35) {}; \node [style=none] (113) at (6.275, -0.325) {}; \node [style=none] (114) at (5.275, -1.075) {}; \node [style=none] (117) at (9.225, 0.65) {}; \node [style=none] (118) at (12.125, 0.65) {}; \node [style=none] (119) at (10.05, -1.825) {}; \node [style=none] (120) at (9.225, -0.625) {}; \node [style=none] (121) at (10.85, -0.6) {}; \node [style=none] (122) at (10.05, -1.225) {}; \node [style=none] (124) at (10.825, 0.65) {}; \node [style=none] (125) at (13.825, 0.65) {}; \node [style=none] (126) at (12.95, -1.825) {}; \node [style=none] (127) at (12.125, -0.625) {}; \node [style=none] (128) at (13.825, -0.6) {}; \node [style=none] (129) at (12.95, -1.25) {}; \node [style=none] (131) at (19.65, -0.75) {$=$}; \node [style=none] (134) at (18.2, -1.525) {}; \node [style=none] (137) at (18.2, -0.05) {$\bullet$}; \node [style=none] (138) at (20.25, -3) {$\epsilon_{A \otimes B} = \epsilon_{A} \otimes \epsilon_{B}$}; \node [style=none] (145) at (21.025, -1.525) {}; \node [style=none] (146) at (21.025, -0.05) {$\bullet$}; \node [style=none] (148) at (22.275, -1.525) {}; \node [style=none] (149) at (22.275, -0.05) {$\bullet$}; \node [style=none] (151) at (9.25, -3) {$\delta_{A \otimes B} = (1_A \otimes \sigma_{BA} \otimes 1_B) \circ (\delta_{A} \otimes \delta_B)$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire, bend right=90, looseness=1.25] (112.center) to (113.center); \draw [style=wire] (108.center) to (112.center); \draw [style=wire] (110.center) to (113.center); \draw [style=wire] (111.center) to (114.center); \draw [style=wire, bend right=90, looseness=1.25] (120.center) to (121.center); \draw [style=wire] (117.center) to (120.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (118.center) to (121.center); \draw [style=wire] (119.center) to (122.center); \draw [style=wire, bend right=90, looseness=1.25] (127.center) to (128.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (124.center) to (127.center); \draw [style=wire] (125.center) to (128.center); \draw [style=wire] (126.center) to (129.center); \draw [style=wire] (134.center) to (137.center); \draw [style=wire] (145.center) to (146.center); \draw [style=wire] (148.center) to (149.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \begin{equation}\label{discar:nat} \begin{tikzpicture}[xscale = .55, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (200) at (19.4, 1.75) {$=$}; \node [style=none] (202) at (17.45, 1.525) {}; \node [style=none] (205) at (17.45, 0.6) {}; \node [style=small box] (207) at (17.45, 1.875) {$f$}; \node [style=none] (208) at (17.45, 3.225) {$\bullet$}; \node [style=none] (209) at (17.45, 2.3) {}; \node [style=none] (210) at (21.15, 2.725) {$\bullet$}; \node [style=none] (211) at (21.15, 1.1) {}; \node [style=none] (212) at (19.4, -0.75) {$\epsilon_B \circ f = \epsilon_A$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (202.center) to (205.center); \draw [style=wire] (208.center) to (209.center); \draw [style=wire] (210.center) to (211.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \end{defn} \begin{nota} Recall that our convention is to draw a string diagram in the lower-left to upper-right direction. So, above, the duplicate $\delta_A : A \longrightarrow A \otimes A$ is depicted as an upward fork $\begin{tikzpicture}[xscale = .3, yscale = .3, baseline={([yshift=5pt]current bounding box.south)}] \begin{pgfonlayer}{nodelayer} \node [style=none] (324) at (8.4, 6.1) {}; \node [style=none] (325) at (8.4, 5.575) {}; \node [style=none] (326) at (7.7, 5.05) {}; \node [style=none] (327) at (7.7, 4.425) {}; \node [style=none] (328) at (6.975, 6.1) {}; \node [style=none] (329) at (6.975, 5.575) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (325.center) to (324.center); \draw [style=wire] (327.center) to (326.center); \draw [style=wire] (329.center) to (328.center); \draw [style=wire, bend left=90, looseness=1.25] (325.center) to (329.center); \end{pgfonlayer} \end{tikzpicture}$ and the discard $\epsilon_A : A \longrightarrow \mathbf{I}$ an upward dead-end $\begin{tikzpicture}[xscale = .3, yscale = .3, baseline={([yshift=5pt]current bounding box.south)}] \begin{pgfonlayer}{nodelayer} \node [style=none] (326) at (7.7, 5.8) {$\bullet$}; \node [style=none] (327) at (7.7, 4.425) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (327.center) to (326.center); \end{pgfonlayer} \end{tikzpicture}$. \end{nota} Thus a Markov category is endowed with both a symmetric monoidal structure and additional duplicate morphisms and discard morphisms that satisfy (\ref{mon:law})-(\ref{discar:nat}). For our purpose, duplicate morphisms are needed mainly to express the same input entering several causal processes, and discard morphisms are needed to express ignoring or marginalizing over some outcomes of a causal process. The equations in (\ref{mon:law}) are axioms for the so-called \memph{cocommutative monoidal comonoid}, and the equations in (\ref{fins:frob}) express the condition that duplicates and discards respect the monoidal product. All these axioms are fairly intuitive. The equation in (\ref{discar:nat}) says roughly that discarding the output of a morphism is identical to discarding the input in the first place. This condition is not explicitly imposed in \cite{Fong:thesis} but is actually needed for a main result therein (more on this later). Actually (\ref{discar:nat}) holds automatically if the monoidal unit $\mathbf{I}$ is terminal; conversely, (\ref{discar:nat}), together with the other conditions stipulated above, implies that $\mathbf{I}$ is terminal, and hence $\epsilon_\mathbf{I} = 1_\mathbf{I}$. Also note that $\delta_\mathbf{I} = 1_\mathbf{I}$ in any strict Markov category. See \cite[Remark~2.3]{fritz2020synthetic}. For categories with additional structures, the notion of a functor can be strengthened accordingly. For example, a \memph{(strong) Markov functor} between two Markov categories is a functor that preserves the relevant structures (see \cite[Definition~10.14]{fritz2020synthetic} for details.) \section{Causal theories and effect morphisms} \label{sec:cau} In this section we describe the central object of study in this paper, a syntax category for DAG-based causal models defined in \cite{Fong:thesis}, called a causal theory. The framework is an abstraction of causal Bayesian networks, so we first review the latter in \ref{subsec:cbn}, and then introduce causal theories as free Markov categories in \ref{subsec:cau}. In \ref{subsec:effect} we highlight a class of morphisms constructed in \cite{Fong:thesis}, which we refer to as causal effect morphisms. Our main results are concerned with these morphisms. \subsection{Causal Bayesian networks} \label{subsec:cbn} A \memph{directed graph} is a quadruple $G = (V, A, s, t)$, where $V$, $A$ are sets and $s : A \longrightarrow V$, $t: A \longrightarrow V$ are functions. Elements in $V$ are called \memph{vertices} of $G$ and those in $A$ are \memph{directed edges} or \memph{arrows} of $G$. For $a\in A$, $s(a)$ is the \memph{source} of $a$ and $t(a)$ the \memph{target} of $a$. $G$ is \memph{finite} if both $V$ and $A$ are. It is \memph{simple} if, for all $a, a'\in A$, we have $a=a'$ whenever $s(a)=s(a')$ and $t(a)=t(a')$. We consider only finite simple graphs in this paper. A sequence of distinct arrows $a_1, \ldots, a_n \in A(G)$ is a \memph{directed path}, starting from $s(a_1)$ and ending at $t(a_n)$, if $s(a_{i+1}) = t(a_i)$ for $1 \leq i < n$. It is a \memph{cycle} if, in addition, $s(a_1) = t(a_n)$. $G$ is \memph{acyclic} if it contains no cycle. For $x, y\in V(G)$, $x$ is called a \memph{parent} of $y$ and $y$ a \memph{child} of $x$ if for some $a\in A(G)$, $s(a)=x$ and $t(a)=y$. A \memph{Bayesian network} (BN) over a set of (categorical) random variables $\mathbf{V}$ consists of a triple $(G, P, \upsilon)$, where $G$ is a directed acyclic graph (DAG), $P$ is a joint probability law of $\mathbf{V}$, and $\upsilon: V(G)\rightarrow \mathbf{V}$ is a bijection between the vertices of $G$ and the random variables. Following common practice, we will leave the bijection $\upsilon$ implicit and simply identify $V(G)$ with $\mathbf{V}$, and call $G$ a DAG over $\mathbf{V}$. The defining condition of a BN is that $G$ and $P$ satisfy a Markov condition, which requires that $P$ can be factorized according to $G$ as follows: \begin{equation} \label{fac:pre} P(\mathbf{V}) = \prod_{X\in \mathbf{V}}P(X | \pa_{G}(X)), \end{equation} where $\pa_G(X)$ denotes the set of parents of $X$ in $G$. When $G$ is sufficiently sparse, the factorization enables efficient computations of various probabilities entailed by the joint probability law, which makes the BN useful for probabilistic reasoning \cite{Pearl1988}. The DAG in a BN usually lends itself to a causal interpretation, as a representation of the qualitative causal structure. With this causal reading, the BN framework can be extended to handle reasoning about effects of interventions \cite{SGS2000, pearl2009causality}. Specifically, a \memph{causal Bayesian network} (CBN) over $\mathbf{V}$ does not represent just one joint probability law, but a number of \memph{interventional} probability distributions. The standard setup is that for every subset $\mathbf{T}\subseteq \mathbf{V}$ and every possible value configuration $\mathbf{t}$ for $\mathbf{T}$, there is a probability distribution resulting from an (exogenous) intervention that forces $\mathbf{T}$ to take value $\mathbf{t}$. Such an interventional distribution, denoted as $P(\mathbf{V} | do(\mathbf{T}=\mathbf{t}))$ using Pearl's (\cite{pearl2009causality}) do-operator, is assumed to be equal to a truncated factorization: \begin{equation} \label{fac:post} P(\mathbf{V} | do(\mathbf{T}=\mathbf{t})) = \left\{ \begin{array}{ll} \prod_{X\in \mathbf{V}\backslash \mathbf{T}}P(X | \pa_G(X)) & \textrm{for values of } \mathbf{V} \textrm{ consistent with } \mathbf{T} = \mathbf{t}, \\ 0 & \textrm{for values of } \mathbf{V} \textrm{ inconsistent with } \mathbf{T} = \mathbf{t}. \end{array}\right. \end{equation} As a special case, when $\mathbf{T}=\emptyset$, we obtain the factorization (\ref{fac:pre}) of the \memph{pre-intervention} distribution. Equation (\ref{fac:post}) can be viewed as the defining axiom for the CBN, sometimes referred to as the \memph{intervention principle} \cite{zhang2011intervention}. Note two key ideas in this formulation of a CBN: (1) for each $X\in \mathbf{V}$, $P(X|\pa_G(X))$ encodes a \memph{modular} causal process or mechanism (when $\pa_G(X)=\emptyset$, $P(X)$ is taken to encode an \memph{exogenous} mechanism for $X$), and the whole causal system is composed of these causal modules; (2) an intervention breaks the modules for its target variables but does not affect the other modules (hence the truncated factorization.) Put this way, $P(X|\pa_G(X))$ is a particular, probabilistic model of the causal module; the causal theory, as a syntax category, will express the causal module more abstractly, to which we now turn. \subsection{Causal theories as free Markov categories} \label{subsec:cau} We now follow \cite{Fong:thesis} to define the causal theory induced by a DAG $G = (V, A, s, t)$, a category denoted as $\cat{Cau}(G)$. The objects are given by words over $V$. A \memph{word} over $V$ is a finite sequence of elements of $V$, and this also includes the empty word $\emptyset$. Let $W(V)$ be the set of words over $V$. Obviously $W(V)$ is closed under \memph{concatenation}: if $v, w \in W(V)$ then $vw \in W(V)$. So concatenation provides a monoidal product on $W(V)$, with the empty word $\emptyset$ as the unit. \begin{ter}\label{graph:bas} For convenience, elements of $W(V)$ are also referred to as \memph{variables} and those of length $1$, that is, the vertices in $V$, are called \memph{atomic variables}. To ease the notation, we will henceforth denote all variables with lower case letters. Concatenation of two variables $v$, $w$ is also written as $v \otimes w$. An atomic variable $v$ is a \memph{path ancestor} of an atomic variable $w$ if there is a directed path in $G$ from $v$ to $w$, and is an \memph{ancestor} of $w$ if it is a path ancestor of $w$ or is identical with $w$. If no atomic variable occurs more than once in a variable $v$ then $v$ is \memph{singular}; in particular, $\emptyset$ is singular. A singular variable is \memph{maximal} if each atomic variable occurs exactly once in it. Let $v = \bigotimes_{1 \leq i \leq n} v_i$, where each $v_i$ is atomic. Let $v_S = \bigotimes_{i \in S} v_i$ for $S \subseteq \{1, \ldots, n\}$; set $v_\emptyset = \emptyset$. Write $w \subseteq v$, or $w \in v$ if $w$ is atomic, and say that $w$ is a \memph{sub-variable} of $v$ if $w$ is equal to some $v_S$. Let $w = v_S$ and $w' = v_{S'}$. Write $v/w = v_{\{1, \ldots, n\} \smallsetminus S}$, $w \cap w' = v_{S \cap S'}$, $w \smallsetminus w' = v_{S \smallsetminus S'}$, and so on. We say that $w$, $w'$ are \memph{disjoint} if no atomic variable occurs in both of them. Note that being disjoint is not the same as $w \cap w' = \emptyset$, unless $v$ is singular. \end{ter} The morphisms in $\cat{Cau}(G)$ are generated from two distinct classes of generators (basic morphisms), in addition to the identity morphisms: \begin{itemize} \item The first class consists of duplicate and discard morphisms for each atomic variable $v$ \[ \emptyset \toleft^{\epsilon_v} v \to^{\delta_v} vv. \] As mentioned previously, duplicate morphisms are needed to express the same variable entering multiple causal processes, and discard morphisms are needed to express ignoring or marginalizing over some outcomes of a causal process. \item The second class is the heart of the matter and consists of a \memph{causal mechanism} for each atomic variable $v$ \[ \pa(v) \to^{\kappa_v} v, \] where $\pa(v)$ is a chosen singular variable that contains all the parents of $v$, and is more accurately denoted by $\pa_{G}(v)$ if necessary. If $\pa(v) = \emptyset$ then this is just $\emptyset \longrightarrow v$, which shall be called a \memph{exogenous} causal mechanism. \end{itemize} The causal theory $\cat{Cau}(G)$ is the \memph{free} Markov category generated from these two classes of morphisms (and the identity morphisms), by taking all compositions and products as depicted in (\ref{free:graph:def}) and (\ref{mon:free:graph:def}), subject only to the constraints in axioms (\ref{mon:law})-(\ref{discar:nat}). For convenience, set $\kappa_\emptyset = 1_\emptyset$ in $\cau(G)$. A free category is a category generated from certain generators by well-defined operations in a ``no junk no noise'' manner: ``no junk'' in the sense that only those morphisms that can be so generated are in the category, and ``no noise'' in the sense that no relations between morphisms hold unless they are required by the axioms. For precise technical definitions and graphical constructions of free monoidal categories, see \cite{selinger2010survey}. A graphical construction of free Markov categories takes a little more work, which can be found in \cite{YinZhangModularity}. For the present purposes, we need not enter the rather technical details of the constructions, and we will simply use some lemmas from \cite{YinZhangModularity} in some of our proofs. \begin{rem}\label{cau:mech:ind} It may seem that the construction of $\cat{Cau}(G)$ depends on the choice of the singular variables $\pa(v)$ for the causal mechanisms $\kappa_v$. But this is not so: two distinct choices of $\pa(v)$ (and hence of $\kappa_v$) only differ by a permutation of atomic variables in $\pa(v)$ and the resulting free Markov categories are isomorphic. \end{rem} Following \cite{Fong:thesis} (see also \cite{jacobs2019causal}), we take $\cau(G)$ as an categorical embodiment of the syntax for causal reasoning with $G$. It can then be interpreted in any Markov category via strong Markov functors, yielding different kinds of causal models. For example, a CBN based on $G$ is a model of $\cat{Cau}(G)$ in the Markov category $\cat{FinStoch}$, the category containing stochastic matrices as morphisms \cite{ Fong:thesis, fritz2020synthetic, jacobs2019causal}, whereas a deterministic structural equation model based on $G$ is a model of $\cat{Cau}(G)$ in the Markov category $\cat{Set}$. We may also explore less studied causal models, such as possibilistic ones, which are models of $\cat{Cau}(G)$ in the Markov category $\cat{Rel}$, the morphisms in which are relations between sets \cite{Fong:thesis}. \subsection{Causal effect morphisms} \label{subsec:effect} Recall the interventional probability distributions $P(\mathbf{V}|do(\mathbf{T}))$ in the context of CBN, which is often referred to as the causal effect of $\mathbf{T}$ on $\mathbf{V}$ \cite{tian2002general}. We now construct a class of morphisms in a causal theory that is a syntactic counterpart to such causal effects. \begin{nota}\label{uni:pro} In any strict Markov category $\cat M$ such as $\cat{Cau}(G)$, a morphism $A \longrightarrow B$ is called a \memph{multiplier} on the monoidal product $A = \bigotimes_{i} A_i$ if it is generated from the duplicates, discards, symmetries, and identities on the factors $A_i$; so $B$ must be a monoidal product of copies of the factors $A_i$. Moreover, if $(\cat M_0, \otimes, \mathbf{I})$ is a free monoid and $A_1, \ldots, A_n$ are pairwise distinct objects in the alphabet then the multiplier is unique, which is denoted by $\iota_{A \rightarrow B}$. This is due to (\ref{mon:law}) or, more intuitively, coherence of the graphical language for Markov categories (see \cite{YinZhangModularity}). For instance, if $A = A_1 \otimes A_2 \otimes A_3$ and $B = A_1^2 \otimes A_2 \otimes A_1 \otimes A_2$ then $\iota_{A \rightarrow B}$ may be depicted as $\begin{tikzpicture}[xscale = .3, yscale = .3, baseline={([yshift=8pt]current bounding box.south)}] \begin{pgfonlayer}{nodelayer} \node [style=none] (108) at (4.275, 0.15) {}; \node [style=none] (110) at (7.325, 0.15) {}; \node [style=none] (111) at (5.275, -1.575) {}; \node [style=none] (112) at (4.275, -0.1) {}; \node [style=none] (113) at (6.275, -0.65) {}; \node [style=none] (114) at (5.275, -0.95) {}; \node [style=none] (117) at (6.175, 0.15) {}; \node [style=none] (118) at (8.8, 0.15) {}; \node [style=none] (119) at (7.975, -1.575) {}; \node [style=none] (120) at (7.125, -0.6) {}; \node [style=none] (121) at (8.775, -0.35) {}; \node [style=none] (122) at (7.975, -1.075) {}; \node [style=none] (124) at (10.2, -1.55) {}; \node [style=none] (150) at (10.2, 0.025) {$\bullet$}; \node [style=none] (151) at (5.275, 0.15) {}; \node [style=none] (152) at (4.4, -1.5) {$A_1$}; \node [style=none] (153) at (7, -1.55) {$A_2$}; \node [style=none] (154) at (9.2, -1.5) {$A_3$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire, in=-135, out=-90] (112.center) to (113.center); \draw [style=wire] (108.center) to (112.center); \draw [style=wire, in=45, out=-90, looseness=1.25] (110.center) to (113.center); \draw [style=wire, in=270, out=90] (111.center) to (114.center); \draw [style=wire, in=-90, out=-60, looseness=1.25] (120.center) to (121.center); \draw [style=wire, in=120, out=-90] (117.center) to (120.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (118.center) to (121.center); \draw [style=wire] (119.center) to (122.center); \draw [style=wire] (124.center) to (150.center); \draw [style=wire] (114.center) to (151.center); \end{pgfonlayer} \end{tikzpicture}$, where how the duplicates in the trident are arranged, how the edges at the nodes are ordered, how the copies of the same object in the codomain are ordered, and so on, can all be left unspecified. \end{nota} Henceforth we work in $\cau(G)$. \begin{ter}\label{what:dia} By the construction in \cite{YinZhangModularity}, a morphism in $\cau(G)$ is an equivalence class of string diagrams up to surgeries. Therefore, by a string diagram of a morphism, we mean any diagram in the equivalence class in question. \end{ter} \begin{nota} Although, for our purpose, there is no need to distinguish between $wv$ and $vw$ in $\cat{Cau}(G)$, for a technical reason (symmetries in free Markov categories cannot be identities), we cannot work with the quotient of $W(V)$ with respect to the relation $wv=vw$ on words. This is also the reason why the maneuver in Remark~\ref{cau:mech:ind} is needed. To remedy this, we first choose a total ordering on $V$ and denote the corresponding maximal singular variable by $\dot V = 1 \otimes \ldots \otimes n$. All singular variables we shall speak of are sub-variables of $\dot V$. For instance, if $v$, $w$ are singular variables then $v \cup w$ denotes the unique sub-variable of $\dot V$ that contains exactly the atomic variables in $v$, $w$. The results below depend on the chosen ordering only because taking monoidal products of atomic variables does. \end{nota} \begin{defn}\label{gen:condi} For singular variables $t$ and $v$, let $G_{t \rightarrow v}$ be the subgraph of $G$ that consists of all the vertices in $t \cup v$ and all the directed paths that end in $v$ but do not \memph{travel toward} $t$, that is, do not pass through or end in $t$ (starting in $t$ is allowed). Note that, for every $i \in V(G_{t \rightarrow v})$, if $i \notin t$ then its parents in $G$ are all in $G_{t \rightarrow v}$ as well and if $i \in t$ then it has no parents in $G_{t \rightarrow v}$. Construct a string diagram as follows. For each $i \in V(G_{t \rightarrow v})$, let $\bar i$ be the monoidal product of as many copies of $i$ as the number of children of $i$ in $G_{t \rightarrow v}$. Let $\Gamma_i$ be a string diagram of \[ \begin{dcases*} \iota_{i \rightarrow \bar i \otimes i} & if $i \in t \cap v$,\\ \iota_{i \rightarrow \bar i} & if $i \in t \smallsetminus v$,\\ \iota_{i \rightarrow \bar i \otimes i} \circ \kappa_i & if $i \in v \smallsetminus t$,\\ \iota_{i \rightarrow \bar i} \circ \kappa_i & if $i \notin t \cup v$; \end{dcases*} \] note the extra copy of $i$ in the codomain of $\iota_{i \rightarrow \bar i \otimes i}$. According to Notation~\ref{uni:pro}, there is no need to choose orderings for the codomains of the multipliers employed here. For $j \in V(G_{t \rightarrow v})$, let $o_j$ be the number of output wires of $\Gamma_j$ and $p_j$ that of all the input wires labelled by $j$ of all the other $\Gamma_i$. Observe that $o_j = p_j + 1$ if $j \in v$ and $o_j = p_j$ in all other cases. So we may connect the corresponding wires and fuse these \memph{components} $\Gamma_i$ into a single string diagram, denoted by $\Gamma_{[v \| t]}$, whose input wires are labelled by $t$ and the output wires by $v$. The string diagram thus obtained may not be unique up to isomorphisms, but the morphism it represents is, due to coherence of the graphical language for Markov categories. This morphism is referred to as the \memph{causal effect} of $t$ on $v$ and is denoted by $[v \| t] : t \longrightarrow v$, or simply $[v]$ when $t = \emptyset$, which is also called the \memph{exogenous effect} on $v$. \end{defn} This class of morphisms was called ``causal conditionals'' in \cite[\S~4]{Fong:thesis}. We prefer to call them ``causal effects'' here because of their eponymous counterparts in probabilistic causal modeling mentioned earlier, but also because we will study a notion of a conditional in the next section, and $[v \| t]$ may not be a conditional in that sense. \begin{exam}\label{exa:cau:con} For any atomic variable $v$, if $\pa(v) = \emptyset$ then $\kappa_v$ is simply depicted as $\begin{tikzpicture}[xscale = .3, yscale = .3, baseline={([yshift=6pt]current bounding box.south)}] \begin{pgfonlayer}{nodelayer} \node [style=none] (124) at (9.825, -1.55) {$\bullet$}; \node [style=none] (150) at (9.825, 0.025) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (124.center) to (150.center); \end{pgfonlayer} \end{tikzpicture}$. The simplest causal effects are the ones of the form $[v \| \pa(v)]$, which is of course just the causal mechanism $\kappa_v$. Below are some simple examples of the causal effect $[z \| x]$ in $\cau(G)$ for four different graphs with three vertices: \begin{center} \begin{tabular}{ c|c|c|c|c } The graph $G$ & $\bfig \Atriangle(0,0)/<-`->`/<150, 200>[y`x`z; ``] \efig$ & $\bfig \Atriangle(0,0)/->`->`/<150, 200>[y`x`z; ``] \efig$ & $\bfig \Atriangle(0,0)/<-`<-`/<150, 200>[y`x`z; ``] \efig$ & $\bfig \Atriangle(0,0)/->`->`->/<150, 200>[y`x`z; ``] \efig$ \\ \hline The subgraph $G_{x \rightarrow z}$ & $\bfig \Atriangle(0,0)/<-`->`/<150, 200>[y`x`z; ``] \efig$ & $\bfig \Atriangle(0,0)/`->`/<150, 200>[y`x`z; ``] \efig$ & $\bfig \Atriangle(0,0)/``/<150, 200>[`x`z; ``] \efig$ & $\bfig \Atriangle(0,0)/`->`->/<150, 200>[y`x`z; ``] \efig$ \\ \hline The causal effect $[z \| x]$ & $\begin{tikzpicture}[xscale = .7, yscale = .4, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=small box] (166) at (24.475, 1.7) {$\kappa_y$}; \node [style=none] (167) at (24.475, 3.7) {}; \node [style=none] (168) at (24.475, 2.125) {}; \node [style=small box] (203) at (24.475, 4.05) {$\kappa_z$}; \node [style=none] (204) at (24.475, 5.7) {}; \node [style=none] (205) at (24.475, 4.475) {}; \node [style=none] (206) at (24.475, 1.35) {}; \node [style=none] (207) at (24.475, 0.125) {}; \node [style=none] (209) at (24.075, 0.45) {$x$}; \node [style=none] (210) at (24.075, 2.9) {$y$}; \node [style=none] (211) at (24.075, 5.1) {$z$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (167.center) to (168.center); \draw [style=wire] (204.center) to (205.center); \draw [style=wire] (206.center) to (207.center); \end{pgfonlayer} \end{tikzpicture}$ & $\begin{tikzpicture}[xscale = .7, yscale = .5, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (167) at (24.475, 3.7) {}; \node [style=none] (168) at (24.475, 2.45) {$\bullet$}; \node [style=small box] (203) at (24.475, 4.05) {$\kappa_z$}; \node [style=none] (204) at (24.475, 5.625) {}; \node [style=none] (205) at (24.475, 4.475) {}; \node [style=none] (206) at (23.225, 4.6) {$\bullet$}; \node [style=none] (207) at (23.225, 3.375) {}; \node [style=none] (209) at (22.825, 3.7) {$x$}; \node [style=none] (210) at (24.075, 2.95) {$y$}; \node [style=none] (211) at (24.075, 5.1) {$z$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (167.center) to (168.center); \draw [style=wire] (204.center) to (205.center); \draw [style=wire] (206.center) to (207.center); \end{pgfonlayer} \end{tikzpicture}$ & $\begin{tikzpicture}[xscale = .7, yscale = .5, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (204) at (24.525, 4.65) {}; \node [style=none] (205) at (24.525, 3.4) {$\bullet$}; \node [style=none] (206) at (23.225, 4.6) {$\bullet$}; \node [style=none] (207) at (23.225, 3.375) {}; \node [style=none] (209) at (22.825, 3.7) {$x$}; \node [style=none] (211) at (24.2, 4.175) {$z$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (204.center) to (205.center); \draw [style=wire] (206.center) to (207.center); \end{pgfonlayer} \end{tikzpicture}$ & $\begin{tikzpicture}[xscale = .7, yscale = .5, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (17) at (5.7, 0.35) {}; \node [style=none] (18) at (6.3, 0.35) {$\bullet$}; \node [style=none] (19) at (6.3, 1.575) {}; \node [style=none] (20) at (5.7, 1.575) {}; \node [style=small box] (22) at (6, 2.075) {$\kappa_z$}; \node [style=none] (24) at (6, 2.575) {}; \node [style=none] (25) at (6, 3.775) {}; \node [style=none] (37) at (5.65, 3.425) {$z$}; \node [style=none] (38) at (5.3, 0.425) {$x$}; \node [style=none] (39) at (6.7, 0.825) {$y$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (17.center) to (20.center); \draw [style=wire] (18.center) to (19.center); \draw [style=wire] (24.center) to (25.center); \end{pgfonlayer} \end{tikzpicture}$ \end{tabular} \end{center} Note that in the second and third examples, $x$ is not an ancestor of $z$ in the causal graph $G$, and the causal effect $[z\|x]$ is accordingly ``disconnected'': the morphism factors through the monoidal unit $\emptyset$, which marks the lack of influence of $x$ on $z$. \end{exam} \section{The existence of conditionals and a generic do-calculus} \label{sec:effect} With string diagrams, we can use topological notions to aid reasoning. Here are some notions that will be used in some of the arguments below: \begin{defn}\label{defn:inferen} Let $\Gamma$ be a string diagram in a symmetric monoidal category $\cat C$. Denote the source of an edge $e$ in $\Gamma$ by $e(0)$ and the target by $e(1)$. A \memph{directed path} $a \rightsquigarrow b$ in $\Gamma$ is a sequence of edges in $\Gamma$ \[ p = (a = e_0, e_1, \ldots, e_k, b = e_{k+1}) \] such that, for each $i$, $e_i(1) = e_{i+1}(0)$ and $e_i$ is not labeled by $\mathbf{I}$; we also regard the source and target of each $e_i$ as belonging to the directed path, and write $p(0) = a(0)$ and $p(1) = b(1)$. A \memph{path} is just a concatenation of finitely many directed paths. In particular, a \memph{splitter path} (respectively, a \memph{collider path}) is a concatenation of two directed paths joined at the starting nodes (respectively, at the ending nodes). Two (not necessarily distinct) edges are \memph{connected} in $\Gamma$ if there is a path between them. More generally, two sets $A$, $B$ of edges are connected in $\Gamma$ if some $a \in A$ is connected with some $b \in B$, of particular interest is the case $A = \dom (\Gamma)$ and $B = \cod (\Gamma)$. \end{defn} In some proofs below, we shall need the theory on surgeries on string diagrams developed in \cite{YinZhangModularity}. For Markov categories, there are four types of surgeries, corresponding to the four diagrams in (\ref{mon:law}) and (\ref{discar:nat}), which shall be accordingly referred to as coassociativity surgery, counitality surgery, cocommutativity surgery, and discard surgery, respectively. Only the following portion from that theory is needed here. Recall Remark~\ref{intro:string} and Terminology~\ref{what:dia}. Let $\Gamma$ be a string diagram of a morphism in $\cau(G)$. A node $x$ of $\Gamma$ is \memph{quasi-terminal} if either it is a dead-end (discard) or every maximal directed path $p$ in $\Gamma$ with $p(0) = x$ runs into a dead-end or, in case that $x$ is a duplicate, this is so for all such paths through one of the prongs. Denote the set of quasi-terminal nodes of $\Gamma$ by $\Delta_\Gamma$ and its complement by $\tilde \Delta_\Gamma$. Denote by $P_\Gamma$ the set of the directed paths that end in $\cod(\Gamma)$ and by $S_\Gamma$ the set of splitter paths between edges in $\cod(\Gamma)$. \begin{lem}\label{decor:mat} Suppose that $\Gamma$, $\Upsilon$ are string diagrams of the same morphism in $\cau(G)$. Then \begin{itemize} \item There is a bijection $\pi : \tilde \Delta_\Gamma \longrightarrow \tilde \Delta_{\Upsilon}$ compatible with the labels in $\Gamma$, $\Upsilon$. \item There is a bijection $\dot \pi : P_\Gamma \longrightarrow P_{\Upsilon}$ compatible with $\pi$, that is, $\pi$ restricts to a bijection between the nodes in $\tilde \Delta_\Gamma$ belonging to $p \in P_\Gamma$ and those in $\tilde \Delta_\Upsilon$ belonging to $\dot \pi(p)$. \item There is a bijection $\ddot \pi : S_\Gamma \longrightarrow S_{\Upsilon}$ compatible with $\pi$. \end{itemize} \end{lem} We continue to work in $\cau(G)$. Here is a useful fact from \cite{YinZhangModularity} that will be needed in the subsequent arguments: \begin{lem}\label{infe:ances} Let $f : v \longrightarrow w$ be a morphism between singular variables. Then there is a morphism $g : v / v' \longrightarrow w$ for some sub-variable $v' \subseteq v$ such that $f = g \otimes \epsilon_{v'}$ and, in all string diagrams of $g$, every atomic variable in $v / v'$ is connected with an atomic variable in $w$ via a directed path. \end{lem} We now proceed to establish some results about causal effect morphisms in a causal theory. A central result has to do with the existence of conditionals in a Markov category, as is defined in \cite{fritz2020synthetic}. \begin{defn}\label{defn:gen:cond} Let $f : Z \longrightarrow X \otimes Y$ be a morphism in a Markov category $\cat M$. \begin{itemize} \item The \memph{marginal} $f_{X|Z}$ of $f$ over $Y$ is the morphism $\begin{tikzpicture}[xscale = .5, yscale = .5, baseline={([yshift=10pt]current bounding box.south)}] \begin{pgfonlayer}{nodelayer} \node [style=none] (210) at (3.65, 2.55) {}; \node [style=none] (211) at (3.65, 2.05) {}; \node [style=small box] (225) at (3.65, 3.025) {$f$}; \node [style=none] (226) at (3.425, 4.075) {}; \node [style=none] (227) at (3.425, 3.525) {}; \node [style=none] (228) at (3.875, 4.075) {$\bullet$}; \node [style=none] (229) at (3.875, 3.525) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \end{pgfonlayer} \end{tikzpicture} = (1_X \otimes \epsilon_Y) \circ f: Z \longrightarrow X$. \item $f$ admits a \memph{conditional over $X$} if there is a morphism $f_{Y|XZ} : X \otimes Z \longrightarrow Y$ such that \begin{equation}\label{cond:gen:mark} \begin{tikzpicture}[xscale = .6, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (110) at (7.875, 4.4) {}; \node [style=none] (157) at (7.125, 0.625) {}; \node [style=none] (158) at (7.125, 0.05) {}; \node [style=none] (210) at (1.9, 2.55) {}; \node [style=none] (211) at (1.9, 1.8) {}; \node [style=wide small box] (225) at (1.9, 3.025) {$f$}; \node [style=none] (226) at (1.425, 4.325) {}; \node [style=none] (227) at (1.425, 3.525) {}; \node [style=none] (228) at (2.375, 4.325) {}; \node [style=none] (229) at (2.375, 3.525) {}; \node [style=none] (273) at (6.35, 1.45) {}; \node [style=wide small box] (274) at (7.35, 4.725) {$f_{Y|XZ}$}; \node [style=none] (275) at (7.35, 6.025) {}; \node [style=none] (276) at (7.35, 5.15) {}; \node [style=wide small box] (281) at (6.35, 1.95) {$f$}; \node [style=none] (283) at (5.875, 2.45) {}; \node [style=none] (284) at (6.925, 3.15) {$\bullet$}; \node [style=none] (285) at (6.825, 2.45) {}; \node [style=none] (286) at (4.125, 2.925) {$=$}; \node [style=none] (287) at (6.35, 1.175) {}; \node [style=none] (288) at (7.85, 1.2) {}; \node [style=none] (289) at (6.825, 4.2) {}; \node [style=none] (290) at (6.075, 3.025) {}; \node [style=none] (292) at (5.55, 3.375) {}; \node [style=none] (293) at (6.55, 3.4) {}; \node [style=none] (294) at (5.25, 5.5) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire, in=90, out=-90] (284.center) to (285.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire, in=90, out=-90] (284.center) to (285.center); \draw [style=wire, bend right=90, looseness=1.25] (287.center) to (288.center); \draw [style=wire] (287.center) to (273.center); \draw [style=wire, bend right=90, looseness=1.25] (292.center) to (293.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (290.center) to (283.center); \draw [style=wire, in=-120, out=90] (293.center) to (289.center); \draw [style=wire, in=-90, out=90] (292.center) to (294.center); \draw [style=wire] (110.center) to (288.center); \draw [style=wire] (110.center) to (288.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \end{itemize} \end{defn} The marginals of a causal effect morphism behave as expected. \begin{lem}\label{three:cau:mar} Let $u$, $v$, and $w$ be singular variables with $v \cap w = \emptyset$. Then the marginal of the causal effect $[vw \| u]$ over $v$ is the causal effect $[w \| u]$ (and that over $w$ is $[v \| u]$). \end{lem} \begin{proof} By induction on the cardinality of $v$, this is immediately reduced to the case where $v$ is an atomic variable. We examine how composing with $\epsilon_{v}$ changes the component $\Gamma_v$ and other subsequently impacted components $\Gamma_i$ without changing the morphism represented (recall Definition \ref{gen:condi}). If $\Gamma_v$ has more than one output wire then, by counitality surgery, $\iota_{v \rightarrow \bar v \otimes v} $ is changed to $\iota_{v \rightarrow \bar v} $ and $\Gamma_v$ is thus changed without impacting any other $\Gamma_i$. If $\Gamma_v$ has only one output wire then, by discard surgery, it is reduced to $\bigotimes_{j \in \pa(v)} \epsilon_{j}$, where $\pa(v)$ is computed in $G_{u \rightarrow vw}$. In that case, for any $j \in \pa(v)$, we ask the same question that whether $\Gamma_j$ has more than one output wire or not, and proceed accordingly as before. Observe that, when there are no more surgeries to be performed, the remaining components $\Gamma_j$, including the modified ones, are exactly those required to construct $\Gamma_{[w \| u]}$. The lemma follows. \end{proof} Note that this lemma relies on the axiom (\ref{discar:nat}), or discard surgery, which is not imposed in \cite{Fong:thesis} as we do here. To see it, consider again the third graph in Example~\ref{exa:cau:con} and the marginal $(1_x \otimes \epsilon_y) \circ [xy \| z]$ of the causal effect $[xy\|z]$ over $y$, then we have: \begin{equation}\label{fong:counter} \begin{tikzpicture}[xscale = .7, yscale = .5, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (17) at (5.75, 1.1) {}; \node [style=none] (18) at (6.25, 0.45) {}; \node [style=none] (19) at (6.25, 1.5) {}; \node [style=none] (20) at (5.75, 1.5) {}; \node [style=small box] (22) at (6, 2) {$\kappa_y$}; \node [style=none] (23) at (4.425, 1.1) {}; \node [style=none] (24) at (6, 2.5) {}; \node [style=none] (25) at (6, 3.425) {$\bullet$}; \node [style=none] (26) at (4.425, 3.025) {}; \node [style=none] (27) at (5.1, 0.2) {$\bullet$}; \node [style=none] (28) at (5.1, 0.6) {}; \node [style=none] (29) at (3.925, 3.025) {$x$}; \node [style=none] (30) at (6.65, 0.525) {$z$}; \node [style=none] (37) at (6.525, 2.925) {$y$}; \node [style=none] (40) at (8.225, 1.675) {$=$}; \node [style=none] (212) at (13.075, 1.675) {$=$}; \node [style=none] (213) at (14.725, 2.4) {}; \node [style=none] (214) at (14.725, 1.15) {$\bullet$}; \node [style=none] (215) at (15.925, 2.35) {$\bullet$}; \node [style=none] (216) at (15.925, 1.125) {}; \node [style=none] (217) at (16.275, 1.45) {$z$}; \node [style=none] (218) at (14.4, 1.925) {$x$}; \node [style=none] (219) at (11, 2.35) {}; \node [style=none] (220) at (11.5, 1.2) {}; \node [style=none] (221) at (11.5, 2.25) {$\bullet$}; \node [style=none] (222) at (11, 2.5) {$\bullet$}; \node [style=none] (224) at (9.675, 2.35) {}; \node [style=none] (227) at (9.675, 2.525) {}; \node [style=none] (228) at (10.35, 0.95) {$\bullet$}; \node [style=none] (229) at (10.35, 1.85) {}; \node [style=none] (230) at (9.95, 1.475) {$x$}; \node [style=none] (231) at (11.9, 1.275) {$z$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (17.center) to (20.center); \draw [style=wire] (18.center) to (19.center); \draw [style=wire] (23.center) to (26.center); \draw [style=wire] (24.center) to (25.center); \draw [style=wire, bend right=90, looseness=1.25] (23.center) to (17.center); \draw [style=wire] (27.center) to (28.center); \draw [style=wire] (213.center) to (214.center); \draw [style=wire] (215.center) to (216.center); \draw [style=wire] (219.center) to (222.center); \draw [style=wire] (220.center) to (221.center); \draw [style=wire] (224.center) to (227.center); \draw [style=wire, bend right=90, looseness=1.25] (224.center) to (219.center); \draw [style=wire] (228.center) to (229.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} where the first equality is begotten by discard surgery and the second one by counitality surgery. Without (\ref{discar:nat}), the first equality would fail. Related to this observation is a claim in \cite[Proposition~4.2]{Fong:thesis} that if $v$, $w$ are atomic variables and $v$ is not an ancestor of $w$ in $G$, then there exists no morphism $f: v \longrightarrow w$ in $\cat{Cau}(G)$ such that $v$ and $w$ are connected. Again, this is not quite right without (\ref{discar:nat}), as shown by the example in (\ref{fong:counter}). Now that we have imposed (\ref{discar:nat}), this claim does hold, and is immediate from Lemma \ref{infe:ances}: \begin{prop}[\cite{Fong:thesis}] \label{connect:ancestral} Let $v$, $w$ be atomic variables. If there exists a morphism $v \longrightarrow w$ in which $v$, $w$ are connected then $v$ is an ancestor of $w$. Conversely, if $v$ is an ancestor of $w$ then they are connected by a directed path in $\Gamma_{[w \| v]}$. \end{prop} This fact signals that $\cau(G)$ is ``purely causal'', in that all connected morphisms in the category go from causal ancestors to descendants. As a result, merely ``associational'' or ``evidential'' relations are not expressed by any morphism in the category. (Recall the ``no junk'' property of a free category.) In some Markov categories such as $\cat{FinStoch}$ mentioned earlier, every morphism of the form $f : Z \longrightarrow X \otimes Y$ admits conditionals over both objects in the codomain \cite{fritz2020synthetic}, but this is not the case in $\cat{Cau}(G)$. Take, for instance, the simple graph $x \rightarrow y$ and consider the exogenous effect $[xy] : \emptyset \longrightarrow xy$. If a conditional $[xy]_{x|y} : y \longrightarrow x$ over $y$ existed then we would have \begin{equation} \begin{tikzpicture}[xscale = .7, yscale = .5, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (17) at (5.75, 1.1) {}; \node [style=none] (20) at (5.75, 1.5) {}; \node [style=small box] (22) at (5.75, 2) {$\kappa_y$}; \node [style=none] (23) at (4.425, 1.1) {}; \node [style=none] (24) at (5.75, 2.5) {}; \node [style=none] (25) at (5.75, 3.025) {}; \node [style=none] (26) at (4.425, 3.025) {}; \node [style=none] (27) at (5.1, 0.025) {$\bullet$}; \node [style=none] (28) at (5.1, 0.6) {}; \node [style=none] (29) at (3.9, 3.025) {$x$}; \node [style=none] (37) at (6.25, 3) {$y$}; \node [style=none] (48) at (7.825, 1.5) {}; \node [style=none] (49) at (7.825, 1.5) {$=$}; \node [style=none] (50) at (11.475, -0.65) {$\bullet$}; \node [style=none] (53) at (11.475, -0.175) {}; \node [style=small box] (54) at (11.475, 0.325) {$\kappa_y$}; \node [style=none] (56) at (11.475, 0.825) {}; \node [style=none] (57) at (11.475, 1.275) {}; \node [style=none] (62) at (13.275, 3.375) {$y$}; \node [style=none] (68) at (10.325, 2.15) {}; \node [style=none] (69) at (12.65, 2.15) {}; \node [style=none] (70) at (11.475, 1.275) {}; \node [style=none] (72) at (10.325, 3.95) {}; \node [style=none] (73) at (10.325, 3.35) {}; \node [style=small box] (75) at (10.325, 2.85) {$[xy]_{x|y}$}; \node [style=none] (76) at (10.325, 2.35) {}; \node [style=none] (77) at (12.75, 3.375) {}; \node [style=none] (78) at (10.825, 3.975) {$x$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (17.center) to (20.center); \draw [style=wire] (23.center) to (26.center); \draw [style=wire] (24.center) to (25.center); \draw [style=wire, bend right=90, looseness=1.25] (23.center) to (17.center); \draw [style=wire] (27.center) to (28.center); \draw [style=wire] (50.center) to (53.center); \draw [style=wire] (56.center) to (57.center); \draw [style=wire, bend left=90, looseness=1.25] (69.center) to (68.center); \draw [style=wire] (72.center) to (73.center); \draw [style=wire, in=-90, out=90] (69.center) to (77.center); \draw [style=wire] (68.center) to (76.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} Since the duplicate $\delta_y$ does not occur on the left-hand side, by the first claim of Lemma~\ref{decor:mat}, its displayed occurrence on the right-hand side must be quasi-terminal, but then $x$, $y$ cannot be connected by a splitter path, violating the third claim of Lemma~\ref{decor:mat}. So the equality is not possible. On the other hand, $[xy]$ obviously admits a conditional over $x$, which is just $[y\| x] = \kappa_y$. This simple example actually illustrates a general fact: for pairwise disjoint singular variables in $\cau(G)$, $u$, $v$, $w$, if $[vw \| u]$ admits a conditional over $v$, the conditional must be $[w \| uv]$. We will leave the proof of this fact to another occasion, since it is a little involved and not directly relevant to the intended contributions of this paper. For the present purpose, the directly relevant question is when $[w \| uv]$ is a conditional of $[w \| uv]$, or in other words, when the following \memph{decomposition} or \memph{disintegration} of a causal effect holds: \begin{equation}\label{effect:decom} \begin{tikzpicture}[xscale = .6, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (110) at (7.875, 4.4) {}; \node [style=none] (157) at (7.125, 0.625) {}; \node [style=none] (158) at (7.125, 0.05) {}; \node [style=none] (210) at (1.9, 2.55) {}; \node [style=none] (211) at (1.9, 1.8) {}; \node [style=wide small box] (225) at (1.9, 3.025) {$[vw \| u]$}; \node [style=none] (226) at (1.425, 4.325) {}; \node [style=none] (227) at (1.425, 3.525) {}; \node [style=none] (228) at (2.375, 4.325) {}; \node [style=none] (229) at (2.375, 3.525) {}; \node [style=none] (273) at (6.35, 1.45) {}; \node [style=wide small box] (274) at (7.35, 4.725) {$ [w\|vu] $}; \node [style=none] (275) at (7.35, 6.025) {}; \node [style=none] (276) at (7.35, 5.15) {}; \node [style=wide small box] (281) at (6.35, 1.95) {$[v \| u]$}; \node [style=none] (283) at (6.325, 2.45) {}; \node [style=none] (286) at (4.125, 2.925) {$=$}; \node [style=none] (287) at (6.35, 1.175) {}; \node [style=none] (288) at (7.85, 1.2) {}; \node [style=none] (289) at (6.825, 4.2) {}; \node [style=none] (290) at (6.325, 3.025) {}; \node [style=none] (292) at (5.8, 3.375) {}; \node [style=none] (293) at (6.8, 3.4) {}; \node [style=none] (294) at (5.25, 5.5) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire, bend right=90, looseness=1.25] (287.center) to (288.center); \draw [style=wire] (287.center) to (273.center); \draw [style=wire, bend right=90, looseness=1.25] (292.center) to (293.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (290.center) to (283.center); \draw [style=wire] (293.center) to (289.center); \draw [style=wire, in=-90, out=90] (292.center) to (294.center); \draw [style=wire] (110.center) to (288.center); \draw [style=wire] (110.center) to (288.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} Call the property expressed by (\ref{effect:decom}) the \memph{decomposability} of $[vw\|u]$ over $v$. We now introduce some graphical conditions relevant to characterizing decomposability and other significant concepts to be introduced presently: \begin{defn}\label{def:separation} Let $i$, $j$ be two distinct vertices in $G$. A \memph{forward trek} from $i$ to $j$ in $G$ is a directed path from $i$ to $j$. A \memph{backward trek} from $i$ to $j$ is a directed path from $j$ to $i$, or a disjoint union of two directed paths joined at a distinct starting vertex $k$ (i.e., $i\leftarrow \dots \leftarrow k \rightarrow \dots \rightarrow j$). Given $X, Y \subseteq V(G)$, a \memph{proper} forward (respectively, backward) trek from $X$ to $Y$ is a forward (respectively, backward) trek from some $i\in X$ to some $j\in Y$ that does not contain any other vertex in $X$ or in $Y$. We say that \begin{itemize} \item $X$ is \memph{forward-$t$-separated} from $Y$ by $Z$ if every proper forward trek in $G$ from $X$ to $Y$ contains some $k \in Z$; \item $X$ is \memph{backward-$t$-separated} from $Y$ by $Z$ if every proper backward trek in $G$ from $X$ to $Y$ contains some $k \in Z$; \item $X$ and $Y$ are \memph{$t$-separated} by $Z$ if $X$ is both forward-$t$-separated and backward-$t$-separated from $Y$ by $Z$. \end{itemize} \end{defn} Observe that $t$-separation is a symmetric relation, but forward-$t$-separation and backward-$t$-separation are not. Also note that $t$-separation is a simpler condition than the well-known $d$-separation \cite{Pearl1988}; the former is concerned only with blocking treks, whereas the latter also has an explicit requirement for paths that contain colliders, where two arrows point at the same vertex (i.e., $i\rightarrow k \leftarrow j$). For the rest of this section, let $u$, $v$, and $w$ be pairwise disjoint singular variables in $\cau(G)$. \begin{thm}\label{thm: main1} $[vw \| u]$ is decomposable over $v$ if and only if $v$ is backward-$t$-separated from $w$ by $u$. \end{thm} \begin{proof} For the ``if'' direction, suppose $v$ is backward-$t$-separated from $w$ by $u$, and we show that the equality (\ref{effect:decom}) holds. We examine the components $\Gamma_i$, $\Gamma_j$ for $i \in V(G_{u \rightarrow v})$, $j \in V(G_{uv \rightarrow w})$ and show that, together with $\delta_{v}$ and $\delta_{u}$ on the righthand side of (\ref{effect:decom}), they are exactly those needed to construct the string diagram $\Gamma_{[vw \| u]}$. There are the following cases. \begin{itemize} \item $i \notin uv$. Then there is a directed path from $i$ to some $i' \in v$ in $G$ that does not pass through $u$. If $i$ also occurs in $G_{uv \rightarrow w}$ then either there is a directed path from it to some $j' \in w$ in $G$ that does not pass through $uv$, or it is contained in $w$, both of which are prohibited by the backward-$t$-separation of $v$ from $w$ by $u$. So $\Gamma_i$ is the same in $\Gamma_{[vw \| u]}$ and $\Gamma_{[v \| u]}$. \item $i \in uv$. Let $i'$, $j'$ be any children of $i$ in $G_{u \rightarrow v}$, $G_{uv \rightarrow w}$, respectively. So $i' \notin u$ and $j' \notin uv$. If $i' \notin v$ then, by the case just considered, $i'$ does not occur in $G_{uv \rightarrow w}$ at all; for the same reason, $j'$ does not occur in $G_{u \rightarrow v}$. On the other hand, if $i' \in v$ then it cannot be a child of $i$ in $G_{uv \rightarrow w}$. So $\Gamma_i$ in $\Gamma_{[vw \| u]}$ is the juxtaposition of the two $\Gamma_i$ in $\Gamma_{[v \| u]}$ and $\Gamma_{[w \| uv]}$ joined by $\delta_{u}$. \item $j \notin uv$. Then $j$ is an ancestor of some $j' \in w$ in $G_{(uv \rightarrow w}$, and hence cannot occur in $G_{u \rightarrow v}$, again due to the backward-$t$-separation of $v$ from $w$ by $u$. So $\Gamma_j$ is the same in $\Gamma_{[vw \| u]}$ and $\Gamma_{[w \| uv]}$. \end{itemize} This establishes (\ref{effect:decom}). For the ``only if'' direction, suppose that (\ref{effect:decom}) holds. Let $\pi$ be a proper backward trek from $a \in v$ to $b \in w$ in $G$. Suppose for contradiction that $\pi$ does not contain any vertex in $u$. By the first claim of Lemma~\ref{decor:mat}, $\kappa_b$ cannot occur in $\Gamma_{[v \| u]}$. Thus, by the other two claims of Lemma~\ref{decor:mat}, $\pi$ would translate into a directed path $b \rightsquigarrow a$ in $\Gamma_{[w \| v u]}$, which is not possible, or a splitter path between $a$ and $b$ in $\Gamma_{[vw \| u]}$ that does not pass through $v$ in the direction of $b$ and hence must pass through $u$, contradiction again. \end{proof} Readers familiar with Pearl's do-calculus \cite{Pearl1995} may have noticed the close affinity between backward-$t$-separation and the condition for Rule 2 of the do-calculus. Before we elaborate on the connection, let us introduce two more notions to fully match the do-calculus. One of them (``conditional independence'') is introduced in \cite{fritz2020synthetic} for all Markov categories. \begin{defn} \label{def:irre:ind} Let $\cat M$ be a Markov category. \begin{itemize} \item Let $f : X \otimes Z \longrightarrow Y$ be a morphism in $\cat M$. We say that $X$ is \memph{conditionally irrelevant to $Y$ given $Z$ over $f$} if there is a morphism $f_{Y|Z} : Z \longrightarrow Y$ such that \begin{equation}\label{cau:ind:z} \begin{tikzpicture}[xscale = .6, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (242) at (0.825, 2.075) {}; \node [style=wide small box] (254) at (0.825, 2.575) {$f_{Y|Z}$}; \node [style=none] (255) at (0.8, 3.85) {}; \node [style=none] (256) at (0.8, 3.075) {}; \node [style=none] (260) at (-1.15, 3.425) {$\bullet$}; \node [style=none] (261) at (-1.15, 1.525) {}; \node [style=none] (271) at (0.825, 1.275) {}; \node [style=none] (210) at (-4.3, 3.075) {}; \node [style=none] (211) at (-4.3, 3.825) {}; \node [style=wide small box] (225) at (-4.3, 2.6) {$f$}; \node [style=none] (226) at (-3.825, 1.3) {}; \node [style=none] (227) at (-3.825, 2.1) {}; \node [style=none] (228) at (-4.775, 1.3) {}; \node [style=none] (229) at (-4.775, 2.1) {}; \node [style=none] (314) at (-2.3, 2.425) {$=$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (255.center) to (256.center); \draw [style=wire] (260.center) to (261.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (242.center) to (271.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \item Let $f : Z \longrightarrow X \otimes Y$ be a morphism in $\cat M$. We say that $X$, $Y$ are \memph{conditionally independent given $Z$ over $f$} if \begin{equation}\label{cond:ind} \begin{tikzpicture}[xscale = .6, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (241) at (-0.3, 2.525) {}; \node [style=none] (242) at (1.9, 2.525) {}; \node [style=wide small box] (254) at (1.9, 3.025) {$f$}; \node [style=none] (255) at (2.375, 4.3) {}; \node [style=none] (256) at (2.375, 3.525) {}; \node [style=none] (257) at (1.425, 4.175) {$\bullet$}; \node [style=none] (258) at (1.425, 3.525) {}; \node [style=wide small box] (259) at (-0.3, 3.025) {$f$}; \node [style=none] (260) at (0.175, 4.175) {$\bullet$}; \node [style=none] (261) at (0.175, 3.525) {}; \node [style=none] (262) at (-0.775, 4.3) {}; \node [style=none] (263) at (-0.775, 3.525) {}; \node [style=none] (271) at (1.9, 2.225) {}; \node [style=none] (272) at (-0.3, 2.25) {}; \node [style=none] (282) at (0.775, 0.725) {}; \node [style=none] (210) at (-4.3, 2.05) {}; \node [style=none] (211) at (-4.3, 1.3) {}; \node [style=wide small box] (225) at (-4.3, 2.525) {$f$}; \node [style=none] (226) at (-3.825, 3.825) {}; \node [style=none] (227) at (-3.825, 3.025) {}; \node [style=none] (228) at (-4.775, 3.825) {}; \node [style=none] (229) at (-4.775, 3.025) {}; \node [style=none] (314) at (-2.3, 2.425) {$=$}; \node [style=none] (324) at (0.775, 1.425) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (255.center) to (256.center); \draw [style=wire] (257.center) to (258.center); \draw [style=wire] (260.center) to (261.center); \draw [style=wire] (262.center) to (263.center); \draw [style=wire, bend left=90, looseness=1.25] (271.center) to (272.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (242.center) to (271.center); \draw [style=wire] (282.center) to (324.center); \draw [style=wire] (241.center) to (272.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \end{itemize} \end{defn} We consider a specialized version of conditional irrelevance: $v$ is \memph{causally screened-off} from $w$ by $u$ if \begin{equation}\label{screenoff} \begin{tikzpicture}[xscale = .7, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (242) at (0.825, 2.075) {}; \node [style=wide small box] (254) at (0.825, 2.575) {$[w\|u]$}; \node [style=none] (255) at (0.8, 3.85) {}; \node [style=none] (256) at (0.8, 3.075) {}; \node [style=none] (260) at (-1.15, 3.425) {$\bullet$}; \node [style=none] (261) at (-1.15, 1.525) {}; \node [style=none] (271) at (0.825, 1.275) {}; \node [style=none] (210) at (-4.3, 3.075) {}; \node [style=none] (211) at (-4.3, 3.825) {}; \node [style=wide small box] (225) at (-4.3, 2.6) {$[w \| vu]$}; \node [style=none] (226) at (-3.825, 1.3) {}; \node [style=none] (227) at (-3.825, 2.1) {}; \node [style=none] (228) at (-4.775, 1.3) {}; \node [style=none] (229) at (-4.775, 2.1) {}; \node [style=none] (314) at (-2.2, 2.425) {$=$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (255.center) to (256.center); \draw [style=wire] (260.center) to (261.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (242.center) to (271.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} It is easy to show that causal screening-off is captured precisely by forward-$t$-separation. \begin{thm} \label{thm:main2} $[w\| vu] = \epsilon_v\otimes [w\|u]$ if and only if $v$ is forward-$t$-separated from $w$ by $u$ in $G$. \end{thm} \begin{proof} For the ``if'' direction, since $v$ is forward-$t$-separated from $w$ by $u$, no $i \in v$ can have children in $G_{vu \rightarrow w}$ and hence $G_{vu \rightarrow w}$ is the union of $G_{u \rightarrow w}$ and the trivial graph with vertices in $v$. It then follows from the construction of causal effects in Definition~\ref{gen:condi} that (\ref{screenoff}) holds. For the ``only if'' direction, suppose that (\ref{screenoff}) holds. If there is a proper forward trek from $v$ to $w$ in $G$ that does not contain any vertex in $u$ then, by Lemma~\ref{decor:mat}, it would translate into a directed path on the right-hand side of (\ref{screenoff}) connecting $v$ and $w$, which is not possible. \end{proof} Similarly, conditional independence over causal effects is captured precisely by $t$-separation. \begin{thm} \label{thm:main3} We have that $v$, $w$ are conditionally independent given $u$ over $[vw \| u]$ if and only if they are $t$-separated by $u$ in $G$. \end{thm} \begin{proof} For the ``if'' direction, note that $t$-separation between $v$ and $w$ by $u$ entails that, on the one hand, $v$ is backward-$t$-separated from $w$ by $u$ and hence, by Theorem \ref{thm: main1}, the equality (\ref{effect:decom}) holds, and on the other hand, $v$ is forward-$t$-separated from $w$ by $u$ and hence, by Theorem \ref{thm:main2}, the equality (\ref{screenoff}) holds. It then follows that \begin{equation} \begin{tikzpicture}[xscale = .65, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (110) at (7.875, 4.4) {}; \node [style=none] (157) at (7.125, 0.625) {}; \node [style=none] (158) at (7.125, 0.05) {}; \node [style=none] (210) at (1.9, 2.55) {}; \node [style=none] (211) at (1.9, 1.8) {}; \node [style=wide small box] (225) at (1.9, 3.025) {$[vw \| u]$}; \node [style=none] (226) at (1.425, 4.325) {}; \node [style=none] (227) at (1.425, 3.525) {}; \node [style=none] (228) at (2.375, 4.325) {}; \node [style=none] (229) at (2.375, 3.525) {}; \node [style=none] (273) at (6.35, 1.45) {}; \node [style=wide small box] (274) at (7.35, 4.725) {$ [w\|vu] $}; \node [style=none] (275) at (7.35, 6.025) {}; \node [style=none] (276) at (7.35, 5.15) {}; \node [style=wide small box] (281) at (6.35, 1.95) {$[v \| u]$}; \node [style=none] (283) at (6.325, 2.45) {}; \node [style=none] (286) at (4.125, 2.925) {$=$}; \node [style=none] (287) at (6.35, 1.175) {}; \node [style=none] (288) at (7.85, 1.2) {}; \node [style=none] (289) at (6.825, 4.2) {}; \node [style=none] (290) at (6.325, 3.025) {}; \node [style=none] (292) at (5.8, 3.375) {}; \node [style=none] (293) at (6.8, 3.4) {}; \node [style=none] (294) at (5.25, 5.5) {}; \node [style=none] (295) at (13.375, 4.4) {}; \node [style=none] (296) at (12.625, 0.625) {}; \node [style=none] (297) at (12.625, 0.05) {}; \node [style=none] (298) at (11.85, 1.45) {}; \node [style=small box] (299) at (13.35, 4.725) {$ [w\|u] $}; \node [style=none] (300) at (13.35, 6.025) {}; \node [style=none] (301) at (13.35, 5.15) {}; \node [style=wide small box] (302) at (11.85, 1.95) {$[v \| u]$}; \node [style=none] (303) at (11.825, 2.45) {}; \node [style=none] (304) at (9.625, 2.925) {$=$}; \node [style=none] (305) at (11.85, 1.175) {}; \node [style=none] (306) at (13.35, 1.2) {}; \node [style=none] (307) at (12.325, 3.7) {$\bullet$}; \node [style=none] (308) at (11.825, 3.025) {}; \node [style=none] (309) at (11.3, 3.375) {}; \node [style=none] (310) at (12.3, 3.4) {}; \node [style=none] (311) at (10.75, 5.25) {}; \node [style=none] (312) at (19.875, 2.875) {}; \node [style=none] (313) at (18.875, 1.675) {}; \node [style=none] (314) at (18.875, 1.1) {}; \node [style=none] (315) at (17.85, 2.7) {}; \node [style=wide small box] (316) at (19.85, 3.2) {$ [w\|u] $}; \node [style=none] (317) at (19.85, 4.5) {}; \node [style=none] (318) at (19.85, 3.625) {}; \node [style=wide small box] (319) at (17.85, 3.2) {$[v \| u]$}; \node [style=none] (320) at (17.825, 3.7) {}; \node [style=none] (321) at (15.625, 2.925) {$=$}; \node [style=none] (322) at (17.85, 2.425) {}; \node [style=none] (323) at (19.85, 2.45) {}; \node [style=none] (325) at (17.825, 4.525) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire, bend right=90, looseness=1.25] (287.center) to (288.center); \draw [style=wire] (287.center) to (273.center); \draw [style=wire, bend right=90, looseness=1.25] (292.center) to (293.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (290.center) to (283.center); \draw [style=wire] (293.center) to (289.center); \draw [style=wire, in=-90, out=90] (292.center) to (294.center); \draw [style=wire] (110.center) to (288.center); \draw [style=wire] (110.center) to (288.center); \draw [style=wire] (296.center) to (297.center); \draw [style=wire] (300.center) to (301.center); \draw [style=wire] (296.center) to (297.center); \draw [style=wire] (296.center) to (297.center); \draw [style=wire] (300.center) to (301.center); \draw [style=wire, bend right=90, looseness=1.25] (305.center) to (306.center); \draw [style=wire] (305.center) to (298.center); \draw [style=wire, bend right=90, looseness=1.25] (309.center) to (310.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (308.center) to (303.center); \draw [style=wire] (310.center) to (307.center); \draw [style=wire, in=-90, out=90] (309.center) to (311.center); \draw [style=wire] (295.center) to (306.center); \draw [style=wire] (295.center) to (306.center); \draw [style=wire] (313.center) to (314.center); \draw [style=wire] (317.center) to (318.center); \draw [style=wire] (313.center) to (314.center); \draw [style=wire] (313.center) to (314.center); \draw [style=wire] (317.center) to (318.center); \draw [style=wire, bend right=90, looseness=1.25] (322.center) to (323.center); \draw [style=wire] (322.center) to (315.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (325.center) to (320.center); \draw [style=wire] (312.center) to (323.center); \draw [style=wire] (312.center) to (323.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} So, by Lemma~\ref{three:cau:mar}, $v$, $w$ are conditionally independent given $u$ over $[vw \| u]$. For the ``only if'' direction, by Lemma~\ref{three:cau:mar} again, we may assume \begin{equation}\label{concau:indep:free} \begin{tikzpicture}[xscale = .6, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (241) at (4.15, 2.525) {}; \node [style=none] (242) at (1.95, 2.525) {}; \node [style=none] (244) at (4.15, 2.25) {}; \node [style=wide small box] (254) at (1.95, 3.025) {$[v \| u]$}; \node [style=none] (255) at (1.975, 4.3) {}; \node [style=none] (256) at (1.975, 3.525) {}; \node [style=wide small box] (259) at (4.15, 3.025) {$[w \| u]$}; \node [style=none] (262) at (4.125, 4.3) {}; \node [style=none] (263) at (4.125, 3.525) {}; \node [style=none] (271) at (1.95, 2.225) {}; \node [style=none] (272) at (4.15, 2.25) {}; \node [style=none] (282) at (3.075, 0.725) {}; \node [style=none] (210) at (-2.1, 2.05) {}; \node [style=none] (211) at (-2.1, 1.3) {}; \node [style=wide small box] (225) at (-2.1, 2.525) {$[vw \| u]$}; \node [style=none] (226) at (-2.575, 3.825) {}; \node [style=none] (227) at (-2.575, 3.025) {}; \node [style=none] (228) at (-1.625, 3.825) {}; \node [style=none] (229) at (-1.625, 3.025) {}; \node [style=none] (314) at (0, 2.425) {$=$}; \node [style=none] (324) at (3.075, 1.425) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (241.center) to (244.center); \draw [style=wire] (255.center) to (256.center); \draw [style=wire] (262.center) to (263.center); \draw [style=wire, bend right=90, looseness=1.25] (271.center) to (272.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (242.center) to (271.center); \draw [style=wire] (282.center) to (324.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} Let $\pi$ be a proper forward or backward trek from $a \in v$ to $ b \in w$. If $\pi$ does not contain any vertex in $u$ then it would translate into a directed or splitter path $\gamma$ between $a$ and $b$ in $\Gamma_{[vw \| u]}$. Since $a, b \notin u$, we see that $\kappa_a$, $\kappa_b$ occur exactly once in $\Gamma_{[vw \| u]}$ and hence, by (\ref{concau:indep:free}) and the first claim of Lemma~\ref{decor:mat}, $\kappa_a$ and hence $a$ do not occur in $\Gamma_{[w \| u]}$, whereas $\kappa_b$ and hence $b$ do not occur in $\Gamma_{[v \| u]}$. It follows from the other two claims of Lemma~\ref{decor:mat} that $\gamma$ has to pass through $u$, contradiction. \end{proof} A merit of such theorems about the syntax category is that the sufficiency claims in them are immediately transferred to all models. \begin{cor} \label{cor:model:do} Let $M$ be a Markov category and $F: \cau(G) \longrightarrow \cat M$ a strong Markov functor. Then \begin{enumerate} \item If $v$ and $w$ are $t$-separated by $u$ in $G$ then, in $\cat M$, $F(v)$ and $F(w)$ are conditionally independent given $F(u)$ over $F([vw\|u])$: \begin{equation}\label{do-cal1} \begin{tikzpicture}[xscale = 1, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (241) at (-0.3, 2.525) {}; \node [style=none] (242) at (1.9, 2.525) {}; \node [style=wide small box] (254) at (1.9, 3.025) {$F([vw\|u])$}; \node [style=none] (255) at (2.375, 4.3) {}; \node [style=none] (256) at (2.375, 3.525) {}; \node [style=none] (257) at (1.425, 4.175) {$\bullet$}; \node [style=none] (258) at (1.425, 3.525) {}; \node [style=wide small box] (259) at (-0.3, 3.025) {$F([vw\|u])$}; \node [style=none] (260) at (0.175, 4.175) {$\bullet$}; \node [style=none] (261) at (0.175, 3.525) {}; \node [style=none] (262) at (-0.775, 4.3) {}; \node [style=none] (263) at (-0.775, 3.525) {}; \node [style=none] (271) at (1.9, 2.225) {}; \node [style=none] (272) at (-0.3, 2.25) {}; \node [style=none] (282) at (0.775, 0.725) {}; \node [style=none] (210) at (-4.3, 2.05) {}; \node [style=none] (211) at (-4.3, 1.3) {}; \node [style=wide small box] (225) at (-4.3, 2.525) {$F([vw\|u])$}; \node [style=none] (226) at (-3.825, 3.825) {}; \node [style=none] (227) at (-3.825, 3.025) {}; \node [style=none] (228) at (-4.775, 3.825) {}; \node [style=none] (229) at (-4.775, 3.025) {}; \node [style=none] (314) at (-2.3, 2.425) {$=$}; \node [style=none] (324) at (0.775, 1.425) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (255.center) to (256.center); \draw [style=wire] (257.center) to (258.center); \draw [style=wire] (260.center) to (261.center); \draw [style=wire] (262.center) to (263.center); \draw [style=wire, bend left=90, looseness=1.25] (271.center) to (272.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (242.center) to (271.center); \draw [style=wire] (282.center) to (324.center); \draw [style=wire] (241.center) to (272.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \item If $v$ is backward-$t$-separated from $w$ by $u$ in $G$ then, in $\cat M$, $F([w\|uv])$ is a conditional of $F([vw\|u])$: \begin{equation}\label{do-cal2} \begin{tikzpicture}[xscale = .8, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (110) at (7.875, 4.4) {}; \node [style=none] (157) at (7.125, 0.625) {}; \node [style=none] (158) at (7.125, 0.05) {}; \node [style=none] (210) at (1.9, 2.55) {}; \node [style=none] (211) at (1.9, 1.8) {}; \node [style=wide small box] (225) at (1.9, 3.025) {$F([vw \| u])$}; \node [style=none] (226) at (1.425, 4.325) {}; \node [style=none] (227) at (1.425, 3.525) {}; \node [style=none] (228) at (2.375, 4.325) {}; \node [style=none] (229) at (2.375, 3.525) {}; \node [style=none] (273) at (6.35, 1.45) {}; \node [style=wide small box] (274) at (7.35, 4.725) {$ F([w\|uv]) $}; \node [style=none] (275) at (7.35, 6.025) {}; \node [style=none] (276) at (7.35, 5.15) {}; \node [style=wide small box] (281) at (6.35, 1.95) {$F([v \| u])$}; \node [style=none] (283) at (6.325, 2.45) {}; \node [style=none] (286) at (4.275, 2.925) {$=$}; \node [style=none] (287) at (6.35, 1.175) {}; \node [style=none] (288) at (7.85, 1.2) {}; \node [style=none] (289) at (6.825, 4.2) {}; \node [style=none] (290) at (6.325, 3.025) {}; \node [style=none] (292) at (5.8, 3.375) {}; \node [style=none] (293) at (6.8, 3.4) {}; \node [style=none] (294) at (5.25, 5.5) {}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (157.center) to (158.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (275.center) to (276.center); \draw [style=wire, bend right=90, looseness=1.25] (287.center) to (288.center); \draw [style=wire] (287.center) to (273.center); \draw [style=wire, bend right=90, looseness=1.25] (292.center) to (293.center); \draw [style=wire, in=90, out=-90, looseness=1.25] (290.center) to (283.center); \draw [style=wire] (293.center) to (289.center); \draw [style=wire, in=-90, out=90] (292.center) to (294.center); \draw [style=wire] (110.center) to (288.center); \draw [style=wire] (110.center) to (288.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \item If $v$ is forward-$t$-separated from $w$ by $u$ in $G$ then, in $\cat M$, $F(v)$ is conditionally irrelevant to $F(w)$ given $F(u)$ over $F([w\|uv])$: \begin{equation}\label{do-cal3} \begin{tikzpicture}[xscale = .8, yscale = .45, baseline=(current bounding box.center)] \begin{pgfonlayer}{nodelayer} \node [style=none] (242) at (0.825, 2.075) {}; \node [style=wide small box] (254) at (0.825, 2.575) {$F([w\|u])$}; \node [style=none] (255) at (0.8, 3.85) {}; \node [style=none] (256) at (0.8, 3.075) {}; \node [style=none] (260) at (-1.15, 3.425) {$\bullet$}; \node [style=none] (261) at (-1.15, 1.525) {}; \node [style=none] (271) at (0.825, 1.275) {}; \node [style=none] (210) at (-4.3, 3.075) {}; \node [style=none] (211) at (-4.3, 3.825) {}; \node [style=wide small box] (225) at (-4.3, 2.6) {$F([w\|uv])$}; \node [style=none] (226) at (-3.825, 1.3) {}; \node [style=none] (227) at (-3.825, 2.1) {}; \node [style=none] (228) at (-4.775, 1.3) {}; \node [style=none] (229) at (-4.775, 2.1) {}; \node [style=none] (314) at (-2.1, 2.425) {$=$}; \end{pgfonlayer} \begin{pgfonlayer}{edgelayer} \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (255.center) to (256.center); \draw [style=wire] (260.center) to (261.center); \draw [style=wire] (210.center) to (211.center); \draw [style=wire] (226.center) to (227.center); \draw [style=wire] (228.center) to (229.center); \draw [style=wire] (242.center) to (271.center); \end{pgfonlayer} \end{tikzpicture} \end{equation} \end{enumerate} \end{cor} On the other hand, the necessity claims do not hold in all models. For example, the decomposition property (\ref{do-cal2}) always holds in deterministic structural equation models (as functors from $\cau(G)$ to $\cat{Set}$), regardless of backward-$t$-separation. The necessity in question is necessity for validity (``true in all models''), rather than truth in particular models. \section{The causal core of the do-calculus} \label{sec:cal} Corollary \ref{cor:model:do} is particularly interesting because its three clauses correspond to the three rules in Pearl's do-calculus, respectively. Suppose $\cat M = \cat{FinStoch}$, and $F$ sends each causal mechanism $\kappa_v$ to a positive stochastic matrix, so that it gives rise to a causal Bayesian network (CBN) model \cite{Fong:thesis}, in which the pre-intervention joint probability distribution is positive (which is assumed by Pearl's do-calculus). Let $\mathbf{X}$ denote the set of random variables represented by the object $u$, $\mathbf{Y}$ by $w$, and $\mathbf{Z}$ by $v$. Then equations (\ref{do-cal1})-(\ref{do-cal3}) can be reformulated as follows.\footnote{In $\cat{FinStoch}$, we can simply use nonzero natural numbers as the objects, and the morphisms are stochastic matrices: a morphism $n\longrightarrow m$ is a $m\times n$ stochastic matrix. A discard morphism $\epsilon_n: n\longrightarrow 1$ is the $1\times n$ stochastic matrix in which each entry is $1$, and a duplicate morphism $\delta_n : n \longrightarrow n^2$ is the $n^2\times n$ stochastic matrix in which $(\delta_n)^{(i - 1)n + i}_{i} = 1$ (and other entries are zero.) The composition of morphisms is given by matrix multiplication, and the monoidal product is given by the Kronecker product of matrices \cite{Fong:thesis,fritz2020synthetic}. As shown in \cite{Fong:thesis}, $F([v_G])$, the image of the exogenous effect on $v_G$ in $\cat{FinStoch}$, is a stochastic matrix (in fact, a column vector) encoding a joint probability distribution over the set of random variables $\mathbf(V)$ represented by $v_G$ that satisfies the factorization in (\ref{fac:pre}). His argument can be generalized to show that $F([v\|u])$ is a stochastic matrix encoding the distributions over the random variables represented by $v$ given that those represented by $u$ are intervened to take various values, according to the intervention principle (\ref{fac:post}). Note that equations (\ref{prob-docal-1})-(\ref{prob-docal-3}) are understood as holding for all values of $\mathbf{X}, \mathbf{Y}, \mathbf{Z}$, and so express equality between specific entries in the relevant matrices.} Equation (\ref{do-cal1}) is rendered as: \begin{equation} \label{prob-docal-1} P(\mathbf{Y}, \mathbf{Z} | do(\mathbf{X})) = P(\mathbf{Y} | do(\mathbf{X}))P(\mathbf{Z} | do(\mathbf{X})). \end{equation} Equation (\ref{do-cal2}) is rendered as: \begin{equation} \label{prob-docal-2} P(\mathbf{Y}, \mathbf{Z} | do(\mathbf{X})) = P(\mathbf{Z}| do(\mathbf{X}))P(\mathbf{Y} | do(\mathbf{X}), do(\mathbf{Z})). \end{equation} Equation (\ref{do-cal3}) is rendered as: \begin{equation} \label{prob-docal-3} P(\mathbf{Y}| do(\mathbf{X}), do(\mathbf{Z})) = P(\mathbf{Y}| do(\mathbf{X})). \end{equation} Note in addition that by the probability calculus and the assumed positivity, (\ref{prob-docal-1}) is equivalent to \[ P(\mathbf{Y} | do(\mathbf{X}), \mathbf{Z}) = P(\mathbf{Y} | do(\mathbf{X})), \] and (\ref{prob-docal-2}) is equivalent to \[ P(\mathbf{Y} | do(\mathbf{X}), do(\mathbf{Z})) = P(\mathbf{Y} | do(\mathbf{X}), \mathbf{Z}), \] because by the chain rule of the probability calculus, $P(\mathbf{Y}, \mathbf{Z} | do(\mathbf{X})) = P(\mathbf{Z}| do(\mathbf{X}))P(\mathbf{Y} | do(\mathbf{X}), \mathbf{Z})$. The upshot is that Corollary \ref{cor:model:do}, when applied to a CBN model based on $G$ (with a positive or regular pre-intervention distribution), entails the following rules. \begin{itemize} \item[{\it Rule 1}] (Insertion/deletion of observations): if $\mathbf{Y}$ and $\mathbf{Z}$ are $t$-separated by $\mathbf{X}$ in $G$, then \[ P(\mathbf{Y} | do(\mathbf{X}), \mathbf{Z}) = P(\mathbf{Y} | do(\mathbf{X})). \] \item[{\it Rule 2}] (Action/observation exchange): if $\mathbf{Z}$ is backward-$t$-separated from $\mathbf{Y}$ by $\mathbf{X}$ in $G$, then \[ P(\mathbf{Y} | do(\mathbf{X}), do(\mathbf{Z})) = P(\mathbf{Y} | do(\mathbf{X}), \mathbf{Z}). \] \item[{\it Rule 3}] (Insertion/deletion of actions): if $\mathbf{Z}$ is forward-$t$-separated from $\mathbf{Y}$ by $\mathbf{X}$ in $G$, then \[ P(\mathbf{Y} | do(\mathbf{X}), do(\mathbf{Z})) = P(\mathbf{Y} | do(\mathbf{X})). \] \end{itemize} Pearl's do-calculus \cite{Pearl1995} consists of exactly three rules like these, but each rule therein is more general than the corresponding rule above and is formulated in terms of the more complicated $d$-separation criterion and various modifications of $G$. The extra generality in Pearl's version is that the consequent equation in each rule has an extra set of variables $\mathbf{W}$ to be conditioned upon on both sides of the equation. For example, the consequent equation in the first rule of Pearl's do-calculus is \[ P(\mathbf{Y} | do(\mathbf{X}), \mathbf{Z}, \mathbf{W}) = P(\mathbf{Y} | do(\mathbf{X}), \mathbf{W}), \] and similarly for the other two rules. It is a simple exercise to check that each of the rules above is exactly equivalent to the corresponding rule in Pearl's calculus when $\mathbf{W}$ is taken to be empty. So Corollary \ref{cor:model:do}, when applied to a CBN model, yields a specialized version of Pearl's do-calculus. However, although each rule in the specialized version is a special case of the corresponding rule in the full version, taken together they are actually as strong as the full version. To see this, it suffices to show that we can recover the intervention principle (\ref{fac:post}) from the specialized rules, or to be more exact, from Rule 2 and Rule 3 above, since Rule 1 is entailed by the conjunction of Rule 2 and Rule 3 (just as in the full version, see \cite{HV2006}.) Since the full version is entailed by the intervention principle (plus the probability calculus), it is also entailed by the specialized version (plus the probability calculus) if the intervention principle is entailed by the specialized version (plus the probability calculus). We now sketch a fairly simple argument to that effect. It helps to first consider the pre-intervention case, where we need to show that Rule 2 and Rule 3 entail that the pre-intervention probability distribution factorizes as in (\ref{fac:pre}). This is equivalent to deriving the local Markov condition from Rule 2 and Rule 3, the condition that every variable is probabilistically independent of its non-descendants conditional on its parents \cite{SGS2000}. The derivation is straightforward. For any random variable $V\in \mathbf{V}$ in the CBN, by Rule 2, we have \[ P(V | do(\pa(V))) = P(V | \pa(V)), \] and \[ P(V | do(\nd(V))) = P(V | \nd(V)), \] where $\pa(V)$ and $\nd(V)$ denote the set of $V$'s parents in $G$ and the set of $V$'s non-descendants in $G$ (i.e., those variables of which $V$ is not an ancestor), respectively. This is so because $\pa(V)$ is trivially backward-$t$-separated from $V$ by the empty set (for there is no proper backward trek from $\pa(V) $ to $V$), and so is $\nd(V)$, which contains $\pa(V)$ as a subset. Then by Rule 3, we have \[ P(V | do(\nd(V))) = P(V | do(\pa(V))), \] simply because every forward trek to $V$ contains a parent of $V$. It follows that for each $V$, \[ P(V | \nd(V)) = P(V | \pa(V)). \] So the factorization required by the intervention principle holds in the pre-intervention case. This argument easily generalizes to any post-intervention probability distribution $P(\mathbf{V}|do(\mathbf{T}))$; that is, we can derive in the same fashion from Rule 2 and Rule 3 that for every $V$, \[ P(V | \nd^*(V), do(\mathbf{T})) = P(V | \pa^*(V), do(\mathbf{T})), \] where $\pa^*(V)$ and $\nd^*(V)$ denote the set of $V$'s parents and the set of $V$'s non-descendants, respectively, in the subgraph of $G$ in which all arrows into variables in $\mathbf{T}$ are deleted. From this follows the factorization of $P(\mathbf{V}|do(\mathbf{T}))$ required by the intervention principle (\ref{fac:post}). Therefore, the full do-calculus can in principle be derived from the specialized do-calculus together with the probability calculus. This fact reveals an equivalent formulation of the do-calculus for CBN models that is simpler than the standard formulation. More importantly, this simpler formulation reflects the ``causal core'' of the do-calculus, for it is an instance of the generic do-calculus given in Corollary \ref{cor:model:do}, and the generic do-calculus is derived from results in a syntax category that is, so to speak, purely causal (because there is no morphism in that category to match non-causal or evidential relations between variables.) More precisely, the causal core of the do-calculus is given by the rule for causal decomposition ((\ref{do-cal2}), rendered as (\ref{prob-docal-2}) in a CBN model) and the rule for causal screening-off ((\ref{do-cal3}), rendered as (\ref{prob-docal-3}) in a CBN model). These are derived without any consideration of the non-causal features of the models. The standard do-calculus for the CBN models can be seen as derived from a conjunction of these two rules on the one hand, which are purely causal, and the probability calculus on the other hand, which is non-causal. \section{Conclusion} \label{sec:con} Following the pioneering work of \cite{Fong:thesis}, we studied the causal effect morphisms in a causal DAG-induced free Markov category in some depth, and established sufficient and necessary graphical conditions for some conceptually important properties of such morphisms, including especially decomposition and screening-off. Our results yield a generic do-calculus that is more general and abstract than the standard do-calculus in the context of causal Bayesian networks. Not only is the generic do-calculus more widely applicable, it is also conceptually illuminating in that it reveals the purely causal component of the do-calculus. When applied to causal Bayesian networks, it also results in a simpler but equivalent formulation of the probabilistic do-calculus. Since the simpler do-calculus uses trek-separation rather than the more convoluted d-separation, it is probably easier to explain and understand. Moreover, the simpler do-calculus may also be readily extendable to other causal graphical models derived from DAG models. For example, in \cite{Zhang2008}, Pearl's do-calculus is extended to the so-called partial ancestral graphs (PAGs), which are used to represent Markov equivalence classes of DAG models. The extension is intended to capture the applicability of a do-calculus rule in all DAGs in the equivalence class represented by a PAG, but due to the complex graphical conditions in Pearl's do-calculus, it only accommodates some but not all such cases of unanimous applicability. We suspect that an extension of the simpler do-calculus highlighted in this paper would be more straightforward and complete. \section*{Acknowledgements} This research was supported by the Research Grants Council of Hong Kong under the General Research Fund 13602818. \providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace} \providecommand{\MR}{\relax\ifhmode\unskip\space\fi MR } \providecommand{\MRhref}[2]{% \href{http://www.ams.org/mathscinet-getitem?mr=#1}{#2} } \providecommand{\href}[2]{#2}
{'timestamp': '2022-04-12T02:29:23', 'yymm': '2204', 'arxiv_id': '2204.04821', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04821'}
arxiv
\section{1. Introduction} In the field of machine learning, many problems can be formulated as the minimax problem, including adversarial learning \cite{goodfellow2014generative}, reinforcement learning \cite{du2017stochastic,dai2018sbeed}, AUC maximization \cite{zhao2011online,gao2013one,ying2016stochastic,liu2018fast,lei2021stochastic}, robust optimization \cite{chen2017robust,namkoong2017variance}, and distributed computing \cite{shamma2008cooperative,mateos2010distributed,razaviyayn2020nonconvex}, to mention but a few. In the minimax problem, there are two groups of decision variables, one for minimization and the other for maximization \cite{lei2021stability}. To solve the minimax problem, various optimization algorithms have been designed, such as Gradient Descent Ascent (GDA), Stochastic Gradient Descent Ascent (SGDA), Alternating Gradient Descent Ascent (AGDA), Proximal Point Method (PPM), etc \cite{farnia2021train,lei2021stability}. Like other machine learning problems, the minimax problem also faces the privacy troubles, because tremendous individual's data have to be collected for training \cite{phan2020scalable,wang2021differentially}. In the real scenarios, not only the original data leakages the sensitive information, the machine learning model also causes privacy issues \cite{fredrikson2014privacy,shokri2017membership}. Under these circumstances, \cite{dwork2006calibrating} proposes a theoretically rigorous tool: Differential Privacy (DP) \cite{dwork2014the}, to protect the sensitive information of individuals who participate in the training dataset, by introducing random noise to the model. There are mainly three approaches to guarantee DP: output perturbation, objective perturbation, and gradient perturbation \cite{chaudhuri2011differentially,song2013stochastic}. There exist some works to combine differential privacy with some of the minimax problems, such as DP-adversarial learning \cite{xu2019ganobfuscator,phan2020scalable,giraldo2020adversarial,lin2021on}, DP-reinforcement learning \cite{vietri2020private,chen2021an}, DP-AUC maximization \cite{huai2020pairwise,wang2021differentially,yang2021stability}, and DP-robust optimization \cite{lecuyer2019certified}. However, all the researches mentioned above only focus on particular models (e.g. Generative Adversarial Networks (GANs)), but not on the general minimax paradigm. Besides, there is no analysis on the generalization error of the general DP-minimax problem to the best of our knowledge. To solve these problems, in this paper, we concentrate on differentially private minimax optimization, provide privacy guarantees and analyze the generalization performance of the DP minimax model (we pay more attentions on the generalization part). Due to the simplicity, GDA is one of the most widespread usded optimization methods in the field of minimax problem, so we focus on GDA in this paper. Besides, considering that the high probability generalization performance of machine learning models is paid more attentions, we use algorithmic stability theory, in particular, argument stability, to get several different generalization measures of DP-GDA model, under high probability condition. The contributions of this paper include: 1. In the minimax problem, there are two decision variables: one for minimization and one for maximization, so there are various generalization measures due to different coupling combinations \cite{farnia2021train,lei2021stability,zhang2021generalization}. In this paper, we analyze almost all existing generalization measures for our proposed DP-GDA algorithm, via algorithm stability theory and provide corresponding high probability bounds. And our results are better than previous results analyzed for particular DP-minimax model (such as DP-AUC maximization). To the best of our knowledge, this is the first time to give generalization bounds for the general minimax paradigm. 2. In the minimax problem, the minimization parameter $\bold{w}$ differs when it comes to different maximization parameters $\bold{v}$ (and vice versa), which brings challenges to the theoretical analysis. Moreover, for differentially private models, random noise is an essential part and it makes the results worse. In this paper, to overcome these problems, novel decomposition methods are applied and sharper generalization bounds are achieved. The rest of the paper is organized as follows. The related work is discussed in Section 2. Preliminaries are introduced in Section 3. The algorithm DP-GDA along with the privacy guarantees are given in Section 4. We analyze the generalization performance of DP-GDA in Section 5. We compare our results with existed works in Section 6. Finally, we conclude the paper in Section 7. And all the proofs are given in the Appendix. \section{2. Related Work} For the minimax problem, there is a long list of works discussing the convergence analysis and the empirical risk under convex-concave condition \cite{mokhtari2020a,yan2020optimal,lin2020near,wang2020improved,yoon2021accelerated}, nonconvex-concave condition \cite{luo2020stochastic,lu2020hybird,lin2020on,chen2021proximal}, and nonconvex-nonconcave condition \cite{loizou2020stochastic,yang2020global,wang2020on,liu2021first,diakonikolas2021efficient,loizou2021stochastic,fiez2021local}. However, there is relatively little work concerning the generalization performance. \cite{zhang2021generalization} analyzes the generalization performance of the empirical saddle point (ESP) solution in the minimax problem; \cite{farnia2021train} discusses the generalization performance of several popular optimization algorithms in the minimax problem: GDA, GDmax, SGDA, SGDmax, and PPM. And \cite{zhang2021generalization} and \cite{farnia2021train} only focus on the expectation generalization bounds. Besides, \cite{lei2021stability} gives high probability generalization bounds, of the order $\mathcal{O}(1/\sqrt{n})$, where $n$ is the number of training data. To analyze the generalization performance, complexity theory \cite{bartlett2002localized} and algorithmic stability \cite{bousquet2002stability} are popular tools. On one hand, some existed works analyze the generalization performance of differentially private models via complexity theory. For example, \cite{chaudhuri2011differentially} gives high probability excess population risk bound under strongly convex conditions and \cite{kifer2012private} gives the excess population risk bound in expectation. On the other hand, algorithmic stability is a fundamental concept in learning theory, and it captures the fluctuations on the model caused by modifying one of the data instances. Algorithmic stability has been widely studied in recent decades, including uniform stability \cite{bousquet2002stability,hardt2016train}, hypothesis stability \cite{bousquet2002stability}, argument stability \cite{liu2017algorithmic,bassily2020stability}, locally elastic stability \cite{deng2021toward}. And there is a long list of works analyzing the high probability generalization bounds for differentially private models via algorithmic stability \cite{wu2017bolt,bassily2019private,feldman2020private,bassily2020stability,wang2021differentiallyarxiv}. Besides, \cite{lei2021stability,farnia2021train,zhang2021generalization} have extended the uniform stability and argument stability to the minimax setting, and a new stability concept: weakly stability is designed for the minimax problem in \cite{lei2021stability}. However, the analysis on the generalization performance of DP-minimax problem is still a blank. Meanwhile, there are some works combining differential privacy with some particular minimax problems. \cite{xu2019ganobfuscator} designs GANobfuscator, which guarantees DP of GAN via gradient perturbation method. Besides, \cite{giraldo2020adversarial} discusses the inherent privacy of GANs, from the view of DP. However, these works do not give any theoretical utility guarantees. \cite{wang2021differentially} proposes output and objective perturbation methods to guarantee the differential privacy of AUC maximization, and achieves $\mathcal{O}(1/\sqrt{n})$ high probability excess population risk bound. Considering that AUC maximization can be seemed as one of the pairwise learning problems, \cite{huai2020pairwise,yang2021stability} analyze the privacy guarantees and the generalization bounds of DP-AUC maximization from the pairwise perspective, they also achieve excess population risk bound of the order $\mathcal{O}(1/\sqrt{n})$ with high probability. For reinforcement learning, \cite{chen2021an} proposes a DP version on the platform Vehicular ad hoc network (VANET), and \cite{vietri2020private} not only discusses the privacy, but also gives the probably approximately correct (PAC) and regret bounds. However, to the best of our knowledge, there is no existing work concentrating on DP of the general minimax problem. \section{3. Preliminaries} \subsection{3.1 Differential Privacy} Let $\mathcal{P}$ be a probability measure defined on the data space $\mathcal{Z}$ and let dataset $S=\{z_1,\cdots,z_n\}$ be independent drawn from $\mathcal{P}$. Datasets $S,S'$ differing by at most one data instance are denoted by $S\sim S'$, called adjacent datasets. \begin{definition}\label{def4}[Differential Privacy \cite{dwork2014the}] Algorithm $\mathcal{A}:\mathcal{Z}^n\rightarrow\mathbb{R}^p$ is ($\epsilon,\delta$)-differential privacy (DP) if for all $S\sim S'$ and events $O\in range(\mathcal{A})$ \begin{equation*} \mathbb{P}\left[\mathcal{A}(S)\in O\right]\leq e^{\epsilon}\mathbb{P}\left[\mathcal{A}(S')\in O\right]+\delta. \end{equation*} \end{definition} Differential privacy requires essentially the same distributions to be drawn over any adjacent datasets, so that the adversaries cannot infer whether an individual participates to the training process. Some kind of attacks, such as attribute inference attack, membership inference attack, and memorization attack, can be thwarted by DP \cite{backes2016membership,jayaraman2019evaluating,carlini2019the}. \subsection{3.2. Minimax Paradigm} Denote two parameter spaces as $\mathcal{W},\mathcal{V}\in\mathbb{R}^p$, where $p$ is the parameter dimensions, then for the minimax problem, we define $\ell:\mathcal{W}\times\mathcal{V}\times\mathcal{Z}\rightarrow\mathbb{R}$ and consider \begin{equation*} \min_{\bold{w}\in\mathcal{W}}\max_{\bold{v}\in\mathcal{V}}L(\bold{w},\bold{v})\coloneqq\mathbb{E}_{z\sim\mathcal{P}}\left[\ell(\bold{w},\bold{v};z)\right]. \end{equation*} Since the underlying $\mathcal{P}$ is always unknown, so empirical risk is designed as \begin{equation*} L_S(\bold{w},\bold{v})=\frac{1}{n}\sum_{i=1}^{n}\ell(\bold{w},\bold{v};z_i). \end{equation*} Denoting the model derived from dataset $S$ by applying algorithm $\mathcal{A}$ as $\mathcal{A}(S)=(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S))\in\mathcal{W}\times\mathcal{V}$, in this paper, we focus on analyzing how well $\mathcal{A}(S)$ performs on the underlying distribution $\mathcal{P}$, i.e. the generalization performance. There are several measures to demonstrate the generalization performance of the minimax model. \begin{definition}[\cite{lei2021stability}]\label{def1} There are four generalization measures in the minimax problem. (a) \textbf{Weak Primal-Dual (PD) Risk}: The weak PD population risk of $(\bold{w},\bold{v})$ is defined as \begin{equation*} \triangle^{w}(\bold{w},\bold{v})=\sup_{\bold{v'}\in\mathcal{V}}\mathbb{E}\left[L(\bold{w},\bold{v'})\right]-\inf_{\bold{w'}\in\mathcal{W}}\mathbb{E}\left[L(\bold{w'},\bold{v})\right]. \end{equation*} Corresponding empirical risk is defined as \begin{equation*} \triangle_S^{w}(\bold{w},\bold{v})=\sup_{\bold{v'}\in\mathcal{V}}\mathbb{E}\left[L_S(\bold{w},\bold{v'})\right]-\inf_{\bold{w'}\in\mathcal{W}}\mathbb{E}\left[L_S(\bold{w'},\bold{v})\right]. \end{equation*} $\triangle^{w}(\bold{w},\bold{v})-\triangle_S^{w}(\bold{w},\bold{v})$ is referred to the weak PD generalization error of $(\bold{w},\bold{v})$. (b) \textbf{Strong Primal-Dual (PD) Risk}: The strong PD population risk of $(\bold{w},\bold{v})$ is defined as \begin{equation*} \triangle^{s}(\bold{w},\bold{v})=\sup_{\bold{v'}\in\mathcal{V}}L(\bold{w},\bold{v'})-\inf_{\bold{w'}\in\mathcal{W}}L(\bold{w'},\bold{v}). \end{equation*} Corresponding empirical risk is defined as \begin{equation*} \triangle_S^{s}(\bold{w},\bold{v})=\sup_{\bold{v'}\in\mathcal{V}}L_S(\bold{w},\bold{v'})-\inf_{\bold{w'}\in\mathcal{W}}L_S(\bold{w'},\bold{v}). \end{equation*} $\triangle^{s}(\bold{w},\bold{v})-\triangle_S^{s}(\bold{w},\bold{v})$ is referred to the strong PD generalization error of the model $(\bold{w},\bold{v})$. (c) \textbf{Primal Risk}: The primal population risk and empirical risk are w.r.t model $\bold{w}$, defined as \begin{equation*} R(\bold{w})=\sup_{\bold{v}\in\mathcal{V}}L(\bold{w},\bold{v}),\quad R_S(\bold{w})=\sup_{\bold{v}\in\mathcal{V}}L_S(\bold{w},\bold{v}). \end{equation*} If $R(\bold{w})$ is bounded by $R_S(\bold{w})$, we call this error the primal generalization error; if $R(\bold{w})$ is bounded by $\inf_{\bold{w'}\in\mathcal{W}}R(\bold{w'})$, we call this error the excess primal population risk. (d) \textbf{Plain Risk}: For model $(\bold{w},\bold{v})$, if $L(\bold{w},\bold{v})$ is bounded by $L_S(\bold{w},\bold{v})$, this error is called the plain generalization error. \end{definition} \begin{remark}\label{rem1} In Definition \ref{def1}, the primal risk is w.r.t only one of the parameters $\bold{w}$ and the plain risk are similar to which in traditional learning tasks. Besides, for weak and strong PD risks, one can easily get $\triangle^{w}(\bold{w},\bold{v})\leq\mathbb{E}\left[\triangle^{s}(\bold{w},\bold{v})\right]$ and $\triangle_S^{w}(\bold{w},\bold{v})\leq\mathbb{E}\left[\triangle_S^{s}(\bold{w},\bold{v})\right]$, so the weak PD risk is naturally bounded by the strongly PD risk bound. \end{remark} For a $p$-dimension vector $\bold{x}$, define its $\ell_2$ norm (Euclidean norm) as $\|\bold{x}\|_2=\big(\sum_{i=1}^{p}|\bold{x}_i|^2\big)^{1/2}$, and let $\langle\cdot,\cdot\rangle$ be the inner product. A differentiable function $\ell:\mathcal{W}\rightarrow\mathbb{R}$ is called $\rho$-strongly-convex over $\bold{w}$ if for any $\bold{w},\bold{w}'$ \begin{equation*} \ell(\bold{w})-\ell(\bold{w}')\geq\langle\nabla \ell(\bold{w}'),\bold{w}-\bold{w}'\rangle+\frac{\rho}{2}\|\bold{w}-\bold{w}'\|_2^2. \end{equation*} If $-\ell$ is $\rho$-strongly convex, then $\ell$ is $\rho$-strongly concave. \begin{assumption}\label{a1} For the minimax problem, we say $\ell$ is $\rho$-strongly-convex-strongly-concave ($\rho$-SC-SC) if $\ell(\cdot,\bold{v})$ is $\rho$-strongly-convex for all $\bold{v}$ and $\ell(\bold{w},\cdot)$ is $\rho$-strongly-concave for all $\bold{w}$. In this paper, we focus on the $\rho$-SC-SC problem. \end{assumption} \begin{assumption}\label{a2} For $G>0$, $\ell(\bold{w},\bold{v};z)$ is $G$-Lipschitz if for any $\bold{w},\bold{v}$ and $z$ \begin{equation*} \|\nabla_\bold{w}\ell(\bold{w},\bold{v};z)\|_2\leq G,\quad\|\nabla_\bold{v}\ell(\bold{w},\bold{v};z)\|_2\leq G. \end{equation*} \end{assumption} \begin{assumption}\label{a3} For $L>0$, $\ell(\bold{w},\bold{v};z)$ is $L$-smooth if for any $\bold{w},\bold{w}',\bold{v},\bold{v}'$ and $z$ \begin{equation*} \left\{ \begin{array}{l} \|\nabla_\bold{w}\ell(\bold{w},\bold{v};z)-\nabla_\bold{w}\ell(\bold{w'},\bold{v};z)\|_2\leq L\|\bold{w}-\bold{w}'\|_2, \\ \|\nabla_\bold{w}\ell(\bold{w},\bold{v};z)-\nabla_\bold{w}\ell(\bold{w},\bold{v'};z)\|_2\leq L\|\bold{v}-\bold{v}'\|_2, \\ \|\nabla_\bold{v}\ell(\bold{w},\bold{v};z)-\nabla_\bold{v}\ell(\bold{w'},\bold{v};z)\|_2\leq L\|\bold{w}-\bold{w}'\|_2, \\ \|\nabla_\bold{v}\ell(\bold{w},\bold{v};z)-\nabla_\bold{v}\ell(\bold{w},\bold{v'};z)\|_2\leq L\|\bold{v}-\bold{v}'\|_2. \end{array} \right. \end{equation*} \end{assumption} \subsection{3.3. Algorithmic Stability} Algorithmic stability is a popular tool to analyze the generalization performance of the machine learning model, which captures the difference between models derived from adjacent training datasets. Some of the stabilities have been extended to the minimax problem, such as weakly stability, uniform stability and argument stability, in expectation or high probability \cite{zhang2021generalization,lei2021stability,farnia2021train}. In this paper, we use argument stability to get the high probability generalization bounds, defined as follows. \begin{definition}\label{def2} Algorithm $\mathcal{A}$ is $\gamma$-argument-stable ($\gamma>0$) if for any adjacent datasets $S\sim S'\in\mathcal{Z}^n$ we have \begin{equation*} \|\mathcal{A}_\bold{w}(S)-\mathcal{A}_\bold{w}(S')\|_2+\|\mathcal{A}_\bold{v}(S)-\mathcal{A}_\bold{v}(S')\|_2\leq\gamma. \end{equation*} \end{definition} In the minimax problem, argument stability demonstrates the gap between $\mathcal{A}(S)$ and $\mathcal{A}(S')$, formulated by the summation over $\bold{w}$ and $\bold{v}$. Via property $G$-Lipschitz (Assumption \ref{a2}), it directly derives the uniform stability. \section{4. Differentially Private Gradient Descent Ascent} Among many optimization methods designed for the minimax problem, Gradient Descent Ascent (GDA) is one of the most widespread algorithm because of its simplicity, so we concentrate on GDA in this paper. Let $\bold{w}_1,\bold{v}_1=\bold{0}$ be the intial model, $\eta_t$ be learning rate at iteration $t$ ($t=1,\cdots,T$), and ${\rm Proj}(\cdot)$ be projection to corresponding parameter spaces, then \begin{equation*} \begin{aligned} \bold{w}_{t+1}&={\rm Proj}_\mathcal{W}\left(\bold{w}_t-\eta_t\nabla_\bold{w}L_S(\bold{w}_t,\bold{v}_t)\right), \\ \bold{v}_{t+1}&={\rm Proj}_\mathcal{V}\left(\bold{v}_t+\eta_t\nabla_\bold{v}L_S(\bold{w}_t,\bold{v}_t)\right). \end{aligned} \end{equation*} To guarantee DP, we propose DP-GDA in Algorithm \ref{alg1}. In Algorithm \ref{alg1}, the output is the average of iterates $\bar{\bold{w}}_T$ and $\bar{\bold{v}}_T$, rather than $\bold{w}_T$ and $\bold{v}_T$ themselves. The reason is that the average operator simplifies the optimization error analysis \cite{nemirovski2009robust,lei2021stability}. \begin{algorithm}[tb] \caption{Differentially Private Gradient Descent Ascent} \label{alg1} \begin{algorithmic} \State {\bfseries Input:} dataset $S$, privacy budgets $\epsilon,\delta$, learning rates $\eta_t$ \State Initialize $\bold{w}_1,\bold{v}_1=\bold{0}$. \For{$i=1$ {\bfseries to} $T$} \State Sample $b_\bold{w},b_\bold{v}\sim\mathcal{N}\left(0,\sigma^2I_p\right)$. \State $\bold{w}_{t+1}={\rm Proj}_\mathcal{W}\left(\bold{w}_t-\eta_t\left(\nabla_\bold{w}L_S(\bold{w}_t,\bold{v}_t)+b_\bold{w}\right)\right)$ \\ \State $\bold{v}_{t+1}={\rm Proj}_\mathcal{V}\left(\bold{v}_t+\eta_t\left(\nabla_\bold{v}L_S(\bold{w}_t,\bold{v}_t)+b_\bold{v}\right)\right)$ \EndFor \State $\bar{\bold{w}}_T=\frac{1}{T}\sum_{t=1}^{T}\bold{w}_t, \quad \bar{\bold{v}}_T=\frac{1}{T}\sum_{t=1}^{T}\bold{v}_t.$ \State Return $\mathcal{A}(S)=(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$. \end{algorithmic} \end{algorithm} Before giving the privacy guarantees of Algorithm \ref{alg1}, we first recall the DP property in the single parameter setting. \begin{lemma}\label{lem8}[\cite{wang2017differentially}] In single parameter DP gradient descent paradigm whose model updating process is $\bold{w}_{t+1}={\rm Proj}_\mathcal{W}\left(\bold{w}_t-\eta_t\left(\nabla_\bold{w}L_S(\bold{w}_t)+b_\bold{w}\right)\right)$\footnote{$L_S(\bold{w})$ here is the empirical risk in the single parameter setting.}, and the loss function is $G$-Lipschitz, for $\epsilon,\delta>0$, it is $(\epsilon,\delta)$-DP if the random noise is zero mean Gaussian noise, i.e., $b\sim\mathcal{N}(0,\sigma^2I_p)$, and for some constant $c$, $\sigma^2=c\frac{G^2T\log(1/\delta)}{n^2\epsilon^2}$. \end{lemma} By Lemma \ref{lem8}, we give the privacy guarantees of DP-GDA. \begin{theorem}\label{the1} If $\ell(\cdot,\cdot;\cdot)$ satisfies Assumption \ref{a1}, then for $\epsilon,\delta>0$, DP-GDA is $(\epsilon,\delta)$-DP if \begin{equation*} \sigma=\mathcal{O}\left(\frac{G\sqrt{T\log(1/\delta)}}{n\epsilon}\right). \end{equation*} \end{theorem} Theorem \ref{the1} is directly derived from Lemma \ref{lem8}. For differentially private gradient descent under single parameter condition, \cite{wang2017differentially} gives a tight noise bound (as shown in Lemma \ref{lem8}), via moments accountant theory \cite{abadi2016deep}. In the minimax paradigm, it is also the gradient who may cause the privacy leakage when training, similar to the condition analyzed in \cite{wang2017differentially}. And the privacy cost is independent of the minimization or maximization processes. As a result, if the noise given in \cite{wang2017differentially} is injected to both $\bold{w}$ and $\bold{v}$, the claimed DP will be guaranteed. This is also the reason that $\bold{w}$ and $\bold{v}$ share the same variance in Theorem \ref{the1}. Besides, we average the parameters at the end of the algorithm, this will not effect the claimed DP because of the Post-Processing property of differential privacy \cite{dwork2014the}. Considering that the proof process is almost the same (the only difference is to apply it to $\bold{v}$ once more) and we focus more on the generalization analysis in this paper, we directly use the result here in Algorithm \ref{alg1}. For clarity, we give the proof in Appendix A.1. \begin{remark}\label{rem2} In Algorithm \ref{alg1}, we apply gradient perturbation method to guarantee DP, rather than output or objective perturbation methods. One of the reasons is that gradient perturabtion naturally fits gradient-based algorithms (such as GDA), and as a result it can be used for a wide range of applications. Besides, adding random noise to the gradient allows the model to escape local minima \cite{raginsky2017nonconvex}. So we choose gradient perturbation method to guarantee DP in this paper. \end{remark} \section{5. Generalization Performance} In this section, we analyze the stability of DP-GDA and then give corresponding generalization bounds. To get the generalization bounds, we further assume that the loss function and the parameter space are bounded. \begin{assumption}\label{a4} The loss function $\ell(\cdot,\cdot;\cdot)$ is assumed to be bounded, i.e., $0\leq\ell(\cdot,\cdot;\cdot)\leq M_\ell$. \end{assumption} \begin{assumption}\label{a5} Paramater spaces are assumed to be bounded: for all $\bold{w}$ and $\bold{v}$, $\|\bold{w}\|_2\leq M_\mathcal{W}$ and $\|\bold{v}\|_2\leq M_\mathcal{V}$. \end{assumption} \subsection{5.1. Stability Analysis} Firstly, we analyze the argument stability (defined in Definition \ref{def2}) of our proposed DP-GDA. \begin{theorem}\label{the2} If Assumptions \ref{a1} and \ref{a2} hold. Then with $\sigma$ given in Theorem \ref{the1} and $\eta_t=\frac{1}{\rho t}$, the output of DP-GDA (Algorithm 1) $\mathcal{A}(S)=(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$ is $\gamma$-argument stable with probability at least $1-\zeta$ for $\zeta\in(\exp(-\frac{p}{8}),1)$, where \begin{equation*} \begin{aligned} \gamma&=\frac{4G}{n\rho}+\frac{2\sigma\sqrt{p}\log(eT)}{T}p_\zeta+4\sqrt{\log(eT)}\times \\ &\quad\sqrt{\frac{G^2}{\rho^2T}+\frac{\sigma^2p}{\rho^2T}p_\zeta^2+\frac{2G\sigma\sqrt{p}}{\rho^2T}p_\zeta+\frac{\left(g_\bold{w}+g_\bold{v}\right)\sigma\sqrt{p}}{\rho\log(eT)}p_\zeta}, \end{aligned} \end{equation*} \end{theorem} where $p_\zeta=1+\big(\frac{8\log(2T/\zeta)}{p}\big)^{1/4}$, $g_\bold{w}=\left\Vert\bar{\bold{w}}^*-\bar{\bold{w}}_{T}\right\Vert_2$, and $g_\bold{v}=\left\Vert\bar{\bold{v}}^*-\bar{\bold{v}}_{T}\right\Vert_2$ for $\bar{\bold{w}}^*=\arg\min_{\bold{w}\in\mathcal{W}}L_S(\bold{w},\bar{\bold{v}}_T)$, and $\bar{\bold{v}}^*=\arg\max_{\bold{v}\in\mathcal{V}}L_S(\bar{\bold{w}}_T,\bold{v})$. The proof can be found in Appendix A.2. We first compare it with non-DP minimax problem. The key difference is that in DP-GDA, random noise is an essential part, which brings challenges to the theoretical analysis if we want an acceptable stability bound. In the non-DP setting, if we set $T$ larger, the stability bound will be better in general, however, in DP-GDA, this is not true because the $T$-time injected random noise also affects the stability. Then, we compare it with traditional single parameter problem under DP condition. When it comes to the DP setting, there exist terms $\|b\|_2$ and $\|b\|_2^2$ (in the minimax problem, they are divided into $b_\bold{w}$ and $b_\bold{v}$). Among them, $\|b\|_2^2$ is an \textit{acceptable} term because the variance of $b$ is of the order $\mathcal{O}(1/n)$ w.r.t $n$, so the key challenge is to bound $\|b\|_2$, especially for high probability bounds (in expectation bounds, $\mathbb{E}[\|b\|_2]=0$). In traditional DP settings, factor $\|b\|_2$ can be eliminated by choosing particular $\eta_t$ (for example, in \cite{wang2017differentially}, term $\|b\|_2$ vanishes by setting $\eta_t=1/L$, where $L$ is the smoothness parameter). However, in the minimax paradigm, this cannot go through because parameter $\bold{w}$ differs with the changing of $\bold{v}$ (and vice versa), which brings huge troubles to the theoretical analysis. To solve the problems mentioned above, we introduce terms $g_\bold{w},g_\bold{v}$ to bound $\|b_\bold{w}\|_2$ and $\|b_\bold{v}\|_2$, respectively. Meanwhile, if we bound $g_\bold{w},g_\bold{v}$ rudely by $M_\mathcal{W}$ and $M_\mathcal{V}$, the result will be worse, detailed discussions are shown in Remark \ref{rem4}. \begin{remark}\label{rem3} In Theorem \ref{the2}, there exist terms $g_\bold{w}$ and $g_\bold{v}$, we discuss them here. With $\rho$-strongly convexity, we have $\rho g_\bold{w}^2\leq2(L_S\left(\bar{\bold{w}}_{t},\bar{\bold{v}}_T\right)-L_S\left(\bar{\bold{w}}^*,\bar{\bold{v}}_T\right)) $. By extending the classical analysis of the gradient descent model (see e.g. \cite{shalev2014understanding}), if Assumptions \ref{a1}, \ref{a2} and \ref{a5} hold, then with $\eta_t=\frac{1}{\rho t}$, we have \begin{equation*} \begin{aligned} &L_S\left(\bar{\bold{w}}_{t},\bar{\bold{v}}_T\right)-L_S\left(\bar{\bold{w}}^*,\bar{\bold{v}}_T\right) \\ &\leq\log(eT)\left(\frac{G^2}{2\rho T}+\left(\frac{G}{T}+\frac{M_\mathcal{W}}{\log(eT)}\right)\|b_\bold{w}\|_2+\frac{\|b_\bold{w}\|_2^2}{2T}\right). \end{aligned} \end{equation*} So with probability at least $1-\zeta$ for $\zeta\in(\exp(-\frac{p}{8}),1)$, \begin{equation*} \begin{aligned} g_\bold{w}&\leq\sqrt{\log(eT)}\times \\ &\quad\sqrt{\frac{G^2}{\rho^2T}+\frac{2}{\rho}\left(\frac{G\sigma\sqrt{p}}{T}+\frac{M_\mathcal{W}\sigma\sqrt{p}}{\log(eT)}\right)p_\zeta'+\frac{\sigma^2p}{\rho T}p_\zeta'^2}, \end{aligned} \end{equation*} where $p_\zeta'=1+\big(\frac{8\log(T/\zeta)}{p}\big)^{1/4}$. Similarly, under Assumptions \ref{a1}, \ref{a2} and \ref{a5}, $g_\bold{v}$ shares the same property with high probability. Taking $\sigma$ given in Theorem \ref{the1} and omitting $\log(\cdot)$ terms, we have \begin{equation*} g_\bold{w},g_\bold{v}=\mathcal{O}\left(\sqrt{\frac{1}{T}+\frac{\sqrt{p}}{n\sqrt{T}\epsilon}+\frac{\sqrt{pT}}{n\epsilon}+\frac{\sqrt{p}}{n^2\epsilon^2}}\right). \end{equation*} If taking $T=\mathcal{O}(n^{2/3})$, then with high probability, we have $g_\bold{w},g_\bold{v}=\mathcal{O}\big(\frac{p^{1/4}}{n^{1/3}\epsilon^{1/2}}\big)$. \end{remark} \begin{remark}\label{rem4} Taking $\sigma$ in Theorem \ref{the2} and $T=\mathcal{O}(n^{2/3})$, then with high probability, we have $\gamma=\mathcal{O}\big(\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}}\big)$. Then we can answer the question left above, if we do not bound term $\|b_\bold{w}\|_2$ and $\|b_\bold{v}\|_2$ with $g_\bold{w},g_\bold{v}$, but `rudely' using $M_\mathcal{W}$ and $M_\mathcal{V}$, then the stability bound comes to \begin{equation*} \begin{aligned} \gamma&=\frac{4G}{n\rho}+\frac{2\sigma\sqrt{p}\log(eT)}{T}p_\zeta+4\sqrt{\log(eT)}\times \\ &\sqrt{\frac{G^2}{\rho^2T}+\frac{\sigma^2p}{\rho^2T}p_\zeta^2+\frac{2G\sigma\sqrt{p}}{\rho^2T}p_\zeta+\frac{\left(M_\mathcal{W}+M_\mathcal{V}\right)\sigma\sqrt{p}}{\rho\log(eT)}p_\zeta}. \end{aligned} \end{equation*} Under this condition, if we take $T=\mathcal{O}(n^{2/3})$ and Assumption \ref{a5} holds, the stability bound comes to $\gamma=\mathcal{O}\big(\frac{p^{1/4}}{n^{1/3}\epsilon^{1/2}}\big)$. Thus, by introducing $g_\bold{w}$ and $g_\bold{v}$, we improve the stability bound from $\mathcal{O}\big(\frac{1}{n^{1/3}}\big)$ to $\mathcal{O}\big(\frac{1}{n^{1/2}}\big)$. \end{remark} \subsection{5.2. Utility Bounds via Stability} In this section, we connect different generalization measures listed in Definition \ref{def1} with the argument stability and give corresponding risk bounds. \begin{theorem}\label{the3} With argument stability parameter $\gamma$, (a) If Assumptions \ref{a2} and \ref{a4} hold, then for all $\iota,\zeta>0$, with probability at least $1-\zeta$, the plain generalization error satisfies \begin{equation*} \begin{aligned} &L(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S))-\frac{1}{1-\iota}L_S(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)) \\ &\leq\sqrt{\frac{\left(G^2\gamma^2+64G^2n\gamma^2\log\left(3/\zeta\right)\right)}{2\left(1-\iota\right)^2n}\log\left(\frac{3}{\zeta}\right)} \\ &\quad+\frac{50\sqrt{2}eG\gamma\log(n)}{1-\iota}\log\left(\frac{3e}{\zeta}\right) \\ &\quad+\frac{\left(12+2\iota\right)M_\ell}{3\iota\left(1-\iota\right)n}\log\left(\frac{3}{\zeta}\right). \end{aligned} \end{equation*} (b) If Assumptions \ref{a1}, \ref{a2}, \ref{a3}, and \ref{a4} hold, then for all $\iota,\zeta>0$, with probability at least $1-\zeta$, the primal generalizaiton error staisfies \begin{equation*} \begin{aligned} &R\left(\mathcal{A}_\bold{w}(S)\right)-\frac{1}{1-\iota}R_S\left(\mathcal{A}_\bold{w}(S)\right) \\ &\leq\sqrt{\frac{\left(1+L/\rho\right)^2G^2\gamma^2\left(1+64n\log\left(3/\zeta\right)\right)}{2(1-\iota)^2n}\log\left(\frac{3}{\zeta}\right)} \\ &\quad+\frac{50\sqrt{2}\left(1+L/\rho\right)G\gamma\log(n)}{1-\iota}\log\left(\frac{3e}{\zeta}\right) \\ &\quad+\frac{(12+2\iota)M_\ell}{3\iota(1-\iota)n}\log\left(\frac{3}{\zeta}\right). \end{aligned} \end{equation*} (c) If Assumptions \ref{a1}, \ref{a2}, \ref{a3}, and \ref{a4} hold, then for all $\iota,\zeta>0$, with probability at least $1-\zeta$, the primal excess population risk satisfies \begin{equation*} \begin{aligned} &R\left(\mathcal{A}_\bold{w}(S)\right)-\frac{1+\iota}{1-\iota}\inf_{\bold{w}\in\mathcal{W}}R\left(\bold{w}\right) \\ &\leq\sqrt{\frac{\left(1+L/\rho\right)^2G^2\gamma^2\left(1+64n\log\left(6/\zeta\right)\right)}{2(1-\iota)^2n}\log\left(\frac{6}{\zeta}\right)} \\ &\quad+\sqrt{\frac{\left(G^2\gamma^2+64G^2n\gamma^2\log\left(6/\zeta\right)\right)}{2(1-\iota)^2n}\log\left(\frac{6}{\zeta}\right)} \\ &\quad+\frac{50\sqrt{2}\left(1+e+L/\rho\right)G\gamma\log(n)}{1-\iota}\log\left(\frac{6e}{\zeta}\right) \\ &\quad+\frac{(24+4\iota)M_\ell}{3\iota(1-\iota)n}\log\left(\frac{6}{\zeta}\right) \\ &\quad+\frac{1}{1-\iota}\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right). \end{aligned} \end{equation*} (d) If Assumptions \ref{a1}, \ref{a2}, \ref{a3}, and \ref{a4} hold, then for all $\iota,\zeta>0$, with probability at least $1-\zeta$, the strong primal dual population risk satisfies\footnote{For simplicity, we couple $\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right)$ and its expectation together here, since there is a `global' upper bound for strong PD emprical risk. More details are shown in Appendix A.3.} \begin{equation*} \begin{aligned} &\triangle^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right) \\ &\leq\frac{100\sqrt{2}e(1+\iota)(1+L/\rho)G\gamma\log(n)}{1-\iota}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\frac{144e(1+\iota)G^2}{\rho\iota(1-\iota)n}\log\left(\frac{e}{\zeta}\right)+\frac{8e(1+\iota)M_\ell}{n(1-\iota)}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\left(\frac{e\iota}{1-\iota}\log\left(\frac{e}{\zeta}\right)+1\right)\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right). \end{aligned} \end{equation*} \end{theorem} \begin{remark} For part (a), the plain generalization error is essentially analyzed via uniform stability, defined as the upper bound of $\ell\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S);z\right)-\ell\left(\mathcal{A}_\bold{w}(S'),\mathcal{A}_\bold{v}(S');z\right)$. If the loss function $\ell(\cdot,\cdot;\cdot)$ is $G$-Lipschitz (Assumption \ref{a2}), $\gamma$-argument stability derives $G\gamma$-uniform stability (details can be found in (\ref{eq32}) in Appendix A.3). Then the proof of part (a) is completed by the uniform stability of model $(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S))$. For parts (b), (c), and (d), argument stability is applied to get the claimed results. The proof can be found in Appendix A.3. \end{remark} We give the bound of $\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right)$ in the following and then discuss the results given in Theorem \ref{the3}. \begin{lemma}\label{lem9} If Assumptions \ref{a1} and \ref{a2} hold. Taking $\sigma$ given in Theorem \ref{the1}, and $\eta_t=\frac{1}{\rho t}$, then with probability at least $1-\zeta$ for $\zeta\in(\exp(-\frac{p}{8}),1)$, the strong primal dual empirical risk of the output of DP-GDA: $\mathcal{A}(S)=(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$ satisfies \begin{equation*} \begin{aligned} &\triangle_S^s\left(\bar{\bold{w}}_T,\bar{\bold{v}}_T\right) \\ &\leq \frac{G^2\log(eT)}{\rho T}+\frac{cG\left(g_\bold{w}+g_\bold{v}\right)\sqrt{Tp\log(1/\delta)}}{n\epsilon}p_\zeta \\ &\quad+cG^2\log(eT)\left(\frac{p\log(1/\delta)}{\rho n^2\epsilon^2}p_\zeta^2+\frac{2\sqrt{p\log(1/\delta)}}{\rho\sqrt{T}n\epsilon}p_\zeta\right), \end{aligned} \end{equation*} for some constant $c$, where $p_\zeta,g_\bold{w},g_\bold{v}$ are defined as in Theorem \ref{the2}. \end{lemma} The proof of Lemma \ref{lem9} is a vital part of Theorem \ref{the2}. For clarity, we give a brief sketch in Appendix A.4. Given the strong PD empirical risk $\triangle_S^s\left(\bar{\bold{w}}_T,\bar{\bold{v}}_T\right)$ and the argument stability parameter $\gamma$ of the output of DP-GDA: $(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$, we now give some discussions of Theorem \ref{the3} in Remark \ref{rem5}. \begin{remark}\label{rem5} Part (a) connects the argument stability with the plain generalization error, for the output of Algorithm \ref{alg1}, if taking $T=\mathcal{O}(n^{2/3})$, we have $\gamma=\mathcal{O}\left(\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}}\right)$ as discussed in Remark \ref{rem4}. Then plugging this result back into the plain generalization error, with high probability, we can bound $L(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$ by \begin{equation*} \frac{1}{1-\iota}\mathcal{O}\left(L_S(\bar{\bold{w}}_T,\bar{\bold{v}}_T)+\frac{p^{\frac{1}{4}}\log(n)}{n^{\frac{1}{2}}\epsilon^{\frac{1}{2}}}\right). \end{equation*} For a well trained model (with $n$ large enough), the empirical risk $L_S(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$ can be relatively small \cite{lever2013tighter,yang2019fast,cortes2021relative}. As a result, if $L_S(\bar{\bold{w}}_T,\bar{\bold{v}}_T)=\mathcal{O}\left(1/n^{1/2}\right)$, the plain generalization error along with the plain population risk can be bounded by $\mathcal{O}\left(\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}}\right)$ if $\log(\cdot)$ terms are omitted. Part (b) connects the argument stability with the primal generalization error. Like discussed above, taking $\gamma$ when $T=\mathcal{O}(1/n^{2/3})$, $R(\bar{\bold{w}}_T)$ can be bounded by \begin{equation*} \frac{1}{1-\iota}\mathcal{O}\left(R_S(\bar{\bold{w}}_T)+\frac{p^{\frac{1}{4}}\log(n)}{n^{\frac{1}{2}}\epsilon^{\frac{1}{2}}}\right) \end{equation*} with high probabilty. Thus, for well trained model, the primal generalization error along with the primal population risk can be bounded by $\mathcal{O}\left(\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}}\right)$. Part (c) connects the argument stability with the primal excess population risk. Here, we still taking $T=\mathcal{O}(1/n^{2/3})$. Under this circumstance, the strong PD empirical risk of $(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$ can be bounded by \begin{equation}\label{eq36} \mathcal{O}\left(\frac{p^{\frac{3}{4}}}{n\epsilon^{\frac{3}{2}}}+\frac{1}{n^{\frac{2}{3}}}\right). \end{equation} As a result, the primal excess population risk can be bounded by \begin{equation*} \frac{1}{1-\iota}\mathcal{O}\left(\frac{p^{\frac{1}{4}}}{n^{\frac{1}{2}}\epsilon^{\frac{1}{2}}}+\frac{p^{\frac{3}{4}}}{n\epsilon^{\frac{3}{2}}}+\frac{1}{n^{\frac{2}{3}}}+\inf_{\bold{w}\in\mathcal{W}}R(w)\right). \end{equation*} If $\inf_{\bold{w}\in\mathcal{W}}R(w)$ is smaller than the maximum value of the other three terms, the primal population risk can be bounded by \begin{equation*} \mathcal{O}\left(\max\left\{\frac{p^{\frac{1}{4}}}{n^{\frac{1}{2}}\epsilon^{\frac{1}{2}}},\frac{p^{\frac{3}{4}}}{n\epsilon^{\frac{3}{2}}},\frac{1}{n^{\frac{2}{3}}}\right\}\right). \end{equation*} Part (d) connects the argument stability with the strong PD population risk. Like discussed above, if we take $T=\mathcal{O}(1/n^{2/3})$, the strong PD empirical risk of $(\bar{\bold{w}}_T,\bar{\bold{v}}_T)$ shares the same property as in (\ref{eq36}), and the strong PD population risk can be bounded by \begin{equation*} \mathcal{O}\left(\max\left\{\frac{p^{\frac{1}{4}}}{n^{\frac{1}{2}}\epsilon^{\frac{1}{2}}},\frac{p^{\frac{3}{4}}}{n\epsilon^{\frac{3}{2}}},\frac{1}{n^{\frac{2}{3}}}\right\}\right). \end{equation*} \end{remark} \begin{remark}\label{rem7} Here, we discuss coefficient $\iota$ in Theorem \ref{the3}. We first explain why $\iota$ exists. The existence of $\iota$ is beacuse when decomposing term $\sqrt{L(\bold{w},\bold{v})/n}$, inequality $\sqrt{ab}\leq\iota a+b/\iota$ was applied. Then we have\footnote{We omit other terms here (such as $\log(1/\zeta)$ and $M_\ell$), details can be found in the Appendix.} $\sqrt{L(\bold{w},\bold{v})/n}\leq\iota L(\bold{w},\bold{v})+1/(\iota n)$. In this way, we decouple $n$ from the square root, in order to get sharper bounds when connecting stability with the generalization error (the improvement is from $\mathcal{O}(\sqrt{1/n})$ to $\mathcal{O}(1/n)$), especially when the model is well behaved, $L(\bold{w},\bold{v})$ is a small value. Besides, when it comes to analyzing sharp generalization error, $\iota$ commonly appears. For clarity, in the following, we represent the population risk and the empirical risk by $Pf$ and $P_nf$, respectively, like in \cite{bartlett2005local}. \cite{bartlett2005local} proposes the generalization error like $Pf\leq\mathcal{O}\big(\iota(\frac{1}{\iota-1}P_nf+r^*+\frac{\log(1/\zeta)}{n})\big)$; \cite{klochkov2021stability} proposes the generalization error like $Pf\leq\mathcal{O}\big((1+\iota)P_nf+\frac{\log(1/\zeta)}{\iota n}\big)$. These results are similar to ours by rearrangement, differences are caused by choosing different $\iota$. Results in the similar form include \cite{catoni2007pac}, \cite{lever2013tighter}, \cite{yang2019fast}, to mention but a few. When the machine learning model is well trained and the empirical risk is small, generalization error of this form is better \cite{bartlett2005local,lever2013tighter,yang2019fast,klochkov2021stability,cortes2021relative}. \end{remark} According to the property of the weak PD population risk, we can directly get the following corollary via Theorem \ref{the3}. \begin{table*}[t] \caption{Utility bounds of our proposed DP-GDA method.} \label{tab1} \vskip 0.15in \begin{center} \begin{small} \begin{sc} \begin{tabular}{ccccc} \toprule Generalization Measures & $\rho$ & $G$ & $L$ & Utility Bounds \\ \midrule Weak PD Population Risk / Generalization Error & $\surd$ & $\surd$ & $\surd$ & $\mathcal{O}\left(\max\left\{\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}},\frac{p^{3/4}}{n\epsilon^{3/2}},\frac{1}{n^{2/3}}\right\}\right)$ \\ Strong PD Population Risk / Generalization Error & $\surd$ & $\surd$ & $\surd$ & $\mathcal{O}\left(\max\left\{\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}},\frac{p^{3/4}}{n\epsilon^{3/2}},\frac{1}{n^{2/3}}\right\}\right)$ \\ Primal Excess Population Risk & $\surd$ & $\surd$ & $\surd$ & $\mathcal{O}\left(\max\left\{\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}},\frac{p^{3/4}}{n\epsilon^{3/2}},\frac{1}{n^{2/3}}\right\}\right)$ \\ Primal Population Risk / Generalization Error & $\surd$ & $\surd$ & $\surd$ & $\mathcal{O}\left(\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}}\right)$ \\ Plain Population Risk / Generalization Error & $\surd$ & $\surd$ & $\times$ & $\mathcal{O}\left(\frac{p^{1/4}}{n^{1/2}\epsilon^{1/2}}\right)$ \\ \bottomrule \end{tabular} \end{sc} \end{small} \end{center} \vskip -0.1in \end{table*} \begin{corollary}\label{cor1} With argument stability parameter $\gamma$, (a) Under the condition given in Theorem \ref{the3} part (d), the strong PD generalization error satisfies \begin{equation*} \begin{aligned} &\triangle^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right)-\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right) \\ &\leq\frac{100\sqrt{2}e(1+\iota)(1+L/\rho)G\gamma\log(n)}{1-\iota}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\frac{144e(1+\iota)G^2}{\rho\iota(1-\iota)n}\log\left(\frac{e}{\zeta}\right)+\frac{8e(1+\iota)M_\ell}{n(1-\iota)}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\frac{e\iota}{1-\iota}\log\left(\frac{e}{\zeta}\right)\mathbb{E}_S\left[\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right)\right]. \end{aligned} \end{equation*} (b) Under the condition given in Theorem \ref{the3} part (d), the weak primal dual population risk satisfies \begin{equation*} \begin{aligned} &\triangle^w\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right) \\ &\leq\frac{100\sqrt{2}e(1+\iota)(1+L/\rho)G\gamma\log(n)}{1-\iota}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\frac{144e(1+\iota)G^2}{\rho\iota(1-\iota)n}\log\left(\frac{e}{\zeta}\right)+\frac{8e(1+\iota)M_\ell}{n(1-\iota)}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\left(\frac{e\iota}{1-\iota}\log\left(\frac{e}{\zeta}\right)+1\right)\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right). \end{aligned} \end{equation*} (c) Under the condition given in Theorem \ref{the3} part (d), the weak PD generalization error satisfies \begin{equation*} \begin{aligned} &\triangle^w\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right)-\triangle_S^w\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right) \\ &\leq\frac{100\sqrt{2}e(1+\iota)(1+L/\rho)G\gamma\log(n)}{1-\iota}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\frac{144e(1+\iota)G^2}{\rho\iota(1-\iota)n}\log\left(\frac{e}{\zeta}\right)+\frac{8e(1+\iota)M_\ell}{n(1-\iota)}\log\left(\frac{e}{\zeta}\right) \\ &\quad+\left(\frac{e\iota}{1-\iota}\log\left(\frac{e}{\zeta}\right)+2\right)\triangle_S^s\left(\mathcal{A}_\bold{w}(S),\mathcal{A}_\bold{v}(S)\right). \end{aligned} \end{equation*} \end{corollary} Corollary \ref{cor1} can be easily extended from Theorem \ref{the3} part (d). For clarity, we give proof sketches in Appendix A.5. Meanwhile, the strong and weak PD generalization errors and the weak PD population risk share similar properties with the strong PD population risk given in Thorem \ref{the3} part (d), as discussed in Remark \ref{rem5}. \begin{remark}\label{rem6} By the discussions given in Remark \ref{rem5}, we find that the bottleneck of the generalization bounds is the injected random noise, rather than the analysis apporach itself. The reason is that we apply novel decomposition methods (motivated by \cite{klochkov2021stability}) and overcome the $\mathcal{O}(1/\sqrt{n})$ terms when connecting the stability with the generalization error. However, when it comes to DP paradigm, when analyzing $\gamma$, there exists term\footnote{We pay our attentions to the balance between $T$ and $n$ here and omit parameters $p,\epsilon$.} \begin{equation*} \mathcal{O}\left(\sqrt{\frac{\sqrt{T}}{n}\sqrt{\frac{1}{T}}}\right), \end{equation*} in which term $\sqrt{T}/n$ is derived from the standard deviation $\sigma$ of the random noise and term $\sqrt{1/T}$ is derived from the optimization error. Together with the discussions given before, in the minimax problem, it is hard to eliminate term $\|b\|_2$ because $\bold{w}$ differs when $\bold{v}$ changes. So the best result is $\mathcal{O}(1/\sqrt{n})$, under the setting of gradient perturbation concentrated by this paper, and this may give inspirations to other researchers on how to get better generalization performance in the DP-minimax condition. \end{remark} \section{6. Comparisons with Related Work} In this section, we compare our given bounds with previous related work. The generalization bounds under corresponding assumptions are listed in detail in Table \ref{tab1}, in which $\rho,G,L$ represents $\rho$-SC-SC, $G$-Lipschitz, and $L$-smooth, respectively. Considering there is no existed work analyzing the theoretical bounds for the general DP-minimax problem, so we only give our results in Table \ref{tab1}. \subsection{6.1. Non-DP General Minimax Setting} For the general minimax problem, DP has not been applied to the best of our knowledge so we compare our results with previous non-DP results \cite{farnia2021train,lei2021stability,zhang2021generalization}. Among them, \cite{zhang2021generalization} focuses on ESP and \cite{lei2021stability} focuses on SGDA and AGDA, so the only existed result for GDA is given in \cite{farnia2021train}, it is an $\mathcal{O}\big(1/n\big)$ primal generalization error for GDA in expectation. \subsection{6.2. DP-Minimax Settings} For DP-minimax settings, to the best of our knowledge, the theoretical results are only explicitly given for DP-AUC maximization: \cite{wang2021differentially} gives the expectation excess population risk bounds for DP-AUC maximization problems under output perturbation and objective perturbation methods. The results are of the orders $\mathcal{O}\big(\max\big\{p^{1/3}/(n\epsilon)^{2/3},1/\sqrt{n}\big\}\big)$ and $\mathcal{O}\big(\max\big\{\sqrt{p}/(\sqrt{n}\epsilon^2),1/n^{1/3}\big\}\big)$ for output and objective perturbations, respectively. Considering that it is hard to compare high probability bounds with expectation bounds, and the perturbation methods are different, we only list them here for comparisons. \cite{huai2020pairwise,yang2021stability} analyzes the high probability excess population risk for DP-AUC maximization problems under the pairswise learning paradigm, whose bounds are of the order $\mathcal{O}\big(\sqrt{p}/\sqrt{n}\epsilon\big)$. In this paper, corresponding generalization measure is the plain population risk, so our result is better than previous ones, by an order of $\mathcal{O}\big(p^{1/4}/\epsilon^{1/2}\big)$, considering $\epsilon$ is always set smaller than 1 for meaningful DP. \section{7. Conclusion} In this paper, we focus on the differential privacy of general minimax paradigm and propose DP-GDA. Except for the privacy guarantees, we analyze the stability of DP-GDA and connect it with the generalization performance. Furthermore, we give corresponding bounds under different generalization measures and compare them with previous works on differetially private particular minimax models, theoretical results show that our generalization bounds are better. We believe that our analysis and discussions will give inspirations to DP-minimax generalization performance researches. In future work, we will attempt to relax the assumptions needed in this paper, and overcome challenges brought by the injected random noise, in order to give sharper generalization bounds for general DP-minimax paradigm. \bibliographystyle{aaai}
{'timestamp': '2022-04-25T02:11:00', 'yymm': '2204', 'arxiv_id': '2204.04858', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04858'}
arxiv
\section{Topics covered in {\scshape NeuWS} dataset} The {\scshape NeuWS} dataset language is English and mainly focuses on U.S. political topics that often result in media bias. The top-5 most frequent topics are `Elections', `White House', `Politics', `Coronavirus', `Immigration'. The full list is as follow (in a descending order of frequency): [`Elections', `White House', `Politics', `Coronavirus', `Immigration', `Violence in America', `Economy and Jobs', `Supreme Court', `Middle East', `US House', `Healthcare', `World', `US Senate', `National Security', `Gun Control and Gun Rights', `Media Bias', `Federal Budget', `Terrorism', `US Congress', `Foreign Policy', `Criminal Justice', `Justice Department', `Trade', `Impeachment', `Donald Trump', `North Korea', `Russia', `Education', `Environment', `Free Speech', `FBI', nan, `Abortion', `General News', `Disaster', `US Military', `Technology', `LGBT Rights', `Sexual Misconduct', `Voting Rights and Voter Fraud', `Joe Biden', `Race and Racism', `Economic Policy', `Justice', `Holidays', `Taxes', `China', `Polarization', `Democratic Party', `Religion and Faith', `Sports', `Homeland Security', `Culture', `Cybersecurity', `National Defense', `Public Health', `Civil Rights', `Europe', `Great Britain', `Banking and Finance', `Republican Party', `NSA', `Business', `State Department', `Facts and Fact Checking', `Media Industry', `Labor', `Veterans Affairs', `Campaign Finance', `Life During COVID-19', `Transportation', `Marijuana Legalization', `Agriculture', `Arts and Entertainment', `Fake News', `Campaign Rhetoric', `Nuclear Weapons', `Israel', `Asia', `CIA', `Role of Government', `George Floyd Protests', "Women's Issues", `Safety and Sanity During COVID-19', `Animal Welfare', `Treasury', `Science', `Climate Change', `Domestic Policy', `Energy', `Housing and Homelessness', `Bridging Divides', `Mexico', `Inequality', `COVID-19 Misinformation', `ISIS', `Palestine', `Bernie Sanders', `Tulsi Gabbard', `Sustainability', `Family and Marriage', `Pete Buttigieg', `Welfare', `Opioid Crisis', `Amy Klobuchar', `Food', `EPA', `South Korea', `Alaska: US Senate 2014', `Social Security', `US Constitution', `Tom Steyer', `Andrew Yang', `Africa'] \section{Additional Salient Information Score Results} We report additional Salient information F1 (Table \ref{table:rouge_scores_f1}) and Recall (Table \ref{table:rouge_scores_recall}) scores for {\scshape Rouge1}, {\scshape Rouge2} and {\scshape RougeL}. \begin{table}[h] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{lccc} \toprule & \begin{tabular}[c]{@{}c@{}}{\scshape Rouge1} \\ {\scshape F1}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\scshape Rouge2} \\ {\scshape F1}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\scshape RougeL} \\ {\scshape F1}\end{tabular} \\ \midrule \textsc{Lexrank} & 33.60\% & 13.60\% & 29.77\% \\ \textsc{BartCNN} & 33.76\% & 13.67\% & 30.57\% \\ \textsc{PegasusMulti} & 30.03\% & 10.28\% & 26.70\% \\ \textsc{BartMulti} & 23.01\% & 6.84\% & 20.55\% \\ \textsc{NeuSFT} & 36.76\% & 16.27\% & 32.86\% \\ \midrule \textsc{NeuS-Title} & 35.49\% & 15.69\% & 32.05\% \\ \bottomrule \end{tabular}} \caption{Additional Salient Info Scores. F1 scores for {\scshape Rouge1}, {\scshape Rouge2} and {\scshape RougeL} for \textsc{AllSides}~testset. For the scores, the \textit{higher} number is the better.} \label{table:rouge_scores_f1} \end{table} \begin{table}[h] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{lccc} \toprule & \begin{tabular}[c]{@{}c@{}}{\scshape Rouge1} \\ {\scshape Recall}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\scshape Rouge2} \\ {\scshape Recall}\end{tabular} & \begin{tabular}[c]{@{}c@{}}{\scshape RougeL} \\ {\scshape Recall}\end{tabular} \\ \midrule \textsc{Lexrank} & 39.08\% & 17.66\% & 34.69\% \\ \textsc{BartCNN} & 35.63\% & 15.32\% & 32.22\% \\ \textsc{PegasusMulti} & 44.42\% & 16.99\% & 39.45\% \\ \textsc{BartMulti} & 35.76\% & 12.48\% & 32.08\% \\ \textsc{NeuSFT} & 35.11\% & 15.74\% & 31.43\% \\ \midrule \textsc{NeuS-Title} & 36.07\% & 16.47\% & 32.63\% \\ \bottomrule \end{tabular}} \caption{Additional Salient Info Scores. Recall scores for {\scshape Rouge1}, {\scshape Rouge2} and {\scshape RougeL} for \textsc{AllSides}~testset. For the scores, the \textit{higher} number is the better.} \label{table:rouge_scores_recall} \end{table} \section{Details for Human Evaluation (A/B testing)} The participants have different nationalities including Canada, China, Indonesia, Iran, Italy, Japan, Poland and South Korea (ordered in an alphabetical order). All of participants answered to be not having political leaning towards U.S. politics. All participants are fully explained on the usage of collected data in this particular work and agreed on it. The question we asked in human evaluation is as follow: ``Which one of the articles do you believe to be more biased toward one side or the other side in the reporting of news?'' This is modified to serve as a question for AB testing based on ``To what extent do you believe that the article is biased toward one side or the other side in the reporting of news?'' The original question is one of the 21 questions which are suitable and reliable for measuring the perception of media bias, designed by \citet{spinde2021you}. \section{Experimental Setup Details} All our experimental codes are based on the HuggingFace~\cite{wolf-etal-2020-transformers}. We used the following hyperparameters during training and across models: $10$ epoch size, $3e-5$ learning rate, and a batch size of $16$. We did not do hyper-parameters tuning since our objective is to provide various baselines and analysis. Training run-time for all of our experiments are fast ($<6$hr). We ran all experiments with one NVIDIA 2080Ti GPU with 16 GB of memory. The experiment was a single-run. \section{Generation Examples from Different Models} To help better understand performances of each models, we provide more examples of generation from all baseline models and our proposed models along with the target neutral headline summary. The examples can be found in Table \ref{appendix_table:generation_examples}. \section{Illustration of hallucinatory framing bias} In Table \ref{appendix_table:hallu_generation_examples}, we provide more examples of hallucinatory framing bias that was discussed in analysis. \label{sec:appendix_understanding_framing_bias} \begin{table*} \centering \small \resizebox{\linewidth}{!}{ \centering \begin{tabular}{p{15cm}} \toprule \textit{\textbf{Target:} The State Department has blocked Gordon Sondland, the U.S. Ambassador to the European Union, from testifying at a scheduled deposition on the Ukraine controversy. Sondland is a key figure as he had texted with Bill Taylor, a top U.S. diplomat in Ukraine, arguing over allegations of a quid pro quo. This move by the State Department has triggered a new clash with House Democrats as part of their impeachment inquiry, and President Trump has dismissed the deposition as a ``a kangaroo court'' as he defended the State Department decision.} \\ \midrule \midrule \textbf{\textsc{Lexrank}:} The Trump administration on Tuesday blocked a planned deposition from Gordon Sondland, the U.S. ambassador to the European Union and a central figure in the Democrats’ impeachment inquiry, according to a statement by his lawyer. Democrats swiftly called the administration’s move an act of \textcolor{black}{obstruction} and \textcolor{black}{accused} President Trump of \textcolor{black}{hiding} information about his efforts to pressure the Ukrainian government to investigate his \textcolor{black}{political} rivals. \\ \midrule \textbf{\textsc{BartCNN}:} The State Department instructed Ambassador to the European Union Gordon Sondland not to appear for the deposition, according to his counsel. Democrats swiftly called the administration’s move an act of \textcolor{black}{obstruction} and \textcolor{black}{accused} President Trump of \textcolor{black}{hiding} information about his efforts to pressure the Ukrainian government to investigate his \textcolor{black}{political} rivals. \\ \midrule \textbf{\textsc{PegasusMulti}:} \\ \midrule \textbf{\textsc{BartMulti}:} \\ \midrule \textbf{\textsc{NeuSFT}:} The Trump administration blocked a planned deposition from Gordon Sondland, the U.S. ambassador to the European Union and a central figure in the Democrats’ impeachment inquiry, according to a statement from his lawyer. President Trump responded via Twitter, saying that he ``would love to send Ambassador Sonderland, a really good man and great American, to testify, but \textcolor{black}{unfortunately} he would be testifying before a totally compromised kangaroo court, where Republican’s rights have been taken away, and true facts are not allowed out for the public to see.'' \\ \midrule \textbf{\textsc{NeuS-Title}:} TITLE=> State Dept Orders Ambassador Sondland Not to Testify Before House. ARTICLE=> The State Department has ordered Ambassador Gordon Stondland not to testify before the House of Representatives in the impeachment inquiry of President Donald Trump. Democrats have \textcolor{black}{accused} the Trump administration of blocking statements from witnesses. \\ \bottomrule \\ \toprule \textit{\textbf{Target:} The House Ways and Means Committee has requested that the IRS turn over the last six years of tax returns from President Trump.} \\ \midrule\midrule \textbf{\textsc{Lexrank}:} Representative Richard Neal invoked law that allows House Ways and Means Committee chair to obtain any person’s tax information. The request by House Democrats for six years of Donald Trump's tax returns opens a serious new \textcolor{black}{political}, legal, constitutional and personal front in the party's \textcolor{black}{battle} to use its new majority to check a \textcolor{black}{defiant} President. \\ \midrule \textbf{\textsc{BartCNN}:} Rep. Richard Neal invoked law that allows House Ways and Means Committee chair to obtain any person’s tax information. The request by House Democrats for six years of Donald Trump's tax returns opens a serious new political, legal, constitutional and personal front in the party's battle to use its new majority to check a defiant President. \\ \midrule \textbf{\textsc{PegasusMulti}:} \\ \midrule \textbf{\textsc{BartMulti}:} \\ \midrule \textbf{\textsc{NeuSFT}:} House Ways and Means Committee Chair Richard Neal (D-MA) has formally requested President Trump's tax returns from the IRS. \\ \midrule \textbf{\textsc{NeuS-Title}:} TITLE=> House Committee Seeks Trump Tax Returns. ARTICLE=> The House Ways and Means Committee formally requested President Trump’s tax returns on Wednesday, kicking off what could be a protracted legal fight between Congress and the Trump administration. \\ \bottomrule \end{tabular} } \caption{Neutral Summary Generation Examples from baseline models and \textsc{NeuS-Title}.} \label{appendix_table:generation_examples} \end{table*} \setcounter{table}{2} \begin{table*} \centering \small \resizebox{\linewidth}{!}{ \centering \begin{tabular}{p{15cm}} \toprule \textit{\textbf{Target:} Ukrainian police have opened an investigation into whether or not U.S. Ambassador Marie Yovanovitch came under surveillance before she was recalled from her post in Ukraine last May. Democrats have released documents that show Lev Parnas, an associate of Rudy Giuliani, communicating about Yovanovitch's removal.} \\ \midrule\midrule \textbf{\textsc{Lexrank}:} Ukraine’s government announced Thursday that police are investigating whether ousted U.S. ambassador Marie Yovanovitch was subject to \textcolor{black}{illegal} surveillance, in response to new documents released ahead of President Trump’s \textcolor{black}{impeachment} trial. Those documents, released by Democratic lawmakers, showed Lev Parnas -- an associate of Trump lawyer Rudy Giuliani -- communicating about the removal of Marie Yovanovitch as the ambassador to Ukraine. \\ \midrule \textbf{\textsc{BartCNN}:} Police in Ukraine have opened a criminal investigation into whether allies of President Trump had the U.S. ambassador to the country under surveillance. Newly released documents suggest that Ms. Yovanovitch was being watched in Kyiv. The Ministry of Internal Affairs of Ukraine says it's asking the FBI to help its inquiry. \\ \midrule \textbf{\textsc{PegasusMulti}:} \\ \midrule \textbf{\textsc{BartMulti}:} \\ \midrule \textbf{\textsc{NeuSFT}:} Ukraine's national police are investigating allegations that U.S. Ambassador Marie Yovanovitch was \textcolor{black}{subjected} to \textcolor{black}{illegal} surveillance while she was stationed in Kyiv. \\ \midrule \textbf{\textsc{NeuS-Title}:} TITLE=> Ukraine Opens Investigation Into Claims U.S. Ambassador Yovanovitch Was Under Surveillance. ARTICLE=> Ukraine's national police are investigating allegations that former U. S. ambassador Marie Yovanovich was \textcolor{black}{subjected} to surveillance while she was stationed in Kyiv, following the release of documents by Democratic lawmakers. \\ \bottomrule \end{tabular} } \caption{Continued from Previous Page: Neutral Summary Generation Examples from baseline models and \textsc{NeuS-Title}.} \label{appendix_table:generation_examples} \end{table*} \begin{table*}[t] \centering \small \resizebox{\linewidth}{!}{ \centering \begin{tabular}{p{15cm}} \toprule \textbf{[1] Source:} Newly released documents suggest that Ms. Yovanovitch was being watched in Kyiv while she was the U.S. ambassador there. The police in Ukraine have opened a criminal investigation into whether allies of President Trump had the United States ambassador to the country under surveillance while she was stationed in Kyiv, the Ukrainian government said on Thursday. [SEP] Ukraine’s government announced Thursday that police are investigating whether ousted U.S. ambassador Marie Yovanovitch was subject to illegal surveillance, in response to new documents released ahead of President Trump’s impeachment trial. Those documents, released by Democratic lawmakers, showed Lev Parnas -- an associate of Trump lawyer Rudy Giuliani -- communicating about the removal of Marie Yovanovitch as the ambassador to Ukraine. [SEP] Ukraine's national police are investigating allegations that U.S. Ambassador Marie Yovanovitch was under surveillance in Kyiv last spring — an allegation made in WhatsApp messages between a U.S. politician and Lev Parnas. ``Ukraine cannot ignore such illegal activities on the territory of its own state,'' the Ministry of Internal Affairs of Ukraine said in a statement Thursday. The ministry says it's asking the FBI to help its inquiry. \\ \midrule \textbf{[1] MDS Hallucination:} new documents released ahead of president trump's impeachment trial suggest that the us ambassador to the country was under surveillance while she was stationed in the country, the new york times reports. according to the wall street journal, the allegations were made in a text message between a us politician and an associate of trump lawyer rudy giuliani. in the messages, the politician says he'd like to see former ambassador to ukraine and current ambassador to russia, former deputy foreign minister oleksandr turchynov, removed from his post. ``i would like to remove him from his position,'' the politician wrote in the message, which was sent in april 2017. the messages were sent in response to newly released documents from the house intelligence committee. those documents show that former trump lawyer paul ryan had been trying to get rid of yovanovitch, who was ambassador at the time, for more than a year, the journal reports. the messages also show that ryan's chief of staff, george w. bush, had been in touch with ryan about removing her from her post. \\ \bottomrule \\\toprule \textbf{[2] Source:} ``If I threaten someone, you’ll know it,'' White House counselor Kellyanne Conway told reporters Friday morning in a bizarre hours-long effort to discredit an audio recording that seemingly showed her threatening to use West Wing resources to investigate the personal life of a reporter a day earlier. ``I never threatened anyone,'' Conway told a gaggle of journalists at the White House. ``Don’t use those words. I didn’t threaten. It’s not a threat. I never threatened her.'' [SEP] A tense phone conversation between a reporter for the Washington Examiner and White House senior counselor Kellyanne Conway was published by the newspaper on Thursday. In the conversation, Conway objected that a story written by the reporter, Caitlin Yilek, mentioned that her husband George Conway is a fierce critic of President Trump on Twitter. Yilek was writing a story on Conway possibly becoming President Trump's next White House chief of staff if Trump decides to move on from the official now in the position, Mick Mulvaney. [SEP] Kellyanne Conway defended her phone call with a Washington Examiner reporter during an appearance on Fox News. Fox News host Sandra Smith described the phone call Friday between reporter Caitlin Yilek and the counselor to the president as a "heated clash" during which things got ``very personal.'' Conway claimed, ``Everything I said in that phone call, I’ve said publicly before. Every single thing. I said it again.'' Smith asked Conway if there was anything she regretted about how she handled her phone call, which she denied. \\ \midrule \textbf{[2] MDS Hallucination:} a recording of a tense phone call between senior white house adviser and reporter catherine yilek was published by the washington examiner on friday, and it's not going over well. in the recording, yalek says she was told by the white house that she would be fired if she didn't back off from her reporting on president trump's controversial son-in-law, and that she'd have to go to court if she did not. ``i'm not going to do that,'' she says in the recorded conversation, per the new york times. ``you're going to get fired if you don't shut the f --- up.'' in the call, she also says she'll use the office of management and budget to investigate the personal life of the reporter. ``if i threaten someone, you'll know it,'' the caller can be heard saying in the audio recording, per politico. ``don ’ t use those words. it ’ s not a threat. i never threatened anyone.'' but on monday, white house counselor to the president katie holmes told fox news that she had never threatened the reporter. \\ \bottomrule \end{tabular} } \caption{Examples of hallucinatory framing bias from MDS models and the corresponding the source input.} \label{appendix_table:hallu_generation_examples} \end{table*} \section{Introduction} \label{sec:intro} Media framing bias occurs when journalists make skewed decisions regarding which events or information to cover (information bias) and how to cover them (lexical bias)~\cite{entman2002framing,groeling2013media}. Even if the reporting of the news is based on the same set of underlying issues or facts, the framing of that issue can convey a radically different impression of what actually happened~\cite{gentzkow2006media}. Since the news media plays a crucial role in shaping public opinion toward various important issues \cite{de2004effects, mccombs2009news, perse2016media}, bias in media reporting can reinforce the problem of political polarization and undermining civil society rights. Allsides.com~\cite{sides2018media} mitigates this problem by displaying articles from various media in a single interface along with an expert-written roundup of news articles. This roundup is a neutral summary for readers to grasp a bias-free understanding of an issue before reading individual articles. Although Allsides fights framing bias, scalability still remains a bottleneck due to the time-consuming human labor needed for composing the roundup. Multi-document summarization (MDS) models~\cite{lebanoff2018adapting,liu2019hierarchical} could be one possible choice for automating the roundup generation as both multi-document summaries and roundups share a similar nature in extracting salient information out of multiple input articles. Yet the ability of MDS models to provide \textit{neutral} description of a topic issue -- a crucial aspect of the roundup -- remains unexplored. \begin{figure} \centering \includegraphics[width=1\linewidth]{diagram.png} \caption{ Illustration of the proposed task. We want to generate neutral summarization of news articles from varying of political orientations. \colorbox{myorange}{Orange} highlights indicate phrases that can be considered framing bias.} \label{fig:intro_example} \end{figure} In this work, we fill in this research gap by proposing a task of \underline{Neu}tral multi-news \underline{S}ummarization ({\scshape NeuS}), which aims to generate a framing-bias-free summary from news articles with varying degrees and orientation of political bias (Fig.~\ref{fig:intro_example}). To begin with, we construct a new dataset by crawling Allsides.com, and investigate how framing bias manifests in the news so as to provide a more profound and more comprehensive analysis of the problem. The first important insight from our analysis is a close association between framing bias and the polarity of the text. Grounded on this basis, we propose a polarity-based framing-bias metric that is simple yet effective in terms of alignment with human perceptions. The second insight is that titles serve as a good indicator of framing bias. Thus, we propose {\scshape NeuS}~models that leverage news titles as an additional signal to increase awareness of framing bias. Our experimental results provide rich ideas for understanding the problem of mitigating framing bias. Primarily, we explore whether existing summarization models can already solve the problem and empirically demonstrate their shortcomings in addressing the stylistic aspect of framing bias. After that, we investigate and discover an interesting relationship between framing bias and hallucination, an important safety-related problem in generation tasks. We empirically show that the hallucinatory generation has the risk of being not only factually inaccurate and/or unverifiable but also politically biased and controversial. To the best of our knowledge, this aspect of hallucination has not been previously discussed. We thus hope to encourage more attention toward hallucinatory framing bias to prevent automatic generations from fueling political bias and polarization. We conclude by discussing the remaining challenges to provide insights for future work. We hope our work with the proposed {\scshape NeuS}~task serves is a good starting point to promote the automatic mitigation of media framing bias. \section{Related Works} \label{sec:related_works} \paragraph{Media Bias} Media bias has been studied extensively in various fields such as social science, economics, and political science. Media bias is known to affect readers' perceptions of news in three main ways: priming, agenda-setting, and framing\footnote{Priming happens when news reporting tells the reader what context of the event should they evaluate the event in; Agenda-setting is when news reporting tell readers what are the most important problems to think about}\cite{scheufele2000agenda}. Framing is a broad term that refers to any factor or technique that affect how individuals perceive certain reality or information~\cite{goffman1974frame, entman1993framing, entman2007framing, gentzkow2006media}. In the context of news reports, framing is about how an issue is characterized by journalists and how readers take the information to form their impression \cite{scheufele2007framing}. Our work specifically focuses on framing ``bias'' that exists as a form of text in the news. More specifically, we focus on different writing factors such as word choices and the commission of extra information that sway an individual's perception of certain events. \paragraph{Media Bias Detection} In natural language processing (NLP), computational approaches for detecting media bias often consider linguistic cues that induce bias in political text~\cite{recasens2013linguistic,yano2010shedding,lee2019team,morstatter2018identifying,lee2019team,hamborg2019illegal,lee2021unifying,bang2021assessing}. For instance, \citeauthor{gentzkow2010drives} count the frequency of slanted words within articles. These methods mainly focus on the stylistic (``how to cover'') aspect of framing bias. However, relatively fewer efforts have been made toward the informational (``what to cover'') aspect of framing bias~\cite{park2011contrasting,fan2019plain}. Majority of literature doing informational detection are focused on more general factual domain (non-political information) in the name of ``fact-checking''~\cite{thorne2018fever,lee2018improving,lee2021towards,lee2020language}. However, these methods cannot be directly applied to media bias detection because there does not exist reliable source of gold standard truth to fact-check biased text upon. \paragraph{Media Bias Mitigation} News aggregation, by displaying articles from different news outlets on a particular topic (e.g., Google News,\footnote{https://news.google.com/} Yahoo News\footnote{https://news.yahoo.com/}), is the most common approach to mitigate media bias~\cite{hamborg2019automated}. However, news aggregators require willingness and effort from the readers to be resistant to framing biases and identify the neutral fact from differently framed articles. Other approaches have been proposed to provide additional information~\cite{laban2017newslens}, such as automatic classification of multiple viewpoints~\cite{park2009newscube}, multinational perspectives~\cite{hamborg2017matrix}, and detailed media profiles~\cite{zhang2019tanbih}. However, these methods focus on providing a broader perspective to readers from an enlarged selection of articles, which still puts the burden of mitigating bias on the readers. Instead, we propose to automatically neutralize and summarize partisan articles to produce a neutral article summary. \paragraph{Multi-document Summarization} As a challenging subtask of automatic text summarization, multi-document summarization (MDS) aims to condense a set of documents to a short and informative summary \cite{lebanoff2018adapting}. Recently, researchers have applied deep neural models for the MDS task thanks to the introduction of large-scale datasets \cite{liu2018generating,fabbri2019multi}. With the advent of large pre-trained language models \cite{lewis2019bart,raffel2019exploring}, researchers have also applied them to improve the MDS models, performance~\cite{jin2020multi,pasunuru2021efficiently}. In addition, many works have studied particular subtopics of the MDS task, such as agreement-oriented MDS~\cite{pang2021agreesum}, topic-guided MDS~\cite{cui2021topic} and MDS of medical studies~\cite{deyoung2021ms2}. However, few works have explored generating framing-bias-free summaries from multiple news articles. To add to this direction, we propose the {\scshape NeuS}~task and creates a new benchmark. \begin{table*}[t] \centering \resizebox{0.85\linewidth}{!}{ \centering \begin{tabular}{c|p{15cm}} \toprule \multicolumn{2}{l}{\textbf{Issue A: Trump Put Hold On Military Aid To Ukraine Days Before Call To Ukrainian President}} \\ \multicolumn{2}{l}{Left: Trump ordered hold on military aid days before calling Ukrainian president, officials say} \\ \multicolumn{2}{l}{Right: Trump administration \colorbox{myorange}{\textcolor{black}{claims}} Ukraine aid was \colorbox{myorange}{\textcolor{black}{stalled} over \textcolor{black}{corruption concerns}, \textcolor{black}{decries} media \textcolor{black}{`frenzy'}}}\\ \multicolumn{2}{l}{Center: Trump Put Hold on Military Aid Ahead of Phone Call With Ukraine’s President} \\ \midrule \multicolumn{2}{l}{\textbf{Issue B: Michael Reinoehl appeared to target right-wing demonstrator before fatal shooting in Portland, police say}} \\ \multicolumn{2}{l}{Left: \colorbox{myorange}{\textcolor{black}{Suspect} in \textcolor{black}{killing} of right-wing \textcolor{black}{protester} \textcolor{black}{fatally shot} during \textcolor{black}{arrest} }} \\ \multicolumn{2}{l}{Right: \colorbox{myorange}{Portland's Antifa-supporting \textcolor{black}{gunman} appeared to target \textcolor{black}{victim}, police say}}\\ \multicolumn{2}{l}{Center: \colorbox{myorange}{Suspect in Patriot Prayer Shooting Killed by Police}} \\\midrule \multicolumn{2}{l}{\textbf{Issue C: Trump Says the `Fake News Media' Are `the true Enemy of the People'}} \\ \multicolumn{2}{l}{Left: President Trump \colorbox{myorange}{renews \textcolor{black}{attacks}} on press as `true \textcolor{black}{enemy} of the people' even as \colorbox{myorange}{CNN receives another \textcolor{black}{suspected bomb}}} \\ \multicolumn{2}{l}{Right: \colorbox{myorange}{`Great \textcolor{black}{Anger}'} in America caused by `fake news' — \colorbox{myorange}{Trump \textcolor{black}{rips} media for biased reports'}} \\ \multicolumn{2}{l}{Center: Trump \colorbox{myorange}{blames} 'fake news' \colorbox{myorange}{for country's anger}: 'the true enemy of the people'} \\ \bottomrule \end{tabular} } \caption{Illustration of \colorbox{myorange}{differences in framing} from Left/Right/Center media with examples from \textsc{AllSides}~dataset. We use titles for the analysis of bias, since they are simpler to compare and are representative of the framing bias that exists in the article.} \label{table:framing_bias_examples} \end{table*} \section{Task and Dataset} \label{sec:task_definition} \subsection{Task Formulation} The main objective of {\scshape NeuS}~is to generate a neutral article summary $A_{neu}$ given multiple news articles $A_{0...N}$ with varying degrees and orientations of political bias. The neutral summary $A_{neu}$ should (i) retain salient information and (ii) minimize as much framing bias as possible from the input articles. \subsection{\textsc{AllSides}~Dataset} \label{section:dataset} Allsides.com provides access to triplets of news, which comprise reports from left, right, and center American publishers on the same event, with an expert-written neutral summary of the articles and its neutral title. The dataset language is English and mainly focuses on U.S. political topics that often result in media bias. The top-3 most frequent topics\footnote{The full list is provided in the appendix.} are `Elections', `White House', and `Politics'. We crawl the article triplets\footnote{In some cases, Allsides does not provide all three reportings, and such cases are filtered out.} to serve as the source inputs $\{A_{L},A_{R},A_{C}\}$, and the neutral article summary to be the target output $A_{neu}$ for our task. Note that ``center'' does not necessarily mean completely bias-free~\cite{allsides_2021} as illustrated in Table~\ref{table:framing_bias_examples}. Although ``center'' media outlets are relatively less tied to a particular political ideology, their reports may still contain framing bias because editorial judgement naturally leads to human-induced biases. In addition, we also crawl the title triplets $\{T_{L},T_{R},T_{C}\}$ and the neutral issue title $T_{neu}$ that are later used in our modeling. To make the dataset richer, we also crawled other meta-information such as date, topic tags, and media name. In total, we crawled $3,564$ triplets ($10,692$ articles). We use 2/3 of the triplets, which is $2,276$, to be our training and validation set ($80:20$ ratio), and the remaining $1,188$ triples as our test set. We will publicly release this dataset for future research use. \section{Analysis of Framing Bias} \label{sec:case_study} The literature on media framing bias from the NLP community and social science studies provide the definition and types of framing bias \cite{goffman1974frame, entman1993framing, gentzkow2015media, fan2019plain} --- \textit{Informational framing bias} is the biased selection of information (tangential or speculative information) to sway the minds of readers. \textit{Lexical framing bias} is a sensational writing style or linguistic attributes that may mislead readers. However, the definition is not enough to understand exactly how framing bias manifests in real examples such as, in our case, the \textsc{AllSides}~dataset. We conduct a case-study to obtain concrete insights to guide our design choices for defining the metrics and methodology. \subsection{Case-Study Observations} First, we identify and share the examples of framing bias in accordance with the literature (Table~\ref{table:framing_bias_examples}). \paragraph{Informational Bias} This bias exists dominantly in the form of ``extra information'' on top of the salient key information about an issue that changes the overall impression of it. For example, in Table~\ref{table:framing_bias_examples}, when reporting about the hold put on military aid to Ukraine (Issue A), the right-leaning media reports the speculative claim that there were ``corruption concerns'' and tangential information ``decries media `frenzy''' that amplifies the negative impression of the issue. Sometimes, media with different political leanings report additional information to convey a completely different focus on the issue. For Issue C, left-leaning media implies that Trump's statement about fake news has led to ``CNN receiving another suspected bomb'', whereas right-leaning media implies that the media is at fault by producing ``biased reports''. \paragraph{Lexical Bias} This bias exists mainly as biased word choices that change the nuance of the information that is being delivered. For example, in Issue B, we can clearly observe that two media outlets change the framing of the issue by using different terms ``suspect'' and ``gunman'' to refer to the shooter, and ``protester'' and ``victim'' to refer to the person shot. Also, in Issue A, when one media outlet uses ``(ordered) hold'', another media uses ``stalled'', which has a more negative connotation. \subsection{Main Insights from Case-Study} Next, we share important insights from the case study observation that guide our metric and model design. \paragraph{Relative Polarity} Polarity is one of the commonly used attributes in identifying and analyzing framing bias~\cite{fan2019plain,recasens2013linguistic}. Although informational and lexical bias is conceptually different, both are closely associated with polarity changes of concept, i.e., positive or negative, to induce strongly divergent emotional responses from the readers~\cite{hamborg2019illegal}. Thus, polarity can serve as a good indicator of framing bias. However, we observe that the polarity of text must be utilized with care in the context of framing bias. \textit{It is the relative polarity that is meaningful to indicate the framing bias, not the absolute polarity}. To elaborate, if the news issue itself is about tragic events such as ``Terror Attack in Pakistan'' or ``Drone Strike That Killed 10 people'', then the polarity of neutral reporting will also be negative. \paragraph{Indicator of Framing} We discover that the news title is very representative of the framing bias that exist in the associated articles -- this makes sense because the title can be viewed as a succinct overview of the content that follows\footnote{There can be exceptions for the non-main-stream media that use clickbait titles.}. For instance, in Table~\ref{table:generation_examples} the source input example, the right-leaning media's title, and article are mildly mocking of the ``desperate'' democrats' failed attempts to take down President Trump. In contrast, the left-leaning media's title and an article show a completely different frame -- implying that many investigations are happening and there is ``possible obstruction of justice, public corruption, and other abuses of power.'' \section{Metric} \label{sec:metric} We use three metrics to evaluate summaries from different dimensions. For framing bias, we propose a polarity-based metric based on the careful design choices detailed in \S\ref{subsec:metric_bias}. For evaluating whether the summaries retain salient information, we adopt commonly used information recall metrics (\S\ref{subsec:metric_recall}). In addition, we use a hallucination metric to evaluate if the generations contain any unfaithful hallucinatory information because the existence of such hallucinatory generations can make the summary fake news (\S\ref{subsec:hallu}). \subsection{Framing Bias Metric} \label{subsec:metric_bias} \subsubsection{Design Consideration} Our framing bias metric is developed upon the insights we obtained from our case study in \S\ref{sec:case_study}. First of all, we propose to build our metric based on the fact that framing bias is closely associated with polarity. Both model-based and lexicon-based polarity detection approaches are options for our work, and we leverage the latter for the following reasons: 1) There is increasing demand for interpretability in the field of NLP~\cite{belinkov2020interpretability, sarker2019interpretable}, and the lexicon-based approach is more interpretable (provides token-level human interpretable annotation) compared to black-box neural models. 2) In the context of framing bias, distinguishing the subtle nuance of words between synonyms is crucial (e.g., dead vs. murdered). The lexicon-resource provides such token-level fine-grained scores and annotations, making it useful for our purpose. Metric calibration is the second design consideration, and is motivated by our insight into the relativity of framing bias. The absolute polarity of the token itself does not necessarily indicate framing bias (i.e., the word ``riot'' has negative sentiment but does not always indicate bias), so it is essential to measure the relative degree of polarity. Therefore, calibration of the metric in reference to the neutral target is important. Any tokens existing in the neutral target will be ignored in bias measurement for the generated neutral summary. For instance, if ``riot'' exists in the neutral target, it will not be counted in bias measurement through calibration. \subsubsection{Framing Bias Metric Details} For our metric, we leverage Valence-Arousal-Dominance (VAD)~\cite{mohammad2018obtaining} dataset which has a large list of lexicons annotated for valence ($v$), arousal ($a$) and dominance ($d$) scores. Valence, arousal, and dominance represent the direction of polarity (positive, negative), the strength of the polarity (active, passive), and the level of control (powerful, weak), respectively. Given the neutral summary generated from the model $\hat{A}_{neu}$, our metric is calculated using the VAD lexicons in the following way: \begin{enumerate}[noitemsep] \item Filter out all the tokens that appear in neutral target $A_{neu}$ to obtain set of tokens \textit{unique} to $\hat{A}_{neu}$. This ensures that we are measuring the \textit{relative} polarity of $\hat{A}_{neu}$ in reference to the neutral target $A_{neu}$ -- results in calibration effect. \item Select tokens with either positive valence ($v > 0.65$) or negative valence ($v < 0.35$) to eliminate neutral words (i.e., stopwords and non-emotion-provoking words) -- this step excludes tokens that are unlikely to be associated with framing bias from the metric calculation. \item Sum the arousal scores for the identified positive and negative tokens from Step 2 -- positive arousal score ($Arousal_{+}$) and negative arousal score ($Arousal_{-}$). We intentionally separate the positive and negative scores for finer-grained interpretation. We also have the combined arousal score ($Arousal_{sum}$=$Arousal_{+}$+$Arousal_{-}$) for a coarse view. \item Repeat for all \{$A_{neu}$, $\hat{A}_{neu}$\} pairs in the testset, and calculate the average scores to use as the final metric. We report these scores in our experimental results section (\S\ref{sec:results_and_analysis}). \end{enumerate} \textit{In essence, our metric approximates the existence of framing bias by quantifying how intensely aroused and sensational the generated summary is in reference to the target neutral reference.} We publicly release our metric code for easy use by other researchers\footnote{https://github.com/HLTCHKUST/framing-bias-metric}. \subsubsection{Human Evaluation} To ensure the quality of our metric, we evaluate the correlation between our framing bias metric and human judgement. We conduct A/B testing\footnote{Please refer the appendix for more detail of the A/B testing} where the annotators are given two generated articles about an issue, one with a higher $Arousal_{sum}$~score and the other with a lower score. Then, annotators are asked to select the more biased article summary. When asking which article is more ``biased'', we adopt the question presented by \citeauthor{spinde2021you} We also provide examples and the definition of framing bias for a better understanding of the task. We obtain three annotations each for $50$ samples and select those with the majority of votes. A critical challenge of this evaluation is in controlling the potential involvement of the annotators' personal political bias. Although it is hard to eliminate such bias completely, we attempt to avoid it by collecting annotations from those indifferent to the issues in the test set. Specifically, given that our test set mainly covers US politics, we restrict the nationality of annotators to non-US nationals who view themselves bias-free towards any US political parties. After obtaining the human annotations from A/B testing, we also obtain automatic annotation based on the proposed framing bias metric score, where the article with a higher $Arousal_{sum}$~is chosen to be the more biased generation. The Spearman correlation coefficient between human-based and metric-based annotations is 0.63615 with a p-value < 0.001, and the agreement percentage $80\%$. These values indicate that the association between the two annotations is statistically significant, suggesting that our metric provides a good approximation of the existence of framing bias. \subsection{Salient Info} \label{subsec:metric_recall} The generation needs to retain essential/important information while reducing the framing bias. Thus, we also report {\scshape Rouge}~\cite{lin2004rouge} and {\scshape Bleu}~\cite{papineni2002bleu} between the generated neutral summary, $\hat{A}_{neu}$, and human-written summary, $A_{neu}$. Note that {\scshape Rouge} measures the recall (i.e., how often the n-grams in the human reference text appear in the machine-generated text) and {\scshape Bleu}~measures the precision (i.e., how often the n-grams in the machine-generated text appear in the human reference text). The higher the {\scshape Bleu}~and {\scshape Rouge1-R}~score, the better the essential information converges. In our results, we only report Rouge-1, but Rouge-2 and Rouge-L can be found in the appendix. \subsection{Hallucination Metric} \label{subsec:hallu} Recent studies have shown that neural sequence models can suffer from the hallucination of additional content not supported by the input~\cite{reiter2018structured,wiseman-etal-2017-challenges,nie2019simple, maynez-etal-2020-faithfulness,pagnoni2021understanding,ji2022survey}, consequently adding factual inaccuracy to the generation of NLG models. Although not directly related to the goal of {\scshape NeuS}, we evaluate the hallucination level of the generations in our work. We choose a hallucination metric called FeQA~\cite{durmus-etal-2020-feqa} because it is one of the publicly available metrics known to have a high correlation with human faithfulness scores. This is a question-answering-based metric built on the assumption that the same answers will be derived from hallucination-free generation and the source document when asked the same questions. \begin{table*} \centering \resizebox{0.85\linewidth}{!}{ \begin{tabular}{lccc|cc|c} \toprule & \multicolumn{3}{c|}{\textbf{Avg. Framing Bias Metric}} & \multicolumn{2}{c|}{\textbf{Salient Info}} & \textbf{Hallucination} \\ \cmidrule{2-7} \multirow{-2}{*}{\textbf{Models}} & $Arousal_{+}$ $\downarrow$ & $Arousal_{-}$ $\downarrow$ & $Arousal_{sum}$ $\downarrow$ & {\scshape Bleu} $\uparrow$ & {\scshape Rouge1-R} $\uparrow$ & FeQA $\uparrow$ \\ \midrule All Source input & 6.76 & 3.64 & 10.40 & 8.27 & 56.57\% & - \\ \midrule \textsc{Lexrank} & 3.02 & 1.74 & 4.76 & \textbf{12.21} & 39.08\% & 53.44\% \\ \textsc{BartCNN} & 2.09 & 1.23 & 3.32 & 10.49 & 35.63\% & 58.03\% \\ \textsc{PegasusMulti} & 5.12 & 2.39 & 7.51 & 6.12 & \textbf{44.42\%} & 22.24\% \\ \textsc{BartMulti} & 5.94 & 2.66 & 8.61 & 4.24 & 35.76\% & 21.06\% \\ \textsc{NeuSFT} & 1.86 & 1.00 & 2.85 & 11.67 & 35.11\% & \textbf{58.50\%} \\ \midrule \textsc{NeuS-Title} & \textbf{1.69} & \textbf{0.83} & \textbf{2.53} & 12.05 & 36.07\% & 45.95\% \\ \bottomrule \end{tabular}} \caption{Experimental results for \textsc{AllSides}~test set. We provide the level of framing bias inherent in ``source input'' from the \textsc{AllSides}~test set to serve as a reference point for the framing bias metric. For framing bias metric, the \textit{lower} number is the better ($\downarrow$). For other scores, the \textit{higher} number is the better ($\uparrow$).} \label{table:main_result} \end{table*} \section{Models and Experiments\footnote{Experimental details are provided in the appendix for reproducibility.}} \label{sec:experiment} \subsection{Baseline Models} Since one common form of framing bias is the reporting of extra information (\S\ref{sec:case_study}), summarization models, which extract commonly shared salient information, may already generate a neutral summaries to some extent. To test this, we conduct experiments using the following baselines. \begin{itemize}[noitemsep] \item \textsc{Lexrank}~\cite{erkan2004lexrank}: an extractive single-document summarization (SDS) model that extracts representative sentences that hold information common in both left- and right-leaning articles. \item \textsc{BartCNN}: an abstractive SDS model that fine-tunes BART-large~\cite{lewis2019bart}, with 406M parameters, using the CNN/DailyMail~\cite{hermann2015teaching} dataset. \item \textsc{BartMulti}: a multi-document summarization (MDS) model that fine-tunes BART-large using Multi-News~\citep{fabbri2019multi} dataset. \item \textsc{PegasusMulti}: an MDS model that fine-tunes Pegasus-base~\cite{zhang2019pegasus}, with 568M parameters, using the Multi-News dataset. \end{itemize} \noindent Since the summarization models are not trained with in-domain data, we provide another baseline model trained with in-domain data for a full picture. \begin{itemize}[noitemsep] \item \textsc{NeuSFT}: a baseline that fine-tunes the BART-large model using \textsc{AllSides}. \end{itemize} \subsection{Our {\scshape NeuS}~Models (\textsc{NeuS-Title})} We design our models based on the second insight from the case study (\S\ref{sec:case_study}) - the news title serves as an indicator of the framing bias in the corresponding article. We hypothesize that it would be helpful to divide-and-conquer by neutralizing the the title first, then leveraging the ``neutralized title'' to guide the final neutral summary of the longer articles. Multi-task learning (MTL) is a natural modeling choice because two sub-tasks are involved -- title-level and article-level neutral summarization. Meanwhile, we also have to ensure a hierarchical relationship between the two tasks in our MTL training because article-level neutral summarization leverages the generated neutral title as an additional resource. We use a simple technique to do hierarchical MTL by formatting our hierarchical data pair (title, article) in a single natural language text with identifier-tokens (``Title=>'', ``Article=>''). This technique allows us to optimize for both title and article neutral summarization tasks easily by optimizing for the negative log-likelihood of the single target Y. The auto-regressive nature of the decoder also ensures the hierarchical relationship between the title and article. We train BART's autoregressive decoder to generate the target text $Y$ formatted as follows: \begin{align*} \texttt{TITLE}\Rightarrow T_{neu}. \ \texttt{ARTICLE}\Rightarrow A_{neu}, \end{align*} where $T_{neu}$~and $A_{neu}$ denote the neutral title and neutral article summary. The input $X$ to our BART encoder is formatted similarly to the target text $Y$: \begin{align*} &\texttt{TITLE}\Rightarrow T_{L}. \ \texttt{ARTICLE}\Rightarrow A_{L}. [SEP] \\ &\texttt{TITLE}\Rightarrow T_{C}. \ \texttt{ARTICLE}\Rightarrow A_{C}. [SEP] \\ &\texttt{TITLE}\Rightarrow T_{R}. \ \texttt{ARTICLE}\Rightarrow A_{R}, \ \end{align*} where $T_{L/C/R}$~and $A_{L/C/R}$ denote the title and article from left-wing, center, and right-wing media, and [SEP] denotes the special token that separates different inputs. Note that the order of left, right, and center are randomly shuffled for each sample to discourage the model from learning spurious patterns from the input. \begin{table*}[t] \centering \small \resizebox{\linewidth}{!}{ \centering \begin{tabular}{p{15cm}} \toprule \textbf{SOURCE:} \textbf{<Left>} \textbf{Title:} Here Are The 81 People And Entities Close To Trump Democrats Are Investigating. \textbf{Article:} Democrats on the House Judiciary Committee on Monday sent document requests to 81 agencies, entities and individuals close to President Donald Trump as part of a broad investigation into possible obstruction of justice, public corruption and other abuses of power. The list includes Trump’s sons, Eric Trump and Donald Trump Jr., as well as his son-in-law, Jared Kushner. \textbf{<Center>} \textbf{Title:} House Panel Requests Documents From Associates of Trump. \textbf{Article:} House Democrats intensified their investigations into President Trump and his associates Monday, demanding records from more than 80 people and organizations related to his business dealings, interactions with the Justice Department and communications with Russian President Vladimir Putin. \textbf{<Right>} \textbf{Title:} Dems Continue Their Assault on The Trump Administration By Launching Another Probe. \textbf{Article:} Democrats are desperate to take down President Donald Trump. The Russia probe has proven to be ineffective and, quite frankly, a waste of time and taxpayer money. They didn't find what they wanted so now they're launching another probe. \\\midrule \textbf{TARGET:} House Democrats launched a broad probe into President Trump on Monday, requesting documents from 81 agencies and individuals as they investigate his business dealings, interactions with Russia, and possible obstruction of justice. \\ \midrule \midrule \textbf{Lexrank:} Democrats are \textcolor{red}{desperate} to take \textcolor{red}{down} President Donald Trump. The Russia probe has proven to be \textcolor{red}{ineffective} and, quite frankly, a \textcolor{red}{waste} of time and taxpayer money. \\ \midrule \textbf{\textsc{NeuSFT}:} The Russia probe has proven to be \textcolor{red}{ineffective} and, quite frankly, a \textcolor{red}{waste} of time and taxpayer money. \\ \midrule \textbf{\textsc{NeuS-Title}:} TITLE=> House Panel Requests Documents. ARTICLE=> The House Select Committee on Intelligence has requested documents from 81 people and entities \textcolor{red}{close} to President Trump, including his sons Eric and Donald Trump Jr., as well as Jared Kushner. \\ \bottomrule \end{tabular} } \caption{Generation examples for analysis purposes. \textcolor{red}{Red} highlights the tokens identified by VAD lexicons. Refer to the appendix for more examples.} \label{table:generation_examples} \end{table*} \begin{table*}[t] \centering \small \resizebox{\linewidth}{!}{ \centering \begin{tabular}{p{15cm}} \toprule \textbf{SOURCE:} ... President Trump on Saturday blasted what he called the ``phony'' BuzzFeed story and the mainstream media’s coverage of it.... \\ \midrule \textbf{MDS Hallucination:} president trump on sunday slammed what he called called a ``phony'' story by the \colorbox{myorange}{``dishonest'' and ``fake news'' news outlet} in a series of tweets. ... \colorbox{myorange}{``the fake news media is working overtime to make} \colorbox{myorange}{this story look like it is true,'' trump tweeted. ``they are trying to make it look like the president is trying to hide} \colorbox{myorange}{something, but it is not true!''} \\ \bottomrule \end{tabular} } \caption{Illustration of \colorbox{myorange}{hallucinatory framing bias} from MDS models and the corresponding ``most relevant source snippet'' from the source input. Refer to the appendix for more examples with full context.} \label{table:hallucination_examples} \end{table*} \section{Results and Analysis} \label{sec:results_and_analysis} In this section, we point out noteworthy observations from the quantitative results in Table~\ref{table:main_result} along with insights obtained through qualitative analysis. Table~\ref{table:generation_examples} shows generation examples that are most representative of the insights we share.\footnote{More examples are provided in the appendix.} \subsection{Main Results} Firstly, summarization models can reduce the framing bias to a certain degree (drop in $Arousal_{sum}$~score from 10.40 to 4.76 and 3.32 for \textsc{Lexrank}~and \textsc{BartCNN}). This is because informational framing bias is addressed when summarization models extract the most salient sentences, which contain common information from the inputs. However, summarization models, especially \textsc{Lexrank}~cannot handle the lexical framing bias, as shown in Table~\ref{table:generation_examples}. Moreover, if we further observe the results of \textsc{Lexrank}, it is one of the best performing models in terms of {\scshape Rouge1-R}~($39.08\%$), the standard metric for summarization performance, but not in terms of the framing bias metric. This suggests that \textit{having good summarization performance ({\scshape Rouge1-R}) does not guarantee that the model is also neutral} -- i.e., the requirement for summaries to be neutral adds an extra dimension to the summarization task. Secondly, one interesting pattern that deserves attention is that only the single-document summarization models (\textsc{BartCNN}~and \textsc{Lexrank}) reduced framing bias well, not the multi-document summarization models (\textsc{PegasusMulti}~and \textsc{BartMulti}). This is rather surprising because our task setup is more similar to MDS than SDS. One of the major contributors to high bias in the MDS models is probably the hallucination because MDS models portray drastically poor hallucination performance than all the other models (both the MDS models \textsc{PegasusMulti}~and \textsc{BartMulti}~achieve 22.24\% and 21.06\%, when most of the other models achieve over 50\%).\footnote{Note that 22.24\% and 21.06\% are already high FeQA scores, however, a comparatively low score in reference.} This suggests that the framing bias of MDS models may be related to the hallucination of politically biased content. We investigate into this in the next subsection (\S\ref{subsection:further_analysis}). Thirdly, although summarization models help reduce the framing bias scores, we, unsurprisingly, observe a more considerable bias reduction when training with in-domain data. \textsc{NeuSFT}~shows a further drop across all framing bias metrics without sacrificing the ability to keep salient information. However, we observe that \textsc{NeuSFT}~often copies directly without any neutral re-writing -- e.g., the \textsc{NeuSFT}~example shown in Table~\ref{table:generation_examples} is a direct copy of the sentence from the input source. Lastly, we can achieve slightly further improvement with \textsc{NeuS-Title}~across all metrics except the FeQA~score. This model demonstrates a stronger tendency to paraphrase rather than directly copy, and has comparatively more neutral framing of the issue. As shown in Table~\ref{table:generation_examples}, when \textsc{Lexrank}~and \textsc{NeuSFT}~are focused on the ``ineffectiveness of Russia probe'', the TARGET and \textsc{NeuS-Title}~focus on the start of the investigation with the request for documents. \textsc{NeuS-Title}~also generate a title with a similar neutral frame to the TARGET, suggesting this title generation guided the correctly framed generation. \subsection{Further Analysis and Discussion} \label{subsection:further_analysis} \paragraph{Q: Is hallucination contributing to the high framing bias in MDS models?} Through qualitative analysis, we discovered the MDS generations were hallucinating politically controversial or sensational content that did not exist in the input sources. This is probably originating from the memorization of either the training data or the LM-pretraining corpus. For instance, in Table~\ref{table:hallucination_examples}, we can observe stylistic bias being injected -- ``the `dishonest' and `fake news' news outlet''. Also, the excessive elaboration of the president's comment towards the news media, which does not appear the in source or target, can be considered informational bias -- ``they are trying to make it look like the president is trying to hide something, but it is not true!'' \textit{This analysis unveils the overlooked danger of hallucination, which is the risk of introducing political framing bias in summary generations.} Note that this problem is not confined to MDS models only because other baseline models also have room for improvement in terms of the FeQA~hallucination score. \noindent \paragraph{Q: What are the remaining challenges and future directions?} The experimental results of \textsc{NeuS-Title}~suggest that there is room for improvement. We qualitatively checked some error cases and discovered that the title-generation is, unsurprisingly, not always accurate, and the error propagating from the title-generation step adversely affected the overall performance. Thus, one possible future direction would be to improve the neutral title generation, which would then improve the neutral summarization. Another challenge is the subtle lexical bias involving nuanced word choices that manoeuvre readers to understand the events from biased frames. For example, ``put on hold'' and ``stalled'' both mean the same outcome, but the latter has a more negative connotations. Improving the model's awareness of such nuanced words or devising ways to incorporate style-transfer-based bias mitigation approaches~\cite{liu2021mitigating} could be another helpful future direction. We started the neutral summarization task assuming that framing bias originates from the source inputs. However, our results and analysis suggest that hallucination is another contributor to framing bias. Leveraging hallucination mitigation techniques would be a valuable future direction for the {\scshape NeuS}~task. We believe it will help to reduce informational framing bias, although it may be less effective to lexical framing biases. Moreover, our work can also be used to facilitate hallucination research as well. We believe the proposed framing bias metric will help researchers evaluate hallucinatory phenomena from different angles other than ``factuality''. The proposed framing bias metric could also be adapted to the hallucination problem without a ``neutral'' reference. The source input can substitute the ``neutral'' reference to measure if the generated summary is more politically biased than the source -- a potential indication of political hallucination. \section{Conclusion} \label{sec:conclusion} We introduce a new task of Neutral Multi-News Summarization ({\scshape NeuS}) to mitigate media framing bias by providing a neutral summary of articles, along with the dataset \textsc{AllSides}~and a set of metrics. Throughout the work, we share insights to understand the challenges and future directions in the task. We show the relationships among polarity, extra information, and framing bias, which guides us to the metric design, while the insight that the title serves as an indicator of framing bias leads us to the model design. Our qualitative analysis reveals that hallucinatory content generated by models may also contribute to framing bias. We hope our work stimulates researchers to actively tackle political framing bias in both human-written and machine-generated texts. \section*{Ethical Considerations} \label{sec:ethical_considerations} The idea of unbiased journalism has always been challenged\footnote{https://www.allsides.com/blog/does-unbiased-news-really-exist} because journalists will make their own editorial judgements that can never be guaranteed to be completely bias-free. Therefore, we propose to generate a comprehensive summary of articles from different political leanings, instead of trying to generate a gold standard ``neutral'' article. One of the considerations is the bias induced by the computational approach. Automatic approaches replace a known source bias with another bias caused by human-annotated data or the machine learning models. Understanding the risk of uncontrolled adoption of such automatic tools, careful guidance should be provided in how to adopt them. For instance, an automatically generated neutral summary should be provided with reference to the original source instead of standing alone. We use news from English-language sources only and largely American news outlets throughout this paper. Partisanship from this data refers to domestic American politics. We note that this work does not cover media bias at the international-level or in other languages. In future work, we will explore the application of our methodology to different cultures or languages. However, we hope the paradigm of {\scshape NeuS}, providing multiple sides to neutralize the view of an issue, can encourage future research in mitigating framing bias in other languages or cultures.
{'timestamp': '2022-05-04T02:17:50', 'yymm': '2204', 'arxiv_id': '2204.04902', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04902'}
arxiv
\section{Introduction} Reinforcement Learning (RL) has shown impressive performance in various fields including game \cite{silver2017mastering,vinyals2019grandmaster,badia2020agent57}, chip placement \cite{mirhoseini2021graph}, energy \cite{deepmind2016reduces}, recommendation \cite{afsar2021reinforcement}, robotics \cite{finn2016deep,nair2018visual} and many others. Therefore, RL has been actively researched on both academic and industrial fields lately. Following this trend, several RL frameworks have been released recently. For the researchers and students who study RL, the algorithms and environments of RL framework should be customizable to develop their research. For the user, who is not a RL expert and wants to use RL framework for industrial problem, the RL framework should be easy to use and be able to add new industrial environments. Accordingly, there has been a growing demand for a RL framework that can be easily used and customized. There are some RL frameworks \cite{baselines, plappert2016kerasrl, liang2017ray, hoffman2020acme, weng2021tianshou, fujita2021chainerrl} opened for the users who wants to study or use RL algorithms. However, Some frameworks have problems that hinder usability or convenience for the users. First, it is difficult to modify or add RL algorithms or environments in most of the frameworks. If there are restrictions on the modification of the environment or algorithm, it is difficult to conduct more advanced research based on the framework. Second, some of the frameworks such as \cite{baselines}, \cite{plappert2016kerasrl} provide less number of the algorithms than JORLDY or do not provide latest RL algorithms. Third, many existing frameworks such as \cite{baselines}, \cite{plappert2016kerasrl}, \cite{weng2021tianshou}, \cite{fujita2021chainerrl} don't provide distributed training for RL. Recently, great performance improvement can be conducted for RL algorithm with applying distributed training, so most of state-of-the-art RL algorithms have distributed training structure. Therefore, it is important for RL frameworks to support distributed training. For these reasons, we propose a new open source RL framework "Join Our Reinforcement learning framework for Developing Yours" (JORLDY). JORLDY is named after Jordy, one of the Niniz character of the Kakao corporation which is illustrated in Figure 1. As the full name suggests, we expect RL users to further develop their own research through the proposed framework. \begin{figure} \centering \includegraphics[width=9cm]{Images/1_jorldy.png} \caption{Niniz character Jordy of Kakao Corp.} \label{fig:fig1} \end{figure} JORLDY framework provides more than 20 RL algorithms from basic to advanced algorithms. The algorithms consist of various kinds of RL algorithms such as value-based, policy-based, actor-critic, distributional and distributed structure algorithms. Each RL algorithm consists of some components: agent, network, buffer and optimizer. All the components of RL algorithms are fully customizable, so users can modify the existing algorithms and develop new RL algorithms based on the provided RL algorithms of JORLDY. Also, all the components can be freely combined with each other, so various implementations are possible. Moreover, JORLDY provides various distributed architecture using Ray \cite{moritz2018ray}, so it can support RL algorithms that have distributed training process. The RL algorithms are implemented using Python with deep learning library Pytorch \cite{paszke2019pytorch}. Also, JORLDY supports various existing RL environments such as OpenAI gym \cite{brockman2016openai}, Arcade Learning Environment (ALE) \cite{machado18arcade}, Gym Super Mario Bros \cite{gym-super-mario-bros}, Procgen \cite{cobbe2019procgen} and MuJoCo \cite{todorov2012mujoco}. For the diversity of the RL environments, some of the custom environments made with Unity ML-Agents toolkit \cite{juliani2018unity} are provided. Any environments can be applied if they set to a specified format for JORLDY. Because of this characteristic, it is expected that RL can be applied to not only games but also various industrial environments through JORLDY. Lastly, JORLDY considers usability that non RL expert can use RL without difficulties. Therefore, the provided RL algorithms and environments can be easily connected and run with single line of command. The main features of JORLDY are as follows: \begin{itemize} \item More than 20 RL algorithms and various RL environment are provided \item The RL components (i.e. network, agent, buffer) and environments can be added and fully customized \item Various combination of the RL components can be simply conducted \item All the provided algorithms and environments can be run with a simple command \item Various distributed architecture for RL algorithms are supported using Ray \item Benchmark of the algorithms is conducted in many RL environment \end{itemize} The rest of this paper is constructed as follows: Section 2 describes overall structure and each component of JORLDY. Section 3 describes the features of JORLDY. About usability, customizability, distributed architecture and benchmark of JORLDY is explained in this section. In section 4, we conclude this paper. \section{Structure of JORLDY} The overall structure of JORLDY is shown in Figure 2. In this section, all the components of JORLDY are described. \begin{figure} \centering \includegraphics[width=0.8\textwidth]{Images/2_structure.png} \caption{The entire structure of JORLDY} \label{fig:fig2} \end{figure} At first, users have to decide train or evaluate the agent with running the script. In this process, users also can select distributed setting of the training. JORLDY has a python scripts to run: \emph{main.py}. It uses options (\emph{\texttt{-{}-}single}, \emph{\texttt{-{}-}sync}, \emph{\texttt{-{}-}async}, \emph{\texttt{-{}-}eval}) for selecting distributed training mode or evaluation. The first three options are used to train the agent. A single worker is trained without distributed setting with \emph{\texttt{-{}-}single} option. The \emph{\texttt{-{}-}sync} and \emph{\texttt{-{}-}async} options provide a different type of distributed training architecture. The \emph{\texttt{-{}-}eval} option is used to evaluate the agent. JORLDY has some components: \emph{config}, \emph{core}, \emph{manager}, \emph{process} and \emph{logs}. The first component of JORLDY is \emph{config}. In the \emph{config}, users can manage the parameter setting files. The configuration files are saved in the path: jorldy/config/[agent name]/[env name].py (e.g. jorldy/config/dqn/cartpole.py). The example of the configuration can be found in Appendix A. The second component of JORLDY is \emph{core}. The \emph{core} manages agent and environment classes. In the \emph{core}, there are 5 subcomponents: env, agent, network, optimizer and buffer. The env manages environment classes such as Gym, Atari, ML-Agents, etc. The agent manages all the agent classes such as DQN, PPO, SAC, Rainbow, etc. The network manages network classes such as noisy, policy\_value, rnd, etc. The optimizer manages optimizer classes and the buffer manages buffer class such as replay buffer, rollout buffer, per buffer, etc. All the subcomponents of \emph{core} are fully customizable. The other components of JORLDY are \emph{manager}, \emph{process} and \emph{logs}. The \emph{manager} manages auxiliary classes for running. The \emph{process} manages multi process functions such as interact and manage. The results of the training are saved in the jorldy/log folder. The results are saved in the path: jorldy/logs/[env name]/[agent name]/[timestamp]/ (e.g. jorldy/logs/cartpole/dqn/20211123141004). Trained model, config file, tensorboard file and gif of evaluation are saved in the path. \section{Features of JORLDY} \begin{table}[] \centering \caption {RL Algorithms of JORLDY} \begin{adjustbox}{width=\textwidth} \begin{tabular}{|c|c|} \hline \textbf{Category} & \textbf{Algorithms} \\ \hline Value-based & \makecell{DQN \cite{mnih2015human}, Double DQN \cite{van2016deep}, Dueling DQN \cite{wang2016dueling}, Multistep DQN \cite{sutton2018reinforcement}, PER \cite{schaul2015prioritized},\\ Rainbow (-DQN, -IQN) \cite{hessel2018rainbow}, M-RL (DQN, IQN) \cite{vieillard2020munchausen} } \\ \hline Policy-based, Actor-Critic & \makecell{REINFORCE \cite{sutton2000policy}, DDPG \cite{lillicrap2015continuous}, TD3 \cite{fujimoto2018addressing}, PPO \cite{schulman2017proximal}, SAC \cite{haarnoja2018soft}, MPO \cite{abdolmaleki2018maximum}, V-MPO \cite{song2019v}} \\ \hline Distributional RL & C51 \cite{bellemare2017distributional}, QR-DQN \cite{dabney2018distributional}, IQN \cite{dabney2018implicit} \\ \hline Exploration & Noisy DQN \cite{fortunato2017noisy}, ICM \cite{pathak2017curiosity}, RND \cite{burda2018exploration} \\ \hline Distributed Structure & APE-X \cite{horgan2018distributed}, R2D2 \cite{kapturowski2018recurrent} \\ \hline \end{tabular} \end{adjustbox} \end{table} \subsection{Contents of JORLDY} JORLDY consists of various RL algorithms and environments. The implemented RL algorithms of JORLDY are shown in Table 1. According to the characteristics of algorithms, the RL algorithms are grouped as follows: value-based, policy-based \& actor-critic, distributional RL, exploration, distributed structure. The algorithms except Rainbow-IQN are implemented based on the published papers. JORLDY supports multiple RL environments for evaluating the performance of RL algorithms. Currently, JORLDY supports following RL environments: OpenAI gym \cite{brockman2016openai}, Arcade Learning Environment (ALE) \cite{machado18arcade}, Super Mario Bros \cite{gym-super-mario-bros}, Procgen \cite{cobbe2019procgen}, Mujoco \cite{todorov2012mujoco} and Unity ML-Agents \cite{juliani2018unity}. The environments other than custom Unity ML-Agents environments are existing RL environments. \begin{figure} \centering \includegraphics[width=\textwidth]{Images/3_mlagent_envs.png} \caption{Examples of custom RL environments made with Unity ML-Agents (Left: Pong, Center: Hopper, Right: Drone Delivery)} \label{fig:fig3} \end{figure} \begin{figure} \centering \includegraphics[width=\textwidth]{Images/4_custom_architecture.png} \caption{Code structure of JORLDY} \label{fig:fig4} \end{figure} \subsection{Customizability} One of the main features of JORLDY is customizability. Most of the existing RL frameworks are hard to modify the specific part of the algorithms and environments because they provide nested class structure. In the case of JORLDY, not only configuration but also all the components in the core can be modified. For example, we implemented Rainbow-IQN that uses IQN instead of C51 among the algorithms constituting Rainbow-DQN. As the case of the Rainbow-IQN, users can change few parts of existing algorithm to apply their own idea and add entire new RL algorithms. All the RL components such as network, buffer, agent are separately implemented, so they can be simply combined. For example, Dueling DQN, Double DQN and PER are independent algorithms in JORLDY. However, the agent of Double DQN can use network of Dueling DQN with buffer of PER with little modification. In this way, if users implement new RL component in JORLDY, the component can be applied to all the other RL components. Custom RL environments also can be added in JORLDY. For example, \emph{pong\_mlagent}, \emph{hopper\_mlagent}, \emph{drone\_delivery\_mlagent} of JORLDY are custom RL environment made with Unity ML-Agents. These custom environments are shown in Figure 3. Not only the environment made with Unity ML-Agents, any extisting RL environments can be applied to JORLDY. JORLDY supports the inheritance structure for users to modify and add the algorithms and environments more conveniently. Each of the component has base class. In order to implement a new object, this base class must be inherited. However, in the network component, if necessary, an object can be implemented without inheritance of the base class (refer to icm, rnd network). In this case, the head network cannot be used. In addition, the functions of the object can be utilized by inheriting an existing object. As a result, users don't have to write unnecessary redundant code. This structure not only imposes rules on code implementation, but also makes code implementation easier. Based on the code structure, users can modify or add all the components. The example of inheritance chart is shown in Figure 4. \subsection{Distributed Architecture} JORLDY provides 3 different options for training: \emph{\texttt{-{}-}single}, \emph{\texttt{-{}-}sync} and \emph{\texttt{-{}-}async}. Among these options, \emph{\texttt{-{}-}single} uses a single actor for training, so it is not the one which has a distributed training structure. The \emph{\texttt{-{}-}sync} and \emph{\texttt{-{}-}async} options support different structures for distributed training. The difference between these two options is whether actors interact synchronously or asynchronously with learner. The flow chart and timeline of each distributed structure are shown in Figure 5 and Figure 6. At first, \emph{\texttt{-{}-}single} option has main process and manage process. In the main process, a single agent interacts with environments to collect transition data and trains network from it. The manage process evaluates with the latest network to get a score, and records this score and the results of training in the main process. The \emph{\texttt{-{}-}sync} option also has main process and manage process. In the main process, multiple actors interact in parallel at the same time to collect transition data and the learner trains the network from it. In detail, the transition data obtained through the interaction is collected and delivered to the learner when all actors complete the interact process. Then, the learner receives these data, performs training, and delivers the updated network to all actors. The manage process evaluates agent with the latest model to get a score, and records this score and the results of training in the main process. The \emph{\texttt{-{}-}async} option has interact process, main process and manage process. In the interact process, multiple actors interact in parallel to collect transition data. Unlike the \emph{\texttt{-{}-}sync} option, each actor interacts asynchronously. More specifically, in the \emph{\texttt{-{}-}async}, transition data is collected only for actors who have completed the interact process within a specific time and delivered to the learner. If any actor does not complete within a certain time, it waits until the completed actor comes out. Then, the learner receives these data, performs learning, and delivers the updated network only to actors who have completed the interact process. In the main process, the learner trains the model through the transition data. The manage process evaluates with the latest model to get a score, and records this score and the results of training in the main process. \begin{figure} \centering \includegraphics[width=13cm]{Images/5_distributed_flowchart.png} \caption{Flow chart of the distributed structures} \label{fig:fig5} \end{figure} \begin{figure} \centering \includegraphics[width=\textwidth]{Images/6_distributed_timeline.png} \caption{Timeline of the distributed structures} \label{fig:fig6} \end{figure} \subsection{Benchmark} Benchmark of the algorithms is conducted in RL environments. Benchmark of the Atari and MuJoCo environment can be found in Appendix B.1 and B.2, respectively. All the benchmark results of JORLDY contains not only score but also configuration, script information and specification. The results can be found in the following link: \url{https://bit.ly/3tVYYJo} \section{How to Use JORLDY} Training RL algorithms in desired environment has following two process: configuration setting, executing run command. In this section, detail of the configuration setting and run command is described. \subsection{Configuration Setting} At first, the user has to set the configuration of the agent and environment. As Appendix A shows, configuration files have 4 parts. In the env part, users can change the configuration of the environment. It contains information about rendering, input data (width, height, grayscale) and reward setting. In the agent part of the configuration file, hyperparameters settings of the network and agent can be adjusted. To identify the name of the network and head, the user has to check \emph{\_network\_dict.txt} and \emph{\_head\_dict.txt} in jorldy/core/network. In the optim part, user can set the optimizer and its parameters. Lastly, the configuration of training can be changed in the train part. Using the configurations, user can set whether to train or evaluate the agent. Also, various period about training, saving and printing can be changed in this part. Moreover, the distributed setting can be decided in the train part. \subsection{Run command} After the configuration setting, users should run the command for executing the algorithm. Default command consists of script part and configuration part. The example command for training DQN algorithm with CartPole environment is as follows. \emph{\texttt{-{}-}single} training option is a default option, so it can be deleted. However, if user wants to train with distributed setting, \emph{\texttt{-{}-}sync} or \emph{\texttt{-{}-}async} option has to be appended after \emph{main.py} \begin{verbatim} python main.py --config config.dqn.cartpole \end{verbatim} When you type path of configuration file, you should omit '.py' in the name of the configuration file. If the command does not contain configuration path, it runs with the default configuration in the script. All parameters in the configuration file can be changed by using the parser without modifying the configuration file. To change the configuration using the command, users should type the parameter key and value. The example command for training PPO algorithm using sync distributed training with changing number of workers in distributed structure is as follows. \begin{verbatim} python main.py --sync --config config.ppo.cartpole --train.num_workers 8 \end{verbatim} With these simple commands, the algorithms and environments of JORLDY can be executed. \section{Conclusion} This paper proposes a new open source reinforcement learning framework: JORLDY. It contains various RL algorithms and environments which can be fully customized. With this flexibility, users can not only modify the existing algorithms and environments but also add their algorithms and environments for their research. Also, JORLDY provides various types of distributed structure for training the RL algorithms. The users can select one of these distributed structures to proceed with training. We think that even non-experts on RL will be able to use RL algorithms more easily and apply them to their various environments by using JORLDY. We also believe that it will help researchers and students working on RL to advance their research. In order to contribute to the development of reinforcement learning, JORLDY will continue to develop in the future. \section*{Acknowledgments} We thank Kakao Enterprise AI Lab \& Service, Advanced tech team member for their support. Also, We appreciate Jinhyung Ahn who contributes the development of JORLDY a lot. \bibliographystyle{unsrt} \section{Introduction} \lipsum[2] \lipsum[3] \section{Headings: first level} \label{sec:headings} \lipsum[4] See Section \ref{sec:headings}. \subsection{Headings: second level} \lipsum[5] \begin{equation} \xi _{ij}(t)=P(x_{t}=i,x_{t+1}=j|y,v,w;\theta)= {\frac {\alpha _{i}(t)a^{w_t}_{ij}\beta _{j}(t+1)b^{v_{t+1}}_{j}(y_{t+1})}{\sum _{i=1}^{N} \sum _{j=1}^{N} \alpha _{i}(t)a^{w_t}_{ij}\beta _{j}(t+1)b^{v_{t+1}}_{j}(y_{t+1})}} \end{equation} \subsubsection{Headings: third level} \lipsum[6] \paragraph{Paragraph} \lipsum[7] \section{Examples of citations, figures, tables, references} \label{sec:others} \lipsum[8] \cite{kour2014real,kour2014fast} and see \cite{hadash2018estimate}. The documentation for \verb+natbib+ may be found at \begin{center} \url{http://mirrors.ctan.org/macros/latex/contrib/natbib/natnotes.pdf} \end{center} Of note is the command \verb+\citet+, which produces citations appropriate for use in inline text. For example, \begin{verbatim} \citet{hasselmo} investigated\dots \end{verbatim} produces \begin{quote} Hasselmo, et al.\ (1995) investigated\dots \end{quote} \begin{center} \url{https://www.ctan.org/pkg/booktabs} \end{center} \subsection{Figures} \lipsum[10] See Figure \ref{fig:fig1}. Here is how you add footnotes. \footnote{Sample of the first footnote.} \lipsum[11] \begin{figure} \centering \fbox{\rule[-.5cm]{4cm}{4cm} \rule[-.5cm]{4cm}{0cm}} \caption{Sample figure caption.} \label{fig:fig1} \end{figure} \subsection{Tables} \lipsum[12] See awesome Table~\ref{tab:table}. \begin{table} \caption{Sample table title} \centering \begin{tabular}{lll} \toprule \multicolumn{2}{c}{Part} \\ \cmidrule(r){1-2} Name & Description & Size ($\mu$m) \\ \midrule Dendrite & Input terminal & $\sim$100 \\ Axon & Output terminal & $\sim$10 \\ Soma & Cell body & up to $10^6$ \\ \bottomrule \end{tabular} \label{tab:table} \end{table} \subsection{Lists} \begin{itemize} \item Lorem ipsum dolor sit amet \item consectetur adipiscing elit. \item Aliquam dignissim blandit est, in dictum tortor gravida eget. In ac rutrum magna. \end{itemize} \section{Conclusion} Your conclusion here \section*{Acknowledgments} This was was supported in part by...... \bibliographystyle{unsrt}
{'timestamp': '2022-04-12T02:33:17', 'yymm': '2204', 'arxiv_id': '2204.04892', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04892'}
arxiv
\section{Introduction} Optimizing latency and power tradeoffs (e.g., minimizing latency while meeting a power constraint) is crucial to modern computer systems. To achieve these goals, hardware and software configuration parameters---e.g., number of cores, core frequency, memory management, etc.---are exposed to users such that both the underlying system and application can be configured to operate at an optimal point in the latency-power tradeoff space~\cite{xu2015hey,colin2018reconfigurable,blocher2021switches}. Selecting an optimal configuration, however, is a challenging problem as the size and complexity of the configuration space require intelligent methods to avoid local optima \cite{LEO,CALOREE}. \textbf{Sample Efficiency.} Machine learning techniques have proven effective solutions to optimizing computer system configurations~\cite{herodotou2020survey,penney2019survey,ZhangH2019learned}. While a variety of such methods have been applied, they require a large sampling effort; i.e., generating a candidate configuration, running it to measure its high-level \emph{system behavior} (e.g., latency and energy), and then building a model to predict the system behavior of unsampled configurations. Among these techniques, an appealing direction is sample-efficient machine learning (SEML), which reduces the number of samples required to find the optimal configuration ~\cite{ipek2006efficiently,alipourfar2017cherrypick,ding2019generative,nardi2019practical,patel2020clite}. A powerful example of SEML is Bayesian optimization~\cite{alipourfar2017cherrypick,nardi2019practical,patel2020clite}. Bayesian optimization intelligently selects samples that provide the most information for the model updates, and this intelligence reduces the number of samples required to find the configuration that produces optimal systems behavior. Besides Bayesian optimization, other sample-efficient optimizers have been proposed for specific systems problems~\cite{ipek2006efficiently,petrica2013flicker,venkataraman2016ernest,ding2019generative}. \textbf{Cost of Samples.} SEML reduces the cost for computer systems optimization by reducing the number of samples to find the optimal configuration. There is, however, a significant additional cost: the time to collect each sample. Critically in computer systems optimization, the samples corresponding to the worst configurations take a much longer time to collect than others. For instance, a slow configuration can take 10$\times$ the execution time of the optimal configuration on the same Apache Spark workload~\cite{yu2018datasize}. Thus, there is a need for reducing the cost of individual sample collection and not just the total number of samples. \textbf{Compute Efficiency}. We note that achieving \emph{compute efficiency} for SEML should reduce both the number of samples and the cost of collecting each sample. To reduce the cost of collecting each sample, prior work replies on \emph{measured early termination} that terminates samples when the measured system behavior surpasses a given \emph{termination threshold} (e.g., a target latency)~\cite{hutter2013bayesian,eggensperger2020neural}; and this threshold typically distinguishes between good and poor system behavior. For instance, if the termination threshold is 40 seconds and the true latency of the workload running at a particular configuration is 60 seconds, measured early termination techniques will terminate samples when their runtime surpasses 40 seconds. However, this approach still pays the cost of waiting for the sample to hit the termination threshold, which is compute-inefficient. \subsection{Compute Efficiency with Cello{}} In contrast to prior work based on measured early termination, we introduce \emph{predictive early termination}. This approach monitors running samples, predicts whether the sample will surpass the threshold, and terminates such unpromising samples before they are measured to be poor (e.g., long latency or high energy). To apply this insight, we present Cello{}, an efficient computer systems optimization framework that augments Bayesian optimization with predictive early termination. To enable predictive early termination, Cello{} must predict, both early and accurately, whether a running sample will perform poorly; i.e., eventually exceed the termination threshold, which Cello{} sets as the best measured behavior. To do so, Cello{} applies \emph{censored regression}, a prediction approach that is designed to model missing data (i.e., samples that are measured but not finish running) more accurately than techniques that do not account for the missing data~\cite{miller1982regression,portnoy2003censored}. Formally, \emph{censoring} is a condition where a measurement is only partially observable due to a given censoring threshold~\cite{powell1986censored}. Instead of observing the true measurement, in censored regression we only know that it exceeded the censoring threshold. For example, if the censoring threshold is 30 seconds, the true latency of a sample that keeps running after 30 seconds is not observed at this moment because it is censored. Although its true latency is unknown at this moment, we know that it must be at least 30 seconds. The intuition behind censored regression is to model the censored and uncensored data (in our case, the samples that are still running and finished running before the termination threshold) differently, and then combine these models in a way that produces more accurate predictions than standard regression that does not account for censoring (\cref{sec:res-censor}). \subsection{Summary of Results} We implement Cello{} and test it on twelve Apache Spark workloads from HiBench~\cite{huang2010hibench}. We compare Cello{} to state-of-the-art Bayesian optimization techniques and different variants of early termination (including both measured and predictive). We give each method a fixed time to search a combined space of hardware and software configuration parameters and find solutions for two systems optimization problems: (1) minimizing latency under a power constraint (Latency-Under-Power{}) and (2) minimizing energy under a latency constraint (Energy-Under-Latency{}). Our evaluation shows a complete breakdown of results for different constraints and workloads for Cello{} and prior approaches to SEML. Compared to the prior work, we find that on average Cello{} (\cref{sec:res-good}): \begin{itemize} \item improves latency by 1.19$\times$ for Latency-Under-Power{} and energy by 1.18$\times$ for Energy-Under-Latency{} compared to Bliss{}~\cite{roy2021bliss}, the state of the art SEML approach for computer systems optimizations; \item improves latency by 1.24--1.61$\times$ for Latency-Under-Power{} and energy by 1.24--1.34$\times$ for Energy-Under-Latency{} compared to other SEML approaches that use measured early termination; \item improves latency by 1.90$\times$ for Latency-Under-Power{} and energy by 2.35$\times$ for Energy-Under-Latency{} compared to the SEML approach that uses predictive early termination based on standard regression, rather than Cello{}'s censored regression. \end{itemize} \subsection{Contributions} This paper presents the following contributions: \begin{itemize} \item Introducing predictive early termination, based on predicted---rather than measured---behavior which allows SEML to terminate samples much earlier than prior work. \item Introducing censored regression to predict the system behavior of samples and enable predictive early termination. To the best of our knowledge this is the first demonstration of the benefits of censored regression for computer systems optimization. \item Presenting Cello{}, an efficient computer system optimization framework that combines predictive early termination and censored regression to reduce the cost of applying machine learning methods for systems optimization while still improving systems outcomes. \end{itemize} Incomplete data are often prevalent in computer systems optimization. To the best of our knowledge, Cello{} is the first framework that reduces the time cost per sample by intelligently taking advantages of incomplete data via censored regression and predictive early termination. Our work provides a foundation on which the computer systems community can build new efficient frameworks that process incomplete data in computer systems research. \section{Experimental Setup} \label{sec:setup} \subsection{Software Systems}\label{sec:sw-systems} We use Apache Spark as our software system~\cite{spark}. Each experiment has a master node and four worker nodes. We use a wide range of configuration parameters that reflect significant properties categorized by shuffle behavior, data compression and serialization, memory management, execution behavior, networking, and scheduling (details in the software category of Table~\ref{tbl:conf}). We use the same set of parameters as prior work~\cite{yu2018datasize} slightly modified for the current version of HiBench Spark. We use 12 workloads (Table~\ref{tbl:workloads}) from HiBench's big data benchmark suite~\cite{huang2010hibench}---a benchmark suite that is widely used in prior work~\cite{yu2018datasize,wang2019tpshare,banerjee2021bayesperf,ding2021generalizable}. The workloads cover various domains including microbenchmarks, machine learning, websearch, and graph analytics. \begin{table}[!htb] \begin{center} \caption{HiBench workloads.} \begin{tabular}{ll|ll} \toprule \textbf{Workload} & \textbf{Data size} & \textbf{Workload} & \textbf{Data size} \\ \midrule als & 0.6 GB & bayes & 19 GB \\ gbt & 2 GB & kmeans & 20 GB \\ linear & 48 GB & lr & 8 GB \\ nweight & 0.9 GB & pagerank & 1.5 GB \\ pca & 4 GB & rf & 0.8 GB \\ terasort & 3.2 GB & wordcount & 32 GB \\ \bottomrule \end{tabular} \label{tbl:workloads} \end{center} \end{table} \subsection{Hardware Systems}\label{sec:hw-systems} We run experiments on the Chameleon configurable cloud computing systems~\cite{keahey2020lessons}, where each node is a dual-socket system running Ubuntu 18.04 (GNU/Linux 5.4) with 2 Intel(R) Xeon(R) Gold 6126 processors, 192 GB of RAM, hyperthreads and TurboBoost. Each socket has 12 cores/24 hyperthreads and a 20 MB last-level cache. The hardware parameters we optimize are in the hardware category of Table~\ref{tbl:conf}, which have been shown to have a significant affect on latency and power tradeoffs~\cite{zhang2016maximizing}. \subsection{Points of Comparison}\label{sec:comparison} We compare a spectrum of approaches including random sampling (RS{}), Bayesian optimization (BO{}), Bayesian optimization with measured early termination (BO-ST{}, BO-TC{}, BO-IM{}, BO-NN{}) and predictive early termination (BO-GB{}), and ensemble Bayesian optimization (Bliss{}). \begin{itemize} \item \textbf{RS{}}: randomly sample configurations and select the best configuration that meets the constraint. \item \textbf{BO{}}: Bayesian optimization using random forest as the surrogate model and expected improvement as the acquisition function~\cite{alipourfar2017cherrypick,nardi2019practical,patel2020clite,chen2021efficient}. We also use the same setting for the following approaches. \item \textbf{BO-ST{}}: Bayesian optimization with measured early termination using the static termination threshold; i.e., terminate the experiment when the measured latency or energy is observed to reach the static termination threshold, and then drop the sample. The static threshold is the latency or energy of the initial sample because it is the only prior knowledge we have to set this threshold. \item \textbf{BO-TC{}}: Bayesian optimization with measured early termination by truncation; i.e., terminate the experiment when the measured latency or energy is observed to be worse than the existing best, and then drop the configuration. \item \textbf{BO-IM{}}: Bayesian optimization with measured early termination by imputation~\cite{hutter2013bayesian}; i.e., terminate the experiment when the measured latency or energy is observed to be worse than the existing best, and then impute---i.e., replace missing data with predicted values---the unfinished configuration. \item \textbf{BO-NN{}}: Neural model-based Bayesian optimization with measured early termination and censored observations~\cite{eggensperger2020neural}; i.e., train the neural network with the Tobit loss function for the censored training data. The same neural network architecture and hyperparameter settings are used in~\cite{eggensperger2020neural}. We use the same static threshold setting as the experiments in~\cite{eggensperger2020neural}. The threshold is the latency or energy of the initial sample because it is the only prior knowledge we have to set this threshold. \item \textbf{BO-GB{}}: Bayesian optimization with predictive early termination by predicting with standard regression; i.e., terminate the experiment when the predicted latency or energy is worse than the existing best, and drop the configuration. We use gradient boosting trees as the standard regressor due to its high accuracy~\cite{chen2016xgboost}. This approach is novel to this paper, we include it to show the importance of using censored regression rather than standard regression for predicted early termination. \item \textbf{Bliss{}}: ensemble Bayesian optimization~\cite{roy2021bliss}. Bliss{} reduces sample collection time by determining when to update its surrogate model using predictions from that same surrogate. To the best of our knowledge, Bliss{} is the state-of-the-art of Bayesian optimization in configuration search for computer systems. \item \textbf{Cello{}}: Bayesian optimization with predictive early termination by predicting with censored regression. \end{itemize} \subsection{Evaluation Methodology}\label{sec:eval-method} Following a methodology established in prior work on investigating Apache Spark systems~\cite{yu2018datasize}, we create a set of 2000 configurations per workload, randomly sampled from both hardware and software configuration parameters. We run these configurations to record their latency and energy consumption. For reference, we used more than 50000 CPU hours to record this test dataset (and we will include it as part of our open source release). We then give each of the above approaches a fixed amount of time to search a combined space of hardware and software configuration parameters and find solutions for two optimization problems: (1) \textbf{Latency-Under-Power{}:} minimizing latency under a power constraint; and (2) \textbf{Energy-Under-Latency{}:} minimizing energy under a latency constraint. We evaluate on a wide range of search time budgets such that at least one of the above approaches converges to the optimal solution. We set a range of constraints: the power and latency constraints are set as $[10, 20, 30, 40, 50, 60, 70, 80, 90]$-th percentiles of the distributions. For all approaches that measure progress of running samples, we set a time interval of 5 seconds; i.e., the system behavior is monitored every 5 seconds. The reported results are averaged over different constraints over 10 runs with different random seeds. For censored regression from the XGBoost library, we choose the \texttt{extreme} distribution for the loss function. We set \texttt{num\_boost\_round}, the parameter that controls the number of steps to fit gradient boosting trees in~\cref{eq:mle} to minimize the loss (i.e., the point at which to early stop) to 20. We tune this parameter by generating predictions that are generally above the current elapsed latency and energy on one workload \texttt{als} dataset, and use this same value on all other datasets without additional tuning. For each distinct trial on each dataset, we run cross validation for \texttt{distribution\_scale} with the value range of $[0.2, 0.3, 0.4]$ and \texttt{learning\_rate} with the value range of $[0.2, 0.25, 0.3]$ and report the best results. \subsection{Evaluation Metric} \noindent \textbf{RE.} We use relative error (RE) between the result from each approach and the optimal for evaluation: \begin{align} \text{RE} = \frac{|Y_{\rm pred} - Y_{\rm opt}|}{|Y_{\rm opt}|}, \label{eq:ape} \end{align} where $Y_{\rm pred}$ is the best value found by the approach, and $Y_{\rm opt}$ is the optimal measured value. Lower RE is better. \section{Experimental Evaluation}\label{sec:evaluation} We evaluate the following research questions (RQs): \begin{itemize} \item \textbf{RQ1:} How well does Cello{} perform? Cello{} reduces latency by 1.19--1.90$\times$ for Latency-Under-Power{} (Figure~\ref{fig:pup} and~\ref{fig:bar-pup}) and energy by 1.18--2.35$\times$ for Energy-Under-Latency{} (Figure~\ref{fig:eup} and~\ref{fig:bar-eup}). \item \textbf{RQ2:} Is prediction or measurement better for early termination? Cello{}'s predictive early termination outperforms measured early termination approaches by terminating much earlier while producing more accurate predictions (\cref{sec:res-pred}). \item \textbf{RQ3:} How is censored regression beneficial to Cello{}? Cello{}'s censored regression reduces prediction error (as mean squared error) for latency and energy by 60\% and 82\% over standard regression for Latency-Under-Power{} and Energy-Under-Latency{} (Figure~\ref{fig:gbcr}). \item \textbf{RQ4:} How many samples are explored? By combining censored regression and predictive early termination, Cello{} both explores more samples and improves search results compared to other baselines (\cref{sec:res-samples}). \item \textbf{RQ5:} What is the overhead? Within the same amount of search time (learning overhead included), Cello{} produces the best results by both predicting accurately (\cref{sec:res-censor}) and updating quickly (0.3 seconds per sample, \cref{sec:res-overhead}). \end{itemize} \begin{figure*}[!htb] \centering \includegraphics[width=\linewidth]{fig/pup-all.pdf} \caption{Latency results averaged over all power constraints for Latency-Under-Power{} (lower is better).} \label{fig:pup} \end{figure*} \begin{figure*}[!htb] \centering \includegraphics[width=\linewidth]{fig/bar_pup.pdf} \caption{Latency results averaged over all search time budgets for Latency-Under-Power{} (lower is better).}\label{fig:bar-pup} \end{figure*} \begin{figure*}[!htb] \centering \includegraphics[width=\linewidth]{fig/eup-all.pdf} \caption{Energy results averaged over all latency constraints for Energy-Under-Latency{}s (lower is better).} \label{fig:eup} \end{figure*} \begin{figure*}[!htb] \centering \includegraphics[width=\linewidth]{fig/bar_eup.pdf} \caption{Energy results averaged over all search time budgets for Energy-Under-Latency{} (lower is better).}\label{fig:bar-eup} \end{figure*} \subsection{RQ1: How well does Cello{} perform?}\label{sec:res-good} Figure~\ref{fig:pup} and~\ref{fig:eup} show the latency and energy results of different approaches as a function of different search time budgets for Latency-Under-Power{} and Energy-Under-Latency{}, respectively, where the x-axis is the search time, and the y-axis is the latency or energy (lower is better). We compare the summarized results averaged over all search times in Figure~\ref{fig:bar-pup} and~\ref{fig:bar-eup}, and compute the relative error (RE) by comparing to the optimal value (Optimal) in Table~\ref{tbl:main-res}, where Optimal is the best value found through brute force search. We can see that compared to other approaches, Cello{} finds the configuration with the lowest latency and energy at almost all search times for almost all workloads. The major exceptions are \texttt{lr} and \texttt{rf} in Latency-Under-Power{}, and \texttt{als} and \texttt{bayes} in Energy-Under-Latency{}, where Bliss{} outperforms Cello{} at some points. It is not surprising since with numerous local optima in the tremendous search space, no single method will dominate. Despite that, Cello{} still outperforms prior work in the majority of cases and gets much better results on average. In particular, we find that on average: \begin{table}[!htb] \small \begin{center} \caption{Summarized results averaged over all workloads for each approach. Lower RE is better.} \begin{tabular}{l|ll|ll} \toprule & \multicolumn{2}{c}{Latency-Under-Power{}} & \multicolumn{2}{c}{Energy-Under-Latency{}} \\ \midrule & RE (\%) & \# samples & RE (\%) & \# samples \\ \midrule RS & 55 & 23 & 46 & 25 \\ BO & 52 & 24 & 36 & 28 \\ BO-ST & 51 & 26 & 31 & 32 \\ BO-TC & 48 & 30 & 32 & 41 \\ BO-IM & 51 & 91 & 31 & 69 \\ BO-NN & 94 & 19 & 54 & 21 \\ BO-GB & 127 & 385 & 72 & 378 \\ Bliss & 42 & 36 & 31 & 31 \\ Cello & 20 & 44 & 16 & 50 \\ \bottomrule \end{tabular} \label{tbl:main-res} \end{center} \end{table} \begin{itemize} \item Cello{} achieves 20\% and 16\% REs for Latency-Under-Power{} and Energy-Under-Latency{} respectively (Table~\ref{tbl:main-res}), which represent 1.19$\times$ and 1.18$\times$ speedups compared to the best baseline Bliss{}, and 1.90$\times$ and 2.35$\times$ speedups compared to the weakest baseline BO-GB{}. \item BO{} underperforms all approaches with early termination except BO-GB{}, which indicates the benefits of early terminations in SEML. The reasons that BO-GB{} performs poorly will be discussed in \cref{sec:res-censor}. \item As the state-of-the-art Bayesian optimization approach for configuration optimization, Bliss{} under-performs Cello{} in most workloads for several reasons. First, Bliss{} does not incorporate early termination; it runs a few rounds as BO{} in the beginning and then starts using predictions to update the surrogate model, which means that it does not reduce the cost of collecting samples during early rounds. Second, Bliss{} uses its surrogate model---i.e., standard regression---to predict, which leads to less accurate prediction compared to censored regression (more details in~\cref{sec:res-censor}). Finally, Bliss{} updates its surrogate alternating between using predictions and measured system behavior, which produces less accurate model updates. In contrast, Cello{} combines censored regression and early termination based on predicted behavior to reduce search costs. When running for a fixed time budget, Cello{} explores more configurations than Bliss{} (\texttt{\# sample} columns in Table~\ref{tbl:main-res}), and thus generally achieves better results. \end{itemize} \subsection{RQ2: Is prediction or measurement better for early termination?}\label{sec:res-pred} Here, we focus on comparing predictive early termination (Cello{}) to measured early termination (BO-ST{}, BO-TC{}, BO-IM{} and BO-NN{}) to determine if the former significantly improves early termination methods. In Figure~\ref{fig:bar-pup} and~\ref{fig:bar-eup} , Cello{} has 1.24--1.61$\times$ and 1.24--1.34$\times$ speedups over BO-ST{}, BO-TC{}, BO-IM{} and BO-NN{} for Latency-Under-Power{} and Energy-Under-Latency{} respectively. Cello{} outperforms other measured early termination approaches because it terminates poor samples much earlier using the accurate predictions from censored regression. Therefore, given the same amount of the search time budget, Cello{} also evaluate more samples than BO-ST{}, BO-TC{}, and BO-NN{} from Table~\ref{tbl:main-res}, which reflects the fact that Cello{} terminates more samples earlier. Although BO-IM{} evaluates more samples than Cello{}, it underperforms Cello{}, which suggests that it is terminating both early and accurately that improve results, not just terminating early. These results demonstrate the benefits of predictive early termination over measured early termination; however, the next section shows that achieving these benefits requires an appropriate predictive model. \begin{figure*}[!t] \centering \begin{subfloat}{\label{fig:gbcr-pup} \includegraphics[width=0.49\linewidth]{fig/gbcr_pup}} \end{subfloat} \begin{subfloat}{\label{fig:gbcr-eup} \includegraphics[width=0.49\linewidth]{fig/gbcr_eup}} \end{subfloat} \caption{MSEs for Latency-Under-Power{} (left) and Energy-Under-Latency{} (right). Lower is better.} \label{fig:gbcr} \end{figure*} \begin{figure*}[!htb] \centering \includegraphics[width=\linewidth]{fig/bar_oh_pup.pdf} \caption{Overhead of processing each sample for Latency-Under-Power{}. Lower is better.}\label{fig:oh-pup} \end{figure*} \begin{figure*}[!htb] \centering \includegraphics[width=\linewidth]{fig/bar_oh_eup.pdf} \caption{Overhead of processing each sample for Energy-Under-Latency{}. Lower is better.}\label{fig:oh-eup} \end{figure*} \subsection{RQ3: How is censored regression beneficial to Cello{}?}\label{sec:res-censor} Here, we analyze the results of BO-GB{} to Cello{}. BO-GB{} uses early termination, but based on a standard regression model rather than Cello{}'s censored regression. Although BO-GB{} has predictive early termination, it achieves the worst results. This poor result is due to the low prediction accuracy from standard regression when training on censored data. To illustrate this, we compare the prediction accuracy of each selected sample between BO-GB{}'s standard regression (gradient boosting trees) and Cello{}'s censored regression. We monitor workload execution and predict its latency at each time interval (\cref{sec:eval-method}). The censoring threshold for censored regression is thus the elapsed latency observed at each time interval. We compute the mean squared error (MSE) between predicted latency and true latency. Figure~\ref{fig:gbcr} shows the average MSE over all time intervals, where the x-axis is the workload, the y-axis is MSE (lower is better), and the last column, Mean, is the arithmetic mean over all workloads. Censored regression almost always has much lower MSE than standard regression, with 60\% and 82\% reductions for Latency-Under-Power{} and Energy-Under-Latency{} respectively. Standard regression has worse prediction accuracy because BO-GB{} terminates all samples throughout the execution and thus does not update the surrogate model at all. These results suggest that it is important to make accurate predictions so that the poor configurations can be quickly identified. Censored regression achieves high accuracy by considering both uncensored (finished) and censored (running) samples, while standard regression only takes uncensored (finished) samples into account. \subsection{RQ4: How many samples are explored?}\label{sec:res-samples} Table~\ref{tbl:main-res} summarizes the average number of samples selected for each approach. Note that since all approaches are given the same time to explore, exploring more samples is generally better, provided those samples produce useful information for updating the model. We find that: \begin{itemize} \item Within the same time budgets, BO{} selects fewer samples than others (except BO-NN{}) as BO{} does not use early termination to save extra time for more samples. \item BO-NN{} selects the fewest samples compared to others; 19 and 21 on average for for Latency-Under-Power{} and Energy-Under-Latency{} respectively. The reason is that BO-NN{} has a surprisingly high overhead for model updates--over 11 seconds per sample (\cref{sec:res-overhead})---and thus a significant portion of its time is spent on surrogate updates instead of searching new configurations. \item BO-GB{} selects the most samples; in Table~\ref{tbl:main-res}, BO-GB{} selects 385 and 378 samples for Latency-Under-Power{} and Energy-Under-Latency{} respectively. It is because BO-GB{} terminates all samples in the first time interval based on its predictions, and does not update the surrogate model at all. More results can be found in~\cref{sec:res-censor}. \item Cello{} selects 44 and 50 samples for Latency-Under-Power{} and Energy-Under-Latency{} respectively, which are more than RS{}, BO{}, BO-ST{}, BO-TC{}, BO-NN{}, and Bliss{}, while fewer than BO-IM{} and BO-GB{}. It indicates that increasing the number of samples is not the key to achieving the best results, but selecting more useful samples matters. Cello{} is such an example that combines early termination and censored regression to search more high-quality samples. \end{itemize} \subsection{RQ5: What is the overhead?}\label{sec:res-overhead} We report the learning overhead of processing each sample, including predicting future behavior and updating the surrogate. Figure~\ref{fig:oh-pup} and~\ref{fig:oh-eup} show the overhead of processing each sample for different approaches for Latency-Under-Power{} and Energy-Under-Latency{} respectively, where the x-axis is the workload, the y-axis is the overhead, and the last column Mean is the arithmetic mean over all workloads. We use the same setting for neural network training as in~\cite{eggensperger2020neural} for BO-NN{}, and BO-NN{} has the highest overhead; i.e., over 11 seconds on average. To better visualize other methods properly, we cap the y-axis at 1 second. BO-IM{} has the second largest overhead due to the high overhead of imputing samples using the Expected-maximization algorithm~\cite{hutter2013bayesian}. The Expected-maximization algorithm is an iterative method and thus needs numerous steps to converge~\cite{moon1996expectation}. Cello{} has the third largest overhead because it uses the gradient boosting trees---which is an ensemble method---to fit the loss function of censored regression. Nevertheless, Cello{}'s overhead (0.3 seconds on average) is negligible compared to the cost of collecting each sample (22.3 seconds on average), which is key for its applicability to the efficient computer systems optimization problems. All results in this section include learning overhead for all approaches, and Cello{} still produces the best results, showing that the overhead can be negligible compared to making good decisions about early termination to explore more high-quality samples in the same amount of time. \section{Discussion} To understand the impact of each configuration parameter on system design, we visualize the SHAP values of the parameters with the best energy under 50-th latency constraint for Energy-Under-Latency{} selected by Cello{} on \texttt{als} and \texttt{bayes} workloads in Figure~\ref{fig:shap_eup_als} and~\ref{fig:shap_eup_bayes}, respectively. SHAP (SHapley Additive exPlanations) is a state-of-the-art approach to interpret the output of machine learning models~\cite{lundberg2017unified}, which visualizes parameters contributing to push the model output from the base value (i.e., the average model output over the training data we passed) to the model output. For \texttt{als} in Figure~\ref{fig:shap_eup_als}, \texttt{n.socket} and \texttt{cpu.freq} have the largest effects (with contributing value $-41.87$ and $-37.46$) that push the energy prediction lower from the base value to the predictive value. The other high-influence parameters are \texttt{shuffle.sort.bypassMergeThreshold}, \texttt{uncore.freq}, \texttt{hyperthreading}. For \texttt{bayes} in Figure~\ref{fig:shap_eup_bayes}, \texttt{uncore.freq} and \texttt{n.sockets} have the largest effects (with contributing value $-27.69$ and $-23.53$) that push the energy prediction lower from the base value to the predictive value. The other high-influence parameters are \texttt{cpu.freq}, \texttt{n.cores}, \texttt{shuffle.file.buffer}, etc.. Two key points can be seen from these examples. First, both hardware (e.g., \texttt{uncore.freq}) and software (e.g., \texttt{shuffle.sort.bypassMergeThreshold}) parameters influence the system behavior, and thus both types of parameters should be tuned to meet the optimization goal. Second, same parameters have different effects on different workloads, which suggests that the optimal configuration is workload dependent. Therefore, we should be careful about the prior knowledge obtained from the existing workloads since information learned for one workload might not transfer directly to a new workload. \begin{figure}[!htb] \centering \includegraphics[width=\linewidth]{fig/shap_eup_als.pdf} \caption{SHAP values for the \texttt{als} workload. }\label{fig:shap_eup_als} \end{figure} \begin{figure}[!htb] \centering \includegraphics[width=\linewidth]{fig/shap_eup_bayes.pdf} \vspace{-0.25in} \caption{SHAP values for the \texttt{bayes} workload. }\label{fig:shap_eup_bayes} \end{figure} \section{Limitations}\label{sec:limitation} We recognize the limitations of this work as follows: \begin{itemize} \item The outcome of predictive early termination and censored regression from Cello{} depends on the SEML framework. We chose to implement Cello{} by adding these components to Bayesian optimization because it has proven to provide high-quality samples. Future work can explore how Cello{} can be generalized to other learning frameworks. \item It is challenging to determine the search time budget in advance to make sure that the search results converge to the optimal. There has been work investigating this topic in the machine learning community~\cite{lorenz2015stopping,nguyen2017regret}. Although it is out of scope in this paper, it is interesting to explore the combination of Cello{} and this direction. \item The improper setting of \texttt{num\_boost\_round}, the parameter that controls the number of training steps can result in poor prediction accuracy. Future work can explore more systematic ways to set this parameter, or incorporate its regularizing effect into the loss function. \end{itemize} \section{Conclusion} \label{sec:conclusion} This paper presents Cello{}, a systematic approach to reduce the cost of samples through predictive early termination and censored regression. Evaluations show that Cello{} improves the system outcomes compared to a wide range of existing SEML and early termination techniques. Finally, we hope that Cello{} can inspire future research directions on reducing time cost of sample collection rather than the number of samples, and other applications of censored regression in computer systems research. \section{Cello{} Design}\label{sec:framework} Cello{} is an efficient computer systems optimization framework that reduces the cost of samples by predictive early termination which we enable with censored regression. Figure~\ref{fig:workflow} illustrates the Cello{} design. After a configuration is selected from Bayesian optimization (\circled{A}), Cello{} starts monitoring it (\circled{B}), and records the current latency and energy at regular time intervals. At each interval, Cello{} checks if the configuration has finished running (Branch \circled{1}). If so, Cello{} goes back to Bayesian Optimization (\circled{A}) for the next round. Otherwise, Cello{} predicts the final latency or energy using the Censored Regressor (\circled{C}). Then, Cello{} sends the predictions to Predictive Early Termination (\circled{D}) to determine whether the configuration should be terminated based on its prediction (Branch \circled{2}). If the prediction is worse than the existing best from the collected samples, Cello{} terminates this sample collection and goes to the next round. Otherwise, the configuration continues running until the next time interval. When the configuration finishes, Cello{} records the data for this sample and goes to the next Bayesian optimization round (\circled{A}). The remainder of this section first provides a brief set of definitions to establish the core concepts, and then describe Cello{}'s design, and concludes with the Cello{}'s application to computer systems optimization problems. \subsection{Definitions} Cello{}'s input includes a workload and a list of configuration parameters over which to optimize. The goal is to find a configuration that meets the goal of systems optimization---e.g., the configuration that minimizes latency under a power constraint. We assume that Cello{} can measure high-level systems behavior including latency, power, and energy at different time intervals, which is reasonable since many software frameworks (e.g., Apache Spark~\cite{spark}, MapReduce~\cite{mapreduce}, Cassandra~\cite{cassandra}, HBase~\cite{hbase}, etc) already have this capability as they log systems behavior at regular time intervals. \begin{description} \item[Workload.] A program that runs on a computer system. \item[Configuration.] A configuration ${\mathbf{x}}_i$ is a $p$-dimensional vector where $p$ is the number of configuration parameters: \begin{align}\label{eq:vector} {\mathbf{x}}_i = [x_{i1},x_{i2},\cdots, x_{ip}], \end{align} As SEML sequentially explores configurations, we use index $i$ to refer to the sequence of configurations explored; ${\mathbf{x}}_i$ is the $i$-th configuration. $x_{ij}$ refers to an individual parameter setting, the $j$-th parameter, $j\in[p]$. A configuration parameter can either be a hardware feature such as the number of cores, core frequency, etc, or a software feature such as execution behavior, networking, scheduling, etc. A complete list of configuration parameters studied in this paper is in Table~\ref{tbl:conf}. \item[System behavior.] The high-level system behavior that Cello{} monitors and optimizes. In this paper, we use latency (i.e., execution time of a workload), power, and energy consumption as system behavior, depending on the specific problem. \item[Sample.] Given the above, a sample is the pair of a configuration along with its system behavior. \item[Termination threshold.] The termination threshold is a latency or energy value that is used to determine whether to terminate a sample early or not. Unlike prior approaches~\cite{hutter2013bayesian,eggensperger2020neural}, Cello{} dynamically updates this threshold based on the best latency or energy seen so far. \end{description} Next, we will describe each labeled box in Figure~\ref{fig:workflow}. \subsection{Bayesian Optimization} Cello{} uses Bayesian optimization (\circled{A}) to select the configuration at each round~\cite{settles2011theories}. Formally, \begin{align} {\mathbf{x}}^\star = \argmin_{{\mathbf{x}}\in \mathbb{R}^p} f({\mathbf{x}}), \end{align} where $f(\cdot)$ is the unknown underlying function which is being optimized. There are two main components in Bayesian optimization: the surrogate model and the acquisition function. The surrogate model learns the unknown underlying function $f(\cdot)$. The acquisition function selects the most informative configuration at each round. We describe these two components as follows. \subsubsection{Surrogate Model} Bayesian optimization requires a surrogate model that produces uncertainty estimates, and Cello{} requires the surrogate model that can handle different variable modalities (continuous, discrete, etc.) that exist in configuration space. In this paper, we use random forest as our surrogate model as it satisfies both of these requirements~\cite{hutter2011sequential,nardi2019practical}. As an ensemble learning method, random forest constructs a multitude of decision trees, where its predictions are the average of the output from its component trees. The uncertainty, therefore, can be obtained by taking the standard deviation from the predictions of each tree~\cite{breiman2001random}. For configuration ${\mathbf{x}}_i$, we denote $\mu_i(\cdot)$ and $\sigma_i(\cdot)$ as its predictive mean and uncertainty from the surrogate model. \subsubsection{Acquisition Function} After the surrogate model outputs predictive mean and uncertainty for the unseen configurations, Cello{} needs an acquisition function to select the best configuration to sample. A good acquisition function should balance the tradeoffs between exploration and exploitation. For Cello{}, we chose the expected improvement (EI) acquisition function, which has been demonstrated to perform well in configuration search~\cite{alipourfar2017cherrypick,patel2020clite,roy2021bliss}. EI selects the configuration that would have the highest expected improvement over the best observed system behavior so far. Assuming $m_i$ is the best observed system behavior at the $i$-th round, we have \begin{align} {\mathbf{x}}_i = \argmax_{{\mathbf{x}}\in \mathbb{R}^p} \begin{cases} \left(\mu_i({\mathbf{x}})-m_i \right)\Phi(Z)+\sigma_i({\mathbf{x}})\phi(Z), & \text{if } \sigma_i({\mathbf{x}})>0 \nonumber \\ 0, & \text{if } \sigma_i({\mathbf{x}})=0 \end{cases} \end{align} where $Z=\frac{\mu_i({\mathbf{x}})-m_i}{\sigma_i({\mathbf{x}})}$, $\Phi(\cdot)$ is the cumulative distribution function and $\phi(\cdot)$ is the probability density function, both assuming normal distributions. In particular, $\left(\mu_i({\mathbf{x}})-m_i \right)\Phi(Z)$ indicates the improvement in favor of exploitation, and $\sigma_i({\mathbf{x}})\phi(Z)$ indicates the uncertainty in favor of exploration. The unseen configuration with the highest expected improvement will be selected. \subsection{System Monitor} When a configuration is selected, Cello{} runs the workload in this configuration and monitors its status. The System Monitor (\circled{B}) records behavior (i.e., latency and energy) at regular time intervals to check if the configuration has finished running (\circled{1}). If the configuration finishes, Cello{} reports the latency and energy back to Bayesian Optimization (\circled{A}) for the next round. If the configuration is still running, the System Monitor reports the current latency and energy to the next module. \subsection{Censored Regressor}\label{sec:censor} Cello{}'s Censored Regressor (\circled{C}) takes the information from the System Monitor (\circled{B}) and predicts the current configuration's final latency and energy. The key idea of censored regression is to use the system behavior at the current time interval to accurately predict whether the current configuration will exceed the termination threshold. In particular, censored regression categorizes the training samples as follows: \begin{itemize} \item \rectangled{1} Samples that finish running; i.e., those which have terminated normally and thus have known latency and energy. \item \rectangled{2} Samples that do not finish running; i.e., those which are terminated early and their latency and energy are censored at the current elapsed latency and energy. \end{itemize} Next, we describe how censored regression models these two categories of training data. We will use the problem of minimizing latency under a power constraint as an example, in which we will predict latency. Let $z_i$ be the observed latency associated with ${\mathbf{x}}_i$ at the $i$-th round, and $g(\cdot)$ be the output from censored regression. Then the formal definition of censored regression model~\cite{barnwal2020survival} is: \begin{align}\label{eq:z} \log z_i = g({\mathbf{x}}_{i}) + \varsigma\epsilon_i, \end{align} where $\varsigma$ is a constant and $\epsilon_i$ is the measurement noise. The $\log$-scale of the response simplifies modeling different types of exponential distributions. The goal of censored regression is to estimate $g(\cdot)$. When ${\mathbf{x}}_i$ is running and the System Monitor returns the current latency at the $t$-th time interval, the current latency $y_{it}$ is a censored value of $z_i$ such that \begin{align}\label{eq:current} y_{it} = \begin{cases} z_i, & z_i < \tau_{it} \quad (\rectangled{1}) \\ \tau_{it}, & z_i \geq \tau_{it} \quad (\rectangled{2}) \end{cases} \end{align} where $\tau_{it}$ is the current latency at the $t$-th time interval (i.e., the amount of time that has elapsed during the execution of the sample). In~\cref{eq:current}: \begin{itemize} \item If the observed latency is less than the current latency $z_i < \tau_{it}$, Cello{} observes the latency when the configuration finishes running; i.e., $y_{i\cdot} = z_i$, where $y_{i\cdot}$ is the observed latency of a sample that terminated normally. Cello{} treats these uncensored (finished) samples by fitting them with regression, corresponding to \rectangled{1}. \item If the observed latency is greater than or equal to the current latency $z_i \geq \tau_{it}$, Cello{} observes the current latency censored at the $t$-th time interval, and $\tau_{it}$ is the current elapsed latency. Cello{} treats this censored (running) sample by estimating its probability of $z_i$ exceeding $\tau_{it}$ given the configuration, corresponding to \rectangled{2}. \end{itemize} Censored regression treats the uncensored (finished) samples and the censored (running) sample differently, and solves them together by minimizing the total negative log-likelihood (NLL) loss function. The NLL loss function at the $t$-th time interval in the $i$-th round is: \begin{align}\label{eq:mle} \rho\left(g;({\mathbf{x}}_{j}, y_{j\cdot})_{j=1}^{i-1},({\mathbf{x}}_{i}, \tau_{it})\right) &=-\sum_{j=1}^{i-1}\mathbbm{1}_{[z_{j}=y_{j\cdot}]}\log\frac{1}{y_{j\cdot}\sigma}\phi\left(\frac{\log y_{j\cdot}-g({\mathbf{x}}_{j})}{\sigma}\right) \nonumber \\ & -\log\left(1-\Phi\left(\frac{\log\tau_{it}-g({\mathbf{x}}_{i})}{\sigma}\right)\right), \end{align} where $\phi(\cdot)$ and $\Phi(\cdot)$ are the probability density and cumulative distribution functions of the noise $\epsilon_i$ in~\cref{eq:z}, respectively. The first term is the log-likelihood function for the uncensored (finished) samples that measures the discrepancy between $\log y_{j\cdot}$ and $g({\mathbf{x}}_{j})$ where $j\in[1,i-1]$, corresponding to \rectangled{1}. The second term is the log-likelihood function for the censored (running) sample of the current $i$-th round that encourages $g({\mathbf{x}}_{i})>\log\tau_{it}$ when $y_{it}=\tau_{it}$, corresponding to \rectangled{2}. To fit this loss function, Cello{} uses gradient boosting trees due to its high fitting power in various predictive tasks~\cite{chen2016xgboost}. Because, all else equal, the loss function in \cref{eq:mle} is lower when $g({\mathbf{x}}_{j})$ is higher, we regularize the predictor by training with early stopping~\cite[Chapter 5.5.2]{bishop2006pattern}. \subsection{Predictive Early Termination} Cello{}'s Predictive Early Termination Module (\circled{D}) will terminate the current configuration based on the predictions from the Censored Regressor (\circled{C}). If the prediction is better than the existing best from the collected samples, Cello{} lets the configuration keep running until the next time interval, when Cello{} will make another prediction to check if the configuration should be terminated. If the prediction is worse than the existing best from the collected samples, Cello{} will terminate the running process, drop this configuration, and begin the next round of Bayesian Optimization (\circled{A}). In this case, the surrogate model does not change since no new samples are added to the training set. To avoid selecting the same configuration as the previous rounds, Cello{} only selects the configuration that maximizes the acquisition function from the unsampled configurations. With this module, Cello{} reduces the time cost of each sample by dynamically determining whether predictive early termination should happen and when it will happen. \begin{algorithm}[!htb] \begin{algorithmic}[1] \small \Require $T_{\rm budget}$ \Comment{Time budget.} \Require $C$ \Comment{Target constraint in power or latency.} \State Randomly sample a configuration ${\mathbf{x}}_0$ to construct $X_{\mathrm{train}}$ and obtain its system behavior $y_0$ to construct $Y_{\mathrm{train}}$. \State $i=1$ \While{$T_{\rm budget}>0$} \State Train surrogate model using $X_{\mathrm{train}}$ and $Y_{\mathrm{train}}$. \label{line:surrogate} \State Select configuration ${\mathbf{x}}_i$ based on acquisition function. \label{line:acquisition} \State Run experiment at ${\mathbf{x}}_i$ and monitor its system behavior. \label{line:run} \State $\gamma_i \gets \min Y_{\mathrm{train}}$. \Comment{Update the existing best.} \label{line:update} \For{each interval $t=1,\ldots,$} \If {\rm sample not finished} \label{line:not-c} \State Get current system behavior $y_{it}$. \label{line:censor-1} \State Build censored regressor on $X_{\mathrm{train}}$, $Y_{\mathrm{train}}$, ${\mathbf{x}}_i$, $y_{it}$.\label{line:censor-2} \State Get predicted latency $\hat{y}_{it}$ for ${\mathbf{x}}_{i}$. \label{line:censor-3} \If {$\hat{y}_{it} \geq \gamma_i$} \label{line:terminate-1} \State Early terminate experiment.\label{line:terminate-2} \State Get current running time $t_{it}$. \State $T_{\rm budget} \gets T_{\rm budget} - t_{it}$. \label{line:time-1} \Else \State Get system behavior $y_{i\cdot}$ and constraint $c_i$ for ${\mathbf{x}}_i$. \label{line:con-1} \If{$c_i \leq C$ } \label{line:con-2} \State $X_{\mathrm{train}}\gets X_{\mathrm{train}} \bigcup {\mathbf{x}}_i$, $Y_{\mathrm{train}}\gets Y_{\mathrm{train}}\bigcup y_{i\cdot}$. \label{line:con-3} \Else \State $X_{\mathrm{train}}\gets X_{\mathrm{train}} \bigcup {\mathbf{x}}_i$, $Y_{\mathrm{train}}\gets Y_{\mathrm{train}}\bigcup \mathrm{inf}$. \label{line:con-4} \EndIf \State Get current running time $t_{it}$. \State $T_{\rm budget} \gets T_{\rm budget} - t_{it}$. \label{line:time-2} \EndIf \EndIf \EndFor \State $i \gets i+1$. \EndWhile \State \Return ${\mathbf{x}}^\star$ with the best system behavior from $X_{\mathrm{train}}$ that meets the target constraint. \label{line:out} \end{algorithmic} \caption{Cello{} for systems optimization.} \label{alg:cello} \end{algorithm} \subsection{Applying Cello{} to Optimization Problems} Cello{} is a general framework that can augment existing SEML approaches by reducing the time cost per sample. We apply Cello{} to solve the following two optimization problems: (1) \textbf{Latency-Under-Power{}:} minimizing latency under a power constraint; and (2) \textbf{Energy-Under-Latency{}:} minimizing energy under a latency constraint. Algorithm~\ref{alg:cello} summarizes the procedure. In \cref{line:surrogate,line:acquisition}, Cello{} conducts Bayesian Optimization to select the configuration to run (\circled{A}). In \cref{line:run}, Cello{}'s System Monitor observes the running configuration (\circled{B}). In \cref{line:update}, Cello{} updates the existing best system behavior (latency for Latency-Under-Power{}, energy for Energy-Under-Latency{}) from the collected samples. At each time interval, if the sample has not finished (\cref{line:not-c}), Cello{}'s Censored Regressor (\circled{C}) predicts future behavior (\cref{line:censor-1,line:censor-2,line:censor-3}). If the predicted behavior is worse than the existing best (\cref{line:terminate-1}), Cello{} terminates the configuration (\circled{D}, \cref{line:terminate-2}), and updates the time budget (\cref{line:time-1}). If the experiment has terminated normally, Cello{} determines how to update the training set. If the configuration meets the target constraint---in either latency or power---(\cref{line:con-2}), Cello{} adds this configuration and its true behavior to the training set for the next round (\cref{line:con-3}). Otherwise, Cello{} adds this configuration and uses a extremely high value to replace its true behavior (\cref{line:con-4}), which incorporates the knowledge that this configuration violates the target constraint by adding a discontinuous sample to the training set. Meanwhile, Cello{} updates the time budget (\cref{line:time-2}) to make sure that there is enough time to go to the next round. Finally, Cello{} outputs the best configuration that meets the target constraint (\cref{line:out}). We implement Cello{} in Python with libraries including numpy~\cite{numpy}, pandas~\cite{pandas}, and scikit-learn~\cite{scikit-learn}. For censored regression, we use an implementation from the Accelerated Failure Time model in XGBoost library, which is a state-of-the-art implementation of censored regression fitted with the gradient boosting trees~\cite{barnwal2020survival}. The code is released in~\url{https://anonymous.4open.science/r/cello-code-8512}. \begin{table*}[!htb] \small \begin{center} \caption{Hardware and software configuration parameters tuned in the experiments.} \begin{tabular}{clll} \toprule \textbf{Category} & \textbf{Configuration parameter} & \textbf{Range} & \textbf{Description} \\ \midrule \multirow{5}{*}{\rotatebox{90}{Hardware}} & cpu.freq & 1.0--3.7 & CPU frequency, in GHz. \\ & uncore.freq & 1.0--2.4 & Uncore frequency, in GHz. \\ & hyperthreading & on, off & Hyperthreading. \\ & n.sockets & 1, 2 & Number of sockets. \\ & n.cores & 1--12 & Number of cores per socket. \\\midrule \multirow{20}{*}{\rotatebox{90}{Software}} & spark.reducer.maxSizeInFlight & 24--128 & Max size of map outputs to fetch from each reduce task, in MB. \\ & spark.shuffle.file.buffer & 24--128 & Size of the in-memory buffer for each shuffle file output stream, in KB. \\ & spark.shuffle.sort.bypassMergeThreshold & 100--1000 & Avoid merge-sorting data if there is no map-side aggregation. \\ & spark.speculation.interval & 100--1000 & How often Spark will check for tasks to speculate, in millisecond. \\ & spark.speculation.multiplier & 1--5 & How many times slower a task is than median considered for speculation. \\ & spark.speculation.quantile & 0--1 & Percentage of tasks to be complete before speculation is enabled. \\ & spark.broadcast.blockSize & 2--128 & Size of each piece of a block for TorrentBroadcastFactory, in MB. \\ & spark.io.compression.snappy.blockSize & 24--128 & Block size used in snappy, in KB. \\ & spark.kryoserializer.buffer.max & 24-128 & Maximum allowable size of Kryo serialization buffer, in MB. \\ & spark.kryoserializer.buffer & 24--128 & Initial size of Kryo’s serialization buffer, in KB. \\ & spark.driver.memory & 6--12 & Amount of memory to use for the driver process, in GB. \\ & spark.executor.memory & 6--16 & Amount of memory to use per executor process, in GB. \\ & spark.network.timeout & 20--500 & Default timeout for all network interactions, in second. \\ & spark.locality.wait & 1--10 & How long to launch a data-local task before giving up, in second. \\ & spark.task.maxFailures & 1--8 & Number of task failures before giving up on the job. \\ & spark.shuffle.compress & false, true & Whether to compress map output files. \\ & spark.memory.fraction & 0--1 & Fraction of (heap space--300 MB) used for execution and storage. \\ & spark.shuffle.spill.compress & false, true & Whether to compress data spilled during shuffles. \\ & spark.broadcast.compress & false, true & Whether to compress broadcast variables before sending them. \\ & spark.memory.storageFraction & 0.5--1 & Amount of storage memory immune to eviction. \\ \bottomrule \end{tabular}\label{tbl:conf} \end{center} \end{table*} \section{Background and Related Work}\label{sec:related} This section discusses related work on machine learning for configuration optimization (\cref{sec:seml}), early termination (\cref{sec:early-termination}), and machine learning for prediction (\cref{sec:ml-pred}). \subsection{Computer Systems Configuration Optimization}\label{sec:seml} Modern computer systems are increasingly configurable~\cite{vishwanath2010characterizing,xu2015hey}. These configuration parameters have a large effect on high-level systems behavior including throughput~\cite{belay2014ix}, latency~\cite{van2017automatic}, and energy~\cite{LEO,ding2019generative}. Furthermore, the number of parameters and their complex interactions create a large search space with many local optima~\cite{deng2017memory,CALOREE}, which present challenges for heuristics~\cite{LEO,CALOREE}. To optimize systems behavior, machine learning techniques have been applied to search this configuration space for high-performing configurations. Sample-efficient machine learning (SEML) represents a class of machine learning techniques that reduce the number of samples required to find the optimal configuration~\cite{settles2011theories}. SEML approaches work iteratively, using their current predictions to determine which new configuration to sample and then update their model based on the observed behavior of that sample. Bayesian optimization is a typical SEML approach that has been applied in various domains~\cite{frazier2018tutorial}. For example, Cherrypick uses Bayesian optimization to find optimal cloud configurations~\cite{alipourfar2017cherrypick}. CLITE uses Bayesian optimization to schedule workloads for datacenters~\cite{patel2020clite}. HyperMapper applies Bayesian optimization to tune compilers~\cite{nardi2019practical}. Bliss uses Bayesian optimization to tune parallel applications on large-scale systems~\cite{roy2021bliss}. Additional works propose problem-specific SEML approaches, including multi-phase sampling~\cite{ding2019generative}, optimal experiment design in Ernest~\cite{venkataraman2016ernest}, and fractional factorial design in Flicker~\cite{petrica2013flicker}. \textbf{An example of cost per sample.} The SEML approaches above reduce the cost of computer systems optimization by reducing the number of samples. However, there is also the opportunity to reduce the cost of each sample itself. To demonstrate this, we compare the number of samples and cost per sample between random sampling (not a SEML approach), Bayesian optimization, and Cello{}. We run the Apache Spark workload \texttt{als} from HiBench on a cloud computing system (details in \cref{sec:hw-systems}) with the goal of finding the configuration with the lowest latency. Figure~\ref{fig:motive_cso} compares the time cost per sample between random sampling, Bayesian optimization, and Cello{}. We observe that the time costs per sample from random sampling and Bayesian optimization approaches are roughly the same, which validates that Bayesian optimization does not reduce the time cost of collecting samples Cello{}, however, focuses on reducing the cost of each sample. For achieving the same optimal latency, Cello{} only needs 7.12s per sample, which is a 44\% reduction in the time cost per sample compared to Bayesian optimization. \begin{figure}[!htb] \centering \includegraphics[width=\linewidth]{fig/motive_cost_per_sample} \caption{Comparing cost per sample between random sampling (RS), Bayesian optimization (BO), and Cello{} on the \texttt{als} workload.} \label{fig:motive_cso} \end{figure} \subsection{Early Termination}\label{sec:early-termination} \emph{Early termination} aborts poor performing configurations before they finish, leaving time and resources to sample more promising configurations. This approach has been applied to speed up hyperparameter optimization and deep neural network (DNN) training. For hyperparameter optimization, HyperBand~\cite{li2017hyperband} and HyperDrive~\cite{rasley2017hyperdrive} randomly generate a large number of configurations at one time rather than intelligently sampling a small number of configurations iteratively, which is much more compute-intensive than SEML approaches. For DNN training, prior work predicts future behavior using learning curves---i.e., the learning accuracy of an algorithm as a function of its training time~\cite{swersky2014freeze,domhan2015speeding,Klein2017LearningCP}. However, Bayesian optimization does not have an analogous structure to learning curves, so we need a different mechanism for predicting future behavior and in this work we demonstrate the use of censored regression for this prediction problem. For Bayesian optimization, \citet{hutter2013bayesian} and \citet{eggensperger2020neural} apply measured early termination to terminate samples when their measured behavior reaches the termination threshold. Cello{}, however, uses predictive early termination to terminate samples when their predicted behavior---obtained from censored regression---reaches the termination threshold. This prediction step enables much earlier termination and thus saves more time for Cello{} to explore more samples compared to prior work (\cref{sec:res-good},\cref{sec:res-samples}). \subsection{Machine Learning for Behavior Prediction}\label{sec:ml-pred} A large body of machine learning techniques have been applied to predict high-level system behavior for resource management \cite{ponomarev2001reducing,choi2006learning,lee2007methods,lee2008cpr,martinez2009dynamic,snowdon2009koala,cochran2011pack,zhang2012flexible,sridharan2013holistic,petrica2013flicker,oliner2013carat,Reddi2013,LEO,CALOREE,ding2019generative,zhang2020sinan,shi2019applying,shi2021hierarchical} and scheduling~\cite{tesauro2007reinforcement,winter2010scalable,van2012scheduling,quasar,paragon}. The general strategy is to use low-level, readily-available metrics (e.g., branch miss rates, IPC) to predict high-level behavior (e.g., throughput or latency)~\cite{lee2006accurate,Ipek2008,bitirgen2008coordinated,snowdon2009koala,dubach2010predictive,Reddi2013,teran2016perceptron,peled2019neural,ding2019generative,bhatia2019perceptron,garza2019bit,bera2021pythia,peled2015semantic}. For example, \citet{lee2006accurate,lee2010applied} apply linear regression to predict performance and power. \citet{paragon,quasar} use collaborative filtering to predict job performance for datacenter workloads. \citet{LEO,CALOREE} use hierarchical Bayesian models to predict latency and energy. \citet{garza2019bit} and \citet{bhatia2019perceptron} use perceptrons to predict branch and prefetcher behavior. \begin{figure}[!htb] \centering \includegraphics[width=\linewidth]{fig/motive_bo} \caption{Comparing prediction accuracy between standard regression (SR) and censored regression (CR) in terms of mean squared error (MSE) on \texttt{als}.} \label{fig:motive_srcr} \end{figure} \begin{figure*}[!htb] \centering \includegraphics[width=0.8\textwidth]{fig/workflow.png} \caption{Cello{} workflow. White Box A is Bayesian optimization, and shaded Boxes B to D are unique to Cello{}. } \label{fig:workflow} \end{figure*} Most prior work achieves high prediction accuracy relying on a training set that includes samples in a wide range of behavior. Bayesian optimization, however, accumulates samples as more iterations finish. Thus, there are insufficient samples as training data in the early stage of Bayesian optimization, and these samples are likely to lie in the range of poor values~\cite{rasley2017hyperdrive}. Directly training models on these samples will predict running samples to be poor, which leads to a increasing number of predictions of poor values and thus inaccurate sample selection for the next round~\cite{roy2021bliss}. To overcome this inaccuracy, Cello{} utilizes knowledge of the current elapsed latency and energy at each time interval to generate more accurate predictions through censored regression. \textbf{An example of prediction accuracy.} To demonstrate the benefits of censored regression, we run Bayesian optimization on the \texttt{als} workload and predict each new configuration's latency with different predictors: standard and censored regression. We use gradient boosting trees as our standard regression model due to its high predictive accuracy~\cite{chen2016xgboost}. We monitor the workload execution and predict its latency at each time interval (see~\cref{sec:eval-method}). The censoring threshold for censored regression is the elapsed latency observed at each time interval. We compute the mean squared error (MSE) between predicted latency and true latency. Figure~\ref{fig:motive_srcr} shows the results, where the y-axis represents the average MSE over all time intervals, lower is better. Censored regression has 2.84$\times$ lower MSE than standard regression. This example illustrates that censored regression is effective at improving prediction accuracy when training on samples collected from Bayesian optimization. The accurate prediction from censored regression is fundamental to predictive early termination in Cello{}, as we describe next.
{'timestamp': '2022-04-12T02:30:22', 'yymm': '2204', 'arxiv_id': '2204.04831', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04831'}
arxiv
\section{Introduction}\label{S:intro} Recent advances in array-based and next-generation sequencing (NGS) technologies have revolutionized biomedical research, especially in cancer. The rapid decline in the cost of genome technologies has facilitated the availability of datasets that involve intrinsically different sizes and scales of high throughput data, providing genome-wide, high resolution information about the biology of cancer. In general, a common goal is the identification of differential genomic signatures between groups of samples corresponding to different treatments or biological conditions, e.g., treatment arms, response to adjuvant chemotherapy, tumor subtypes, or cancer stages. The analytic challenges include the high dimensionality of genomic biomarkers or probes, usually in the hundreds of thousands, and the relatively small number of patient samples, usually no more than a few~hundred. This ``small $n$, large $p$'' setting results in unstable inferences due to collinearity. Further, there exist complex interaction patterns, such as signaling or functional pathway-based interactions, and genomic or chromosomal location-based serial correlation for high-throughput sequencing data. These data attributes significantly affect the reliability of detecting differential genomic signatures by statistical techniques. \paragraph{Differential DNA methylation in cancer studies} DNA methylation is an important epigenetic mechanism that occurs by the addition of a methyl (CH$_3$) group to DNA, resulting in the modification of gene functions. It typically occurs at specific genomic locations called cytosine-phosphate-guanine (CpG) sites. Alterations in DNA methylation, e.g., hypomethylation of oncogenes and hypermethylation of tumor suppressor genes, are often associated with the development and progression of cancer \citep{feinberg2004history}. It was previously believed that these alterations occur almost exclusively at promoter regions known as CpG islands, which are chromosomal regions with a high frequency of CpG sites. However, with the advent of high-throughput technologies, it has been shown that a significant proportion of methylation alterations related to cancer do not occur in either promoters or CpG islands \citep{irizarry2009genome}, prompting higher resolution, epigenome-wide investigations. Gastrointestinal (GI) cancer, the most common form of cancer in the U.S. \citep{CAAC:CAAC21387}, are malignant conditions affecting the digestive system, and are associated with epigenetic alterations \citep{vedeld2017epigenetic}. Molecular characterization of the different cancer types, facilitated by the identification of differentially methylated CpG sites, is therefore key to better understanding GI cancer. In the motivating application, we analyze methylation profiles publicly available from The Cancer Genome Atlas (TCGA) project, consisting of 1,224 tumor samples belonging to four GI cancers of the upper digestive tract: stomach adenocarcinoma (STAD), liver hepatocellular carcinoma (LIHC), esophageal carcinoma (ESCA) and pancreatic adenocarcinoma (PAAD). For 485,577 probes, with each probe mapped to a CpG site, DNA methylation levels ranging from 0 (no methylation) to 1 (full methylation) were measured using the Illumina Human Methylation 450 platform. \begin{figure}[h] \centering \includegraphics[width=0.7\textwidth]{figures/PlotData_20200330_5.pdf} \caption{Methylation levels of CpG sites near gene TP53.} \label{intro_data_plots} \end{figure} Figure \ref{intro_data_plots} displays the methylation levels for CpG sites near TP53, a tumor suppressor gene located on chromosome $17$. A random subset of the samples was chosen to facilitate an informal visual evaluation. The four sets of colors and shapes of the points represent the four upper GI cancers. Although differential methylation is clearly visible at some CpG sites, the differences are generally subtle, demonstrating the need for sophisticated statistical analyses. An obvious feature is the correlation between the apparent methylation statuses of nearby CpG sites \citep{eckhardt2006dna, irizarry2008comprehensive, leek2010tackling}. The dependence of proximal CpG sites is also seen in Figure \ref{intro_data_plots2} of Supplementary Material, where we find high first order autocorrelations and highly significant tests for serial correlations. Furthermore, the variability of the inter-probe spacings in Figure~\ref{intro_data_plots} suggests that the need for modeling distance-based dependencies. \paragraph{Existing statistical approaches for differential DNA methylation and limitations} Numerous frequentist and Bayesian methods have been developed for differential DNA methylation, and can be broadly classified into four categories: \textit{(i)} \textit{Testing-based methods}, such as Illumina Methylation Analyzer (IMA) \citep{wang2012ima}, City of Hope CpG Island Analysis Pipeline (COHCAP) \citep{warden2013cohcap}, and BSmooth \citep{hansen2012bsmooth}. These methods rely on two-sample or multiple-sample tests for the mean group differences at each CpG site. \textit{(ii)} \textit{Regression based models}, such as Methylkit \citep{akalin2012methylkit}, bump hunting \citep{jaffe2012bump}, Biseq \citep{hebestreit2013detection}, and RADMeth \citep{dolzhenko2014using}. After applying smoothing or other adjustments, these methods fit individual regression models for each CpG site and test for significance. \textit{(iii)} \textit{Beta-binomial model-based methods}, such as MOABS \citep{sun2014moabs}, DSS \citep{feng2014bayesian}, and methylSig \citep{park2014methylsig}. These methods fit separate models for each CpG site. \textit{(iv)} \textit{Hidden Markov models (HMMs)}, such as MethPipe \citep{song2013reference}, Bisulfighter \citep{saito2014bisulfighter}, and HMM-DM \citep{yu2016hmm}. These methods detect differentially methylated sites based on the inferred hidden~states. The aforementioned methods have several deficiencies. Most methods ignore the strong correlations between neighboring CpG sites or probes, fitting separate models to each probe. This reduces the detection power for the relatively small sample sizes. Additionally, beta-binomial, HMM, and most of the testing-based methods are able to accommodate only two treatments or groups. To handle multiple treatments, they resort to inefficient multiple comparison adjustments. The methods that account for serial dependence (e.g., HMMs) do not adjust for the widely varying distances between the probes, instead assuming uniform inter-site dependencies. The few methods that account for inter-site distances \citep[e.g.,][]{hansen2012bsmooth, jaffe2012bump, hebestreit2013detection} rely on ad hoc parameter-tuning procedures that do not adjust for the distinctive data characteristics. Motivated by these challenges, we propose general and flexible methodology for differential analysis in DNA methylation data, referred to as \textit{BayesDiff}. Rather than fitting a separate model for each CpG site or probe, BayesDiff relies on a global analytical framework for simultaneous inferences on the probes that adapts to the unique data attributes. To diminish collinearity effects and achieve dimension reduction, the probes are allocated to a smaller, unknown number of latent clusters based on the similarities of probes-specific multivariate parameters. Finally, differential state variables of the probes delineate the genomic signature of the disease to fulfil the main inferential goal. For realistically modeling the probe-cluster allocation mechanism of DNA methylation profiles, we devise an extension of Poisson Dirichlet processes (PDPs) \citep{perman1992size} called the \textit{Sticky PDP} (equivalently, the \textit{two-restaurant two-cuisine franchise}). In addition to accounting for long-range biological interactions, this nonparametric process accommodates distance-based serial dependencies of the probes. Additionally, separately for the differential and non-differential probes, it flexibly permits the data to direct the choice between PDPs, and their special case, Dirichlet processes, in finding the best-fitting allocation schemes. We implement an inferential procedure using a Markov chain Monte Carlo (MCMC) algorithm which is specifically designed for posterior inferences in Sticky PDPs and is scalable to the typically large methylation datasets. Simulation results show that our approach significantly outperforms existing methods for multigroup comparisons in datasets with or without serial correlation. For the motivating TCGA dataset, in addition to confirming known features of DNA methylation and disease-gene associations, the analysis reveals interesting aspects of the biological mechanisms of upper GI~cancers. The rest of the paper is organized as follows. Section \ref{model_desc_section} describes the BayesDiff approach, with Section~\ref{Sticky_PDPs_DA} introducing the Sticky PDP or two-restaurant two-cuisine franchise (2R2CF) for differential DNA methylation. Section~\ref{S:post_inf} outlines a computationally efficient posterior inference procedure for detecting differential probes. For varying noise and correlation levels, Section \ref{sim_study} uses artificial datasets to assess the accuracy of BayesDiff in detecting disease genomic signatures and compares the results with established techniques for DNA methylation data. The motivating upper GI dataset is analyzed using the BayesDiff procedure in Section \ref{data_analysis}. Finally, conclusions and future related work are discussed in Section~\ref{disc}. \section{The BayesDiff Model} \label{model_desc_section} Sequencing technologies measure DNA methylation levels of $p$ biomarkers represented by CpG sites (``probes'') and $n$ matched patient or tissue samples (``individuals''), with $p$ much larger than $n$. The data belong to the interval $[0,1]$ and are arranged in an $n \times p$ matrix of proportions, $\mathbf{X}=((x_{ij}))$, for individuals $i$ and probes $j$, with the probes sequentially indexed by their genomic locations. The distances between adjacent probes are denoted by $e_1,\ldots,e_{p-1}$, and typically exhibit high variability, e.g., in the upper GI TCGA dataset, the inter-probe distances range from 2 base pairs to 1 megabase pair. Each individual $i$ is associated with a known experimental or biological condition (``treatment'') denoted by $t_i$ that takes values in $\{1,...,T\}$, $T\ge 2$. In the motivating TCGA data, there are $T=4$ upper GI cancer~types. We model the logit transformation of the methylation levels, $z_{ij}=\log\left(x_{ij}/\left(1-x_{ij}\right)\right)$, as follows: \begin{equation} z_{ij} \sim N\left(\xi_i+\chi_j+\theta_{t_ij},\sigma^{2}\right) \label{def_main_model} \end{equation} where $\xi_i$ represents the $i$th subject's random effect, $\chi_j$ represents the $j$th probe's random effect, and $\theta_{tj}$ is the random treatment $t$--probe $j$ interaction effect. The main inferential goal is the detection of differential probes, i.e., probes $j$ for which the elements of column vector $\boldsymbol{\theta}_j=$ $\left(\theta_{1j},\dots, \theta_{Tj}\right)'$ are not all identical. Consequently, we define a binary \textit{differential state variable}, $s_j$, with $s_j=1$ indicating that probe $j$ is not differential, and $s_j=2$ indicating that it is differential: \begin{align} s_j= \begin{cases} 1 \qquad\text{if } \theta_{1j}=\theta_{2j}=\dots=\theta_{Tj}, \\ 2 \qquad \text{otherwise}, \end{cases} \label{def_nonDE} \end{align} for $j=1, \dots, p$. Thus, the key parameters for differential methylation are $s_1,\ldots,s_p$, with the disease genomic signature consisting of the probes with state $s_j=2$. Motivated by the distance-dependent correlations exhibited by DNA methylation data and the deficiencies of existing statistical approaches noted in Section \ref{S:intro}, this paper fosters a novel Bayesian nonparametric framework for the random effects $\boldsymbol{\theta}_1,\ldots,\boldsymbol{\theta}_p$ on which the differential state variables depend. \subsection*{Modeling probe clusters} \label{PDP_sec_main} As mentioned, in addition to high-dimensionality, the analytical challenges posed by DNA methylation datasets include pervasive collinearity caused by dependencies between physically proximal CpG sites or probes. Additionally, there are long-range dependencies between non-adjacent probes due to biological interactions, e.g., signaling or functional pathways. To accommodate dependencies and extract information from the large number of probes, we allocate the $p$ probes to a much smaller number, $q$, of latent clusters based on the similarities of the random effects $\boldsymbol{\theta}_j$ for probes $j=1,\ldots,p$. We favor clustering to dimension reduction methods such as principal components analysis (PCA). Specifically, because each principal component is a linear combination of all $p$ biomarkers, PCA is less useful in cancer research because of its inability to select features, i.e., probes. By contrast, our approach facilities biological interpretations by identifying CpG sites relevant to the differential disease genomic~signatures. Suppose that an \textit{allocation variable}, $c_j$, assigns probe $j$ to one of $q$ latent clusters, where $q$ is unknown. The event $[c_j=k]$ signifies that the $j^{th}$ probe belongs to the $k^{th}$ latent cluster, $k=1,\dots, q$. We assume that the $q$ clusters are associated with \textit{latent vectors}, $\boldsymbol{\lambda}_1,\dots, \boldsymbol{\lambda}_q$, where the probe-specific random effects and cluster-specific latent vectors have the relation: \begin{equation} \boldsymbol{\theta}_j=\boldsymbol{\lambda}_k \quad \text{if $c_j=k$.}\label{allocation c} \end{equation} That is, all probes within a cluster are assumed to have identical random effects equal to that cluster's latent vector. The differential state variables of the probes, defined in equation (\ref{def_nonDE}), then become a shared attribute of their parent cluster, and clusters as a whole are either differentially or non-differentially methylated. Further, if probe $j$ belongs to cluster $k$ (i.e., $c_j=k$), then condition $\theta_{1j}=\theta_{2j}=\dots=\theta_{Tj}$ in equation~(\ref{def_nonDE}) is equivalent to $\lambda_{1k}=\lambda_{2k}=\dots=\lambda_{Tk}$, and differential clusters constitute the set \begin{equation} \mathcal{D} = \left\{k: \lambda_{tk} \neq \lambda_{t^{'}k}, \text{ for some } t \neq t^{'}, k=1,\ldots,q\right\}. \label{D} \end{equation} \paragraph{Mixture models for allocation} Bayesian infinite mixture models are a natural choice for allocating $p$ probes to a smaller, unknown number of latent clusters based on their random effects similarities. Dirichlet processes \citep{ferguson1973bayesian} are arguably the most frequently used infinite mixture models; see \citet[chap.\ 4]{muller2013bayesian} for a comprehensive review. The use of Dirichlet processes to achieve dimension reduction in massive datasets has precedence in the literature, albeit in unrelated applications \citep[see][]{Medvedovic_etal_2004,Kim_etal_2006, Dunson_etal_2008,Dunson_Park_2008,Guha_Baladandayuthapani_2016}. \cite*{Lijoi_Mena_Prunster_2007b} advocated the use of Gibbs-type priors \citep*{Gnedin_Pitman_2005} for accommodating more flexible clustering mechanisms, and also demonstrated the utility of Poisson-Dirichlet processes (PDPs) in genomic applications. Formally, the two-parameter PDP \citep{perman1992size} relies on a discount parameter $d \in [0,1)$, positive mass parameter $\alpha$, and $T$-variate base distribution $W$, and is denoted by $\mathcal{W}(d,\alpha,W)$. The value $d=0$ yields a Dirichlet process with mass parameter $\alpha$ and base distribution $W$. Suppose $\boldsymbol{\theta}_1, \ldots, \boldsymbol{\theta}_p$ are distributed as $\mathcal{W}(d,\alpha,W)$. The \textit{stick-breaking representation} of $\mathcal{W}(d,\alpha,W)$ is $\boldsymbol{\theta}_j \stackrel{iid}\sim \mathcal{P}$, where random distribution $\mathcal{P}$ is the discrete mixture $\sum_{v=1}^\infty \pi_v \delta_{\boldsymbol{\phi}_v}$, with $\delta_{\boldsymbol{\phi}_v}$ denoting a point mass located at the atom $\boldsymbol{\phi}_v \stackrel{iid}\sim W$. The random stick-breaking probabilities have the form $\pi_1 = V_1$, and $\pi_h = V_h \prod_{v=1}^{h-1}(1-V_v)$ for $h > 1$, where $V_h \stackrel{indep}\sim \text{beta}(1-d, \alpha+hd)$. \cite{Guha_Baladandayuthapani_2016} introduced VariScan, a technique that utilizes PDPs and Dirichlet processes for clustering, variable selection, and prediction in high-dimensional regression problems in general, and in gene expression datasets in particular. They also demonstrated that PDPs are overwhelmingly favored to Dirichlet processes in gene expression datasets, which typically exhibit no serial~correlation. \paragraph{Limitations of existing mixture models} Although the aforementioned mixture models achieve dimension reduction in the large number of probes and account for the long-range biological interactions between non-adjacent probes, a potential drawback is their implicit assumption of apriori probe (i.e., CpG site) exchangeability. Consequently, these techniques cannot account for the serial correlation among CpG sites in methylation data. Infinite HMMs, such as the hierarchical Dirichlet process hidden Markov model (HDP-HMM) \citep{Teh_etal_2006} and Sticky HDP-HMM \citep{Fox_etal_2011}, may be utilized to fill this gap. Although these models are a step in the right direction, they have several undesirable features for differential analysis. \textit{First}, the degree of first order dependence is uniform irrespective of the inter-probe distances. This is unrealistic in methylation datasets where the correlation between adjacent probes typically decreases with inter-probe distance \citep{hansen2012bsmooth, jaffe2012bump, hebestreit2013detection}. {\textit{Second}, an ad hoc exploratory analysis of the GI cancer dataset reveals that the serial correlation in the treatment-probe effects is weaker than the serial dependence between the differential state variables defined in equation (\ref{def_nonDE}). Although there may not be a biological explanation for this phenomenon, this makes sense from a statistical perspective, because the differential states are binary functions of the treatment-probe interactions; the differential states are more sensitive in detecting first order dependence even when the higher-dimensional (and noisier) treatment-probe interactions show weak or no correlation.} This suggests that a hypothetical two-group Markov model, rather than an infinite-group Markov model such as HDP-HMM or Sticky HDP-HMM, would provide a better fit for the data. \textit{Third}, the range of allocation patterns supported by infinite HMMs is relatively limited. In particular, realistic allocation patterns, such as power law decays in the cluster sizes and large numbers of small-sized clusters, a common feature of cancer datasets \citep{Lijoi_Mena_Prunster_2007a}, are assigned relatively small prior probabilities by infinite HMMs. \subsection{Sticky PDP: A Two-restaurant, Two-cuisine Franchise (2R2CF) for Differential Analysis}\label{Sticky_PDPs_DA} For the aforementioned reasons, we invent a mixture model called the Sticky PDP. Essentially, this is a cohort of regular PDPs that generates the probe-specific random effects, $\boldsymbol{\theta}_1,\ldots,\boldsymbol{\theta}_p$, by switching the generative PDPs at random locations along the probe sequence. Alternatively, the well-known Chinese restaurant franchise (CRF) metaphor for HDP-HMMs and Sticky HDP-HMMs \citep[e.g.,][]{Fox_etal_2011} can be generalized to the \textit{two-restaurant two-cuisine franchise} (2R2CF) to provide an equivalent representation of Sticky PDPs appropriate for differential analysis. We present an overview of 2R2CF followed by an in-depth~description. Imagine that a franchise has two restaurants, labeled 1 and 2. Each restaurant consists of two sections, and each section serves a single cuisine consisting of an infinite number of dishes. Section 1 in both the restaurants exclusively serves its customers cuisine~1, whereas section 2 exclusively serves cuisine 2. The \textit{section-cuisine menu}, or a list of available cuisine dishes, is identical at the two restaurants. Although both restaurants serve the two cuisines in their respective sections, restaurant~1 specializes in cuisine~1, and consequently, cuisine 1 is more popular with restaurant~1 patrons. Similarly, cuisine 2 is more popular at restaurant 2 because it specializes in that cuisine. Although every menu item is available at both the restaurants, the relative popularity of each menu item is generally different at the two restaurants. A succession of $p$ customers, representing the CpG sites or probes, arrive at the franchise, and each customer selects a restaurant followed by a section (equivalently, cuisine) in that restaurant. The waiting times between successive customers, $e_1, \dots,e_{p-1}$, represent the inter-probe distances. Cuisine 1 symbolizes the {non-differential state}, and cuisine 2 symbolizes the {differential state}. Each restaurant section has an infinite number of tables. A restaurant customer who selects a particular section may either sit at one of the tables already occupied by previous customers in that section, or sit at a new table. All customers whose choose an already occupied table are served the same dish, previously chosen from the section-cuisine menu by the first customer who sat at that table. Multiple tables in a section may serve the same dish. The dish that franchise customer $j$ eats represent their probe-specific random effect, $\boldsymbol{\theta}_j$, of length $T$. Since cuisine 1 represents the {non-differential state}, its dishes are characterized by random effects vectors with all $T$ elements equal. Similarly, the cuisine 2 (differential state) dishes are characterized by $T$-variate random vectors with at least two unequal elements. By design, if a customer has eaten a dish belonging to cuisine 1 (2), the next customer is more likely to visit restaurant 1 (2), where that cuisine is more popular there. Consequently, a customer tends to select the same cuisine as the previous customer. This model feature accounts for long runs of differential or non-differential states. However, a customer's influence on the next customer diminishes as the time interval separating the two customers~increases. That is, the differential statuses of two adjacent probes become statistically independent in the limit as their inter-probe distance~grows. The process evolution is graphically illustrated in Figure~\ref{2R2CF plots} and discussed below in greater~detail. \paragraph{Cuisine 1 menu.} As mentioned, the dishes list on the cuisine 1 menu are characterized by random vectors with all $T$ elements equal. Therefore, they are modeled by \textit{menu distribution} $W_1$ having the following structure: with $\boldsymbol{1}_T$ denoting the column vector of $T$ ones, \begin{align} W_1 &\stackrel{d} = \psi\boldsymbol{1}_T, \quad\text{where $\psi \in \mathcal{R}$ with}\label{W1}\\ \psi & \sim G, \notag\\ G & \sim \mathcal{DP} \left(\beta,G_0\right),\quad\text{and}\notag\\ G_0&=N\left(\mu_G,\tau_G^{2}\right). \nota \end{align} The symbol $\mathcal{DP} \left(\beta,G_0\right)$ denotes a Dirichlet process prior with mass parameter $\beta>0$ and base distribution $G_0$. The stick-breaking representation of the Dirichlet process implies that random distribution $G$ is almost surely discrete, and has the mixture distribution \begin{equation} G \stackrel{d}= \sum_{v=1}^\infty \varpi_{v} \delta_{\zeta_{v}}, \text{ where $\sum_{v=1}^\infty \varpi_{v}=1$ and $\zeta_{v} \stackrel{iid}\sim G_0$}. \label{density G} \end{equation} The precise form of the random probabilities, $\varpi_{v}$, which depend on mass parameter $\beta$, was derived in \cite{sethuraman1994constructive}; see also \cite{Ishwaran_James_2003} and \cite{Lijoi_Prunster_2010}. For natural numbers $\mathcal{N}$, the set $\mathcal{S}_1=$ $\{\zeta_{v}\boldsymbol{1}_T : v \in \mathcal{N}\}$ then represents the list of available cuisine 1 dishes, and is the support of distribution $W_1$. The continuity of base distribution $G_0$ guarantees that all the menu dishes are unique. The fact that distribution $G$ is discrete has practical consequences for differential analysis: \textit{(a)} cuisine 1 consists of a countably infinite set, rather than a continuous spectrum, of dishes, and \textit{(b)} any two section 1 tables may potentially serve the same cuisine~1 dish even if the tables belong to different restaurants. \paragraph{Cuisine 2 menu.} As previously stated, the cuisine dishes characterize the {differential state} through $T$-variate random vectors with at least two unequal elements. The menu is modeled by a distribution, $W_2$, satisfying two conditions: \textit{(i)}~for similar reasons as the cuisine 1 menu, $W_2$ is a countably infinite distribution, and \textit{(ii)} each atom of $W_2$ has at least two unequal elements. For every $\boldsymbol{\phi}=(\phi_1,\ldots,\phi_T)' \in \mathcal{R}^T$, a probability mass function satisfying both conditions can be constructed as follows: \begin{align} W_2(\boldsymbol{\phi}) = \begin{cases} \prod_{t=1}^T G(\phi_t)/\bigl(1-\sum_{v=1}^\infty \varpi_{v}^T\bigr) &\qquad\text{if $\phi_{t}\neq \phi_{t'}$ for some $t\neq t'$,}\\ 0 &\qquad\text{otherwise.} \end{cases}\label{density W2} \end{align} where $G(\phi)$ denotes the mass function of distribution $G$, defined in equation~(\ref{density G}) and evaluated at $\phi\in \mathcal{R}$. Then, as required, the menu distribution $W_2$ is discrete and has the countable support, \[ \mathcal{S}_2 = \{(\zeta_{v_1},\ldots,\zeta_{v_T})':\text{$\zeta_{v_t}\neq \zeta_{v_{t'}}$ for some integers $v_t\neq v_{t'}$, where $(v_1,\ldots,v_T) \in \mathcal{N}^T$}\}. \] We observe that the differential and non-differential states communicate through the shared distribution $G$. When the number of treatments, $T$, is~large, the discreteness of distribution $G$ causes dimension reduction in the $T$-variate differential state atoms by allowing ties between the atom elements, and resulting in a relatively small number of unique elements within each $T$-variate atom. When $T$ is~large, this model feature facilities computational savings for the inferential procedure. \subsubsection{Selections made by sequentially arriving 2R2CF customers} For $j \ge 1$, let the restaurant chosen by customer $j$ be denoted by $g_j$ and the cuisine (i.e.,~section) chosen by customer $j$ be denoted by $s_j$. \paragraph{Customer 1.} Suppose the first franchise customer, arriving at time $0$, selects restaurant $g_1=1$ with probability $\rho_1>0$ and selects restaurant $g_1=2$ with positive probability $\rho_2=1-\rho_1$. For reasons that will become clear, we refer to $\rho_1$ as the \textit{baseline non-differential proportion} and $\rho_2$ as the \textit{baseline differential proportion}. Typically, the differential state is less frequent than the non-differential state, and so $\rho_2<\rho_1$ (i.e.,~$\rho_2<1/2$). \textbf{\textit{Choice of cuisine $s_1$}} \quad Next, customer 1 selects one of the two cuisine-sections in restaurant $g_1$. Recall that each restaurant specializes in the cuisine with the same label, and the specialty cuisine is more popular there. In differential analysis, this is guaranteed by the following assumption. Within restaurant $g_j$ (where $j=1$ for the first customer), assume customer $j$ selects cuisine 1 with probability \begin{align} \mathcal{Q}_{g_j}(1) = \begin{cases} \rho_1 + \rho_2 \gamma &\qquad \text{if $g_j=1$,}\\ \rho_1 - \rho_1 \gamma &\qquad \text{if $g_j=2$,}\\ \end{cases} \label{PDP_state_prob1} \end{align} for a \textit{speciality-cuisine popularity parameter}, $\gamma \in (0,1]$, determining the degree to which a restaurant's patrons tend to favor its namesake cuisine. Expression (\ref{PDP_state_prob1}) implies that the customer chooses cuisine 2 in restaurant~$g_j$ with probability $\mathcal{Q}_{g_j}(2)=1-\mathcal{Q}_{g_j}(1)$. \textbf{\textit{Choice of table $v_1$ and dish $\boldsymbol{\theta}_{1}$}} \quad Since the identifiers of the infinite tables belonging to section $s_1$ of restaurant $g_1$ are arbitrary, we assume without loss of generality that customer 1 sits at table $v_1=1$, and the tables in the restaurant section are assigned consecutive labels as they are occupied by sequentially arriving patrons. Next, customer~$1$ randomly orders a dish according to menu distribution $W_{s_1}$, and the dish represents the random effect of the first probe. In other words, $\boldsymbol{\theta}_{1}\mid s_1 \sim W_{s_1}$ \begin{figure} \centering \vspace{-.5 in} \includegraphics[width=0.84\textwidth]{figures/MRF1.pdf} \vspace{-1 in} \includegraphics[width=0.84\textwidth]{figures/MRF2.pdf} \vspace{-1 in} \includegraphics[width=0.84\textwidth]{figures/MRF3.pdf} \vspace{-.5 in} \caption{\small Cartoon representation of the two-restaurant two-cuisine franchise for differential analysis, showing the progressive choice of restaurant, cuisine section, and table by customer $j$, where $j>1$. The numbered circles represent the table numbers. See the text in Section \ref{Sticky_PDPs_DA} for a detailed description. } \label{2R2CF plots} \end{figure} \paragraph{Customer $j$, where $j>1$.} Unlike customer~1, the \textit{restaurant} choices of the subsequent customers are influenced by the \textit{cuisine} choice of their immediately preceding customer and also by the waiting time separating the two customers. When $j>1$, suppose customer $j$ arrives at the franchise after a time interval of $e_{j-1}$ after the $(j-1)$th customer. For a non-negative \textbf{\textit{dependence parameter}} $\eta$, time $e_{j-1}$ is first transformed to an \textbf{\textit{affinity}} measure between customer $(j-1)$ and customer $j$: \begin{align} r_j=\exp(-e_{j-1}/\eta), \qquad j>1, \label{def_dep_par} \end{align} belonging to the interval $[0,1]$ for $\eta>0$. If $\eta=0$, affinity $r_j$ is defined as $0$ irrespective of the waiting~time. As we will see, given the choices of the preceding customer, the affinity influences the behavior of customer $j$ through (\ref{PDP_grp_prob1}) defined below. Additionally, we assume without loss of generality that the waiting times $e_1,\ldots,e_{p-1}$ are scaled so that their total equals~1. Since the probes in differential analysis represent CpG sites on a chromosome, it has a unit scaled length if the first probe is located at the chromosomal~edge. \textbf{\textit{Choice of restaurant $g_j$}} \quad As previously mentioned, the cuisine $s_{j-1}$ chosen by the $(j-1)$th customer influences the restaurant choice of the $j$th customer. Specifically, the selected restaurant \[g_j \mid s_{j-1}\sim \mathcal{F}_j, \] where, using the speciality-cuisine popularity parameter $\gamma$ defined in (\ref{PDP_state_prob1}), the probability that customer $j$ selects restaurant 1 is \begin{align} \mathcal{F}_j(1) \stackrel{def}= P(g_j = 1 \mid s_{j-1}) = \begin{cases} \rho_1 + \rho_2 r_j /\gamma &\qquad\text{if $s_{j-1}=1$,}\\ \rho_1 - \rho_1 r_j /\gamma &\qquad\text{if $s_{j-1}=2$,}\\ \end{cases} \label{PDP_grp_prob1} \end{align} so that $\mathcal{F}_j(2)=1-\mathcal{F}_j(1)$. The idea is illustrated in the top panel of Figure \ref{2R2CF plots}, where customer $j$ chooses restaurant 1 with probability $\mathcal{F}_j(1)$ and restaurant 2 with probability $\mathcal{F}_j(2)$. As seen from definition (\ref{PDP_grp_prob1}), if $\eta>0$, these probabilities depend on the cuisine section $s_{j-1}$ of the previous customer and on the waiting time, $e_{j-1}$. If $\eta=0$, on the other hand, the restaurant choices of the customers are independent of one another, and $\mathcal{F}_j(g) =\rho_g$, $g=1,2$. It is easily verified that $\mathcal{F}_j$ is a probability mass function if and only if $r_j/\gamma<1$. Since the scaled waiting times are bounded above by 1, a globally sufficient condition is $\eta < -1/\log \gamma$. We therefore assume a mixture prior for dependence parameter $\eta$: \begin{align} \eta \mid \gamma \sim \frac{1}{2}\delta_{0} + \frac{1}{2} \mathcal{H}\cdot \mathcal{I}(\eta<-1/\log \gamma), \label{etaPrior} \end{align} where the second mixture component involves a continuous distribution, $\mathcal{H}$, restricted to the interval $[0,-1/\log \gamma)$, thereby enforcing the sufficient condition. Speciality-cuisine popularity parameter $\gamma$ is assigned an independent uniform prior on the unit interval. In our experience, posterior inferences on $\eta$ are relatively robust to the continuous prior $\mathcal{H}$ provided it is not highly concentrated on a small part of interval $[0,-1/\log \gamma)$. When $\eta=0$, we have a \textit{zero-order Sticky PDP}. On the other hand, when $\eta>0$, we obtain a \textit{first order Sticky PDP}. Some interesting consequences of specification~(\ref{PDP_grp_prob1}) are: \begin{enumerate} \item \textbf{Zero-order Sticky PDP}: When $\eta=0$, each customer independently chooses restaurant 1 (or 2) with probability equal to the baseline proportion of $\rho_1$ (or $\rho_2$), and the $p$ customers also act identically. \item \textbf{First order Sticky PDP with $e_{j-1}/\eta$ large}: \quad Customer $j$ acts approximately independently of the history. Specifically, somewhat similarly to customer 1, customer $j$ chooses restaurant 1 (2) with probability approximately, but not exactly equal to the baseline proportion of $\rho_1$ ($\rho_2$). In other words, at large distances, consecutive customers do not appreciably influence each other's choices. \item \textbf{First order Sticky PDP with $e_{j-1}/\eta$ small}: \quad In the limit as $e_{j-1}/\eta \to 0$ (e.g., for an infinitesimal inter-probe distance $e_{j-1}$), the restaurant choice of customer~$j$ follows a hidden Markov model. \end{enumerate} Since it drives the dependence characteristics of DNA methylation data, posterior inferences on dependence parameter $\eta$ are of interest. Prior specification~(\ref{etaPrior}) allows the data to direct the model's order through posterior probability, $P[\eta = 0 \mid \boldsymbol{X}]$. An MCMC probability estimate is readily available. \textbf{\textit{Choice of cuisine $s_j$}} \quad Within restaurant $g_j$, customer $j$ selects cuisine-section $s_j$ with distribution $\mathcal{Q}_{g_j}$, defined earlier in expression (\ref{PDP_state_prob1}). For a graphical depiction, see the middle panel of Figure \ref{2R2CF plots}, where $g_j=1$. That is, customer~$j$, having already chosen restaurant $1$, must now choose a cuisine section. Restaurant 2 has been greyed out because it is no longer accessible to this customer. In the lower panel of Figure \ref{2R2CF plots}, we find that the customer has picked cuisine-section 1, i.e.,~$s_j=1$, and so, the other restaurant sections are greyed out. \textbf{\textit{Choice of table $v_j$}} \quad Of the previous $(j-1)$ customers, consider the $p_{j-1}$ customers who also chose cuisine-section $s_j$ in restaurant $g_j$. Then $p_{j-1}=$ $\sum_{l=1}^{j-1}\mathcal{I}(g_l=g_j, s_l=s_j)$. Let the number of tables occupied by these customers in section $s_j$ of restaurant $g_j$ be $M_{j-1} \ge 0$. Recall that all customers seated at a table are served the same dish, chosen from the cuisine menu (in this case, cuisine $s_j$) by the first customer seated at that table. If $M_{j-1} > 0$, that is, if customer $j$ is not the first patron of the restaurant section, let $\boldsymbol{\phi}_{g_j s_j k}$ denote the dish from cuisine $s_j$ served to the $p_{j-1, k}$ previous customers already seated at table $k$, where $k=1,\ldots,M_{j-1}$. Clearly, $p_{j-1, k}=\sum_{l=1}^{j-1}\mathcal{I}(g_l=g_j, s_l=s_j,v_l=k)$. Of course, $p_{j-1}=\sum_{k=1}^{M_{j-1}}p_{j-1, k}$. i.e., the number of people who selected section $s_j$ in restaurant $g_j$ before customer $j$, equals the number of people seated at all currently occupied tables in the restaurant~section. Recall that a new customer may sit at an already occupied table or a new table. Two of these possibilities are illustrated in the lower panel of Figure \ref{2R2CF plots}. For a PDP with mass parameter $\alpha_{s_j}$ and discount parameter $d_{s_j} \in [0,1)$, the predictive distribution of table $v_j$ selected by customer $j$ is specified as \begin{align} P\biggl(v_j = k \mid p_{j-1, 1}, \ldots, p_{j-1, M_{j-1}} \biggr) \propto \begin{cases} p_{j-1, k} - d_{s_j} \quad &\text{if $k = 1,\ldots,M_{j-1}$,}\\ \alpha_{s_j} + M_{j-1} d_{s_j} \quad &\text{if $k = (M_{j-1} + 1)$,}\\ \end{cases}\label{pred.table_j} \end{align} where the second line corresponds to customer $j$ sitting at a new table, in which case the updated number of occupied tables becomes $M_{j}=M_{j-1}+1$. Otherwise, if customer $j$ sits at a previously occupied table, then $M_{j}=M_{j-1}$. Obviously, $p_{j}=p_{j-1}+1$. Distribution (\ref{pred.table_j}) implies that customer $j$ is more likely to choose already occupied tables with many occupants, positively reinforcing the selected table's popularity for future customers. The number of occupied tables stochastically increases with the PDP mass and discount parameters. When PDP discount parameter $d_{s_j} = 0$, we obtain the well-known P\`{o}lya urn scheme for Dirichlet processes \citep{Ferguson_1973} for section $s_j$. PDPs act as effective dimension reduction devices because the random number of occupied tables is much smaller than the number of customers. Specifically, as the number of patrons in the restaurant section grows, i.e.,~as $p_j\to \infty$, the number of occupied tables, $M_{j}$, is asymptotically equivalent to \begin{align} \begin{cases} \alpha_{s_j} \log p_j \qquad &\text{if $d_{s_j} = 0$} \\ T_{d_{s_j}, \alpha_{s_j}} \, p_j^{d_{s_j}}\qquad &\text{if $0 < d_{s_j} < 1$}\\ \end{cases}\label{q} \end{align} for a positive random variable $T_{d_{s_j}, \alpha_{s_j}}$ \citep{Lijoi_Prunster_2010}. \textbf{\textit{Choice of dish $\boldsymbol{\theta}_j$}} \quad If customer $j$ sits at a previously occupied table, he or she is served the dish selected by the first customer to occupy that table. Otherwise, if a new table is chosen, customer $j$ picks a dish from menu distribution $W_{s_j}$. The dish that customer $j$ eats represents probe-specific random effect~$\boldsymbol{\theta}_j$ and has the distribution: \begin{equation} \boldsymbol{\theta}_j \begin{cases} = \boldsymbol{\phi}_{g_j s_j v_j} \qquad &\text{if $v_j = 1,\ldots,M_{j-1}$,} \\ \sim W_{s_j}\qquad &\text{if $v_j = (M_{j-1}+1)$.}\\ \end{cases}\label{dish} \end{equation} If customer $j$ sits at an already occupied table, then $M_{j}=M_{j-1}$, and $\boldsymbol{\theta}_j=\boldsymbol{\phi}_{g_j s_j v_j}$ as indicated above. On the other hand, if customer $j$ selects a new table, i.e.,~if $v_j = (M_{j-1}+1)$, the number of occupied tables becomes $M_{j}=M_{j-1}+1$, and the newly selected dish, $\boldsymbol{\theta}_j=\boldsymbol{\phi}_{g_j s_j M_{j}}\sim W_{s_j}$ is served to all future customers who sit at table~$M_{j}$. A consequence of specifications (\ref{pred.table_j}) and (\ref{dish}) is that although each restaurant offers both cuisines and potentially serves every dish, the relative popularity of each dish is restaurant-specific. The aforementioned process continues for the subsequent franchise customers. As seen in expression (\ref{PDP_grp_prob1}), the cuisine selected by the previous customer influences the restaurant choice of a customer. Additionally, expression (\ref{PDP_state_prob1}) guarantees that a cuisine is more popular at its namesake restaurant. This makes a customer more likely to select the same cuisine as the previous customer, and facilitates lengthy runs of differential or non-differential states of the probes. In addition to achieving dimension reduction, the proposed Sticky PDP models serial dependencies in the two-state differential status of adjacent probes as a decreasing function of the inter-probe distances. \subsubsection{Latent clusters and their differential states}\label{S:latent clusters} The notion of latent clusters, introduced earlier in expression (\ref{allocation c}) and forming the basis of the dimenson reduction strategy, comprises all probes with identical random effects. Returning to the 2R2CF metaphor, we find that a cluster is therefore the set of customers eating the same dish. Recall that although customers seated at a table are served the same dish, multiple tables at the two restaurants may serve the same dish because of the shared cuisine menu. Aggregating customers eating the same dishes, irrespective of the restaurant, we obtain the probe-cluster allocation variables $c_1,\ldots,c_p$, and therefore, the random number of latent clusters, $q$. Additionally, the cuisines determine the common differential states; specifically, the set of distinct cuisine~2 dishes symbolizes the differential clusters, $\mathcal{D}$, defined in equation~(\ref{D}). From expression (\ref{q}), we expect the number of occupied tables to be much smaller than the number of franchise customers,~$p$. Further, since multiple tables at both restaurants can serve the same dish, the number of latent clusters, $q$, is smaller than the number of occupied tables. With high probability, this implies that $q$ is much smaller than $p$. \paragraph{PDP discount parameter $d_2$.} Consider the differential state cuisine menu, $W_2$, of definition~(\ref{density W2}). It can be shown that when the number of treatments $T \to \infty$, the individual elements of each $T$-variate atom of $W_2$ are asymptotically i.i.d.\ $G$, and the differential clusters are not only a posteriori asymptotically identifiable but also consistently detected; refer to Section 4 of \cite{Guha_Baladandayuthapani_2016} for a detailed discussion of this remarkable phenomenon in standard PDP settings. Since the differential clusters ae often accurately inferred when $T$ and $p$ are large, discount parameter $d_2$ is given the mixture prior: \begin{align*} d_2\sim \frac{1}{2}\delta_{0} + \frac{1}{2} U(0,1) \end{align*} where $d_2=0$ corresponds to a Dirichlet process. This provides the posterior flexibility to choose between a Dirichlet process and a more general~PDP for a suitable clustering pattern of the differential probes. Allocation patterns characteristic of non-Dirichlet PDPs, such as power law decays in the cluster sizes and relatively large numbers of small-sized clusters, cause the posterior of parameter $d_2$ to exclude 0. Allocation patterns more typical of Dirichlet processes, such as exponentially decaying cluster sizes dominated by a few large clusters, result in high posterior probabilities being assigned to $0$. A proof of the intrinsically different clusters of Dirichlet processes and PDPs is given in Theorem~2.1 of \cite{Guha_Baladandayuthapani_2016}. Since distribution $G$ is discrete, all atoms of $T$-variate distribution $W_2$ may not be unique. Indeed, this is common for $T=2$ treatments. However, as $T$ grows, and provided the number of probes, $p$, grows at a slower-than-exponential rate as $T$, the probability that any two allocated atoms are identical rapidly decays to 0. In regression problems unrelated to differential analysis, a similar result was derived for a relatively simple zero-order stochastic process in Section 2.3 of \cite{Guha_Baladandayuthapani_2016}. We have verified this phenomenon in our simulation studies on differential analysis datasets. In several hundred artificial datasets generated from the Sticky PDP, for $p=1,500$ probes and $T$ as small as four, no two allocated atoms of $W_2$ were identical. \paragraph{PDP discount parameter $d_1$.} Consider cuisine menu $W_1$ is defined in (\ref{W1}). The flexibility provided by PDP allocation patterns is not necessary for non-differential probes. This is because the allocation patterns of distribution $W_1$ are driven by univariate parameter $\psi$ in (\ref{W1}). In general, the allocations of univariate objects are unidentifiable \citep[e.g.,][]{Fruhwirth-Schnatter_2006}. Consequently, we set PDP discount parameter $d_1=0$, reducing the two PDPs associated with the non-differential state (i.e.,~section 1 in the two restaurants) to Dirichlet processes. \subsubsection{Other model parameters}\label{S:hyperpriors} Since the essential data features are mostly absorbed by the Sticky PDP model for the random effects $\boldsymbol{\theta}_{j}$, we can specify simpler parametric models for the remaining terms in relation (\ref{def_main_model}). For the subject-specific random effects $\xi_1,\ldots,\xi_n$, we assume i.i.d.\ $N(0,\tau_{\epsilon}^{2})$ priors. Similarly, appropriate models for the probe-specific parameters $\chi_1,\ldots,\chi_p$ include i.i.d.~zero-mean normal distributions, and finite mixture models or HMMs with a finite number of latent states and state-specific normal distributions. An inverse-gamma prior is assigned to parameters $\sigma^2$ in (\ref{def_main_model}). Appropriate priors are assumed for mass parameters $\beta$, $\alpha_1$, and $\alpha_2$ in expressions (\ref{W1}) and (\ref{pred.table_j}). Mean $\mu_G$ and variance $\tau_G^{2}$ of base distribution $G_0$ in expression (\ref{W1}) are given a joint normal-inverse gamma~prior. Baseline non-differential proportion $\rho_1$ is given a uniform prior. \section{Posterior Inference} \label{S:post_inf} Due to the analytical intractability of the BayesDiff model, we rely on MCMC methods for posterior inferences and detection of differential probes. \subsection{MCMC Strategy} \label{MCMC_summary} The model parameters are initialized using na\"{i}ve estimation techniques and iteratively updated by MCMC techniques until the chain converges. We split the MCMC updates into three blocks. An outline of the MCMC procedure is as follows. Further details can be found in Section \ref{MCMC_summary_supp} of Supplementary Material. \begin{enumerate} \item \textbf{Restaurant-cuisine-table-dish choice $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ of customer $j$:} \quad For each probe $j=1,\ldots,p,$ we sample the 4-tuple $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ given the 4-tuples of the other $(p-1)$ probes. This is achieved by proposing a new value of $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ from a carefully constructed approximation to its full conditional, and by accepting or rejecting the proposed parameters in a Metropolis-Hastings step. The procedure is repeated for all $p$ probes. As discussed in Section \ref{S:latent clusters}, the probe-cluster allocations $c_1,\ldots,c_p$ are immediately available from the restaurant-cuisine-table allocations $(g_j,s_j,v_j)$ of the $p$ probes. Also available are the $q$ latent clusters along with their allocated probes, and the set of differential clusters $\mathcal{D}$. \item \textbf{Latent vectors} $\boldsymbol{\lambda}_1,\dots, \boldsymbol{\lambda}_q$: \quad There are $T q$ latent vector elements, not all of which are necessarily distinct because of the Dirichlet process prior on distribution~$G$. Although the latent vector elements are known from the Block 1 updates, MCMC mixing is considerably improved by updating the latent vector elements conditional on the $p$ probe-cluster allocations. As the calculation in Supplementary Material shows, this is possible by Gibbs~sampling. \item \textbf{Remaining model parameters}: Generated by standard MCMC techniques. \end{enumerate} \paragraph{Scalability} Due to the intensive nature of the one-parameter-at-a-time Gibbs sampling updates in Block 2, the Metropolis-Hastings algorithm of \cite{guha2010posterior} can be applied to significantly speed up the updates. Relatively to standard Gibbs samplers, ten- to hundred-fold speedups are possible by this fast MCMC strategy. A similar strategy can be applied to obtain order of magnitude speedups for the Block 1 parameters. \subsection{Detection of Differential Probes with FDR Control} \label{FDR_control} Post-processing the MCMC sample, a Bayesian approach for controlling the false discovery rate (FDR) \citep{newton2004detecting} is applied for more accurately detecting the differential probes, i.e.,~the probes $j$ with differential state, $s_j=2$. Specifically, let $q_0$ be the nominal FDR level and let $\omega_j$ be the posterior probability of probe $j$ being differential, so that $\omega_j=P[s_j=2\mid\boldsymbol{X}]$. An empirical average estimate, $\hat{\omega}_j$, is available from the MCMC sample. To achieve the desired FDR level in calling the differential probes, we first rank all the probes in decreasing order of $\hat{\omega}_j$. Let $\hat{\omega}_{(1)}>\hat{\omega}_{(2)}>\dots>\hat{\omega}_{(p)}$ denote the ordered posterior probability estimates. For each $b=1,\dots ,p$, we calculate as follows the posterior expected FDR resulting from calling the first $b$ probes in decreasing order of $\hat{\omega}_j$: \begin{align} \widehat{\text{FDR}}_b=\frac{\sum_{j=1}^{p}\left(1-\hat{\omega}_j\right)\mathcal{I}\left(\hat{\omega}_j\geq \hat{\omega}_{(b)}\right)}{\sum_{j=1}^{p}\mathcal{I}\left(\hat{\omega}_j\geq \hat{\omega}_{(b)}\right)}=\frac{\sum_{j=1}^{b}\left(1-\hat{\omega}_{(j)}\right)}{b}, \end{align} where the simplified expression follows from the fact that the $\hat{\omega}_j$'s are sorted. Finally, we pick the largest value of $b$, denoted by $b^{*}$, for which $\widehat{\text{FDR}}_b<q_0$. A nominal FDR~level of $q_0$ is achieved by labeling as differential the first $b^{*}$ probes arranged in decreasing order of $\hat{\omega}_j$. \section{Simulation Studies} \label{sim_study} Using artificial datasets with $T=5$ treatments, we analyzed the accuracy of BayesDiff in detecting the differentially methylated probes. We also compared the results with established differential methylation procedures and general statistical techniques for multigroup comparisons. Further, we evaluated the ability of the BayesDiff procedure in discovering the complex dependence structure of DNA methylation data. \paragraph{Generation strategy} Proportions representing DNA methylation data were generated using the logit transformation in equation (\ref{def_main_model}). The distances between the $p$ probes were actual sequences of $(p-1)$ inter-probe distances from the motivating TCGA dataset, scaled to add to $1$. In order to capture the complexity of methylation data, such as the existence of multiple latent methylation states (e.g,.~CpG islands and shores), different read depths across CpGs, and the incomplete conversion of bisulphite sequencing, the generation strategy was partly based on techniques implemented in WGBSSuite, a flexible stochastic simulation tool for generating single-base resolution methylation data \citep{Rackham_etal_2015}. However, the generation procedure differed from WGBSSuite in some respects. Specifically, it accommodated more than two treatments ($T>2$). Additionally, as expected in actual methylation datasets, the generation procedure incorporated serial dependence not only in the methylation states, but also in the differential states of the probes. The probes-specific read depths were generated as $n_j \stackrel{iid}\sim \text{Poisson}(50)$. Unlike BayesDiff assumption (\ref{def_main_model}), there were no subject-specific random effects in the generation mechanism. Instead, the normal mean of the generated data included additive probe-specific random effects, $\chi_1^{(0)},\ldots,\chi_p^{(0)}$, that were generated as follows: \begin{enumerate} \item Generate the true methylation status of the probes, denoted by $h_1^{(0)},\ldots,h_p^{(0)}$, using the 4-state \textit{distance-based} HMM of \cite{Rackham_etal_2015}, with the states respectively representing the methylated, first transit, demethylated, and second transit states. \item Set the baseline methylation levels for the methylated, (first or second) transit, and demethylated states as $p_{\text{methylated}}=0.8$, $p_{\text{transit}}=0.5$, and $p_{\text{un-methylated}}=0.2$, respectively. \item For $j=1,\ldots,p$, define the mean probe-specific random effect as follows: \begin{align*} \tilde{\chi}_j^{(0)} = \begin{cases} \log(\frac{p_{\text{methylated}}}{(1-p_{\text{methylated}}}) &\text{if $h_j=1$ (i.e.,~methylated state),}\\ \log(\frac{p_{\text{transit}}}{(1-p_{\text{transit}}}) &\text{if $h_j=2,4$ (first or second transit state),}\\ \log(\frac{p_{\text{demethylated}}}{(1-p_{\text{demethylated}}}) &\text{if $h_j=3$ (i.e.,~demethylated state).}\\ \end{cases} \end{align*} \item Independently generate true probe-specific random effects: $\chi_j^{(0)} \sim N\bigl(\tilde{\chi}_j^{(0)}, \tau_{\chi}^2\bigr)$ for probe $j=1,\ldots,p$. \end{enumerate} \paragraph{Noise and dependence levels} We investigated four scenarios corresponding to the combinations of two noise levels and two dependence levels. For each scenario, 20 datasets were independently generated, with each dataset consisting of $p=500$ probes and $T=5$ treatments with 4 samples each, i.e.,~a total to $n=20$ samples. The low noise level corresponded to true variance parameter $\sigma^{2}_0=0.36$; equivalently, to a signal-to-noise of $R_0^2\approx 70\%$. The high noise level corresponded to $\sigma^{2}_0=1$ or $R_0^2\approx 40\%$. The true between-probe dependencies comprised two levels: no serial correlation (i.e.,~a zero-order Sticky PDP) with $\eta_0=0$, and positive serial correlation (i.e.,~a first order Sticky PDP) with $\eta_0=0.004$. Although $\eta_0=0.004$ may appear to be small, its value is calibrated to the inter-probe distances; when the distance between two adjacent probes is equal to the standardized average distance of $\bar{e}=1/(p-1)=1/499$, $\eta_0=0.004$ gives an affiliation of $r_0=0.6$ in equation (\ref{def_dep_par}). Since the affiliations are bounded above by 1, $\eta_0=0.004$ represents fairly high inter-probe dependence. For convenience, we will refer to the two dependence levels as ``no-correlation'' and ``high correlation.'' The other model parameters were common for the four scenarios and are displayed in Table~\ref{parm_sim1}. Setting a true baseline differential proportion of $\rho_2=0.1$ resulted in approximately 10\% true differentially methylated CpGs in each dataset. \begin{table} \centering \begin{tabular}{*{9}{c}} $\alpha_1$ & $\alpha_2$ & $d_2$ & $\beta$ & $\gamma$ & $\rho_2$ & $\mu_G$ & $\tau^{2}_G$ & $\tau^{2}_{\chi}$ \\ \hline 20 & 20 & 0.33 & 20 & 0.9 & 0.1 & 0 & 1 & 0.1225 \end{tabular} \caption{True parameter values used to generate the artificial datasets.} \label{parm_sim1} \end{table} \paragraph{Posterior inferences} Assuming all model parameters to be unknown, each artificial dataset was analyzed using the BayesDiff procedure. The true generation mechanism differed in key respects from the BayesDiff model subsequently used to analyze the data. For example, unlike the 4-state HMM of the generation strategy, the probe-specific random effects $\chi_j$ were analyzed using a BayesDiff model that ignored the first order dependence, and instead, relied on a 3-state finite mixture model representing the methylated, transit, and unmethylated states. Additionally, in contrast to the zeroed-out subject-specific random effects during data generation, the BayesDiff procedure assumed that the random effects were i.i.d.~normal with zero mean. To assess the accuracy of BayesDiff in detecting the absence or presence of inter-probe serial correlation, in the no-correlation ($\eta_0=0$) situation, we evaluated $\log \left(\frac{P\left[\eta=0\mid \mathbf{X}\right]}{P\left[\eta>0\mid \mathbf{X}\right]}\right)$, the log-Bayes factor comparing zero order to first order Sticky PDPs. In the high correlation ($\eta_0=004$) situation, we evaluated $\log \left(\frac{P\left[\eta>0\mid \mathbf{X}\right]}{P\left[\eta=0\mid \mathbf{X}\right]}\right)$, the log-Bayes factor comparing first order to zero order Sticky PDPs. Thus, in any scenario, a large positive value of this log-Bayes factor constitutes strong evidence that BayesDiff detects the correct model order. Although conceptually straightforward, the estimation of Bayes factors requires multiple MCMC runs, even for relatively simple parametric models \citep{Chib_1995}. \cite{Basu_Chib_2003} extended the estimation strategy to infinite dimensional models such as Dirichlet processes. However, the computational costs are prohibitively high for big datasets, and multiple MCMC runs for estimating Bayes factors would stretch available computational resources far beyond their present-day limits. Faced with these challenges, we relied on an alternative strategy for estimating the \textit{lower bounds} of log-Bayes factors using a single MCMC run. As it turns out, this is often sufficient to infer the Sticky PDP model orders. Let $\Theta^{-}$ denote all BayesDiff model parameters except $\eta$. In the high correlation situation, applying Jensen's inequality, a lower bound for the corresponding log-Bayes factor is $E\left[\log \left(\frac{P\left[\eta>0\mid \mathbf{X},\Theta^{-}\right]}{P\left[\eta=0\mid \mathbf{X},\Theta^{-}\right]}\right)\mid\mathbf{X}\right]$. Unlike log-Bayes factors, this lower bound can be easily estimated by an empirical average estimate based on a single MCMC run. In the no-correlation situation, a lower bound for the log-Bayes factor, $\log \left(\frac{P\left[\eta=0\mid \mathbf{X}\right]}{P\left[\eta>0\mid \mathbf{X}\right]}\right)$, can be similarly~derived. \begin{figure} \centering \includegraphics[width=0.5\textwidth]{figures/logBF_boxplot} \caption{In the simulation study, box plots for the estimated lower bounds of log-Bayes factors in favor of the true model order.} \label{sim1_log-BF} \end{figure} For each of the four generation scenarios, box plots of these estimated lower bounds for the 20 datasets are depicted in Figure \ref{sim1_log-BF}. Except for the high noise--no-correlation scenario, for which the results were inconclusive, the estimated lower bounds of the log-Bayes factors in favor of the true correlation structure were all positive and large. In the low noise--no-correlation scenario, BayesDiff decisively favored zero-order models, and the smallest lower bound among the 20 datasets was $13.9$, corresponding to Bayes factors exceeding $e^{13.9}=1,088,161$. The $25^{th}$ percentile of these lower bounds was 30.9, corresponding to Bayes factors exceeding $e^{30.9}=2.63 \times 10^{13}$. This is strong evidence that the BayesDiff approach is reliable in this scenario. For the high-correlation scenarios, the estimated lower bounds were even higher, showing that BayesDiff overwhelmingly favors first order models when the data are actually serially~correlated. \paragraph{Comparisons with other methods} We evaluated the success of the BayesDiff procedure in detecting disease genomic signatures and made comparisons with six well-known procedures. These included some general statistical techniques for multigroup comparisons, namely, one-way analysis of variance (ANOVA) and the Kruskal-Wallis test. We also made comparisons with some methods specially developed for detecting differential methylation in more than two treatments: COHCAP \citep{warden2013cohcap}, methylKit \citep{akalin2012methylkit}, BiSeq \citep{hebestreit2013detection}, and RADMeth \citep{dolzhenko2014using}. The ANOVA and the Kruskal-Wallis test procedures were applied separately on each probe after applying the inverse-logit transform. Being specifically designed for differential methylation analysis, the COHCAP method was directly applied to the generated proportions of the synthetic data. The remaining three methylation-related methods are designed for bisulfite sequencing, which consists of the total methylation reads for each measured CpG site. For these methods, the methylation reads for each probe was obtained by multiplying the proportion methylation values by the total read. The bandwidth smoothing parameter of the method BiSeq was tuned to optimize the overall detection. For all six methods, the probe-specific p-values were obtained. As recommended by these techniques, the probes whose test p-values were less than the desired significance level were labeled as differential. \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma06_eta0004_20200329.pdf} \caption{Low noise, high correlation} \end{subfigure}% \quad \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma06_eta0_20200329.pdf} \caption{Low noise, no correlation} \end{subfigure} \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma1_eta0004_20200329.pdf} \caption{High noise, high correlation} \end{subfigure}% \quad \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma1_eta0_20200329.pdf} \caption{High noise, no correlation} \end{subfigure} \caption{ROC curves, averaged over 20 simulated datasets, for the seven methods and the four simulation scenarios. The numbers in parentheses represent the corresponding AUCs for each method.} \label{sim1_ROC_avg} \end{figure} We computed the receiver operating characteristic (ROC) curves for differential probe detection for all seven methods. For a quantitative assessment, we calculated the area under curve (AUC), declaring the method with the largest AUC as the most reliable in each scenario. The ROC curves, averaged over the 20 datasets under each simulation scenario, are shown with the AUCs in Figure \ref{sim1_ROC_avg}. In all except the high-noise--no-correlation scenario, BayesDiff uniformly outperformed the other methods, as indicated by the fact that the areas under the ROC curves were greater for BayesDiff. Even in the high-noise--no-correlation scenario, we find that BayesDiff performed better in the low FPR region. As expected, all seven methods had lower accuracies for the higher noise levels. The performance of BayesDiff was significantly better than the competing methods in the high correlation scenarios, suggesting that the incorporation of between-probe dependencies greatly improves its accuracy in situations typical of DNA methylation data. In addition, since researchers typically focus on small false positive rates (FPRs), that is, small significance levels, we also calculated the measures, $\textrm{AUC}_{20}$ and $\textrm{AUC}_{10}$. $\textrm{AUC}_{20}$ ($\textrm{AUC}_{10}$) is defined as the area under the ROC curve multiplied by $5$ ($10$) when the FPR does not exceed $0.2$ ($0.1$). The multiplicative factor ensures that the areas potentially vary between $0$ and $1$. The three versions of AUC are presented in Table~\ref{table_sim1} in Supplementary Material. As also seen in Figure \ref{sim1_ROC_avg}, Table~\ref{table_sim1} reveals that in three of the four scenarios, BayesDiff had the largest overall AUC. Furthermore, BayesDiff had vastly improved reliability for low FPRs. For example, consider the low noise--high correlation scenario. The overall AUC for BayesDiff was 0.031 greater than that for ANOVA. In contrast, the gains for BayesDiff, relative to ANOVA, were $+0.098$ for $\textrm{AUC}_{20}$ and $+0.136$ for $\textrm{AUC}_{10}$. The advantages of BayesDiff were even greater relative to the other competing methods. In the high noise--low-correlation scenario, BayesDiff had a relatively low AUC, as mentioned earlier. However, even in this scenario, it had the greatest $\textrm{AUC}_{20}$ and $\textrm{AUC}_{10}$ values among all the methods. Additionally, for a nominal FDR level of $q_0=0.05$, the achieved FDR of BayesDiff was between 0 and 0.03 in every dataset and simulation scenario. These results demonstrate the ability of BayesDiff to accurately detect the differential probes even in challenging situations where the FPR is~small. \section{Data Analysis} \label{data_analysis} We returned to the motivating DNA methylation dataset consisting of the upper GI cancers: stomach adenocarcinoma (STAD), liver hepatocellular carcinoma (LIHC), esophageal carcinoma (ESCA) and pancreatic adenocarcinoma (PAAD). Applying the BayesDiff procedure, we detected the differentially methylated CpG loci among the cancer types. \paragraph*{Data processing} The dataset was obtained from The Cancer Genome Atlas project, which is publicly available through The Genomic Data Commons (GDC) Data Portal \citep{grossman2016toward}. The data are available from the Illumina Human Methylation 450 platform for each of 485,577 probes at the CpG sites. At the time of analysis, the dataset consisted of $1,224$ tumor~samples. The analysis was performed on a gene-by-gene basis. We picked a set of 443 genes involving mutation in at least 5\% of the samples. To ensure that all CpG sites potentially related to a gene were included in the analysis, we selected all sites located within 50K base pairs outside the gene body, specifically, upstream from the 5' end and downstream from the 3' end. The number of gene-specific CpG sites ranged from 1 to 769, and are displayed in Figure \ref{appl_plots}(a) of Supplementary Material. As a final preprocessing step, since the methylation patterns of short genes are of lesser interest in cancer~investigations, we eliminated the 25 genes mapped to 20 or fewer CpG sites. \paragraph*{Inference procedure} The data were analyzed using the proposed BayesDiff approach. Exploratory analyses indicated that a satisfactory fit was obtained by eliminating the probes-specific random effects $\chi_j$ in (\ref{def_main_model}). The MCMC procedure of Section~\ref{MCMC_summary} was applied to obtain posterior samples for each gene. For detecting differentially methylated CpG sites, we applied the Bayesian FDR control procedure of Section \ref{FDR_control} with a nominal FDR of $q_0=0.05$. \paragraph*{Results} \begin{figure} \centering \begin{subfigure}{0.4\textwidth} \centering \includegraphics[width=1.1\textwidth]{figures/realdata_bar_in-out} \caption{Contingency table of detected methylation status and location of CpG site with respect to gene body} \end{subfigure}% \quad \begin{subfigure}{0.4\textwidth} \centering \includegraphics[width=1.1\textwidth]{figures/realdata_bar_5-3} \caption{Contingency table of detected methylation status and proximity of CpG site to chromosomal end} \end{subfigure} \caption{Associations of detected methylation status and position of CpG sites. } \label{appl_probeSummaries} \end{figure} Among the differentially methylated CpG sites detected by our approach, approximately 40.6\% of the sites were located outside the gene bodies. Figure \ref{appl_probeSummaries} displays the associations between detected methylation status and positions of the CpG sites. For our analysis, we have defined ``near the 5' (3') end'' as the CpG sites located within one-fourth length of the gene body, either inside or outside the gene boundary, and closer to the transcription start (termination) site. Our results indicate that the proportion of differential methylation is higher for CpG sites inside the gene body, and that most differentially methylated loci are situated within the gene body, as is well known from numerous previous studies. However, our analysis also revealed significant amounts of differential methylation outside the gene body. Despite the common belief that DNA methylation analysis should focus on the 5' end region, we found that CpG sites near the 3' ends also display considerable degrees of differential methylation. These findings support the recommendations of \cite{irizarry2009genome} that investigations of DNA methylation alteration should be conducted on a higher resolution, epigenome-wide basis. \begin{figure} \centering \includegraphics[width=0.4\textwidth]{figures/realdata_pie_maxdiff_probes} \caption{Site-wise summary of the largest pairwise differences of differentially methylated loci among the four upper GI cancer types.} \label{appl_maxdifSummaries} \end{figure} Among the differentially methylated sites detected by BayesDiff, we estimated the pairwise differences between the random effects associated with the four cancer types. Site-wise summaries of the largest pairwise differences of the cancer-specific effects are plotted in Figure \ref{appl_maxdifSummaries}. None of the four cancer types displayed consistent hypermethylation or hypomethylation across all the genes or entire chromosomes. However, we found that LIHC is frequently differentially methylated relative to one of the other cancer types, implying that it is the most volatile disease with respect to DNA~methylation. For each gene, Figure \ref{appl_plots}(b) of Supplementary Material displays 95\% credible intervals for lower bounds of log-Bayes factors of a first versus zero-order model, i.e., $\eta=0$ versus $\eta > 0$ in expression (\ref{def_dep_par}) for the inter-probe affiliations. Models with first order dependence are overwhelmingly favored for a majority of the genes, suggesting that statistical techniques that do not account for dependence between neighboring CpG sites would be less effective for these data. Figure \ref{DA_detail_2genes} of Supplementary Material displays the detailed differential methylation pattern for the top two mutated genes, TP53 and TTN. An obvious feature of both the genes is that the detected differential methylation of the CpG sites is highly serially correlated. For gene TP53, there are almost no differentially methylated loci within the gene body. The 3' end region outside the gene body has a cluster of differentially methylated loci, for which cancer type STAD is mostly hypermethylated. The results for gene TTN tell a quite different story: most of the differentially methylated loci are inside the gene body and near the 5' end. Cancer type LIHC is hypomethylated compared to PAAD around the 5' end region, but it is hypermethylated compared to STAD near the 3' end. Finally, genes with at least 90\% differentially methylated sites are listed in Table \ref{table_list_gene_prop} of Supplementary Material, along with the largest pairwise difference between the four cancer types among the differentially methylated loci. The number of CpG sites within each segment is listed in Table~\ref{table_list_num_probe} of Supplementary Material. Existing medical literature both supports and complements our findings. For example, hypermethylation of the EDNRB and SLIT2 genes have been found in STAD \citep{tao2012quantitative}. Gene FBN2 was hypermethylated in ESCA \citep{tsunoda2009methylation}. While several studies have found that the gene and protein expressions of ABC transporter genes, such as ABCC9, are useful for understanding the prognosis of esophageal cancer \citep{vrana2018abc}, we conclude that hypermethylation of ABCC9 is a major difference between cancer types ESCA and LIHC. Gene FLRT2 is a potential tumor suppressor that is hypermethylated and downregulated in breast cancer \citep{bae2017epigenetically}. Our results indicate that this gene is also hypermethylated in cancer type STAD versus LIHC. Mutations in SPTA1 gene has been linked with PAAD \citep{murphy2013genetic}. Our results indicate that hypermethylation of this gene distinguishes PAAD from LIHC. \paragraph*{Accounting for data characteristics} In genomic studies, a statistical model should be able to account for the probe-specific means and variances. This is especially important in multiple-testing based approaches where the first two sample moments must be plausibly explained by the fitted model to avoid making misleading biological interpretations \citep{Subramaniam_Hsiao_2012}. From this perspective, certain aspects of the BayesDiff model, such as variance~$\sigma^2$ a priori unrelated to the mean in expression~(\ref{def_main_model}), may appear to be restrictive. However, even though the BayesDiff model was not specifically constructed to match data summaries such as sample moments, in practice, the nonparametric nature of the Sticky PDP allows the posterior to flexibly adapt to the features of the data, including sample moments, thereby accounting for mean-variance relationships in a robust manner. For example, consider again the top mutated genes, TP53 and TTN, discussed in Figure \ref{DA_detail_2genes} of Supplementary Material. The ability of the BayesDiff model to match the sample moments of the gene-specific probes is demonstrated as follows. Given the inter-probe distances, the joint posterior of the BayesDiff parameters induces predictive distributions on the $n$ measurements for each probe. Functionals of these predictive distributions, such as the probe-specific sample moments, are easily estimated by post-processing the MCMC sample. For these two genes, Figure \ref{mean-mean_var-var} of Supplementary Material shows that the sample moments predicted by BayesDiff closely match the actual first and second sample moments, with correlations exceeding 99\% in each plot. Similar results were observed in other datasets. \section{Discussion} \label{disc} DNA methylation data exhibit complex structures due to unknown biological mechanisms and distance-dependent serial correlations among neighboring CpG sites or probes. The identification of differential signatures among different groups of samples is crucial for developing targeted treatments for disease. This paper formulates a flexible approach applicable to multiple treatments called BayesDiff. The technique relies on a novel Bayesian mixture model called the Sticky PDP or the two-restaurant two-cuisine franchise. In addition to allowing simultaneous inferences on the probes, the model accommodates distance-based serial dependence and accounts for the complex interaction patterns commonly observed in cancer data. A computationally efficient MCMC strategy for detecting the differential probes is developed. The success of the BayesDiff procedure in differential DNA methylation, relative to well-established methodologies, is exhibited via simulation studies. The new technique is applied to the motivating TCGA dataset to detect the differential genomic signatures of four upper GI~cancers. The results both support and complement various known facts about the epigenomic differences between these cancer types, while revealing a set of genes exhibiting high proportions of differentially methylated CpG sites. These results emphasize the need for further investigation to better understand the molecular characterizations of different upper GI cancers. The general methodology is applicable to differential analysis in genomic, epigenomic, transcriptomic, and proteomic datasets. In addition to providing a good fit for the data, a statistical model must be able to account for features of the dataset such as sample moments. The success of the BayesDiff model in this regard is demonstrated in Section \ref{data_analysis} for the upper GI dataset. It must be emphasized, however, that there may be other datasets where BayesDiff is less successful in accounting for the data characteristics. This could be due to many reasons, e.g.~as the number of probes grows, there is slow asymptotic convergence of the posterior to the true generative process, and so, $p$ is insufficiently large to provide a good match for the data. In such situations, more flexible global transformations \citep{Li_etal_2016} or variance-stabilizing transformations \citep{Durbin_etal_2002} could be used. Alternatively, we could replace the global transformations of the measurements, $z_{ij}=z(x_{ij})$, by local Laplace approximations of exponential family likelihoods through link functions, e.g.~binomial likelihoods with logit link for proportions \citep{Zeger_Karim_1991, Chib_Winkelmann_2001}. In this manner, we could extend the BayesDiff procedure to further improve the model fit and better explain the unique data characteristics. Going beyond biomedical applications, the generalized form of the Sticky PDP is presented in Section \ref{general2R2CF} of Supplementary Material. In addition to extending PDPs to discrete time series type data, the generalized formulation offers a diverse palette of parametric and nonparametric models for capturing the distinctive features of data in various applications. The range of models includes Dirichlet processes, PDPs, infinite HMMs, hierarchical Dirichlet process (HDP) \citep{Muller_etal_2004,Teh_etal_2006}, finite HMMs, nested Chinese restaurant processes \citep{Blei_Jordan_2005}, nested Dirichlet processes \citep{Rodriguez_etal_2008}, and analysis of densities models \citep{Tomlinson_Escobar_2003}. Ongoing work involves extending the correlation structure to model more sophisticated forms of inter-probe dependence in DNA methylation data. We are currently developing an R package implementing BayesDiff in a parallel computing framework using graphical processing units. The software will be made available for detecting differential genomic signatures in a wide variety of omics datasets. Initial results indicate that dramatic speedups of several orders of magnitude would allow the analysis of user-specified datasets on ordinary personal computers. \newpage \newpage \begin{supplement} \section{MCMC Strategy} \label{MCMC_summary_supp} As mentioned in Section \ref{MCMC_summary} of the paper, we split the MCMC updates into three blocks. The MCMC procedure for updating Blocks 1 and 2 is described below. Unless otherwise stated, all references to equations, tables, and figures are for the main paper. \begin{enumerate} \item \textbf{Restaurant-cuisine-table-dish choice $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ of customer $j$:} \quad For each probe $j=1,\ldots,p,$ we sample the 4-tuple $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ given the 4-tuples of the other $(p-1)$ probes. This is achieved by proposing a new value of $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ from a carefully constructed approximation to its full conditional, and by accepting or rejecting the proposed 4-tuple of probe-specific parameters in a Metropolis-Hastings step. The procedure is repeated for all $p$ probes to complete the block of MCMC updates. We give here an intuitive description of the details. Further calculation details are available in Section \ref{MCMC_sec} of Supplementary Material. For the $j$th probe, $1<j<p$, the choice of restaurant $g_j$ depends on the triplets of the two immediately adjacent probes. Specifically, as discussed in Section~\ref{Sticky_PDPs_DA} and graphically shown in the upper and middle panel of Figure \ref{2R2CF plots}, the restaurant selected by a customer depends on the cuisine of the previous customer. Then, within restaurant $g_j$, the customer chooses cuisine $s_j$ with a restaurant-specific probability. Finally, the customer may either sit an existing table, in which case they must eat the same dish as everyone already sitting at that table, or the customer may open a new table and order a dish from cuisine menu $s_j$. The generation strategy for table and dish depends on the cuisine, as discussed below. \vspace{-5 mm} \paragraph{Cuisine $s_j=1$} Evaluating the posterior probability of table $v_j$ involves integrating the Gaussian likelihood of column vector $\mathbf{z}_j=(z_{1j},\ldots,z_{nj})'$ with respect to the cuisine~1 menu, i.e.,~$\boldsymbol{\theta}_j \sim W_{1}$. Recall that the cuisine 1 menu has the special structure (\ref{W1}), allowing its reduction to a univariate quantity distributed as $G$. This random distribution itself follows a Dirichlet process conditional prior with a base distribution that is a mixture of known atoms (given the 4-tuples of the other probes) and Gaussian distribution $G_0$. This conjugate hierarchical structure allows the calculation of table and dish choice for cuisine 1 in computationally closed~form. \vspace{-5 mm} \paragraph{Cuisine $s_j=2$} This situation is more complicated because the Gaussian likelihood must be integrated with respect to prior distribution $W_{2}$ of the cuisine~2 dishes. Unlike cuisine 1, this is not possible in computationally closed form because menu structure (\ref{density W2}) cannot be reduced to a univariate quantity. In other words, for cuisine 2 (i.e.,~the differential state), the Dirichlet process conditional prior for distribution $G$ is non-conjugate. We utilize an auxiliary variable approach. Given the current set and frequency of atoms of distribution $G$ in the other $(p-1)$ probes, we first compute a finite mixture approximation, $G^{*}$, to the Dirichlet process conditional prior for $G$, as in \cite{Ishwaran_Zarepour_2002}. Then, using prior (\ref{density W2}), it is possible to approximate the posterior probability of customer $j$ joining an existing table or sitting at a new table, irrespective of the dishes. This allows us to generate the table selection, $v_j$. Finally, we propose the dish, $\boldsymbol{\theta}_j=\boldsymbol{\phi}_{g_j s_j v_j}$. If table $v_j$ is one of the already existing tables, then the customer simply chooses the common, table-specific dish. Otherwise, we sequentially generate from the posterior the $T$ elements representing the new dish. This is done using the corresponding treatment-specific elements of vector $\mathbf{z}_j=(z_{1j},\ldots,z_{nj})'$ and finite mixture $G^{*}$, with the restriction that not all $T$ atoms of vector $\boldsymbol{\theta}_j$ are equal. The Metropolis-Hasting step compensates for any approximations and produces post--burn-in samples from the BayesDiff model posterior. \vspace{-5 mm} \paragraph{Latent clusters} As discussed in Section \ref{S:latent clusters}, the probe-cluster allocations $c_1,\ldots,c_p$ are immediately available from the restaurant-cuisine-table allocations $(g_j,s_j,v_j)$ of the $p$ probes. The $q$ latent clusters, along with their allocated probes, and the set of differential clusters $\mathcal{D}$, are also immediately available. \item \textbf{Latent vectors} $\boldsymbol{\lambda}_1,\dots, \boldsymbol{\lambda}_q$: \quad Since each latent vector is of length $T$, there are $T q$ latent vector elements, not all of which are necessarily distinct because of the Dirichlet process prior on distribution $G$. Although the latent vector elements are available from Block 1, mixing of the MCMC chain is considerably improved by an additional block of updates of the latent vector elements conditional on the $p$ probe-cluster allocations. As the following calculation shows, this can be done by Gibbs~sampling. Since a non-differential cluster's latent vector consists of a single value repeated $T$ times, the number of \textit{distinct} latent vector elements is no more than $\left(q_1+T q_2\right)$. Given the current probe-cluster allocations, suppose there are $m_k$ probes associated with latent cluster $k$, where $k=1,\dots, q$. Let $q_2=|\mathcal{D}|$ be the number of differential clusters, so that $q_1=q-q_2$ is the number of non-differential clusters. \vspace{-5 mm} \paragraph{Non-differential clusters} For these clusters, the latent vector $\boldsymbol{\lambda}_k$ takes the form, $\boldsymbol{\lambda}_k = \psi_k \boldsymbol{1}_T$ for some $\psi_k \in \mathcal{R}$. Given the other $(q-1)$ latent vectors, assumptions (\ref{W1}) and (\ref{density W2}) imply that parameter $\psi_k$ has a Dirichlet process conditional prior. The base distribution of the Dirichlet process is a mixture of a continuous distribution, $G_0=N(\mu_G, \tau_G^2)$, and the univariate atoms located at the ``known'' elements of the other $(q-1)$ latent vectors. The sufficient statistic for $\psi_k$ is \begin{align*} \bar{y}_{ k} &= \frac{1}{n m_k}\sum_{j=1}^{p}\sum_{i=1}^{n}\left({z_{ij}}-{\xi_i}-\chi_j\right)\mathcal{I}\left(c_j=k\right) \\&\sim N\left(\psi_k,\frac{\sigma^2}{n m_k}\right) \quad\text{for cluster } k \not\in \mathcal{D}. \end{align*} Since the Dirichlet process conditional prior is conjugate to this normal likelihood, parameter $\psi_k$ could be updated by Gibbs sampling \citep{escobar1994estimating,maceachern1994estimating,escobar1995bayesian}. \vspace{-5 mm} \paragraph{Differential clusters} For these clusters, some of the $T$ elements of latent vector $\boldsymbol{\lambda}_k = (\lambda_{1k},\ldots,\lambda_{Tk})'$ could be tied, but at least two elements must be unequal. Denote these restrictions on $\boldsymbol{\lambda}_k$ by $\mathcal{A}$. For a treatment~$t$, let the remaining $(T-1)$ elements of vector $\boldsymbol{\lambda}_k$ be denoted by $\boldsymbol{\lambda}_{-tk}$. Imagine updating element $\lambda_{tk}$ assuming that $\boldsymbol{\lambda}_{-tk}$ and the remaining $(q-1)$ latent vectors are known. Vector $\boldsymbol{\lambda}_{-tk}$ and restriction $\mathcal{A}$ imply a possibly restricted support, $\mathcal{A}_t$, for parameter $\lambda_{tk}$. Observe that the support is unrestricted, i.e.,~$\mathcal{A}_t=\mathcal{R}$, if at least two elements of $\boldsymbol{\lambda}_{-tk}$ differ. Similarly to non-differential clusters, it can be shown that element $\lambda_{tk}$ follows a Dirichlet process conditional prior restricted to the support $\mathcal{A}_t$, and that the base distribution is a mixture of a normal distribution and univariate atoms. The sufficient statistic for latent vector element $\lambda_{tk}$ is \begin{align*} \bar{y}_{t k}&=\frac{1}{n_t m_k} \sum_{j=1}^{p}\sum_{i:t_i=t}\left({z_{ij}}-{\xi_i}-\chi_j\right)\mathcal{I}\left(c_j=k\right) \\ &\sim N\left(\lambda_{t k},\frac{\sigma^2}{n_t m_k}\right) \quad\text{for treatment $t=1,\ldots,T$, and cluster $k \in \mathcal{D}$}, \end{align*} where $n_{t}$ is the number of individuals associated with treatment $t$. The conjugate structure implies that parameter $\lambda_{tk}$ could be generated from its full conditional by a rejection sampler on set $\mathcal{A}_t$ coupled with standard Gibbs proposals for conjugate Dirichlet processes. In practice, the acceptance rates of the rejection sampler are very high for $T$ as small as 3 or 4, and are nearly 100\% for larger $T$. This is because the posterior probability of support set $\mathcal{A}_t$ tends to 1 as $T$ grows. An intuitive explanation for this asymptotic property is provided in Section \ref{S:hyperpriors} following the prior specification of discount parameter~$d_2$. \end{enumerate} \section{Additional details about Block 1 MCMC updates} \label{MCMC_sec} In the first block of MCMC updates of Section \ref{MCMC_summary}, we sample the the set \[\mathcal{C} = \left\{(g_j,s_j,v_j,\boldsymbol{\theta}_j) : j = 1,\ldots, p\right\}. \] We iteratively sample the 4-tuple, $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$, for each probe $j$ via Metropolis-Hastings updates. Specifically, for the $j$th probe, we propose group (i.e.,~restaurant) $g_j$, state (i.e.,~cuisine) $s_j$, PDP cluster (i.e.,~table) label $v_j$, and random effect (i.e.,~dish) $\boldsymbol{\theta}_j$, with the proposal distribution approximately equal to the joint posterior of $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ conditional on the data and all other parameters being equal to the current values. As explained in the paper, since the base measure of the Sticky PDP is discrete and not conjugate to the likelihood, this makes the case of parameter $v_j$ being assigned a new cluster label complicated. To deal with this situation, an auxiliary variable approach is used. Conditional on the current parameter values of the Dirichlet process prior for the latent vector elements, we generate a finite-dimensional approximation, $G^{*}$, to the Dirichlet process \citep{Ishwaran_Zarepour_2002}. Since the distribution $G^{*}$ is discrete, it is characterized by a finite vector of probability masses, $\boldsymbol{\pi}$, and the corresponding values of probability mass points, $\mathbf{u}$. Then, conditional on the auxiliary variables from $G^{*}$, we obtain the quantities needed for the conditional posterior of $v_j$ being assigned a new cluster label in the Metropolis-Hastings algorithm. More formally, consider probe $j \in \{1,\dots ,p\}$. The proposal probabilities for $\left(g_j,s_j,v_j\right)$ are as follows: \begin{align} &\bullet \quad \text{For an existing PDP cluster indexed by } v\in \{1,\ldots,q_{gs}^{(-j)}\},\nonumber \\ &Q\left(g_j=g,s_j=s,v_j=v\right)=P\left(g_j=g,s_j=s,v_j=v\mid \mathbf{z}_j,\mathbf{c}^{(-j)},\boldsymbol{\phi}_{gsv},s_{j-1},\eta,\rho,\gamma,\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right) \nonumber \\ &\propto \left[\mathbf{z}_j\mid v,s,g,\boldsymbol{\phi}_{gsv},\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right]P\left(v_j=v\mid \mathbf{c}^{(-j)},s,g\right)P\left(s_j=s\mid g,\gamma,\rho\right)P\left(g_j=g\mid s_{j-1},\eta,\gamma,\rho\right) \nonumber \\ &\propto \prod_{i=1}^{n}\varphi\left({z_{ij}}\mid \phi_{t_igsv}+\xi_i+\chi_j,\sigma^{2}\right)\left(m^{(-j)}_{gsv}-d_{s}\right) \mathcal{Q}_g(s) \mathcal{F}_{j}(g). \label{proposal_existing} \end{align} \begin{align} &\bullet \quad\text{For a new PDP cluster indexed by } v^{*}= q_{gs}^{(-j)}+1, \nonumber \\ &Q\left(g_j=g,s_j=s,v_j=v^{*}\right)=P\left(g_j=g,s_j=s,v_j=v^{*}\mid \mathbf{z}_j,\mathbf{c}^{(-j)},\boldsymbol{\pi},\mathbf{u},s_{j-1},\eta,\rho,\gamma,\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right) \nonumber \\ &\propto \left[\mathbf{z}_j\mid v^{*},s,g,\boldsymbol{\pi},\mathbf{u},\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right]P\left(v_j=v^{*}\mid \mathbf{c}^{(-j)},s,g\right)P\left(s_j=s\mid g,\gamma,\rho\right)P\left(g_j=g\mid s_{j-1},\eta,\gamma,\rho\right) \nonumber \\ &\propto \begin{cases} \!\begin{aligned & \sum_{l=1}^{L}\pi_l\left\{\prod_{i=1}^{n}\varphi\left(z_{ij}\mid u_l+\xi_i+\chi_j,\sigma^{2}\right)\right\}\left(\alpha_1+d_{1}q^{(-j)}_{g1}\right) \mathcal{Q}_g(1) \mathcal{F}_{j}(g), \quad \text{if $s=1$,} \\ \end{aligned} \\%[1ex] \!\begin{aligned \left\{\prod_{t=1}^{T}\sum_{l=1}^{L} \pi_l \prod_{i:t_i=t}\varphi\left({z_{ij}}\mid u_l+{\xi_i}+\chi_j,\sigma^{2}\right) -\sum_{l=1}^{L} \pi_{l}^{T} \prod_{i=1}^{n} \varphi\left({z_{ij}}\mid u_{l}+{\xi_i},\sigma^{2}\right)\right\} \\ \times \left(\alpha_2+d_{2}q^{(-j)}_{g2}\right) \mathcal{Q}_g(2) \mathcal{F}_{j}(g), \quad\text{if $s=2$.} \\ \end{aligned} \\%[1ex] \end{cases} \label{proposal_new} \end{align} In expressions (\ref{proposal_existing}) and (\ref{proposal_new}), when $j<p$, superscript $(-j)$ for a variable indicates that the calculation excludes the $j$th and $(j+1)$th cluster allocation variables. Specifically, $q^{(-j)}_{gs}$ denotes the number of PDP clusters for group $g$ and state $s$; $\mathbf{c}^{(-j)}$ denotes the vector of cluster allocations; $m^{(-j)}_{gsv}$ denotes the cluster membership count for cluster $v$ in the PDP with group $g$ and state $s$; $\mathcal{Q}_g(s)$ and $\mathcal{F}_{j}(g)$ are defined in the paper; $\varphi\left(\cdot\mid \mu,\sigma^{2}\right)$ is the pdf of normal distribution with mean $\mu$ and variance $\sigma^{2}$; $L$ is the number of distinct mass points in $G^{*}$; $u_l$ denotes the value of distinct mass points in $G^{*}$ and $\pi_l$ is the corresponding probability mass. Before calculating the proposal, latent vectors of emptied clusters are removed and cluster labels rearranged so that the largest label is~$q^{(-j)}_{gs}$. The case $v^{*}= (q_{gs}^{(-j)}+1)$ corresponds to the case of $v_j$ opening a new cluster. If $v_j=(q_{gs}^{(-j)}+1)$ has been proposed, then a new random effect of length $T$ is sampled from the posterior distribution based on the $n$-dimensional observation vector $\mathbf{z}_j$ and the prior $G^{*}$ characterized by the auxiliary variables, subject to the constraints imposed on the random effects of the differential state $s_j$. The Metropolis-Hastings acceptance ratio is computed to decide whether the proposed $g_j$, $s_j$ and $v_j$ values are accepted. For $j=p$, our proposal density is exactly the desired conditional posterior, so we always accept the move. For $j<p$, since our proposal density is part of the desired conditional posterior for $\left(g_j, s_j, v_j\right)$, this part cancels out in the acceptance ratio. Therefore, the acceptance ratio only relates to the transition from $\left(g_j, s_j, v_j\right)$ to $\left(g_{j+1}, s_{j+1}, v_{j+1}\right)$, which is \begin{align} r_j=\frac{p\left(g_{j+1},s_{j+1},\tilde{v}_{j+1},\mid g_j^{*},s_j^{*},v_j^{*},\boldsymbol{\phi}^{*}_{g_{j+1}s_{j+1}\tilde{v}_{j+1}},\mathbf{z}_{j+1},\mathbf{c}^{-},\eta,\boldsymbol{\xi},\boldsymbol{\chi},\sigma\right)}{p\left(g_{j+1},s_{j+1},v_{j+1} \mid g_j^{0},s_j^{0},v_j^{0},\boldsymbol{\phi}_{g_{j+1}s_{j+1}v_{j+1}},\mathbf{z}_{j+1},\mathbf{c}^{-},\eta,\boldsymbol{\xi},\boldsymbol{\chi},\sigma\right)} \label{MH_ratio} \end{align} where $g_j^{*}$, $s_j^{*}$ and $v_j^{*}$ represent the proposed values; $g_j^{0}$, $s_j^{0}$ and $v_j^{0}$ are the old values; $\tilde{v}_{j+1}$ denotes $v_{j+1}$ under the proposed variable values (due to possible PDP cluster label change or elimination). Specifically, $\tilde{v}_{j+1}=(q^{*}_{g_{j+1}s_{j+1}}+1)$ if it belongs to no existing cluster, where $q^{*}_{g_{j+1}s_{j+1}}$ is the number of clusters under the proposed variable values and $\boldsymbol{\phi}^{*}_{g_{j+1}s_{j+1}\tilde{v}_{j+1}}$ is the random effect under the proposed variable values. Both the nominator and the denominator in (\ref{MH_ratio}) can be calculated using (\ref{proposal_existing}) and (\ref{proposal_new}), and by transposing $j$ to $(j+1)$ \section{Generalized form of the Sticky PDP}\label{general2R2CF} Beyond biomedical applications, a Sticky PDP is defined by the following general properties: \begin{enumerate} \item[Property 1:] Let set $\mathcal{G}$ contain a countable number of generative \textit{groups}. Each group $g \in \mathcal{G}$ contains a countable number of group-specific regular PDPs. The PDPs are identified by a combination of the group label $g$ and an integer-valued \textit{state},~$s \in \mathcal{S} \subset \mathcal{N}$, the set of natural numbers. That is, the regular PDPs comprising a Sticky PDP have bivariate labels, $(g,s)\in \mathcal{G}\times \mathcal{S}$. \item[Property 2:] The regular PDPs may have equal or unequal discount parameters, mass parameters, and/or base distributions. For every $(g,s) \in \mathcal{G}\times \mathcal{S}$, let the corresponding PDP be $\mathcal{W}_{gs}(d_{s}, \alpha_{s}, W_{s})$. With $\mathcal{P}_{gs}$ denoting a random realization of the PDP's stick-breaking distribution, we have \begin{align} \mathcal{P}_{gs} &\stackrel{d}= \sum_{v=1}^\infty \pi_{gsv} 1_{\boldsymbol{\phi}_{gsv}} \quad\text{where the $T$-variate atoms}\notag\\ &\boldsymbol{\phi}_{gsv} \stackrel{iid}\sim W_{s}, \quad\text{for index $v \in \mathcal{N}$, and probabilities}\label{phi}\\ &\pi_{gs1} = V_{gs1}, \quad \pi_{gsh} = V_{gsh} \prod_{v=1}^{h-1}(1-V_{gsv}), \quad h > 1, \quad\text{with}\notag\\ &V_{gsh} \stackrel{indep}\sim \text{beta}(1-d_{s}, \alpha_{s}+hd_{s}). \notag \end{align} Notice that base distribution $W_s$ in $\mathcal{R}^T$ is determined by the state $s$ but not group $g$. On the other hand, the atoms and their associated probabilities in distribution $\mathcal{P}_{gs}$ may depend on both group and state. If set $\mathcal{S}$ contains multiple states, assume that the set of base distributions $\{W_{s}: s \in \mathcal{S}\}$ is such that two PDPs associated with unequal states will almost surely have non-intersecting sets of atoms. That is, whenever $s_1^* \neq s_2^*$, the intersection of the random sets of the atoms $\{\boldsymbol{\phi}_{g_1^*s_1^*v}\}_{v=1}^\infty$ and $\{\boldsymbol{\phi}_{g_2^*s_2^*v}\}_{v=1}^\infty$ of stick-breaking distributions $\mathcal{P}_{g_1^*s_1^*}$ and $\mathcal{P}_{g_2^*s_2^*}$ is almost surely empty. \smallskip \item[Property 3:] For probe $j=1,\ldots,p$, the label of the PDP generating random effect $\boldsymbol{\theta}_j$ is denoted by $(g_j,s_j) \in \mathcal{G}\times \mathcal{S}$, and $ \boldsymbol{\theta}_j \mid \mathcal{P}_{g_j s_j} \stackrel{indep}\sim \mathcal{P}_{g_j s_j}. $ Equivalently, random effect $\boldsymbol{\theta}_j$ equals atom $\boldsymbol{\phi}_{g_j s_j v_j}$ with probability~$\pi_{g_j s_j v_j}$ for index $v_j \in \mathcal{N}$. \smallskip \item[Property 4:]\label{SP1} Given group $g_j$ for the $j^{th}$ probe, the state of the PDP generating random effect $\boldsymbol{\theta}_{j}$ is randomly selected as follows: \begin{equation*} s_j \mid g_j \sim \mathcal{Q}_{g_j} \end{equation*} where for every $g \in \mathcal{G}$, $\mathcal{Q}_g$ denotes a group-specific probability mass function on the set $\mathcal{S}$; thus, $\sum_{s \in \mathcal{S}}\mathcal{Q}_{g}(s) = 1$. \smallskip \item[Property 5:] \textit{(Markov property)} \quad For probe $j>1$, given the variables associated with the preceding probes, group variable $g_j$ has a mass function depending on random vector $\boldsymbol{\theta}_{j-1}$ and inter-probe distance $e_{j-1}$: \begin{equation*} g_j \sim \mathcal{F}_{\boldsymbol{\theta}_{j-1},e_{j-1}} \end{equation*} where, for every $\boldsymbol{\theta} \in \mathcal{R}^T$ and $e>0$, $\mathcal{F}_{\boldsymbol{\theta},e}$ denotes a probability mass function on the set $\mathcal{G}$, so that $\sum_{g \in \mathcal{G}}\mathcal{F}_{\boldsymbol{\theta},e}(g) = 1$. For the first probe, group $g_1$ follows a categorical distribution, $\mathcal{F}_{0}$, on the set $\mathcal{G}$. \end{enumerate} Some examples are presented in Table \ref{T1} of Supplementary Material; as suggested by the form of distribution $\mathcal{F}_{\boldsymbol{\theta} , e}$ in the table, the first two models are first order Sticky~PDPs. The Sticky PDP corresponding to 2R2CF models used in differential methylation is a special case with two groups and two states. We observe that the first order models displayed in Table 1 are multiple-group, \textit{single-state} models, and that their dependencies are the same irrespective of the inter-probe distances. In contrast, as noted in Consequences 2 and 3 of Section \ref{Sticky_PDPs_DA}, the proposed Sticky PDP for differential analysis behaves similarly to two-state hidden Markov models for very small inter-probe distances, and similarly to finite mixture models for relatively large distances. For differential analysis, this offers a key advantage in datasets with widely varying inter-probe distances, as discussed in detail in Section \ref{S:intro}. The differential and non-differential probes are allowed to have different cluster allocation patterns depending on the differential status of the adjacent probes. These are some of the features that make Sticky PDPs ideally suited for differential analysis, and are primarily facilitated by the two-group, two-state~construct. { \begin{table} \footnotesize \begin{center} \renewcommand{\arraystretch}{1.3} \begin{tabular}{l | c c c c c } \hline\hline \textbf{Model} &$\mathcal{G}$ &$\mathcal{W}_{gs}(d_{s}, \alpha_{s}, W_{s})$ &$\mathcal{P}_{gs}$ &$\mathcal{F}_{\boldsymbol{\theta},e}$ \\ \hline\hline HDP-HMM &$\mathcal{N}$ &$\mathcal{W}_{g}(0, \alpha, W)$, &$\sum_{v=1}^\infty \pi_{gv} 1_{\boldsymbol{\phi}_{v}}$ &Point mass at \\ & &countably infinite $W$ & &$\sum_{v=1}^\infty v\cdot \mathcal{I}(\boldsymbol{\theta}=\boldsymbol{\phi}_{v})$\\\hline % % Finite HMM &$\{1,\ldots,K\}$ &$\mathcal{W}_g(0, \alpha, W)$, &$\sum_{v=1}^K \pi_{gv} 1_{\boldsymbol{\phi}_{v}}$ &Point mass at \\ & &discrete $W$ with $K<\infty$ atoms & &$\sum_{v=1}^K v\cdot \mathcal{I}(\boldsymbol{\theta}=\boldsymbol{\phi}_{v})$\\\hline % % HDP &$\{1,\ldots,K\}$ &$\mathcal{W}_{g}(0, \alpha, W)$, &$\sum_{v=1}^\infty \pi_{gv} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{g\}}$, \\ & &countably infinite $W$ & &prespecified $g \in \mathcal{G}$ \\\hline % % PDP &$\{1\}$ &$\mathcal{W}(d, \alpha, W)$ &$\sum_{v=1}^\infty \pi_{v} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{1\}}$ \\\hline % % Dirichlet process &$\{1\}$ &$\mathcal{W}(0, \alpha, W)$ &$\sum_{v=1}^\infty \pi_{v} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{1\}}$ \\\hline % % Finite mixture &$\{1\}$ &$\mathcal{W}(0, \alpha, W)$, &$\sum_{v=1}^K \pi_{v} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{1\}}$ \\ & &discrete $W$ with $K<\infty$ atoms \\%\hline % % \hline \end{tabular} \end{center} \caption{Examples of Sticky PDPs. Set $\mathcal{N}$ represents the natural numbers. All the above examples correspond to singleton set $\mathcal{S}=\{1\}$ and degenerate distribution $\mathcal{Q}_{g}=1_{\{1\}}$. Refer to the description in Section \ref{general2R2CF} for the notation. }\label{T1} \end{table} } \begin{figure}[h] \centering \includegraphics[width=0.7\textwidth]{figures/PlotCorr} \caption{Exploratory analysis of DNA methylation profiles of upper GI cancer samples from TCGA. See the text in the paper for further explanation. } \label{intro_data_plots2} \end{figure} \begin{table} \centering \footnotesize \begin{tabular}{c c | c c c c} & & \multicolumn{2}{c}{Low noise} &\multicolumn{2}{c}{High noise} \\ \hline & & High correlation & No correlation & High correlation & No correlation \\ \hline \multirow{7}{0.1\textwidth}{\centering AUC} & BayesDiff & \textbf{0.995} & \textbf{0.970} & \textbf{0.944} & 0.830 \\ & ANOVA & 0.964 & 0.949 & 0.888 & \textbf{0.864} \\ & Kruskal-Wallis & 0.958 & 0.944 & 0.878 & 0.854 \\ & COHCAP & 0.955 & 0.941 & 0.861 & 0.841 \\ & Methylkit & 0.955 & 0.942 & 0.869 & 0.848 \\ & BiSeq & 0.949 & 0.933 & 0.867 & 0.845 \\ & RADMeth & 0.959 & 0.944 & 0.876 & 0.852 \\ \hline \multirow{7}{0.1\textwidth}{\centering $\textrm{AUC}_{20}$} & BayesDiff & \textbf{0.988} & \textbf{0.926} & \textbf{0.884} & \textbf{0.636} \\ & ANOVA & 0.891 & 0.851 & 0.684 & 0.628 \\ & Kruskal-Wallis & 0.876 & 0.833 & 0.657 & 0.597 \\ & COHCAP & 0.856 & 0.820 & 0.602 & 0.556 \\ & Methylkit & 0.858 & 0.819 & 0.633 & 0.579 \\ & BiSeq & 0.822 & 0.781 & 0.607 & 0.559 \\ & RADMeth & 0.871 & 0.833 & 0.639 & 0.588 \\ \hline \multirow{7}{0.1\textwidth}{\centering $\textrm{AUC}_{10}$} & BayesDiff & \textbf{0.985} & \textbf{0.901} & \textbf{0.857} & \textbf{0.565} \\ & ANOVA & 0.849 & 0.804 & 0.586 & 0.529 \\ & Kruskal-Wallis & 0.827 & 0.773 & 0.551 & 0.493 \\ & COHCAP & 0.797 & 0.751 & 0.492 & 0.433 \\ & Methylkit & 0.794 & 0.744 & 0.523 & 0.458 \\ & BiSeq & 0.726 & 0.673 & 0.482 & 0.424 \\ & RADMeth & 0.817 & 0.775 & 0.531 & 0.471 \\ \end{tabular} \caption{Areas under ROC curves for the different methods (rows) under the four simulation scenarios (columns). See the text in the paper for further discussion.} \label{table_sim1} \end{table} \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/PlotHist_numprobes} \caption{Histogram of the number of gene-specific CpG~sites} \end{subfigure}% \quad \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/RealData_eta0_logBF} \caption{95\% credible intervals for lower bounds of log-Bayes factors of first order versus zero-order models. The intervals whose lower limits are positive are marked in red.} \end{subfigure} \caption{Data analysis plots. See the Section \ref{data_analysis} text for further explanation.} \label{appl_plots} \end{figure} \begin{table \centering \begin{tabular}{ccc|ccc} \hline \hline \multirow{2}{*}{Gene} & DM & Largest & \multirow{2}{*}{Gene} & DM & Largest \\ & Proportion & Difference & & Proportion & Difference\\ \hline EDNRB & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & SLITRK1 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ PCLO & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & FLRT2 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ PREX2 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & KCNA1 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ SLIT2 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & TRPA1 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ SLITRK2 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & ADCY8 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ SORCS3 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & CTNNA2 & 0.95 & PAAD$\uparrow$ LIHC$\downarrow$ \\ SPHKAP & 1.00 & ESCA$\uparrow$ LIHC$\downarrow$ & GRIA2 & 0.95 & STAD$\uparrow$ LIHC$\downarrow$ \\ SPTA1 & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & ADGRL3 & 0.94 & PAAD$\uparrow$ LIHC$\downarrow$ \\ UNC13C & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & LRRC7 & 0.94 & STAD$\uparrow$ LIHC$\downarrow$ \\ XIRP2 & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & ERBB4 & 0.93 & PAAD$\uparrow$ LIHC$\downarrow$ \\ ZNF804B & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & PCDH10 & 0.93 & STAD$\uparrow$ LIHC$\downarrow$ \\ TSHZ3 & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & SOX11 & 0.93 & STAD$\uparrow$ LIHC$\downarrow$ \\ MYO3A & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & NLGN4X & 0.93 & PAAD$\uparrow$ LIHC$\downarrow$ \\ ABCC9 & 0.97 & ESCA$\uparrow$ LIHC$\downarrow$ & NBEA & 0.93 & PAAD$\uparrow$ LIHC$\downarrow$ \\ EPB41L3 & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & CNTN1 & 0.92 & STAD$\uparrow$ LIHC$\downarrow$ \\ FBN2 & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & GRM5 & 0.92 & PAAD$\uparrow$ LIHC$\downarrow$ \\ PCDH17 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ & PTPRZ1 & 0.91 & STAD$\uparrow$ PAAD$\downarrow$ \\ CDH8 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ & EPHA5 & 0.91 & STAD$\uparrow$ LIHC$\downarrow$ \\ \hline \hline \end{tabular} \caption{Genes with the overall proportion of differentially methylated CpG sites exceeding 0.9, listed in descending order. The ``Largest Difference'' column displays which pair-wise difference between the four cancer types is the largest, with the symbol ``$\uparrow$ ($\downarrow$)'' indicating higher (lower) methylation level for one cancer type relative to the other.} \label{table_list_gene_prop}% \end{table} \begin{table \centering \begin{tabular}{lc|lc} \hline \hline Gene & Number of probes & Gene & Number of probes \\ \hline ABCC9 & 36 & NLGN4X & 28 \\ ADCY8 & 24 & PCDH10 & 30 \\ ADGRL3 & 35 & PCDH17 & 27 \\ CDH8 & 26 & PCLO & 20 \\ CNTN1 & 25 & PREX2 & 21 \\ CTNNA2 & 85 & PTPRZ1 & 23 \\ EDNRB & 56 & SLIT2 & 29 \\ EPB41L3 & 34 & SLITRK1 & 26 \\ EPHA5 & 22 & SLITRK2 & 28 \\ ERBB4 & 30 & SORCS3 & 39 \\ FBN2 & 30 & SOX11 & 44 \\ FLRT2 & 51 & SPHKAP & 17 \\ GRIA2 & 20 & SPTA1 & 16 \\ GRM5 & 25 & TRPA1 & 25 \\ KCNA1 & 25 & TSHZ3 & 39 \\ LRRC7 & 34 & UNC13C & 11 \\ MYO3A & 38 & XIRP2 & 19 \\ NBEA & 55 & ZNF804B & 21 \\ \hline \hline \end{tabular} \caption{For the top methylated genes listed in Table \ref{table_list_gene_prop} of the paper, number of included CpG sites.} \label{table_list_num_probe}% \end{table} \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{\textwidth} \centering \includegraphics[trim={0 12pt 0 0},clip,width=0.75\textwidth]{figures/RealData_TP53_eqd_wlab} \caption{Gene TP53} \vspace{10pt} \end{subfigure} \begin{subfigure}{\textwidth} \centering \includegraphics[trim={0 12pt 0 0},clip,width=0.75\textwidth]{figures/RealData_TTN_eqd_wlab} \caption{Gene TTN} \vspace{10pt} \end{subfigure} \caption{Detailed differential methylation results for the top 2 mutated genes. For each gene, the upper panel shows the mean methylation levels. The middle panel shows the posterior probabilities of each CpG site being differentially methylated, with solid points representing differential methylation and dashed line denoting the corresponding cutoff value. The lower panel indicates the largest pairwise difference between the 4 cancer types. Symbols 1--4 in the lower panel represent GI cancer types STAD, LIHC, ESCA and PAAD, respectively. The vertical dotted lines represent the gene boundaries. The arrow at the top indicates the transcription direction.} \label{DA_detail_2genes} \end{figure} \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/mean-mean-TP53.pdf} \caption{First moments for gene TP53} \end{subfigure}% \quad \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/var-var-TP53.pdf} \caption{Second moments for gene TP53} \end{subfigure} \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/mean-mean-TTN.pdf} \caption{First moments for gene TTN} \end{subfigure}% \quad \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/var-var-TTN.pdf} \caption{Second moments for gene TTN} \end{subfigure} \caption{Comparison of predicted and actual sample moments for the 2 top mutated genes} \label{mean-mean_var-var} \end{figure} \end{supplement} \bibliographystyle{ba} \section{Introduction}\label{S:intro} Recent advances in array-based and next-generation sequencing (NGS) technologies have revolutionized biomedical research, especially in cancer. The rapid decline in the cost of genome technologies has facilitated the availability of datasets that involve intrinsically different sizes and scales of high throughput data, providing genome-wide, high resolution information about the biology of cancer. In general, a common goal is the identification of differential genomic signatures between groups of samples corresponding to different treatments or biological conditions, e.g., treatment arms, response to adjuvant chemotherapy, tumor subtypes, or cancer stages. The analytic challenges include the high dimensionality of genomic biomarkers or probes, usually in the hundreds of thousands, and the relatively small number of patient samples, usually no more than a few~hundred. This ``small $n$, large $p$'' setting results in unstable inferences due to collinearity. Further, there exist complex interaction patterns, such as signaling or functional pathway-based interactions, and genomic or chromosomal location-based serial correlation for high-throughput sequencing data. These data attributes significantly affect the reliability of detecting differential genomic signatures by statistical techniques. \paragraph{Differential DNA methylation in cancer studies} DNA methylation is an important epigenetic mechanism that occurs by the addition of a methyl (CH$_3$) group to DNA, resulting in the modification of gene functions. It typically occurs at specific genomic locations called cytosine-phosphate-guanine (CpG) sites. Alterations in DNA methylation, e.g., hypomethylation of oncogenes and hypermethylation of tumor suppressor genes, are often associated with the development and progression of cancer \citep{feinberg2004history}. It was previously believed that these alterations occur almost exclusively at promoter regions known as CpG islands, which are chromosomal regions with a high frequency of CpG sites. However, with the advent of high-throughput technologies, it has been shown that a significant proportion of methylation alterations related to cancer do not occur in either promoters or CpG islands \citep{irizarry2009genome}, prompting higher resolution, epigenome-wide investigations. Gastrointestinal (GI) cancer, the most common form of cancer in the U.S. \citep{CAAC:CAAC21387}, are malignant conditions affecting the digestive system, and are associated with epigenetic alterations \citep{vedeld2017epigenetic}. Molecular characterization of the different cancer types, facilitated by the identification of differentially methylated CpG sites, is therefore key to better understanding GI cancer. In the motivating application, we analyze methylation profiles publicly available from The Cancer Genome Atlas (TCGA) project, consisting of 1,224 tumor samples belonging to four GI cancers of the upper digestive tract: stomach adenocarcinoma (STAD), liver hepatocellular carcinoma (LIHC), esophageal carcinoma (ESCA) and pancreatic adenocarcinoma (PAAD). For 485,577 probes, with each probe mapped to a CpG site, DNA methylation levels ranging from 0 (no methylation) to 1 (full methylation) were measured using the Illumina Human Methylation 450 platform. \begin{figure}[h] \centering \includegraphics[width=0.7\textwidth]{figures/PlotData_20200330_5.pdf} \caption{Methylation levels of CpG sites near gene TP53.} \label{intro_data_plots} \end{figure} Figure \ref{intro_data_plots} displays the methylation levels for CpG sites near TP53, a tumor suppressor gene located on chromosome $17$. A random subset of the samples was chosen to facilitate an informal visual evaluation. The four sets of colors and shapes of the points represent the four upper GI cancers. Although differential methylation is clearly visible at some CpG sites, the differences are generally subtle, demonstrating the need for sophisticated statistical analyses. An obvious feature is the correlation between the apparent methylation statuses of nearby CpG sites \citep{eckhardt2006dna, irizarry2008comprehensive, leek2010tackling}. The dependence of proximal CpG sites is also seen in Figure \ref{intro_data_plots2} of Supplementary Material, where we find high first order autocorrelations and highly significant tests for serial correlations. Furthermore, the variability of the inter-probe spacings in Figure~\ref{intro_data_plots} suggests that the need for modeling distance-based dependencies. \paragraph{Existing statistical approaches for differential DNA methylation and limitations} Numerous frequentist and Bayesian methods have been developed for differential DNA methylation, and can be broadly classified into four categories: \textit{(i)} \textit{Testing-based methods}, such as Illumina Methylation Analyzer (IMA) \citep{wang2012ima}, City of Hope CpG Island Analysis Pipeline (COHCAP) \citep{warden2013cohcap}, and BSmooth \citep{hansen2012bsmooth}. These methods rely on two-sample or multiple-sample tests for the mean group differences at each CpG site. \textit{(ii)} \textit{Regression based models}, such as Methylkit \citep{akalin2012methylkit}, bump hunting \citep{jaffe2012bump}, Biseq \citep{hebestreit2013detection}, and RADMeth \citep{dolzhenko2014using}. After applying smoothing or other adjustments, these methods fit individual regression models for each CpG site and test for significance. \textit{(iii)} \textit{Beta-binomial model-based methods}, such as MOABS \citep{sun2014moabs}, DSS \citep{feng2014bayesian}, and methylSig \citep{park2014methylsig}. These methods fit separate models for each CpG site. \textit{(iv)} \textit{Hidden Markov models (HMMs)}, such as MethPipe \citep{song2013reference}, Bisulfighter \citep{saito2014bisulfighter}, and HMM-DM \citep{yu2016hmm}. These methods detect differentially methylated sites based on the inferred hidden~states. The aforementioned methods have several deficiencies. Most methods ignore the strong correlations between neighboring CpG sites or probes, fitting separate models to each probe. This reduces the detection power for the relatively small sample sizes. Additionally, beta-binomial, HMM, and most of the testing-based methods are able to accommodate only two treatments or groups. To handle multiple treatments, they resort to inefficient multiple comparison adjustments. The methods that account for serial dependence (e.g., HMMs) do not adjust for the widely varying distances between the probes, instead assuming uniform inter-site dependencies. The few methods that account for inter-site distances \citep[e.g.,][]{hansen2012bsmooth, jaffe2012bump, hebestreit2013detection} rely on ad hoc parameter-tuning procedures that do not adjust for the distinctive data characteristics. Motivated by these challenges, we propose general and flexible methodology for differential analysis in DNA methylation data, referred to as \textit{BayesDiff}. Rather than fitting a separate model for each CpG site or probe, BayesDiff relies on a global analytical framework for simultaneous inferences on the probes that adapts to the unique data attributes. To diminish collinearity effects and achieve dimension reduction, the probes are allocated to a smaller, unknown number of latent clusters based on the similarities of probes-specific multivariate parameters. Finally, differential state variables of the probes delineate the genomic signature of the disease to fulfil the main inferential goal. For realistically modeling the probe-cluster allocation mechanism of DNA methylation profiles, we devise an extension of Poisson Dirichlet processes (PDPs) \citep{perman1992size} called the \textit{Sticky PDP} (equivalently, the \textit{two-restaurant two-cuisine franchise}). In addition to accounting for long-range biological interactions, this nonparametric process accommodates distance-based serial dependencies of the probes. Additionally, separately for the differential and non-differential probes, it flexibly permits the data to direct the choice between PDPs, and their special case, Dirichlet processes, in finding the best-fitting allocation schemes. We implement an inferential procedure using a Markov chain Monte Carlo (MCMC) algorithm which is specifically designed for posterior inferences in Sticky PDPs and is scalable to the typically large methylation datasets. Simulation results show that our approach significantly outperforms existing methods for multigroup comparisons in datasets with or without serial correlation. For the motivating TCGA dataset, in addition to confirming known features of DNA methylation and disease-gene associations, the analysis reveals interesting aspects of the biological mechanisms of upper GI~cancers. The rest of the paper is organized as follows. Section \ref{model_desc_section} describes the BayesDiff approach, with Section~\ref{Sticky_PDPs_DA} introducing the Sticky PDP or two-restaurant two-cuisine franchise (2R2CF) for differential DNA methylation. Section~\ref{S:post_inf} outlines a computationally efficient posterior inference procedure for detecting differential probes. For varying noise and correlation levels, Section \ref{sim_study} uses artificial datasets to assess the accuracy of BayesDiff in detecting disease genomic signatures and compares the results with established techniques for DNA methylation data. The motivating upper GI dataset is analyzed using the BayesDiff procedure in Section \ref{data_analysis}. Finally, conclusions and future related work are discussed in Section~\ref{disc}. \section{The BayesDiff Model} \label{model_desc_section} Sequencing technologies measure DNA methylation levels of $p$ biomarkers represented by CpG sites (``probes'') and $n$ matched patient or tissue samples (``individuals''), with $p$ much larger than $n$. The data belong to the interval $[0,1]$ and are arranged in an $n \times p$ matrix of proportions, $\mathbf{X}=((x_{ij}))$, for individuals $i$ and probes $j$, with the probes sequentially indexed by their genomic locations. The distances between adjacent probes are denoted by $e_1,\ldots,e_{p-1}$, and typically exhibit high variability, e.g., in the upper GI TCGA dataset, the inter-probe distances range from 2 base pairs to 1 megabase pair. Each individual $i$ is associated with a known experimental or biological condition (``treatment'') denoted by $t_i$ that takes values in $\{1,...,T\}$, $T\ge 2$. In the motivating TCGA data, there are $T=4$ upper GI cancer~types. We model the logit transformation of the methylation levels, $z_{ij}=\log\left(x_{ij}/\left(1-x_{ij}\right)\right)$, as follows: \begin{equation} z_{ij} \sim N\left(\xi_i+\chi_j+\theta_{t_ij},\sigma^{2}\right) \label{def_main_model} \end{equation} where $\xi_i$ represents the $i$th subject's random effect, $\chi_j$ represents the $j$th probe's random effect, and $\theta_{tj}$ is the random treatment $t$--probe $j$ interaction effect. The main inferential goal is the detection of differential probes, i.e., probes $j$ for which the elements of column vector $\boldsymbol{\theta}_j=$ $\left(\theta_{1j},\dots, \theta_{Tj}\right)'$ are not all identical. Consequently, we define a binary \textit{differential state variable}, $s_j$, with $s_j=1$ indicating that probe $j$ is not differential, and $s_j=2$ indicating that it is differential: \begin{align} s_j= \begin{cases} 1 \qquad\text{if } \theta_{1j}=\theta_{2j}=\dots=\theta_{Tj}, \\ 2 \qquad \text{otherwise}, \end{cases} \label{def_nonDE} \end{align} for $j=1, \dots, p$. Thus, the key parameters for differential methylation are $s_1,\ldots,s_p$, with the disease genomic signature consisting of the probes with state $s_j=2$. Motivated by the distance-dependent correlations exhibited by DNA methylation data and the deficiencies of existing statistical approaches noted in Section \ref{S:intro}, this paper fosters a novel Bayesian nonparametric framework for the random effects $\boldsymbol{\theta}_1,\ldots,\boldsymbol{\theta}_p$ on which the differential state variables depend. \subsection*{Modeling probe clusters} \label{PDP_sec_main} As mentioned, in addition to high-dimensionality, the analytical challenges posed by DNA methylation datasets include pervasive collinearity caused by dependencies between physically proximal CpG sites or probes. Additionally, there are long-range dependencies between non-adjacent probes due to biological interactions, e.g., signaling or functional pathways. To accommodate dependencies and extract information from the large number of probes, we allocate the $p$ probes to a much smaller number, $q$, of latent clusters based on the similarities of the random effects $\boldsymbol{\theta}_j$ for probes $j=1,\ldots,p$. We favor clustering to dimension reduction methods such as principal components analysis (PCA). Specifically, because each principal component is a linear combination of all $p$ biomarkers, PCA is less useful in cancer research because of its inability to select features, i.e., probes. By contrast, our approach facilities biological interpretations by identifying CpG sites relevant to the differential disease genomic~signatures. Suppose that an \textit{allocation variable}, $c_j$, assigns probe $j$ to one of $q$ latent clusters, where $q$ is unknown. The event $[c_j=k]$ signifies that the $j^{th}$ probe belongs to the $k^{th}$ latent cluster, $k=1,\dots, q$. We assume that the $q$ clusters are associated with \textit{latent vectors}, $\boldsymbol{\lambda}_1,\dots, \boldsymbol{\lambda}_q$, where the probe-specific random effects and cluster-specific latent vectors have the relation: \begin{equation} \boldsymbol{\theta}_j=\boldsymbol{\lambda}_k \quad \text{if $c_j=k$.}\label{allocation c} \end{equation} That is, all probes within a cluster are assumed to have identical random effects equal to that cluster's latent vector. The differential state variables of the probes, defined in equation (\ref{def_nonDE}), then become a shared attribute of their parent cluster, and clusters as a whole are either differentially or non-differentially methylated. Further, if probe $j$ belongs to cluster $k$ (i.e., $c_j=k$), then condition $\theta_{1j}=\theta_{2j}=\dots=\theta_{Tj}$ in equation~(\ref{def_nonDE}) is equivalent to $\lambda_{1k}=\lambda_{2k}=\dots=\lambda_{Tk}$, and differential clusters constitute the set \begin{equation} \mathcal{D} = \left\{k: \lambda_{tk} \neq \lambda_{t^{'}k}, \text{ for some } t \neq t^{'}, k=1,\ldots,q\right\}. \label{D} \end{equation} \paragraph{Mixture models for allocation} Bayesian infinite mixture models are a natural choice for allocating $p$ probes to a smaller, unknown number of latent clusters based on their random effects similarities. Dirichlet processes \citep{ferguson1973bayesian} are arguably the most frequently used infinite mixture models; see \citet[chap.\ 4]{muller2013bayesian} for a comprehensive review. The use of Dirichlet processes to achieve dimension reduction in massive datasets has precedence in the literature, albeit in unrelated applications \citep[see][]{Medvedovic_etal_2004,Kim_etal_2006, Dunson_etal_2008,Dunson_Park_2008,Guha_Baladandayuthapani_2016}. \cite*{Lijoi_Mena_Prunster_2007b} advocated the use of Gibbs-type priors \citep*{Gnedin_Pitman_2005} for accommodating more flexible clustering mechanisms, and also demonstrated the utility of Poisson-Dirichlet processes (PDPs) in genomic applications. Formally, the two-parameter PDP \citep{perman1992size} relies on a discount parameter $d \in [0,1)$, positive mass parameter $\alpha$, and $T$-variate base distribution $W$, and is denoted by $\mathcal{W}(d,\alpha,W)$. The value $d=0$ yields a Dirichlet process with mass parameter $\alpha$ and base distribution $W$. Suppose $\boldsymbol{\theta}_1, \ldots, \boldsymbol{\theta}_p$ are distributed as $\mathcal{W}(d,\alpha,W)$. The \textit{stick-breaking representation} of $\mathcal{W}(d,\alpha,W)$ is $\boldsymbol{\theta}_j \stackrel{iid}\sim \mathcal{P}$, where random distribution $\mathcal{P}$ is the discrete mixture $\sum_{v=1}^\infty \pi_v \delta_{\boldsymbol{\phi}_v}$, with $\delta_{\boldsymbol{\phi}_v}$ denoting a point mass located at the atom $\boldsymbol{\phi}_v \stackrel{iid}\sim W$. The random stick-breaking probabilities have the form $\pi_1 = V_1$, and $\pi_h = V_h \prod_{v=1}^{h-1}(1-V_v)$ for $h > 1$, where $V_h \stackrel{indep}\sim \text{beta}(1-d, \alpha+hd)$. \cite{Guha_Baladandayuthapani_2016} introduced VariScan, a technique that utilizes PDPs and Dirichlet processes for clustering, variable selection, and prediction in high-dimensional regression problems in general, and in gene expression datasets in particular. They also demonstrated that PDPs are overwhelmingly favored to Dirichlet processes in gene expression datasets, which typically exhibit no serial~correlation. \paragraph{Limitations of existing mixture models} Although the aforementioned mixture models achieve dimension reduction in the large number of probes and account for the long-range biological interactions between non-adjacent probes, a potential drawback is their implicit assumption of apriori probe (i.e., CpG site) exchangeability. Consequently, these techniques cannot account for the serial correlation among CpG sites in methylation data. Infinite HMMs, such as the hierarchical Dirichlet process hidden Markov model (HDP-HMM) \citep{Teh_etal_2006} and Sticky HDP-HMM \citep{Fox_etal_2011}, may be utilized to fill this gap. Although these models are a step in the right direction, they have several undesirable features for differential analysis. \textit{First}, the degree of first order dependence is uniform irrespective of the inter-probe distances. This is unrealistic in methylation datasets where the correlation between adjacent probes typically decreases with inter-probe distance \citep{hansen2012bsmooth, jaffe2012bump, hebestreit2013detection}. {\textit{Second}, an ad hoc exploratory analysis of the GI cancer dataset reveals that the serial correlation in the treatment-probe effects is weaker than the serial dependence between the differential state variables defined in equation (\ref{def_nonDE}). Although there may not be a biological explanation for this phenomenon, this makes sense from a statistical perspective, because the differential states are binary functions of the treatment-probe interactions; the differential states are more sensitive in detecting first order dependence even when the higher-dimensional (and noisier) treatment-probe interactions show weak or no correlation.} This suggests that a hypothetical two-group Markov model, rather than an infinite-group Markov model such as HDP-HMM or Sticky HDP-HMM, would provide a better fit for the data. \textit{Third}, the range of allocation patterns supported by infinite HMMs is relatively limited. In particular, realistic allocation patterns, such as power law decays in the cluster sizes and large numbers of small-sized clusters, a common feature of cancer datasets \citep{Lijoi_Mena_Prunster_2007a}, are assigned relatively small prior probabilities by infinite HMMs. \subsection{Sticky PDP: A Two-restaurant, Two-cuisine Franchise (2R2CF) for Differential Analysis}\label{Sticky_PDPs_DA} For the aforementioned reasons, we invent a mixture model called the Sticky PDP. Essentially, this is a cohort of regular PDPs that generates the probe-specific random effects, $\boldsymbol{\theta}_1,\ldots,\boldsymbol{\theta}_p$, by switching the generative PDPs at random locations along the probe sequence. Alternatively, the well-known Chinese restaurant franchise (CRF) metaphor for HDP-HMMs and Sticky HDP-HMMs \citep[e.g.,][]{Fox_etal_2011} can be generalized to the \textit{two-restaurant two-cuisine franchise} (2R2CF) to provide an equivalent representation of Sticky PDPs appropriate for differential analysis. We present an overview of 2R2CF followed by an in-depth~description. Imagine that a franchise has two restaurants, labeled 1 and 2. Each restaurant consists of two sections, and each section serves a single cuisine consisting of an infinite number of dishes. Section 1 in both the restaurants exclusively serves its customers cuisine~1, whereas section 2 exclusively serves cuisine 2. The \textit{section-cuisine menu}, or a list of available cuisine dishes, is identical at the two restaurants. Although both restaurants serve the two cuisines in their respective sections, restaurant~1 specializes in cuisine~1, and consequently, cuisine 1 is more popular with restaurant~1 patrons. Similarly, cuisine 2 is more popular at restaurant 2 because it specializes in that cuisine. Although every menu item is available at both the restaurants, the relative popularity of each menu item is generally different at the two restaurants. A succession of $p$ customers, representing the CpG sites or probes, arrive at the franchise, and each customer selects a restaurant followed by a section (equivalently, cuisine) in that restaurant. The waiting times between successive customers, $e_1, \dots,e_{p-1}$, represent the inter-probe distances. Cuisine 1 symbolizes the {non-differential state}, and cuisine 2 symbolizes the {differential state}. Each restaurant section has an infinite number of tables. A restaurant customer who selects a particular section may either sit at one of the tables already occupied by previous customers in that section, or sit at a new table. All customers whose choose an already occupied table are served the same dish, previously chosen from the section-cuisine menu by the first customer who sat at that table. Multiple tables in a section may serve the same dish. The dish that franchise customer $j$ eats represent their probe-specific random effect, $\boldsymbol{\theta}_j$, of length $T$. Since cuisine 1 represents the {non-differential state}, its dishes are characterized by random effects vectors with all $T$ elements equal. Similarly, the cuisine 2 (differential state) dishes are characterized by $T$-variate random vectors with at least two unequal elements. By design, if a customer has eaten a dish belonging to cuisine 1 (2), the next customer is more likely to visit restaurant 1 (2), where that cuisine is more popular there. Consequently, a customer tends to select the same cuisine as the previous customer. This model feature accounts for long runs of differential or non-differential states. However, a customer's influence on the next customer diminishes as the time interval separating the two customers~increases. That is, the differential statuses of two adjacent probes become statistically independent in the limit as their inter-probe distance~grows. The process evolution is graphically illustrated in Figure~\ref{2R2CF plots} and discussed below in greater~detail. \paragraph{Cuisine 1 menu.} As mentioned, the dishes list on the cuisine 1 menu are characterized by random vectors with all $T$ elements equal. Therefore, they are modeled by \textit{menu distribution} $W_1$ having the following structure: with $\boldsymbol{1}_T$ denoting the column vector of $T$ ones, \begin{align} W_1 &\stackrel{d} = \psi\boldsymbol{1}_T, \quad\text{where $\psi \in \mathcal{R}$ with}\label{W1}\\ \psi & \sim G, \notag\\ G & \sim \mathcal{DP} \left(\beta,G_0\right),\quad\text{and}\notag\\ G_0&=N\left(\mu_G,\tau_G^{2}\right). \nota \end{align} The symbol $\mathcal{DP} \left(\beta,G_0\right)$ denotes a Dirichlet process prior with mass parameter $\beta>0$ and base distribution $G_0$. The stick-breaking representation of the Dirichlet process implies that random distribution $G$ is almost surely discrete, and has the mixture distribution \begin{equation} G \stackrel{d}= \sum_{v=1}^\infty \varpi_{v} \delta_{\zeta_{v}}, \text{ where $\sum_{v=1}^\infty \varpi_{v}=1$ and $\zeta_{v} \stackrel{iid}\sim G_0$}. \label{density G} \end{equation} The precise form of the random probabilities, $\varpi_{v}$, which depend on mass parameter $\beta$, was derived in \cite{sethuraman1994constructive}; see also \cite{Ishwaran_James_2003} and \cite{Lijoi_Prunster_2010}. For natural numbers $\mathcal{N}$, the set $\mathcal{S}_1=$ $\{\zeta_{v}\boldsymbol{1}_T : v \in \mathcal{N}\}$ then represents the list of available cuisine 1 dishes, and is the support of distribution $W_1$. The continuity of base distribution $G_0$ guarantees that all the menu dishes are unique. The fact that distribution $G$ is discrete has practical consequences for differential analysis: \textit{(a)} cuisine 1 consists of a countably infinite set, rather than a continuous spectrum, of dishes, and \textit{(b)} any two section 1 tables may potentially serve the same cuisine~1 dish even if the tables belong to different restaurants. \paragraph{Cuisine 2 menu.} As previously stated, the cuisine dishes characterize the {differential state} through $T$-variate random vectors with at least two unequal elements. The menu is modeled by a distribution, $W_2$, satisfying two conditions: \textit{(i)}~for similar reasons as the cuisine 1 menu, $W_2$ is a countably infinite distribution, and \textit{(ii)} each atom of $W_2$ has at least two unequal elements. For every $\boldsymbol{\phi}=(\phi_1,\ldots,\phi_T)' \in \mathcal{R}^T$, a probability mass function satisfying both conditions can be constructed as follows: \begin{align} W_2(\boldsymbol{\phi}) = \begin{cases} \prod_{t=1}^T G(\phi_t)/\bigl(1-\sum_{v=1}^\infty \varpi_{v}^T\bigr) &\qquad\text{if $\phi_{t}\neq \phi_{t'}$ for some $t\neq t'$,}\\ 0 &\qquad\text{otherwise.} \end{cases}\label{density W2} \end{align} where $G(\phi)$ denotes the mass function of distribution $G$, defined in equation~(\ref{density G}) and evaluated at $\phi\in \mathcal{R}$. Then, as required, the menu distribution $W_2$ is discrete and has the countable support, \[ \mathcal{S}_2 = \{(\zeta_{v_1},\ldots,\zeta_{v_T})':\text{$\zeta_{v_t}\neq \zeta_{v_{t'}}$ for some integers $v_t\neq v_{t'}$, where $(v_1,\ldots,v_T) \in \mathcal{N}^T$}\}. \] We observe that the differential and non-differential states communicate through the shared distribution $G$. When the number of treatments, $T$, is~large, the discreteness of distribution $G$ causes dimension reduction in the $T$-variate differential state atoms by allowing ties between the atom elements, and resulting in a relatively small number of unique elements within each $T$-variate atom. When $T$ is~large, this model feature facilities computational savings for the inferential procedure. \subsubsection{Selections made by sequentially arriving 2R2CF customers} For $j \ge 1$, let the restaurant chosen by customer $j$ be denoted by $g_j$ and the cuisine (i.e.,~section) chosen by customer $j$ be denoted by $s_j$. \paragraph{Customer 1.} Suppose the first franchise customer, arriving at time $0$, selects restaurant $g_1=1$ with probability $\rho_1>0$ and selects restaurant $g_1=2$ with positive probability $\rho_2=1-\rho_1$. For reasons that will become clear, we refer to $\rho_1$ as the \textit{baseline non-differential proportion} and $\rho_2$ as the \textit{baseline differential proportion}. Typically, the differential state is less frequent than the non-differential state, and so $\rho_2<\rho_1$ (i.e.,~$\rho_2<1/2$). \textbf{\textit{Choice of cuisine $s_1$}} \quad Next, customer 1 selects one of the two cuisine-sections in restaurant $g_1$. Recall that each restaurant specializes in the cuisine with the same label, and the specialty cuisine is more popular there. In differential analysis, this is guaranteed by the following assumption. Within restaurant $g_j$ (where $j=1$ for the first customer), assume customer $j$ selects cuisine 1 with probability \begin{align} \mathcal{Q}_{g_j}(1) = \begin{cases} \rho_1 + \rho_2 \gamma &\qquad \text{if $g_j=1$,}\\ \rho_1 - \rho_1 \gamma &\qquad \text{if $g_j=2$,}\\ \end{cases} \label{PDP_state_prob1} \end{align} for a \textit{speciality-cuisine popularity parameter}, $\gamma \in (0,1]$, determining the degree to which a restaurant's patrons tend to favor its namesake cuisine. Expression (\ref{PDP_state_prob1}) implies that the customer chooses cuisine 2 in restaurant~$g_j$ with probability $\mathcal{Q}_{g_j}(2)=1-\mathcal{Q}_{g_j}(1)$. \textbf{\textit{Choice of table $v_1$ and dish $\boldsymbol{\theta}_{1}$}} \quad Since the identifiers of the infinite tables belonging to section $s_1$ of restaurant $g_1$ are arbitrary, we assume without loss of generality that customer 1 sits at table $v_1=1$, and the tables in the restaurant section are assigned consecutive labels as they are occupied by sequentially arriving patrons. Next, customer~$1$ randomly orders a dish according to menu distribution $W_{s_1}$, and the dish represents the random effect of the first probe. In other words, $\boldsymbol{\theta}_{1}\mid s_1 \sim W_{s_1}$ \begin{figure} \centering \vspace{-.5 in} \includegraphics[width=0.84\textwidth]{figures/MRF1.pdf} \vspace{-1 in} \includegraphics[width=0.84\textwidth]{figures/MRF2.pdf} \vspace{-1 in} \includegraphics[width=0.84\textwidth]{figures/MRF3.pdf} \vspace{-.5 in} \caption{\small Cartoon representation of the two-restaurant two-cuisine franchise for differential analysis, showing the progressive choice of restaurant, cuisine section, and table by customer $j$, where $j>1$. The numbered circles represent the table numbers. See the text in Section \ref{Sticky_PDPs_DA} for a detailed description. } \label{2R2CF plots} \end{figure} \paragraph{Customer $j$, where $j>1$.} Unlike customer~1, the \textit{restaurant} choices of the subsequent customers are influenced by the \textit{cuisine} choice of their immediately preceding customer and also by the waiting time separating the two customers. When $j>1$, suppose customer $j$ arrives at the franchise after a time interval of $e_{j-1}$ after the $(j-1)$th customer. For a non-negative \textbf{\textit{dependence parameter}} $\eta$, time $e_{j-1}$ is first transformed to an \textbf{\textit{affinity}} measure between customer $(j-1)$ and customer $j$: \begin{align} r_j=\exp(-e_{j-1}/\eta), \qquad j>1, \label{def_dep_par} \end{align} belonging to the interval $[0,1]$ for $\eta>0$. If $\eta=0$, affinity $r_j$ is defined as $0$ irrespective of the waiting~time. As we will see, given the choices of the preceding customer, the affinity influences the behavior of customer $j$ through (\ref{PDP_grp_prob1}) defined below. Additionally, we assume without loss of generality that the waiting times $e_1,\ldots,e_{p-1}$ are scaled so that their total equals~1. Since the probes in differential analysis represent CpG sites on a chromosome, it has a unit scaled length if the first probe is located at the chromosomal~edge. \textbf{\textit{Choice of restaurant $g_j$}} \quad As previously mentioned, the cuisine $s_{j-1}$ chosen by the $(j-1)$th customer influences the restaurant choice of the $j$th customer. Specifically, the selected restaurant \[g_j \mid s_{j-1}\sim \mathcal{F}_j, \] where, using the speciality-cuisine popularity parameter $\gamma$ defined in (\ref{PDP_state_prob1}), the probability that customer $j$ selects restaurant 1 is \begin{align} \mathcal{F}_j(1) \stackrel{def}= P(g_j = 1 \mid s_{j-1}) = \begin{cases} \rho_1 + \rho_2 r_j /\gamma &\qquad\text{if $s_{j-1}=1$,}\\ \rho_1 - \rho_1 r_j /\gamma &\qquad\text{if $s_{j-1}=2$,}\\ \end{cases} \label{PDP_grp_prob1} \end{align} so that $\mathcal{F}_j(2)=1-\mathcal{F}_j(1)$. The idea is illustrated in the top panel of Figure \ref{2R2CF plots}, where customer $j$ chooses restaurant 1 with probability $\mathcal{F}_j(1)$ and restaurant 2 with probability $\mathcal{F}_j(2)$. As seen from definition (\ref{PDP_grp_prob1}), if $\eta>0$, these probabilities depend on the cuisine section $s_{j-1}$ of the previous customer and on the waiting time, $e_{j-1}$. If $\eta=0$, on the other hand, the restaurant choices of the customers are independent of one another, and $\mathcal{F}_j(g) =\rho_g$, $g=1,2$. It is easily verified that $\mathcal{F}_j$ is a probability mass function if and only if $r_j/\gamma<1$. Since the scaled waiting times are bounded above by 1, a globally sufficient condition is $\eta < -1/\log \gamma$. We therefore assume a mixture prior for dependence parameter $\eta$: \begin{align} \eta \mid \gamma \sim \frac{1}{2}\delta_{0} + \frac{1}{2} \mathcal{H}\cdot \mathcal{I}(\eta<-1/\log \gamma), \label{etaPrior} \end{align} where the second mixture component involves a continuous distribution, $\mathcal{H}$, restricted to the interval $[0,-1/\log \gamma)$, thereby enforcing the sufficient condition. Speciality-cuisine popularity parameter $\gamma$ is assigned an independent uniform prior on the unit interval. In our experience, posterior inferences on $\eta$ are relatively robust to the continuous prior $\mathcal{H}$ provided it is not highly concentrated on a small part of interval $[0,-1/\log \gamma)$. When $\eta=0$, we have a \textit{zero-order Sticky PDP}. On the other hand, when $\eta>0$, we obtain a \textit{first order Sticky PDP}. Some interesting consequences of specification~(\ref{PDP_grp_prob1}) are: \begin{enumerate} \item \textbf{Zero-order Sticky PDP}: When $\eta=0$, each customer independently chooses restaurant 1 (or 2) with probability equal to the baseline proportion of $\rho_1$ (or $\rho_2$), and the $p$ customers also act identically. \item \textbf{First order Sticky PDP with $e_{j-1}/\eta$ large}: \quad Customer $j$ acts approximately independently of the history. Specifically, somewhat similarly to customer 1, customer $j$ chooses restaurant 1 (2) with probability approximately, but not exactly equal to the baseline proportion of $\rho_1$ ($\rho_2$). In other words, at large distances, consecutive customers do not appreciably influence each other's choices. \item \textbf{First order Sticky PDP with $e_{j-1}/\eta$ small}: \quad In the limit as $e_{j-1}/\eta \to 0$ (e.g., for an infinitesimal inter-probe distance $e_{j-1}$), the restaurant choice of customer~$j$ follows a hidden Markov model. \end{enumerate} Since it drives the dependence characteristics of DNA methylation data, posterior inferences on dependence parameter $\eta$ are of interest. Prior specification~(\ref{etaPrior}) allows the data to direct the model's order through posterior probability, $P[\eta = 0 \mid \boldsymbol{X}]$. An MCMC probability estimate is readily available. \textbf{\textit{Choice of cuisine $s_j$}} \quad Within restaurant $g_j$, customer $j$ selects cuisine-section $s_j$ with distribution $\mathcal{Q}_{g_j}$, defined earlier in expression (\ref{PDP_state_prob1}). For a graphical depiction, see the middle panel of Figure \ref{2R2CF plots}, where $g_j=1$. That is, customer~$j$, having already chosen restaurant $1$, must now choose a cuisine section. Restaurant 2 has been greyed out because it is no longer accessible to this customer. In the lower panel of Figure \ref{2R2CF plots}, we find that the customer has picked cuisine-section 1, i.e.,~$s_j=1$, and so, the other restaurant sections are greyed out. \textbf{\textit{Choice of table $v_j$}} \quad Of the previous $(j-1)$ customers, consider the $p_{j-1}$ customers who also chose cuisine-section $s_j$ in restaurant $g_j$. Then $p_{j-1}=$ $\sum_{l=1}^{j-1}\mathcal{I}(g_l=g_j, s_l=s_j)$. Let the number of tables occupied by these customers in section $s_j$ of restaurant $g_j$ be $M_{j-1} \ge 0$. Recall that all customers seated at a table are served the same dish, chosen from the cuisine menu (in this case, cuisine $s_j$) by the first customer seated at that table. If $M_{j-1} > 0$, that is, if customer $j$ is not the first patron of the restaurant section, let $\boldsymbol{\phi}_{g_j s_j k}$ denote the dish from cuisine $s_j$ served to the $p_{j-1, k}$ previous customers already seated at table $k$, where $k=1,\ldots,M_{j-1}$. Clearly, $p_{j-1, k}=\sum_{l=1}^{j-1}\mathcal{I}(g_l=g_j, s_l=s_j,v_l=k)$. Of course, $p_{j-1}=\sum_{k=1}^{M_{j-1}}p_{j-1, k}$. i.e., the number of people who selected section $s_j$ in restaurant $g_j$ before customer $j$, equals the number of people seated at all currently occupied tables in the restaurant~section. Recall that a new customer may sit at an already occupied table or a new table. Two of these possibilities are illustrated in the lower panel of Figure \ref{2R2CF plots}. For a PDP with mass parameter $\alpha_{s_j}$ and discount parameter $d_{s_j} \in [0,1)$, the predictive distribution of table $v_j$ selected by customer $j$ is specified as \begin{align} P\biggl(v_j = k \mid p_{j-1, 1}, \ldots, p_{j-1, M_{j-1}} \biggr) \propto \begin{cases} p_{j-1, k} - d_{s_j} \quad &\text{if $k = 1,\ldots,M_{j-1}$,}\\ \alpha_{s_j} + M_{j-1} d_{s_j} \quad &\text{if $k = (M_{j-1} + 1)$,}\\ \end{cases}\label{pred.table_j} \end{align} where the second line corresponds to customer $j$ sitting at a new table, in which case the updated number of occupied tables becomes $M_{j}=M_{j-1}+1$. Otherwise, if customer $j$ sits at a previously occupied table, then $M_{j}=M_{j-1}$. Obviously, $p_{j}=p_{j-1}+1$. Distribution (\ref{pred.table_j}) implies that customer $j$ is more likely to choose already occupied tables with many occupants, positively reinforcing the selected table's popularity for future customers. The number of occupied tables stochastically increases with the PDP mass and discount parameters. When PDP discount parameter $d_{s_j} = 0$, we obtain the well-known P\`{o}lya urn scheme for Dirichlet processes \citep{Ferguson_1973} for section $s_j$. PDPs act as effective dimension reduction devices because the random number of occupied tables is much smaller than the number of customers. Specifically, as the number of patrons in the restaurant section grows, i.e.,~as $p_j\to \infty$, the number of occupied tables, $M_{j}$, is asymptotically equivalent to \begin{align} \begin{cases} \alpha_{s_j} \log p_j \qquad &\text{if $d_{s_j} = 0$} \\ T_{d_{s_j}, \alpha_{s_j}} \, p_j^{d_{s_j}}\qquad &\text{if $0 < d_{s_j} < 1$}\\ \end{cases}\label{q} \end{align} for a positive random variable $T_{d_{s_j}, \alpha_{s_j}}$ \citep{Lijoi_Prunster_2010}. \textbf{\textit{Choice of dish $\boldsymbol{\theta}_j$}} \quad If customer $j$ sits at a previously occupied table, he or she is served the dish selected by the first customer to occupy that table. Otherwise, if a new table is chosen, customer $j$ picks a dish from menu distribution $W_{s_j}$. The dish that customer $j$ eats represents probe-specific random effect~$\boldsymbol{\theta}_j$ and has the distribution: \begin{equation} \boldsymbol{\theta}_j \begin{cases} = \boldsymbol{\phi}_{g_j s_j v_j} \qquad &\text{if $v_j = 1,\ldots,M_{j-1}$,} \\ \sim W_{s_j}\qquad &\text{if $v_j = (M_{j-1}+1)$.}\\ \end{cases}\label{dish} \end{equation} If customer $j$ sits at an already occupied table, then $M_{j}=M_{j-1}$, and $\boldsymbol{\theta}_j=\boldsymbol{\phi}_{g_j s_j v_j}$ as indicated above. On the other hand, if customer $j$ selects a new table, i.e.,~if $v_j = (M_{j-1}+1)$, the number of occupied tables becomes $M_{j}=M_{j-1}+1$, and the newly selected dish, $\boldsymbol{\theta}_j=\boldsymbol{\phi}_{g_j s_j M_{j}}\sim W_{s_j}$ is served to all future customers who sit at table~$M_{j}$. A consequence of specifications (\ref{pred.table_j}) and (\ref{dish}) is that although each restaurant offers both cuisines and potentially serves every dish, the relative popularity of each dish is restaurant-specific. The aforementioned process continues for the subsequent franchise customers. As seen in expression (\ref{PDP_grp_prob1}), the cuisine selected by the previous customer influences the restaurant choice of a customer. Additionally, expression (\ref{PDP_state_prob1}) guarantees that a cuisine is more popular at its namesake restaurant. This makes a customer more likely to select the same cuisine as the previous customer, and facilitates lengthy runs of differential or non-differential states of the probes. In addition to achieving dimension reduction, the proposed Sticky PDP models serial dependencies in the two-state differential status of adjacent probes as a decreasing function of the inter-probe distances. \subsubsection{Latent clusters and their differential states}\label{S:latent clusters} The notion of latent clusters, introduced earlier in expression (\ref{allocation c}) and forming the basis of the dimenson reduction strategy, comprises all probes with identical random effects. Returning to the 2R2CF metaphor, we find that a cluster is therefore the set of customers eating the same dish. Recall that although customers seated at a table are served the same dish, multiple tables at the two restaurants may serve the same dish because of the shared cuisine menu. Aggregating customers eating the same dishes, irrespective of the restaurant, we obtain the probe-cluster allocation variables $c_1,\ldots,c_p$, and therefore, the random number of latent clusters, $q$. Additionally, the cuisines determine the common differential states; specifically, the set of distinct cuisine~2 dishes symbolizes the differential clusters, $\mathcal{D}$, defined in equation~(\ref{D}). From expression (\ref{q}), we expect the number of occupied tables to be much smaller than the number of franchise customers,~$p$. Further, since multiple tables at both restaurants can serve the same dish, the number of latent clusters, $q$, is smaller than the number of occupied tables. With high probability, this implies that $q$ is much smaller than $p$. \paragraph{PDP discount parameter $d_2$.} Consider the differential state cuisine menu, $W_2$, of definition~(\ref{density W2}). It can be shown that when the number of treatments $T \to \infty$, the individual elements of each $T$-variate atom of $W_2$ are asymptotically i.i.d.\ $G$, and the differential clusters are not only a posteriori asymptotically identifiable but also consistently detected; refer to Section 4 of \cite{Guha_Baladandayuthapani_2016} for a detailed discussion of this remarkable phenomenon in standard PDP settings. Since the differential clusters ae often accurately inferred when $T$ and $p$ are large, discount parameter $d_2$ is given the mixture prior: \begin{align*} d_2\sim \frac{1}{2}\delta_{0} + \frac{1}{2} U(0,1) \end{align*} where $d_2=0$ corresponds to a Dirichlet process. This provides the posterior flexibility to choose between a Dirichlet process and a more general~PDP for a suitable clustering pattern of the differential probes. Allocation patterns characteristic of non-Dirichlet PDPs, such as power law decays in the cluster sizes and relatively large numbers of small-sized clusters, cause the posterior of parameter $d_2$ to exclude 0. Allocation patterns more typical of Dirichlet processes, such as exponentially decaying cluster sizes dominated by a few large clusters, result in high posterior probabilities being assigned to $0$. A proof of the intrinsically different clusters of Dirichlet processes and PDPs is given in Theorem~2.1 of \cite{Guha_Baladandayuthapani_2016}. Since distribution $G$ is discrete, all atoms of $T$-variate distribution $W_2$ may not be unique. Indeed, this is common for $T=2$ treatments. However, as $T$ grows, and provided the number of probes, $p$, grows at a slower-than-exponential rate as $T$, the probability that any two allocated atoms are identical rapidly decays to 0. In regression problems unrelated to differential analysis, a similar result was derived for a relatively simple zero-order stochastic process in Section 2.3 of \cite{Guha_Baladandayuthapani_2016}. We have verified this phenomenon in our simulation studies on differential analysis datasets. In several hundred artificial datasets generated from the Sticky PDP, for $p=1,500$ probes and $T$ as small as four, no two allocated atoms of $W_2$ were identical. \paragraph{PDP discount parameter $d_1$.} Consider cuisine menu $W_1$ is defined in (\ref{W1}). The flexibility provided by PDP allocation patterns is not necessary for non-differential probes. This is because the allocation patterns of distribution $W_1$ are driven by univariate parameter $\psi$ in (\ref{W1}). In general, the allocations of univariate objects are unidentifiable \citep[e.g.,][]{Fruhwirth-Schnatter_2006}. Consequently, we set PDP discount parameter $d_1=0$, reducing the two PDPs associated with the non-differential state (i.e.,~section 1 in the two restaurants) to Dirichlet processes. \subsubsection{Other model parameters}\label{S:hyperpriors} Since the essential data features are mostly absorbed by the Sticky PDP model for the random effects $\boldsymbol{\theta}_{j}$, we can specify simpler parametric models for the remaining terms in relation (\ref{def_main_model}). For the subject-specific random effects $\xi_1,\ldots,\xi_n$, we assume i.i.d.\ $N(0,\tau_{\epsilon}^{2})$ priors. Similarly, appropriate models for the probe-specific parameters $\chi_1,\ldots,\chi_p$ include i.i.d.~zero-mean normal distributions, and finite mixture models or HMMs with a finite number of latent states and state-specific normal distributions. An inverse-gamma prior is assigned to parameters $\sigma^2$ in (\ref{def_main_model}). Appropriate priors are assumed for mass parameters $\beta$, $\alpha_1$, and $\alpha_2$ in expressions (\ref{W1}) and (\ref{pred.table_j}). Mean $\mu_G$ and variance $\tau_G^{2}$ of base distribution $G_0$ in expression (\ref{W1}) are given a joint normal-inverse gamma~prior. Baseline non-differential proportion $\rho_1$ is given a uniform prior. \section{Posterior Inference} \label{S:post_inf} Due to the analytical intractability of the BayesDiff model, we rely on MCMC methods for posterior inferences and detection of differential probes. \subsection{MCMC Strategy} \label{MCMC_summary} The model parameters are initialized using na\"{i}ve estimation techniques and iteratively updated by MCMC techniques until the chain converges. We split the MCMC updates into three blocks. An outline of the MCMC procedure is as follows. Further details can be found in Section \ref{MCMC_summary_supp} of Supplementary Material. \begin{enumerate} \item \textbf{Restaurant-cuisine-table-dish choice $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ of customer $j$:} \quad For each probe $j=1,\ldots,p,$ we sample the 4-tuple $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ given the 4-tuples of the other $(p-1)$ probes. This is achieved by proposing a new value of $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ from a carefully constructed approximation to its full conditional, and by accepting or rejecting the proposed parameters in a Metropolis-Hastings step. The procedure is repeated for all $p$ probes. As discussed in Section \ref{S:latent clusters}, the probe-cluster allocations $c_1,\ldots,c_p$ are immediately available from the restaurant-cuisine-table allocations $(g_j,s_j,v_j)$ of the $p$ probes. Also available are the $q$ latent clusters along with their allocated probes, and the set of differential clusters $\mathcal{D}$. \item \textbf{Latent vectors} $\boldsymbol{\lambda}_1,\dots, \boldsymbol{\lambda}_q$: \quad There are $T q$ latent vector elements, not all of which are necessarily distinct because of the Dirichlet process prior on distribution~$G$. Although the latent vector elements are known from the Block 1 updates, MCMC mixing is considerably improved by updating the latent vector elements conditional on the $p$ probe-cluster allocations. As the calculation in Supplementary Material shows, this is possible by Gibbs~sampling. \item \textbf{Remaining model parameters}: Generated by standard MCMC techniques. \end{enumerate} \paragraph{Scalability} Due to the intensive nature of the one-parameter-at-a-time Gibbs sampling updates in Block 2, the Metropolis-Hastings algorithm of \cite{guha2010posterior} can be applied to significantly speed up the updates. Relatively to standard Gibbs samplers, ten- to hundred-fold speedups are possible by this fast MCMC strategy. A similar strategy can be applied to obtain order of magnitude speedups for the Block 1 parameters. \subsection{Detection of Differential Probes with FDR Control} \label{FDR_control} Post-processing the MCMC sample, a Bayesian approach for controlling the false discovery rate (FDR) \citep{newton2004detecting} is applied for more accurately detecting the differential probes, i.e.,~the probes $j$ with differential state, $s_j=2$. Specifically, let $q_0$ be the nominal FDR level and let $\omega_j$ be the posterior probability of probe $j$ being differential, so that $\omega_j=P[s_j=2\mid\boldsymbol{X}]$. An empirical average estimate, $\hat{\omega}_j$, is available from the MCMC sample. To achieve the desired FDR level in calling the differential probes, we first rank all the probes in decreasing order of $\hat{\omega}_j$. Let $\hat{\omega}_{(1)}>\hat{\omega}_{(2)}>\dots>\hat{\omega}_{(p)}$ denote the ordered posterior probability estimates. For each $b=1,\dots ,p$, we calculate as follows the posterior expected FDR resulting from calling the first $b$ probes in decreasing order of $\hat{\omega}_j$: \begin{align} \widehat{\text{FDR}}_b=\frac{\sum_{j=1}^{p}\left(1-\hat{\omega}_j\right)\mathcal{I}\left(\hat{\omega}_j\geq \hat{\omega}_{(b)}\right)}{\sum_{j=1}^{p}\mathcal{I}\left(\hat{\omega}_j\geq \hat{\omega}_{(b)}\right)}=\frac{\sum_{j=1}^{b}\left(1-\hat{\omega}_{(j)}\right)}{b}, \end{align} where the simplified expression follows from the fact that the $\hat{\omega}_j$'s are sorted. Finally, we pick the largest value of $b$, denoted by $b^{*}$, for which $\widehat{\text{FDR}}_b<q_0$. A nominal FDR~level of $q_0$ is achieved by labeling as differential the first $b^{*}$ probes arranged in decreasing order of $\hat{\omega}_j$. \section{Simulation Studies} \label{sim_study} Using artificial datasets with $T=5$ treatments, we analyzed the accuracy of BayesDiff in detecting the differentially methylated probes. We also compared the results with established differential methylation procedures and general statistical techniques for multigroup comparisons. Further, we evaluated the ability of the BayesDiff procedure in discovering the complex dependence structure of DNA methylation data. \paragraph{Generation strategy} Proportions representing DNA methylation data were generated using the logit transformation in equation (\ref{def_main_model}). The distances between the $p$ probes were actual sequences of $(p-1)$ inter-probe distances from the motivating TCGA dataset, scaled to add to $1$. In order to capture the complexity of methylation data, such as the existence of multiple latent methylation states (e.g,.~CpG islands and shores), different read depths across CpGs, and the incomplete conversion of bisulphite sequencing, the generation strategy was partly based on techniques implemented in WGBSSuite, a flexible stochastic simulation tool for generating single-base resolution methylation data \citep{Rackham_etal_2015}. However, the generation procedure differed from WGBSSuite in some respects. Specifically, it accommodated more than two treatments ($T>2$). Additionally, as expected in actual methylation datasets, the generation procedure incorporated serial dependence not only in the methylation states, but also in the differential states of the probes. The probes-specific read depths were generated as $n_j \stackrel{iid}\sim \text{Poisson}(50)$. Unlike BayesDiff assumption (\ref{def_main_model}), there were no subject-specific random effects in the generation mechanism. Instead, the normal mean of the generated data included additive probe-specific random effects, $\chi_1^{(0)},\ldots,\chi_p^{(0)}$, that were generated as follows: \begin{enumerate} \item Generate the true methylation status of the probes, denoted by $h_1^{(0)},\ldots,h_p^{(0)}$, using the 4-state \textit{distance-based} HMM of \cite{Rackham_etal_2015}, with the states respectively representing the methylated, first transit, demethylated, and second transit states. \item Set the baseline methylation levels for the methylated, (first or second) transit, and demethylated states as $p_{\text{methylated}}=0.8$, $p_{\text{transit}}=0.5$, and $p_{\text{un-methylated}}=0.2$, respectively. \item For $j=1,\ldots,p$, define the mean probe-specific random effect as follows: \begin{align*} \tilde{\chi}_j^{(0)} = \begin{cases} \log(\frac{p_{\text{methylated}}}{(1-p_{\text{methylated}}}) &\text{if $h_j=1$ (i.e.,~methylated state),}\\ \log(\frac{p_{\text{transit}}}{(1-p_{\text{transit}}}) &\text{if $h_j=2,4$ (first or second transit state),}\\ \log(\frac{p_{\text{demethylated}}}{(1-p_{\text{demethylated}}}) &\text{if $h_j=3$ (i.e.,~demethylated state).}\\ \end{cases} \end{align*} \item Independently generate true probe-specific random effects: $\chi_j^{(0)} \sim N\bigl(\tilde{\chi}_j^{(0)}, \tau_{\chi}^2\bigr)$ for probe $j=1,\ldots,p$. \end{enumerate} \paragraph{Noise and dependence levels} We investigated four scenarios corresponding to the combinations of two noise levels and two dependence levels. For each scenario, 20 datasets were independently generated, with each dataset consisting of $p=500$ probes and $T=5$ treatments with 4 samples each, i.e.,~a total to $n=20$ samples. The low noise level corresponded to true variance parameter $\sigma^{2}_0=0.36$; equivalently, to a signal-to-noise of $R_0^2\approx 70\%$. The high noise level corresponded to $\sigma^{2}_0=1$ or $R_0^2\approx 40\%$. The true between-probe dependencies comprised two levels: no serial correlation (i.e.,~a zero-order Sticky PDP) with $\eta_0=0$, and positive serial correlation (i.e.,~a first order Sticky PDP) with $\eta_0=0.004$. Although $\eta_0=0.004$ may appear to be small, its value is calibrated to the inter-probe distances; when the distance between two adjacent probes is equal to the standardized average distance of $\bar{e}=1/(p-1)=1/499$, $\eta_0=0.004$ gives an affiliation of $r_0=0.6$ in equation (\ref{def_dep_par}). Since the affiliations are bounded above by 1, $\eta_0=0.004$ represents fairly high inter-probe dependence. For convenience, we will refer to the two dependence levels as ``no-correlation'' and ``high correlation.'' The other model parameters were common for the four scenarios and are displayed in Table~\ref{parm_sim1}. Setting a true baseline differential proportion of $\rho_2=0.1$ resulted in approximately 10\% true differentially methylated CpGs in each dataset. \begin{table} \centering \begin{tabular}{*{9}{c}} $\alpha_1$ & $\alpha_2$ & $d_2$ & $\beta$ & $\gamma$ & $\rho_2$ & $\mu_G$ & $\tau^{2}_G$ & $\tau^{2}_{\chi}$ \\ \hline 20 & 20 & 0.33 & 20 & 0.9 & 0.1 & 0 & 1 & 0.1225 \end{tabular} \caption{True parameter values used to generate the artificial datasets.} \label{parm_sim1} \end{table} \paragraph{Posterior inferences} Assuming all model parameters to be unknown, each artificial dataset was analyzed using the BayesDiff procedure. The true generation mechanism differed in key respects from the BayesDiff model subsequently used to analyze the data. For example, unlike the 4-state HMM of the generation strategy, the probe-specific random effects $\chi_j$ were analyzed using a BayesDiff model that ignored the first order dependence, and instead, relied on a 3-state finite mixture model representing the methylated, transit, and unmethylated states. Additionally, in contrast to the zeroed-out subject-specific random effects during data generation, the BayesDiff procedure assumed that the random effects were i.i.d.~normal with zero mean. To assess the accuracy of BayesDiff in detecting the absence or presence of inter-probe serial correlation, in the no-correlation ($\eta_0=0$) situation, we evaluated $\log \left(\frac{P\left[\eta=0\mid \mathbf{X}\right]}{P\left[\eta>0\mid \mathbf{X}\right]}\right)$, the log-Bayes factor comparing zero order to first order Sticky PDPs. In the high correlation ($\eta_0=004$) situation, we evaluated $\log \left(\frac{P\left[\eta>0\mid \mathbf{X}\right]}{P\left[\eta=0\mid \mathbf{X}\right]}\right)$, the log-Bayes factor comparing first order to zero order Sticky PDPs. Thus, in any scenario, a large positive value of this log-Bayes factor constitutes strong evidence that BayesDiff detects the correct model order. Although conceptually straightforward, the estimation of Bayes factors requires multiple MCMC runs, even for relatively simple parametric models \citep{Chib_1995}. \cite{Basu_Chib_2003} extended the estimation strategy to infinite dimensional models such as Dirichlet processes. However, the computational costs are prohibitively high for big datasets, and multiple MCMC runs for estimating Bayes factors would stretch available computational resources far beyond their present-day limits. Faced with these challenges, we relied on an alternative strategy for estimating the \textit{lower bounds} of log-Bayes factors using a single MCMC run. As it turns out, this is often sufficient to infer the Sticky PDP model orders. Let $\Theta^{-}$ denote all BayesDiff model parameters except $\eta$. In the high correlation situation, applying Jensen's inequality, a lower bound for the corresponding log-Bayes factor is $E\left[\log \left(\frac{P\left[\eta>0\mid \mathbf{X},\Theta^{-}\right]}{P\left[\eta=0\mid \mathbf{X},\Theta^{-}\right]}\right)\mid\mathbf{X}\right]$. Unlike log-Bayes factors, this lower bound can be easily estimated by an empirical average estimate based on a single MCMC run. In the no-correlation situation, a lower bound for the log-Bayes factor, $\log \left(\frac{P\left[\eta=0\mid \mathbf{X}\right]}{P\left[\eta>0\mid \mathbf{X}\right]}\right)$, can be similarly~derived. \begin{figure} \centering \includegraphics[width=0.5\textwidth]{figures/logBF_boxplot} \caption{In the simulation study, box plots for the estimated lower bounds of log-Bayes factors in favor of the true model order.} \label{sim1_log-BF} \end{figure} For each of the four generation scenarios, box plots of these estimated lower bounds for the 20 datasets are depicted in Figure \ref{sim1_log-BF}. Except for the high noise--no-correlation scenario, for which the results were inconclusive, the estimated lower bounds of the log-Bayes factors in favor of the true correlation structure were all positive and large. In the low noise--no-correlation scenario, BayesDiff decisively favored zero-order models, and the smallest lower bound among the 20 datasets was $13.9$, corresponding to Bayes factors exceeding $e^{13.9}=1,088,161$. The $25^{th}$ percentile of these lower bounds was 30.9, corresponding to Bayes factors exceeding $e^{30.9}=2.63 \times 10^{13}$. This is strong evidence that the BayesDiff approach is reliable in this scenario. For the high-correlation scenarios, the estimated lower bounds were even higher, showing that BayesDiff overwhelmingly favors first order models when the data are actually serially~correlated. \paragraph{Comparisons with other methods} We evaluated the success of the BayesDiff procedure in detecting disease genomic signatures and made comparisons with six well-known procedures. These included some general statistical techniques for multigroup comparisons, namely, one-way analysis of variance (ANOVA) and the Kruskal-Wallis test. We also made comparisons with some methods specially developed for detecting differential methylation in more than two treatments: COHCAP \citep{warden2013cohcap}, methylKit \citep{akalin2012methylkit}, BiSeq \citep{hebestreit2013detection}, and RADMeth \citep{dolzhenko2014using}. The ANOVA and the Kruskal-Wallis test procedures were applied separately on each probe after applying the inverse-logit transform. Being specifically designed for differential methylation analysis, the COHCAP method was directly applied to the generated proportions of the synthetic data. The remaining three methylation-related methods are designed for bisulfite sequencing, which consists of the total methylation reads for each measured CpG site. For these methods, the methylation reads for each probe was obtained by multiplying the proportion methylation values by the total read. The bandwidth smoothing parameter of the method BiSeq was tuned to optimize the overall detection. For all six methods, the probe-specific p-values were obtained. As recommended by these techniques, the probes whose test p-values were less than the desired significance level were labeled as differential. \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma06_eta0004_20200329.pdf} \caption{Low noise, high correlation} \end{subfigure}% \quad \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma06_eta0_20200329.pdf} \caption{Low noise, no correlation} \end{subfigure} \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma1_eta0004_20200329.pdf} \caption{High noise, high correlation} \end{subfigure}% \quad \begin{subfigure}{0.45\textwidth} \centering \includegraphics[width=\textwidth]{figures/ROC_avg_sigma1_eta0_20200329.pdf} \caption{High noise, no correlation} \end{subfigure} \caption{ROC curves, averaged over 20 simulated datasets, for the seven methods and the four simulation scenarios. The numbers in parentheses represent the corresponding AUCs for each method.} \label{sim1_ROC_avg} \end{figure} We computed the receiver operating characteristic (ROC) curves for differential probe detection for all seven methods. For a quantitative assessment, we calculated the area under curve (AUC), declaring the method with the largest AUC as the most reliable in each scenario. The ROC curves, averaged over the 20 datasets under each simulation scenario, are shown with the AUCs in Figure \ref{sim1_ROC_avg}. In all except the high-noise--no-correlation scenario, BayesDiff uniformly outperformed the other methods, as indicated by the fact that the areas under the ROC curves were greater for BayesDiff. Even in the high-noise--no-correlation scenario, we find that BayesDiff performed better in the low FPR region. As expected, all seven methods had lower accuracies for the higher noise levels. The performance of BayesDiff was significantly better than the competing methods in the high correlation scenarios, suggesting that the incorporation of between-probe dependencies greatly improves its accuracy in situations typical of DNA methylation data. In addition, since researchers typically focus on small false positive rates (FPRs), that is, small significance levels, we also calculated the measures, $\textrm{AUC}_{20}$ and $\textrm{AUC}_{10}$. $\textrm{AUC}_{20}$ ($\textrm{AUC}_{10}$) is defined as the area under the ROC curve multiplied by $5$ ($10$) when the FPR does not exceed $0.2$ ($0.1$). The multiplicative factor ensures that the areas potentially vary between $0$ and $1$. The three versions of AUC are presented in Table~\ref{table_sim1} in Supplementary Material. As also seen in Figure \ref{sim1_ROC_avg}, Table~\ref{table_sim1} reveals that in three of the four scenarios, BayesDiff had the largest overall AUC. Furthermore, BayesDiff had vastly improved reliability for low FPRs. For example, consider the low noise--high correlation scenario. The overall AUC for BayesDiff was 0.031 greater than that for ANOVA. In contrast, the gains for BayesDiff, relative to ANOVA, were $+0.098$ for $\textrm{AUC}_{20}$ and $+0.136$ for $\textrm{AUC}_{10}$. The advantages of BayesDiff were even greater relative to the other competing methods. In the high noise--low-correlation scenario, BayesDiff had a relatively low AUC, as mentioned earlier. However, even in this scenario, it had the greatest $\textrm{AUC}_{20}$ and $\textrm{AUC}_{10}$ values among all the methods. Additionally, for a nominal FDR level of $q_0=0.05$, the achieved FDR of BayesDiff was between 0 and 0.03 in every dataset and simulation scenario. These results demonstrate the ability of BayesDiff to accurately detect the differential probes even in challenging situations where the FPR is~small. \section{Data Analysis} \label{data_analysis} We returned to the motivating DNA methylation dataset consisting of the upper GI cancers: stomach adenocarcinoma (STAD), liver hepatocellular carcinoma (LIHC), esophageal carcinoma (ESCA) and pancreatic adenocarcinoma (PAAD). Applying the BayesDiff procedure, we detected the differentially methylated CpG loci among the cancer types. \paragraph*{Data processing} The dataset was obtained from The Cancer Genome Atlas project, which is publicly available through The Genomic Data Commons (GDC) Data Portal \citep{grossman2016toward}. The data are available from the Illumina Human Methylation 450 platform for each of 485,577 probes at the CpG sites. At the time of analysis, the dataset consisted of $1,224$ tumor~samples. The analysis was performed on a gene-by-gene basis. We picked a set of 443 genes involving mutation in at least 5\% of the samples. To ensure that all CpG sites potentially related to a gene were included in the analysis, we selected all sites located within 50K base pairs outside the gene body, specifically, upstream from the 5' end and downstream from the 3' end. The number of gene-specific CpG sites ranged from 1 to 769, and are displayed in Figure \ref{appl_plots}(a) of Supplementary Material. As a final preprocessing step, since the methylation patterns of short genes are of lesser interest in cancer~investigations, we eliminated the 25 genes mapped to 20 or fewer CpG sites. \paragraph*{Inference procedure} The data were analyzed using the proposed BayesDiff approach. Exploratory analyses indicated that a satisfactory fit was obtained by eliminating the probes-specific random effects $\chi_j$ in (\ref{def_main_model}). The MCMC procedure of Section~\ref{MCMC_summary} was applied to obtain posterior samples for each gene. For detecting differentially methylated CpG sites, we applied the Bayesian FDR control procedure of Section \ref{FDR_control} with a nominal FDR of $q_0=0.05$. \paragraph*{Results} \begin{figure} \centering \begin{subfigure}{0.4\textwidth} \centering \includegraphics[width=1.1\textwidth]{figures/realdata_bar_in-out} \caption{Contingency table of detected methylation status and location of CpG site with respect to gene body} \end{subfigure}% \quad \begin{subfigure}{0.4\textwidth} \centering \includegraphics[width=1.1\textwidth]{figures/realdata_bar_5-3} \caption{Contingency table of detected methylation status and proximity of CpG site to chromosomal end} \end{subfigure} \caption{Associations of detected methylation status and position of CpG sites. } \label{appl_probeSummaries} \end{figure} Among the differentially methylated CpG sites detected by our approach, approximately 40.6\% of the sites were located outside the gene bodies. Figure \ref{appl_probeSummaries} displays the associations between detected methylation status and positions of the CpG sites. For our analysis, we have defined ``near the 5' (3') end'' as the CpG sites located within one-fourth length of the gene body, either inside or outside the gene boundary, and closer to the transcription start (termination) site. Our results indicate that the proportion of differential methylation is higher for CpG sites inside the gene body, and that most differentially methylated loci are situated within the gene body, as is well known from numerous previous studies. However, our analysis also revealed significant amounts of differential methylation outside the gene body. Despite the common belief that DNA methylation analysis should focus on the 5' end region, we found that CpG sites near the 3' ends also display considerable degrees of differential methylation. These findings support the recommendations of \cite{irizarry2009genome} that investigations of DNA methylation alteration should be conducted on a higher resolution, epigenome-wide basis. \begin{figure} \centering \includegraphics[width=0.4\textwidth]{figures/realdata_pie_maxdiff_probes} \caption{Site-wise summary of the largest pairwise differences of differentially methylated loci among the four upper GI cancer types.} \label{appl_maxdifSummaries} \end{figure} Among the differentially methylated sites detected by BayesDiff, we estimated the pairwise differences between the random effects associated with the four cancer types. Site-wise summaries of the largest pairwise differences of the cancer-specific effects are plotted in Figure \ref{appl_maxdifSummaries}. None of the four cancer types displayed consistent hypermethylation or hypomethylation across all the genes or entire chromosomes. However, we found that LIHC is frequently differentially methylated relative to one of the other cancer types, implying that it is the most volatile disease with respect to DNA~methylation. For each gene, Figure \ref{appl_plots}(b) of Supplementary Material displays 95\% credible intervals for lower bounds of log-Bayes factors of a first versus zero-order model, i.e., $\eta=0$ versus $\eta > 0$ in expression (\ref{def_dep_par}) for the inter-probe affiliations. Models with first order dependence are overwhelmingly favored for a majority of the genes, suggesting that statistical techniques that do not account for dependence between neighboring CpG sites would be less effective for these data. Figure \ref{DA_detail_2genes} of Supplementary Material displays the detailed differential methylation pattern for the top two mutated genes, TP53 and TTN. An obvious feature of both the genes is that the detected differential methylation of the CpG sites is highly serially correlated. For gene TP53, there are almost no differentially methylated loci within the gene body. The 3' end region outside the gene body has a cluster of differentially methylated loci, for which cancer type STAD is mostly hypermethylated. The results for gene TTN tell a quite different story: most of the differentially methylated loci are inside the gene body and near the 5' end. Cancer type LIHC is hypomethylated compared to PAAD around the 5' end region, but it is hypermethylated compared to STAD near the 3' end. Finally, genes with at least 90\% differentially methylated sites are listed in Table \ref{table_list_gene_prop} of Supplementary Material, along with the largest pairwise difference between the four cancer types among the differentially methylated loci. The number of CpG sites within each segment is listed in Table~\ref{table_list_num_probe} of Supplementary Material. Existing medical literature both supports and complements our findings. For example, hypermethylation of the EDNRB and SLIT2 genes have been found in STAD \citep{tao2012quantitative}. Gene FBN2 was hypermethylated in ESCA \citep{tsunoda2009methylation}. While several studies have found that the gene and protein expressions of ABC transporter genes, such as ABCC9, are useful for understanding the prognosis of esophageal cancer \citep{vrana2018abc}, we conclude that hypermethylation of ABCC9 is a major difference between cancer types ESCA and LIHC. Gene FLRT2 is a potential tumor suppressor that is hypermethylated and downregulated in breast cancer \citep{bae2017epigenetically}. Our results indicate that this gene is also hypermethylated in cancer type STAD versus LIHC. Mutations in SPTA1 gene has been linked with PAAD \citep{murphy2013genetic}. Our results indicate that hypermethylation of this gene distinguishes PAAD from LIHC. \paragraph*{Accounting for data characteristics} In genomic studies, a statistical model should be able to account for the probe-specific means and variances. This is especially important in multiple-testing based approaches where the first two sample moments must be plausibly explained by the fitted model to avoid making misleading biological interpretations \citep{Subramaniam_Hsiao_2012}. From this perspective, certain aspects of the BayesDiff model, such as variance~$\sigma^2$ a priori unrelated to the mean in expression~(\ref{def_main_model}), may appear to be restrictive. However, even though the BayesDiff model was not specifically constructed to match data summaries such as sample moments, in practice, the nonparametric nature of the Sticky PDP allows the posterior to flexibly adapt to the features of the data, including sample moments, thereby accounting for mean-variance relationships in a robust manner. For example, consider again the top mutated genes, TP53 and TTN, discussed in Figure \ref{DA_detail_2genes} of Supplementary Material. The ability of the BayesDiff model to match the sample moments of the gene-specific probes is demonstrated as follows. Given the inter-probe distances, the joint posterior of the BayesDiff parameters induces predictive distributions on the $n$ measurements for each probe. Functionals of these predictive distributions, such as the probe-specific sample moments, are easily estimated by post-processing the MCMC sample. For these two genes, Figure \ref{mean-mean_var-var} of Supplementary Material shows that the sample moments predicted by BayesDiff closely match the actual first and second sample moments, with correlations exceeding 99\% in each plot. Similar results were observed in other datasets. \section{Discussion} \label{disc} DNA methylation data exhibit complex structures due to unknown biological mechanisms and distance-dependent serial correlations among neighboring CpG sites or probes. The identification of differential signatures among different groups of samples is crucial for developing targeted treatments for disease. This paper formulates a flexible approach applicable to multiple treatments called BayesDiff. The technique relies on a novel Bayesian mixture model called the Sticky PDP or the two-restaurant two-cuisine franchise. In addition to allowing simultaneous inferences on the probes, the model accommodates distance-based serial dependence and accounts for the complex interaction patterns commonly observed in cancer data. A computationally efficient MCMC strategy for detecting the differential probes is developed. The success of the BayesDiff procedure in differential DNA methylation, relative to well-established methodologies, is exhibited via simulation studies. The new technique is applied to the motivating TCGA dataset to detect the differential genomic signatures of four upper GI~cancers. The results both support and complement various known facts about the epigenomic differences between these cancer types, while revealing a set of genes exhibiting high proportions of differentially methylated CpG sites. These results emphasize the need for further investigation to better understand the molecular characterizations of different upper GI cancers. The general methodology is applicable to differential analysis in genomic, epigenomic, transcriptomic, and proteomic datasets. In addition to providing a good fit for the data, a statistical model must be able to account for features of the dataset such as sample moments. The success of the BayesDiff model in this regard is demonstrated in Section \ref{data_analysis} for the upper GI dataset. It must be emphasized, however, that there may be other datasets where BayesDiff is less successful in accounting for the data characteristics. This could be due to many reasons, e.g.~as the number of probes grows, there is slow asymptotic convergence of the posterior to the true generative process, and so, $p$ is insufficiently large to provide a good match for the data. In such situations, more flexible global transformations \citep{Li_etal_2016} or variance-stabilizing transformations \citep{Durbin_etal_2002} could be used. Alternatively, we could replace the global transformations of the measurements, $z_{ij}=z(x_{ij})$, by local Laplace approximations of exponential family likelihoods through link functions, e.g.~binomial likelihoods with logit link for proportions \citep{Zeger_Karim_1991, Chib_Winkelmann_2001}. In this manner, we could extend the BayesDiff procedure to further improve the model fit and better explain the unique data characteristics. Going beyond biomedical applications, the generalized form of the Sticky PDP is presented in Section \ref{general2R2CF} of Supplementary Material. In addition to extending PDPs to discrete time series type data, the generalized formulation offers a diverse palette of parametric and nonparametric models for capturing the distinctive features of data in various applications. The range of models includes Dirichlet processes, PDPs, infinite HMMs, hierarchical Dirichlet process (HDP) \citep{Muller_etal_2004,Teh_etal_2006}, finite HMMs, nested Chinese restaurant processes \citep{Blei_Jordan_2005}, nested Dirichlet processes \citep{Rodriguez_etal_2008}, and analysis of densities models \citep{Tomlinson_Escobar_2003}. Ongoing work involves extending the correlation structure to model more sophisticated forms of inter-probe dependence in DNA methylation data. We are currently developing an R package implementing BayesDiff in a parallel computing framework using graphical processing units. The software will be made available for detecting differential genomic signatures in a wide variety of omics datasets. Initial results indicate that dramatic speedups of several orders of magnitude would allow the analysis of user-specified datasets on ordinary personal computers. \newpage \newpage \begin{supplement} \section{MCMC Strategy} \label{MCMC_summary_supp} As mentioned in Section \ref{MCMC_summary} of the paper, we split the MCMC updates into three blocks. The MCMC procedure for updating Blocks 1 and 2 is described below. Unless otherwise stated, all references to equations, tables, and figures are for the main paper. \begin{enumerate} \item \textbf{Restaurant-cuisine-table-dish choice $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ of customer $j$:} \quad For each probe $j=1,\ldots,p,$ we sample the 4-tuple $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ given the 4-tuples of the other $(p-1)$ probes. This is achieved by proposing a new value of $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ from a carefully constructed approximation to its full conditional, and by accepting or rejecting the proposed 4-tuple of probe-specific parameters in a Metropolis-Hastings step. The procedure is repeated for all $p$ probes to complete the block of MCMC updates. We give here an intuitive description of the details. Further calculation details are available in Section \ref{MCMC_sec} of Supplementary Material. For the $j$th probe, $1<j<p$, the choice of restaurant $g_j$ depends on the triplets of the two immediately adjacent probes. Specifically, as discussed in Section~\ref{Sticky_PDPs_DA} and graphically shown in the upper and middle panel of Figure \ref{2R2CF plots}, the restaurant selected by a customer depends on the cuisine of the previous customer. Then, within restaurant $g_j$, the customer chooses cuisine $s_j$ with a restaurant-specific probability. Finally, the customer may either sit an existing table, in which case they must eat the same dish as everyone already sitting at that table, or the customer may open a new table and order a dish from cuisine menu $s_j$. The generation strategy for table and dish depends on the cuisine, as discussed below. \vspace{-5 mm} \paragraph{Cuisine $s_j=1$} Evaluating the posterior probability of table $v_j$ involves integrating the Gaussian likelihood of column vector $\mathbf{z}_j=(z_{1j},\ldots,z_{nj})'$ with respect to the cuisine~1 menu, i.e.,~$\boldsymbol{\theta}_j \sim W_{1}$. Recall that the cuisine 1 menu has the special structure (\ref{W1}), allowing its reduction to a univariate quantity distributed as $G$. This random distribution itself follows a Dirichlet process conditional prior with a base distribution that is a mixture of known atoms (given the 4-tuples of the other probes) and Gaussian distribution $G_0$. This conjugate hierarchical structure allows the calculation of table and dish choice for cuisine 1 in computationally closed~form. \vspace{-5 mm} \paragraph{Cuisine $s_j=2$} This situation is more complicated because the Gaussian likelihood must be integrated with respect to prior distribution $W_{2}$ of the cuisine~2 dishes. Unlike cuisine 1, this is not possible in computationally closed form because menu structure (\ref{density W2}) cannot be reduced to a univariate quantity. In other words, for cuisine 2 (i.e.,~the differential state), the Dirichlet process conditional prior for distribution $G$ is non-conjugate. We utilize an auxiliary variable approach. Given the current set and frequency of atoms of distribution $G$ in the other $(p-1)$ probes, we first compute a finite mixture approximation, $G^{*}$, to the Dirichlet process conditional prior for $G$, as in \cite{Ishwaran_Zarepour_2002}. Then, using prior (\ref{density W2}), it is possible to approximate the posterior probability of customer $j$ joining an existing table or sitting at a new table, irrespective of the dishes. This allows us to generate the table selection, $v_j$. Finally, we propose the dish, $\boldsymbol{\theta}_j=\boldsymbol{\phi}_{g_j s_j v_j}$. If table $v_j$ is one of the already existing tables, then the customer simply chooses the common, table-specific dish. Otherwise, we sequentially generate from the posterior the $T$ elements representing the new dish. This is done using the corresponding treatment-specific elements of vector $\mathbf{z}_j=(z_{1j},\ldots,z_{nj})'$ and finite mixture $G^{*}$, with the restriction that not all $T$ atoms of vector $\boldsymbol{\theta}_j$ are equal. The Metropolis-Hasting step compensates for any approximations and produces post--burn-in samples from the BayesDiff model posterior. \vspace{-5 mm} \paragraph{Latent clusters} As discussed in Section \ref{S:latent clusters}, the probe-cluster allocations $c_1,\ldots,c_p$ are immediately available from the restaurant-cuisine-table allocations $(g_j,s_j,v_j)$ of the $p$ probes. The $q$ latent clusters, along with their allocated probes, and the set of differential clusters $\mathcal{D}$, are also immediately available. \item \textbf{Latent vectors} $\boldsymbol{\lambda}_1,\dots, \boldsymbol{\lambda}_q$: \quad Since each latent vector is of length $T$, there are $T q$ latent vector elements, not all of which are necessarily distinct because of the Dirichlet process prior on distribution $G$. Although the latent vector elements are available from Block 1, mixing of the MCMC chain is considerably improved by an additional block of updates of the latent vector elements conditional on the $p$ probe-cluster allocations. As the following calculation shows, this can be done by Gibbs~sampling. Since a non-differential cluster's latent vector consists of a single value repeated $T$ times, the number of \textit{distinct} latent vector elements is no more than $\left(q_1+T q_2\right)$. Given the current probe-cluster allocations, suppose there are $m_k$ probes associated with latent cluster $k$, where $k=1,\dots, q$. Let $q_2=|\mathcal{D}|$ be the number of differential clusters, so that $q_1=q-q_2$ is the number of non-differential clusters. \vspace{-5 mm} \paragraph{Non-differential clusters} For these clusters, the latent vector $\boldsymbol{\lambda}_k$ takes the form, $\boldsymbol{\lambda}_k = \psi_k \boldsymbol{1}_T$ for some $\psi_k \in \mathcal{R}$. Given the other $(q-1)$ latent vectors, assumptions (\ref{W1}) and (\ref{density W2}) imply that parameter $\psi_k$ has a Dirichlet process conditional prior. The base distribution of the Dirichlet process is a mixture of a continuous distribution, $G_0=N(\mu_G, \tau_G^2)$, and the univariate atoms located at the ``known'' elements of the other $(q-1)$ latent vectors. The sufficient statistic for $\psi_k$ is \begin{align*} \bar{y}_{ k} &= \frac{1}{n m_k}\sum_{j=1}^{p}\sum_{i=1}^{n}\left({z_{ij}}-{\xi_i}-\chi_j\right)\mathcal{I}\left(c_j=k\right) \\&\sim N\left(\psi_k,\frac{\sigma^2}{n m_k}\right) \quad\text{for cluster } k \not\in \mathcal{D}. \end{align*} Since the Dirichlet process conditional prior is conjugate to this normal likelihood, parameter $\psi_k$ could be updated by Gibbs sampling \citep{escobar1994estimating,maceachern1994estimating,escobar1995bayesian}. \vspace{-5 mm} \paragraph{Differential clusters} For these clusters, some of the $T$ elements of latent vector $\boldsymbol{\lambda}_k = (\lambda_{1k},\ldots,\lambda_{Tk})'$ could be tied, but at least two elements must be unequal. Denote these restrictions on $\boldsymbol{\lambda}_k$ by $\mathcal{A}$. For a treatment~$t$, let the remaining $(T-1)$ elements of vector $\boldsymbol{\lambda}_k$ be denoted by $\boldsymbol{\lambda}_{-tk}$. Imagine updating element $\lambda_{tk}$ assuming that $\boldsymbol{\lambda}_{-tk}$ and the remaining $(q-1)$ latent vectors are known. Vector $\boldsymbol{\lambda}_{-tk}$ and restriction $\mathcal{A}$ imply a possibly restricted support, $\mathcal{A}_t$, for parameter $\lambda_{tk}$. Observe that the support is unrestricted, i.e.,~$\mathcal{A}_t=\mathcal{R}$, if at least two elements of $\boldsymbol{\lambda}_{-tk}$ differ. Similarly to non-differential clusters, it can be shown that element $\lambda_{tk}$ follows a Dirichlet process conditional prior restricted to the support $\mathcal{A}_t$, and that the base distribution is a mixture of a normal distribution and univariate atoms. The sufficient statistic for latent vector element $\lambda_{tk}$ is \begin{align*} \bar{y}_{t k}&=\frac{1}{n_t m_k} \sum_{j=1}^{p}\sum_{i:t_i=t}\left({z_{ij}}-{\xi_i}-\chi_j\right)\mathcal{I}\left(c_j=k\right) \\ &\sim N\left(\lambda_{t k},\frac{\sigma^2}{n_t m_k}\right) \quad\text{for treatment $t=1,\ldots,T$, and cluster $k \in \mathcal{D}$}, \end{align*} where $n_{t}$ is the number of individuals associated with treatment $t$. The conjugate structure implies that parameter $\lambda_{tk}$ could be generated from its full conditional by a rejection sampler on set $\mathcal{A}_t$ coupled with standard Gibbs proposals for conjugate Dirichlet processes. In practice, the acceptance rates of the rejection sampler are very high for $T$ as small as 3 or 4, and are nearly 100\% for larger $T$. This is because the posterior probability of support set $\mathcal{A}_t$ tends to 1 as $T$ grows. An intuitive explanation for this asymptotic property is provided in Section \ref{S:hyperpriors} following the prior specification of discount parameter~$d_2$. \end{enumerate} \section{Additional details about Block 1 MCMC updates} \label{MCMC_sec} In the first block of MCMC updates of Section \ref{MCMC_summary}, we sample the the set \[\mathcal{C} = \left\{(g_j,s_j,v_j,\boldsymbol{\theta}_j) : j = 1,\ldots, p\right\}. \] We iteratively sample the 4-tuple, $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$, for each probe $j$ via Metropolis-Hastings updates. Specifically, for the $j$th probe, we propose group (i.e.,~restaurant) $g_j$, state (i.e.,~cuisine) $s_j$, PDP cluster (i.e.,~table) label $v_j$, and random effect (i.e.,~dish) $\boldsymbol{\theta}_j$, with the proposal distribution approximately equal to the joint posterior of $(g_j,s_j,v_j,\boldsymbol{\theta}_j)$ conditional on the data and all other parameters being equal to the current values. As explained in the paper, since the base measure of the Sticky PDP is discrete and not conjugate to the likelihood, this makes the case of parameter $v_j$ being assigned a new cluster label complicated. To deal with this situation, an auxiliary variable approach is used. Conditional on the current parameter values of the Dirichlet process prior for the latent vector elements, we generate a finite-dimensional approximation, $G^{*}$, to the Dirichlet process \citep{Ishwaran_Zarepour_2002}. Since the distribution $G^{*}$ is discrete, it is characterized by a finite vector of probability masses, $\boldsymbol{\pi}$, and the corresponding values of probability mass points, $\mathbf{u}$. Then, conditional on the auxiliary variables from $G^{*}$, we obtain the quantities needed for the conditional posterior of $v_j$ being assigned a new cluster label in the Metropolis-Hastings algorithm. More formally, consider probe $j \in \{1,\dots ,p\}$. The proposal probabilities for $\left(g_j,s_j,v_j\right)$ are as follows: \begin{align} &\bullet \quad \text{For an existing PDP cluster indexed by } v\in \{1,\ldots,q_{gs}^{(-j)}\},\nonumber \\ &Q\left(g_j=g,s_j=s,v_j=v\right)=P\left(g_j=g,s_j=s,v_j=v\mid \mathbf{z}_j,\mathbf{c}^{(-j)},\boldsymbol{\phi}_{gsv},s_{j-1},\eta,\rho,\gamma,\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right) \nonumber \\ &\propto \left[\mathbf{z}_j\mid v,s,g,\boldsymbol{\phi}_{gsv},\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right]P\left(v_j=v\mid \mathbf{c}^{(-j)},s,g\right)P\left(s_j=s\mid g,\gamma,\rho\right)P\left(g_j=g\mid s_{j-1},\eta,\gamma,\rho\right) \nonumber \\ &\propto \prod_{i=1}^{n}\varphi\left({z_{ij}}\mid \phi_{t_igsv}+\xi_i+\chi_j,\sigma^{2}\right)\left(m^{(-j)}_{gsv}-d_{s}\right) \mathcal{Q}_g(s) \mathcal{F}_{j}(g). \label{proposal_existing} \end{align} \begin{align} &\bullet \quad\text{For a new PDP cluster indexed by } v^{*}= q_{gs}^{(-j)}+1, \nonumber \\ &Q\left(g_j=g,s_j=s,v_j=v^{*}\right)=P\left(g_j=g,s_j=s,v_j=v^{*}\mid \mathbf{z}_j,\mathbf{c}^{(-j)},\boldsymbol{\pi},\mathbf{u},s_{j-1},\eta,\rho,\gamma,\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right) \nonumber \\ &\propto \left[\mathbf{z}_j\mid v^{*},s,g,\boldsymbol{\pi},\mathbf{u},\boldsymbol{\xi},\boldsymbol{\chi},\sigma^{2}\right]P\left(v_j=v^{*}\mid \mathbf{c}^{(-j)},s,g\right)P\left(s_j=s\mid g,\gamma,\rho\right)P\left(g_j=g\mid s_{j-1},\eta,\gamma,\rho\right) \nonumber \\ &\propto \begin{cases} \!\begin{aligned & \sum_{l=1}^{L}\pi_l\left\{\prod_{i=1}^{n}\varphi\left(z_{ij}\mid u_l+\xi_i+\chi_j,\sigma^{2}\right)\right\}\left(\alpha_1+d_{1}q^{(-j)}_{g1}\right) \mathcal{Q}_g(1) \mathcal{F}_{j}(g), \quad \text{if $s=1$,} \\ \end{aligned} \\%[1ex] \!\begin{aligned \left\{\prod_{t=1}^{T}\sum_{l=1}^{L} \pi_l \prod_{i:t_i=t}\varphi\left({z_{ij}}\mid u_l+{\xi_i}+\chi_j,\sigma^{2}\right) -\sum_{l=1}^{L} \pi_{l}^{T} \prod_{i=1}^{n} \varphi\left({z_{ij}}\mid u_{l}+{\xi_i},\sigma^{2}\right)\right\} \\ \times \left(\alpha_2+d_{2}q^{(-j)}_{g2}\right) \mathcal{Q}_g(2) \mathcal{F}_{j}(g), \quad\text{if $s=2$.} \\ \end{aligned} \\%[1ex] \end{cases} \label{proposal_new} \end{align} In expressions (\ref{proposal_existing}) and (\ref{proposal_new}), when $j<p$, superscript $(-j)$ for a variable indicates that the calculation excludes the $j$th and $(j+1)$th cluster allocation variables. Specifically, $q^{(-j)}_{gs}$ denotes the number of PDP clusters for group $g$ and state $s$; $\mathbf{c}^{(-j)}$ denotes the vector of cluster allocations; $m^{(-j)}_{gsv}$ denotes the cluster membership count for cluster $v$ in the PDP with group $g$ and state $s$; $\mathcal{Q}_g(s)$ and $\mathcal{F}_{j}(g)$ are defined in the paper; $\varphi\left(\cdot\mid \mu,\sigma^{2}\right)$ is the pdf of normal distribution with mean $\mu$ and variance $\sigma^{2}$; $L$ is the number of distinct mass points in $G^{*}$; $u_l$ denotes the value of distinct mass points in $G^{*}$ and $\pi_l$ is the corresponding probability mass. Before calculating the proposal, latent vectors of emptied clusters are removed and cluster labels rearranged so that the largest label is~$q^{(-j)}_{gs}$. The case $v^{*}= (q_{gs}^{(-j)}+1)$ corresponds to the case of $v_j$ opening a new cluster. If $v_j=(q_{gs}^{(-j)}+1)$ has been proposed, then a new random effect of length $T$ is sampled from the posterior distribution based on the $n$-dimensional observation vector $\mathbf{z}_j$ and the prior $G^{*}$ characterized by the auxiliary variables, subject to the constraints imposed on the random effects of the differential state $s_j$. The Metropolis-Hastings acceptance ratio is computed to decide whether the proposed $g_j$, $s_j$ and $v_j$ values are accepted. For $j=p$, our proposal density is exactly the desired conditional posterior, so we always accept the move. For $j<p$, since our proposal density is part of the desired conditional posterior for $\left(g_j, s_j, v_j\right)$, this part cancels out in the acceptance ratio. Therefore, the acceptance ratio only relates to the transition from $\left(g_j, s_j, v_j\right)$ to $\left(g_{j+1}, s_{j+1}, v_{j+1}\right)$, which is \begin{align} r_j=\frac{p\left(g_{j+1},s_{j+1},\tilde{v}_{j+1},\mid g_j^{*},s_j^{*},v_j^{*},\boldsymbol{\phi}^{*}_{g_{j+1}s_{j+1}\tilde{v}_{j+1}},\mathbf{z}_{j+1},\mathbf{c}^{-},\eta,\boldsymbol{\xi},\boldsymbol{\chi},\sigma\right)}{p\left(g_{j+1},s_{j+1},v_{j+1} \mid g_j^{0},s_j^{0},v_j^{0},\boldsymbol{\phi}_{g_{j+1}s_{j+1}v_{j+1}},\mathbf{z}_{j+1},\mathbf{c}^{-},\eta,\boldsymbol{\xi},\boldsymbol{\chi},\sigma\right)} \label{MH_ratio} \end{align} where $g_j^{*}$, $s_j^{*}$ and $v_j^{*}$ represent the proposed values; $g_j^{0}$, $s_j^{0}$ and $v_j^{0}$ are the old values; $\tilde{v}_{j+1}$ denotes $v_{j+1}$ under the proposed variable values (due to possible PDP cluster label change or elimination). Specifically, $\tilde{v}_{j+1}=(q^{*}_{g_{j+1}s_{j+1}}+1)$ if it belongs to no existing cluster, where $q^{*}_{g_{j+1}s_{j+1}}$ is the number of clusters under the proposed variable values and $\boldsymbol{\phi}^{*}_{g_{j+1}s_{j+1}\tilde{v}_{j+1}}$ is the random effect under the proposed variable values. Both the nominator and the denominator in (\ref{MH_ratio}) can be calculated using (\ref{proposal_existing}) and (\ref{proposal_new}), and by transposing $j$ to $(j+1)$ \section{Generalized form of the Sticky PDP}\label{general2R2CF} Beyond biomedical applications, a Sticky PDP is defined by the following general properties: \begin{enumerate} \item[Property 1:] Let set $\mathcal{G}$ contain a countable number of generative \textit{groups}. Each group $g \in \mathcal{G}$ contains a countable number of group-specific regular PDPs. The PDPs are identified by a combination of the group label $g$ and an integer-valued \textit{state},~$s \in \mathcal{S} \subset \mathcal{N}$, the set of natural numbers. That is, the regular PDPs comprising a Sticky PDP have bivariate labels, $(g,s)\in \mathcal{G}\times \mathcal{S}$. \item[Property 2:] The regular PDPs may have equal or unequal discount parameters, mass parameters, and/or base distributions. For every $(g,s) \in \mathcal{G}\times \mathcal{S}$, let the corresponding PDP be $\mathcal{W}_{gs}(d_{s}, \alpha_{s}, W_{s})$. With $\mathcal{P}_{gs}$ denoting a random realization of the PDP's stick-breaking distribution, we have \begin{align} \mathcal{P}_{gs} &\stackrel{d}= \sum_{v=1}^\infty \pi_{gsv} 1_{\boldsymbol{\phi}_{gsv}} \quad\text{where the $T$-variate atoms}\notag\\ &\boldsymbol{\phi}_{gsv} \stackrel{iid}\sim W_{s}, \quad\text{for index $v \in \mathcal{N}$, and probabilities}\label{phi}\\ &\pi_{gs1} = V_{gs1}, \quad \pi_{gsh} = V_{gsh} \prod_{v=1}^{h-1}(1-V_{gsv}), \quad h > 1, \quad\text{with}\notag\\ &V_{gsh} \stackrel{indep}\sim \text{beta}(1-d_{s}, \alpha_{s}+hd_{s}). \notag \end{align} Notice that base distribution $W_s$ in $\mathcal{R}^T$ is determined by the state $s$ but not group $g$. On the other hand, the atoms and their associated probabilities in distribution $\mathcal{P}_{gs}$ may depend on both group and state. If set $\mathcal{S}$ contains multiple states, assume that the set of base distributions $\{W_{s}: s \in \mathcal{S}\}$ is such that two PDPs associated with unequal states will almost surely have non-intersecting sets of atoms. That is, whenever $s_1^* \neq s_2^*$, the intersection of the random sets of the atoms $\{\boldsymbol{\phi}_{g_1^*s_1^*v}\}_{v=1}^\infty$ and $\{\boldsymbol{\phi}_{g_2^*s_2^*v}\}_{v=1}^\infty$ of stick-breaking distributions $\mathcal{P}_{g_1^*s_1^*}$ and $\mathcal{P}_{g_2^*s_2^*}$ is almost surely empty. \smallskip \item[Property 3:] For probe $j=1,\ldots,p$, the label of the PDP generating random effect $\boldsymbol{\theta}_j$ is denoted by $(g_j,s_j) \in \mathcal{G}\times \mathcal{S}$, and $ \boldsymbol{\theta}_j \mid \mathcal{P}_{g_j s_j} \stackrel{indep}\sim \mathcal{P}_{g_j s_j}. $ Equivalently, random effect $\boldsymbol{\theta}_j$ equals atom $\boldsymbol{\phi}_{g_j s_j v_j}$ with probability~$\pi_{g_j s_j v_j}$ for index $v_j \in \mathcal{N}$. \smallskip \item[Property 4:]\label{SP1} Given group $g_j$ for the $j^{th}$ probe, the state of the PDP generating random effect $\boldsymbol{\theta}_{j}$ is randomly selected as follows: \begin{equation*} s_j \mid g_j \sim \mathcal{Q}_{g_j} \end{equation*} where for every $g \in \mathcal{G}$, $\mathcal{Q}_g$ denotes a group-specific probability mass function on the set $\mathcal{S}$; thus, $\sum_{s \in \mathcal{S}}\mathcal{Q}_{g}(s) = 1$. \smallskip \item[Property 5:] \textit{(Markov property)} \quad For probe $j>1$, given the variables associated with the preceding probes, group variable $g_j$ has a mass function depending on random vector $\boldsymbol{\theta}_{j-1}$ and inter-probe distance $e_{j-1}$: \begin{equation*} g_j \sim \mathcal{F}_{\boldsymbol{\theta}_{j-1},e_{j-1}} \end{equation*} where, for every $\boldsymbol{\theta} \in \mathcal{R}^T$ and $e>0$, $\mathcal{F}_{\boldsymbol{\theta},e}$ denotes a probability mass function on the set $\mathcal{G}$, so that $\sum_{g \in \mathcal{G}}\mathcal{F}_{\boldsymbol{\theta},e}(g) = 1$. For the first probe, group $g_1$ follows a categorical distribution, $\mathcal{F}_{0}$, on the set $\mathcal{G}$. \end{enumerate} Some examples are presented in Table \ref{T1} of Supplementary Material; as suggested by the form of distribution $\mathcal{F}_{\boldsymbol{\theta} , e}$ in the table, the first two models are first order Sticky~PDPs. The Sticky PDP corresponding to 2R2CF models used in differential methylation is a special case with two groups and two states. We observe that the first order models displayed in Table 1 are multiple-group, \textit{single-state} models, and that their dependencies are the same irrespective of the inter-probe distances. In contrast, as noted in Consequences 2 and 3 of Section \ref{Sticky_PDPs_DA}, the proposed Sticky PDP for differential analysis behaves similarly to two-state hidden Markov models for very small inter-probe distances, and similarly to finite mixture models for relatively large distances. For differential analysis, this offers a key advantage in datasets with widely varying inter-probe distances, as discussed in detail in Section \ref{S:intro}. The differential and non-differential probes are allowed to have different cluster allocation patterns depending on the differential status of the adjacent probes. These are some of the features that make Sticky PDPs ideally suited for differential analysis, and are primarily facilitated by the two-group, two-state~construct. { \begin{table} \footnotesize \begin{center} \renewcommand{\arraystretch}{1.3} \begin{tabular}{l | c c c c c } \hline\hline \textbf{Model} &$\mathcal{G}$ &$\mathcal{W}_{gs}(d_{s}, \alpha_{s}, W_{s})$ &$\mathcal{P}_{gs}$ &$\mathcal{F}_{\boldsymbol{\theta},e}$ \\ \hline\hline HDP-HMM &$\mathcal{N}$ &$\mathcal{W}_{g}(0, \alpha, W)$, &$\sum_{v=1}^\infty \pi_{gv} 1_{\boldsymbol{\phi}_{v}}$ &Point mass at \\ & &countably infinite $W$ & &$\sum_{v=1}^\infty v\cdot \mathcal{I}(\boldsymbol{\theta}=\boldsymbol{\phi}_{v})$\\\hline % % Finite HMM &$\{1,\ldots,K\}$ &$\mathcal{W}_g(0, \alpha, W)$, &$\sum_{v=1}^K \pi_{gv} 1_{\boldsymbol{\phi}_{v}}$ &Point mass at \\ & &discrete $W$ with $K<\infty$ atoms & &$\sum_{v=1}^K v\cdot \mathcal{I}(\boldsymbol{\theta}=\boldsymbol{\phi}_{v})$\\\hline % % HDP &$\{1,\ldots,K\}$ &$\mathcal{W}_{g}(0, \alpha, W)$, &$\sum_{v=1}^\infty \pi_{gv} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{g\}}$, \\ & &countably infinite $W$ & &prespecified $g \in \mathcal{G}$ \\\hline % % PDP &$\{1\}$ &$\mathcal{W}(d, \alpha, W)$ &$\sum_{v=1}^\infty \pi_{v} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{1\}}$ \\\hline % % Dirichlet process &$\{1\}$ &$\mathcal{W}(0, \alpha, W)$ &$\sum_{v=1}^\infty \pi_{v} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{1\}}$ \\\hline % % Finite mixture &$\{1\}$ &$\mathcal{W}(0, \alpha, W)$, &$\sum_{v=1}^K \pi_{v} 1_{\boldsymbol{\phi}_{v}}$ &$1_{\{1\}}$ \\ & &discrete $W$ with $K<\infty$ atoms \\%\hline % % \hline \end{tabular} \end{center} \caption{Examples of Sticky PDPs. Set $\mathcal{N}$ represents the natural numbers. All the above examples correspond to singleton set $\mathcal{S}=\{1\}$ and degenerate distribution $\mathcal{Q}_{g}=1_{\{1\}}$. Refer to the description in Section \ref{general2R2CF} for the notation. }\label{T1} \end{table} } \begin{figure}[h] \centering \includegraphics[width=0.7\textwidth]{figures/PlotCorr} \caption{Exploratory analysis of DNA methylation profiles of upper GI cancer samples from TCGA. See the text in the paper for further explanation. } \label{intro_data_plots2} \end{figure} \begin{table} \centering \footnotesize \begin{tabular}{c c | c c c c} & & \multicolumn{2}{c}{Low noise} &\multicolumn{2}{c}{High noise} \\ \hline & & High correlation & No correlation & High correlation & No correlation \\ \hline \multirow{7}{0.1\textwidth}{\centering AUC} & BayesDiff & \textbf{0.995} & \textbf{0.970} & \textbf{0.944} & 0.830 \\ & ANOVA & 0.964 & 0.949 & 0.888 & \textbf{0.864} \\ & Kruskal-Wallis & 0.958 & 0.944 & 0.878 & 0.854 \\ & COHCAP & 0.955 & 0.941 & 0.861 & 0.841 \\ & Methylkit & 0.955 & 0.942 & 0.869 & 0.848 \\ & BiSeq & 0.949 & 0.933 & 0.867 & 0.845 \\ & RADMeth & 0.959 & 0.944 & 0.876 & 0.852 \\ \hline \multirow{7}{0.1\textwidth}{\centering $\textrm{AUC}_{20}$} & BayesDiff & \textbf{0.988} & \textbf{0.926} & \textbf{0.884} & \textbf{0.636} \\ & ANOVA & 0.891 & 0.851 & 0.684 & 0.628 \\ & Kruskal-Wallis & 0.876 & 0.833 & 0.657 & 0.597 \\ & COHCAP & 0.856 & 0.820 & 0.602 & 0.556 \\ & Methylkit & 0.858 & 0.819 & 0.633 & 0.579 \\ & BiSeq & 0.822 & 0.781 & 0.607 & 0.559 \\ & RADMeth & 0.871 & 0.833 & 0.639 & 0.588 \\ \hline \multirow{7}{0.1\textwidth}{\centering $\textrm{AUC}_{10}$} & BayesDiff & \textbf{0.985} & \textbf{0.901} & \textbf{0.857} & \textbf{0.565} \\ & ANOVA & 0.849 & 0.804 & 0.586 & 0.529 \\ & Kruskal-Wallis & 0.827 & 0.773 & 0.551 & 0.493 \\ & COHCAP & 0.797 & 0.751 & 0.492 & 0.433 \\ & Methylkit & 0.794 & 0.744 & 0.523 & 0.458 \\ & BiSeq & 0.726 & 0.673 & 0.482 & 0.424 \\ & RADMeth & 0.817 & 0.775 & 0.531 & 0.471 \\ \end{tabular} \caption{Areas under ROC curves for the different methods (rows) under the four simulation scenarios (columns). See the text in the paper for further discussion.} \label{table_sim1} \end{table} \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/PlotHist_numprobes} \caption{Histogram of the number of gene-specific CpG~sites} \end{subfigure}% \quad \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/RealData_eta0_logBF} \caption{95\% credible intervals for lower bounds of log-Bayes factors of first order versus zero-order models. The intervals whose lower limits are positive are marked in red.} \end{subfigure} \caption{Data analysis plots. See the Section \ref{data_analysis} text for further explanation.} \label{appl_plots} \end{figure} \begin{table \centering \begin{tabular}{ccc|ccc} \hline \hline \multirow{2}{*}{Gene} & DM & Largest & \multirow{2}{*}{Gene} & DM & Largest \\ & Proportion & Difference & & Proportion & Difference\\ \hline EDNRB & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & SLITRK1 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ PCLO & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & FLRT2 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ PREX2 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & KCNA1 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ SLIT2 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & TRPA1 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ SLITRK2 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & ADCY8 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ \\ SORCS3 & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & CTNNA2 & 0.95 & PAAD$\uparrow$ LIHC$\downarrow$ \\ SPHKAP & 1.00 & ESCA$\uparrow$ LIHC$\downarrow$ & GRIA2 & 0.95 & STAD$\uparrow$ LIHC$\downarrow$ \\ SPTA1 & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & ADGRL3 & 0.94 & PAAD$\uparrow$ LIHC$\downarrow$ \\ UNC13C & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & LRRC7 & 0.94 & STAD$\uparrow$ LIHC$\downarrow$ \\ XIRP2 & 1.00 & PAAD$\uparrow$ LIHC$\downarrow$ & ERBB4 & 0.93 & PAAD$\uparrow$ LIHC$\downarrow$ \\ ZNF804B & 1.00 & STAD$\uparrow$ LIHC$\downarrow$ & PCDH10 & 0.93 & STAD$\uparrow$ LIHC$\downarrow$ \\ TSHZ3 & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & SOX11 & 0.93 & STAD$\uparrow$ LIHC$\downarrow$ \\ MYO3A & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & NLGN4X & 0.93 & PAAD$\uparrow$ LIHC$\downarrow$ \\ ABCC9 & 0.97 & ESCA$\uparrow$ LIHC$\downarrow$ & NBEA & 0.93 & PAAD$\uparrow$ LIHC$\downarrow$ \\ EPB41L3 & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & CNTN1 & 0.92 & STAD$\uparrow$ LIHC$\downarrow$ \\ FBN2 & 0.97 & STAD$\uparrow$ LIHC$\downarrow$ & GRM5 & 0.92 & PAAD$\uparrow$ LIHC$\downarrow$ \\ PCDH17 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ & PTPRZ1 & 0.91 & STAD$\uparrow$ PAAD$\downarrow$ \\ CDH8 & 0.96 & STAD$\uparrow$ LIHC$\downarrow$ & EPHA5 & 0.91 & STAD$\uparrow$ LIHC$\downarrow$ \\ \hline \hline \end{tabular} \caption{Genes with the overall proportion of differentially methylated CpG sites exceeding 0.9, listed in descending order. The ``Largest Difference'' column displays which pair-wise difference between the four cancer types is the largest, with the symbol ``$\uparrow$ ($\downarrow$)'' indicating higher (lower) methylation level for one cancer type relative to the other.} \label{table_list_gene_prop}% \end{table} \begin{table \centering \begin{tabular}{lc|lc} \hline \hline Gene & Number of probes & Gene & Number of probes \\ \hline ABCC9 & 36 & NLGN4X & 28 \\ ADCY8 & 24 & PCDH10 & 30 \\ ADGRL3 & 35 & PCDH17 & 27 \\ CDH8 & 26 & PCLO & 20 \\ CNTN1 & 25 & PREX2 & 21 \\ CTNNA2 & 85 & PTPRZ1 & 23 \\ EDNRB & 56 & SLIT2 & 29 \\ EPB41L3 & 34 & SLITRK1 & 26 \\ EPHA5 & 22 & SLITRK2 & 28 \\ ERBB4 & 30 & SORCS3 & 39 \\ FBN2 & 30 & SOX11 & 44 \\ FLRT2 & 51 & SPHKAP & 17 \\ GRIA2 & 20 & SPTA1 & 16 \\ GRM5 & 25 & TRPA1 & 25 \\ KCNA1 & 25 & TSHZ3 & 39 \\ LRRC7 & 34 & UNC13C & 11 \\ MYO3A & 38 & XIRP2 & 19 \\ NBEA & 55 & ZNF804B & 21 \\ \hline \hline \end{tabular} \caption{For the top methylated genes listed in Table \ref{table_list_gene_prop} of the paper, number of included CpG sites.} \label{table_list_num_probe}% \end{table} \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{\textwidth} \centering \includegraphics[trim={0 12pt 0 0},clip,width=0.75\textwidth]{figures/RealData_TP53_eqd_wlab} \caption{Gene TP53} \vspace{10pt} \end{subfigure} \begin{subfigure}{\textwidth} \centering \includegraphics[trim={0 12pt 0 0},clip,width=0.75\textwidth]{figures/RealData_TTN_eqd_wlab} \caption{Gene TTN} \vspace{10pt} \end{subfigure} \caption{Detailed differential methylation results for the top 2 mutated genes. For each gene, the upper panel shows the mean methylation levels. The middle panel shows the posterior probabilities of each CpG site being differentially methylated, with solid points representing differential methylation and dashed line denoting the corresponding cutoff value. The lower panel indicates the largest pairwise difference between the 4 cancer types. Symbols 1--4 in the lower panel represent GI cancer types STAD, LIHC, ESCA and PAAD, respectively. The vertical dotted lines represent the gene boundaries. The arrow at the top indicates the transcription direction.} \label{DA_detail_2genes} \end{figure} \begin{figure} \centering \captionsetup[subfigure]{justification=centering} \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/mean-mean-TP53.pdf} \caption{First moments for gene TP53} \end{subfigure}% \quad \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/var-var-TP53.pdf} \caption{Second moments for gene TP53} \end{subfigure} \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/mean-mean-TTN.pdf} \caption{First moments for gene TTN} \end{subfigure}% \quad \begin{subfigure}{0.48\textwidth} \centering \includegraphics[width=\textwidth]{figures/var-var-TTN.pdf} \caption{Second moments for gene TTN} \end{subfigure} \caption{Comparison of predicted and actual sample moments for the 2 top mutated genes} \label{mean-mean_var-var} \end{figure} \end{supplement} \bibliographystyle{ba}
{'timestamp': '2022-04-12T02:30:39', 'yymm': '2204', 'arxiv_id': '2204.04840', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04840'}
arxiv
\section{Introduction} \label{sec:intro} Human-Object Interaction~(HOI) detection, serving as a fundamental task for high-level computer vision tasks, e.g. image captioning, visual grounding, visual question answer, etc., has attracted enormous attention in recent years. Given an image, HOI detection aims to localize the pair of human and object instances and recognize the interaction between them. A human-object interaction could be defined as the $<$human, object, verb$>$ triplet. \par Many two- or one-stage methods~\cite{hico-det2018learning-chao, ican2018gao, gpnn2018qi, transferable2019li, rpnn2019zhou, pastanet2020li, drg2020gao, ppdm2020liao, ipnet2020learning-wang, uniondet2020kim, atl2021houaffordance, xukunlun2022effective} have significantly advanced the process of HOI detection, while transformer-based methods~\cite{hotr2021kim, as-net2021reformulating, hoi-transformer2021, qpic2021tamura, phrse-transformer2021li, cdn2021zhang} have been remarkably proposed recently and achieved the new state-of-the-art result. \par Thanks to the self-attention and cross-attention mechanisms, Transformer~\cite{transformer2017attention-vaswani} has a better capability of capturing long-range dependence between different instances, which is especially suitable for the HOI detection. HOTR~\cite{hotr2021kim} and AS-Net~\cite{as-net2021reformulating} utilize two parallel branches with transformer-decoders for performing instance detection and interaction classification respectively. Motivated by DETR~\cite{detr2020carion}, HOI-Transformer~\cite{hoi-transformer2021} and QPIC~\cite{qpic2021tamura} adopt one transformer-decoder with several sequential layers and automatically group the different types of predictions from one query into an HOI triplet in an end-to-end manner. \par Though these transformer-based methods have greatly promoted the community by improving the performance and efficiency without complex grouping strategies, there is a common issue with the Object Query\footnotemark[2] regardless of the differences in these methods. \footnotetext[2]{The Object Query is one input of the transformer-decoder and contains $N_q$ object queries without query positional embedding in this paper.} Specifically, the Object Query of the first decoder layer of these methods is always simply initialized as zeros since there is no previous layer for feeding semantic features~(shown as Black-Dotted-Box in Figure~\ref{fig1-curve}(a)). The capability of these models has not been fully explored due to the simple initialization of the Object Query, which would affect the performance. Meanwhile, multi-modal information, including spatial~\cite{hico-det2018learning-chao}, posture~\cite{pairwise2018fang}, and language~\cite{pdnet2021zhong}, has been indicated to be beneficial for two-stage HOI detection models. Thus, one question remains: \textbf{how semantic information promotes a transformer-based HOI detection model?} In this paper, we try to study the issue of elevating transformer-based HOI detectors by initializing the Object Query with category-aware semantic information. \par To this end, we present the Category-Aware Transformer Network~(CATN), consisting of two modules: the Category Aware Module~(CAM) and the Category-Level Attention Module~(CLAM). CAM can obtain category priors which is then applied to the initialization of the Object Query. Specifically, we use an external object detector and design a select strategy to get the categories contained in the image. After that, these categories would be transferred to corresponding word embeddings as final category priors. Moreover, these priors could be further used for enhancing the representation ability of features via the proposed CLAM. \par We first show that category-aware semantic information can indeed promote a transformer-based HOI detection model by the Oracle Experiment where the category priors are generated from the ground truth. Then we evaluate the effectiveness of our proposed CATN on two widely used HOI benchmarks: HICO-DET and V-COCO datasets. The contributions of our work could be summarized as: \begin{itemize} \item We reveal that a transformer-based HOI model can be further improved by taking category-aware semantic information as the initialization of the Object Query to achieve a new state-of-the-art result. \item We present the Category-Aware Transformer Network (CATN), which obtains two modules: CAM for generating category priors of an image and CLAM for enhancing the representation ability of the features. \item Extensive experiments, involving discussions of different initialization types and where to leverage the semantic information, have been conducted to demonstrate the effectiveness of the proposed idea. \end{itemize} \begin{figure*}[htb] \centering \includegraphics[width=2.0\columnwidth]{figures/framework_v6.pdf} \caption{Overall architecture of our proposed CATN. Compared with the previous, our method contains two main components: Category Aware Module~(CAM) and Category-Level Attention Module~(CLAM). We propose CAM which uses an external object detector to obtain category priors of the image and the priors are then applied for initializing the Object Query. Moreover, such priors can be further used in the CLAM for enhancing the representation ability of features.} \label{fig2-framework} \end{figure*} \vspace{-0.5cm} \section{Related Works} \label{sec:formatting} Many remarkable methods have advanced the progress of HOI detection, which could be simply categorized into Two-, one-stage methods, and transformer-based methods. \par \textbf{Two-stage methods.} Two-stage methods usually utilize a pre-trained object detector to generate human and object proposals in the first stage and then adopt an independent module to infer the multi-label interactions of each human-object pair in the second stage. HO-RCNN~\cite{hico-det2018learning-chao} firstly presents a multi-stream architecture. iCAN~\cite{ican2018gao} proposes an Instance-Centric Attention to aggregate the context feature of humans and objects. In order to obtain accurate interactions, some extra information, e.g. human posture~\cite{pmfnet2019wan, pastanet2020li} and language knowledge~\cite{pdnet2021zhong}, have been introduced into HOI detection. To better model the spatial relationship between the human and object, some GNN-based methods~\cite{gpnn2018qi, vsgnet2020ulutan, drg2020gao, rpnn2019zhou} are sequentially proposed and improve the performance. Two-stage methods generally suffer from inefficiency due to the separate architecture, where all possible pairs of human-object proposals are predicted one after the other and the cropped features generated from the object detector maybe not suitable for interaction classification in the second stage. \par \textbf{One-stage Methods.} One-stage methods are proposed to deal with the problems of high computational cost and feature mismatching appearing in two-stage methods. PPDM~\cite{ppdm2020liao} and IPNet~\cite{ipnet2020learning-wang} address the task of HOI as a key-point detection problem by regarding the interaction point as the mid of human-object centers. Based on the feature at the midpoint, the interactions between the human and object are predicted in a one-stage manner. Meanwhile, UnionNet~\cite{uniondet2020kim} provides another alteration to perform HOI detection in a one-stage manner, which treats the union box of human and object bounding-box as the region of each HOI triplet. UnionNet conduct an extra branch to predict the union box and group the final HOI triplet based on IoUs. Despite great improvement in efficiency, the performance of existing one-stage methods is limited by complex hand-crafted grouping strategies to group object detection results and the interaction predictions into final HOI triplets. \textbf{Transformer-based Methods.} Recently, transformer~\cite{transformer2017attention-vaswani}, with a good capability of capturing the long-range dependency, has been introduced to the HOI detection and brings a significant performance improvement. HOTR~\cite{hotr2021kim} and AS-Net~\cite{as-net2021reformulating} combine the advantages of both one-stage method and transformer, and utilize two parallel decoders to predict human-object proposals and interactions respectively. Apart from the above methods, HOI-Transformer~\cite{hoi-transformer2021} and QPIC~\cite{qpic2021tamura} extend DETR~\cite{detr2020carion} to the HOI detection, which directly defines the predictions from a query as the HOI triplet without the complex grouping strategy. \par Although significant performance is obtained by these transformer-based methods, they have a common issue that the Object Query is initialized with zeros as illustrated in Figure~\ref{fig1-curve}(a). In this paper, we study the issue of how to promote a transformer-based HOI detector by initializing the Object Query with category-aware semantic information. \textbf{Category Information and HOI Detection.} Category Information is a kind of semantic information indeed, which represents the object categories in an image. The effectiveness of such information has been demonstrated in several domains. Different from part-of-speech category for image captioning~\cite{kim2019dense} or the category shape for 3D-Reconstruction~\cite{runz2020frodo}, we studied object category information since the instance has category-aware relation in HOI detection, e.g. person-eat-apple, person-ride-bike, etc. \vspace{-0.5cm} \section{Approach} \subsection{Overview} In this section, we present our Category-Aware Transformer Network~(CATN), trying to improve the performance of transformer-based HOI detectors with category priors. Firstly, we start with the overall architecture of our proposed CATN. Secondly, we detailedly introduce the Category Aware Module~(CAM) to extract category priors of an image, which then are applied to the initialization of the Object Query of the first decoder layer. Moreover, we propose the Category-Level Attention Module~(CLAM) to enhance the capability of features with such priors. Finally, we modify the matching cost, used in bipartite matching, for better matching between the ground-truths and $N_q$ predictions. \subsection{CATN Architecture} The overall pipeline of our CATN is illustrated in Figure~\ref{fig2-framework}, which is similar to previous transformer-based methods except for additional proposed CAM and CLAM. \par \noindent \textbf{Backbone.} Given an RGB image, we firstly adopt a CNN-based backbone to extract a visual feature map denoted as $I_c \in \mathbb{R}^{D_c\times h\times w}$. Then a convolution layer with a kernel size of $1 \times 1$ is utilized to reduce the channel dimension from $D_c$ to $D_d$, where $D_c$, $D_d$ are 2,048 and 256 by default. Then the visual feature map is flattened and denoted as $I_{visual} \in \mathbb{R}^{D_d\times hw}$. After that, we adopt the CLAM to enhance the features from CNN with category priors and denote the output feature map as $I_{CLAM} \in \mathbb{R}^{D_d\times hw}$. \par \noindent \textbf{Encoder.} The transformer encoder aims to improve the capability of capturing long-range dependence. It is a stack of multiple encoder layers, where each layer mainly consists of a self-attention layer and a feed-forward~(FFN) layer. To make the flatten features spatially aware, a fixed Spatial Positional Encoding, denoted as $P_S \in \mathbb{R}^{D_d \times hw}$, is conducted and fed into each encoder layer with the features. The calculation of the transformer encoder could be expressed as: \vspace{-0.5cm} \begin{align} I_{enc} = f_{enc \times N_{enc}}(I_{CLAM}, P_{S}) \end{align} where $ f_{enc}$ indicates the function of one encoder layer, $N_{enc}$ is the number of stacked layers, and $I_{enc} \in \mathbb{R}^{D_d \times hw}$ is the output feature and then fed into the following decoder. \noindent \textbf{Decoder.} The transformer decoder aims to transform a set of object queries $Q_{zeros} \in \mathbb{R}^{N_q \times D_d}$ (with query positional embedding $P_{Q} \in \mathbb{R}^{N_q \times D_d}$ whose parameters are learnable) to another set of output queries $Q_{out} \in \mathbb{R}^{N_q \times D_d}$. It is also a stack of decoder layers. Apart from selt-attention and FFN, each decoder layer contains an additional cross-attention layer, which is used to aggregate the features $I_{enc}$ output from encoder into $N_q$ queries. \par In our CATN, $Q_{zeros}$ is replaced with Category Aware Query~(CAQ), denoted as $Q_{CA} \in \mathbb{R}^{N_q \times D_d}$, which is generated via category priors. The calculation of the transformer decoder could be expressed as: \begin{align} Q_{out} = f_{dec \times N_{dec}}(Q_{CA}, P_{Q}, I_{enc}, P_{S}) \end{align} where $f_{dec}$ indicates the function of one decoder layer and $N_{dec}$ is the number of stacked decoder layers. \noindent \textbf{Prediction Head.} In our experiments, an HOI triplet consists of four elements: the human bounding box, the object bounding box, the object category with its confidence, and multiple verb categories with their confidence. Based on the above definition, four feed-forward networks~(FFNs) are conducted on each output query as follows: \vspace{-0.5cm} \begin{align} \begin{cases} b_h^i = \sigma(f_{h,b}(Q_{out}^i)) \\ b_o^i = \sigma(f_{o,b}(Q_{out}^i)) \\ c_o^i = \varsigma(f_{o,c}(Q_{out}^i)) \\ c_v^i = \sigma(f_{v,c}(Q_{out}^i)) \\ \end{cases} \end{align} where $i$ indicates the index of outputting queries and the ground-truths, and $\sigma, \varsigma$ are the sigmoid and softmax functions respectively. \subsection{Category Aware Module} As mentioned above, the Object Query of the first decoder layer is simply initialized with zeros since there is no last layer where we argue this may affect the performance. In this section, we detailedly introduce the Category Aware Module~(CAM) to extract the category priors of an image which then are used for Category Aware Query and CLAM. \par The Blue-Dotted-Box in Figure~\ref{fig2-framework} describes the proposed CAM. Given an image, we firstly utilize an external object detector, e.g. Faster-RCNN, to perform object detection and only reserve the results with confidence scores higher than the detection threshold $T_{det}$. Since we focus on studying the effect of category-aware semantic information on HOI detectors and avoid the influence of other factors, we directly discard the bounding box of each prediction and only utilize the category with its confidence score. \par \noindent \textbf{Select Strategy.} Based on their categories, the rest results can be divided into different sets $\Omega = \{ \Omega_1, \Omega_2, ..., \Omega_K \}$, where $K$ is the total number of categories in the dataset and $\Omega_i$ represents a set of detection results whose category is the i-th category denoted as $c_i$. After that, we calculate the confidence score as follows: \begin{align} S_{c_i} = \begin{cases} max(\Omega_i) + \frac{|\Omega_i|}{2} \times mean(\Omega_i) , &|\Omega_i| \neq 0\\ 0 , &|\Omega_i| = 0\\ \end{cases} \end{align} where $S_{c_i}$ represents the probability of category $c_i$ contained in the image and $|.|$ indicates the number of the set. \par With these statistics, we firstly select a threshold $T_{can}$ for a set of candidate categories $\Omega_{can} = \{c_i | \sum_{i = 1}^{K} S_{c_i} \geq T_{can}\}$ and re-rank them based on $S_{c_i}$. Then $Top^{(N_c - 1)}$ categories from $\Omega_{can}$ with a fixed category (named as `background') are set as the prior categories of an image, where the `background' is used as the placeholder for matching if no relevant instance is obtained by the detector in CAM and the detail is discussed in Section 3.5. Note that the rest category will be filled with `None' if the number of categories in $\Omega_{can}$ is lower than $N_{c} - 1$. We denote the final prior categories of the image as $C^* = \{ c_i | c_i \in C_{can} \cup None\}_i^{N_{c}}$. \par \noindent \textbf{Category Priors.} We transform prior categories of an image to the word embedding vectors which could be used in the following module. To this end, we utilize a pre-trained word2vector model, e.g. fastText~\cite{fastText2017mikolov-advances}, to generate the category priors of an image. \vspace{-0.5cm} \begin{align} E_{prior} = \{f_{FC}(f_{w2v}(c_i)) | c_i \in C^*\} \end{align} where $f_{w2v}(c_i)$ is to obtain the embedding vector of $c_i$ category and $f_{FC}$ is a fully connected layer to adjust the dimension of the embedding. Especially, the embeddings of all object categories are calculated beforehand and saved locally. Regardless of training or inference, there is only a slight increase in computation cost due to the fully connected layer. In addition, we also evaluate several different word2vector models and the experimental results are shown in the later section. \par \noindent \textbf{Category Aware Query.} An image may contain more than one HOI triplet with the same category and the number of prior categories $N_c$ is usually much smaller than the number of queries $N_q$. Thus, we generate $Q_{CA} \in R^{N_q \times D_d}$ by simply repeating the $E_{prior}$ vectors $\frac{N_q}{N_c}$ times as follows. \vspace{-0.5cm} \begin{align} Q_{CA} = Repeat(E_{prior}, N_q, N_{c}) \end{align} Finally, we use $Q_{CA}$ as initial values of the Object Query. \begin{figure}[t] \centering \includegraphics[width=0.75\columnwidth]{figures/CLAM.pdf} \caption{The pipeline of our proposed Category-Level Attention Module~(CLAM). Each cuboid indicates a feature vector with the shape of $1 \times D_d$. $\cdot$, $\times$, + mean dot-product, multiplication and element-wise addition respectively.} \label{fig:clam} \vspace{-0.2cm} \end{figure} \subsection{Category-Level Attention Module} For maximizing the capability of category information, we also propose an attention mechanism, named as Category-Level Attention Module~(CLAM), to enhance the representation ability of features output from backbone. As illustrated in Figure~\ref{fig:clam}, to clearly describe the entire workflow, we take the visual feature in one location as an example of this module and denote the feature as $X_{visual} \in \mathbb{R}^{1 \times D_d}$, while features work consistently. \par The visual feature $X_{visual}$ is firstly projected to another $D_d$-dimensional vector, denoted as $\hat{X}_{visual}\in \mathbb{R}^{1 \times D_d}$, via a Muti-Layer Perception~(MLP). The MLP contains an FC layer without BatchNorm and ReLU and is used to transform the feature from visual space to word space. Then we measure the similarity between the vector and category embedding by dot product operation, and a softmax function is followed to normalize the similarity values of all categories. \vspace{-0.5cm} \begin{align} W_{att} = Softmax(MLP(X_{visual}) \cdot E_{prior}^T) \end{align} where $W_{att} \in \mathbb{R}^{1 \times N_{c}}$ represents the attention weights of prior categories on the feature and `$\cdot$' means Dot-Product. Specifically, the weight in a category is high if the feature contains rich information related to the category. To make the features category aware, we aggregate all word embeddings of prior categories with corresponding weights into one vector $X_{word} \in \mathbb{R}^{1 \times D_d}$ and then add the vector back to the original visual feature $X_{visual}$. The feature aggregation can be written as: \vspace{-0.5cm} \begin{align} X_{clam} = X_{app} + \sum_{j=1}^{N_c} w_{att}^j \times E_{prior}^j \end{align} where $w_{att}^{j}$ is a value and indicates the attention weight of j-th category belonging to the prior categories, $E_{prior}^{j}$ is the embedding of j-th category, `+' represents element-wise addition, and `$\times$' mean the multiplication between the scalar $w_{att}^j$ and each element of the vector $E_{prior}^j$ respectively. \par Our proposed CLAM has several advantages. Compared to instance-level attention mechanism~\cite{ican2018gao}, ours is category-level and has lower requirements on the accuracy of bounding boxes. Meanwhile, we add the weighted average word embedding with category information to the originally visual features. Therefore, the aggregated features, output from our CLAN, not only have the capability of aware visual information but also are aware of category information. \vspace{-0.5cm} \subsection{Matching Cost \& Training Loss} For training transformer-based models~\cite{detr2020carion} with a set of prediction results, the bipartite-matching algorithm is publicly used to automatically match a ground-truth with at most one prediction, which would suppress the problem of redundant predictions. To this end, two types of losses are introduced below. \par \noindent \textbf{Modified Matching Cost.} Matching cost is conducted to measure the similarity between the ground truth and an HOI prediction and assign the label of each query whether a positive or a negative. Firstly, we calculate the matching cost $H \in \mathbb{R}^{N_{gt} \times N_q}$ following Formula 1 in~\cite{qpic2021tamura}, where $N_{gt}$ is the number of ground-truth HOI triplet and $H_{i, j}$ indicates the matching cost between i-th ground-truth and j-th prediction generated from j-th output query. Then, we modify the matching cost by $\hat{H}_{i,j}= H_{i,j} + Cost_{i,j}$ and the external cost $Cost_{i, j}$ is defined as follows: \vspace{-0.3cm} \begin{align} Cost_{i, j}= \begin{cases} 0 , &C(q_{j})=C(GT_i)\\ v , &C(q_{j})=``Background''\\ 2v , &C(q_{j})=``None''\\ 2v , &Else \end{cases} \end{align} where $C$ represents the corresponding object category, $q_j$ is the j-th query of $Q_{CA}$, $GT_i$ means the i-th ground-truth triplet in the image. The $Cost_{i,j}$ is used to make the matching cost $H_{i, j}$ higher when the object categories of j-th query and i-th ground-truth are different. Meanwhile, the experimental results show that there is no difference when the value is higher than a threshold. Thus we empirically set $v$ as 500. Finally, we utilize the Hungarian Algorithm~\cite{hungarian1955kuhn} to perform the optimal assignment $\hat{\omega} = argmin_{\omega \in \Omega_{N_q}} \sum_{i=1}^{N_q}\hat{H}_{i,\omega(i)}$, where only $N_{gt}$ predictions in $\hat{\omega}$ are set as positive and the rest are negative. \par With the above modifications, a ground-truth will match the query where their object category are the same. In addition, if the object category of a ground truth is not included in prior categories, the ground truth will preferentially match the query whose prior category is ``background''. Thus the modified cost shrinks the matching space between the ground truth and the predictions. \par \noindent \textbf{Training Loss.} Based on the above label assignment, the training loss is calculated to optimize the parameters of our CATN model. We directly adopt equations 6$\sim$10 in~\cite{qpic2021tamura} and keep the weights consistent, which reveals that the performance improvement is obtained by our proposed category priors, not hyper-parameters. \section{Experiments} \subsection{Datasets \& Metrics} \noindent\textbf{Datasets.} We conduct experiments on two widely used datasets to verify the effectiveness of our model. \textbf{V-COCO}~\cite{vcoco2015visual-gupta}, a subset of COCO~\cite{coco2014microsoft-lin} dataset, consists of 2,533 training images, 2,867 valuation images, and 4,946 test images respectively. There are 16,199 human instances and each instance has a set of binary labels for 29 different actions. \textbf{HICO-DET}~\cite{hico-det2018learning-chao} is the largest dataset in HOI detection. There are 38,118 training images and 9,658 test images respectively with totally more than 150k HOI annotations. It has 600 hoi categories~(Full) with 117 verb categories and 80 object categories, which can be further divided into 118 categories~(Rare) and 462 categories~(Non-Rare) based on the number of instances in the training set. \par \noindent \textbf{Evaluation Metrics.} Following the standard rule~\cite{vcoco2015visual-gupta}, we use the commonly used role mean average precision (mAP) to evaluate the model performance for both benchmarks. An HOI prediction is regarded as a true positive if the categories of the object and verbs are correct, and the predicted bounding boxes of the human and object are localized accurately where the IoUs are greater than 0.5 with the corresponding ground truth. \subsection{Implementation Details} We conduct our experiments with the publicly available PyTorch framework~\cite{pytorch2019paszke}. \par For the external detector used in CAM to obtain category priors, we adopt Faster-RCNN-FPN~\cite{fasterrcnn2015ren, fpn2017lin} with ResNet-50~\cite{resnet2016he} as the backbone to perform object detection. For better performance, we use COCO pre-trained weights and then fine-tune the model on both HICO-DET and V-COCO datasets. During training, we drop the weight of regressing Bbox in loss cost from 1.0 to 0.2 and keep the other hyper-parameters consistent as default. Meanwhile, the human category is discarded since the number of humans is dominant. We set the batch size to 4 and use SGD as the optimizer with a learning rate of 0.01, a weight decay of 0.0001, and a momentum of 0.9. We train the model for 12 epochs with twice the learning rate decay at epoch 8, 11 by 10 times respectively. The detection threshold $T_{det}$ is set to 0.15. The prior threshold $T_{can}$, used for category priors, is set to 0.3 and 0.4 for HICO-DET and V-COCO respectively. The number $N_{c}$ is set to 4 and 5 for two datasets respectively. To obtain better category priors, we adopt some commonly used augmentation strategies, including random scales, random flip, color jittering, and random corp augmentation. \par For our CATN, ResNet-50 is used as the backbone, the number of encoder and decoder layers are both set to 6 and the number of Object Query $N_q$ is set to 100. We initialize the network with parameters of DETR~\cite{detr2020carion} pre-trained on the COCO dataset. During training, we set the batch size to 16, the backbone's learning rate to 1e-5, the transformer's learning rate to 1e-4, and weight decay to 1e-4. The model is trained for 150 epochs totally on both datasets with once learning rate decreased by 10 times at epoch 100. Following DETR, scale augmentation, scaling the input image such that the shortest side is at least 480 and at most 800 pixels while the longest at most 1333, is adopted for better performance in training. \par Note that the category embedding is generated by fastText~\cite{fastText2017mikolov-advances} and the ``baseline'' indicates the QPIC~\cite{qpic2021tamura} with ResNet-50~\cite{resnet2016he} if there are no additional comments. \begin{table}[t] \centering \resizebox{0.95\columnwidth}{!}{ \begin{tabular}{c | c | c c c} \hline Method & Query & Full & Rare & Non-Rare \\ \hline baseline & Zeros & 29.07 & 21.85 & 31.23\\ Ours & CAQ* & 37.17 & 31.65 & 38.81\\ \hline \multicolumn{2}{c|}{Improvement} & (8.10 \textcolor{red}{$\uparrow$}) & (9.80 \textcolor{red}{$\uparrow$}) & (7.58 \textcolor{red}{$\uparrow$})\\ \hline \end{tabular} } \caption{Oracle experiment on HICO-DET dataset. Zeros and CAQ represent that the Object Query is initialized with zero-values or category priors respectively. * indicates such category priors generated from the ground truth. The performance is tremendously promoted once category priors are adopted for initializing the Object Query. This phenomenon directly indicates the rationality of introducing category priors. } \label{tab:oracle_experiment} \vspace{-0.2cm} \end{table} \subsection{Oracle Experiment} To verify the effectiveness of our idea that the performance of transformer-based HOI detectors could be further improved by initializing the Object Query with category-aware semantic information, we firstly conduct the oracle experiment where the category priors of an image are simply generated from the ground truth. \par Table~\ref{tab:oracle_experiment} illustrates the experimental results on HICO-DET. In this experiment, we select QPIC as the baseline and only apply such priors to the Object Query without the proposed CLAM. Compared with the baseline, our method achieves a great performance improvement on all three default settings. With such category priors, the `Full' performance is improved from 29.09 to 37.17 with a 27.8\% relative performance gain and especially the `Rare' performance is improved from 21.85 to 31.65 with a 44.8\% relative performance gain. This simple experiment with great performance gain verifies the effectiveness of our idea and supports subsequent detailed experiments. \begin{table*}[t] \centering \begin{tabular}{l c c | c c c | c c c } \hline \hline & & & \multicolumn{3}{c|}{Default} & \multicolumn{3}{c}{Known Object}\\ Methods & Backbone & Detector & Full & Rare & Non-Rare & Full & Rare & Non-Rare \\ \hline \multicolumn{2}{l}{\textit{Two-Stage Methods}} & & & & & &\\ HO-RCNN~\cite{hico-det2018learning-chao} & CaffeNet & C & 7.81 & 5.37 & 8.54 & 10.41 & 8.94 & 10.85\\ InteractNet~\cite{InteractNet2018detecting-gkioxari} & R50-FPN & C & 9.94 & 7.16 & 10.77 & - & - & -\\ GPNN~\cite{gpnn2018qi} & R101 & C & 13.11 & 9.34 & 14.23 & - & - & -\\ iCAN~\cite{ican2018gao} & R50 & C & 14.84 & 10.45 & 16.15 & 16.26 & 11.33 & 17.73\\ PMFNet~\cite{pmfnet2019wan} & R50-FPN & C & 17.46 & 15.65 & 18.00 & 20.34 & 17.47 & 21.20\\ VSGNet~\cite{vsgnet2020ulutan} & R152 & C & 19.80 & 14.63 & 20.87 & - & - & -\\ PDNet~\cite{pdnet2021zhong} & R152 & C & 20.81 & 15.90 & 22.28 & 24.78 & 18.88 & 26.54\\ FCMNet~\cite{fcmnet2020amplifying-liu} & R50 & C & 20.41 & 17.34 & 21.56 & 22.04 & 18.97 & 23.12\\ PastaNet~\cite{pastanet2020li} & R50 & C & 22.65 & 21.17 & 23.09 & 24.53 & 23.00 & 24.99\\ VCL~\cite{vcl2020hou} & R101 & H & 23.63 & 17.21 & 25.55 & 25.98 & 19.12 & 28.03\\ DRG~\cite{drg2020gao} & R50-FPN & H & 24.53 & 19.47 & 26.04 & 27.98 & 23.11 & 29.43\\ \hline \multicolumn{2}{l}{\textit{One-Stage Methods}} & & & & & & &\\ UnionDet~\cite{uniondet2020kim} & R50-FPN & H & 17.58 & 11.52 & 19.33 & 19.76 & 14.68 & 21.27\\ IPNet~\cite{ipnet2020learning-wang} & HG-104 & C & 19.56 & 12.79 & 21.58 & 22.05 & 15.77 & 23.92\\ PPDM~\cite{ppdm2020liao} & HG-104 & H & 21.73 & 13.78 & 24.10 & 24.58 & 16.65 & 26.84\\ \hline \multicolumn{2}{l}{\textit{Transformer-based Methods}} & & & & & & &\\ HOI Transformer~\cite{hoi-transformer2021} & R50 & - & 23.46 & 16.91 & 25.41 & 26.15 & 19.24 & 28.22\\ HOTR~\cite{hotr2021kim} & R50 & - & 25.10 & 17.34 & 27.42 & - & - & - \\ AS-Net~\cite{as-net2021reformulating} & R50 & - & 28.87 & 24.25 & 30.25 & 31.74 & \underline{27.07} & 33.14\\ QPIC~\cite{qpic2021tamura} & R50 & - & 29.07 & 21.85 & 31.23 & 31.68 & 24.14 & 33.93\\ \hline \multicolumn{2}{l}{\textit{Ours}} & & & & & & &\\ \textbf{CATN~(with fastText~\cite{fastText2017mikolov-advances})} & R50 & H & 31.62 & 24.28 & \underline{33.79} & 33.53 & 26.53 & 35.92\\ \textbf{CATN~(with BERT~\cite{bert2018devlin})} & R50 & H & \textbf{31.86} & \textbf{25.15} & \textbf{33.84} & \textbf{34.44} & \textbf{27.69} & \textbf{36.45}\\ \textbf{CATN~(with CLIP~\cite{clip2021radfordlearning})} & R50 & H & \underline{31.71} & \underline{24.82} & 33.77 & \underline{33.96} & 26.37 & \underline{36.23}\\ \hline \hline \end{tabular} \caption{Comparison against state-of-the-art methods on HICO-DET dataset. For Detector, C means that the detector is trained on COCO dataset, while H means that the detector is then fine-tuned on HICO-DET dataset. `Default' and `Known Object' are two evaluation modes following the standard rule. ``fastText'', ``BERT'', ``CLIP'' means that the embeddings of prior categories are obtained from these pre-trained word2vector models. The BEST and the SECOND BEST performances are highlighted in \textbf{bold} and \underline{underlined} respectively. Our proposed CATN outperforms the previous by a large margin to achieve new state-of-the-art results on both evaluation modes.} \label{tab:sota-hico} \end{table*} \begin{table}[thb] \centering \resizebox{0.9\columnwidth}{!}{ \begin{tabular}{l c | c } \hline Methods & Backbone & AProle \\ \hline VCL~\cite{vcl2020hou} & R50-FPN & 48.3 \\ DRG~\cite{drg2020gao} & R50-FPN & 51.0 \\ PDNet~\cite{pdnet2021zhong} & R152 & 52.6 \\ \hline UnionBox~\cite{uniondet2020kim} & R50-FPN & 47.5 \\ IPNet~\cite{ipnet2020learning-wang} & HG-104 & 51.0 \\ \hline HOI Transformer~\cite{hoi-transformer2021} & R50 & 52.9 \\ HOTR~\cite{hotr2021kim} & R50 & 55.2 \\ AS-Net~\cite{as-net2021reformulating} & R50 & 53.9 \\ QPIC~\cite{qpic2021tamura} & R50 & 58.8 \\ \textbf{CATN~(with fastText~\cite{fastText2017mikolov-advances})} & R50 & \textbf{60.1} \\ \hline \end{tabular} } \caption{Comparison against state-of-the-art methods on V-COCO dataset. The BEST performances are high-lighted in \textbf{bold}. Ours also outperforms others to achieve a new state-of-the-art result.} \label{tab:sota-vcoco} \vspace{-0.5cm} \end{table} \subsection{Comparison to the State-of-The-Art} In this section, we use the proposed CAM to obtain category priors of an image and compare our proposed CATN with other state-of-the-art methods on two public benchmarks. \textbf{HICO-DET.} To verify the effectiveness of our proposed idea, we adopt several different word2vector models including fastText\cite{fastText2017mikolov-advances}, BERT~\cite{bert2018devlin} and CLIP~\cite{clip2021radfordlearning}, to obtain the category-aware semantic information and conducts the experiments on HICO-DET dataset. As shown in Table~\ref{tab:sota-hico}, our proposed method obtains the significant performance improvement on both ``Default'' and ``Known-Object'' evaluation modes. Especially, the experiment with BERT~\cite{bert2018devlin} has achieved the new state-of-the-art result, which promotes the mAP-full from 29.07 to 31.86 in Default mode and from 31.74 to 34.44 in Known-Object mode. \textbf{V-COCO.} We also evaluate our proposed CATN on V-COCO dataset. A similar performance gain is obtained as shown in Tabel~\ref{tab:sota-vcoco}. Compared with previous methods, our method also achieves a new state-of-the-art result. With the embeddings generated by fastText~\cite{fastText2017mikolov-advances}, we reach an AP-role of 60.1, which obtains 1.3 points performance gain than the second-best method. \subsection{Ablations Study} \textbf{The effectiveness of each component in our CATN.} In order to make a clearer study of the impact of each component on the overall performance, supplementary ablation experiments are conducted on the HICO-DET dataset. The results in Default evaluation mode are shown in Table~\ref{tab:ablation}. Initializing the Object Query with category-aware semantic information instead of just zeros~\cite{qpic2021tamura} can effectively improve mAP from 29.07 to 30.82, which indicates the superiority of our main idea on HOI detection. Modifying the matching cost can also promote mAP to 31.03 with a gain of 0.21 mAP. Illustrated as line 4, the performance could be further improved from 31.03 to 31.62 when our proposed CLAM enhances the representation ability of features via the category-aware semantic information. Moreover, we visualize an example of the attention map in the supplementary file to demonstrate the effectiveness of our CLAM. \begin{table}[t] \centering \begin{tabular}{c | c | c c c | c} \hline & Method & CAQ & MMC & CLAM & mAP \\ \hline 1 & baseline & - & - & - & 29.07\\ \hline 2 & \multirow{3}{*}{CATN} & \checkmark & & & 30.82\\ 3 & & \checkmark & \checkmark & & 31.03 \\ 4 & & \checkmark & \checkmark & \checkmark & \textbf{31.62} \\ \hline \end{tabular} \caption{Ablation studies on the effectiveness of each module in our CATN on HICO-DET dataset. $\checkmark$ represents the component is used. ``CAQ'' means the Object Query is initialized with category-aware semantic information. ``MMC'' indicates our modified matching cost. ``CLAM'' represents the proposed Category-Level Attention Module.} \label{tab:ablation} \vspace{-0.5cm} \end{table} \subsection{Discussion} \par \textbf{The impacts of where to leverage the category priors.} To verify how the category-aware semantic information better promotes the HOI detection model, we design experiments to leverage category priors in another location. As Figure~\ref{fig:query_head}, the category priors are introduced in prediction heads. Before predicting the categories of interaction, we combine the visual feature and the category prior by different operations~(add and concatenate). Experimental results indicate that taking category-aware semantic information as the Object Query initialization achieves better performance than using the information as complementary features. \par \textbf{The impacts of different initial types.} Table~\ref{table:types of initialization} presents comparisons to different types of query initialization, including ``Zeros'', ``Random Values~(following the Uniform or Gaussian distribution)'' and ``Category-Aware Semantic Information''. Models of the Object Query initialized with 3 different category-aware semantic information consistently achieve better performance than other initial types. \par \textbf{Hyper-parameters in CAM.} Figure~\ref{fig:hyper-parameters} illustrates the variance by several hyper-parameters, including $N_c$, $T_{det}$, and $T_{can}$, in CAM. To clearly study the impacts1 of them on the quality of category priors, we calculate the recall and precision metrics of the prior categories in image level not instance level. In other words, we only care if a object category could be detected, not the amount and location. We change one parameter in turn and keep others consistent. We achieve the best performance where $N_c=3$, $T_{det}=0.15$, and $T_{can}=0.30$, due to a better trade-off between the recall and precision. \begin{figure} \centering \includegraphics[width=0.95\columnwidth]{figures/query_head3.pdf} \caption{The impacts of where to leverage the category priors. ``H'', ``B'', ``C'' are prediction heads, bounding boxes, and categories respectively. Similar to~\cite{drg2020gao}, Figure~(a) and ``Head'' in Tabel~(b) indicate our experiments of introducing category priors~(CP) into the verb prediction head. Results from (b) indicate that taking such semantic information as the Object Query initialization~(shown as Figure~\ref{fig1-curve}.a) achieves a significant performance gain than into the prediction head~(Row.4 vs. Row2/3). } \label{fig:query_head} \vspace{-0.1cm} \end{figure} \begin{table}[t] \centering \resizebox{0.95\columnwidth}{!}{ \begin{tabular}{c | c | c | c c c} \hline & Method & Value & Full & Rare & Non-Rare \\ \hline 1 & Zeros & Zero & 29.07 & 21.85 & 31.23 \\ \hline 2 & \multirow{2}{*}{Rondom} & Uniform & 29.70 & 23.53 & 31.53 \\ 3 & & Gaussian & 29.60 & 22.42 & 31.73 \\ \hline 4 & \multirow{3}{*}{CAQ} & fastText~\cite{fastText2017mikolov-advances} & 31.03 & 23.97 & 33.12\\ 5 & & BERT~\cite{bert2018devlin} & 31.28 & 24.89 & 33.14 \\ 6 & & CLIP~\cite{clip2021radfordlearning} & 31.23 & 24.82 & 33.10 \\ \hline \end{tabular} } \caption{The impacts of different initial types. CLAM is not used due to the need of category priors. Models of the Object Query initialized with 3 different category-aware semantic information consistently achieve better performance than other initial types. } \label{table:types of initialization} \vspace{-0.1cm} \end{table} \begin{figure}[t] \centering \begin{subfigure}{0.32\columnwidth} \centering \includegraphics[width=0.9\linewidth]{figures/Nc.pdf} \caption{$N_c$.} \label{fig:sub1} \end{subfigure} % \hfill \begin{subfigure}{0.32\columnwidth} \centering \includegraphics[width=0.9\linewidth]{figures/Tdet.pdf} \caption{$T_{det}$.} \label{fig:sub2} \end{subfigure} \hfill \begin{subfigure}{0.32\columnwidth} \centering \includegraphics[width=0.9\linewidth]{figures/Tcan.pdf} \caption{$T_{can}$.} \label{fig:sub3} \end{subfigure} \vspace{-0.2cm} \caption{The impacts of different settings of hyper-parameters, including $N_c$, $T_{det}$, $T_{can}$, in CAM.} \label{fig:hyper-parameters} \vspace{-0.3cm} \end{figure} \section{Conclusion} In this paper, we explore the issue of promoting a transformer-based HOI model by initializing the Object Query with category-aware semantic information. We propose the Category-Aware Transformer Network~(CATN), which obtains two modules: CAM for generating category priors of an image and CLAM for enhancing the representation ability of the features. Extensive experiments, involving discussions of different initialization types and where to leverage the semantic information, have been conducted to demonstrate the effectiveness of the proposed idea. With the category priors, our method achieves new state-of-the-art results on both V-COCO and HICO-DET datasets. \section{Acknowledge} This work is supported by the National Natural Science Foundation of China~(NSFC) grant 62176100, the Central Guidance on Local Science and Technology Development Fund of Hubei Province grant 2021BEE056. {\small \bibliographystyle{ieee_fullname}
{'timestamp': '2022-04-12T02:34:07', 'yymm': '2204', 'arxiv_id': '2204.04911', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04911'}
arxiv
\section{Introduction} Pre-trained sequence-to-sequence language models (PLMs) like BART~\cite{lewis2020bart} and T5~\cite{2020t5} have led to significant advances in many natural language generation tasks like text summarization and machine translation. The models are pre-trained on massive amounts of text data with self-supervision, thus enabling them to construct coherent natural language sentences for downstream tasks. This then raises the question whether pre-trained language models, trained on free-form natural language data, can also adapt themselves to generate structured outputs like graphs. Graphs are common in NLP tasks that involve representing structured knowledge in the form of knowledge bases~\cite{guarino1995ontologies}, constructing event chains from documents~\cite{chambers2009unsupervised}, or more recent work on encoding reasoning chains, explanations, or deductive proofs~\cite{saha2020prover, tafjord2020proofwriter, dalvi2021explaining}. Graphs differ from free-form natural language. In the context of NLP, natural language graphs (consisting of textual nodes and edges) can have distinct structural and semantic properties. For example, consider a recently proposed commonsense explanation graph generation task shown in Fig.~\ref{fig:intro_fig}~\cite{saha2021explagraphs}. Each example shows a belief, an argument and an explanation graph explaining how the argument supports or refutes the belief. \new{These explanation graphs encode structured knowledge (augmented with commonsense) and consist of concepts as nodes and relations from ConceptNet \cite{liu2004conceptnet} as edges. For example, the second graph encodes the knowledge that ``both salads and fast food are part of mcdonalds and hence mcdonalds is not greasy and fattening'', thus explicitly refuting the belief.} From prior work, the structural constraints enforce the graphs to be connected directed acyclic and the nodes to contain at least two concepts from the belief and two from the argument. The semantic aspect deals with commonsense and evaluates whether each edge expresses coherent relational knowledge and if the whole graph explains the stance. Following~\citet{saha2021explagraphs}, we represent graphs as strings composed of concatenated edges and fine-tune T5 to generate graphs in an autoregressive manner. We observe that while moderate amount of supervision enables the model to learn valid graph encodings, the graphs frequently violate task-specific structural constraints (like connectivity). For instance, the first example in Fig.~\ref{fig:intro_fig} shows a graph generated by T5 that is disconnected and hence structurally incorrect. Moreover, for the fraction of graphs that are structurally correct, the model also makes commonsense mistakes, a type of semantic error, by inferring wrong or incoherent relations between concepts. Both T5-generated graphs shown in Fig.~\ref{fig:intro_fig} contain incoherent or non-commonsensical edges (marked by dashed arrows) like ``fast food; has context; salads''. Based on these observations, we study PLMs that generate explanation graphs in an end-to-end manner \new{and analyze their ability to learn the structural constraints as well as the semantics of such graphs.} While a general recipe towards improving the structural and semantic aspects of graph generation can be via large-scale training with more human-annotated graphs, it is prohibitive under most practical scenarios because of the cognitive load associated with a complex data creation task like graph annotation~\cite{dalvi2021explaining, saha2021explagraphs}. Hence, we propose simple yet effective methods of graph perturbations that perform various kinds of node and edge addition, deletion, and replacement operations to construct \new{structurally} and \new{semantically} positive (correct) and negative (incorrect) graphs. Overall, we leverage three types of negative graphs (synthetic \new{structural}, synthetic semantic, and human-created semantic) and develop multiple contrastive learning models~\cite{hjelm2018learning, chen2020simple, khosla2020supervised, gunel2020supervised} for effectively distinguishing between correct and incorrect graphs. Our first method is a \textit{Generate-and-Refine} model that first generates an initial graph and further refines it using another T5 model. Next, we propose two improved models -- one that uses the negative graphs in a max-margin formulation and another that uses both positive and negative graphs with a InfoNCE~\cite{Oord2018RepresentationLW} contrastive loss. On two real-world tasks of explanation graph generation and temporal graph generation, with varied node and edge semantics, we observe that our proposed methods and graph perturbation techniques generalize well and lead to improvements in both structural and semantic accuracy of graphs. \new{Further analysis of different types of negative graphs reveal that the human-error graphs are the hardest, most diverse, and hence the best type of negatives to learn from in contrastive learning. Hence, we also develop methods to automatically generate more such human-like semantic negative graphs, which leads to further improvements.} We summarize our contributions as follows. \begin{itemize}[nosep, wide=0pt, leftmargin=*, after=\strut] \item \new{We present a detailed analysis of graph structure and semantics for end-to-end explanation graph generation via pre-trained language models.} \item We propose simple yet effective graph perturbation techniques for constructing positive and negative graphs (incl. human errors) and use them in different graph contrastive learning models. \item Our methods lead to significant improvements in both structural and semantic accuracy of explanation graphs and also generalize to other similar (e.g., temporal) graph generation tasks. \end{itemize}{} \section{Related Work} \noindent \textbf{Graph Generation from Language Models.} Representative works on graph generation from language models include knowledge graph completion models like Comet~\cite{bosselut2019comet, hwang2021comet} that fine-tune GPT~\cite{radford2019language, brown2020language} and BART~\cite{lewis2020bart}, generation of event influence graphs~\cite{tandon2019wiqa, madaan2020eigen}, partially ordered scripts~\cite{sakaguchi2021proscript}, temporal graphs~\cite{madaan2021neural}, entailment trees~\cite{dalvi2021explaining}, proof graphs~\cite{saha2020prover, tafjord2020proofwriter, saha2021multiprover} and commonsense explanation graphs~\cite{saha2021explagraphs}. \new{Linguistic tasks like syntactic parsing \cite{zhou-etal-2020-limit, mohammadshahi2021recursive, kondratyuk201975} and semantic parsing \cite{chen2020low, shin2021constrained} have also made use of language models.} There is also a large body of work on building generative models for learning unconditional graph distributions~\cite{you2018graphrnn, simonovsky2018graphvae, grover2019graphite, liao2019efficient, shi2020graphaf} without any semantics attached to the graphs. Our novelty lies in presenting the first systematic analysis of \new{structure} and semantics of graph generation for two downstream NLP tasks using pre-trained language models and improving them via constrastive learning. \noindent \textbf{Data Augmentation and Contrastive Learning.} \new{Data Augmentation for NLP \cite{hedderich2020survey, feng2021survey, chen2021empirical} has been a powerful tool in low-data settings, ranging from its early usages with synonym replacement \cite{kolomiyets2011model, wang2015s} to more recent methods of perturbing hidden representations \cite{miyato2016adversarial, shen2020simple}}. Contrastive learning, beyond its historical use in learning robust image representations~\cite{chopra2005learning, hadsell2006dimensionality, gutmann2010noise, hoffer2015deep, hjelm2018learning, chen2020simple, he2020momentum} has been explored in supervised scenarios~\cite{khosla2020supervised, gunel2020supervised} and for NLP, in training self-supervised language models~\cite{fang2020cert}, learning sentence representations~\cite{gao2021simcse}, document clustering~\cite{zhang2021supporting}, summarization~\cite{liu2021simcls, cao2021cliff} and generic text generation~\cite{lee2020contrastive}. It has also been used in unconditional graph representation learning~\cite{you2020graph, hassani2020contrastive, zhu2021graph}. We follow this rich line of work to explore their applicability in supervised graph generation tasks from pre-trained language models in low-resource settings. \noindent \textbf{Generative Commonsense Reasoning.} While traditional commonsense reasoning tasks are discriminative in nature~\cite{zellers2018swag, talmor2019commonsenseqa, sap2019socialiqa, bisk2020piqa, sakaguchi2020winogrande, talmor2021commonsenseqa}, recent focus on generative evaluation have led to the development of tasks and benchmarks that explore unstructured commonsense sentence generation~\cite{lin2020commongen}, event influence graph generation~\cite{madaan2020eigen}, commonsense explanation graph generation~\cite{saha2021explagraphs}, etc. We experiment with two graph generation tasks, primarily focusing on ExplaGraphs \cite{saha2021explagraphs} because of the clear distinction in the underlying structural constraints and the semantic aspect dealing with commonsense. \section{Motivation and Background} \new{Our primary task of interest is a recently proposed commonsense explanation graph generation task called ExplaGraphs~\cite{saha2021explagraphs}. In Sec.~\ref{sec:temporal}, we also experiment with another related task of temporal graph generation \cite{madaan2020eigen}. In both these tasks, the structural aspect deals with satisfying certain task-specific constraints on the graph (like connectivity) and the semantic aspect deals with the construction of meaningful edges (that adhere to commonsense). Below we discuss ExplaGraphs briefly and analyze pre-trained language models for their ability to generate explanation graphs.} \paragraph{ExplaGraphs \cite{saha2021explagraphs}. }In this task, given a belief and an argument, an agent has to perform two sub-tasks -- predict the stance (support/counter) and also generate an explanation graph explaining the stance. \new{Explanation graphs are structured explanations that capture explicit reasoning chains between the belief and the argument, thereby making models more interpretable.} Formally, an explanation graph is a connected DAG with nodes as concepts and edges as commonsense relations between two concepts (See Fig.~\ref{fig:intro_fig}). \new{The concepts are either part of the belief or the argument (represented with solid boxes) or any external commonsense phrase (represented with dashed boxes). Each edge in the graph forms a coherent sentence and the graph, when read as a whole, forms reasoning structures explaining why the argument supports or refutes the belief.} \citet{saha2021explagraphs} evaluate explanation graphs by defining two accuracy metrics -- (1) \emph{Structural Correctness Accuracy (StCA)}: Fraction of graphs that satisfy all structural constraints, and (2) \emph{Semantic Correctness Accuracy (SeCA)}: Fraction of graphs that are both structurally and semantically correct. A graph is considered structurally correct if it satisfies the following constraints: (1) it is connected, (2) it is a DAG, (3) the edge relations belong to a pre-defined list, (4) there are at least two concepts from the belief and two from the argument. If all these constraints are satisfied, the graph is next evaluated for semantic correctness by a model-based metric~\cite{saha2021explagraphs}. It works on the principle that an explanation graph is semantically correct if the stance inferred from the belief and the graph matches the gold stance. Refer to Appendix~\ref{appendix:metrics} for a detailed description of all evaluation metrics. \paragraph{Baseline T5 Model. }Following prior work~\cite{saha2021explagraphs}, we generate explanation graphs as post-hoc explanations by conditioning on the belief, argument and the predicted stance.\footnote{These are rationalizing models~\cite{rajani2019explain, hase2020leakage} that first predict the stance, followed by the graph. While graphs can also be generated first, followed by the stance, we experiment with one model family for this work.} The stance prediction model is a fine-tuned RoBERTa model~\cite{liu2019roberta} which we keep unaltered from prior work and focus on the graph generation sub-task. We generate graphs as linearized strings in an end-to-end manner by leveraging an encoder-decoder pre-trained language model, T5~\cite{2020t5}. The input to the model is the concatenated belief, argument and the stance along with a prefix \textit{``Generate an Explanation Graph for''}. The graphs are encoded as concatenated bracketed edges, in which the edges are ordered according to the Depth First Search (DFS) order of the nodes. While we choose T5 because of its superior performance~\cite{saha2021explagraphs}, we do not make any model-specific assumptions and graphs can be generated via any encoder-decoder style pre-trained language model (\new{e.g., see Appendix~\ref{appendix:results} for results with BART)}. \paragraph{Analysis of T5 Baseline.} We analyze the quality of the explanation graphs generated by T5 in Table~\ref{tab:data_size}. We vary the amount of training data from 500 to 2368 samples (all) and report StCA and SeCA along with other metrics like Graph-BertScore (G-BS) introduced in prior work~\cite{saha2021explagraphs}. While the structural accuracy improves with increase in training data, the gain saturates quickly and even after training on the entire data, we find a significant fraction of graphs to violate the structural constraints. We note that a high 91\% of T5's generations are valid graph encodings i.e., the generated strings can be parsed into graphical structures (without any post-processing), suggesting that T5 is able to learn the graph encoding from a fairly small amount of supervision. However, it fails to satisfy the various structural constraints -- (1) 20\% of the graphs are disconnected, (2) 6\% of the graphs contain cycles, and (3) 14\% of the graphs have less than two concepts from the belief or from the argument. Note that these constraints are not encoded in the model, thus making them fairly hard to learn from limited supervision. On the fraction of structurally correct graphs, the model makes further semantic errors and a lower SeCA of 35\% demonstrates that. In Fig.~\ref{fig:intro_fig}, we show examples of structurally incorrect and semantically incorrect graphs generated by T5. Overall, these results indicate that there is a significant scope for improvement both on graph structure and semantics, thus motivating us to develop methods with design choices aimed at improving both aspects. \begin{table}[t] \small \centering \begin{tabular}{rrrrrr} \toprule Count & StCA$\uparrow$ & SeCA$\uparrow$ & G-BS$\uparrow$ & GED$\downarrow$ & EA$\uparrow$ \\ \midrule 500 & 42.5 & 20.7 & 36.3 & 0.68 & 20.4 \\ 1000 & 49.2 & 23.7 & 42.2 & 0.63 & 26.2 \\ 1500 & 50.7 & 33.2 & 43.4 & 0.61 & 28.2 \\ 2368 & 51.0 & 34.7 & 43.9 & 0.61 & 29.5 \\ \bottomrule \end{tabular} \vspace{-5pt} \caption{Performance of T5-large with varying amount of training data on ExplaGraphs test set. } \vspace{-15pt} \label{tab:data_size} \end{table} \section{Graph Perturbations} \label{sec:data_augmentation} Most prior works that collect human-annotated graphs for a \new{downstream} NLP task have found such collection processes to be quite expensive and tedious~\cite{tandon2019wiqa, dalvi2021explaining, saha2021explagraphs}. For instance,~\citet{saha2021explagraphs} obtained high-quality data only after multiple rounds of refinement and~\citet{dalvi2021explaining} employ trained expert annotators for entailment tree construction. The corresponding datasets are also relatively small in size (2-3k), thus limiting the prospect of large-scale training. Hence, our approach towards improving explanation graph generation is through data augmentation techniques that perturb human-curated graphs to construct positive and negative graphs. As noted earlier, we wish to construct graphs that enable better learning of structural graph constraints and their semantics. \subsection{Positive Graph Perturbations} One simple method to augment existing training data is to create synthetic positive graphs. These graphs should be created such that all the task-specific constraints continue to hold upon perturbations. E.g., removing a node that makes the graph disconnected is a prohibitive action. Hence, we choose nodes (concepts) that are not part of the belief or the argument (also termed as commonsense nodes) and replace them with phrases that are synonymous to the original phrases. To do so, we select words from the concept with POS tags of Adjective, Noun, Adverb, or Verb and replace them with that synonym from Wordnet \cite{miller1995wordnet} for which the cosine similarity of their word2vec representations \cite{mikolov2013efficient} is the highest.\footnote{We also tried similar replacement operations with antonyms. However, they often lead to semantically inconsistent graphs. E.g., \textit{A causes B} does not always imply \textit{A not causes not B} or \textit{not A not causes not B.}} Fig. \ref{fig:data_aug} shows an example of a positive graph perturbation where the node ``loss of jobs'' is replaced with ``going of business''. Note that our node replacement operations will always lead to structurally similar graphs. Automatically constructing structurally diverse positive graphs is a challenging problem and we leave that for future work. \begin{figure}[t] \centering \includegraphics[width=0.95\columnwidth]{figures/T5_main.pdf} \vspace{-5pt} \caption{Our T5-based contrastive learning framework for graph generation using positively and three kinds of negatively perturbed graphs.} \label{fig:data_aug} \vspace{-15pt} \end{figure} \subsection{Negative Graph Perturbations} In order to enable the model to learn from explicit hard negatives, we construct three diverse types of graphs -- synthetically constructed structural negatives for learning graph constraints and synthetic and human-created semantic negatives to capture a fairly large space of semantically incorrect graphs. Below we discuss the construction of these graphs. \paragraph{Synthetic \& Structurally Negative Graphs (SySt).} As shown previously, one common source of errors in the generated explanation graphs is the violation of structural constraints. To enable learning these constraints, we generate four types of negative graphs by performing the following perturbations on each ground-truth graph: (1) removing an edge at random such that the resultant graph becomes disconnected, (2) adding an edge between two randomly chosen nodes such that the resultant graph becomes cyclic, (3) adding and removing one edge at random such that the resultant graph becomes both disconnected and cyclic, (4) removing a node randomly such that the resultant graph contains less than two concepts from the belief or argument. Fig.~\ref{fig:data_aug} shows an example of a disconnected graph created as part of the structurally negative graphs. \paragraph{Synthetic \& Semantic Negative Graphs (SySe).} We also construct semantically incorrect negative explanation graphs. While the previous category of negative graphs (SySt) captures structural constraints, SySe captures the relational knowledge in graphs. Semantic incorrectness typically arises from inappropriate relations that do not adhere to human commonsense (``loss of jobs; is a; humane''). We create such negative graphs by selecting a random number of edges and then replacing the relations with some other relations. Fig.~\ref{fig:data_aug} shows a semantic negative graph in which the relations marked \new{with dashed lines} are perturbed. \paragraph{Human-created \& Semantic Negative Graphs (HuSe). }The space of semantically incorrect graphs is fairly large and in order to augment our synthetic negative graphs with harder structurally-diverse negatives, we make use of human-created incorrect graphs \new{from prior work \cite{saha2021explagraphs}}.\footnote{\new{Publicly released by~\citet{saha2021explagraphs} at \url{https://github.com/swarnaHub/ExplaGraphs/blob/main/data/refinement_graphs_train.tsv}.}} \new{Humans make subtle errors, thus making them ideal negative candidates for contrastive learning.} ExplaGraphs was constructed via an iterative framework in which the graphs are iteratively refined (up to two times) until they are verified as correct. We treat these refined graphs as negatives. Specifically, in two rounds, if an initial graph $\mathcal{G}_1$ is refined into graphs $\mathcal{G}_2$ and $\mathcal{G}_3$ successively, then $\mathcal{G}_1$ and $\mathcal{G}_2$ are considered as negative graphs. Unlike SySe which only perturb the relations, these negatives are structurally diverse (see Fig.~\ref{fig:data_aug}) and capture semantics not just at the level of each edge but for the graph as a whole (e.g., a graph might be refined because it does not explain the stance). Note that human-created graphs can only be semantically incorrect, since their structural correctness is already ensured during construction. \section{Augmentation with Perturbed Graphs} \label{sec:model} Next we propose different methods of leveraging these positive and negative graphs for explanation graph generation. Our models either use only positive graphs as simple data augmentation, only negative graphs in a max-margin model, or both in a \textit{Generate \& Refine} model and a Contrastive model. \subsection{Augmentation with Positive Graphs} \label{sec:positive} In this first simple approach, we augment the training data with the synthetically created positive graphs and retrain the baseline T5 model. \subsection{Max-Margin Graph Generation Model} \label{sec:max-margin} Our next model leverages the negatively perturbed graphs in a max-margin formulation. During training, given a (belief, argument, stance) context $x$, a ground truth graph $\mathcal{G}^{(g)}$ and a negative graph $\mathcal{G}^{(n)}$, linearized into a sequence of words $\{y_i^{(g)}\}_{i=1}^k$ and $\{y_i^{(n)}\}_{i=1}^l$ respectively, we define the loss function $\mathcal{L}$ as a linear combination of the standard cross-entropy loss $\mathcal{L}_{\mathit{CE}}$ and a max-margin loss $\mathcal{L}_{\mathit{MM}}$, defined between a word $y_i^{(g)}$ of the positive graph and a word $y_i^{(n)}$ of the negative graph. \begin{eqnarray} \mathcal{L}_{\mathit{CE}} = \sum_{i} - log P_\theta(y_i^{(g)}|y_{<i}^{(g)}, x) \nonumber\\ \mathcal{L}_{\mathit{MM}} = \sum_{i} \max(0, log P_\theta(y_i^{(g)}|y_{<i}^{(g)}, x) \nonumber \\ - \log P_\theta(y_i^{(n)}|y_{<i}^{(n)}, x) + \beta) \nonumber \\ \mathcal{L} = \mathcal{L}_{\mathit{CE}} + \alpha \mathcal{L}_{\mathit{MM}} \nonumber \end{eqnarray} where $\alpha$ and $\beta$ (margin) are hyperparameters. As noted earlier, the baseline model often makes commonsense mistakes in distinguishing between positive and negative relations (``causes'' vs ``not causes'') and our relation perturbing negative graphs and the max-margin loss component facilitate learning a better boundary between them. \subsection{Generate \& Refine Graph Generation} \label{sec:gen-refine} ExplaGraphs was constructed using a ``Refinement'' phase wherein the initially constructed graphs that are marked incorrect by human verifiers are further refined by another set of annotators. Here we emulate the graph refinement phase with the help of a model. Specifically, our approach is a 2-stage pipeline -- first, an initial graph is generated by the baseline T5 model and second, an \textit{Explanation Graph Refinement} model conditions on the initial graph, along with the belief, argument and the stance to refine the graph. The refiner is also a T5 model fine-tuned with the prefix ``Refine the Explanation Graph for'' on all positive and negative graphs described in Sec.~\ref{sec:data_augmentation}. Note that our approach differs from the actual data collection process in two aspects. Unlike the human-annotated graphs, which are refined only for semantic correctness, the model-generated graphs can be both structurally and semantically incorrect. Second, our approach does not involve a graph verification stage and thus, the refiner model acts on all (correct and incorrect) graphs generated in stage 1 and is thus trained with both correct and incorrect graphs. \begin{table*}[t] \small \centering \begin{tabular}{lrrrrrr} \toprule & SA$\uparrow$ & StCA$\uparrow$ & SeCA$\uparrow$ & G-BS$\uparrow$ & GED$\downarrow$ & EA$\uparrow$ \\ \midrule T5-Base \cite{saha2021explagraphs} & \textbf{87.2} & 38.7 & 19.0 & 33.6 & 0.71 & 20.8 \\ T5-Large & \textbf{87.2} & 51.0 & 34.7 & 43.9 & 0.61 & 29.5 \\ \midrule Generate \& Refine & \textbf{87.2} & 52.5 & 37.7 & 45.3 & 0.60 & 30.0 \\ Pos Data Aug & \textbf{87.2} & 54.5 & 41.5 & 46.9 & 0.58 & 30.2 \\ Max-Margin & \textbf{87.2} & 56.7 & \textbf{43.5} & 48.6 & 0.57 & 30.5 \\ Contrastive & \textbf{87.2} & \textbf{60.5} & 42.5 & \textbf{52.1} & \textbf{0.52} & \textbf{33.1} \\ \midrule Upper Bound & 91.0 & 91.0 & 83.5 & 71.1 & 0.38 & 46.8 \\\bottomrule \end{tabular} \vspace{-5pt} \caption{Comparison of all models across all metrics on the ExplaGraphs \cite{saha2021explagraphs} test set. \new{Improvement in SeCA is statistically significant (computed using Bootstrap test \cite{efron1994introduction}) with $p < 0.005$.} } \vspace{-12pt} \label{tab:model_test} \end{table*} \subsection{Contrastive Graph Generation Model} \label{sec:contrastive} Our Contrastive Graph Generation Model (Fig.~\ref{fig:data_aug}) also leverages both positive and negative graphs but instead of doing so in a 2-stage \textit{Generate \& Refine} model, uses a contrastive learning framework \cite{khosla2020supervised, gunel2020supervised}. Given a ground-truth graph $\mathcal{G}^{(g)}$, a positive graph $\mathcal{G}^{(p)}$ and a set of negative graphs $\{\mathcal{G}^{(n)}_i\}_{i=1}^{M}$, contrastive learning aims to learn the graph representations such that the gold graph's representation is close to that of the synthetic positive graph while being distant from those of the negative graphs. Similar to \citet{cao2021cliff}, we use the last layer of the decoder in T5 as the representation of each token in the graph and obtain the graph representation by averaging over the constituent token representations. Let the graph representations be denoted by $h^{(g)}$, $h^{(p)}$ and $\{h^{(n)}_i\}_{i=1}^{M}$. Given $ \mathcal{H}^{(g)} = \{h^{(p)}\} \bigcup \{h^{(n)}_i\}_{i=1}^{M}$, our overall loss combines the cross-entropy loss $\mathcal{L}_{\mathit{CE}}$ and the InfoNCE contrastive loss \cite{Oord2018RepresentationLW} $\mathcal{L}_{\mathit{CL}}$ as shown below. \begin{eqnarray} \mathcal{L}_{\mathit{CL}} = - \log \frac{\exp(\operatorname{sim}(h^{(g)},h^{(p)}) / \tau)}{\sum_{h_i \in \mathcal{H}^{(g)}} \exp(\operatorname{sim}(h^{(g)},h_i) / \tau)} \nonumber\\ \mathcal{L} = \mathcal{L}_{\mathit{CE}} + \alpha \mathcal{L}_{\mathit{CL}} \nonumber \end{eqnarray} where $\alpha$ and the temperature $\tau$ are the hyperparameters and $\operatorname{sim}()$ denotes the cosine similarity function between the graph representations. \section{Experiments} \subsection{Impact of Different Models on Graph Structural and Semantic Accuracy} In Table~\ref{tab:model_test}, we compare the various modeling techniques described in Sec.~\ref{sec:model} and their effect on the structural and semantic correctness of the generated graphs. While our primary metrics of interest are Graph Structural Accuracy (StCA) and Semantic Accuracy (SeCA), following prior work \cite{saha2021explagraphs}, we also report Stance Accuracy (SA), Graph-BertScore (G-BS), Graph Edit Distance (GED) and Edge Accuracy (EA). \paragraph{Effect of Model Size and Training Data. }The T5-Large model uses the same setup as the T5-Base model experimented with in \citet{saha2021explagraphs}. We observe that using a larger T5 model improves StCA by 12\% and SeCA by 16\%. This finding is in line with other commonsense reasoning tasks \cite{lourie2021unicorn, elazar2021back} which also show that fine-tuning a larger language model typically leads to better performance. Together with the results reported in Table \ref{tab:data_size}, we conclude that much of the improvement in explanation graph generation comes from increasing the training data and using a larger model. Given its superior performance, we build our proposed models on T5-large. \paragraph{Results with Generate \& Refine Model. }The \textit{Generate \& Refine} model (Sec.~\ref{sec:gen-refine}) improves all metrics; however the gains are small. Note that this model refines all graphs (correct or not) and can lead to already correct graphs becoming incorrect after refinement. In practice, we observe that most graphs do not change much after refinement which we believe stems from the model's inability to distinguish between correct and incorrect graphs. \paragraph{Effect of Positive Graph Perturbations.} On retraining T5 augmented with the positively perturbed graphs (Sec.~\ref{sec:positive}), we observe that it obtains significant improvement over T5 and \textit{Generate \& Refine} both in structural and semantic accuracy. Note that, by construction, the positive graphs only differ in the commonsense concepts (not part of the belief or argument) while keeping the structure intact. Hence, the model has more supervision about the semantics of the graphs as opposed to the structural constraints. This is reflected in the larger improvement in SeCA. The positive graphs, being structurally correct, also reinforces the model's belief about structural correlation with correct graphs, thus leading to some improvement in StCA as well. \paragraph{Effect of Negative Graph Perturbations. }The \textit{Max-Margin} model (Sec.~\ref{sec:max-margin}) leverages all structurally and semantically incorrect graphs and obtains up to 6\% and 9\% improvement in StCA and SeCA respectively over the baseline T5 model. The model implicitly learns the structural constraints through relevant supervision and the margin-based loss enables it to learn a better boundary between correct and incorrect graphs. Similarly, the semantically perturbed graphs improves the model's relation prediction capability between concepts. The \textit{Max-Margin} model outperforms the \textit{Pos Data Aug} model because of the former having access to both structural and semantic supervision while the latter is only augmented with structurally similar graphs. \paragraph{Effect of Positive and Negative Graph Perturbations with Contrastive Learning.} The \textit{Contrastive Graph Generation} model (Sec.~\ref{sec:contrastive}) leverages both positive and negative graphs and improves StCA to 60\% with comparable SeCA to the \textit{Max-Margin} model. The overall improvements in StCA and SeCA are 9\% and 8\% respectively compared to T5. We hypothesize that the constrastive model does not lead to further improvement in SeCA because of the structurally similar positive graphs. This can potentially be improved by incorporating more structurally diverse graphs. Finally, our best SeCA is far from perfect and significant future work can be done in improving the graph semantics. Further ablations of negative graphs and human evaluation are done on the \textit{Max-Margin} model, due to its slightly higher SeCA. \begin{table}[t] \small \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{lrrrrr} \toprule & StCA$\uparrow$ & SeCA$\uparrow$ & G-BS$\uparrow$ & GED$\downarrow$ & EA$\uparrow$ \\ \midrule T5-Large & 46.5 & 31.6 & 36.8 & 0.66 & 26.7 \\ + SySt & 50.2 & 34.1 & 40.7 & 0.64 & 27.4 \\ + SySe & 50.7 & 35.1 & 40.8 & 0.63 & 27.3 \\ + HuSe & 49.5 & 38.4 & 39.4 & 0.64 & 26.1 \\ \bottomrule \vspace{-10pt} \end{tabular} } \caption{Ablation study showing the effect of different types of negative graphs on ExplaGraphs dev set.} \vspace{-5pt} \label{tab:effect_aug} \end{table} \begin{table}[t] \small \centering \begin{tabular}{lrrr} \toprule & Valid$\uparrow$ & StCA$\uparrow$ & G-BS$\uparrow$ \\ \midrule T5-Base & 88.8 & 88.7 & 54.4 \\ Max-Margin & 89.1 & 87.7 & 55.7 \\ Contrastive & \textbf{97.5} & \textbf{96.9} & \textbf{57.2} \\ \bottomrule \end{tabular} \caption{Comparison of T5, Max-Margin and Contrastive models for temporal graph generation.} \label{tab:temporal} \vspace{-15pt} \end{table} \vspace{-2pt} \subsection{Human Evaluation of Graph Semantics} \vspace{-1pt} Automatically evaluating graphs for semantic correctness is challenging. We conduct human evaluation to further validate our findings. We compare the graphs generated by T5 and our \textit{Max-Margin} model on Amazon Mechanical Turk where three annotators choose which graph is better or if they are mostly similar (instructions in Appendix~\ref{appendix:human_eval}). For fair comparison, we evaluate only those samples where both models predict the correct stance and the graphs are also structurally correct. In fact, this lets us evaluate the semantic aspect in isolation when both graphs are structurally correct. With majority voting on 150 samples, we observe that our \textit{Max-Margin} model's graphs are preferred 13\% more times compared to those of the T5 model (43\% vs 30\% and statistically significant with $p$ < 0.05) while in 22\% cases, the graphs are marked similar (remaining have no majority). \vspace{-2pt} \subsection{Ablation with Negative Graphs} \vspace{-1pt} In Table~\ref{tab:effect_aug}, we show the effect of different types of negative graphs. We compare the results on the ExplaGraphs validation set by leveraging Synthetic Structural (SySt), Synthetic Semantic (SySe) and Human-created Semantic (HuSe) graphs with the \textit{Max-Margin} graph generation model. All types of negatives graphs lead to consistent increase in SeCA. Leveraging human-created negative graphs leads to a bigger gain in SeCA because of the hardness and diversity in these graphs \new{and hence are the best candidates for contrastive learning.} \subsection{Generalization to Other Graph Generation Tasks} \label{sec:temporal} We test the generalizability of constructing structurally and semantically perturbed graphs for contrastive learning by also experimenting on a temporal graph generation task \cite{madaan2021neural} that requires constructing a temporal graph from a document. The nodes in the graph are events from the document and the edges are temporal relations between events (``before'', ``after'', etc). Following our overall goal of improving graph generation with limited data, we randomly sample 1.3\% of the overall corpus ($\sim$9.5k samples) as the training data such that all graphs are connected DAGs. Similar to ExplaGraphs, we create structurally negative graphs with disconnected and cyclic graphs and semantic negative graphs by perturbating the temporal relations. E.g., if an edge relation is ``before'', we replace it with ``after''. We construct positive graphs by replacing edges like ``A before B'' with ``B after A'' (more details in Appendix~\ref{appendix:temporal}). In Table \ref{tab:temporal}, we report structural correctness accuracy (StCA) (percentage of connected DAGs) and Graph-BertScore (G-BS) for measuring approximate semantic correctness wrt gold graphs. We observe that our contrastive model not only generates more valid graph encodings but also improves StCA by 8\% and G-BS by 3\%. \begin{table*}[t] \small \centering \begin{tabular}{lrrrrr} \toprule & StCA$\uparrow$ & SeCA$\uparrow$ & G-BS$\uparrow$ & GED$\downarrow$ & EA$\uparrow$ \\ \midrule SySt + SySe + HuSe & 49.5 & 38.4 & 39.4 & 0.64 & 26.1 \\ SySt + SySe + HuSe + \textit{HuSe-Gen (IP)} & 53.5 & 38.7 & 42.1 & 0.62 & 28.1 \\ SySt + SySe + HuSe + \textit{HuSe-Gen (AE)} & 52.0 & 40.2 & 41.3 & 0.62 & 28.2 \\ \bottomrule \vspace{-15pt} \end{tabular} \caption{Effect of training the Max-Margin model with additional Human-like Semantic Negative Graphs on ExplaGraphs dev set. IP and AE refer to the two thresholding techniques for filtering generated negatives.} \vspace{-12pt} \label{tab:effect_huse_gen} \end{table*} \begin{figure}[t] \centering \includegraphics[width=0.95\columnwidth]{figures/analysis1_vert.pdf} \vspace{-5pt} \caption{Qualitative analysis of explanation graphs.} \label{fig:qual1} \vspace{-15pt} \end{figure} \subsection{Analysis of Generated Graphs} Fig.~\ref{fig:qual1} shows an example of the graphs generated by different models (more examples in Appendix~\ref{appendix:human_eval}). Unlike T5, our models' graphs are both structurally and semantically correct with diverse commonsense nodes (``Groupthink'', ``Good Thing''). While our models generate more correct graphs, they lack in structural diversity -- the Contrastive model generates 77\% of linear graphs (i.e., the nodes are in a linear chain) which is comparable to 75\% in the T5 model. This can be attributed to our structurally similar positive graphs as the model does not obtain enough supervision to generate diverse graphs. Structural diversity is not a measure of graph correctness; however, like diverse text generation \cite{vijayakumar2016diverse}, generating diverse graphs is an interesting direction for future work. \subsection{Generating Human-like Semantic Negatives (HuSe-Gen)} \new{In ExplaGraphs, human-created negatives account for 38\% of the samples for which the initially constructed graph was incorrect and was refined. Moreover, we see in the previous section that human-error graphs are the best negative candidates for contrastive learning (which is intuitive since tricky and subtle errors made by expert human annotators would make for some of the hardest negatives/distractors for a contrastive learning model to learn from). Hence, in this final section, we further explore whether it is also possible to automatically imitate and generate more of such \textit{harder human-like} incorrect graphs for the remaining samples as well. Our method consists of the following steps.} \noindent \new{\textbf{Human-like Negative Edge Generation. }We first fine-tune a T5 model that conditions on the belief, argument and the stance to generate a set of incorrect edges (which is the set of edges that are present in the incorrect graph and not in the refined graph)}. \noindent \new{\textbf{Human-like Negative Graph Construction. }This generated set of incorrect edges is then added to the correct graph to construct the incorrect graph, such that it is structurally correct and hence representative of human-like erroneous graphs.} \noindent \new{\textbf{Filtering High-quality Negative Graphs.} Contrastive models will only benefit from these negatives if the negative edge generation model is accurate and generates edges that are actually incorrect. Hence, we control the quality of the generated incorrect graphs by the following two techniques -- (a) \textit{Thresholding via fraction of Acceptable Edges (AE):} We say that a generated incorrect edge is acceptable if it is not part of the correct graph and can be added to the correct graph without violating any structural constraints. We compute the fraction of acceptable edges for every generated negative graph and choose only those graphs with AE above a certain threshold $\delta$. Intuitively, this ensures that a high fraction of the generated edges are actually incorrect and hence when added to the correct graph, will lead to a sufficiently different (human-like) incorrect graph. (b) \textit{Thresholding via Incorrect Probability of a graph (IP):} We use our SeCA metric model (that classifies a graph into support, counter, or incorrect class) to compute the probability of the generated graph being incorrect and choose those graphs that are above a certain threshold $\gamma$ of incorrect probability.} \new{We set $\delta=0.4$ and $\gamma=0.5$ (tuned on the dev set) and train the Max-margin model using these additionally generated human-like negative graphs. As shown in Table~\ref{tab:effect_huse_gen} both thresholding approaches lead to further improvements over using just the human-created negative graphs. These initial promising results for emulating hard/tricky human errors as strong negatives for contrastive learning will hopefully lead to further future work in this interesting direction.} \vspace{-3pt} \section{Conclusion} \vspace{-2pt} We presented an empirical study of graph structure and semantics for end-to-end explanation graph generation from pre-trained language models and showed that the generated graphs often violate structural constraints or are semantically incorrect. We significantly improve both the structural and semantic accuracy of graph generation by proposing contrastive learning models that leverage simple yet efficient methods of graph perturbations and also generalize to similar graph generation tasks. \section*{Ethical Considerations} From an ethics standpoint, we provide a brief overview and show samples from the datasets that our models are trained on throughout the paper and also in the Appendix. Explanation graph generation improves the interpretability of neural commonsense reasoning systems and could prove to be effective in understanding and debugging such models. Hence we do not foresee any major risks or negative societal impact of our work. However, like any other ML model, the graphs generated by our models may not always be completely accurate and hence should be used with caution for real-world applications. \section*{Acknowledgements} \new{We thank the reviewers for their helpful feedback and the annotators for their time and effort. This work was supported by DARPA MCS Grant N66001-19-2-4031, NSF-CAREER Award 1846185, DARPA YFA17-D17AP00022, ONR Grant N00014-18-1-2871, Microsoft Investigator Fellowship, and Munroe \& Rebecca Cobey Fellowship. The views in this article are those of the authors and not the funding agency.} \section{Evaluation Metrics for ExplaGraphs} \label{appendix:metrics} Below we provide brief descriptions of the evaluation metrics used for the ExplaGraphs task. For further details, we refer readers to prior work \cite{saha2021explagraphs}. \paragraph{Structural Correctness Accuracy of Graphs (StCA).} It computes the fraction of graphs where all the structural constraints are satisfied. \paragraph{Semantic Correctness Accuracy of Graphs (SeCA).} SeCA is a model-based metric that computes the fraction of graphs that are both structurally and semantically correct. For computing SeCA, prior work trains a 3-way RoBERTa \cite{liu2019roberta} classifier that given a belief and a generated explanation graph, infers whether the graph supports the belief, counters the belief or is incorrect (because of incoherent edges). If it predicts support or counter and this stance matches the gold stance, then the graph is considered semantically correct. In essense, SeCA works on the principle that an explanation graph is semantically correct if a stance can be unambiguously inferred from it (by a model in this case or a human) and that stance is the same as the gold stance. Note that SeCA is a reference-free metric (does not use the ground-truth graph) and hence is invariant to structural variations in explanation graphs. \paragraph{Graph-BertScore (G-BS).} Graph-BertScore is an extension of BertScore \cite{bertscore} for computing the degree of match between the predicted graphs and the ground-truth graphs. It treats a graph as a set of edges and computes the best match between the gold edges and the predicted edges, where the matching score between a pair of edges is given by the BertScore F1. \paragraph{Graph Edit Distance (GED).} GED is the standard Graph Edit Distance for graphs, measuring the number of edit operations (addition, deletion, and replacement of nodes and edges) to transform one graph to the other and further normalized by an appropriate normalizing constant. \paragraph{Edge Accuracy (EA).} The final metric, Edge Accuracy (EA) measures the fraction of edges in the graph that are important. An edge is considered important if removing it from the graph leads to a drop in the gold stance prediction confidence. \begin{table}[] \centering \small \begin{tabular}{cccc} \toprule SySt & SySe & HuSe & Total \\ \midrule 7522 & 2368 & 1336 & 11226 \\ \bottomrule \vspace{-15pt} \end{tabular} \caption{\label{tab:neg-data} Count of negative graphs in each category.} \vspace{-10pt} \end{table} \section{Statistics of Graph Perturbations} We create a total of 11k negative graphs. Table \ref{tab:neg-data} shows the respective counts of the negative graphs belonging to synthetic structural (SySt), synthetic semantic (SySe) and human-created semantic (HuSe) categories. \section{Temporal Graph Generation} \label{appendix:temporal} The task of temporal graph generation requires constructing a temporal graph from a document (see Fig. \ref{fig:temporal_example}). The nodes in the graph are events from the document (e.g., ``Markovic jailed'' or ``Covering up attempted murder'') and the edges are temporal relations between the events (e.g., ``Markovic jailed; before; Covering up attempted murder''). The authors consider five temporal relations (``before'', ``after'', ``simultaneous'', ``is included'' and ``includes'') and build an automatically constructed large-scale dataset for the task. Following our overall goal of improving graph generation in limited data settings, we randomly sample 1.3\% of the overall corpus ($\sim$ 9.5k samples) as the training corpus such that all graphs are connected DAGs.\footnote{Since the dataset was constructed automatically, we found about 10\% of the graphs to be disconnected or cyclic.} Following~\citet{madaan2021neural}, we represent graphs in DOT format~\cite{koutsofios1996drawing} as shown in Fig.~\ref{fig:temporal_example}. We find that the specifics of the graph representations do not matter much, as long as all the edges are concatenated in one particular ordering (either DFS, BFS or Topological order). We construct semantic negative graphs by randomly sampling a fraction of the edges and performing the following operations. If an edge relation is one of ``before'', ``after'' or ``simulatenous'', we replace it with any other relation from this set and if the relation is one of ``is included'' or ``includes'' we replace it with the other relation. Note that these perturbations will always lead to incorrect graphs because ``A before B'' implies that ``A after B'' or ``A simultaneous B'' do not hold. Finally, we construct positive graphs by randomly sampling a fraction of edges and replacing them using the following rules: (1) ``A before B'' with ``B after A'' and viseversa, (2) ``A simultaneous B'' with ``B simultaneous A'', (3) ``A includes B'' with ``B is included A''. Note that all these operations preserve the temporal meaning of the graph and are done in a way such that the perturbed graph continues to be a connected DAG. \begin{table}[] \centering \begin{tabular}{llll} \toprule Dataset & Train & Dev & Test \\ \midrule ExplaGraphs & 2368 & 398 & 400 \\ Temporal (Sampled) & 9531 & 953 & 949 \\\bottomrule \end{tabular} \caption{Train, validation and test split sizes of the two datasets. For Temporal Graph Generation, we randomly sample 1.3\% of the overall corpus \cite{madaan2021neural}.} \label{tab:dataset_stats} \end{table} \begin{table*}[t] \small \centering \begin{tabular}{lrrrrrr} \toprule & SA$\uparrow$ & StCA$\uparrow$ & SeCA$\uparrow$ & G-BS$\uparrow$ & GED$\downarrow$ & EA$\uparrow$ \\ \midrule T5-Base & \textbf{86.2} & 35.4 & 15.5 & 27.7 & 0.75 & 19.8 \\ T5-Large & \textbf{86.2} & 46.5 & 31.6 & 36.8 & 0.66 & 26.8 \\ \midrule Generate \& Refine & \textbf{86.2} & 46.8 & 34.4 & 37.2 & 0.66 & 27.2 \\ Pos Data Aug & \textbf{86.2} & 50.0 & 37.6 & 39.6 & 0.64 & 28.4 \\ Max-margin & \textbf{86.2} & 49.5 & \textbf{38.4} & 39.4 & 0.64 & 26.1 \\ Contrastive & \textbf{86.2} & \textbf{52.7} & 37.9 & \textbf{41.7} & \textbf{0.62} & \textbf{29.8} \\ \bottomrule \end{tabular} \caption{Comparison of our models with baseline T5 models across all metrics on ExplaGraphs dev set. } \label{tab:model_dev} \end{table*} \begin{table*}[t] \small \centering \begin{tabular}{lrrrrrr} \toprule & SA$\uparrow$ & StCA$\uparrow$ & SeCA$\uparrow$ & G-BS$\uparrow$ & GED$\downarrow$ & EA$\uparrow$ \\ \midrule BART-Base & \textbf{87.2} & 25.7 & 13.0 & 22.0 & 0.81 & 12.8 \\ BART-Large & \textbf{87.2} & 34.2 & 22.2 & 28.9 & 0.75 & 20.0 \\ Contrastive & \textbf{87.2} & \textbf{40.7} & \textbf{26.3} & \textbf{31.3} & \textbf{0.71} & \textbf{22.3} \\ \bottomrule \end{tabular} \caption{Effect of Contrastive Learning with BART on ExplaGraphs test set. } \label{tab:bart} \end{table*} \section{Experimental Setup} \label{appendix:setup} Table \ref{tab:dataset_stats} shows the number of train, validation and test samples of the two datasets we experiment with. We build our models on top of the Hugging Face transformers library \cite{wolf2019huggingface}.\footnote{\url{https://github.com/huggingface/transformers}} All models for the ExplaGraphs dataset\footnote{\url{https://github.com/swarnaHub/ExplaGraphs}} \cite{saha2021explagraphs} are trained with a batch size of $8$ and an initial learning rate of $3*10^{-5}$ for a maximum of $15$ epochs. The maximum input and output sequence lengths are both set to $150$. For the max-margin graph generation model, we set both the hyperparameters $\alpha$ (mixing ratio) and $\beta$ (margin) to $1.0$ while for the contrastive graph generation model, we set $\alpha$ to $0.1$. For the temporal graph generation task\footnote{\url{https://github.com/madaan/temporal-graph-gen}} \cite{madaan2021neural}, we train all models with a batch size of $4$ and an initial learning rate of $3*10^{-5}$ for a maximum of $10$ epochs. The maximum input and output sequence lengths are set to $512$ and $256$ respectively. On this task, the hyperparameters $\alpha$ and $\beta$ for the max-margin model are again set to $1.0$ while for the contrastive graph generation model, we set $\alpha$ to $0.2$. Across all models and tasks, graphs are generated using beam search decoding with a beam size of $4$. The batch size and learning rate are manually tuned in the range $\{4, 8, 16\}$ and \{$10^{-5}$, $2*10^{-5}$, $3*10^{-5}$\} respectively and the best models are chosen based on the respective validation set performance. Similarly, the mixing ratio hyperparameter $\alpha$ is manually tuned in the range $\{0.1, 0.2, 0.5, 1.0\}$. The random seed is set to $42$ in all our experiments. The total number of parameters in our models is similar to T5-Base (220M) or T5-Large (770M) depending on the base architecture. All our experiments are executed on a single A100 Nvidia GPU. Each epoch of the contrastive model has an average runtime of 30 mins for ExplaGraphs and 2.5 hours for Temporal Graph Generation. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/analysis6.pdf} \caption{An example of the Temporal Graph Generation Task \cite{madaan2020eigen} showing the source document, the target temporal graph and the corresponding DOT representation.} \label{fig:temporal_example} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/template.pdf} \caption{Interface for human evaluation of commonsense explanation graphs.} \label{fig:template} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/analysis2.pdf} \caption{Example of explanation graphs generated by different models. The baseline T5-generated graph is semantically incorrect (incoherent relations marked in dashed red) while our proposed models generate both structurally and semantically correct graphs.} \label{fig:qual2} \end{figure*} \section{Results} \label{appendix:results} Table \ref{tab:model_dev} shows the results of all models on the ExplaGraphs \cite{saha2021explagraphs} validation set. \new{\paragraph{Experiments with BART.} In Table~\ref{tab:bart}, we show the performance of BART~\cite{lewis2020bart} on ExplaGraphs~\cite{saha2021explagraphs} test set. Unsurprisingly, a larger BART model obtains a much higher StCA and SeCA compared to BART-Base. However, we find T5 to perform much better on this task. Applying contrastive learning on top of BART leads to improvements across all metrics, thereby showing our method's generalizability across different pre-trained language models.} \begin{table}[t] \small \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{lrrrrr} \toprule & StCA$\uparrow$ & SeCA$\uparrow$ & G-BS$\uparrow$ & GED$\downarrow$ & EA$\uparrow$ \\ \midrule Max-Margin & 56.7 & 43.5 & 48.6 & 0.57 & 30.5 \\ + Atomic & \textbf{58.2} & \textbf{45.0} & \textbf{49.9} & \textbf{0.56} & \textbf{30.9} \\\bottomrule \vspace{-10pt} \end{tabular}} \caption{Effect of fine-tuning with additional commonsense knowledge from Atomic.} \vspace{-5pt} \label{tab:effect_atomic} \end{table} \paragraph{Effect of Additional Commonsense Knowledge.} In Table~\ref{tab:effect_atomic}, we explore the impact of integrating additional commonsense knowledge to our \textit{Max-Margin} model. Specifically, we first fine-tune a T5 model on the facts based on ConceptNet relations from ATOMIC-2020~\cite{hwang2021comet}, a large-scale commonsense knowledge base. The fine-tuning objective is to predict the target concept given the source concept and the relation. Next, we fine-tune this model further on the end-task of graph generation which leads to small improvements in both StCA and SeCA. This suggests that better methods of inducing commonsense knowledge in these models can potentially lead to bigger gains with more semantically coherent graphs. \section{Human Evaluation} \label{appendix:human_eval} In Fig.~\ref{fig:template}, we show the interface for human verification of commonsense explanation graphs on Amazon Mechanical Turk. We select crowdworkers who are located in the US with a HIT approval rate higher than 96\% and at least 1000 HITs approved. Since graph evaluation is a challenging task, we first explain how to read the graphs and also provide clear guidelines for comparing the quality of the two graphs.\footnote{The payment for each HIT is 0.25\$ at the rate of 12-15\$ per hour.} \section{Examples of Generated Explanation Graphs} In Fig.~\ref{fig:qual2},~\ref{fig:qual3},~\ref{fig:qual4} and~\ref{fig:qual5}, we show various examples of explanation graphs generated by our models. In Fig. \ref{fig:qual2} and \ref{fig:qual3}, our proposed models improve upon the incorrect semantic relations from the T5 baseline graphs. Fig. \ref{fig:qual4} shows an example where all generated graphs, while different, are correct. Finally, Fig~\ref{fig:qual5} shows an example where although our proposed models improve the semantic aspect compared to the baseline graph, the generated graphs are disconnected and hence structurally incorrect. Overall, our quantitative results and human evaluation suggest that there is significant room for improvement on the task of commonsense explanation graph generation. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/analysis4.pdf} \caption{Example of explanation graphs generated by different models. The baseline T5-generated graph is semantically incorrect (incoherent relations marked in dashed red) while our proposed models generate both structurally and semantically correct graphs.} \label{fig:qual3} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/analysis5.pdf} \caption{Example of explanation graphs generated by different models. All models generate structurally and semantically correct graphs while the individual nodes and edges differ.} \label{fig:qual4} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{figures/analysis3.pdf} \caption{Example of explanation graphs generated by different models. T5 generates a semantically incorrect graph. Our models generate graphs, which while contain meaningful edges, are disconnected and hence are structurally incorrect.} \label{fig:qual5} \end{figure*}
{'timestamp': '2022-04-12T02:29:01', 'yymm': '2204', 'arxiv_id': '2204.04813', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04813'}
arxiv
\section{Conclusion} \label{sec:conclusion} GAN-based models are commonly adopted to generate high-quality EHR data. To tackle the challenges of generating EHR with GAN, we proposed {{MTGAN}} to generate time-series visit records with uncommon diseases. {{MTGAN}} can preserve temporal information as well as increase the generation quality of uncommon diseases in generated EHR by developing a temporally correlated generation process with a smooth conditional matrix. Our experimental results showed that the synthetic EHR data generated by {{MTGAN}} not only have better statistical properties, but also achieve superior ability than the state-of-the-art GAN models to improve the performance of predictive models on multiple tasks, especially for predicting uncommon diseases. In this work, we mainly focused on GAN models to generate diseases, i.e., multi-label generation. Therefore, one of the shortcomings of {{MTGAN}} is that it does not consider other feature types in EHR, such as procedures, medications, or lab tests. In the future, we plan to explore effective methods to generate real values including lab tests and vital signs of patients. Furthermore, we will utilize the GAN method to deal with missing values in the EHR data. \ifCLASSOPTIONcompsoc \section*{Acknowledgments} This work is supported in part by the US National Science Foundation under grants 1838730, 1948432, and 2047843. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation. \else \section*{Acknowledgment} \fi \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran} \section{Experimental Results} \label{sec:exp} \subsection{Statistical Evaluation} To evaluate the statistical difference between generated EHR data $\tilde{\mathcal{D}}$ and real data $\mathcal{D}$, we utilize visit-level GANs to generate 16,055 and 29,084 visits, and utilize patient-level GANs to generate 6,000 and 10,000 patients, when training with MIMIC-III and MIMIC-IV, respectively. The statistical evaluation results on these datasets are shown in Table~\ref{tab:stat_result}. For the generated disease types (GT), the results should be close to real disease types. All baselines can only generate less than 4,000 diseases, while {{MTGAN}} can generate close types to real data. The visit/patient-level Jensen-Shannon divergence (JSD$_v$, JSD$_p$) shows that {{MTGAN}} can synthesize a good EHR dataset in terms of the overall disease distribution, while the results of other baselines are not too bad. However, when considering uncommon diseases, we can conclude from the normalized distance (ND$_v$, ND$_p$) that {{MTGAN}} has better ability in generating diseases with low frequency than other baselines. This conclusion is further validated by the required sample number (RN) to generate all diseases. In this experiment, we keep generating samples until the disease type in the synthetic dataset $\tilde{\mathcal{D}}$ reaches the disease type in the real dataset $\mathcal{D}$. For all baselines, we stop at $10^7$ samples given that they cannot generate more uncommon diseases. However, {{MTGAN}} is able to generate all diseases only using 7,952 and 11,734 samples for MIMIC-III and MIMIC-IV, respectively. Although these sample numbers are larger than the real patient number in MIMIC-III and MIMIC-IV, the ability to generate uncommon diseases of {{MTGAN}} is verified. When comparing visit-level and patient-level distance of GANs for visit sequences, an important fact is that almost all models have lower scores for JSD$_v$ than JSD$_p$. It shows that retaining temporal correlation in visit sequences is harder than solely learning the disease distribution in single visits. In spite of this, we see that {{MTGAN}} has a minimal difference between JSD$_v$ and JSD$_p$ than nearly all baselines. It is worth noting that although T-CGAN also achieves a relative low distance, it has a large difference between visit-level and patient-level distance. We infer that T-CGAN does not keep temporal information in visit sequences, because it only specifies the time step of a visit while not considering previous visits. Therefore, we can conclude that {{MTGAN}} is able to generate visit sequences, and meanwhile preserve temporal correlations between adjacent visits. In summary, {{MTGAN}} can generate uncommon diseases as well as keep similar disease distribution to real EHR datasets. Meanwhile, {{MTGAN}} can generate visit sequences while considering temporal correlations between visits. \subsection{Analysis of GAN Training} \begin{figure} \centering \subfloat[MIMIC-III]{\includegraphics[width=\linewidth]{figs/history_mimic3}\label{fig:history_mimic3}} \\ \subfloat[MIMIC-IV]{\includegraphics[width=\linewidth]{figs/history_mimic4}\label{fig:history_mimic4}} \\ \subfloat{\includegraphics[width=\linewidth]{figs/history_legend}} \caption{The trend of generated disease types (left) and average disease number per visit (right) during training on MIMIC-III and MIMIC-IV.} \label{fig:history} \end{figure} To analyze the stability of training different GANs for generating EHR data, we plot the disease types and average disease number per visit during training on the MIMIC-III and MIMIC-IV datasets in \figurename~\ref{fig:history}. From the trend of disease types in the left figures of \figurename~\ref{fig:history}\subref{fig:history_mimic3} and \figurename~\ref{fig:history}\subref{fig:history_mimic4}, we notice that baseline GANs relying on the Wasserstein distance (CTGAN, EMR-WGAN, WGAN-GP, and T-CGAN) can generate over 2,000 disease types at the beginning of training. However, this number dramatically drops to 0 after a few iterations, and slowly increases during training. This phenomenon can also be reflected by the average disease number per visit in the right figures. The average disease number per visit of these GANs starts from a high value (over 1,000). Then this number decreases to 0 and increases around the real average disease number of MIMIC-III and MIMIC-IV, i.e., 13.06 and 13.38. We infer it is due to the instability of baseline GANs. In the beginning of training, the generator of baselines tend to generate zero diseases in order to get a lower Wasserstein distance, because of the high sparsity of the EHR data. An exception is RDP-CGAN. We infer it is because RDP-CGAN pre-trains the auto-encoder so that it can generate diseases in the beginning. On the contrary, GANs based on the binary classification (medGAN, TimeGAN) do not have such a phenomenon but they are unstable at a latter stage. Nevertheless, they converge at a lower number of disease types and have a higher Jensen-Shannon divergence and normalized distance. However, from \figurename~\ref{fig:history}, we can see that the generated disease types of {{MTGAN}} stabilize at a high number and are close to the real number of disease types in MIMIC-III (4,880) and MIMIC-IV (6,102). Furthermore, even though {{MTGAN}} is also based on the Wasserstein distance, the average disease number per visit does not dramatically drop, but gradually decreases to the real data. This makes {{MTGAN}} more stable and easier to train than baselines, in terms of adjusting the learning rate, batch size, and other key hyper-parameters. \begin{table} \centering \caption{Statistical results of {{MTGAN}} variants on MIMIC-III and MIMIC-IV.} \label{tab:ablation} \begin{tabular}{clccccc} \toprule & \textbf{Metrics} & {{M}}$_\text{h-}$ & {{M}}$_\text{c-}$ & {{M}}$_\text{dist}$ & {{M}}$_\text{trans}$ & {{MTGAN}} \\ \midrule \multirow{6}{*}{\rotatebox[origin=c]{90}{MIMIC-III}} & GT & 4,284 & 4,044 & 3,339 & 3,362 & \textbf{4,431} \\ & JSD$_v$ & 0.4167 & 0.1508 & 0.1414 & 0.1791 & \textbf{0.1344} \\ & JSD$_p$ & 0.4040 & 0.1534 & 0.1521 & 0.1846 & \textbf{0.1413} \\ & ND$_v$ & 0.7637 & 0.8467 & 0.9894 & 1.0244 & \textbf{0.6563} \\ & ND$_p$ & 0.7783 & 0.8388 & 0.9959 & 1.0038 & \textbf{0.6645} \\ & RN & 9,232 & $>10^7$ & 229,628 & 170,800 & \textbf{7,952} \\ \midrule \multirow{6}{*}{\rotatebox[origin=c]{90}{MIMIC-IV}} & GT & 5,622 & 4,548 & 4,588 & 4,330 & \textbf{5,677} \\ & JSD$_v$ & 0.3327 & 0.1910 & 0.1769 & 0.1599 & \textbf{0.1467} \\ & JSD$_p$ & 0.3264 & 0.2028 & 0.1935 & 0.1957 & \textbf{0.1649} \\ & ND$_v$ & 0.7711 & 0.9748 & 0.9460 & 1.0586 & \textbf{0.6705} \\ & ND$_p$ & 0.7961 & 0.9962 & 0.9783 & 1.0619 & \textbf{0.6843} \\ & RN & 40,850 & $>10^7$ & 1,488,966 & 91,530 & \textbf{11,734} \\ \bottomrule \end{tabular} \end{table} \subsection{Ablation Study} To study the effectiveness of important modules in {{MTGAN}}, we conduct ablation studies by removing or changing parts of the model. The variants of {{MTGAN}} are listed as follows: \begin{itemize}[leftmargin=*] \item {{M}}$_\text{h-}$: In the critic, we remove the hidden state in Equation~(\ref{eq:critic_cat}). In addition, we let the generator only output the probability but not the hidden state of GRU. \item {{M}}$_\text{c-}$: We remove the conditional matrix in the generator to verify the contribution of it to uncommon disease generation. As a result, the generated synthetic data are directly sampled from the GRU outputs. \item {{M}}$_{\text{dist}}$: In Equations~(\ref{eq:loss_d}) and (\ref{eq:loss_g}), we uniformly sample target diseases. In {{M}}$_{\text{dist}}$, we sample target diseases from the visit-level disease distribution in real EHR dataset to study the impact of sampling in the GAN training. \item {{M}}$_{\text{trans}}$: To test the effect of the GRU part in the generator of {{MTGAN}}, we replace $g_{\text{gru}}$ with a Transformer model. More specifically, we use a Transformer encoder module, including a positional encoding part and a masked self-attention part to generate diseases from $T$ noises. In the critic, we also remove the hidden state in Equation~(\ref{eq:critic_cat}), since the generator cannot output it for synthetic data. \end{itemize} \begin{table*} \centering \caption{Downstream task evaluation by pre-training Dipole and GRAM on synthetic data, fine-tuning on real training data. The results are reported on real test data. Note that ``w/o synthetic'' indicates that the model is trained using only real training data. We use w-$F_1$ (\%) for Diagnosis prediction, AUC (\%) for Heart failure and Parkinson's disease prediction. The synthetic data have equal sample numbers as real training data.} \label{tab:downstream} \begin{tabular}{clcccccc} \toprule & \multirow{2}{*}{\textbf{Models}} & \multicolumn{3}{c}{\textbf{Dipole}} & \multicolumn{3}{c}{\textbf{GRAM}} \\ \cmidrule(lr){3-5}\cmidrule(lr){6-8} \multicolumn{2}{c}{~} & Diagnosis & Heart Failure & Parkinson & Diagnosis & Heart Failure & Parkinson \\ \midrule \multirow{5}{*}{\rotatebox[origin=c]{90}{MIMIC-III}} & w/o synthetic & 19.35 & 82.08 & 68.80 & 21.52 & 83.55 & 73.81 \\ & w/ WGAN-GP & 20.02 (+3.46\%) & 82.67 (+0.72\%) & 69.11 (+0.45\%) & 22.48 (+4.46\%) & 84.06 (+0.61\%) & 74.29 (+0.65\%) \\ & w/ TimeGAN & 19.60 (+1.29\%) & 82.69 (+0.74\%) & 68.57 (-0.33\%) & 22.06 (+2.51\%) & 83.84 (+0.35\%) & 73.85 (+0.05\%) \\ & w/ T-CGAN & 20.38 (+5.32\%) & 83.38 (+1.58\%) & 69.33 (+0.77\%) & 22.30 (+3.62\%) & \textbf{84.22 (+0.80\%)} & 74.40 (+0.80\%) \\ & w/ {{MTGAN}} & \textbf{20.48 (+5.84\%)} & \textbf{83.41 (+1.62\%)} & \textbf{70.45 (+2.40\%)} & \textbf{22.57 (+4.88\%)} & 84.19 (+0.77\%) & \textbf{75.06 (+1.69\%)} \\ \midrule \multirow{5}{*}{\rotatebox[origin=c]{90}{MIMIC-IV}} & w/o synthetic & 23.69 & 88.69 & 72.59 & 23.50 & 89.61 & 78.51 \\ & w/ WGAN-GP & 24.17 (+2.03\%) & 88.78 (+0.10\%) & 72.81 (+0.30\%) & 23.68 (+0.77\%) & 89.81 (+0.22\%) & 78.81 (+0.38\%) \\ & w/ TimeGAN & 23.62 (-0.30\%) & 88.63 (-0.07\%) & 72.55 (-0.06\%) & 23.61 (+0.47\%) & 89.68 (+0.08\%) & 78.56 (+0.06\%) \\ & w/ T-CGAN & 24.60 (+3.84\%) & 89.04 (+0.39\%) & 72.76 (+0.23\%) & 23.75 (+1.06\%) & 89.94 (+0.37\%) & 78.90 (+0.50\%) \\ & w/ {{MTGAN}} & \textbf{24.74 (+4.43\%)} & \textbf{89.11 (+0.47\%)} & \textbf{73.16 (+0.79\%)} & \textbf{24.09 (+2.51\%)} & \textbf{90.05 (+0.49\%)} & \textbf{79.35 (+1.07\%)} \\ \bottomrule \end{tabular} \end{table*} We report the statistical results of {{MTGAN}} variants in Table~\ref{tab:ablation}. Comparing {{M}}$_\text{h-}$ and {{MTGAN}}, we notice both JSD and ND have a large increase, but it can still generate all disease types within a small sample number. However, after removing the conditional matrix, {{M}}$_\text{c-}$ cannot generate all disease types with $10^7$ generated samples. We can conclude that distinguishing hidden states in the critic is able to improve the quality of synthetic EHR data in terms of the disease distribution, and the conditional matrix helps to learn the distribution of uncommon diseases. When comparing the results between {{M}}$_{\text{dist}}$ and {{MTGAN}}, we notice that the JSD does not have a large difference, but the ND of {{M}}$_{\text{dist}}$ increases a lot. Additionally, {{M}}$_{\text{dist}}$ requires more samples to generate all disease types. We conjecture it is because uncommon diseases have low frequencies and therefore occur less in the synthetic data when sampling from the visit-level disease distribution. This also leads to a high normalized distance and more samples to generate all disease types. The last comparison is replacing GRU in the generator with a Transformer encoder. Although Transformer is effective and has gained great success in natural language processing, it does not achieve superior performance to GRU. We infer that it is because the the visit sequences in MIMIC-III and MIMIC-IV are not sufficiently long and hence GRU can adequately capture the temporal features of EHR data. Furthermore, we think even with positional encoding, it is still hard to learn temporal information given that the inputs of all time steps are noises. In summary, we conclude that both the hidden state critique and the conditional matrix contribute to the EHR data generation in terms of overall disease distributions and especially uncommon diseases. \begin{figure*} \centering \subfloat[Dipole on MIMIC-III]{\includegraphics[width=0.49\linewidth]{figs/dipole_mimic3}\label{fig:dipole_mimic3}} \hfill \subfloat[GRAM on MIMIC-III]{\includegraphics[width=0.49\linewidth]{figs/gram_mimic3}\label{fig:gram_mimic3}} \\ \subfloat[Dipole on MIMIC-IV]{\includegraphics[width=0.49\linewidth]{figs/dipole_mimic4}\label{fig:dipole_mimic4}} \hfill \subfloat[GRAM on MIMIC-IV]{\includegraphics[width=0.49\linewidth]{figs/gram_mimic4}\label{fig:gram_mimic4}} \\ \subfloat{\includegraphics[width=0.5\linewidth]{figs/downstream_legend}} \caption{Downstream task evaluation by training Dipole and GRAM with different ratios of synthetic data over real training data.} \label{fig:downstream} \end{figure*} \subsection{Downstream Task Evaluation} In this experiment, we evaluate the synthetic data of GANs for patient-level generation, i.e., WGAN-GP, TimeGAN, T-CGAN, and {{MTGAN}}. As we mentioned in Section~\ref{sec:metrics}, we select three temporal prediction tasks as the downstream tasks: Diagnosis prediction, heart failure prediction, and Parkinson's disease prediction. Here, we choose two predictive models as baselines of downstream tasks: \begin{itemize}[leftmargin=*] \item Dipole~\cite{ma2017dipole}: It is a bi-directional RNN with attention methods to predict diagnoses. \item GRAM~\cite{choi2017gram}: It is an RNN-based model using disease domain knowledge to predict all diagnoses and heart failure. \end{itemize} We first train Dipole and GRAM only using the training data of MIMIC-III and MIMIC-IV as baselines (w/o synthetic). Then, we generate synthetic EHR that are trained with WGAN-GP, TimeGAN, T-CGAN, and {{MTGAN}}, respectively. Here, the synthetic data have equal sample numbers to real training data. Next, we pre-train a new Dipole and GRAM using these synthetic data, fine-tune them using real training data, and finally test them on real test data. The experimental results including baseline results, pre-training and fine-tuning results, and their increments are shown in Table~\ref{tab:downstream}. In this table, the synthetic data can enhance the predictive models on almost all tasks, among which {{MTGAN}} has the largest improvement on the diagnosis prediction. We infer that the synthetic EHR data provide more samples especially samples with uncommon diseases, so that the predictive models can provide a better prediction for them. Additionally, compared to other GANs, {{MTGAN}} has the most predominant results on the Parkinson's disease prediction. It further proves that {{MTGAN}} can learn a better distribution for uncommon diseases and boost downstream tasks especially related to these uncommon diseases. In Table~\ref{tab:downstream}, we pre-train Dipole and GRAM on the synthetic data that have an equal sample number to real training data. In addition, we conduct more experiments by adopting different sample numbers of synthetic data in pre-training. Here, we set the ratios of synthetic data over real training data as $\{0.5, 1, 1.5, 2\}$ to explore the impact of the synthetic data amount during pre-training on downstream tasks. The results are illustrated in \figurename~\ref{fig:downstream}. Each predictive model is tested on three tasks with every dataset. In general, with the growth of pre-training data, we notice that the w-$F_1$ and AUC of prediction also show an increasing trend. It shows that these GAN models can learn effective disease distributions in EHR data to some extent. It is still worth noting that {{MTGAN}} can generate synthetic EHR data that are more beneficial to downstream tasks than other GANs, especially the Parkinson's disease prediction. Therefore, we may conclude that the proposed {{MTGAN}} can generate EHR data that have more accurate disease distribution and more advantages in boosting downstream tasks. \section{Introduction}\label{sec:introduction}} \IEEEPARstart{T}{he} application of electronic health records (EHR) in healthcare facilities not only automates access to key clinical information of patients, but also provides valuable data resources for researchers. To analyze EHR data, deep learning has achieved great success on various tasks, including representation learning for patients and medical concepts~\cite{zhang2018patient2vec, lu2021collaborative, xu2016patienttkde}, predicting health events such as diagnoses and mortality~\cite{darabi2020taper, choi2017gram, lu2021self, lu2021context, an2021predictiontkde}, clinical note analysis~\cite{huang2019empirical}, privacy protection~\cite{kamran2011informationtkde, ma2021datatkde}, and phenotyping~\cite{bai2018ehr, song2018attend, yin2020learningtkde}. Although EHR data are significant in healthcare applications, it is typically arduous for researchers to access them. On the one hand, most EHR data are not publicly available because they contain sensitive clinical information of patients, such as demographic features and diagnoses. On the other hand, some public EHR datasets including MIMIC-III~\cite{johnson2016mimic} and eICU~\cite{pollard2018eicu} only have limited samples and may not be suitable for large-scale deep learning. Therefore, the limited EHR data have become a bottleneck of data-driven healthcare studies. \begin{figure} \centering \subfloat[Visit-level]{\includegraphics[scale=0.8]{figs/intro_a}\label{fig:intro_a}} \hfill \subfloat[Patient-level]{\includegraphics[scale=0.8]{figs/intro_b}\label{fig:intro_b}} \caption{Visit-level data generation v.s. patient-level data generation. 1 or 0 in the multi-label diagnosis vector represents the occurrence of the corresponding disease in this visit. Here, \textit{Appendicitis} is an uncommon disease.} \label{fig:intro} \end{figure} Recently, generative adversarial networks (GANs)~\cite{goodfellow2014generative} have been successful in high-quality image generation. Compared with conventional generative models such as autoencoder and variational autoencoder~\cite{kingma2013auto}, GANs are able to generate more realistic data~\cite{gui2021reviewtkde}. Therefore, GANs have also been applied to generate EHR to alleviate the limited data issue~\cite{choi2017generating,baowaly2019synthesizing,zhang2020ensuring}. However, when generating EHR using existing GANs, there are still several challenges: \begin{table*} \centering \caption{Comparison of GANs for generating EHR.} \label{tab:comp} \begin{tabular}{l|cccccc|c} \toprule \textbf{Properties} & \mcell{\textbf{medGAN}}{\cite{choi2017generating}} & \mcell{\textbf{CTGAN}}{\cite{xu2019modeling}} & \mcell{\textbf{EMR-WGAN}}{\cite{zhang2020ensuring}} & \mcell{\textbf{RDP-CGAN}}{\cite{torfi2022differentially}} & \mcell{\textbf{TimeGAN}}{\cite{yoon2019time}} & \mcell{\textbf{T-CGAN}}{\cite{ramponi2018t}} & \mcell{\textbf{{{MTGAN}}}}{(Proposed)} \\ \midrule Time-series data generation &$\times$& $\times$ & $\times$ & $\times$ &\checkmark&\checkmark&\checkmark\\ Keeping temporal correlations &$\times$& $\times$ & $\times$ & $\times$ &\checkmark& $\times$ &\checkmark\\ Uncommon diseases generation &$\times$&\checkmark& $\times$ & $\times$ & $\times$ & $\times$ &\checkmark\\ Stable training with sparse EHR &$\times$& $\times$ & $\times$ & $\times$ & $\times$ & $\times$ &\checkmark\\ \bottomrule \end{tabular} \end{table*} \begin{enumerate}[wide] \item \textbf{Generating time-series EHR data}. In EHR data, a patient can have multiple visits. However, most existing GANs for generating EHR, such as medGAN~\cite{choi2017generating}, EMR-WGAN~\cite{zhang2020ensuring}, Smooth-GAN~\cite{rashidian2020smooth}, and RDP-CGAN~\cite{torfi2022differentially}, can only generate independent visits instead of time-series data. It is because traditional GANs designed for image generation only generate one image given a noise input. Although it is possible to combine generated visits randomly as a sequence, this method cannot preserve temporal information to disclose patient-level features. \figurename~\ref{fig:intro} shows an example of visit-level data generation and patient-level data generation. In \figurename~\ref{fig:intro}\subref{fig:intro_a}, it generates diagnoses for only one visit. An ideal sequence generation is described in \figurename~\ref{fig:intro}\subref{fig:intro_b}. The diagnoses in two close visits are similar and related, such as hypertension and heart failure. Recently, SeqGAN~\cite{yu2017seqgan} and TimeGAN~\cite{yoon2019time} are proposed to generate sequences as a simulation of sentences. However, unlike words in a sentence, each time step (visit) of EHR contains multi-label variates (i.e., diagnoses shown in \figurename~\ref{fig:intro}). Therefore, how to generate multi-label time-series EHR with temporal correlations still remains a challenge. \item \textbf{Generating uncommon diseases}. Based on the statistics of a well-known public EHR dataset, MIMIC-III, some diseases are frequently diagnosed, such as hypertension and diabetes, while some other diseases such as tuberculosis are less common. Although these diseases do not frequently occur, it is still valuable to study them to provide better care plans for patients,~e.g., analyzing occurrence patterns to improve diagnosis prediction accuracy. Despite the ability of existing GANs to generate time-series EHR data, it is still challenging for them to learn a good distribution for uncommon diseases. Instead of only generating frequent diseases shown \figurename~\ref{fig:intro}\subref{fig:intro_a}, we need to find effective ways to generate uncommon diseases, such as \textit{Appendicitis} in \figurename~\ref{fig:intro}\subref{fig:intro_b} given highly imbalanced EHR datasets. \item \textbf{Evaluating synthetic EHR data}. As we mentioned, it is common that EHR datasets have an imbalanced disease distribution. However, when applying traditional evaluation metrics for synthetic images such as Kullback-Leibler divergence and Jensen-Shannon divergence to EHR data, they do not give enough attention to diseases with low frequency. As a result, we may still get low divergence between the distribution of real EHR data and synthetic EHR data when they are close in terms of high-frequent diseases. Therefore, it is still necessary to explore appropriate metrics to evaluate the quality of synthetic EHR data, especially for uncommon diseases. \end{enumerate} To address these challenges, we propose {{MTGAN}}, a \textbf{m}ulti-label \textbf{t}ime-series generation model using a conditional GAN to simultaneously generate time-series diagnoses and uncommon diseases. In the generator, we first propose to recursively generate patient-level diagnosis probabilities with a gated recurrent unit (GRU). Then, to generate uncommon diseases, we adopt the idea of the conditional vector in CTGAN~\cite{xu2019modeling} and broadcast this vector into a smooth conditional matrix throughout all visits in sequences. In the critic of {{MTGAN}}, we propose to discriminate real and synthetic samples by giving scores to both the data and their temporal features. Finally, we design a training strategy to optimize {{MTGAN}} by sampling discrete diseases from patient-level probabilities to stabilize the training process. The model computes temporal features of real data by pre-training a GRU with the task of next visit prediction. The contributions of this work are summarized as follows: \begin{itemize}[leftmargin=*] \item We propose a time-series generative adversarial network {{MTGAN}} to generate multi-label patient-level EHR data. The generator, critic, and training strategy of {{MTGAN}} are able to simultaneously generate realistic visits and preserve temporal correlations across different visits. \item We propose a smooth conditional matrix to cope with the imbalanced disease distribution in EHR data and improve the generation quality of uncommon diseases. \item We use multiple statistical metrics for synthetic EHR evaluation and design a normalized distance especially for uncommon diseases. Meanwhile, we verify that the synthetic EHR generated by {{MTGAN}} can boost deep learning models on temporal health event prediction tasks. \end{itemize} The remaining parts of this paper are listed below: We first discuss related work about EHR generation in Section~\ref{sec:related_work}. Then, we formulate the EHR generation problem in Section~\ref{sec:problem} and introduce the details of {{MTGAN}} in Section~\ref{sec:method}. Next, the experimental setups and results are demonstrated in Sections~\ref{sec:exp_setup} and \ref{sec:exp}, respectively. Finally, we conclude this paper and discuss the future work in Section~\ref{sec:conclusion}. \section{Problem Formulation} \label{sec:problem} In this section, we describe the EHR dataset in detail and formally define the research problem, EHR generation. In addition, we list important symbols and their corresponding explanations in Table~\ref{tab:symbols}. An EHR dataset consists of visit sequences of patients to healthcare facilities. A visit contains different data types, such as diagnoses, procedures, lab tests, and clinical notes. An important feature in EHR data is diagnoses represented by disease codes, such as ICD-9~\cite{icd9cm} or ICD-10~\cite{icd10}. In this work, we focus on generating diagnoses, and the research questions is formulated into a time-series multi-label generation problem. To describe an EHR dataset, we first give the following definitions: \begin{definition}[Visit] A visit contains one or multiple diagnoses. The $t$-th visit is denoted by a binary vector $\mathbf{x}_t \in \{0, 1\}^d$, where $d$ is the number of distinct diseases, i.e., disease types in the EHR dataset. $\mathbf{x}_t^i = 1$ means the disease $i$ is diagnosed in the $t$-th visit. \end{definition} \begin{definition}[Visit sequence] Given a patient $u$, the visit sequence of this patient is denoted as $\boldsymbol{x}_u = (\mathbf{x}_1, \mathbf{x}_2, \dots, \mathbf{x}_T) \in \{0, 1\}^{d \times T}$, where $T$ is the sequence length. \end{definition} \begin{definition}[EHR dataset] An EHR dataset $\mathcal{D}$ is a collection of visit sequences: $\mathcal{D} = \{\boldsymbol{x}_u \mid u \in \mathcal{U}\}$, where $\mathcal{U}$ is a patient set. \end{definition} Based on these descriptions of EHR data, the EHR generation problem is defined as below: \begin{definition}[Problem formulation] Given a real EHR dataset $\mathcal{D}$, we aim to generate a synthetic EHR dataset $\tilde{\mathcal{D}}$ such that $\tilde{\mathcal{D}}$ has the following properties: \begin{enumerate} \item The disease distribution of $\tilde{\mathcal{D}}$ is close to $\mathcal{D}$. \item The disease type in $\tilde{\mathcal{D}}$ is similar to $\mathcal{D}$ when $|\mathcal{D}| = |\tilde{\mathcal{D}}|$. \end{enumerate} Here, $|\cdot|$ denotes the number of data samples. \end{definition} \section{The Proposed {MTGAN}~Model} \label{sec:method} In this section, we introduce some preliminaries about GANs and discuss the proposed {{MTGAN}} to generate discrete diagnoses in electronic health records, including detailed challenges in generating EHR data and our proposed generator, critic, and the training strategy. The model overview of {{MTGAN}} is shown in~\figurename{~\ref{fig:system}}. \begin{figure} \centering \includegraphics[width=\linewidth]{figs/system} \caption{The model overview of {{MTGAN}}. The generator uses a GRU to obtain patient-level diagnosis probabilities with hidden states and use the probabilities to calculate attention scores as a conditional matrix to generate the target disease. The critic calculates a Wasserstein distance by considering both synthetic/real samples and their temporal features.} \label{fig:system} \end{figure} \subsection{Preliminaries of Generative Adversarial Networks} In a typical framework of generative adversarial networks (GANs), there exists a generator $G$ that takes a noise $\boldsymbol{z} \in \mathbb{R}^{s}$ from a random distribution as the input and generates a synthetic data sample $\tilde{\boldsymbol{x}} = G(\boldsymbol{z})$. The discriminator $D$ is another key part of GANs. It tries to distinguish real data samples $\boldsymbol{x}$ from generated samples $\tilde{\boldsymbol{x}}$. The mechanism of GANs can be simulated as a min-max game: the generator tries to generate realistic samples to deceive the discriminator and let it think $\tilde{\boldsymbol{x}}$ is real; the discriminator conducts a binary classification and tries to classify all real and synthetic samples correctly. A vanilla GAN is optimized using the following loss function: \begin{align} \underset{G}{\min}~\underset{D}{\max}~\underset{{\boldsymbol{x} \sim p_{\boldsymbol{x}}}}{\mathbb{E}}[\log{D(\boldsymbol{x})}] + \underset{{\boldsymbol{z} \sim p_{\boldsymbol{z}}}}{\mathbb{E}}[\log{(1 - D(G(\boldsymbol{z})))}]. \end{align} However, such a simple GAN is sometimes hard to train due to the vanishing gradient problem, mode collapse, and failure to converge. To address these issues, Arjovsky \textit{et al.}~\cite{arjovsky2017wasserstein} use the Wasserstein distance in WGAN to train the generator and discriminator (called a critic in WGAN). Gulrajani \textit{et al.}~\cite{gulrajani2017improved} introduce a gradient penalty for training the critic in WGAN-GP. The updated loss functions to train the generator and critic respectively are as follows: \begin{align} L_D =&~\underset{{\boldsymbol{z} \sim p_{\boldsymbol{z}}}}{\mathbb{E}}[D(G(\boldsymbol{z}))] - \underset{{\boldsymbol{x} \sim p_{\boldsymbol{x}}}}{\mathbb{E}}[D(\boldsymbol{x})] \notag \\ &~+ \lambda \underset{{\hat{\boldsymbol{x}} \sim p_{\hat{\boldsymbol{x}}}}}{\mathbb{E}}\left[\left(\|\Delta_{\hat{\boldsymbol{x}}}D(\hat{\boldsymbol{x}})\|_2 - 1\right)^2\right], \\ L_G =&~-\underset{{\boldsymbol{z} \sim p_{\boldsymbol{z}}}}{\mathbb{E}}[D(G(\boldsymbol{z}))], \end{align} where $L_G$ and $L_D$ are the losses for the generator and critic, respectively; $\lambda$ is a coefficient for the gradient penalty; $\hat{\boldsymbol{x}} = \epsilon \boldsymbol{x} + (1 - \epsilon)\tilde{\boldsymbol{x}}$, $\epsilon \sim \text{U}[0, 1]$ is sampled from a uniform distribution; $\Delta$ denotes the derivation operation; and $\|\cdot\|_2$ means $\ell^2$-norm. In these two loss functions, $D(\cdot)$ calculates a critic score for an input. It tries to maximize the score for real data and minimize the score for synthetic data. It turns the binary classification of the original GAN into a regression problem. By introducing Wasserstein distance and gradient penalty, training GAN can be more stable. Therefore, similar to EMR-WGAN~\cite{zhang2020ensuring} and Smooth-GAN~\cite{rashidian2020smooth}, we also introduce the gradient penalty in the training of WGAN. \subsection{Generator} \label{sec:generator} As we discussed before, to generate realistic EHR samples, we must address the following specific challenges: \begin{enumerate}[label=\textbf{C\arabic*:}, ref=\textbf{C\arabic*}] \item How to incorporate temporal features of visit sequences to increase the correlation of adjacent visits?\label{challenge_gc1} \item How to generate very uncommon diseases in the real EHR dataset $\mathcal{D}$ with an unbiased distribution?\label{challenge_gc2} \end{enumerate} \subsubsection{Temporally-Correlated Probability Generation} As proposed in TimeGAN~\cite{yoon2019time}, when generating sequences, an intuitive method is using recurrent neural networks (RNN). In each time step, the input of the RNN cell is a random noise and the hidden state passed from the previous time step. The output of each time step is a new hidden state. We can use the hidden state to generate each visit and combine all visits as a sequence. However, we think that using noises to generate visits for every time step may somewhat bring uncontrollable randomness and weaken the temporal correlation between adjacent visits. We believe an optimized generator is able to generate the entire sequence given a single noise vector at the beginning of the sequence. Similar to the temporal health event prediction task studied in GRAM~\cite{choi2017gram}, CGL~\cite{lu2021collaborative}, and Chet~\cite{lu2021context}, a good generator should predict (generate) the diagnoses in the next visit, given all previous visits. Therefore, based on this idea, we propose to recursively generate the visit sequence from a single noise vector $\boldsymbol{z}$, in order to increase the temporal correlation of adjacent visits, i.e., the challenge \ref{challenge_gc1}. Given a random noise vector $\boldsymbol{z} \in \mathbb{R}^s$ and a visit length $T$, since the disease values in each visit is 0 or 1, we first generate the disease probability $\mathbf{P}_1$ in the first visit by decoding the noise vector: \begin{align} \mathbf{P}_1 = \sigma(\mathbf{W}\boldsymbol{z}) \in \mathbb{R}^d. \end{align} Here, $\mathbf{W} \in \mathbb{R}^{d \times s}$ is the weight to project the noise into the visit space. $\sigma$ is the sigmoid function. After having the first visit, we can recursively generate the disease probability of remaining visits using a gated recurrent unit (GRU)~\cite{chung2014empirical} $g_{\text{gru}}$: \begin{align} \tilde{\mathbf{h}}_{t} &= g_{\text{gru}}(\mathbf{P}_t, \tilde{\mathbf{h}}_{t - 1}) \in \mathbb{R}^s, \\ \mathbf{P}_{t + 1} &= \sigma(\mathbf{W}\tilde{\mathbf{h}}_{t}) \in \mathbb{R}^{d}. \end{align} Here $\tilde{\mathbf{h}}_t$ denotes the hidden state of GRU at the time step $t$. We set $\tilde{\mathbf{h}}_0 = \mathbf{0}$ and set the noise dimension to be the same as hidden units of GRU, because we regard the noise vector as the initial hidden state. Next, we use GRU to calculate the hidden state of the time step $t$ using the hidden state of $t - 1$ and the generated visit probability $\mathbf{P}_t$. Then, we use the same decoding for $\boldsymbol{z}$ to generate $\mathbf{P}_{t + 1}$ for the visit $t + 1$. Finally, we combine all the generated disease probabilities as a patient-level distribution $\mathbf{P}$ for a synthetic EHR data sample: $\mathbf{P} = (\mathbf{P}_1, \mathbf{P}_2, \dots, \mathbf{P}_T) \in \mathbb{R}^{d \times T}$. \subsubsection{Smooth Conditional Matrix} After generating the patient-level diagnosis probabilities, we need to address the challenge of generating uncommon diseases, i.e., \ref{challenge_gc2}. To deal with highly imbalanced tabular data, CTGAN~\cite{xu2019modeling} is proposed to use conditional vectors to guide the GAN training process. More specifically, CTGAN first specifies a category for a tabular feature as the target category. Then, it uses a conditional vector where the corresponding entry for the target category is 1. Finally, it concatenates the conditional vector with the noise vector as the generator input to generate samples that belong to the target category. Inspired by CTGAN, we aim to specify a target disease and adopt the conditional vector to generate a visit sequence that contains the target disease. However, CTGAN is designed for non-sequential data. For a visit sequence, the target disease may appear in one or multiple visits. If we directly concatenate the conditional vector with the noise vector, this input will have the highest impact on the first visit and a decreasing impact on the remaining visits, due to the characters of RNN-based models. As a result, it is highly possible that this disease only appears in the first visit. If we concatenate the conditional vector for all $\mathbf{P}_t$, the generator may output a visit sequence where each visit contains the target disease. To avoid these extreme cases, we propose to smooth the conditional vector into a conditional matrix $\mathbf{c} \in \mathbb{R}^{d \times T}$ for all visits. First, we apply a location-based attention method~\cite{luong2015effective} to the generated probability to broadcast the target disease $i$ into a probability distribution (attention score) for all visits: \begin{align} v_t = \mathbf{W}_v\mathbf{P}_t \in \mathbb{R}, ~\text{where}~t \in \{1, 2, \dots, T\}, \end{align} \begin{align} \text{score}_t = \frac{e^{v_t}}{\sum_{\tau=1}^{T}{e^{v_{\tau}}}}. \end{align} Here, $\mathbf{W}_v \in \mathbb{R}^{1 \times d}$ is an attention weight, and $\sum_{t=1}^{T}{\text{score}_t} = 1$. After calculating the score for each visit, we create a conditional matrix $\mathbf{c} \in \mathbf{0}^{d \times T}$, and set the entry $\mathbf{c}_{i, t}$ corresponding to the target disease $i$ and visit $t$ as $\text{score}_t$: \begin{align} \mathbf{c}_{i, t} = \text{score}_t. \end{align} Then, we use $\mathbf{c}$ to calibrate the generated probability by adding $\mathbf{c}$ to $\mathbf{P}$ and get a calibrated probability $\tilde{\mathbf{P}}$: \begin{align} \tilde{\mathbf{P}} = \max{(1, \mathbf{P} \oplus \mathbf{c})} \in \mathbb{R}^{d \times T}. \end{align} Here, $\oplus$ denotes an element-wise sum of two matrices. We also clip each entry of $\tilde{\mathbf{P}}$ to make sure it is no greater than 1. In this way, the target disease is smoothed to all $T$ visits. Therefore, the conditional matrix can increase the probability of target diseases and let the uncommon diseases gain more exposure. In summary, given a noise vector $\boldsymbol{z}$ and a target disease $i$, the generator $G$ is able to generate a calibrated probability distribution $\tilde{\mathbf{P}}$ for diseases of a visit sequence: $\tilde{\mathbf{P}} = (\tilde{\mathbf{P}}_1, \tilde{\mathbf{P}}_2, \dots, \tilde{\mathbf{P}}_T) = G(\boldsymbol{z}, i)$. We will discuss how to generate discrete diagnoses in Section~\ref{sec:training}. \subsection{Critic} For the critic distinguishing real and fake EHR data, there is still a specific challenge to be addressed to improve the quality of synthetic samples: \begin{enumerate}[label=\textbf{C\arabic*:}, ref=\textbf{C\arabic*}, resume] \item How to calculate a sequential Wasserstein distance for real and synthetic visit sequences? \label{challenge_dc1} \end{enumerate} Given a visit sequence, an optimized critic should consider two aspects to determine whether this sequence is real or not. The first is whether each visit in a sequence is real. The second is whether this visit sequence is able to reflect temporally-correlated characters. These two aspects are intuitive because a visit sequence looks real only if each independent visit looks real. Furthermore, even if each visit looks real, the entire sequence may not be real. For example, we exchange two visits from two different patients or from the same patient. Even though each visit is real, the critic should still detect the abnormal visit sequence if the two exchanged visits are largely different. Based on the above analysis, we propose a \textbf{\textit{sequential critique}} that can simultaneously distinguish whether individual visits are real and whether the entire sequence are real. Given an input sequence $\boldsymbol{x} = (\mathbf{x}_1, \mathbf{x}_2, \dots, \mathbf{x}_T) \in \{0, 1\}^{d \times T}$ and the temporal features of this sequence $\mathbf{H} = (\mathbf{h}_1, \mathbf{h}_2, \dots, \mathbf{h}_T) \in \mathbb{R}^{d \times T}$ that correspond to each visit, the critic first concatenates the diagnosis vector $\mathbf{x}_t$ and temporal feature vector $\mathbf{h}_t$ for each visit. Then it uses a multi-layer perceptron (MLP) to calculate a critic score for this visit. Finally, the score $r$ for the sequence is an average of all visits. This process can be summarized as follows: \begin{align} \mathbf{m}_t = \mathbf{x}_t~||~\mathbf{h}_t \in \mathbb{R}^{d + s}, \label{eq:critic_cat} \end{align} \begin{align} r = \frac{1}{T}{\sum_{t = 1}^{T}{\text{MLP}(\mathbf{m}_t)}} \in \mathbb{R}. \end{align} Here, $||$ denotes the concatenation operation. In this equation, We use the average of all visits because we hypothesize $\mathbf{m}_t$ contains the temporal feature of each visit and therefore is capable of distinguishing time-series data. In this way, the critic can simultaneously consider individual visits and the temporal correlation of adjacent visits. Note that, the visit sequence $\boldsymbol{x}$ can be either a real or a generated sequence. In summary, given an input sequence $\boldsymbol{x}$ and the temporal features $\mathbf{H}$ of $\boldsymbol{x}$, the critic $D$ computes a score for this sequence: $r = D(\boldsymbol{x}, \mathbf{H})$. \subsection{Training Strategy} \label{sec:training} After defining the generator and the critic, there are still two remaining problems when generating diseases and training the critic with real/synthetic samples and temporal features: \begin{enumerate}[leftmargin=*] \item How to get temporal features of real samples? \item How to obtain discrete diagnoses from the generated probability distribution? \end{enumerate} \subsubsection{Temporal Feature Pre-training } For the first problem, when generating the probability distribution, we have already got the hidden state $\tilde{\mathbf{h}}_t$ for each generated visit. We conjecture that if the generator is optimized, the distribution of hidden state for generated visits should also be consistent with real samples. Therefore, we design a prediction task to pre-train a base GRU to calculate the hidden state for real samples. Given a real visit sequence $\boldsymbol{x} = (\mathbf{x}_1, \mathbf{x}_2, \dots, \mathbf{x}_T) \in \{0, 1\}^{d \times T}$, we aim to use a GRU $g'_{\text{gru}}$ that has an identical structure to $g_{\text{gru}}$ to predict the next visit for each $\mathbf{x}_t$ in $\boldsymbol{x}$. To do this, we first transform $\boldsymbol{x}$ into a feature sequence $(\mathbf{x}_1, \mathbf{x}_2, \dots, \mathbf{x}_{T - 1}) \in \{0, 1\}^{d \times (T - 1)}$ and a label sequence $(\mathbf{y}_1, \mathbf{y}_2, \dots, \mathbf{y}_{T - 1}) \in \{0, 1\}^{d \times (T - 1)}$, where $\mathbf{y}_t = \mathbf{x}_{t + 1}$. We then use the $g'_{\text{gru}}$ to calculate the hidden state $\mathbf{h}_t$ for $\mathbf{x}_t$ and predict the next visit $\hat{\mathbf{y}}_t$: \begin{align} \mathbf{h}_t &= g'_{\text{gru}}(\mathbf{x}_t, \mathbf{h}_{t - 1}) \in \mathbb{R}^s, \\ \hat{\mathbf{y}}_{t} &= \sigma(\mathbf{W}'\mathbf{h}_{t}) \in \mathbb{R}^{d}. \end{align} Here, we also set $\mathbf{h}_0 = \mathbf{0}$. To pre-train the $g'_{\text{gru}}$, we use a binary cross-entropy loss for a single visit prediction, and calculate the sum of all visits as the final loss $L_{\text{pre}}$: \begin{align} L_{\text{pre}} = \sum_{t = 1}^{T}{\sum_{i = 1}^{d}{\mathbf{y}_i\log{\hat{\mathbf{y}}_i}} + (1 - \mathbf{y}_i)\log{(1 - \hat{\mathbf{y}}_i)}} \end{align} After getting the pre-trained $g'_{\text{gru}}$, we freeze its parameters and use it to calculate the temporal features $\mathbf{H} = (\mathbf{h}_1, \mathbf{h}_2, \dots, \mathbf{h}_T) = g'_{\text{gru}}(\boldsymbol{x}) \in \mathbb{R}^{d \times T}$ for real samples in the critic. For the synthetic data, we let the generator $G$ return both the probability $\tilde{\mathbf{P}}$ and the hidden state $\tilde{\mathbf{H}} = (\tilde{\mathbf{h}}_1, \tilde{\mathbf{h}}_2, \dots, \tilde{\mathbf{h}}_T) \in \mathbb{R}^{d \times T}$: $(\tilde{\mathbf{P}}, \tilde{\mathbf{H}}) = G(\boldsymbol{z}, i)$. \subsubsection{Discrete Disease Sampling} In Section~\ref{sec:generator}, our generator outputs a probability distribution of visit sequences. When training the generator, it is reasonable to directly feed the probability distribution to the critic because we aim to let the generator increase the probability of occurred diseases and decrease the probability of unoccurred diseases based on gradients flowed from the critic. However, if we directly use the probability distribution to train the critic, it will increase the uncertainty of the generator and make the training less stable. For example, let us say that the generator gives a probability of 0.8 for a disease. After training the critic, it gives a lower score for this generation. When training the generator in the next step, it only knows 0.8 leads to a lower score but does not know whether to increase or decrease the probability to reach a higher score. As a consequence, we may need many iterations to make the training of generator converge after a lot of explorations in the input space. To stabilize the training process, we propose to train the critic by sampling from the generated distribution $\tilde{\mathbf{P}}$ to get a discrete diagnoses sequence $\tilde{\boldsymbol{x}} = (\tilde{\mathbf{x}}_1, \tilde{\mathbf{x}}_2, \dots, \tilde{\mathbf{x}}_T) \sim \tilde{\mathbf{P}} \in \{0, 1\}^{d \times T}$, where \begin{align} \tilde{\mathbf{x}}_t \boldsymbol{\sim} \text{Bernoulli}(\tilde{\mathbf{P}}_t) \in \{0, 1\}^{d}. \end{align} Here, we use $\boldsymbol{\sim}$ to denote element-wise sampling, and $\text{Bernoulli}(p)$ means sampling from a Bernoulli distribution with the success probability as $p$. In this approach, the synthetic data for training the critic are discrete. We also use the probability 0.8 as an example. Assume the sampled output is 1, after a generator optimization step, it not only knows 0.8 will get a low score, but also learns that it should decrease the probability to reach a higher score. There is another advantage of generating discrete diseases by sampling. In traditional GANs for generating EHR such as medGAN~\cite{choi2017generating}, medWGAN~\cite{baowaly2019synthesizing}, Smooth-GAN~\cite{rashidian2020smooth}, and RDP-CGAN~\cite{torfi2022differentially}, after getting the disease probability from either the generator or auto-encoder, they directly round the probability to get the discrete diseases. However, for uncommon diseases, the probabilities of them are usually low. Rounding the probability will further decrease the frequency of uncommon diseases in generated samples. Therefore, we use sampling from the probability as another measure to generate uncommon diseases, i.e., \ref{challenge_gc2}. Finally, we use the losses $L_G$ and $L_D$ to train the generator and critic respectively, given a target disease $i \sim \text{U}[0, d]$: \begin{align} L_D =&~\mathbb{E}_{\tilde{\boldsymbol{x}} \sim \tilde{\mathbf{P}}}[D(\tilde{\boldsymbol{x}}, \tilde{\mathbf{H}}))] - \mathbb{E}_{{\boldsymbol{x} \sim p_{\boldsymbol{x}|i}}}[D(\boldsymbol{x}, \mathbf{H})] \notag \\ &~+ \lambda{\mathbb{E}_{\hat{\boldsymbol{x}} \sim p_{\hat{\boldsymbol{x}}}, \hat{\mathbf{H}} \sim p_{\hat{\mathbf{H}}}}}\left[(\|\Delta_{\hat{\boldsymbol{x}}, \hat{\mathbf{H}}}D(\hat{\boldsymbol{x}}, \hat{\mathbf{H}})\|_2 - 1)^2\right], \label{eq:loss_d}\\ L_G =&~-\mathbb{E}_{\boldsymbol{z} \sim p_{\boldsymbol{z}}}[D(\tilde{\mathbf{P}}, \tilde{\mathbf{H}})]. \label{eq:loss_g} \end{align} The pseudo-code for training {{MTGAN}} is summarized in Algorithm~\ref{algo:model_algo}. In each iteration, we first sample a target disease $i$ from a discrete uniform distribution $\text{U}[0, d]$. When training critic at lines 3-11, we sample real data $\boldsymbol{x} \sim p_{\boldsymbol{x}|i}$ that contain this target disease in any visit, following the setting in CTGAN. When calculating the gradient penalty, besides letting $\hat{\boldsymbol{x}} = \epsilon \boldsymbol{x} + (1 - \epsilon)\tilde{\boldsymbol{x}}$, we also incorporate $\hat{\mathbf{H}} = \epsilon \mathbf{H} + (1 - \epsilon)\tilde{\mathbf{H}}$ with the same $\epsilon$ into the calculation. At lines 13-15, we train the generator by feeding the synthetic probabilities into critic. Finally, we repeat the training of the critic and the generator until they converge. \begin{algorithm} \caption{{MTGAN}-Training ($\mathcal{D}, g'_{\text{gru}}, n_{\text{critic}}$)} \label{algo:model_algo} \DontPrintSemicolon \SetAlgoLined \newcommand\mycommfont[1]{\footnotesize\ttfamily\textcolor{blue}{#1}} \SetCommentSty{mycommfont} \SetKwInOut{Input}{Input} \SetKwInOut{Output}{Output} \Input{Real EHR dataset $\mathcal{D}$\\Pre-trained GRU $g'_{\text{gru}}$\\Critic training number $n_{\text{critic}}$} $d \leftarrow$ Count the disease number in $\mathcal{D}$ \\ \Repeat{convergence}{ Sample a target disease $i \sim \text{U}[0, d]$ \\ \tcp{Training the critic} \For{$j \leftarrow 1$ to $n_{\text{critic}}$}{ Sample real data $\boldsymbol{x} \sim p_{\boldsymbol{x}|i}$, noise $\boldsymbol{z} \sim p_{\boldsymbol{z}}$, coefficient $\epsilon \sim \text{U}[0, 1]$ \\ $\mathbf{H} \leftarrow g'_\text{gru}(\boldsymbol{x})$ \\ $\tilde{\mathbf{P}}, \tilde{\mathbf{H}} \leftarrow G(\boldsymbol{z}, i)$ \\ Sample discrete diseases $\tilde{\boldsymbol{x}} \sim \tilde{\mathbf{P}}$ \\ $\hat{\boldsymbol{x}} \leftarrow \epsilon \boldsymbol{x} + (1 - \epsilon)\tilde{\boldsymbol{x}}$ \\ $\hat{\mathbf{H}} \leftarrow \epsilon \mathbf{H} + (1 - \epsilon)\tilde{\mathbf{H}}$ \\ Optimize the critic $D$ using $L_D$ } \tcp{Training the generator} Sample noise $\boldsymbol{z} \sim p_{\boldsymbol{z}}$ \\ $\tilde{\mathbf{P}}, \tilde{\mathbf{H}} \leftarrow G(\boldsymbol{z}, i)$ \\ Optimize the generator $G$ using $L_G$ \\ } \end{algorithm} \section{Related Work} \label{sec:related_work} \subsection{Generative Adversarial Networks} The generative adversarial networks are first proposed by Goodfellow \textit{et al.}~\cite{goodfellow2014generative} to generate realistic images. A typical GAN contains a generator to generate synthetic samples and a discriminator to distinguish real samples from generated samples. Arjovsky \textit{et al.}~\cite{arjovsky2017wasserstein} proposed WGAN by replacing the binary classification in the discriminator with the Wasserstein distance to alleviate mode collapse and vanishing gradient in GAN. Gulrajani \textit{et al.}~\cite{gulrajani2017improved} introduce a gradient penalty in WGAN-GP to improve the training of WGAN. Xu \textit{et al.}~\cite{xu2019modeling} propose CTGAN to generate imbalanced tabular data with a conditional vector. Wang \textit{et al.}~\cite{wang2019learningtkde} propose a graph softmax method in GraphGAN to sample discrete graph data. Unfortunately, typical GANs are not able to generate time-series data, and therefore cannot be directly applied to generate EHR data. \subsection{GANs for Sequence Generation} To generate sequences with discrete variates, SeqGAN~\cite{yu2017seqgan} is proposed by Yu \textit{et al.} with the REINFORCE algorithm and policy gradient. Yoon \textit{et al.}~\cite{yoon2019time} propose TimeGAN by jointly training with a GAN loss, a reconstruction loss, and a sequential prediction loss. To generate time-series data with conditions, Ramponi \textit{et al.}~\cite{ramponi2018t} propose T-CGAN by specifying the time step of a data sample as the condition. Esteban \textit{et al.}~\cite{esteban2017real} propose a recurrent conditional GAN, RCGAN, to generate real value medical data. Du \textit{et al.}~\cite{du2021gantkde} propose a GAN-based anomaly detection algorithm for multivariate time series data. Liu \textit{at al}~\cite{liu2022timetkde} also apply the GAN framework in BeatGAN by adding an encoder and decoder to reconstruct time-series data for anomaly detection. However, generating multi-label synthetic data from imbalanced datasets is not considered in SeqGAN and TimeGAN. For T-CGAN, when generating a sample, it only uses the temporal position of this sample as the condition, thus ignoring temporal correlations of the entire sequence and the imbalanced distribution of labels. For RCGAN and BeatGAN, they are designed for real-value time-series data and do not fit for EHR data. \subsection{Generating EHR with GANs} Recently, GANs are applied to generate EHR to address the problem of limited data sources in healthcare applications. Che \textit{et al.}~\cite{che2017boosting} propose ehrGAN by feeding the generator with masked real data to generate EHR data. Choi \textit{et al.}~\cite{choi2017generating} propose medGAN by introducing an auto-encoder. The generator outputs a latent feature, and medGAN uses the auto-encoder to decode synthetic data from the latent feature. Baowaly \textit{et al.}~\cite{baowaly2019synthesizing} replace the GAN framework in medGAN with WGAN-GP and propose medWGAN. EMR-WGAN is proposed by Zhang \textit{et al.}~\cite{zhang2020ensuring}. It removes the auto-encoder in medGAN and let the generator directly output synthetic data. Torfi \textit{et al.} propose RDP-CGAN with a convolutional auto-encoder and convolutional GAN. The RDP-CGAN model also uses a differential privacy method to preserve privacy in the synthetic EHR data. However, these GANs only generate single visits instead of patient-level data. As a result, the synthetic EHR data generated by these GANs cannot be used for many time-series tasks such as temporal health event prediction. In addition, they do not consider uncommon diseases given that the diseases in EHR datasets are usually imbalanced, which decreases the quality of the synthetic EHR data. Furthermore, a majority of GANs for EHR generation are not stable when dealing with sparse EHR data, which may make it difficult to train the GANs. In general, we compare related GANs in Table~\ref{tab:comp} based on the important properties required for generating EHR. In this work, we simultaneously consider generating patient-level EHR data and uncommon diseases. \section{Experimental Setups} \label{sec:exp_setup} \subsection{Evaluation Metrics} \label{sec:metrics} To evaluate the statistical quality of the generated EHR dataset $\tilde{\mathcal{D}}$, we use the following metrics: \begin{itemize}[leftmargin=*, labelwidth=0.5\labelwidth] \item \textit{Generated disease types (GT)}: We use the generated disease types to evaluate whether the GAN model can generate all diseases in $\mathcal{D}$. When $|\mathcal{D}| = |\tilde{\mathcal{D}}|$, $\tilde{\mathcal{D}}$ should contain similar disease types as $\mathcal{D}$. \item \textit{Visit/patient-level Jensen-Shannon divergence (JSD$_{\{v, p\}}$)}: JSD is a metric to evaluate a visit/patient-level distribution of disease relative frequency between $\tilde{\mathcal{D}}$ and real EHR dataset $\mathcal{D}$. Here, the visit/patient-level frequency of a disease means the relative frequency of visit/patient that this disease appears. For patient-level frequency, if a disease appears in multiple visits of a patient, the disease frequency is still counted as 1. A lower divergence value means better generation quality. \item \textit{Visit/patient-level normalized distance (ND$_{\{v, p\}}$)}: The Jensen-Shannon divergence focuses on the overall distributions, especially on the difference between data points that have high probability. As a result, the punishment cannot be emphasized for the difference between uncommon diseases that originally have a low probability. Therefore, to further evaluate the distribution of uncommon diseases, we adopt a normalized visit/patient-level distance. Given two distributions $p_{\boldsymbol{x}}$ and $p_{\tilde{\boldsymbol{x}}}$ of the visit/patient-level disease relative frequency in real and generated datasets, the distance is calculated as follows: \begin{align} ND = \frac{1}{d}\sum_{i \in \mathcal{C}}{\frac{2|p_{\boldsymbol{x}}(i) - p_{\tilde{\boldsymbol{x}}}(i)|}{p_{\boldsymbol{x}}(i) + p_{\tilde{\boldsymbol{x}}}(i)}}. \end{align} Here, $\mathcal{C}$ is the entire disease set in the EHR dataset, and $d$ is the number of diseases as mentioned before. A good generation should also have a low normalized distance. \item \textit{Required sample number to generate all diseases (RN)}: We use this metric to evaluate the ability of GANs to generate uncommon diseases. When generating all diseases, $|\tilde{\mathcal{D}}|$ should also contain close sample numbers to $|\mathcal{D}|$. \end{itemize} To assess whether the generated EHR dataset $\tilde{\mathcal{D}}$ is actually meaningful as an extension of real EHR data, we use a deep learning-based approach to train predictive models for health events on real and synthetic training data. More specifically, we pre-train predictive models on synthetic data, fine-tune these models on real training data, and finally test them on real test data of downstream tasks. It aims to quantify how much the generated EHR data can boost the training of predictive models on downstream tasks. Here, we apply three temporal prediction tasks: \begin{itemize}[leftmargin=*] \item \textit{Diagnosis prediction}: It predicts all diagnoses of a patient in the visit $T + 1$ given previous $T$ visits. It is a multi-label classification. \item \textit{Heart failure/Parkinson's disease prediction}: It predicts if a patient will be diagnosed with heart failure/Parkinson's disease in the visit $T + 1$ given all the previous $T$ visits\footnote{The ICD-9 codes for heart failure and Parkinson's disease start with 428 and 332, respectively.}. It is a binary classification. Here, heart failure is one of the most frequent diseases in the EHR datasets we used in this work. The Parkinson's disease is an uncommon disease. \end{itemize} The evaluation metrics for diagnosis prediction are weighted F-1 score (w-$F_1$). For heart failure/Parkinson prediction, we use the area under the ROC curve (AUC). \begin{table} \centering \caption{Statistics of MIMIC-III and MIMIC-IV datasets} \label{tab:dataset} \begin{tabular}{lcccc} \toprule \textbf{Dataset} & \textbf{MIMIC-III} & \textbf{MIMIC-IV} \\ \midrule \# patients & 7,493 & 10,000 \\ \# visits & 19,894 & 36,607 \\ Max. \# visit per patient & 42 & 55 \\ Avg. \# visit per patient & 2.66 & 3.66 \\ \midrule \# diseases & 4,880 & 6,102 \\ Max. \# diseases per visit & 39 & 50 \\ Avg. \# diseases per visit & 13.06 & 13.38 \\ \midrule \# patients with heart failure & 3,364 & 2,137 \\ \# patients with Parkinson & 109 & 153 \\ \bottomrule \end{tabular} \end{table} \begin{figure} \centering \subfloat[MIMIC-III]{\includegraphics[width=0.5\linewidth]{figs/mimic3-stat}\label{fig:mimic3_stat}} \subfloat[MIMIC-IV]{\includegraphics[width=0.5\linewidth]{figs/mimic4-stat}\label{fig:mimic4_stat}} \caption{Visit-level relative frequency distribution of diseases in the MIMIC-III and MIMIC-IV datasets.} \label{fig:mimic_stat} \end{figure} \subsection{Datasets} We use the MIMIC-III~\cite{johnson2016mimic} and MIMIC-IV~\cite{mimiciv} datasets to validate the generation of {{MTGAN}}. MIMIC-III contains 7,493 patients who have multiple visits, i.e., visit sequences, from 2001 to 2012. For MIMIC-IV, we randomly select 10,000 patients with multiple visits from 2013 to 2019 to avoid overlaps with MIMIC-III. The statistics of MIMIC-III and MIMIC-IV are shown in Table~\ref{tab:dataset}. We also illustrate the visit-level disease distribution of MIMIC-III and MIMIC-IV in \figurename~\ref{fig:mimic_stat} in descending order, including annotations for heart failure and Parkinson's disease. The curves illustrate that the disease relative frequency in both datasets is a long-tail distribution. It further verifies the significance of improving the generation quality for uncommon diseases. To conduct the predictive tasks, we randomly split the two datasets into training and test sets. The MIMIC-III contains 6,000 and 1,493 patients in training and test sets, respectively, while MIMIC-IV contains 8,000 and 2,000, respectively. The training sets of MIMIC-III and MIMIC-IV have 16,055 and 29,804 visits, respectively. It is worth noting that {{MTGAN}} is trained using the training sets to ensure there is no data leakage when testing. \subsection{Baseline Models} To evaluate the quality of generated EHR data, we select various GAN models as baselines. They can be divided into two major types: GANs for visit-level generation and GANs for patient-level generation. \subsubsection{GANs for Visit-Level Generation} We adopt four GANs as baselines that generate single visits: \begin{itemize}[leftmargin=*] \item \textit{medGAN}~\cite{choi2017generating}: It uses the generator to output a latent feature and applies a pre-trained auto-encoder to decode the latent feature as the discriminator input. \item \textit{CTGAN}~\cite{xu2019modeling}: It uses a training-by-sampling strategy to generate imbalanced tabular data. The input of the CTGAN generator is the concatenation of a noise vector and a conditional vector. \item \textit{EMR-WGAN}~\cite{zhang2020ensuring}: It removes the auto-encoder in medWGAN~\cite{baowaly2019synthesizing} and directly generates visits with the generator. \item \textit{RDP-CGAN}~\cite{torfi2022differentially}: It uses a convolutional auto-encoder and discriminator under the framework of WGAN. \end{itemize} For these GANs generating single visits, we only calculate GT, JSD$_v$, ND$_v$, and RN to evaluate the statistical results and do not use them for temporal prediction tasks since they cannot generate visit sequences. \subsubsection{GANs for Patient-Level Generation} We select three GANs to generate visit sequences: \begin{itemize}[leftmargin=*] \item \textit{WGAN-GP}: We implement WGAN-GP's generator with GRU to generate time-series data. The input of each GRU cell is a random noise. \item \textit{TimeGAN}~\cite{yoon2019time}: It uses RNN to generate hidden features and proposes unsupervised, supervised, and reconstruction losses to train the GAN model. \item \textit{T-CGAN}~\cite{ramponi2018t}: It applies a conditional GAN by specifying the time step of generated visits. The input of the generator is a concatenation of a noise vector and a time step conditional vector. When generating visit sequences, we specify the time step from 1 to $T$ and combine all generated visits chronologically into a sequence. \end{itemize} \begin{table*} \centering \caption{Statistical evaluation results on generated data based on MIMIC-III and MIMIC-IV. GT: Generated disease type; JSD$_v$, JSD$_p$: Visit/patient-level Jensen-Shannon divergence; ND$_v$, ND$_p$: Visit/patient-level normalized distance; RN: Required sample number to generate all disease types. } \label{tab:stat_result} \begin{tabular}{clccccccccc} \toprule \multicolumn{2}{c}{\multirow{2}{*}{\textbf{Metrics}}} & \multicolumn{4}{c}{\textbf{Single Visit}} & \multicolumn{4}{c}{\textbf{Visit Sequence}} & \multirow{2}{*}{\textbf{Real}} \\ \cmidrule(lr){3-6}\cmidrule(lr){7-10} \multicolumn{2}{c}{~} & medGAN & CTGAN & EMR-WGAN & RDP-CGAN & WGAN-GP & TimeGAN & T-CGAN & {{MTGAN}} & \\ \midrule \multirow{7}{*}{\rotatebox[origin=c]{90}{MIMIC-III}} & GT & 1,356 & 2,742 & 1,210 & 3,161 & 1,775 & 1,037 & 2,344 & \textbf{4,431} & 4,880 \\ & JSD$_v$ & 0.2342 & 0.1983 & 0.1762 & 0.1587 & 0.1843 & 0.3344 & 0.1604 & \textbf{0.1344} & 0 \\ & JSD$_p$ & --- & --- & --- & --- & 0.2022 & 0.3518 & 0.1969 & \textbf{0.1413} & 0 \\ & ND$_v$ & 1.6751 & 1.2911 & 1.6213 & 0.9067 & 1.5817 & 1.7791 & 1.2943 & \textbf{0.6563} & 0 \\ & ND$_p$ & --- & --- & --- & --- & 1.5924 & 1.7719 & 1.3312 & \textbf{0.6645} & 0 \\ & RN & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & \textbf{7,952} & 6,000 \\ & \# Params & 3.84M & 2.59M & 1.96M & 12.07M & 1.35M & 3.05M & 1.95M & 5.84M & --- \\ \midrule \multirow{7}{*}{\rotatebox[origin=c]{90}{MIMIC-IV}} & GT & 1,807 & 2,915 & 1,396 & 3,835 & 1,747 & 1,331 & 2,686 & \textbf{5,677} & 6,102 \\ & JSD$_v$ & 0.2130 & 0.2217 & 0.1912 & 0.1662 & 0.2135 & 0.4004 & 0.1540 & \textbf{0.1467} & 0 \\ & JSD$_p$ & --- & --- & --- & --- & 0.2500 & 0.4153 & 0.1963 & \textbf{0.1649} & 0 \\ & ND$_v$ & 1.6709 & 1.4306 & 1.6902 & 0.9709 & 1.6911 & 1.7849 & 1.4222 & \textbf{0.6705} & 0 \\ & ND$_p$ & --- & --- & --- & --- & 1.7015 & 1.7911 & 1.4731 & \textbf{0.6843} & 0 \\ & RN & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & $>10^7$ & \textbf{11,734} & 10,000 \\ & \# Params & 4.78M & 3.21M & 2.43M & 15.01M & 1.67M & 3.68M & 2.42M & 7.25M & --- \\ \bottomrule \end{tabular} \end{table*} \subsection{Parameter Settings} The parameter settings for baselines are listed as follows: \begin{itemize}[leftmargin=*] \item medGAN: We use three fully-connected (FC) layers with skip-connection and batch normalization as the generator. Each layer has 128 hidden units. The discriminator has three FC layers with 256 and 128 hidden units. The autoencoder contains two FC layers with 128 hidden units. \item CTGAN: It uses three FC layers without skip-connection as the generator. The hidden units are all 128. The discriminator is the same as medGAN. \item EMR-WGAN: The generator and critic of EMR-WGAN have the same hyper-parameter settings with medGAN. \item RDP-CGAN: We use 6 1-d conv layers for both encoder and decoder with kernel sizes \{3, 3, 4, 4, 4, 4\} and \{4, 4, 4, 4, 3, 3\}. We use 3 conv layers in the generator with kernel sizes \{3, 3, 3\} and 5 conv layers in the critic with kernel sizes \{3, 3, 4, 4, 4\}. \item WGAN-GP: It uses a GRU with 128 hidden units as the generator. The critic has two FC layers with 128 hidden units. We calculate the sum of Wasserstein distance each visit as the final discriminator loss. \item TimeGAN: The generator, discriminator, embedder, recovery, and supervisor all have a GRU with 128 hidden units. \item T-CGAN: It has the same generator and critic as CTGAN. \end{itemize} For {{MTGAN}}, we randomly initialize all model parameters. The noise dimension as well as GRU hidden units $s$ are 256. The MLP used in the critic has one hidden layer with 64 hidden units. For base GRU pre-training, we run 200 epochs with Adam optimizer~\cite{KingmaB14} and set the learning rate to be $10^{-3}$. For training {{MTGAN}}, we run $3\times10^5$ iterations with batch size 256. The learning rates for the generator and critic are $10^{-4}$ and $10^{-5}$ and decay by 0.1 every $10^{5}$ iterations, respectively. The critic training number ${n}_{\text{critic}}$ is 1. We use the Adam optimizer and set $\beta_1 = 0.5$ and $\beta_2 = 0.9$. The $\lambda$ for the gradient penalty is 10, the same as the settings in WGAN-GP~\cite{gulrajani2017improved}. All programs are implemented using Python 3.8.6 and PyTorch 1.9.1 with CUDA 11.1 on a machine with Intel i9-9900K CPU, 64GB memory, and Geforce RTX 2080 Ti GPU. The source code of {{MTGAN}} is released publicly at \url{https://github.com/LuChang-CS/MTGAN}.
{'timestamp': '2022-04-12T02:28:22', 'yymm': '2204', 'arxiv_id': '2204.04797', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04797'}
arxiv
\section{Introduction} \label{sec:intro} Egocentric videos recorded by wearable cameras give a unique perspective on human behaviors and the scene context \cite{damen2018scaling,li2018eye,sigurdsson2018actor}. Existing action recognition methods, typically developed for third-person video understanding, focus on learning from the whole video frames~\cite{carreira2017quo,zhou2018temporal,lin2019temporal,wang2018temporal,bulat2021space,feichtenhofer2019slowfast,kazakos2019epic}. Unlike third-person videos where actions often take place in dramatically different background scenes (e.g., swimming in a pool, cycling on the road) \cite{carreira2017quo,soomro2012ucf101}, egocentric videos are often collected at a specific scene (e.g., a kitchen) with similar background shared across different human actions (e.g., cutting onion and washing knife) and cluttered with distractors (e.g., a knife on the countertop). These distinctive characteristics bring about extra challenges for most existing action models {\em without a fine-grained understanding of spatio-temporal dynamics and context.} \begin{figure} \centering \includegraphics[width=\linewidth]{figures/teaser_ECCV22.pdf} \vskip -0.3cm \caption{{\bf Handled Objects are vital players for determining actions in egocentric videos.} However, most action classification models learn directly from video frames (left). This paper puts manipulated objects (right) at the forefront {\em without} the need for expensive and tedious fine-grained object annotations. } \label{fig:example_hoi} \vspace{-0.5cm} \end{figure} To overcome these challenges, recent works have started to incorporate information from other modalities, such as audio \cite{kazakos2019epic,kazakos2021slow}, narration language \cite{kazakos2021little,bertasius2020cobe}, and eye gaze \cite{li2021eye}, into the video action model. This is motivated by their complementary information and the modality-specific nature of distractors. Object information was also shown to be a powerful complement to prior video action models \cite{wu2019long,wang2020symbiotic}. While a video model represents the sequence as a whole, combining foreground and context, object detectors exploit bounding box annotations to explicitly model each object, separately from the others and background. Our work falls in this line of research with a crucial difference. We consider that bounding box annotations are costly and unsuited for {\em long-tail open-vocabulary object distributions} across the scenes, e.g., a kitchen setting. Large-scale annotations are thus seldom possible in most cases. We tackle this issue by capitalizing {\em an off-the-shelf hand-object contact detector} to localize class-agnostic object regions in video. Crucially, we introduce a novel self-supervised approach to learn a specialized representation on detected object regions without resorting to object box annotations nor labels. Our key idea is to leverage the spatio-temporal continuity in videos as {\em a native context constraint} for exploiting the inherent relationships among the set of detected object regions per video. Intuitively, all the handled object regions play respective roles during the course of an action, and they collectively provide a potentially useful context clue for learning a suitable object representation (e.g., the ``tap" and ``plate" while washing dishes - see Fig. \ref{fig:qualitative}). With our class agnostic self-supervised learning, there is also a potential that the natural action class imbalance problem would be simultaneously alleviated -- a typical yet understudied problem in video understanding. We term our self-supervised pre-training {\bf S}elf-Supervised Learning {\bf O}ver {\bf S}ets ({SOS}). After pre-training, we transfer the specialized representation of detected objects to a target task, e.g., video classification. For this purpose, we employ an Objects in Contact ({OIC}) network and further fine-tune the entire representation with {\em weak} video-level labels. Once trained, our {OIC}{} can be flexibly integrated with existing video classification models, further boosting their performance. We make three {\bf contributions} in this paper. {\bf(1)} We investigate the merits on learning a representation of handled objects for egocentric action recognition, from the perspective of boosting state-of-the-art video action models in a flexible manner without the need for expensive fine-grained bounding-box labeling on the target dataset. {\bf(2)} To that end, we leverage an off-the-shelf hand-object contact detector to generate class-agnostic object regions and introduce a novel set self-supervised learning approach, {SOS}, to learn a specialized representation of object regions. {SOS}{} exploits the inherent relation (e.g., concurrence) among handled objects per video to mine the underlying action context clue by treating all the objects collectively as a single set. {\bf(3)} Experiments on two egocentric video datasets showcase that our {OIC}, aided with our {SOS}{} pre-training, complements multiple existing video classification network and yields state-of-the-art results in video classification. Moreover, we demonstrate the benefit of {SOS}{} for dealing with the realistic long-tail setup in videos. (Sec. \ref{exp:sos_lt}). \section{Related Work} \noindent{\bf Egocentric action recognition. } Egocentric action recognition has made significant advances in recent years, thanks to the introduction of ever larger video benchmarks \cite{damen2018scaling,damen2020rescaling,li2018eye}. Early efforts were focused on adapting representative generic video models \cite{wang2018temporal,lin2019temporal,zhou2018temporal,feichtenhofer2019slowfast}. Later on, a variety of dimensions have been investigated. For example, Kazakos et al. \cite{kazakos2019epic} combined multi-modal information (e.g., optical flow, audio) within a range of temporal offsets. Bertasius et al. \cite{bertasius2020cobe} leveraged the language based semantic context to supervise the learning of active object detection. Li et al. \cite{li2021ego} investigated the pre-training of video encoder for mitigating the domain gap from the common pre-trained video datasets (e.g., Kinetics \cite{carreira2017quo}). Sudhakaran et al. \cite{sudhakaran2019lsta} designed an LSTM based Long-Short Term Attention model to locate relevant spatial parts (e.g., active objects) with temporally smooth attention. Similarly, Yan et al. \cite{yan2020interactive} proposed an Interactive Prototype Learning (IPL) model for better learning active object representations by interaction with different motion patterns. Instead, Li et al. \cite{li2018eye,li2021eye} and Liu et al. \cite{liu2020forecasting} used human gaze to guide the attention of deep models to interacting regions. Similar to ours, object detection has been previously exploited for improving action recognition. Indeed, early work already identified explicit hand detection as an informative queue for action recognition \cite{lendingahand2015iccv}. More recently, Wang et al. \cite{wang2018videos} exploited object regions and their spatio-temporal relations to enhance video representation learning. More similar to ours, Baradel et al. \cite{Baradel_2018_ECCV} devised an architecture with a video branch and an object branch. However, their approach requires object-level annotations and has no mechanism to identify foreground/active objects, thus being vulnerable to distractors. Wu et al. \cite{wu2019long} instead used an attentive mechanism and also incorporated long-term temporal context. Wang et al. \cite{wang2020symbiotic} proposed a model specific for egocentric action recognition that relies on a complex attentive mechanism to sieve out distractors. Unlike prior work, our method does not assume fine-grained object-level annotations from the target dataset, hence being scalable in practical applications. Critically, their object representation is tightly coupled with an action model with the need for joint training. In contrast, we learn an independent object representation model enabling to flexibly benefit off-the-shelf action models in a decoupled post-training manner. \paragraph{Hand-object interaction (HOI).} While generic Human-Object Interaction is a widely-studied topic \cite{gkioxari2018detecting,qi2018learning,li2020hoi,hou2020visual}, recent works have shown that it is possible to train large-scale domain-agnostic hand and hand-object contact detectors \cite{shan2020understanding,narasimhaswamy2020detecting}. As face detection models, these models can be deployed without domain-specific retraining and still maintain reasonable effectiveness. In our work, we apply one such off-the-shelf hand-object contact model without retraining \cite{shan2020understanding}. \noindent{\bf Self-supervised learning. } There is a recent surge in self-supervised learning (SSL) for learning generic feature representation models from large scale dataset without labels \cite{he2019momentum,chen2020exploring,chen2020simple,caron2020unsupervised,grill2020bootstrap,SunNTS2021}. We are inspired by this trend and introduce a novel application of exiting SSL techniques that learns a representation specific of objects being manipulated. However, a direct application of a SSL model to our problem does not produce optimal results. We propose two important modifications: firstly, instead of following a classic fine-tuning from domain-agnostic pre-training, e.g. over ImageNet, our method leverages on-domain SSL for solving the domain shift problem with model pre-training. To this end we use a domain-agnostic SSL model as means of pre-training, followed by a domain-specific SSL training \cite{ssl4ssl}. Secondly, existing SSL methods focus on single images, using two different augmentations to obtain two copies of an image. Instead, in the presence of video, sampling different timestamps and locations can create more natural and effective augmentations \cite{demystifyingneurips20}. Inspired by this insight, we propose a variant of SwAV that operates on sets of image regions extracted from a video sequence. The experimental results section shows that these two modifications are crucial to obtain an effective object representation. \noindent{\bf Long-tail learning in video.} Real-world egocentric actions are typically class-imbalanced \cite{damen2018scaling,damen2020rescaling,li2018eye}. Despite extensive works in image domains \cite{dong2018imbalanced,huang2016learning,kang2020exploring,kang2019decoupling,menon2020long,yang2020rethinking}, class imbalance is still less studied in video tasks \cite{zhang2021videolt}. Inspired by the intriguing finding that unlabeled image data is effective in counting class imbalance via SSL \cite{yang2020rethinking}, this work presents an object set based SSL method. Unlike \cite{yang2020rethinking} focusing on images, we consider more complex video data due to the extra temporal dimension, the structured nature of action labels ({\it i.e.}, defined as tuple of two imbalanced labels distributions, verb and noun) and only access to video-level supervision. This paper contributes the first study of the relationship between SSL and long-tailed learning in egocentric video understanding. \section{Method} \begin{figure}[!t] \centering \includegraphics[width=0.75\linewidth]{figures/SSL_diagram_ECCV22.pdf} \vskip -0.3cm \caption{ {\bf Overview of the proposed Self-Supervised Learning Over Sets ({SOS}) approach } for pre-training a specialized Objects In Contact ({OIC}) representation model. Taking as input object regions extracted by an off-the-shelf hand-object contact detector in videos, we formulate a two-staged pre-training strategy. The {\em first} stage consists of generic self-supervision learning (e.g. ImageNet). In the {\em second} stage, we exploit self-supervised learning on per-video object sets using actions as the natural transformations with spatio-temporal continuity. Given a target task, we further fine-tune the representation through {\em video-level} action labels. } \label{fig:pipeline} \vspace{-0.5cm} \end{figure} We aim to learn a generic object-in-contact ({OIC}{}) model for improving the performance of existing egocentric action models in a plug-and-play manner. \paragraph{Overview.} Given a video $V$ and an off-the-shelf hand-object contact detector model \cite{shan2020understanding}, we obtain a set of object regions that likely contain objects manipulated by the hands. Let $\mathcal{B}=\{\bm{B}_i\}_{i=1:M}$ denote the set of $M$ object regions in the video. We have an object region encoder $f_B$ so that $\bm{y}_B^i=f_{B}(V,\bm{B}_i;\theta_B)$. To that end, we propose a simple yet effective approach termed, {\bf S}elf-Supervised Learning {\bf O}ver {\bf S}ets ({SOS}), to train $\theta_B$ in two steps: {\bf (I)} First, a large-scale self-supervised learning model is used for pre-training. {\bf (II)} Followed by, an on-domain self-supervised learning stage yielding a specialized representation better suited for the task of interest. Given a target task, standard discriminative fine-tuning is then followed, using the video-level labels and standard cross-entropy as supervision. An overview of our {SOS}{} is depicted in Fig. \ref{fig:pipeline}. \subsection{Self-Supervised Object Representation Learning from Video Object Regions} \label{sec:ssl} Object representations are typically learned as part of the standard object detector training pipeline. However, we do not assume the availability of object-level annotations. We propose to instead learn the object representation in an unsupervised manner using object regions. \paragraph{Stage I{}: Model pre-training.} There is a lack of standard large-scale datasets for model pre-training in the egocentric video, so one could use the widely used ImageNet~\cite{russakovsky2015imagenet} supervised pre-trained weights for model initialization. This gives rise to an inevitable domain shift challenge for object representation learning due to the intrinsic discrepancy in data distribution. To overcome these domain shift challenges, we leverage the more domain-generic self-supervised learning (SSL) strategy for model pre-training \cite{chen2020simple,grill2020bootstrap,he2019momentum,vondrick2018tracking,chen2020exploring,caron2020unsupervised}. In practice, due to the relatively small size of the target dataset, it is key to start with an SSL model trained on ImageNet for model initialization. In general, any existing SSL method is applicable. Based on preliminary experiments, we select the recent state-of-the-art model SwAV \cite{caron2020unsupervised} (Fig. \ref{fig:swavs} top - Stage I{}). \paragraph{Stage II: On-domain Self-supervised learning Over Sets, {SOS}{}.} The key challenge is how to capitalize the unlabeled object regions. Motivated by the results of \cite{ssl4ssl}, we perform on-domain SSL to specialize the object region encoder $f_B$ to better represent the regions in the target domain, egocentric videos. It is worth noting that the promising recipe from~\cite{ssl4ssl} ignores a key and important piece of information from our problem definition, object regions extracted from a single video are {\em not} independent but correlate to an ongoing action instance {\em collectively}. Inspired by this consideration, we introduce the notion of actions as natural data transformation exploiting the unique spatio-temporal continuity of videos and the inherent relationships among per-video object sets. Intuitively, the set of object regions captures the underlying action context in the video. We argue that statistically predominant inter-object relationships ({\it e.g.}, concurrence) provide a strong self-supervisory signal for learning an specialized object representation. We consider each video $V$ as a training sample and treat the {\em set construction process from all regions in the video $\mathcal{B}$} as {\em a spatio-temporal transformation process}, subject to the structural variations of the performed action in the video ({\it i.e.}, elastic, geometrical or ambient changes that objects undergo through space and time). This is conceptually reminiscent to and complement the standard image augmentation process (e.g., cropping, flipping, jittering). Interestingly, under this perspective, our approach fits exactly on recent top-of-the-line self-supervised frameworks such as contrasting learning, clustering, instance similarity, decorrelated representation, to name a few \cite{chen2020simple,grill2020bootstrap,he2019momentum,chen2020exploring,caron2020unsupervised}. Without loss of generality, we present our Self-supervised Learning Over Sets approach ({SOS}) on top of the SwAV formulation due to their state-of-the-art results. Yet, we anticipate that our {SOS}\ could be extended to other frameworks\cite{chen2020simple,grill2020bootstrap,he2019momentum,chen2020exploring}. \begin{figure}[!t] \centering \includegraphics[width=\linewidth]{figures/figure_swav.pdf} \vskip -0.3cm \caption{ {\bf Overview of the proposed SwAV-S.} Schematically outlining the differences w.r.t the standard SwAV~\cite{caron2020unsupervised} for image regions, and our self-supervised pre-training approach using videos and leveraging actions as natural transformations. } \label{fig:swavs} \vspace{-0.5cm} \end{figure} \noindent{\bf SwAV review.} SwAV \cite{caron2020unsupervised} aims at learning a feature representation that matches different views of the same image. Specifically, the representation of one of these views is used to compute a code $\bm{q}$, which is then predicted from the code of another view. Formally, given an image $\bm{x}$, two corresponding views $\bm{x}_1$ and $\bm{x}_2$ are created by applying a random transformation $t\in \mathcal{T}$, where $\mathcal{T}$ is the set of all considered transformations (typically these are synthetic, such as random crops, color jittering, Gaussian blurring and flipping, etc.). Corresponding feature vectors $\bm{z}_i=g(f(\bm{x}_i;\theta);\phi)$ are generated and projected into the unit sphere, where $\bm{z}_i \in \mathbb{R}^d$, $f$ represents a backbone network with parameters $\theta$ and $g$ a projection head with parameters $\phi$. SwAV can be seen as an online clustering method, where the cluster centroids are defined by set of learnable prototypes $\bm{c}_i \in \bm{C}^{K \textup{x} d}$, which are used as a linear mapping function to compute each view's code $\bm{q}_i = \bm{z}_{i}^{\top}\bm{C}$. The objective is to predict a view's code $\bm{q}_i$ from the other view's features $\bm{z}_j$, and the problem is formulated via cross-entropy minimization as: \begin{equation} \label{eq:swav_loss} L(\bm{z}_1,\bm{z}_2) = \ell(\bm{q}_1,\bm{z}_2) + \ell(\bm{q}_2,\bm{z}_1) \end{equation} \noindent where the first term is \begin{equation} \ell(\bm{q}_1,\bm{z}_2) = - \sum_{k=0}^{K} \bm{q}_1^k \, \textup{log} \, \bm{p}_2^k \;, \end{equation} where $\bm{q}_1$ represents the prototype likelihood or soft cluster assignment of $\bm{x}_1$, $\bm{p}_2^k$ represents the prediction of $\bm{q}_1$ as the softmax of $\bm{z}_{2}^{\top}\bm{c}_{k} / \tau$ and $\tau$ is a temperature parameter. Additionally, $\bm{q}_1^k$ comes from $\bm{Q}$, which normalizes all $\bm{q}$ in a mini-batch (or queue) using the Sinkhorn-Knopp algorithm. The second term of Eq. \eqref{eq:swav_loss} is similarly defined. In practice, SwAV uses more than two views per image. More specifically, the concept of multi-crop is introduced, where crops taken as part of the augmentation strategy can be either global or local concepts of an image. Furthermore, the problem is formulated in such a way that prototype code $\bm{q}$ assignments are only done on global views, while predictions $\bm{p}$ are done using both local and global views. \noindent {\bf Our SwAV-S.} To better exploit unlabeled object regions from videos, we introduce a set structure into SwAV's formulation, resulting in a new SSL variant dubbed as {\em SwAV-S}. Specifically, we sample a subset of object regions from $\mathcal{B}^{'} = \{\bm{B}_i\}_{i=1:N}, \mathcal{B}^{'} \subset \mathcal{B}$ from each video. Then, each region undergoes an independent image transformation and is treated as one view of $V$ to be predicted (or contrasted) from another region of the same set. This set of regions are encoded, generating embedding vectors $\{\bm{z}_i=g_B(f_B(V,\bm{B}_i; \theta_B);\phi_B)\}_{i=1:N}$, where $f_B$ and $g_B$ represent a non-linear encoder function and projection head, respectively. In contrastive learning design, we make a couple of important differences against original SwAV. (1) At each training iteration, we sample $N>2$ object regions $\{B_i\}_{i=1:N}$ from a video sequence $V$. (2) We only consider global views, which allows the expansion of terms in Eq. \eqref{eq:swav_loss} to $N$, effectively treating all object regions as a set as follows: \begin{equation} \label{eq:swavs_loss} L = \frac{-1\hphantom{-}}{N^2\!-\!N} \sum^N_i \sum^{N}_{j \neq i} \sum_{k=0}^{K} \bm{q}_i^k \, \textup{log} \! \left ( \! \frac {\textup{exp} \left ( \frac{1}{\tau}\bm{z}_{j}^{\top}\bm{c}_{k} \right )}{\sum_{k'}\textup{exp} \left ( \frac{1}{\tau}\bm{z}_{j}^{\top}\bm{c}_{k'} \right )} \! \right ) \end{equation} where ($i,j$) indexes the pairs of regions from a video. \paragraph{Discussion.} While our approach shares some high-level ideas w.r.t\ earlier SSL algorithms \cite{wangHG2017}, {SOS}{} relies on (1) different assumptions ({\it e.g.}, do not require an explicit graph of relations among patches or tracking), (2) different aim (integrating object representations for action recognition), and (3) specific methodology (self-supervised learning over sets). All in all, our approach revives this line of research with a refreshing perspective and using leveraging recent insights. \subsection{Target task finetuning: {OIC}{} Net and Model Fusion} \label{sec:aggr} Following the typical transfer learning of SSL pipelines, The pre-trained enhanced object region encoder $\theta_B$ serves as initialization for the {OIC}{} encoder $f_B$ addressing the target task ({\it cf.}\ Fig. \ref{fig:fuse} - {OIC}{} Net). In our case, the target task corresponds to supervised video classification by means of object patches. Given a set of object regions $\mathcal{B}$ per video, we feed them through the {OIC}{} encoder, followed by a pooling module aggregating the information from all the cohort to obtain the classification logits of interest $l= h(f_{B}(V,\mathcal{B};\theta)) \in \mathbb{R}^{\lvert\mathcal{Y}\rvert}$, where $\lvert\mathcal{Y}\rvert$ corresponds to the size of the label space. Note that we only have access to the weak video-level supervision. We apply the standard cross-entropy loss between the logits and the video-level label to optimize the network parameters. \paragraph{Class imbalanced finetuning.} To complement our {SOS}{} pre-training for tackling the class imbalance issue, we adopt the recent logit adjustment method \cite{menon2020long} with the key idea to impose the class distribution prior of training data through logit regulation. For training, we optimize a logit adjustment cross-entropy loss, $L_{la} = -\log\frac{e^{f_y + \tau\log{\pi_y}}} {\sum_{y' \in \mathcal{Y}} e^{f_{y'} + \tau\log{\pi_{y'}}}}$ with $\pi_y$ the frequency of class $y$ on the training set (i.e., the class prior), and $\tau$ the temperature. In our case, we impose this adjustment to the noun and verb branches separately, so that their imbalance can be remedied according to their respective distribution priors. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{figures/system_diagram_ECCV22.pdf} \vskip -0.3cm \caption{ {\bf Our {OIC}{} model can complement any existing video classification network, Video Net.} While most existing classification networks consume the entire video frames, ours {OIC}{} only takes object regions. Their predictions are then late fused. } \label{fig:fuse} \vspace{-0.5cm} \end{figure} \paragraph{Model Fusion.} Once trained as discussed above, our {OIC}{} model can be integrated with any existing action models \cite{bulat2021space,lin2019temporal,feichtenhofer2019slowfast} as depicted in Fig. \ref{fig:fuse}. For simplicity and flexibility, we use a weighted late-fusion of video predictions as: \begin{equation} \bm{l} = \alpha_{\text{{OIC}{}}} \bm{l}_{\text{{OIC}{}}} + \alpha_{i} \bm{l}_i, \label{eq:fuse} \end{equation} where $\bm{l}_{\text{OCI}}, \bm{l}_i$ are the classification logits of our {OIC}{} and any existing model; and $\alpha_{\text{OCI}}, \alpha_i$ are scalars weighting the confidence of each model. In practice, we set $\alpha_{\text{OCI}}, \alpha_i$ based on the performance of each individual model on a pilot validation set ({\it e.g.}, 30\% of training set). In the case of verb and noun based action prediction, the fusion is applied separately. \section{Experiments} \paragraph{Datasets.} We evaluate our method on two standard egocentric video datasets in the domain of kitchen environments. {\bf \em EPIC-KITCHENS-100} \cite{damen2020rescaling} is a large-scale egocentric action recognition dataset with more than 90,000 action video clips extracted from 100 hours of videos in kitchen environments. It captures a wide variety of daily activities in kitchens. The dataset is labeled using 97 verb and 300 noun classes and their combinations define different action classes. Please refer to the \textbf{supplementary material} for results in the test server, additional details, among others. {\bf \em EGTEA} \cite{li2018eye} is another popular egocentric video dataset consisting of 10,321 video clips annotated with 19 verb classes, 51 noun classes, and 106 action classes. \paragraph{Performance metrics.} We report the model evaluation results using the standard action recognition protocol \cite{damen2020rescaling,li2018eye}. Specifically, each model predicts the verb and the noun using two heads, and the accuracy rates of verb, noun, and action ({\it i.e.}\ verb and noun tuple) are calculated as performance metric. For EPIC-KITCHENS-100, we report the standard accuracy on different set of action classes. For EGTEA, we adopt the mean class accuracy on the three train/test splits. \paragraph{Implementation details.} We use an off-the-shelf hand-object contact detector to extract candidate regions of interest where it is likely to find hands and manipulated objects~\cite{shan2020understanding}. We only consider the object regions and select those with a confidence threshold greater than $0.01$ non-filtered by the typical non-maxima suppression operation of object detector pipelines~\cite{gkioxari2018detecting}. Each region of interest is cropped from the original frame size, and resized such that the resolution of each object region is $112 \times 112$. During training, we enable the center and size jittering as means of data augmentation. The jittering is proportional to the size of the region of interest, and sampled from a uniform distribution $[1, 1.25)$. For each frame, we consider three regions at most. At test time, we retained the most confident detected regions. Yet, we sampled object regions irrespective of the confidence score during training for data augmentation purposes. Our {OIC}{} network uses a 2D-CNN backbone, ResNet-50~\cite{resnet2016}, to encode each object region. Its Pool block corresponds to an integrated classifier followed by a aggregation module, the video prediction is done by classifying each object region independently, and then aggregating all the object prediction with a parameter-less Mean pooling operation. We use the standard frame sampling~\cite{wang2018temporal}, and modestly consider 8 frames per video. In contrast to prior art \cite{bulat2021space}, we did \underline{not} resort on additional test-time data augmentations ({\it e.g.}\ multi-crop/views) per video. Thus, the performance of our model could improve further. During the on-domain SOS self-supervised pre-training (Stage II{}), we apply the standard set of photometric and geometric data augmentation ({\it e.g.}, color jittering and cropping). Refer to~\cite{caron2020unsupervised} for more details. We resort in single-machine training with a batch size of 256 over 400 epochs and used the default optimization hyperparameters~\cite{caron2020unsupervised}. We initialize the CNN backbone of {OIC}{} from an off-the-shelf self-supervised pre-trained network on ImageNet~\cite{caron2020unsupervised} ({\it i.e.}, Stage I{} pre-training). During the target task stage, we tune the whole {OIC}{} network end-to-end for the purpose of video classification. We train with SGD using an initial learning rate of $0.02$ and momentum $0.9$ with a batch size of 64 videos. We decay the learning rate by a factor of 0.1 after 20 epochs. We implemented our approach using Pytorch~\cite{pytorch}, PytorchLightning~\cite{pytorchLightning} and the NUMFocus and image processing stack~\cite{numpy,pil}. \subsection{Evaluation on EPIC-KITCHENS-100} \label{sec:epic100_standard_eval} \begin{figure}[t] \centering \includegraphics[width=\linewidth]{figures/qulitative_CVPR22_v3.pdf} \vskip -0.3cm \caption{{\bf Qualitative results.} The green bounding boxes represent automatically detected object regions being manipulated. The left examples are corrected by our method, while the right two examples either errors were maintained or flipped.} \label{fig:qualitative} \vspace{-0.5cm} \end{figure} \noindent {\bf Qualitative analysis } Fig. \ref{fig:qualitative} depicts qualitative results, each quadrant depicts three frames from a particular video with its associated object regions, ground truth labels, and the predictions made by TSM as well as OURS ({\it i.e.}, TSM+{OIC}{}). Correctly predicted verbs and nouns are highlighted as green, while incorrectly predicted as red. We observe that {OIC}{} network provides additional context to guide predictions correctly. Fig. \ref{fig:qualitative} (bottom left) depicts an example where the noun of interest is mainly out of view during the duration of clip (only visible at the very beginning and at the end), hence the verb is also implicitly also not visible. Nevertheless, including the {OIC}{} module allows this information to be correctly captured and preserved. Similarly, Fig. \ref{fig:qualitative} (top right) shows that TSM alone makes somewhat nonsensical prediction of ``fill, tap'', while ours predicts ``wash, bowl" which is arguably visually and semantically closer to the ground truth ``fill, bowl'', after all filling a bowl looks much like washing a bowl. However, both TSM and ours still struggle with visually confusing noun classes, as shown in Fig. \ref{fig:qualitative} (bottom right). Although both models correctly predict the verb ``pour-in", they both confuse the white water kettle with a jug of milk. Perhaps surprisingly, we appreciate that TSM often struggles with seemingly simple cases (noun and verb clearly visible and executed), as shown in Fig. \ref{fig:qualitative} (top left), while the inclusion of {OIC}{} greatly alleviates this problem. \noindent {\bf Baselines } For extensive comparative evaluation, we consider a variety of state-of-the-art action recognition models including (1) top CNN action models: TSM \cite{lin2019temporal}, and SlowFast \cite{feichtenhofer2019slowfast} designed for generic action recognition tasks with varying architectural design for spatio-temporal representation learning, (2) a recent vision transformer: X-ViT \cite{bulat2021space} with superior cost-effective formulation for spatio-temporal attention learning, and (3) the latest egocentric action model: IPL \cite{wang2021interactive} designed to learn superior active object representation subject to human motion cues. We test the effective of our {OIC}{} in improving several above methods with the proposed fusion method. \begin{table*}[!t] \centering \resizebox{\columnwidth}{!}{% \setlength{\tabcolsep}{3pt} \begin{tabular}{l|lc|ccc|ccc|ccc|ccc} \toprule \multirow{3}{*}{Modality} & \multirow{3}{*}{Method} & \multirow{3}{*}{TTDA} & \multicolumn{6}{c|}{Overall} & \multicolumn{3}{c|}{Unseen participants} & \multicolumn{3}{c}{Tail classes} \\ & & & \multicolumn{3}{c|}{Top-1} & \multicolumn{3}{c|}{Top-5} & \multicolumn{3}{c|}{Top-1} & \multicolumn{3}{c}{Top-1} \\ & & & Verb & Noun & Action & Verb & Noun & Action & Verb & Noun & Action & Verb & Noun & Action \\ \midrule V & TSM$^\dagger$ \cite{lin2019temporal} & \xmark & 63.0 & 47.3 & 35.6 & 88.9 & 74.2 & 57.2 & \bf 54.6 & 37.1 & 26.3 & 35.9 & 26.7 & 18.1 \\ V & + {\bf {OIC}} & \xmark & \bf 64.0 & \bf 52.3 & \bf 39.0 & \bf 90.2 & \bf 78.4 & \bf 61.6 & 53.1 & \bf 40.3 & \bf 27.2 & \bf 36.2 & \bf 29.9 & \bf 20.5 \\ \cmidrule(lr{1em}){2-15} V & SlowFast$^\dagger$ \cite{feichtenhofer2019slowfast} & \xmark & 65.6 & 50.0 & 38.5 & \bf 90.0 & 75.6 & 58.7 & \bf 56.7 & 41.6 & 30.0 & 36.3 & 23.3 & 18.7 \\ V & +{\bf {OIC}} & \xmark & \bf 66.5 & \bf 53.5 & \bf 40.9 & 89.6 & \bf 77.8 & \bf 61.8 & 56.6 & \bf 43.6 & \bf 31.1 & \bf 37.6 & \bf 27.3 & \bf 20.3 \\ \cmidrule(lr{1em}){2-15} V & X-ViT$^\dagger$ \cite{bulat2021space} & \xmark & 62.9 & 49.1 & 37.7 & 87.5 & 73.8 & 57.1 & 54.4 & 41.7 & 30.5 & 35.7 & 28.0 & 19.42 \\ V & +{\bf {OIC}} & \xmark & \bf 64.7 & \bf 54.6 & \bf 40.9 & \bf 91.0 & \bf 79.3 & \bf 62.8 & \bf 54.6 & \bf 43.8 & \bf 31.2 & \bf 37.0 & \bf 31.1 & \bf 21.2 \\ \cmidrule(lr{1em}){2-15} V & X-ViT \cite{bulat2021space}$^\dagger$ & \cmark & 68.7 & 56.4 & 44.3 & 90.4 & 79.4 & 64.5 & 57.8 & 47.4 & 34.9 & 38.2 & 31.8 & 22.4 \\ V & +{\bf {OIC}} & \cmark & \underline{\bf 69.3} & \underline{\bf 57.9} & \underline{\bf 45.7} & \bf 91.2 & \underline{\bf 81.1} & \underline{\bf 66.2} & \bf 57.9 & \underline{\bf 49.3} & \underline{\bf 36.3} & \underline{\bf 38.6} & \underline{\bf 33.1} & \underline{\bf 23.7} \\ \midrule V+F & TSM$^\dagger$ \cite{lin2019temporal} & \xmark & 67.9 & 49.1 & 38.4 & 91.0 & 74.9 & 60.7 & 58.5 & 39.2 & 29.3 & 36.8 & 22.5 & 17.7 \\ V+F & +{\bf {OIC}} & \xmark & \bf 68.4 & \bf 53.7 & \bf 41.8 & \underline{\bf 91.4} & \bf 78.7 & \bf 64.0 & \underline{\bf 58.7} & \bf 42.7 & \bf 30.8 & \bf 37.1 & \bf 26.7 & \bf 20.1 \\ \cmidrule(lr{1em}){2-15} V+F & IPL(I3D) \cite{wang2021interactive} & \xmark & 67.82 & 50.87 & 39.87 & - & - & - & - & - & - & - & - & - \\ V+F & IPL(R2+1D) \cite{wang2021interactive} & \xmark & 68.61 & 51.24 & 40.98 & - & - & - & - & - & - & - & - & - \\ \bottomrule \end{tabular} } \caption{{\bf Results on the validation set of EPIC-KITCHENS-100} \cite{damen2020rescaling}. Modality: V=Visual; F=Optical flow. $^\dagger$: Results computed with the model weights released by the authors of \cite{damen2020rescaling,bulat2021space}. TTDA: Test-time data-augmentation ({\it e.g.}, multi-crop). Underlined numbers correspond to best results across the board. Bold numbers highlight the best between a proxy model and proxy + ours. All in all, our model yields state-of-the-art results and it is versatile as improved four action classification models. } \label{tab:sota_epic} \vspace{-25pt} \end{table*} \noindent {\bf Results analysis } We report the action recognition results in Table \ref{tab:sota_epic}. We have the following observations: {\bf (1)} The performance of CNN action models, SlowFast and TSM, is similar to the recently introduced X-ViT without heavy test-time data augmentation. {\bf (2)} Importantly, our {OIC}{} further improves SlowFast(V), TSM(V+F) and X-ViT by 2.4\%, 3.4\%, and 3.2\% on overall action accuracy, respectively. Without using computationally expensive optical flow, TSM still benefits from {OIC}{} at similar scale. These results verify the versatility and consistent usefulness of our {OIC}{} in enhancing prior art models. It is also seen that the improvement is mainly achieved on noun recognition as expected. This indicates that these methods are limited in extracting active objects in manipulation and interaction with human hands from cluttered background and scene. This is exactly the motivation of learning our {OIC}{} model. {\bf (3)} We also observes that our {OIC}{} clearly improves the accuracy scores on unseen participants and tail classes. This implies that exploiting our {OIC}{} could help reduce the negative impact of domain shift (seen vs. unseen participants in this case) and mitigate the overwhelming effect from head classes to tail classes, concurrently. {\bf (4)} Along with TSM, our method also clearly outperforms the latest egocentric action model IPL which is designed to learn better active object representations. This indicates that without explicit region detection, the CNN model itself is less effective to isolate the active objects from the scenes. {\bf (5)} The recent X-ViT model significantly lifts the performance of CNN by means of additional test-time data augmentation ({\it i.e.}, averaging the results from 3 crops per video). It is worth noting that even after triplicating the computational budget, our computationally modest {OIC}{} representation stills provides a further gain of 1.4\% on overall actions to this model. It is possible that our {OIC}{} and previous CNNs model could benefit from the test-time data augmentation techniques. If so, it is worth balancing the euphoria surrounding Transformer-based models with fair and rigorous experimental evaluation. \vspace{-10pt} \subsection{Evaluation on EGTEA} \begin{table}[!t] \centering \setlength{\tabcolsep}{5pt} \resizebox{0.6\columnwidth}{!}{% \begin{tabular}{l|l|ccc|c} \toprule {Modality} & {Method} & Split 1 & Split 2 &Split 3 & Avg \\ \hline V & TSM \cite{lin2019temporal} & 61.2 & 61.2 & 59.6 & 60.7 \\ V & TSM+{\bf {OIC}} & \bf 62.0 &\bf 61.9 &\bf 60.0 &\bf 61.3 \\ \midrule V+F & 2SCNN* \cite{simonyan2014very} & 43.8 & 41.5 & 40.3 & 41.8 \\ V+F & I3D* \cite{carreira2017quo} & 55.8 & 53.1 & 53.6 & 54.2 \\ V+F & I3D+Center Prior* & 52.5 & 49.4 & 49.3 & 50.4 \\ V+F & I3D+EgoConv* \cite{singh2016first} & 54.2 & 51.5 & 49.4 & 51.7 \\ V+F & Ego-RNN-2S* \cite{sudhakaran2018attention} & 52.4 & 50.1 & 49.1 & 50.5 \\ V+F & LSTA-2S* \cite{sudhakaran2019lsta} & 53.0 & - & - & - \\ V+F & MutualCtx-2S* \cite{huang2020mutual} & 55.7 & - & - & - \\ V+F & Prob-ATT \cite{li2021eye} & 56.5 & 53.5 & 53.6 & 54.5 \\ V+F & I3D+IPL \cite{wang2021interactive} & 60.2 & 59.0 & 57.9 & 59.1 \\ \midrule V+F+G & I3D* \cite{carreira2017quo} & 53.7 & 50.3 & 49.6 & 51.2 \\ V+F+G & Prob-ATT \cite{li2021eye} & 57.2 & 53.8 & 54.1 & 55.0 \\ \bottomrule \end{tabular} } \caption{ {\bf Comparison against state of the art in EGTEA \cite{li2018eye}}. Modality: V=Visual; F=Optical flow; G=Gaze. *: Results taken from \cite{li2021eye}.} \label{tab:sota_egtea} \vspace{-15pt} \end{table} \noindent {\bf Baselines } Compared to EPIC-KITCHENS-100, this dataset is uniquely featured with eye gaze tracking information. We compare our method with the following alternatives: (1) 2SCNN \cite{simonyan2014very}: A two stream networks with VGG16 backbone, (2) I3D \cite{carreira2017quo}: A two stream I3D with joint training of RGB and optical flow, (3) I3D+Gaze: Instead of average pooling, the ground truth human gaze is leveraged to pool the features from the last conv layer, (4) I3D+Center Prior: A fixed 2D Gaussian distribution at the center is applied as the attention map for pooling the last conv features, (5) I3D+EgoConv \cite{singh2016first}: Adding a stream of egocentric cues for encoding head motion and hand mask, and the output scores are late fused with RGB and optical flow streams, (6) Ego-RNN-2S \cite{sudhakaran2018attention} and LSTA-2S \cite{sudhakaran2019lsta}: two recurrent networks with soft-attention, (7) MutualCtx-2S \cite{huang2020mutual}: A gaze enhanced action model trained by alternating between gaze estimation and action recognition, (8) Prob-ATT \cite{li2021eye}: A state-of-the-art joint gaze estimation and action recognition model featured with a stochastic gaze distribution formulation, (9) TSM \cite{lin2019temporal}: A recent strong action recognition model with efficient temporal shift operation between nearby frames for motion modeling, (10) IPL \cite{wang2021interactive}: A recent state-of-the-art egocentric action model as discussed earlier. We combine our {OIC}{} with TSM in evaluating this dataset. \paragraph{Results analysis.} Table \ref{tab:sota_egtea} reports the results. We observed that: {\bf (1)} using gaze modality does not guarantee superior results; For example, without gaze IPL still achieves better results than Prob-ATT using gaze. This suggests that video data alone already provide rich information and the key is how to learn and extract discriminative action information with proper model design. % The way to leverage the gaze data is also equally critical. {\bf (2)} Similarly, the computationally expensive optical flow is not the highest performance promise, as indicated by the excellent performance with TSM using only 2D video frames as input. {\bf (3)} Importantly, our {OIC}{} again further improves the performance of TSM consistently over all the splits, suggesting the generic efficacy of our method on a second test scenario. \vspace{-5pt} \subsection{SOS and Long-tail Learning} \label{exp:sos_lt} Here we present a rigorous assessment on the role of our SOS pre-training for dealing with class-imbalance distributions in videos. \textbf{\textit{Dataset and metrics}}. We perform the study in the validation set of EPIC-KITCHENS-100 using the standard metrics for evaluating long-tail learning algorithms \cite{dong2018imbalanced}, class-balanced average accuracy for verb, noun and action. Concretely, each video is weighted by the inverse of the number of instances of its corresponding label. Note that we retain the tail classes definition from \cite{damen2020rescaling}, but the metrics reported in this section differ from those in Table \ref{tab:sota_epic}. \textbf{\textit{Baselines}}. We consider our {OIC}{} network aided (or not) with our {SOS}{} pre\=/training and using (or not) the long-tail (LT) loss of \cite{menon2020long} during the target task fine-tuning. We also report of single-crop X-ViT \cite{bulat2021space}, using the pre-trained weights of the authors, and our fused model. \begin{table*}[!t] \centering \setlength{\tabcolsep}{4pt} \begin{tabular}{llcc|ccc|ccc} \toprule & \multirow{2}{*}{Method} & \multirow{2}{*}{SOS} & \multirow{2}{*}{\shortstack{LT loss\\ \cite{menon2020long}}} & \multicolumn{3}{c|}{Overall} & \multicolumn{3}{c}{Tail classes} \\ & & & & Verb & Noun & Action & Verb & Noun & Action \\ \midrule \bf A & {\bf {OIC}} &\xmark &\xmark & 18.2 & 21.1 & 8.7 & 13.2 & 11.9 & 6.1 \\ \bf B & {\bf {OIC}} & \xmark & \cmark & 27.5 & 25.0 & 8.1 & 25.4 & 19.9 & 7.1 \\ \bf C & {\bf {OIC}} & \cmark & \xmark & 20.8 & 25.0 & \bf 10.8 & 15.9 & 16.7 & 8.6 \\ \bf D & {\bf {OIC}} & \cmark & \cmark & \underline{\bf 30.3} & \bf 28.0 & 9.4 & \underline{\bf 28.6} & \bf 23.4 & \bf 8.7 \\ \midrule \bf E & X-ViT & \xmark & \xmark & 22.1 & 25.9 & 12.8 & 15.9 & 17.8 & 9.5 \\ \bf F & X-ViT + {\bf {OIC}} & \cmark & \cmark & \bf 30.2 & \underline{\bf 31.8} & \underline{\bf 15.2} & \bf 25.2 & \underline{\bf 24.9} & \underline{\bf 12.8} \\ \bottomrule \end{tabular} \caption{{\bf Long-tail results (accuracy) on the validation set of EPIC-KITCHENS-100}, showcasing the impact of SOS for dealing with class-imbalance distributions. Refer to text for details about the metric. } \label{tab:lt_epic} \vspace{-25pt} \end{table*} \paragraph{Results analysis.} Table \ref{tab:lt_epic} reports the results. We observed that: {\bf (1)} Our {SOS}{} pre-training indeed helps for dealing with class-imbalanced scenarios. It naturally improves noun and action classes the most, by +3.9\% and +2.1\% overall classes respectively (row \textbf{C} v.s. \textbf{A}). Note that aiding {OIC}{} with {SOS}{} (\textbf{C}) significantly reduced the gap between the X-ViT (\textbf{E}) and our plain {OIC}{} (\textbf{A}). {\bf (2)} {SOS}{} is complementary to the state-of-the-art LT learning approach. {SOS}{} and the LT loss \cite{menon2020long} yields the best results for the {OIC}{} model, except for overall action classes where {SOS}{} pre-training achieves the best result. The relatively minor setback evidences the relevance of studying LT and SSL pre-training within the context of structured labels such as actions in videos. {\bf (3)} Our fused model (\textbf{F}) , X-ViT with {OIC}{} aided with {SOS}{} and the LT loss \cite{menon2020long}, achieves the state-of-the-art on LT accuracy for noun and action by a large margin. Overall, we have validated the relevance and complementary of {SOS}{} for dealing with long-tail learning scenarios in egocentric action recognition. \vspace{-5pt} \subsection{Ablation Study} \label{sec:exp_ablation} As prior art~\cite{wang2021interactive}, we validate the contribution of the major components of our approach on EPIC-KITCHENS-100. We report the top-1 accuracy for Verb, Noun and Action for overall and tail classes following~\cite{damen2020rescaling}. \paragraph{Impact of an off-the-shelf self-supervised encoder.} Encoders learned via supervised learning might overfit the label space of the pre-training source. In contrast, state-of-the-art self-supervised learning relies on a set of data augmentations and measure of instance similarity. Thus, it is worth studying whether an off-the-shelf self-supervised encoder offers any advantage for representing the visual regions of handled objects in a target dataset. We use two different off-the-shelf encoders learned via: (A) supervision, and (B) self-supervision, both using ImageNet~\cite{russakovsky2015imagenet} and acting as initialization for our {OIC}{} backbone. Table~\ref{tab:single_table_ablation} row {\bf A} reports the results of using a supervised pre-trained encoder as initialization, while row {\bf B} reports when initialization is done via self-supervision. We observe that self-supervised initialization improves the performance w.r.t\ supervised initialization in noun by 1.3\% and action by 0.5\% without significantly degrading verb performance. These results echo the relevance and popularity of self-supervised pre-training~\cite{goyalCLXWPSLMJB2021} in the domain of egocentric visual perception, which has been relatively under-explored. \begin{table}[!t] \centering \setlength{\tabcolsep}{3pt} \begin{tabular}{llc|ccl|ccl} \toprule \multirow{2}{*}{} & \multirow{2}{*}{Method} & \multirow{2}{*}{OD} & \multicolumn{3}{c|}{Overall} & \multicolumn{3}{c}{Tail classes} \\ & & & Verb & Noun & Action & Verb & Noun & Action \\ \midrule {\bf A} & Supervised pre-training & \xmark & 49.3 & 44.5 & 27.4 & 32.0 & 23.6 & 14.8 \\ {\bf B} & SwAV & \xmark & 49.2 & 45.8 & 27.9 & 31.2 & 21.2 & 14.0 \\ {\bf C} & SwAV & \cmark & 49.9 & 47.0 & 28.7 & 30.6 & 23.1 & 14.6 \\ {\bf D} & SwAV-S & \cmark & \bf 51.5 & \bf 48.5 & {\bf 30.2} & \bf 32.4 & \bf 25.6 & {\bf 16.4} \\ \bottomrule \end{tabular} \caption{ \label{tab:single_table_ablation} {\bf Ablation of different components of our approach on EPIC-KITCHENS-100.} Rows {\bf A}-{\bf D} report the top-1 accuracy of the {OIC}{} model by itself ({\it i.e.}, without video network fusion) for \textit{overall} and \textit{tail} Verb, Noun and Action instances~\cite{damen2020rescaling}. OD: On-Domain pre-training in target dataset, EPIC-KITCHENS-100. } \vspace{-25pt} \end{table} \paragraph{Impact of self-supervised adaptation.} We gauge the impact of adapting the off-the-shelf self-supervised representation to the domain of interest, EPIC-KITCHENS-100 manipulated object regions. For this purpose, we employ the standard SwAV loss (Eq.~\eqref{eq:swav_loss}) during the Stage II{} pre-training, ({\it cf.}\ Fig. \ref{fig:pipeline}). We use the original set of data augmentations and optimization hyper-parameters as in~\cite{caron2020unsupervised}. Table~\ref{tab:single_table_ablation} row {\bf C} reports the results of the self-supervised domain adaptation with SwAV loss over individual object regions (Fig. \ref{fig:swavs} - top). Adapting the representation helps to boost the predictive power for verb, noun and action by 0.7\%, 1.2\% and 0.8\% w.r.t no domain adaptation Table~\ref{tab:single_table_ablation} row {\bf B}. \paragraph{Relevance of SwAV-S.} We validate the impact of SwAV-S, which treats actions as a natural self-supervised transformation. For this purpose, we employ the SwAV-S loss (Eq.~\eqref{eq:swavs_loss}) during the Stage II{} pre-training (see Fig. \ref{fig:pipeline}). We kept the same set of hyper-parameters as SwAV. Table~\ref{tab:single_table_ablation} row {\bf D} reports the results of SwAV-S. We observe a more significant boost in performance across the board and surpasses SwAV (Table~\ref{tab:single_table_ablation} row {\bf C}) by 1.6\% for verb, 1.5\% for noun and 1.5\% for action. This result validates the stronger benefit of our novel approach for self-supervised domain adaptation. \section{Conclusions} We have presented a novel method for incorporating object information into egocentric action recognition models. Resorting to self-supervised learning (SSL), our method does not require object-level annotations, and exploits hand-object contact detection to directly select foreground objects and sieve out background distractors. Through a careful SSL design, it obtains a strong representation for objects being manipulated. Experiments show that prior state-of-the-art video models can consistently benefit from our object model on two egocentric datasets, with improved ability to tackle the challenging class imbalance. \clearpage \section{Appendix} \input{sections/appendix.tex} \bibliographystyle{splncs04} \subsection{A closer look into our results on Epic-Kitchens-100} \subsection{Results in EPIC-KITCHENS-100 test set} \label{sec_a:test_epic100} To validate the generalization of the insights presented on the main paper, we resort in the test set of EPIC-KITCHENS-100 with sequestered labels. Concretely, we submitted the predictions of a given model onto the evaluation server. Table \ref{tab:epic_test} reports the results from the evaluation server, with the metrics established by the dataset creators \cite{damen2020rescaling}. Overall the observations drawn from the validation can be seen in the test set with sequestered data. We repeat some of the main observations here: {\bf (1)} The performance of CNN action models, TSM, is similar to the recently introduced X-ViT without heavy test-time data augmentation. {\bf (2)} Importantly, our {OIC}{} further improves X-ViT by 1.6\%, 5.4\%, and 2.6\% on overall verb, noun and action accuracy, respectively. It is also seen that the improvement is mainly achieved on noun recognition as expected. Thus, it indicates that the attention mechanism of transformer is limited in extracting active objects in manipulation and interaction with human hands from cluttered background and scene. This is exactly the motivation of learning our {OIC}{} model. {\bf (3)} We also observes that our {OIC}{} clearly improves the accuracy scores on unseen participants and tail classes. This implies that exploiting our {OIC}{} could help reduce the negative impact of domain shift (seen vs. unseen participants in this case) and mitigate the overwhelming effect from head classes to tail classes, concurrently. {\bf (4)} The recent X-ViT model significantly lifts the performance of CNN by means of additional test-time data augmentation ({\it i.e.}, averaging the results from 3 crops per video). It is worth noting that even after triplicating the computational budget, our computationally modest {OIC}{} representation stills provides a further gain of 1.2\% on overall actions to this model. \begin{table*}[!t] \centering \resizebox{\columnwidth}{!}{% \setlength{\tabcolsep}{3pt} \begin{tabular}{l|lc|ccc|ccc|ccc|ccc} \toprule \multirow{3}{*}{Modality} & \multirow{3}{*}{Method} & \multirow{3}{*}{TTDA} & \multicolumn{6}{c|}{Overall} & \multicolumn{3}{c|}{Unseen participants} & \multicolumn{3}{c}{Tail classes} \\ & & & \multicolumn{3}{c|}{Top-1} & \multicolumn{3}{c|}{Top-5} & \multicolumn{3}{c|}{Top-1} & \multicolumn{3}{c}{Top-1} \\ & & & Verb & Noun & Action & Verb & Noun & Action & Verb & Noun & Action & Verb & Noun & Action \\ \midrule V & X-ViT$^\dagger$ \cite{bulat2021space} & \xmark & 58.5 & 46.9 & 34.5 & 85.2 & 71.4 & 53.0 & 50.4 & 37.7 & 25.7 & 28.2 & 21.9 & 14.0 \\ V & +{\bf {OIC}} & \xmark & \bf 60.1 & \bf 52.3 & \bf 37.1 & \bf 87.7 & \bf 77.7 & \bf 59.0 & \bf 53.0 & \bf 44.9 & \bf 28.8 & \bf 30.4 & \bf 25.2 & \bf 16.1 \\ \cmidrule(lr{1em}){2-15} V & X-ViT \cite{bulat2021space}$^\dagger$ & \cmark & 64.3 & 52.9 & 40.3 & 88.1 & 77.4 & 60.6 & 58.2 & 45.7 & 32.0 & 31.2 & 26.3 & 17.7 \\ V & +{\bf {OIC}} & \cmark & \underline{\bf 64.7} & \underline{\bf 55.0} & \underline{\bf 41.5} & \underline{\bf 89.2} & \underline{\bf 79.5} & \underline{\bf 62.7} & \underline{\bf 58.6} & \underline{\bf 48.0} & \underline{\bf 33.0} & \underline{\bf 31.4} & \underline{\bf 27.6} & \underline{\bf 18.1} \\ \midrule V & TSM$^\dagger$ \cite{lin2019temporal} & \xmark & 58.5 & 45.9 & 32.8 & 86.4 & 72.3 & 54.0 & 53.1 & 41.1 & 27.1 & 27.9 & 21.5 & 13.8 \\ F & TSM$^\dagger$ \cite{lin2019temporal} & \xmark & 60.9 & 33.8 & 26.2 & 86.1 & 57.6 & 43.5 & 55.5 & 27.5 & 20.1 & 26.0 & 6.4 & 7.5 \\ \bottomrule \end{tabular} } \caption{{\bf Results on the test set of EPIC-KITCHENS-100} \cite{damen2020rescaling} with models \underline{only trained in the training set}. Modality: V=Visual; F=Optical flow. $^\dagger$: Results computed with the model weights released by the authors of \cite{damen2020rescaling,bulat2021space}. TTDA: Test-time data-augmentation ({\it e.g.}, multi-crop). Underlined numbers correspond to best results across the board. Bold numbers highlight the best between a proxy model and proxy + ours. All in all, our model complements X-ViT and yields state-of-the-art results. } \label{tab:epic_test} \end{table*} \subsection{Additional ablation of two models ensemble} \label{sec_a:ensemble_ablation} Our full video prediction network corresponds to the fusion of our {OIC}{} Net and one standard video classification network, {\it cf.}\ main paper Sec. \textcolor{red}{3.2} and Fig \textcolor{red}{4}. The intuition behind the proposed fusion are: (1) it allows to validate the relevance of handled objects and learning a specialized neural network representation for them. (2) It is a simple way to integrate the information capture by our {OIC}{} Net without the need of model re-training. (3) It combines the complementary information discovered by our {OIC}{} Net relating to objects while the video net provides the scene context. For fair comparison, we compare the results of our fused model w.r.t\ the proxy video network used in our fusion, and the ensemble of two networks of a given proxy model. \paragraph{\underline{\normalfont{Implementation details.}}} We used the standard TSM video architecture \cite{lin2019temporal} with the pre-trained networks given by \cite{damen2020rescaling} as the proxy video network. For the two model ensemble baseline, we train an additional TSM model using the code and training recipe given by \cite{damen2020rescaling}. For our fused model, we followed the training pipeline presented in the main paper. Table \ref{tab:epic_ensemble} reports the experimental results in the validation set of EPIC-KITCHENS-100 with the metrics established by the dataset creators \cite{damen2020rescaling}. We have the following observations: (1) TSM ensemble yield an absolute performance improvement of +0.7\%, +1.0\% and +0.6\% on overall verb, noun and action respectively. Meanwhile, our model fusion with {OIC}{} yields significantly better absolute improvement for noun and action (+5.0\% and +3.4\%), and slightly better absolute improvement for verb (+1.0\%). (2) We also observes that our {OIC}{} clearly improves the accuracy scores on unseen participants (for noun and action) and tail classes (for verb, noun and action). As expected, the most significant performance improvement are from noun accuracy. In summary, we have validated the significance of the results from our fused model, with {OIC}{}, in comparison to a stronger baseline. \begin{table*}[!t] \centering \resizebox{\columnwidth}{!}{% \setlength{\tabcolsep}{3pt} \begin{tabular}{l|ccc|ccc|ccc|ccc} \toprule \multirow{3}{*}{Method} & \multicolumn{6}{c|}{Overall} & \multicolumn{3}{c|}{Unseen participants} & \multicolumn{3}{c}{Tail classes} \\ & \multicolumn{3}{c|}{Top-1} & \multicolumn{3}{c|}{Top-5} & \multicolumn{3}{c|}{Top-1} & \multicolumn{3}{c}{Top-1} \\ & Verb & Noun & Action & Verb & Noun & Action & Verb & Noun & Action & Verb & Noun & Action \\ \midrule TSM$^\dagger$ \cite{lin2019temporal} & 63.0 & 47.3 & 35.6 & 88.9 & 74.2 & 57.2 & 54.6 & 37.1 & 26.3 & 35.9 & 26.7 & 18.1 \\ TSM ensemble & 63.7 & 48.3 & 36.2 & 89.7 & 75.3 & 58.6 & \bf 55.3 & 38.5 & 26.8 & 34.7 & 26.3 & 18.0 \\ TSM + {\bf {OIC}} & \bf 64.0 & \bf 52.3 & \bf 39.0 & \bf 90.2 & \bf 78.4 & \bf 61.6 & 53.1 & \bf 40.3 & \bf 27.2 & \bf 36.2 & \bf 29.9 & \bf 20.5 \\ \bottomrule \end{tabular} } \caption{{\bf Results on the validation set of EPIC-KITCHENS-100} \cite{damen2020rescaling}. $^\dagger$: Results computed with the model weights released by the authors of \cite{damen2020rescaling}. Bold numbers highlight the best between a proxy model (TSM), two model ensemble of the proxy model (TSM ensemble), and proxy + ours (TSM + {OIC}{}). All in all, our {OIC}{} improves further the proxy model validating the relevance of our handled objects representation. } \label{tab:epic_ensemble} \end{table*} \begin{figure*}[!t] \centering \includegraphics[width=\linewidth]{figures/qualitative_sup2.pdf} \caption{ {\bf Qualitative results.} The green bounding boxes represent automatically detected object regions being manipulated. Rows ({\it a - f}) represent examples that are corrected by our method, rows ({\it g - i}) examples that are partially correct, while rows ({\it j - k}) depicts failure cases for both methods. } \label{fig:qualitative_sup} \end{figure*} \subsection{Qualitative results} \label{sec_a:qualitative_results} Fig.~\ref{fig:qualitative_sup} depicts additional qualitative results to those shown in Fig.~\textcolor{red}{5} in the {\it cf.}\ main manuscript. Here, each row depicts five evenly spaced frames from a particular example with its associated object regions, the ground truth labels, predictions made by TSM and predictions made by TSM+{OIC}{} (ours). Same as before, correctly predicted verbs and nouns are highlighted as green, while incorrectly predicted as red. These additional results further reinforce the notion that the additional context provided by the {OIC}{} module guides prediction correctly. Fig. \ref{fig:qualitative_sup} ({\it a - f}), depicts examples where the noun of interest is either very small ({\it a}, {\it b}, {\it e} and {\it f}), out of view during a large portion of the clip ({\it b} and {\it d}) or not well illuminated ({\it c}). Nevertheless, including the {OIC}{} module allows this information to be correctly captured and preserved, same which is lost or ignored with pure TSM. Fig. \ref{fig:qualitative_sup} , ({\it g}) depicts an example where both TSM and ours make a wrong prediction, in the case of TSM the verb is correctly identified, however, the noun predicted is very different from the ground truth. In this same example, our method correctly predicts the noun, while incorrectly predicting the verb; however, one could argue that the verb wrongly predicted by our method could apply to the example, while the same cannot be said by the wrongly predicted noun by TSM. Similar arguments as the ones just discussed for Fig.~\ref{fig:qualitative_sup} ({\it g}) would apply to {\it h}, where additionally TSM predictions of both verb and noud are incorrect. Finally, Fig.~\ref{fig:qualitative_sup} ({\it j} - {\it k}), shows two fail examples for both methods, where despite the fact that our method makes use of object boxes largely associated with the target noun, the proposed method still fails. Fig.~\ref{fig:qualitative_swav_patches_sup} shows examples of patches representing objects used during {SOS}{} pre-training stage, {\it i.e.}\ to train our proposed SwAV-S. The figure also displays the associated labels from the video for reference, but it is worth noting that our approach does not exploit the given labels during the {SOS}{} pre-training. There, it can be appreciated the \textit{real} spatio-temporal transformation that objects experience. These, represent the sets of objects presented to SwAV-S for cluster assignment and prediction. Fig.\ref{fig:qualitative_swav_patches_sup} left column illustrates cases where the action-process can easily be seen as the primary source of variation ({\it e.g.}, the first row exhibits large deformations of a box being flattened), while the right column illustrates more challenging examples, that nonetheless, are able to capture the semantics of the underlying action. The examples presented in Fig.\ref{fig:qualitative_swav_patches_sup} left, also elucidates why our approach still works without the need of tracking or strictly enforcing object correspondences across frames. \begin{figure*}[!t] \centering \includegraphics[width=\linewidth]{figures/qualitative_swav_patches_sup_v2.pdf} \caption{ {\bf Qualitative results.} SwAV-S input objects and their related \textit{real} spatio-temporal transformations. } \label{fig:qualitative_swav_patches_sup} \end{figure*} \subsection{Performance improvements perspective} \label{sec_a:tolerance} Recently, a study on the influence of random seeds in modern deep learning architectures in computer vision~\cite{picard2021torchmanualseed3407} was conducted. From this study, the relevance and importance of setting a confidence interval to gauge meaningful improvements in the performance of deep neural networks is brought to the forefront. However, in practice it is difficult to define rigorous statistical confidence intervals, as a complete training cycle of both our proposed SOS pre-training and target task takes approximately one week. Thus, we resort to a pragmatic approach to define a confidence interval. During the initial stage of this project, we ran our simplest baseline five times with the same hyperparameter configuration, but with different initialization seeds. By contrasting the differences in performance among the multiple performance metrics (KPIs) across multiple runs, we observe that KPIs varied in a range $\pm0.25\%$. Therefore, we deem relevant results those bigger than $0.5\%$.
{'timestamp': '2022-05-04T02:08:33', 'yymm': '2204', 'arxiv_id': '2204.04796', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04796'}
arxiv
\section{Introduction}\label{int} Linear regression is a popular method to depict the relationship between the response variable $y\in\mathcal Y$ and the covariate $\mathbf{x}\in\mathcal X\subset \mathbb R^p$. Observing $n$ independent and identically distributed data $\mathcal{F}_{n}=\{(\mathbf{x}_i,y_i)\}_{i=1}^n$, we consider the linear model $y_i=\mathbf{x}_i^{\top} \boldsymbol{\beta}+\epsilon_i,\, i=1,\dots,n,$ where $\epsilon_i$ is the independent and identically distributed error term with mean zero and variance $\sigma^2$. The model can be written in the matrix form $$\mathbf{y}=\mathbf{X} \boldsymbol{\beta}+\mathbf{\epsilon},$$ where $\mathbf{y}=(y_1,\dots,y_n)^{\top}$ is a response vector, $\mathbf{X}=(\mathbf{x}_1,\dots,\mathbf{x}_n)^{\top}$ is an $n\times p$ design matrix, $\boldsymbol{\epsilon}=(\epsilon_1,\dots,\epsilon_n)^{\top}$ is an error vector. The ordinary least square approach minimizes $\|\mathbf{y}-\mathbf{X} \boldsymbol{\beta}\|^{2}$ and leads to $\widehat{\boldsymbol{\beta}}_{\text{OLS}}=\left(\mathbf{X}^{\top} \mathbf{X}\right)^{-1} \mathbf{X}^{\top} \mathbf{y}$ provided that $\mathbf{X}^{\top} \mathbf{X}$ is invertible. Ridge regression, proposed by \cite{hoerl1970ridge} 50 years ago, provides a remedy for ill-conditioned $\mathbf{X}^{\top} \mathbf{X}$ in computing the ordinary least square estimator. The ridge regression estimator is defined by adding a ridge on the diagonal of $\mathbf{X}^{\top} \mathbf{X}$, that is, \begin{equation}\label{close_full} \widehat{\boldsymbol{\beta}}=\left(\mathbf{X}^{\top} \mathbf{X}+\lambda \mathbf{I}\right)^{-1} \mathbf{X}^{\top} \mathbf{y}, \end{equation} where $\lambda>0$ is called the ridge parameter. The optimization function for the ridge regression estimator can be written as \begin{equation}\label{opt_full} \min _{\boldsymbol{\beta}}\left\{\|\mathbf{y}-\mathbf{X} \boldsymbol{\beta}\|^{2}+\lambda \|\boldsymbol{\beta}\|^2\right\}. \end{equation} The ridge penalty introduces bias to the estimator, while the variance is reduced at the same time. It leads to a bias-variance trade-off when we attempt to predict at a new location, see e.g., \cite{hastie2009elements,hastie2020ridge}. Tuning the ridge parameter $\lambda$ is critical for balancing the bias and variance of the estimator. Typical methods for choosing the ridge parameter include the cross-validation and the generalized cross-validation \citep{golub1979generalized}. With massive data, it is often computationally prohibitive to calculate the estimator when either the sample size or the dimension is super large. In recent years, many research efforts have been devoted to addressing the computational issue due to the large data matrix. \cite{kumar2012sampling} explored the sampling approach for the column subset selection problem by the Nyström method. \cite{derezinski2020improved} recently provided an improved theoretical guarantee for low-rank approximations of large datasets. Another popular idea in machine learning is coreset, which constructs estimators based on sub-data. \cite{kacham2020optimal} utilized the spectral graph sparsification result of \cite{batson2012twice} and proposed to merge the coresets obtained from multiple servers. \cite{mahoney2011randomized, woodruff2014sketching} studied matrix sketching to generate smaller datasets with random projections. \cite{wang2017sketched} addressed the statistical and algorithmic properties of classical sketch and Hessian sketch. Recently, under the context of ridge regression models, ridge leverage scores, introduced by \cite{alaoui2015fast}, are defined as the diagonal elements of matrix $\mathbf{X}\left(\mathbf{X}^{\top} \mathbf{X}+\lambda \mathbf{I}\right)^{-1} \mathbf{X}^{\top}$. \cite{cohen2017input} extended the concept and proposed a low-rank projection-based approach via ridge leverage score sampling. \cite{homrighausen2020compressed} provided the approximated bias and variance for ridge regression but under the special condition that the compression matrix is of a sparse Bernoulli form. Subsampling can be viewed as a special case of random projection or sketching. A general subsampling procedure is basically to first select a subsample from the original dataset according to certain subsampling probabilities and then construct an estimator via only the subsample. The efficiency of implementation and nice interpretability make subsampling-based methods attractive. Based on the characteristics of the sampling step, existing methods can be summarized into two categories: deterministic and randomized subsampling. For the deterministic approach, \cite{wang2019information} proposed to select the subsample with extreme values on each dimension of $\mathbf X$ in linear regression such that the information matrix has a well-controlled determinant value. The second approach, the randomized subsampling, assigns subsampling probabilities to each observation and can achieve certain optimality by minimizing various criteria from the theory of experimental design. \cite{drineas2011faster}, \cite{ma2015statistical} and \cite{zhu2015optimal} investigated the optimal subsampling for large sample linear regression via leverage scores, i.e., the diagonal elements of $\mathbf{X}\left(\mathbf{X}^{\top} \mathbf{X}\right)^{-1} \mathbf{X}^{\top}$. Such strategy has inspired further studies on versatile statistical models including logistic regression \citep{wang2018optimal}, quantile regression \citep{wang2020optimal} and generalized linear models \citep{ai2018optimal}. Our goal in this paper is to alleviate the computational burden for ridge regression with large-scale datasets. In particular, we focus on the case where the full sample size $n$ is much larger than the dimension $p$. Motivated from the idea of subsampling which concerns the asymptotic result \citep{zhu2015optimal, ma2015statistical}, we study the bias and variance of the regression coefficient estimator from the subsample. Taking the bias-variance trade-off into consideration, we propose to minimize the asymptotic-mean-squared-error criterion and show that the optimal subsampling probability for each observation depends on not only its ridge leverage score but also the $\ell_2$ norm of the covariate. Unlike existing subsampling methods for large sample regression models where no penalty term is involved, it plays an important role to select a proper ridge parameter. Although the derived optimal subsampling probabilities have explicit forms, it is unrealistic to directly apply them because quantities include the ridge parameter and the ridge leverage scores are computationally expensive to calculate. On the one hand, conventional methods for choosing the ridge parameter such as the cross-validation and the generalized cross-validation are time-consuming when applied to the full sample. However, based on the relationship between the best ridge parameter for the full sample and that for the subsample, we can instead apply the cross-validation on the subsample and extrapolate it to the full sample. On the other hand, for efficient approximation, we replace individual ridge leverage scores with their average. As a consequence, the optimal subsampling probabilities are proportional to the $\ell_2$ norms of predictors. Based on the aforementioned adjustments, our new method exhibits better performance with efficient computation than other sketching and subsampling algorithms over extensive simulation studies, especially when the subsample size is small. The rest of the paper is organized as follows. Section \ref{methodology} presents the framework of the subsampling method and explains the details of ridge parameter selection and the optimal subsampling criterion. Section \ref{algorithm} proposes the optimal subsampling algorithm. Section \ref{simulation} and Section \ref{real} demonstrate the practical effectiveness of our algorithms via simulation and application, respectively. \section{Methodology}\label{methodology} \subsection{Subsampling framework} To reduce the computation when dealing with datasets of large sample size $n$, the key step of a general subsampling procedure is to select a subsample of size $r\ll n$ from the original observations according to subsampling probabilities. Extending the weighted estimation algorithm raised in \cite{ma2015statistical} to the ridge regression, we present the following framework for the ridge regression estimator $\widetilde{\boldsymbol{\beta}}$. Our proposed algorithms are based on this basic framework with its details shown in Section \ref{algorithm}. \begin{enumerate}[Step 1.] \item Construct the subsampling probability for each sample $\{\pi_{i}\}_{i=1}^{n}$. Draw a subsample $(\mathbf{X}^*,\mathbf{y}^*)$ of size $r\ll n$ based on the probability. \item Determine the ridge parameter $\widetilde{\lambda}$ for the subsample. Calculate the ridge regression estimator using the subsample, i.e., \begin{equation}\label{weighted} \widetilde{\boldsymbol{\beta}}=\arg \min _{\boldsymbol{\beta}}\left\|\Phi^{*}\mathbf{y}^{*}-\Phi^{*}\mathbf{X}^{*} \boldsymbol{\beta}\right\|^{2}+\widetilde{\lambda}\|\boldsymbol{\beta}\|^2, \end{equation} where $\Phi^{*}=\operatorname{diag}\left\{1/\sqrt{r\pi_{k}^{*}}\}\right\}_{k=1}^{r}$. \end{enumerate} Under the above general subsampling framework, two key questions remain to be answered: \begin{enumerate} \item How to determine the ridge parameter for subsample $\widetilde{\lambda}$? \item What is the optimal subsampling probability for each sample $\{\pi_{i}\}_{i=1}^{n}$? \end{enumerate} \subsection{Ridge parameter selection} The regularization in ridge regression plays an essential role in the prediction performance of the estimator. The ridge parameter $\lambda$ is usually unknown and requires careful tuning. Taking both the bias and variance into consideration, we can view the mean squared error as a function of the ridge parameter, and define the optimal ridge parameter as the one corresponding to the smallest mean squared error. For example, when the design matrix has orthonormal columns, the mean squared error can be derived as $p\sigma^2(1+\lambda)^{-2}+\lambda^2(1+\lambda)^{-2}\boldsymbol{\beta}^{\top}\boldsymbol{\beta}$, and thus the optimal ridge parameter is $p\sigma^2/{\boldsymbol{\beta}^{\top}\boldsymbol{\beta}}$. In practice, the cross-validation and its variants are applied to obtain the optimal ridge parameter. For $K$-fold cross-validation, the training data is divided into $K$ partitions $\{\mathbf{X}^{(k)},\mathbf{y}^{(k)}\}_{k=1}^{K}$ and we denote by $\widehat{\boldsymbol{\beta}}_{\backslash k}(\lambda)$ the estimated coefficient based on all partitions except the $k$th one. The optimal ridge parameter is $$\lambda_{\text{K-fold}}=\arg \min _{\lambda}K^{-1} \sum_{k=1}^{K}\|\mathbf{y}^{(k)}-\mathbf{X}^{(k)}\widehat{\boldsymbol{\beta}}_{\backslash k}(\lambda)\|^{2}.$$ The repeated fitting process by using different parts of the original sample leads to a high computational cost, especially when the sample size is large. \cite{golub1979generalized} proposed the generalized cross-validation to reduce the computation cost of cross-validation. Consider the leave-one-out cross-validation, i.e., $K=n$. It can be shown that $$ \lambda_{\text{LOOCV}} =\arg \min _{\lambda}n^{-1} \sum_{i=1}^{n}\left\{\frac{y_i-\mathbf{x}_i^{\top} \widehat{\boldsymbol{\beta}}(\lambda)}{1-h_{ii}(\lambda)}\right\}^2, $$ where $h_{i i}=\mathbf{x}_{i}^{\top}\left(\mathbf{X}^{\top} \mathbf{X}+\lambda \mathbf{I}\right)^{-1} \mathbf{x}_{i}$ is the diagonal element of the hat matrix $\mathbf{H}=\mathbf{X}\left(\mathbf{X}^{\top} \mathbf{X}+\lambda \mathbf{I}\right)^{-1} \mathbf{X}^{\top}$ where $i=1,\dots,n$. Quantity $h_{ii}$ measures the influential effect of the $i$th data points upon prediction and is called $\lambda$-leverage score \citep{alaoui2015fast}. The computational cost of calculating the ridge leverage score is $\mathcal{O}(np^2)$. The generalized cross-validation replaces individual leverage scores with their average $\textrm{tr}(\mathbf{H})$ to reduce computation, that is, \begin{equation}\label{gcv} \lambda_{\text{GCV}}=\arg \min _{\lambda}n^{-1} \sum_{i=1}^{n}\left\{\frac{y_i-\mathbf{x}_i^{\top} \widehat{\boldsymbol{\beta}}(\lambda)}{1-n^{-1} \textrm{tr}(\mathbf{H})}\right\}^{2}. \end{equation} The optimal ridge parameter $\widetilde\lambda$ for the subsample can be estimated by minimizing the cross-validation criteria but over the subsample. We next provide the rationale of the approximation in the main theorem. \subsection{Optimal subsampling} Once the ridge parameter is fixed, we calculate subsampling probabilities for each observation, by which a subset of data points are selected from the full sample with replacement. We anticipate the estimator based on the subsample can achieve some optimality. In the ridge regression, the regularized estimator can perform much better than the ordinary least square estimator if the bias and variances are traded off properly. Therefore, we consider the mean-squared-error type of criterion which involves both bias and variance. We begin by investigating the difference between the subsampling estimator and its full-sample counterpart. For convenience of analysis, we introduce some notations here to rewrite the subsampling estimator in the form concerning full data. Let $K_i$ be the number of times the observation $\mathbf{x}_{i}$ is sampled and $(K_1,\dots, K_n)$ thus follows a multinomial distribution. Let $\mathbf{W}=\mathbf{\Omega}\mathbf{K}$, where $\mathbf{K}=\operatorname{diag}\{K_i\}_{i=1}^n$, $\mathbf{\Omega}=\operatorname{diag}\{1/r\pi_i\}_{i=1}^n$. Simple algebra yields that the ridge regression estimator based on the subsample from \eqref{weighted} can be expressed as \begin{equation}\label{close_sub} \widetilde{\boldsymbol{\beta}}=\left(\mathbf{X}^{*\top} \Phi^{*2} \mathbf{X}^*+\widetilde{\lambda} \mathbf{I}\right)^{-1} \mathbf{X}^{*\top} \Phi^{*2} \mathbf{y}^* =\left(\mathbf{X}^{\top} \mathbf{W} \mathbf{X}+\widetilde{\lambda} \mathbf{I}\right)^{-1} \mathbf{X}^{\top}\mathbf{W} \mathbf{y}. \end{equation} In the following lemma, we demonstrate the difference between the estimator \eqref{close_sub} and the full-sample estimator \eqref{close_full}. \begin{lemma}\label{lemma1} If $0<\pi_i<1,i=1,\dots,n$, $(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{X}=\mathcal{O}_{p}(r^{-1/2})$ and $(\widetilde{\lambda}-\lambda)(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}=\mathcal{O}(r^{-1/2})$, then \begin{equation}\label{biasvar} \widetilde{\boldsymbol{\beta}}-\widehat{\boldsymbol{\beta}}= (\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{W}\mathbf{e}-\widetilde{\lambda}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\widehat{\boldsymbol{\beta}}+\mathcal{O}_{p}(r^{-1}), \end{equation} where $\mathbf{e}=\mathbf{y}-\mathbf{X}\widehat{\boldsymbol{\beta}}$. \end{lemma} \begin{proof} We first rewrite the subsampling estimator by multiplying $(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}$, \begin{equation}\label{tay} \widetilde{\boldsymbol{\beta}}=\left\{(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}(\mathbf{X}^{\top}\mathbf{W}\mathbf{X}+\widetilde{\lambda}\mathbf{I})\right\}^{-1}\left\{(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{W}\mathbf{y}\right\}. \end{equation} For the inverse term, we apply the Taylor series expansion, \begin{align*} \left\{(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}(\mathbf{X}^{\top}\mathbf{W}\mathbf{X}+\widetilde{\lambda}\mathbf{I})\right\}^{-1}&=\left[\mathbf{I}+(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\{\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{X}+(\widetilde{\lambda}-\lambda)\mathbf{I}\}\right]^{-1}\\ &=\mathbf{I}-(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{X}-(\widetilde{\lambda}-\lambda)(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}+\mathcal{O}_{p}(r^{-1}). \end{align*} For the other term in \eqref{tay}, \begin{align*} (\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{W}\mathbf{y} &=(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\left\{\mathbf{X}^{\top}\mathbf{y}+\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{y}\right\}\\ &=\widehat{\boldsymbol{\beta}}+(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{y}. \end{align*} Since $(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{y}$ and $(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{e}$ are of the same order as $(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{X}$, \begin{align*} \widetilde{\boldsymbol{\beta}}&=\widehat{\boldsymbol{\beta}}+(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}(\mathbf{W}-\mathbf{I})\mathbf{e}+(\lambda-\widetilde{\lambda})(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\widehat{\boldsymbol{\beta}}+\mathcal{O}_{p}(r^{-1})\\ &=\widehat{\boldsymbol{\beta}}+(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{W}\mathbf{e}-\widetilde{\lambda}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\widehat{\boldsymbol{\beta}}+\mathcal{O}_{p}(r^{-1}) \end{align*} The second equation holds due to the normal equation for ridge regression. \end{proof} We investigate the asymptotic mean squared error of $\widetilde{\boldsymbol{\beta}}$, which is used as our criterion for determining the optimal subsampling probabilities. \begin{theorem}\label{them1} If the full sample size $n$ is fixed, $\|\mathbf{x_i}\|<\infty$, $i=1,\dots,n$, the sampling probabilities $\{\pi_i\}_{i=1}^n$ are nonzero, and $\widetilde{\lambda}-\lambda=\mathcal{O}(r^{-1/2})$, then the asymptotic variance and mean are \begin{enumerate} \item $\text{AVar}(\widetilde{\boldsymbol{\beta}})= \Sigma_c-\lambda^2 r^{-1}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1} \widehat{\boldsymbol{\beta}} \widehat{\boldsymbol{\beta}}^{\top} (\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}$, where \\ $\Sigma_c=r^{-1}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}(\sum_{i=1}^n \pi_i^{-1} e_i^2\mathbf{x}_{i} \mathbf{x}_{i}^{\top})(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}$, $e_i=y_i-\mathbf{x}_i^{\top}\widehat{\boldsymbol{\beta}}$.\label{them11} \item $\text{AE}(\widetilde{\boldsymbol{\beta}})=\widehat{\boldsymbol{\beta}}+(\lambda-\widetilde{\lambda})(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1} \widehat{\boldsymbol{\beta}}$.\label{them12} \end{enumerate} The asymptotic mean squared error of $\widetilde{\boldsymbol{\beta}}$ is therefore $$\text{AMSE}(\widetilde{\boldsymbol{\beta}})=\Sigma_c-\lambda^2 r^{-1}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1} \widehat{\boldsymbol{\beta}} \widehat{\boldsymbol{\beta}}^{\top} (\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}+(\lambda-\widetilde{\lambda})^2(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1} \widehat{\boldsymbol{\beta}} \widehat{\boldsymbol{\beta}}^{\top} (\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}.$$ \end{theorem} \begin{proof} We begin by the deduction of the result~\ref{them11}. The roadmap of the proof of this part is motivated from the result in \cite{zhu2015optimal} since the variance term in linear regression case is of similar form. We use Cramer-Wold device to establish the asymptotic normality of $(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{W}\mathbf{e}=(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\sum_{j=1}^r\mathbf{X}^{\top}\mathbf{\Omega}\mathbf{K}^{(j)}\mathbf{e}$. Consider each term in the summation, for any non-zero constant vector $\mathbf{b}\in \mathbb R^p$, we have \begin{equation*} \text{var}\{(\mathbf{b}^{\top}\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{\Omega}\mathbf{K}^{(1)}\mathbf{e}\}=r^{-1}\mathbf{a}^{\top}\left(\sum_{i=1}^n \frac{e_i^2}{\pi_i}\mathbf{x}_i\mathbf{x}_i^T\right)\mathbf{a}-r^{-1}\mathbf{a}^{\top}\mathbf{X}^{\top}\mathbf{e}\mathbf{e}^{\top}\mathbf{X}\mathbf{a}, \end{equation*} where $\mathbf{a}=(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{b}$. By applying the normal equation of ridge regression, we have \begin{equation*} \text{var}\{(\mathbf{b}^{\top}\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{\Omega}\mathbf{K}^{(1)}\mathbf{e}\}=\mathbf{b}^{\top}\left\{\Sigma_c+\lambda^2 r^{-1}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1} \widehat{\boldsymbol{\beta}} \widehat{\boldsymbol{\beta}}^{\top} (\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\right\}\mathbf{b}. \end{equation*} By using Lindeberg–Lévy CLT, we have the variance of the summation, \begin{equation*} \text{var}\{(\mathbf{b}^{\top}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\sum_{j=1}^r\mathbf{X}^{\top}\mathbf{\Omega}\mathbf{K}^{(j)}\mathbf{e}\}=\mathbf{b}^{\top}\left\{\Sigma_c+\lambda^2 r^{-1}(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1} \widehat{\boldsymbol{\beta}} \widehat{\boldsymbol{\beta}}^{\top} (\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\right\}\mathbf{b} \end{equation*} Therefore, we have the result~\ref{them11} due to the Cramer-Wold device. Then consider the result~\ref{them12}. Since $\mathbf{W}=\mathbf{\Omega}\mathbf{K}$, where each element $K_i$ in $\mathbf{K}=\operatorname{diag}\{K_i\}_{i=1}^n$ follows the multinomal distribution $\text{Mult}(r,\{\pi_i\}_{i=1}^n)$, then $\mathbb{E}(W_i)=1$, where $W_i$ is the diagonal element of matrix $\mathbf{W}$. Thus, we can calculate the expectation \begin{align*} \mathbb{E}\{(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{W}\mathbf{e}\}&=(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\mathbf{X}^{\top}\mathbf{e}\\ &=\lambda(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1}\widehat{\boldsymbol{\beta}}, \end{align*} with the second equation following the normal equation. Consequently, we have $\text{AE}(\widetilde{\boldsymbol{\beta}})=\widehat{\boldsymbol{\beta}}+(\lambda-\widetilde{\lambda})(\mathbf{X}^{\top}\mathbf{X}+\lambda\mathbf{I})^{-1} \widehat{\boldsymbol{\beta}}$. \end{proof} The above theorem shows that the controllable part of the criterion is included in the variance term. Considering the expression of variance, only $\Sigma_c$ depends on the subsampling probability $\{\pi_i\}_{i=1}^n$. We resort to minimize the expected trace of $\Sigma_c$ to obtain the corresponding subsampling probability, as shown in the following theorem. \begin{theorem}\label{them2} When $$\pi_i=\frac{\sqrt{\left(1-h_{i i}\right)}\left\|\mathbf{x}_{i}\right\|}{\sum_{j=1}^{n} \sqrt{\left(1-h_{j j}\right)}\left\|\mathbf{x}_{j}\right\|},$$ $\mathbb{E}\{\textrm{tr}(\Sigma_c)\}$ attains its minimum, where $h_{ii}$ is the ridge leverage score, $i=1,\dots,n$. \end{theorem} \begin{proof} Since $\mathbb{E}\{\textrm{tr}(\Sigma_c)\}=r^{-1} \sum_{i=1}^{n}\pi_{i}^{-1} (1-h_{i i})\left\|\mathbf{x}_{i}\right\|^{2}$, we can get the following result by applying Hölder's inequality, \begin{align*} r^{-1} \sum_{i=1}^{n} \frac{1-h_{i i}}{\pi_{i}}\left\|\mathbf{x}_{i}\right\|^{2} =r^{-1} \sum_{i=1}^{n} \frac{1-h_{i i}}{\pi_{i}}\left\|\mathbf{x}_{i}\right\|^{2} \sum_{i=1}^{n} \pi_{i} \geq \left\{\sum_{i=1}^{n} \sqrt{\left(1-h_{i i}\right)\left\|\mathbf{x}_{i}\right\|^{2}}\right\}^{2}, \end{align*} with the equality holds if and only if $\pi_i\propto\sqrt{\left(1-h_{i i}\right)}\left\|\mathbf{x}_{i}\right\|$. \end{proof} In Theorem~\ref{them2}, we obtain the optimal subsampling probability for each observation. It involves both the ridge leverage score and the $\ell_2$ norm of the predictor. Our subsampling strategy is different from the sketching scheme for ridge regression \citep{cohen2017input} which only utilized the ridge leverage score. We will compare these methods on simulation and real data. \section{Algorithm}\label{algorithm} Based on the deduction in the above section, we obtain the subsampling probability and the approaching rate between the ridge parameter for subsample $\widetilde{\lambda}$ and that for full sample $\lambda$. Integrating these ingredients with the general subsampling procedure, $\widetilde{\lambda}=\lambda$ and $\pi_{i}=\frac{\sqrt{\left(1-h_{i i}\right)}\left\|\mathbf{x}_{i}\right\|}{\sum_{j=1}^{n} \sqrt{\left(1-h_{j j}\right)}\left\|\mathbf{x}_{j}\right\|},i=1,\dots,n$, we can calculate the subsampling estimator. However, there are two quantities whose calculations are still computationally demanding. First, it requires $\mathcal{O}(np^2)$ to compute the exact ridge leverage scores, which amounts to the same computation as the full-sample estimator. Second, we need to calculate $\lambda$ first for calculating the ridge leverage score. The ridge parameter $\widetilde{\lambda}$ is then set as $\lambda$, which is not desirable since applying the cross-validation to choose $\lambda$ is time-consuming. To address the aforementioned issues, we propose an efficient approximation to the optimal subsampling probabilities in Theorem~\ref{them2}. Similar to the idea of generalized cross-validation in \eqref{gcv}, we approximate the individual ridge leverage score with their average, i.e., $n^{-1} \textrm{tr}(\mathbf{H})$. It corresponds to the scenario where ridge leverage scores are not highly heterogeneous. Therefore, the subsampling probability reduces to $\pi_i=\|\mathbf{x}_i\|/\sum_{j=1}^n \|\mathbf{x}_j\|,i=1,\dots,n$, which involves only the $\ell_2$ norm of the predictors. Moreover, such an approximation of the subsampling probability no longer depends on the ridge leverage score, and hence we do not need the full sample $\lambda$ to calculate $\pi_i$. In this way, we can perform the cross-validation or generalized cross-validation to directly calculate $\widetilde{\lambda}$ with the selected subsample at a much lower computational cost. The optimal subsampling ridge regression estimation we propose is summarized in Algorithm~\ref{alg}. \begin{algorithm}\label{alg} Ridge Regression with Optimal Subsampling \begin{enumerate}[Step 1.] \item Construct the subsampling probability for each sample $\pi_{i}=\|\mathbf{x}_i\|/\sum_{j=1}^n \|\mathbf{x}_j\|,i=1,\dots,n$. Draw a subsample $(\mathbf{X}^*,\mathbf{y}^*)$ of size $r\ll n$ based on the probability. \label{algstep1} \item Calculate the ridge regression estimator \begin{equation}\label{weighted2} \widetilde{\boldsymbol{\beta}}=\arg \min _{\boldsymbol{\beta}}\left\|\Phi^{*}\mathbf{y}^{*}-\Phi^{*}\mathbf{X}^{*} \boldsymbol{\beta}\right\|^{2}+\widetilde{\lambda}\|\boldsymbol{\beta}\|^2, \end{equation} where $\widetilde{\lambda}$ is selected via cross-validation for response vector $\Phi^{*}\mathbf{y}^{*}$ and design matrix $\Phi^{*}\mathbf{X}^{*}$ and $\Phi^{*}=\operatorname{diag}\left\{1/\sqrt{r\pi_{k}^{*}}\}\right\}_{k=1}^{r}$. \label{algstep2} \end{enumerate} \end{algorithm} Compared to calculating the exact ridge leverage score, the calculation of subsampling probabilities in Step~\ref{algstep1} of Algorithm~\ref{alg} avoids accessing the full design matrix $\mathbf X$, and hence the $\ell_2$ norm of predictors can be obtained in parallel. According to the closeness between $\widetilde\lambda$ and $\lambda$ revealed in Theorem~\ref{them1}, we can extrapolate $\widetilde\lambda$ for the subsample to estimate $\lambda$ for the full sample. It allows us to confirm our theoretical findings with numerical experiments which are presented in the following sections. \section{Simulation}\label{simulation} In the simulation study, we begin by demonstrating the effectiveness of the approximation of the ridge leverage score. We then compare the proposed methods with other subsampling approaches developed for large sample ridge regression or linear regression, including the ridge leverage score subsampling \citep{cohen2017input}, uniform subsampling for ridge regression, optimal subsampling for linear regression \citep{zhu2015optimal} and the information-based optimal subdata selection for linear regression (IBOSS) \citep{wang2019information}. Simulated data are generated in six settings. In each simulation, we generate the full data set of size $n=10^5$ and dimension $p=50$. Subsample sizes are set as $r=100,200,400,800,1600,3200,6400$. The design matrix $\mathbf{X}$ is standardized before being fed into the model. Each experiment is repeated $20$ times. We use the mean squared error (MSE) of the estimated coefficient $\widetilde{\boldsymbol{\beta}}$ to evaluate the performance. The errors $\epsilon_i, i=1,\dots,n$ are independently and identically generated from $N(0,9)$. We set the simulations as follows. For a $q<p$, let $\mathbf{\Sigma}$ be the $q\times q$ covariance matrix with element $\mathbf{\Sigma}_{i,j}=0.5^{1(i \neq j)},i,j=1,\dots,n$. Consider $q$-dimensional $\mathbf{x}_i\sim N(\mathbf{0}, \mathbf{\Sigma}),i=1,\dots,n$ for the true linear model with $\boldsymbol{\beta}=\mathbf{1}_{q\times 1}$. An additional $(p-q)$-dimensional term $\mathbf{x}^a$ is generated without being used in the true model, since we want to test if the subsample helps identify the appropriate relationship between the responses and the true covariates. \begin{enumerate}[\text{Case} 1.] \item $q=10$, $\mathbf{X}^a_i$ follows a multivariate normal distribution, where columns of $\mathbf{X}^a_{i}$ are i.i.d. samples from $N(0,1)$. \item $q=10$, $\mathbf{X}^a_i$ follows a multivariate lognormal distribution, where columns of $\mathbf{X}^a_{i}$ are i.i.d. samples from $LN(0,1)$. \item $q=10$, $\mathbf{X}^a_i$ follows a multivariate $t$ distribution with degrees of freedom $2$, where columns of $\mathbf{X}^a_{i}$ are i.i.d. samples from $t_2(0,1)$. \item $q=25$, $\mathbf{X}^a_i$ follows a multivariate normal distribution, where columns of $\mathbf{X}^a_{i}$ are i.i.d. samples from $N(0,1)$. \item $q=25$, $\mathbf{X}^a_i$ follows a multivariate lognormal distribution, where columns of $\mathbf{X}^a_{i}$ are i.i.d. samples from $LN(0,1)$. \item $q=25$, $\mathbf{X}^a_i$ follows a multivariate $t$ distribution with degrees of freedom $2$, where columns of $\mathbf{X}^a_{i}$ are i.i.d. samples from $t_2(0,1)$. \end{enumerate} First, we show that subsampling by using the fast approximation of ridge leverage score (ROPT) is similar to that by applying the accurate one (ROPT-acc). Figure~\ref{simu_pi} displays the comparison result of MSE of the estimators by using the two sampling probabilities. Both methods have similar performance in all 6 cases given different subsample sizes. Therefore, the effectiveness of the $\ell_2$ approximation of ridge leverage score is demonstrated. \begin{figure}[h!] \centering \subfigure{ \begin{minipage}[b]{0.31\linewidth} \includegraphics[width=1\linewidth]{figure/simu_pi/f1.eps}\vspace{4pt} \includegraphics[width=1\linewidth]{figure/simu_pi/g1.eps} \end{minipage}} \subfigure{ \begin{minipage}[b]{0.31\linewidth} \includegraphics[width=1\linewidth]{figure/simu_pi/f2.eps}\vspace{4pt} \includegraphics[width=1\linewidth]{figure/simu_pi/g2.eps} \end{minipage}} \subfigure{ \begin{minipage}[b]{0.31\linewidth} \includegraphics[width=1\linewidth]{figure/simu_pi/f3.eps}\vspace{4pt} \includegraphics[width=1\linewidth]{figure/simu_pi/g3.eps} \end{minipage}} \caption{Comparison of different subsampling probabilities: $x$-axis is the logarithm of the subsample size, $y$-axis is the logarithm of the mean squared error of $\widetilde{\boldsymbol{\beta}}$.} \label{simu_pi} \end{figure} Then we compare our proposed method with the ridge leverage score subsampling (RLEV), uniform subsampling for ridge regression (RUNIF), optimal subsampling for linear regression (OPT), and the information-based optimal subdata selection for linear regression (IBOSS). The first two competitors are raised for the ridge regression while the rest two are proposed for the linear regression. \begin{figure}[h!] \centering \subfigure{ \begin{minipage}[b]{0.31\linewidth} \includegraphics[width=1\linewidth]{figure/simu_compnew/f1.eps}\vspace{4pt} \includegraphics[width=1\linewidth]{figure/simu_compnew/g1.eps} \end{minipage}} \subfigure{ \begin{minipage}[b]{0.31\linewidth} \includegraphics[width=1\linewidth]{figure/simu_compnew/f2.eps}\vspace{4pt} \includegraphics[width=1\linewidth]{figure/simu_compnew/g2.eps} \end{minipage}} \subfigure{ \begin{minipage}[b]{0.31\linewidth} \includegraphics[width=1\linewidth]{figure/simu_compnew/f3.eps}\vspace{4pt} \includegraphics[width=1\linewidth]{figure/simu_compnew/g3.eps} \end{minipage}} \caption{Comparison of different subsampling estimators: $x$-axis is the logarithm of the subsample size, $y$-axis is the logarithm of the mean squared error of the estimator $\widetilde{\boldsymbol{\beta}}$ compared with true $\boldsymbol{\beta}$.} \label{simu_compnew} \end{figure} In Figure~\ref{simu_compnew}, our algorithm has the best performance among all the 6 cases when the subsample sizes are small or moderate, while all the methods have similar performance when the subsample sizes are large. First, our method has a great advantage when we use a small subsample. Second, by comparing the two rows of Figure~\ref{simu_compnew}, we can find our model preserves its superiority over other models for linear regression even in the cases where the true model favors less for introducing the ridge penalty. \section{Real data example}\label{real} In times of information explosion, people are surrounded by a sea of news from various sources all day and night. For online media, it is critical for them to know what kind of news can attract the public attention, and hence the prediction of the popularity of the news becomes a trendy research topic. To raise the accuracy, numerical features from content, keywords, publish day and earlier popularity of news referenced in the article are extracted and then fed into a regression model to predict the share of the news. We use the open dataset of Online News Popularity Data Set on UC Irvine Machine Learning Repository\footnote{http://archive.ics.uci.edu/ml/datasets/Online+News+Popularity}, which was provided by \cite{fernandes2015proactive}. The data was collected from Mashable, which is one of the largest news websites, from January 7, 2013, to January 7, 2015. It contains more than 39,000 articles in around 700 days. Except for the two non-predictable features, there is one response, the number of shares, and 58 predictive attributes concerning words, links, media, time, keywords, and natural language processing. Since the number of observations is huge and the number of features is also relatively large, it is prohibitive to allocate the memory for calculating the regression estimator. Therefore, we use the subsampling method to reduce the computation cost. The dataset is randomly divided into $70\%$ for training and $30\%$ for testing. Subsample sizes are set as $r=100,200,400,800,1600,3200,6400$. The design matrix $\mathbf{X}$ is standardized before being fed into the model. Each experiment is repeated $20$ times. Because the true regression coefficient $\boldsymbol\beta$ is unknown, we first compare our estimator $\widetilde{\boldsymbol{\beta}}$ with full-sample estimator $\widehat{\boldsymbol{\beta}}$ in terms of MSE. \begin{figure}[h] \centering \includegraphics[width=0.45\linewidth]{figure/real/g1.eps} \caption{Comparison of different subsampling estimators: $x$-axis is the logarithm of the subsample size, $y$-axis is the logarithm of the mean squared error of the estimator $\widetilde{\boldsymbol{\beta}}$ compared with full-sample estimator $\widehat{\boldsymbol{\beta}}$.} \label{realdata} \end{figure} In Figure~\ref{realdata}, we plot the MSE of the estimators calculated by different methods. Our method has the best performance at various subsample sizes compared with the competing methods. Finally, to better compare the performance of different methods, we report the test error under various subsample sizes in Table~\ref{tab}. Our method keeps the advantage compared with other methods as the subsample size grows. \begin{table}[h] \centering \begin{tabular}{c|c|c|c|c|c|c|c} \toprule r & 100 & 200 & 400 & 800 & 1600 & 3200 & 6400 \\ \midrule ROPT & \textbf{0.007} & \textbf{0.043} & \textbf{0.015} & \textbf{0.012} & \textbf{0.013} & \textbf{0.015} & \textbf{0.029} \\ \hline RLEV & 1.560 & 1.754 & 0.594 & 1.032 & 0.555 & 0.516 & 0.285 \\ \hline RUNIF & 1.317 & 1.389 & 1.062 & 1.160 & 0.350 & 0.653 & 0.289 \\ \hline OPT & 1.819 & 1.571 & 0.978 & 0.633 & 1.684 & 1.412 & 2.761 \\ \hline IBOSS & 1.425 & 1.030 & 1.892 & 1.261 & 0.402 & 0.349 & 1.137 \\ \bottomrule \end{tabular} \caption{The logarithm of the test error comparison under different subsample sizes.} \label{tab} \end{table} \bibliographystyle{ims}
{'timestamp': '2022-04-12T02:27:33', 'yymm': '2204', 'arxiv_id': '2204.04776', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04776'}
arxiv
\section{Introduction} Please follow the steps outlined below when submitting your manuscript to the IEEE Computer Society Press. This style guide now has several important modifications (for example, you are no longer warned against the use of sticky tape to attach your artwork to the paper), so all authors should read this new version. \subsection{Language} All manuscripts must be in English. \subsection{Dual submission} Please refer to the author guidelines on the CVPR 2020 web page for a discussion of the policy on dual submissions. \subsection{Paper length} Papers, excluding the references section, must be no longer than eight pages in length. The references section will not be included in the page count, and there is no limit on the length of the references section. For example, a paper of eight pages with two pages of references would have a total length of 10 pages. {\bf There will be no extra page charges for CVPR 2020.} Overlength papers will simply not be reviewed. This includes papers where the margins and formatting are deemed to have been significantly altered from those laid down by this style guide. Note that this \LaTeX\ guide already sets figure captions and references in a smaller font. The reason such papers will not be reviewed is that there is no provision for supervised revisions of manuscripts. The reviewing process cannot determine the suitability of the paper for presentation in eight pages if it is reviewed in eleven. \subsection{The ruler} The \LaTeX\ style defines a printed ruler which should be present in the version submitted for review. The ruler is provided in order that reviewers may comment on particular lines in the paper without circumlocution. If you are preparing a document using a non-\LaTeX\ document preparation system, please arrange for an equivalent ruler to appear on the final output pages. 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. (\LaTeX\ users may uncomment the \verb'\cvprfinalcopy' command in the document preamble.) Reviewers: note that the ruler measurements do 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. Just use fractional references (e.g.\ this line is $095.5$), although in most cases one would expect that the approximate location will be adequate. \subsection{Mathematics} Please number all of your sections and displayed equations. It is important for readers to be able to refer to any particular equation. Just because you didn't refer to it in the text doesn't mean some future reader might not need to refer to it. It is cumbersome to have to use circumlocutions like ``the equation second from the top of page 3 column 1''. (Note that the ruler will not be present in the final copy, so is not an alternative to equation numbers). All authors will benefit from reading Mermin's description of how to write mathematics: \url{http://www.pamitc.org/documents/mermin.pdf}. \subsection{Blind review} Many authors misunderstand the concept of anonymizing for blind review. Blind review does not mean that one must remove citations to one's own work---in fact it is often impossible to review a paper unless the previous citations are known and available. Blind review means that you do not use the words ``my'' or ``our'' when citing previous work. That is all. (But see below for techreports.) Saying ``this builds on the work of Lucy Smith [1]'' does not say that you are Lucy Smith; it says that you are building on her work. If you are Smith and Jones, do not say ``as we show in [7]'', say ``as Smith and Jones show in [7]'' and at the end of the paper, include reference 7 as you would any other cited work. An example of a bad paper just asking to be rejected: \begin{quote} \begin{center} An analysis of the frobnicatable foo filter. \end{center} In this paper we present a performance analysis of our previous paper [1], and show it to be inferior to all previously known methods. Why the previous paper was accepted without this analysis is beyond me. [1] Removed for blind review \end{quote} An example of an acceptable paper: \begin{quote} \begin{center} An analysis of the frobnicatable foo filter. \end{center} In this paper we present a performance analysis of the paper of Smith \etal [1], and show it to be inferior to all previously known methods. Why the previous paper was accepted without this analysis is beyond me. [1] Smith, L and Jones, C. ``The frobnicatable foo filter, a fundamental contribution to human knowledge''. Nature 381(12), 1-213. \end{quote} If you are making a submission to another conference at the same time, which covers similar or overlapping material, you may need to refer to that submission in order to explain the differences, just as you would if you had previously published related work. In such cases, include the anonymized parallel submission~\cite{Authors14} as additional material and cite it as \begin{quote} [1] Authors. ``The frobnicatable foo filter'', F\&G 2014 Submission ID 324, Supplied as additional material {\tt fg324.pdf}. \end{quote} Finally, you may feel you need to tell the reader that more details can be found elsewhere, and refer them to a technical report. For conference submissions, the paper must stand on its own, and not {\em require} the reviewer to go to a techreport for further details. Thus, you may say in the body of the paper ``further details may be found in~\cite{Authors14b}''. Then submit the techreport as additional material. Again, you may not assume the reviewers will read this material. Sometimes your paper is about a problem which you tested using a tool which is widely known to be restricted to a single institution. For example, let's say it's 1969, you have solved a key problem on the Apollo lander, and you believe that the CVPR70 audience would like to hear about your solution. The work is a development of your celebrated 1968 paper entitled ``Zero-g frobnication: How being the only people in the world with access to the Apollo lander source code makes us a wow at parties'', by Zeus \etal. You can handle this paper like any other. Don't write ``We show how to improve our previous work [Anonymous, 1968]. This time we tested the algorithm on a lunar lander [name of lander removed for blind review]''. That would be silly, and would immediately identify the authors. Instead write the following: \begin{quotation} \noindent We describe a system for zero-g frobnication. This system is new because it handles the following cases: A, B. Previous systems [Zeus et al. 1968] didn't handle case B properly. Ours handles it by including a foo term in the bar integral. ... The proposed system was integrated with the Apollo lunar lander, and went all the way to the moon, don't you know. It displayed the following behaviours which show how well we solved cases A and B: ... \end{quotation} As you can see, the above text follows standard scientific convention, reads better than the first version, and does not explicitly name you as the authors. A reviewer might think it likely that the new paper was written by Zeus \etal, but cannot make any decision based on that guess. He or she would have to be sure that no other authors could have been contracted to solve problem B. \medskip \noindent FAQ\medskip\\ {\bf Q:} Are acknowledgements OK?\\ {\bf A:} No. Leave them for the final copy.\medskip\\ {\bf Q:} How do I cite my results reported in open challenges? {\bf A:} To conform with the double blind review policy, you can report results of other challenge participants together with your results in your paper. For your results, however, you should not identify yourself and should not mention your participation in the challenge. Instead present your results referring to the method proposed in your paper and draw conclusions based on the experimental comparison to other results.\medskip\\ \begin{figure}[t] \begin{center} \fbox{\rule{0pt}{2in} \rule{0.9\linewidth}{0pt}} \end{center} \caption{Example of caption. It is set in Roman so that mathematics (always set in Roman: $B \sin A = A \sin B$) may be included without an ugly clash.} \label{fig:long} \label{fig:onecol} \end{figure} \subsection{Miscellaneous} \noindent Compare the following:\\ \begin{tabular}{ll} \verb'$conf_a$' & $conf_a$ \\ \verb'$\mathit{conf}_a$' & $\mathit{conf}_a$ \end{tabular}\\ See The \TeX book, p165. The space after \eg, meaning ``for example'', should not be a sentence-ending space. So \eg is correct, {\em e.g.} is not. The provided \verb'\eg' macro takes care of this. When citing a multi-author paper, you may save space by using ``et alia'', shortened to ``\etal'' (not ``{\em et.\ al.}'' as ``{\em et}'' is a complete word.) However, use it only when there are three or more authors. Thus, the following is correct: `` Frobnication has been trendy lately. It was introduced by Alpher~\cite{Alpher02}, and subsequently developed by Alpher and Fotheringham-Smythe~\cite{Alpher03}, and Alpher \etal~\cite{Alpher04}.'' This is incorrect: ``... subsequently developed by Alpher \etal~\cite{Alpher03} ...'' because reference~\cite{Alpher03} has just two authors. If you use the \verb'\etal' macro provided, then you need not worry about double periods when used at the end of a sentence as in Alpher \etal. For this citation style, keep multiple citations in numerical (not chronological) order, so prefer \cite{Alpher03,Alpher02,Authors14} to \cite{Alpher02,Alpher03,Authors14}. \begin{figure*} \begin{center} \fbox{\rule{0pt}{2in} \rule{.9\linewidth}{0pt}} \end{center} \caption{Example of a short caption, which should be centered.} \label{fig:short} \end{figure*} \section{Formatting your paper} All text must be in a two-column format. The total allowable width of the text area is $6\frac78$ inches (17.5 cm) wide by $8\frac78$ inches (22.54 cm) high. Columns are to be $3\frac14$ inches (8.25 cm) wide, with a $\frac{5}{16}$ inch (0.8 cm) space between them. The main title (on the first page) should begin 1.0 inch (2.54 cm) from the top edge of the page. The second and following pages should begin 1.0 inch (2.54 cm) from the top edge. On all pages, the bottom margin should be 1-1/8 inches (2.86 cm) from the bottom edge of the page for $8.5 \times 11$-inch paper; for A4 paper, approximately 1-5/8 inches (4.13 cm) from the bottom edge of the page. \subsection{Margins and page numbering} All printed material, including text, illustrations, and charts, must be kept within a print area 6-7/8 inches (17.5 cm) wide by 8-7/8 inches (22.54 cm) high. Page numbers should be in footer with page numbers, centered and .75 inches from the bottom of the page and make it start at the correct page number rather than the 4321 in the example. To do this fine the line (around line 23) \begin{verbatim} \setcounter{page}{4321} \end{verbatim} where the number 4321 is your assigned starting page. Make sure the first page is numbered by commenting out the first page being empty on line 46 \begin{verbatim} \end{verbatim} \subsection{Type-style and fonts} Wherever Times is specified, Times Roman may also be used. If neither is available on your word processor, please use the font closest in appearance to Times to which you have access. MAIN TITLE. Center the title 1-3/8 inches (3.49 cm) from the top edge of the first page. The title should be in Times 14-point, boldface type. Capitalize the first letter of nouns, pronouns, verbs, adjectives, and adverbs; do not capitalize articles, coordinate conjunctions, or prepositions (unless the title begins with such a word). Leave two blank lines after the title. AUTHOR NAME(s) and AFFILIATION(s) are to be centered beneath the title and printed in Times 12-point, non-boldface type. This information is to be followed by two blank lines. The ABSTRACT and MAIN TEXT are to be in a two-column format. MAIN TEXT. Type main text in 10-point Times, single-spaced. Do NOT use double-spacing. All paragraphs should be indented 1 pica (approx. 1/6 inch or 0.422 cm). Make sure your text is fully justified---that is, flush left and flush right. Please do not place any additional blank lines between paragraphs. Figure and table captions should be 9-point Roman type as in Figures~\ref{fig:onecol} and~\ref{fig:short}. Short captions should be centred. \noindent Callouts should be 9-point Helvetica, non-boldface type. Initially capitalize only the first word of section titles and first-, second-, and third-order headings. FIRST-ORDER HEADINGS. (For example, {\large \bf 1. Introduction}) should be Times 12-point boldface, initially capitalized, flush left, with one blank line before, and one blank line after. SECOND-ORDER HEADINGS. (For example, { \bf 1.1. Database elements}) should be Times 11-point boldface, initially capitalized, flush left, with one blank line before, and one after. If you require a third-order heading (we discourage it), use 10-point Times, boldface, initially capitalized, flush left, preceded by one blank line, followed by a period and your text on the same line. \subsection{Footnotes} Please use footnotes\footnote {This is what a footnote looks like. It often distracts the reader from the main flow of the argument.} sparingly. Indeed, try to avoid footnotes altogether and include necessary peripheral observations in the text (within parentheses, if you prefer, as in this sentence). If you wish to use a footnote, place it at the bottom of the column on the page on which it is referenced. Use Times 8-point type, single-spaced. \subsection{References} List and number all bibliographical references in 9-point Times, single-spaced, at the end of your paper. When referenced in the text, enclose the citation number in square brackets, for example~\cite{Authors14}. Where appropriate, include the name(s) of editors of referenced books. \begin{table} \begin{center} \begin{tabular}{|l|c|} \hline Method & Frobnability \\ \hline\hline Theirs & Frumpy \\ Yours & Frobbly \\ Ours & Makes one's heart Frob\\ \hline \end{tabular} \end{center} \caption{Results. Ours is better.} \end{table} \subsection{Illustrations, graphs, and photographs} All graphics should be centered. Please ensure that any point you wish to make is resolvable in a printed copy of the paper. Resize fonts in figures to match the font in the body text, and choose line widths which render effectively in print. Many readers (and reviewers), even of an electronic copy, will choose to print your paper in order to read it. You cannot insist that they do otherwise, and therefore must not assume that they can zoom in to see tiny details on a graphic. When placing figures in \LaTeX, it's almost always best to use \verb+\includegraphics+, and to specify the figure width as a multiple of the line width as in the example below {\small\begin{verbatim} \usepackage[dvips]{graphicx} ... \includegraphics[width=0.8\linewidth] {myfile.eps} \end{verbatim} } \subsection{Color} Please refer to the author guidelines on the CVPR 2020 web page for a discussion of the use of color in your document. \section{Final copy} You must include your signed IEEE copyright release form when you submit your finished paper. We MUST have this form before your paper can be published in the proceedings. Please direct any questions to the production editor in charge of these proceedings at the IEEE Computer Society Press: \url{https://www.computer.org/about/contact}. {\small \bibliographystyle{ieee_fullname} \section{Ablation Study} \subsection{Ablation on Architecture Tree $\mathcal{T}_A$} $\mathcal{T}_A$ is proposed to reduce the exploration size from $M^L$ to $\lceil\frac{L}{d_a}\rceil \times M^{d_a}$. Here, we experiment with the expansion depth $d_a$ and the construction of the architecture tree (the branching order of the architecture layers). \mysection{Expansion depth $d_a$.} In Table \ref{table:expand_depth}, we compare TNAS using different expansion depths of the BFS in $\mathcal{T}_A$, ranging from $d_a=0$ to $d_a=L=6$. A larger expansion depth generally leads to a higher search accuracy, but at the cost of search efficiency. It is worthwhile noting that TNAS with $d_a=2$ outperforms GDAS~\cite{dong2019searching}, while using $6\times$ less GPU hours. \begin{table}[!htb] \centering \caption{\textbf{Ablate expansion depths} ($d_a, d_o$) of $\mathcal{T}_A, \mathcal{T}_O$} \label{table:expand_depth} \vspace{-1em} \resizebox{1.\columnwidth}{!}{ \begin{tabular}{lcccccc} \toprule \textbf{expansion depth} & \textbf{CIFAR-10} & \textbf{CIFAR-100} & \textbf{ImageNet-16-120} & \textbf{cost (hours)}\\ \midrule $d_a=1, d_o=1$ & 93.65$\pm$0.14 & 70.63$\pm$0.37 & 44.57$\pm$0.45 & 1.5\\ $d_a=1, d_o=3$ & $93.58\pm0.32$ & $70.96\pm1.23$ & $44.61\pm1.60$ & 1.4\\ \midrule $d_a=2, d_o=1$ & 93.66$\pm$0.20 & 70.93$\pm$0.92 & 44.38$\pm$0.99 & 1.2\\ $d_a=2, d_o=3$ & 93.53$\pm$0.43 & 70.94$\pm$1.32 & 44.31$\pm$1.23 & 2.3 \\ \midrule $d_a=3, d_o=1$ & 93.80$\pm$0.09 & 71.64$\pm$0.05 & 45.25$\pm$0.84 & 1.8\\ $d_a=3, d_o=3$ & 93.83$\pm$0.17& 70.85$\pm$0.07 & 44.92$\pm$1.27 &5.3\\ \midrule $d_a=4, d_o=1$ & 94.15$\pm$0.24 & 72.61$\pm$0.94 & 45.97$\pm$0.75 & 2.3\\\midrule $d_a=5, d_o=1$ & 94.12$\pm$0.14 & 72.63$\pm$0.50 & 46.02$\pm$0.57 & 3.1\\\midrule \textbf{$d_a=6, d_o=1$} & \textbf{94.35}$\pm$0.03 & \textbf{73.02}$\pm$0.34 & \textbf{46.31}$\pm$0.24& 3.6 \\ \bottomrule \end{tabular} } \end{table} \mysection{Branching order of architecture layers.} We construct $\mathcal{T}_A$ by branching the one-shot architecture layer by layer. The branching order will change the structure of $\mathcal{T}_A$. By default, we branch the architecture layer breadth-wise, namely branch all incoming layers of a node at first, then move to the successor of the node in the topological ordering. Here, we experiment with depth-wise order and random order in Table \ref{table:order} with $d_a=1, d_o=1$. The depth-wise order is to branch one layer of the node at first, move to its successor until the last node, then backtrack to the root node and branch its second layer, and so on. Results show that the branching order does not influence the search accuracy much. \begin{table}[!htb] \centering \caption{\textbf{Ablate branching order of the architecture layers}} \vspace{-1em} \label{table:order} \resizebox{1.\columnwidth}{!}{ \begin{tabular}{lcccc} \toprule \textbf{Search Order} & \textbf{CIFAR-10} & \textbf{CIFAR-100} & \textbf{ImageNet-16-120}\\ \midrule breadth-wise (default) & 93.65$\pm$0.14 &70.63$\pm$0.37 & 44.57$\pm$0.45 \\ depth-wise & 93.74$\pm$0.10 &71.52$\pm$0.57& 45.31$\pm$0.86 \\ random & 93.70$\pm$0.22 & 70.78$\pm$1.09 & 44.80$\pm$1.20\\ \bottomrule \end{tabular} } \end{table} \subsection{Ablation on Binary Operation Tree $\mathcal{T}_O$}\label{sec:ablate_op} As mentioned earlier, $\mathcal{T}_O$ is proposed to reduce the exploration size from $M^L$ to $\left\lceil\frac{\log_2(M-1) + 1}{d_o} \right \rceil\times 2^{d_oL}$. Here, we experiment with the expansion depth $d_o$ and the construction of $\mathcal{T}_O$ (the grouping strategy of operations). \mysection{Expansion depth $d_o$.} Table \ref{table:expand_depth} shows the influence of the expansion depth $d_o$ of BFS in the binary operation tree $\mathcal{T}_O$. When $d_a$ is small, TNAS tends to be more greedy and favors a smaller $d_o$. When $d_a$ is large, TNAS tends to be more like a global optimizer and favors a larger $d_o$. Overall, the influence of $d_o$ is not as profound as that of $d_a$. \mysection{Grouping strategy of operations.} How operations are branched in $\mathcal{T}_O$ will change the tree's structure. For simplicity, we number the operations in NAS-Bench-201 as (0) $none$, (1) $skip~connection$, (2) $1\times1~conv$, (3) $3\times3~conv$, and (4) $3\times3 ~avgpool$. Our $\mathcal{T}_O$ has a straightforward structure, $[0, [[2, 3], [1,4]]]$, as shown in Figure \ref{fig:operation_tree}. Here, we ablate different structures, and show their results in Table \ref{table:grouping}. Results demonstrate that the structure of $\mathcal{T}_O$ significantly influences the search accuracy. Our default structure tends to have more distinguishable exclusive operation groups, and is the most accurate among the variants. \begin{table}[!htb] \centering \caption{\textbf{Ablate the grouping strategy of operations} } \label{table:grouping} \vspace{-1em} \resizebox{1.\columnwidth}{!}{ \begin{tabular}{lccccc} \toprule \textbf{Grouping} & \textbf{CIFAR-10} & \textbf{CIFAR-100} & \textbf{ImageNet-16-120}\\ \midrule \textbf{$[[2, 3], [1, 4]]$(default)}& \textbf{94.35} $\pm$ 0.03 & \textbf{73.02} $\pm$ 0.34 & \textbf{46.31} $\pm$ 0.24 \\ $[[2, 1], [3, 4]]$ & 93.63$\pm$0.15 & 70.72$\pm$0.35 & 44.57$\pm$0.31 \\ $[2,4], [1,3]$ & 93.11$\pm$0.35 & 69.89$\pm$0.12& 43.40$\pm$0.34 \\ \bottomrule \end{tabular} } \end{table} \section{Conclusion}\label{sec:conclusion} We present a novel NAS algorithm, TNAS, that performs bi-level BFS on the proposed binary operation tree and the architecture tree. By adjusting the search depths on the trees, TNAS can explicitly control the exploration size. TNAS finds the global optimal architecture in NAS-Bench-201~\cite{Dong2020NASBench201ET} with a search cost of less than 4 GPU hours. \section{Experiments}\label{sec:exp} \begin{table}[t] \centering \caption{\textbf{State-of-the-art comparison on NAS-Bench-201}. Top-1 test accuracy (mean and standard deviation over 5 runs) are reported. For each dataset, \textbf{optimum} indicates the best test accuracy achievable in the NAS-Bench-201 search space.} \label{table:nasbench201} \vspace{-1em} \resizebox{.5\textwidth}{!}{ \begin{tabular}{lcccccc} \toprule \textbf{Architecture} & \textbf{CIFAR-10} & \textbf{CIFAR-100} & \textbf{ImageNet-16-120} & \textbf{Search Cost (hours)} & \textbf{Search Method} \\ \midrule \textbf{optimum} & 94.37 & 73.51 & 47.31 & - & -\\ \midrule ResNet \cite{he2016deep} & 93.97 & 70.86 & 43.63 & - & - \\ \midrule REA \cite{real2019regularized} & $93.92\pm0.30$ & $71.84\pm0.99$ & $45.54\pm1.03$ & 3.3 & EA \\ REINFORCE \cite{ying2019nasbench101} & $93.85\pm0.37$ & $71.71\pm1.09$ & $45.24\pm1.18$ & 3.3 & RL \\ RS \cite{bergstra2012random} & $93.70\pm0.36$ & $71.04\pm1.07$ & $44.57\pm1.25$ & 3.3 & random \\ \midrule NAS w.o. Training \cite{mellor2020neural} & $91.78\pm1.45$ & $67.05\pm2.89$ & $37.07\pm6.39$ & - & training-free \\ TE-NAS \cite{chen2020tenas} & $93.90\pm0.47$ & $71.24\pm0.56$ & $42.38\pm0.46$ & - & training-free \\ \midrule RSPS \cite{li2020random} & $87.66\pm1.69$ & $58.33\pm4.34$ & $31.14\pm3.88$ & 2.2 & random \\ ENAS \cite{pham2018efficient} & $54.30\pm0.00$ & $15.61\pm0.00$ & $16.32\pm0.00$ & 3.7 & EA \\ DARTS (2nd) \cite{liu2018darts} & $54.30\pm0.00$ & $15.61\pm0.00$ & $16.32\pm0.00$ & 8.3 & gradient \\ GDAS \cite{dong2019searching} & $93.61\pm0.09$ & $70.70\pm0.30$ & $41.84\pm0.90$ & 8.0 & gradient \\ DARTS- \cite{chu2021darts-} & $93.80\pm0.40$ & $71.53\pm1.51$ & $45.12\pm0.82$ & 3.2 & gradient \\ VIM-NAS \cite{wang2021vimnas} & $94.31\pm 0.11$ & $\textbf{73.07}\pm0.58$ & $46.27\pm0.17$ & - & gradient \\ \midrule \textbf{TNAS (ours)} & \textbf{94.35}$\pm$0.03 & 73.02$\pm$0.34 & \textbf{46.31}$\pm$0.24& 3.6 &tree& \\ \textbf{TNAS (best)} & $\textbf{94.37}$ & $73.09$ & \textbf{46.33} & 3.6 &tree& \\ \bottomrule \end{tabular} } \end{table} \mysection{Setup.} We evaluate TNAS on NAS-Bench-201~\cite{Dong2020NASBench201ET} with $(d_o=1, d_a=6)$. We train each architecture over $2$ epochs and use the top-1 accuracy on validation set as the score for the architecture. If the architecture consists of a layer with multiple operations, the output of this layer is the sum of all outputs as Equation \ref{eqn:oneshot}. Note that other scoring methods aforementioned in Section \ref{sec:related} can also be applied. \mysection{Results.} Table \ref{table:nasbench201} compares TNAS with state-of-the-art NAS methods. \textit{TNAS finds the global optimal architecture in CIFAR-10 \cite{krizhevsky2009cifar10} within 4 GPU hours.} TNAS achieves 94.35\% average test accuracy, outperforming all other NAS methods. We highlight that TNAS outperforms the EA (REA~\cite{real2019regularized}), RL (REINFORCE~\cite{ying2019nasbench101}) and random search (RS~\cite{bergstra2012random}) with a similar search cost, which clearly demonstrates the benefit of our NAS paradigm. TNAS also performs significantly better than the one-shot based methods, such as ENAS \cite{pham2018efficient}, DARTS\cite{liu2018darts}, GDAS \cite{dong2019searching} and DARTS- \cite{chu2021darts-}, while being more efficient. TNAS picks one operation group out of two for each layer at each search stage, and thus prunes a portion of the candidate architectures in the search space, as illustrated in Figure\xspace \ref{fig:pruning}. \section{Introduction} \label{sec:introduction} Neural architecture search has spurred increasing interest in both academia and industry for its ability in finding high-performance neural network architectures with minimal human intervention. To achieve the most accurate NAS algorithm, one can explore all candidate architectures, training each one to convergence, and picking the best-performing architecture. However, this brute-force NAS is infeasible due to the enormous search space. Therefore, one of the key questions towards a successful NAS algorithm is: how to efficiently explore the search space? One-shot NAS \cite{brock2017smash,pham2018efficient,bender2018understanding,liu2018darts} impressively improved the efficiency of NAS. One-shot NAS leverages a weight-sharing strategy and approximately trains only one network, called the \emph{supernet}, which subsumes all candidate architectures. Each candidate architecture directly inherits weights from the supernet without training. Despite the efficiency of one-shot NAS algorithms, they incur architecture evaluation degradation, \ie the architecture performance evaluated using the weight-sharing is not correctthat, which leads to a degraded search accuracy \cite{Yu20Evaluting,li2020sgas}. \begin{figure}[t] \begin{minipage}[b]{0.55\columnwidth} \begin{subfigure}{\textwidth} \includegraphics[width=\textwidth]{figures/pruning_ranking/pruning0.png} \caption{The entire search space. Each \\dot represents an architecture. } \label{fig:pruning0} \end{subfigure \end{minipage}\hfill \begin{minipage}[s]{0.44\columnwidth} \begin{subfigure}{\textwidth} \includegraphics[width=\textwidth]{figures/pruning_ranking/pruning1.png} \caption{The pruned search space after the first search stage. } \label{fig:pruning1} \end{subfigure \end{minipage} \begin{minipage}[b]{0.45\columnwidth} \begin{subfigure}{\textwidth} \includegraphics[width=\textwidth]{figures/pruning_ranking/pruning2.png} \caption{The pruned search space after the second search stage. } \label{fig:pruning2} \end{subfigure}% \end{minipage}\hfill \begin{minipage}[s]{0.45\columnwidth} \begin{subfigure}{\textwidth} \includegraphics[width=\textwidth]{figures/pruning_ranking/pruning3.png} \caption{The single candidate architecture found after the third stage. } \label{fig:pruning3} \end{subfigure \end{minipage} \caption{\textbf{TNAS hierarchically factorizes the search space and gradually prunes the unpromising architectures.} The colorbar shows the global rankings of architectures on CIFAR-10 \cite{krizhevsky2009cifar10} in NAS-Bench-201~\cite{Dong2020NASBench201ET}. Red stars indicate top-10 architectures. } \vspace{-1em} \label{fig:pruning} \end{figure} In this work, we diverge from the paradigms set by early NAS, and instead design a new algorithm to explore the search space in a wiser manner. Consider a search space $\mathcal{A}$ where the number of candidate operations is $M$ and the number of architecture layers to search is $L$. The size of the entire search space $|\mathcal{A}|$ equals to $M^L$. If $M=2$ or $L=1$, $|\mathcal{A}|$ can be drastically reduced to $2^L$ or $M$. The intuition behind our work is to develop a method that factorizes the operation space (size $M$) and the architecture layers (size $L$), and thus reduces the exploration size exponentially. \vspace{2pt}\noindent \textbf{Contributions.} \textbf{(1)} We introduce an architecture tree and a binary operation tree to factorize the search space $L$ and $M$, respectively. By combining the two trees, we iteratively branch a search space into two exclusive subspaces. \textbf{(2)} We propose a novel, flexible, accurate, and efficient NAS algorithm, called \textbf{TNAS}: NAS with trees. TNAS performs a modified bi-level Breadth-First Search (BFS) in the two proposed trees. By adjusting the expansion depths of the BFS, TNAS explicitly controls the exploration size $N$ and is able to exponentially reduce $N$ from $M^L$ to $O(L\log_2{M})$. The essence of TNAS is illustrated in Figure \ref{fig:pruning}. \textbf{(3)} TNAS is is able to find the global optimal architecture on CIFAR-10~\cite{krizhevsky2009cifar10} (94.37\% test acc.) in NAS-Bench-201~\cite{Dong2020NASBench201ET} within 4 GPU hours on one GTX2080Ti GPU. TNAS outperforms the RL and EA based NAS \cite{zoph2018nasnet,real2019regularized} as well as one-shot NAS \cite{pham2018efficient,chen2019pdarts}, with a similar search cost. \begin{figure*}[t] \centering \begin{minipage}[b]{0.35\textwidth} \centering \begin{subfigure}{\textwidth} \includegraphics[width=\textwidth]{figures/architecture_tree_complicated.pdf} \caption{Architecture tree $\mathcal{T}_A$} \label{fig:arch_tree} \end{subfigure \end{minipage} \hfill \begin{minipage}[s]{0.63\textwidth \centering \begin{subfigure}{\textwidth} \includegraphics[width=\linewidth]{figures/pipeline_d1L3.pdf} \caption{BFS with expansion depth $d_a=1$ explores $M\times L$ architectures} \label{fig:arch_tree_l1} \end{subfigure} \vfill \begin{subfigure}{\textwidth} \includegraphics[width=\linewidth]{figures/pipeline_d3L3.pdf} \caption{BFS with $d_a=L=3$ explores $M^L$ architectures} \label{fig:arch_tree_l3} \end{subfigure \end{minipage} \caption{\textbf{Illustration of the architecture tree $\mathcal{T}_A$ and the proposed Breadth-First Search (BFS)}. } \vspace{-1em} \label{fig:arch_tree_pipelines} \end{figure*} \section{Methodology} \label{sec:methodology} We present TNAS (NAS with trees) to efficiently find a high-performance architecture by performing a modified bi-level Breadth-First Search in the proposed architecture tree $\mathcal{T}_A$ and binary operation tree $\mathcal{T}_O$. \subsection{Architecture Tree $\mathcal{T}_A$} Given a search space with $L$ layers and $M$ operations per layer, we propose an architecture tree $\mathcal{T}_A$ to factorize the one-shot architecture and to exponentially reduce the exploration size. The architecture tree $\mathcal{T}_A$ is illustrated in Figure\xspace \ref{fig:arch_tree}. Each node in the tree represents an architecture. The root node is the $M$-path $L$-layer one-shot architecture. Each path in a layer denotes a distinct operation from $M$ candidate operations. $\mathcal{T}_A$ has a maximum depth level equal to $L$. For each node (architecture) at depth $i$ ($i \in [0, 1, \dots, L-1$), the tree separates the $M$ operations in layer $i$ into $M$ branches each with a single operation. Such branching is repeated for each node, until the leaf nodes are reached. Each leaf node represents a distinct single-path architecture. The union of the leaf nodes is the set of all candidate architectures. Note that if layer $i$ contains multiple operations, the output of this layer will be the summation of the outputs of all operations at this layer, as inspired by the one-shot NAS \cite{bender2018understanding} and is formulated as: \begin{equation}\label{eqn:oneshot} {\bar{o}}^{i}(x) = \sum_{o_j \in \mathcal{O}} o_j^{i}(x), \end{equation} where $\mathcal{O} = \{o_j~|~ j = 1, 2, \ldots, M\}$ denotes $M$ different operations and $x$ denotes the input feature map. \mysection{Breadth-First Search (BFS) in $\mathcal{T}_A$.} Here, we show that the architecture search can be done by performing our modified BFS in the architecture tree $\mathcal{T}_A$. Our BFS requires a hyperparameter, the expansion depth denoted as $d_a$, where the subscript $a$ denotes ``architecture''. BFS starts at the root node (the one-shot model) at depth $0$, expands all its successors until depth $d_a$, and obtains up to $M^{d_a}$ leaf nodes after expansion. BFS scores the subnets defined by these leaf nodes, and picks the node with the highest score as the root node for the next step. The above procedure is defined as a \textit{decision step}, and is repeated until a single-path architecture is determined. The \textit{score} function can be chosen to be the validation performance after training, or a metric function proposed by any metric-based NAS method such as the number of linear regions \cite{mellor2020neural}. For simplicity, we choose the scoring function to be validation performance in our experiments. The expansion depth $d_a$ of the BFS denotes how many layers to branch at each decision step. As illustrated in Figure\xspace \ref{fig:arch_tree_l1}, the BFS with $d_a=1$ is a \textit{sequential, greedy} NAS algorithm that decides the operation for the architecture layer by layer, similar to the progressive NAS method SGAS \cite{li2020sgas}. The BFS with $d_a=L$ as shown in Figure\xspace \ref{fig:arch_tree_l3} works as the \textit{brute-force} NAS, where only $1$ decision step is required. The BFS explores all $M^{L}$ subnets and decides the operation for all of the layers at the same decision step. When $d_a=k\in \{2, \cdots, L-1\}$, $k$ layers are branched in each decision step, $M^k$ subnets need to be scored, and $\left\lceil{\frac{L}{k}}\right\rceil$ decision steps are required. This case works similar to the block-wise NAS \cite{li2020dna}, while our BFS does not require any block-level supervision. \subsection{Binary Operation Tree $\mathcal{T}_O$} We propose a binary operation tree $\mathcal{T}_O$ that hierarchically factorizes the operation space to further reduce the exploration size. Each node in $\mathcal{T}_O$ is an \textit{operation group} consisting of one or more distinct operations. The root node represents $\mathcal{O}$, the entire operation space containing all $M$ operations. $\mathcal{T}_O$ starts from the root node and branches it into two child nodes that represent two exclusive operation groups. Such branching is repeated for each node until a leaf node that represents a single operation is reached. $\mathcal{T}_O$ has $M$ leaf nodes. The union of leaf nodes is $\mathcal{O}$. Taking NAS-Bench-201~\cite{Dong2020NASBench201ET} operation space as an example, we illustrate the $\mathcal{T}_O$ in Figure\xspace \ref{fig:operation_tree}. \begin{figure}[t] \centering \includegraphics[width=0.6\columnwidth]{figures/operation_tree.pdf} \caption{\textbf{The binary operation tree $\mathcal{T}_O$}. } \vspace{-1em} \label{fig:operation_tree} \end{figure} \mysection{Breadth-First Search (BFS) in $\mathcal{T}_O$.} The expansion depth of our modified BFS in $\mathcal{T}_O$ is denoted as $d_o$. BFS starts at the root node (the entire operation space) at depth $0$, expands all its successors until depth $d_o$, and obtains up to $2^{d_o}$ leaf nodes after expansion. These leaf nodes represent the current candidate operation groups. BFS scores the architectures equipped with these different operation groups, and picks the node defined by the operation group with the highest score as the root node for the next stage. The above procedure is defined as a \textit{decision stage}, and is repeated until a single operation is picked. Note that each architecture layer can choose different operation groups at each decision stage. If $d_o = 1$, the BFS decides the operation groups per depth following $\mathcal{T}_O$. In this case, BFS consists of $\lceil\frac{\log_2{(M-1)}+1}{d_o}\rceil = 3$ decision stages. At the $1^{\text{st}}$ stage, BFS decides among \textit{None} or \textit{Not None} for each architecture layer. At the $2^{\text{nd}}$ stage, for those layers that chose \textit{Not None}, the algorithm decides among the \textit{Convolution} group or \textit{Topology} group. At the final stage, the algorithm will pick a single operation for each layer. If $d_o=3$, BFS only needs one decision stage to decide which single operation to choose for each layer. \begin{figure}[t] \centering \includegraphics[width=0.50\textwidth]{figures/pipeline_d2.pdf} \caption{\textbf{Illustration of TNAS ($d_a=2, d_o=1$).} } \vspace{-1mm} \label{fig:pipeline} \end{figure} \subsection{TNAS}\label{sec:tnas} We present a new NAS algorithm: \textbf{N}eural \textbf{A}rchitecture \textbf{S}earch with \textbf{T}rees (\textbf{TNAS}). Given a search space with $M$ candidate operations and $L$ layers, TNAS constructs a binary operation tree $\mathcal{T}_O$ and an architecture tree $\mathcal{T}_A$. TNAS starts from the $M$-path $L$-layer one-shot model, and performs \textit{bi-level Breadth-First Search} on $\mathcal{T}_O$ and $\mathcal{T}_A$. At the outer loop, TNAS performs BFS with the expansion depth $d_o=1$ on $\mathcal{T}_O$ by default, to make a large $d_a$ feasible. The outer loop requires $\lceil\log_2{(M-1)} +1\rceil$ decision stages. Each stage branches each operation group of the chosen layers into two child operation groups, which define the operation search space for the inner loop. The outer loop repeats the decision stage until every architecture layer reaches a leaf node of $\mathcal{T}_O$, \ie all the layers pick a single operation. In the inner loop, TNAS performs BFS with an expansion depth $d_a$ on $\mathcal{T}_A$. The inner loop takes $\left\lceil{\frac{L}{d_a}}\right\rceil$ decision steps. Each step chooses $d_a$ undecided layers to branch, obtains $2^{d_a}$ subnets, scores each subnet, and then chooses the highest scoring one. The chosen subnet will be used to replace the one-shot model and become the starting point for the next step. The inner loop repeats the above decision step until it chooses a leaf node of $\mathcal{T}_A$, \ie all layers of the architecture have decided their operation group at the current decision stage. We illustrate the TNAS algorithm ($d_o=1, d_a=2$) in Figure\xspace \ref{fig:pipeline}. The NAS-Bench-201 \cite{Dong2020NASBench201ET} search space (\ie $M=5$ and $L=6$) is used as an example. \mysection{Exploration size analysis.} Given a search space with $M$ operations and $L$ layers, TNAS reduces the exploration size exponentially from $M^L$ to: \begin{equation} \small N = O \left( 2^{d_od_a} \times \left\lceil\frac{L}{d_a}\right\rceil \times \left\lceil\frac{\log_2{(M-1)}+1}{d_o}\right\rceil \right) \end{equation} \section{Related Work}\label{sec:related} The computational bottleneck of NAS is \textit{exploring} candidate architectures in this huge search space and \textit{exploiting} each one (\ie score the architecture by training to convergence). Through the work, we name the number of architectures to score as the \textit{exploration size}, denoted as $N$. To alleviate the computational bottleneck, NAS algorithms should consider: (i) how to explore wisely, where time can be saved if the algorithm explores more among the ``good" architectures and less on the ``bad" ones, and (ii) how to exploit wisely, where training each network to convergence just to know the architecture's performance then throwing weights away is inefficient. \mysection{Explore wisely.} Early methods adopt Reinforcement Learning \cite{zoph17nas-rl,baker17metaqnn,zoph2018nasnet} or Evolutionary Algorithms \cite{Stanley2002EvolvingNN,Real17large_scale_evolution,real2019regularized} to auto-explore the huge search space. Although early NAS methods have been able to discover architectures that outperform manually designed networks, they consume significant computational resources. This is primarily because these algorithms require a large exploration size to achieve a decent search accuracy. Progressive NAS is a method that factorizes the search space into a product of smaller search spaces and can greatly reduce the exploration size. PNAS~\cite{liu2018progressive} and P-DARTS~\cite{chen2019pdarts} start searching with shallow models and gradually progress to deeper ones. Li \etal propose block-wise progressive NAS~\cite{li2020dna,li2021bossnas} that consider the architectures is built by sequential blocks and search the architecture block by block. SGAS~\cite{li2020sgas}, GreedyNAS~\cite{you2020greedynas}, and \cite{hu2020abs, zheng2020rethinking,wu2021weak} progressively shrink the search space by dropping unpromising candidates. These progressive NAS methods require a much smaller exploration size, but their greedy nature hampers their search accuracy. Our TNAS designs a new paradigm for exploring wisely by introducing two trees to factorize the search space. \mysection{Exploit wisely.} A straightforward idea of reducing exploitation is to train fewer epochs as done in Block-QNN~\cite{block_qnn}. A more advanced solution is to share weights among child networks, apart from training them from scratch. This weight-sharing strategy was first proposed by ENAS~\cite{brock2017smash,pham2018efficient} and has inspired many following works, including one-shot NAS~\cite{bender2018understanding,liu2018darts,guo2020spos,wan2020fbnet2,peng2020cream,yu2020bignas,chu2021darts-,gu2021dots}. To alleviate the evaluation degradation \cite{Yu20Evaluting,Bender2020CanWS,li2020sgas} issues of one-shot NAS caused by weight-sharing, few-shot NAS~\cite{zhao2021fewshotnas,kshotnas} were proposed by training $k$ supernets instead of training only one. Another line of work to exploit wisely is accuracy prediction~\cite{liu2018progressive,chamnet,block_qnn_plus}, where an accuracy predictor is learned to directly estimate an architecture's accuracy without training it completely. Recently, metric-based NAS methods~\cite{mellor2020neural,chen2020tenas,zero-cost-nas,rlnas,hu2020abs,chen2021bnnas} have emerged, using well-designed metrics to score the sampled architectures quickly with significantly less training or even no training. Since our paper focuses on how to wisely explore the NAS search space, wise exploitation is an orthogonal direction. In fact, we highlight here that our TNAS can be applied with nearly all the aforementioned exploit-wise NAS methods. \section{Exploration Size Analysis} The number of architectures to score (exploration size $N$) is up bounded by $ \left( 2^{d_od_a} \times \left\lceil\frac{L}{d_a}\right\rceil \times \left\lceil\frac{\log_2{(M-1)}+1}{d_o}\right\rceil \right)$ in our proposed TNAS. Here we list the exact number of $N$ of TNAS when using different expansion depths in Table\xspace \ref{table:darts_size}. \begin{table}[!htb] \centering \caption{Exploration size in the worst case in NAS-Bench-201 search space $L=6, M=5$. The maximum depth level of the binary operation tree is $\lceil\log_2(M-1)+1\rceil=3$. }. \label{table:darts_size} \resizebox{1.\columnwidth}{!}{ \begin{tabular}{lc} \toprule Expansion depths & Exploration size\\ \midrule $d_a=1, d_o=1$ (progressive sequential greedy) & $2 \times 6 \times 3$=36\\ $d_a=1, d_o=3$ (sequential greedy) & $5 \times 6 = 30$ \\ $d_a=3, d_o=1$ & $2^3 \times \frac{6}{3} \times 3 = 48$ \\ $d_a=6, d_o=1$ (progressive brute-force) & $2^{6} \times 3 = 192$\\ $d_a=6, d_o=3$ (brute-force) & $5^{6}= 15,625$ \\ \bottomrule \end{tabular} } \end{table} \section{NAS-Bench-201 Details} NAS-Bench-201 \cite{Dong2020NASBench201ET} builds a cell-based search space. The cell is a directed acyclic graph consisting of $4$ nodes and $L=6$ edges. Through our work, we denote each edge of the graph as an architecture layer. Each candidate network is stacked by $15$ cells. Each layer has an operation selected from $M=5$ operations. The search space contains $5^6 = 15,625$ candidate architectures in total. \section{DARTS Search Space} \subsection{Binary Operation Tree} In DARTS search space, each architecture layer has $M=8$ operations for selection: $3\times3$ and $5\times5$ \textit{separable convolution}, $3\times3$ and $5\times5$ \textit{dilated separable convolution}, $3\times3$ \textit{maxpool}, $3\times3$ \textit{avgpool}, \textit{skip connection}, and \textit{none} (\textit{zero}). The binary operation tree in DARTS operation space is illustrated in Figure\xspace \ref{fig:darts_operation_tree}. \begin{figure}[t] \centering \includegraphics[width=1.0\columnwidth]{figures/darts_operation_tree.pdf} \caption{\textbf{The binary operation tree $\mathcal{T}_O$} in DARTS operation space. } \label{fig:darts_operation_tree} \end{figure} \subsection{Architecture Trees} Different from the NAS-Bench-201 \cite{Dong2020NASBench201ET}, in DARTS search space, one has to find the architectures for both normal cell and reduce cell. Each cell has $L=14$ layers. We build an architecture tree for each cell. For each decision stage, our TNAS will search for the normal cell on the normal architecture tree at first, then search for the reduce cell on the reduce architecture tree, following our proposed TNAS algorithm. \subsection{ImageNet Transfer} We transfer the best cell architecture found in CIFAR-10 \cite{krizhevsky2009cifar10} to ImageNet \cite{imagenet_cvpr09} in the mobile setting. We adopt the same training and evaluation as DARTS \cite{liu2018darts}. We stack the found cells by $14$ times, and change the channel size to meet the 600M MAdds constraint. We train each network by $250$ epochs with label smoothing and an auxiliary classification head without other strong data augmentation. The results are shown in the main paper. \subsection{Visualization of Architectures} The best found cell architectures on CIFAR-10 \cite{krizhevsky2009cifar10} without the two incoming edges constraint are illustrated in Figure\xspace \ref{fig:architectures}. \begin{figure}[!htb] \centering \begin{subfigure}{\columnwidth} \includegraphics[width=1.0\columnwidth]{figures/architectures/tnasl1_1_normal.pdf} \caption{The best found Normal cell. } \end{subfigure} \begin{subfigure}{\columnwidth} \includegraphics[width=1.0\columnwidth]{figures/architectures/tnasl1_1_reduction.pdf} \caption{The best found Reduce cell. } \end{subfigure} \caption{\textbf{The best found architectures of TNAS in DARTS search space} \cite{liu2018darts}.} \label{fig:architectures} \end{figure} \section{RobustDARTS Search Space} To show the strength of TNAS, we also experiment on the RobustDARTS search space S4 proposed in \cite{ZelaESMBH20}. This space consists of two candidate operations $3\times3$ \textit{sepconv} and \textit{noise}. The \textit{noise} is intentionally added and actively harms the performance and should not be selected. We show the architecture found by TNAS in RobustDARTS S4 space in Figure\xspace \ref{fig:s4_architectures}. While DARTS \cite{liu2018darts} and PC-DARTS \cite{xu2019pc} cannot distinguish the harmful noise operation, our TNAS does not choose any $noise$ in both normal cell and reduce cell. Table\xspace \ref{table:s4} show the quantitative results of TNAS, which demonstrates that our TNAS outperforms the state-of-the-art by a large margin. \begin{table}[!htb] \centering \caption{\textbf{State-of-the-art comparison on RobustDARTS search space S4}. } \vspace{-1em} \label{table:s4} \resizebox{1.0\columnwidth}{!}{% \begin{threeparttable} \scriptsize \begin{tabular}{cccccccccc} \toprule \multicolumn{3}{c}{\textbf{DARTS} \cite{liu2018darts}} &\multicolumn{2}{c}{\textbf{R-DARTS \cite{ZelaESMBH20}}} &\multicolumn{2}{c}{\textbf{SDARTS \cite{chen2020stabilizing}}} &\multirow{2}{*}{\textbf{PC-DARTS} \cite{xu2019pc}} &\multirow{2}{*}{\textbf{DARTS-} \cite{chu2021darts-}} &\multirow{2}{*}{\textbf{TNAS (ours)}}\\ \cmidrule(r){1-3} \cmidrule(r){4-5} \cmidrule(r){6-7} - &ES & ADA & DP & L2 & RS & ADV\\ \midrule 7.20 & 3.71 & 4.84 & 3.58 & 3.56 & 2.93 & 2.87 & 3.02 & 2.86 & \textbf{2.43} \\ \bottomrule \end{tabular}% \end{threeparttable} } \end{table} \begin{figure}[!htb] \centering \begin{subfigure}{\columnwidth} \includegraphics[width=1.0\columnwidth]{figures/architectures/s4_tnas_normal.pdf} \caption{The Normal cell. } \end{subfigure} \begin{subfigure}{\columnwidth} \includegraphics[width=1.0\columnwidth]{figures/architectures/s4_tnas_reduction.pdf} \caption{The Reduce cell. } \end{subfigure} \caption{\textbf{The architecture found by TNAS in RobustDARTS S4 search space} \cite{ZelaESMBH20}.} \label{fig:s4_architectures} \end{figure}
{'timestamp': '2022-04-12T02:34:17', 'yymm': '2204', 'arxiv_id': '2204.04918', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04918'}
arxiv
\section{Introduction}\label{sec:introduction} Legal Judgment Prediction (LJP), which predicts the outcome of legal cases from the fact descriptions~\cite{lawlor1963computers}, plays a vital role in legal assistance systems and benefits both legal practitioners and normal citizens. In reality, this task is purely done by legal experts, who receive many years of specialized training before processing legal cases. LJP involves several steps like finding relevant law articles/history cases, defining the range of the charge, deciding the penalty term, etc. Each step is time-consuming and requires domain-specific solid background, incurring a great burden to the limited amounts of legal practitioners. In Louisiana, every attorney handles up to 50 cases per day, leaving only 1-5 minutes for case preparation~\cite{oppel2019one}. There are 332 thousand cases in progress in Brazil per day, considering only the financial domain~\cite{Brazil2014}. In India, 38 million pending cases cannot be handled on time until December 2021~\cite{NJDG2021backlog}. The massive imbalance between the need for legal assistance and the number of legal experts brings severe social problems. For example, low-income Americans reported 86\% of the civil legal issues received inadequate or no legal help ~\cite{legal2017justice}. This calls for the need for automatic LJP systems, which can significantly improve the working efficiency of legal experts since they do not need to process everything from scratch. Automated LJP systems can also offer real-time legal consult and enhance public access to justice. LJP is itself a long-standing task. As early as the 1950s, ~\cite{kort1957predicting,kort1960quantitative} have applied factor and linear regression analyses to predict decisions (pro or con) of the US Supreme Court cases depending on the 26 factual elements (patterns) with 14 training and 14 test "right to counsel" cases. Most LJP methods in the same period were based on rules or statistical methods~\cite{nagel1960weighting,ulmer1963quantitative,lawlor1963computers,keown1980mathematical}. However, these systems are sensitive to noise and cannot generalize to other law domains. Later on, researchers began to apply machine learning methods trained on a larger number of legal cases~\cite{liu2006exploring,katz2012quantitative,RN220,sulea2017predicting}. Recently, the rapid advances of neural networks and large-scale pretrained language models based on the Transformer architecture further led to a considerable improvement in this area~\cite{2017Learning,shen2017estimation,vaswani2017attention,devlin-etal-2019-bert,brown2020language,ge2021learning,huang2021dependency}. As shown in Fig.~\ref{fig7}, the legal domain papers have proliferated in major NLP conferences. Among all these papers, around 65\% of them are relevant to the LJP task. The availability of challenging benchmark datasets plays a crucial role in spurring innovation in LJP~\cite{kalamkar2021indian}. In the past few years, we have witnessed an explosion of public LJP benchmark datasets, such as CAIL2018~\cite{zhong2020does,xiao2018cail2018}, ECHR-CASES~\cite{zhong2020does,2019Neural}, SwissJudgmentPrediction~\cite{niklaus2021swiss}, JUSTICE~\cite{2021JUSTICE2021,chalkidis2021lexglue}. These datasets inspired a large number of LJP models, such as TopJudge~\cite{2018Legal}, MLCP-NLN~\cite{wei2019external}, MPBFN-WCA~\cite{2019Legal}, and LADAN~\cite{2020Distinguish}. Impressive results have been achieved in various benchmark datasets, despite a clear gap between the machine and human performance~\cite{xiao2018cail2018}. However, most researchers focus on a few popular LJP datasets, while most other LJP datasets are not widely known and studied by the community. In addition, there is also a need for systematic categorization/classification of LJP subtasks. For example, LJP tasks are generally divided into three subtasks: the decision of applicable law articles, charges, and terms of penalty~\cite{xiao2018cail2018,2018Legal,2019Legal,2020Distinguish}, but this classification method is not thorough, only applies to limited legal systems and domains~\cite{Hai2018Interpretable,wu-etal-2020-de}. A comprehensive survey of existing LJP tasks, datasets, evaluation metrics, and models is strongly needed to promote the future development of LJP. This paper aims to address this gap. There have been a few surveys in the LJP domain. For example, experimental results for symbolic and embedding-based methods and possible future directions have been provided in~\cite{zhong2020does}, but their effects are based on the single benchmark dataset CAIL2018. The task definition and evaluation metrics have been mentioned in~\cite{kalamkar2021indian}, but they focus only on Indian Legal NLP benchmarks and do not cover advances made in other benchmarks. To the best of our knowledge, our survey is the first work that provides a comprehensive survey of the LJP task. It provides a thorough overview of 31 publicly available LJP datasets in 6 languages and introduces the pros and cons of popular state-of-the-art models. \begin{figure} \centering \includegraphics[width=6.2in]{method.pdf} \caption{The number of legal-domain papers in major NLP conferences}\label{fig7} \end{figure} In section~\ref{Tasks Formulations}, we introduce the basis of LJP tasks. We first compare the litigation procedure differences between the common-law and the civil-law system. Next, we define some notations of and analyze the critical dimensions of the existing 31 LJP datasets. We summarized three attributes of LJP: the type of LJP tasks, the type of legal systems, and the type of law domains. Based on the outcomes of LJP tasks, we propose a thorough taxonomy to classify existing LJP datasets. Section~\ref{Datasets} presents 31 LJP datasets in 6 languages and 6 pre-training datasets in 3 languages. In section~\ref{Evaluation Metrics}, evaluation metrics are introduced. We begin by analyzing the four categories for evaluating the outputs from LJP tasks. Then we discuss the computing methods of 14 evaluation metrics of LJP tasks among three LJP task types. Finally, we present the usages of different evaluation metrics in the existing 31 LJP tasks. Section~\ref{methods} reviews 12 legal-domain pretrained models in 3 languages and highlights 3 other major research directions, including multi-task learning, interpretable learning, and few-shot learning models. Multi-task learning methods concentrate on utilizing the dependent information among the multi-subtask in LJP. Interpretable learning methods aim to enhance the interpretability of LJP models and few-shot learning targets at improving the data efficiency on low-frequency (i.e., few-shot) judgment results. In section~\ref{result}, we share the state-of-art results for eight representative LJP datasets from different court cases and the observations of these results for explored research. Finally, in section~\ref{Discussions}, we summarize three prime challenges for existing datasets and methods in LJP: (1) LJP when there is inadequate information from facts. In the trial practice, sometimes an event appears to fit within the statute's language, but it seems absurd to think that the legislature intended to make the disputed activity a crime. At other times, the defendant has done something similar to the activities included in the statutory language, but it seems like a stretch to say that the words fit the event in question. LJP, when there is inadequate information from the determination of facts by the jury, will significantly prevent civil and criminal errors. Predicting the judgment results reducing the universe of evidence from real courtrooms, especially when the proof rules are inadequate or the text is ambiguous, would be a proactive issue in the future. (2) Complex legal logical reasoning. Current NLP models are good at exploring the statistics in the dataset to achieve good accuracy but cannot still reason over complex evidence, deduce from facts and find the logical dependence among factors. (3) Interpretability. LJP is a critical task, and any tiny error from the system might affect judicial fairness. Without good interpretability, humans can hardly trust the output from the automatic LJP system proactive. \section{Tasks Formulations}\label{Tasks Formulations} \subsection{Background}\label{background} \begin{figure} \centering \includegraphics[width=6.2in]{cui_fig1.pdf} \caption{The procedure of court judgment. Firstly, the plaintiff submits his pleas. Secondly, fact verdict is made based on the court debate held between the plaintiff and defendant. Finally, the judge make decisions based on the fact verdict.}\label{fig:cut} \end{figure} As is well known, continental civil-law of those countries (e.g., France, Germany, Switzerland, Belgium, and the Netherlands in European continental, China, Thailand, and Vietnam in Asiatic countries, and Scandinavian countries and Soviet countries) and the common-law of the Anglo-Saxon countries(e.g., the United Kingdom, the United States, Canada, Australia, New Zealand, and India) are two significant legal systems. Both these legal systems have the same purpose of regulating and harmonizing the human activity within their respective societies, and in each society, its legal system is also influenced by its culture, epistemology, and civilization as well as of the history and the life of its people, such as the civil-law and the common-law have been functioning together in countries like Japan and Italy and places like Louisiana, Quebec, Scotland and South Africa. However, it must be recognized that there are of course significant differences between common-law and civil-law. As Roman-law writers had noted that the Roman law of the classical period, the first two centuries A.D. when it reached its highest point of technical development, is in many respects closer in character to the common-law than it is to modern civil-law systems that are derived from Roman law ~\cite{stein1991roman}. As shown in Fig. \ref{fig:cut}, a judicial procedure in a real court setting abides by the no claim no trial principle, whereas the court's claimant's pleadings and court's decisions are two essential components of judicial procedure to protect the legitimate interest of parties. Specifically, a litigation procedure often experiences three stages: pre-trial claim collection stage (plaintiff or petitioner submit written materials appealing its case to the court), trial court debate stage (Followed that the court decides to hear that case, the parties containing plaintiff, defendant, witness, lawyer debate before the court focusing on the fact details), and after trial judge sentence stage(judge generates verdict including judgment). Around the litigation procedure above, the differences between civil-law and common-law system are further concluded: \begin{itemize} \item Pre-trial claim collection stage. The principle of prosecuting a case (legality in civil-law vs. opportunity in common-law)~\cite{ligeti2019place}: Under the legality principle, if there is sufficient evidence at the close of the investigation, the prosecutor is in principle duty-bound to press charges and cannot dismiss a case. The opportunity principle, on the contrary, entrusts the prosecutor with the discretionary choice of whether or not to prosecute a case despite sufficient evidence to charge. Based on the opportunity principle, the portion of federal civil cases resolved by trial fell from 11.5 percent in 1962 to 1.8 percent in 2002, and a similar decline in both the percentage and the absolute number of trials in federal criminal cases~\cite{galanter2004vanishing}, whereas the accused’s fate~\cite{mckillop2003position} is determined by the trial court in common-law rather than the conclusions drawn from the investigation in civil-law. \item Trial court debate stage. Two differences are concluded: (1) Formality of evidence (Public oral evidence in common-law vs. private written proof in civil-law)~\cite{stein1991roman}: In the common-law, the witnesses must give their evidence in public before the court while the civil-law has a preference for written proof in private before a judge who questions him from a neutral standpoint. (2) Methods of facts verdict (Voting jury trial in common-law vs. collegial reasoning trial in civil-law)~\cite{dainow1966civil}: The jury in common-law based on its voting values never had to justify its fact verdict with reasons whereas the judge in civil-law must give the reasons for its verdict based on given facts, the established statutory law articles and common sense. \item After trial judge sentence stage (precedent in common-law vs. legislation in civil-law)~\cite{dainow1966civil}. The civil-law judges search the legislation for the controlling principle and the rules which govern the subject; this principle or rule is then applied or interpreted according to the particular facts of the dispute case. On the contrary, if a statute is involved and the text is clear, common-law judges abide by its provisions. However, if doubt or ambiguity can avoid the statute's applicability, common-law judges search in the previous decisions for a similar case and are guided accordingly, this precedent is then applied or interpreted according to the determination of facts by the jury, the summarized evidence and the relevant rules of law. \end{itemize} \begin{figure*} \centering \includegraphics[width=6.4in]{cui_fig2.pdf} \caption{An outcomes-based judicial framework example interpretation of notations introduced by a law case life-cycle in a real court setting. Within this framework, the LJP tasks are divided into two categories: main LJP tasks (blue) and auxiliary LJP tasks (green).}\label{fig:example} \end{figure*} Based on the background of LJP tasks, some notations of LJP tasks for a court case instance in Fig.~\ref{fig:example} are given, as shown in Table~\ref{table: notation}. \begin{table} \centering \caption{Notations definition for a court case.} \label{table: notation} \begin{tabular}{|l|l|} \hline \textbf{Notation} & \textbf{Description} \\ \hline Pleas & The sentence narratives from the plaintiff for the target dispute. \\ \hline Plea Judgments & \begin{tabular}[c]{@{}l@{}}The response sentence from the judge on the pleas with labels like reject,\\ partially support and support.\end{tabular} \\ \hline Debate & \begin{tabular}[c]{@{}l@{}}The diachronic statement of fact detail from the plaintiff, defendant, witness, \\ lawyer and judge in the real court on the target dispute.\end{tabular} \\ \hline Facts & The admissible facts summarized by the judge by employing evidence \\ \hline Articles & The applied law articles of a Law case. \\ \hline Charges & The specific statement of what crime the party is accused contained in the criminal plea. \\ \hline Prison terms & The penalty terms for corresponding charges in a criminal case. \\ \hline Court View & \begin{tabular}[c]{@{}l@{}}The explanation written by judges to interpret the judgment decision \\ for certain law case.\end{tabular} \\ \hline Facts snippets & The extracted decisive phrases or sentences from facts. \\ \hline Charge attributes & The predefined attribute knowledge for discriminating confusing charges. \\ \hline Attributes prediction & \begin{tabular}[c]{@{}l@{}}A binary classification task used to predict the charge with the attribute or not \\ according to the input facts.\end{tabular} \\ \hline Elements questions & The predefined questions for extracting judgment elements. \\ \hline Elements answers & The answers for element questions. \\ \hline Others & \begin{tabular}[c]{@{}l@{}}The additional metadata that judges can obtain from a case except the items described above, \\ such as the date, the legal area, the canton of origin per case.\end{tabular} \\ \hline \end{tabular} \end{table} \begin{figure} \centering \includegraphics[width=5.8in]{classification.pdf} \caption{Proposed classification method of legal judgment prediction tasks.}\label{fig:classification} \end{figure} \subsection{Taxonomy} To have a better understanding of LJP tasks, in this section, we analyze existing LJP tasks from the key dimensions of 31 LJP datasets as shown in Table \ref{table00} based on notations and terminologies in section \ref{background}. In many research ~\cite{xiao2018cail2018,2018Legal,2019Legal,2020Distinguish}, LJP tasks are divided into three subtasks: the decision of applicable law articles, charges, and penalty terms. However, as shown in Table~\ref{table00}, this classification method has limited coverage of LJP tasks, such as neglecting pro or con decisions. Hence, as shown in Fig.~\ref{fig:classification}, we propose a new classification method of LJP tasks with summarized three attributes of LJP tasks, including the type of tasks, the type of legal systems, and the type of law domains. Each of these attributes can be divided into several different categories. These categories are: \begin{itemize} \item Type of tasks. Two cases are conducted: (1) main tasks: Judgements results are determined by these tasks' outcomes, such as Article recommendation, Charge prediction, Prison term prediction, Court View generation, and Plea judgment task in Table~\ref{table00} and Fig.~\ref{table00}. (2) auxiliary tasks: Judgements results are latently improved by these tasks' outcomes, such as Fact snippets extraction, attribute prediction of the confusing charges and elements answers. \item Type of legal systems. Two main legal systems are considered, including the common-law and civil-law systems. Specifically, for the common-law system: (1) Fact verdicts: Verdicts of Fact gives out the voting values for their Court's charges. (2) Sentence: The trial judge provides the Court's results, including law article recommendation, precedent, prison terms, and Plea judgments. For the civil-law system: (1) Justify the judgments: The judge gives the reasons for its judgment results based on given facts, the established statutory law articles, and common sense. (2) Judgment results: The trial judge provides the Court's results, including charges, prison terms, and Plea judgments. \item Type of law domains. According to online legal community users' demand and the case classification that the Supreme People's Court of the People's Republic of China provides in the Chinese Judgments Online, three prominent cases are conducted: (1)criminal: Articles, Charges, Prison terms, and Plea judgments. (2)civil: Articles, Obligation, Penalty terms, and Plea judgments. (3)administrative: Articles, Penalty terms, and Plea judgments. \end{itemize} \subsubsection{Types of LJP Tasks} \begin{table} \centering \caption{The key dimensions for the format of the existing LJP tasks.} \label{table00} \setlength{\tabcolsep}{0.01pt} \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|} \hline \multirow{2}{*}{Dataset} & \multirow{2}{*}{Language} & \multicolumn{3}{c|}{\multirow{2}{*}{Input}} & \multicolumn{4}{c|}{Output} & \multirow{2}{*}{Download} \\ \cline{6-9} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{Rationale} & \multicolumn{2}{c|}{Decision} & \\ \hline \multirow{3}{*}{SwissJudgmentPrediction ~\cite{niklaus2021swiss}} & German & \multicolumn{1}{c|}{\multirow{4}{*}{Pleas$^{\rm r}$}} & \multicolumn{2}{c|}{\multirow{3}{*}{Facts$^{\rm r}$}} & \multicolumn{2}{c|}{\multirow{4}{*}{-}} & \multicolumn{2}{c|}{\multirow{4}{*}{Plea judgments$^{\rm r}$}} & \multirow{3}{*}{\href{https://zenodo.org/record/5529712}{Link}} \\ \cline{2-2} & Italian & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \\ \cline{2-2} & \multirow{2}{*}{French} & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \\ \cline{1-1} \cline{4-5} \cline{10-10} Sulea et al.~\cite{sulea2017predicting} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Facts$^{\rm r}$} & Others$^{\rm r}$ & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & - \\ \hline TSCC~\cite{kowsrihawat2018predicting} & Thai & \multicolumn{3}{c|}{Facts$^{\rm a}$} & \multicolumn{2}{c|}{Articles$^{\rm a}$} & \multicolumn{2}{c|}{-} & \href{https://github.com/KevinMercury/tscc-dataset}{Link} \\ \hline JUSTICE~\cite{2021JUSTICE2021} & \multirow{7}{*}{English} & \multicolumn{1}{c|}{\multirow{3}{*}{Pleas$^{\rm r}$}} & \multicolumn{2}{c|}{Facts$^{\rm r}$} & \multicolumn{2}{c|}{\multirow{2}{*}{-}} & \multicolumn{2}{c|}{\multirow{3}{*}{Plea judgments$^{\rm r}$}} & - \\ \cline{1-1} \cline{4-5} \cline{10-10} BStricks\_LDC~\cite{strickson2020legal} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\multirow{2}{*}{Facts$^{\rm r}$}} & \multirow{2}{*}{Others$^{\rm r}$} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \href{https://github.com/BStricks/legal_document_classifier_V2}{Link} \\ \cline{1-1} \cline{6-7} \cline{10-10} ILDC~\cite{malik2021ildc} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & & \multicolumn{2}{c|}{\multirow{2}{*}{Fact snippets$^{\rm r}$}} & \multicolumn{2}{c|}{} & \href{https://github.com/Exploration-Lab/ CJPE}{Link} \\ \cline{1-1} \cline{3-5} \cline{8-10} ACI~\cite{paul-etal-2020-automatic} & & \multicolumn{3}{c|}{Facts$^{\rm a,r}$} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{Charges$^{\rm a}$} & \href{https://github.com/Law-AI/automatic-charge-identification}{Link} \\ \cline{1-1} \cline{3-10} echr~\cite{RN220} & & \multicolumn{3}{c|}{\multirow{4}{*}{Facts$^{\rm r}$}} & \multicolumn{2}{c|}{\multirow{4}{*}{Articles$^{\rm r}$}} & \multicolumn{2}{c|}{\multirow{4}{*}{-}} & \href{https://figshare.com/s/6f7d9e7c375ff0822564}{Link} \\ \cline{1-1} \cline{10-10} ECHR-CASES~\cite{2019Neural} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \href{https://archive.org/details/ECHR-ACL2019}{Link} \\ \cline{1-1} \cline{10-10} ECtHR\_crystal\_ball~\cite{2018Medvedeva} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \href{https://github.com/masha-medvedeva/ECtHR\_crystal\_ball}{Link} \\ \cline{1-2} \cline{10-10} DPAM~\cite{RN224} & \multirow{21}{*}{Chinese} & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \href{https://drive.google.com/open?id=1TCcTzte2cQ2wxWw-kXsZdUApCsNejdn8}{Link} \\ \cline{1-1} \cline{3-10} MLMN~\cite{2021Learning} & & \multicolumn{3}{c|}{Facts$^{\rm a}$} & \multicolumn{2}{c|}{Articles$^{\rm a}$} & \multicolumn{2}{c|}{Prison terms$^{\rm r}$} & \href{https://github.com/gjdnju/MLMN}{Link} \\ \cline{1-1} \cline{3-10} CAIL2018~\cite{xiao2018cail2018} & & \multicolumn{3}{c|}{\multirow{9}{*}{Facts$^{\rm r}$}} & \multicolumn{2}{c|}{\multirow{6}{*}{Articles$^{\rm r}$}} & \multicolumn{1}{c|}{\multirow{5}{*}{Charges$^{\rm r}$}} & \multirow{5}{*}{Prison terms$^{\rm r}$} & \href{http://cail.cipsc.org.cn/index.html}{Link} \\ \cline{1-1} \cline{10-10} TOPJUDGE-CJO~\cite{2018Legal} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & & \multirow{3}{*}{-} \\ \cline{1-1} TOPJUDGE-PKU~\cite{2018Legal} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & & \\ \cline{1-1} TOPJUDGE-CAIL~\cite{2018Legal} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & & \\ \cline{1-1} \cline{10-10} CAIL-Long~\cite{xiao2021lawformer} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & & \href{https://github.com/thunlp/LegalPLMs}{Link} \\ \cline{1-1} \cline{8-10} FLA~\cite{2017Learning} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{\multirow{3}{*}{Charges$^{\rm r}$}} & \multirow{3}{*}{-} \\ \cline{1-1} \cline{6-7} RACP~\cite{2018Interpretable} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{Fact snippets$^{\rm a}$} & \multicolumn{2}{c|}{} & \\ \cline{1-1} \cline{6-7} MAMD~\cite{RN200} & & \multicolumn{3}{c|}{} & \multicolumn{2}{c|}{-} & \multicolumn{2}{c|}{} & \\ \cline{1-1} \cline{6-10} Court-View-Gen~\cite{Hai2018Interpretable} & & \multicolumn{3}{c|}{} & \multicolumn{4}{c|}{\multirow{2}{*}{Court View$^{\rm r}$}} & \href{https://github.com/oceanypt/Court-View-Gen}{Link} \\ \cline{1-1} \cline{3-5} \cline{10-10} AC-NLG~\cite{wu-etal-2020-de} & & \multicolumn{1}{c|}{\multirow{8}{*}{Facts$^{\rm r}$}} & \multicolumn{2}{c|}{Pleas$^{\rm r}$} & \multicolumn{4}{c|}{} & \href{https://github.com/wuyiquan/AC-NLG}{Link} \\ \cline{1-1} \cline{4-10} CPTP~\cite{2019Charge} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{Charges$^{\rm r}$} & \multicolumn{2}{c|}{-} & \multicolumn{2}{c|}{Prison terms$^{\rm r}$} & \href{https://github.com/huajiechen/CPTP}{Link} \\ \cline{1-1} \cline{4-10} Criminal-S~\cite{2018few-shot} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{\multirow{3}{*}{Charge attributes$^{\rm a}$}} & \multicolumn{2}{c|}{\multirow{3}{*}{Attributes prediction$^{\rm r}$}} & \multicolumn{2}{c|}{\multirow{6}{*}{Charges$^{\rm r}$}} & \href{https://github.com/thunlp/attribute\_charge}{Link} \\ \cline{1-1} \cline{10-10} Criminal-M~\cite{2018few-shot} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \href{https://github.com/thunlp/attribute\_charge}{Link} \\ \cline{1-1} \cline{10-10} Criminal-L~\cite{2018few-shot} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{} & \href{https://github.com/thunlp/attribute\_charge}{Link} \\ \cline{1-1} \cline{4-7} \cline{10-10} QAjudge-CJO~\cite{2020Iteratively} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{\multirow{3}{*}{Elements questions$^{\rm a}$}} & \multicolumn{1}{c|}{\multirow{3}{*}{Articles$^{\rm r}$}} & \multicolumn{1}{c|}{\multirow{3}{*}{Elements answers$^{\rm r}$}} & \multicolumn{2}{c|}{} & \multirow{4}{*}{-} \\ \cline{1-1} QAjudge-PKU~\cite{2020Iteratively} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \\ \cline{1-1} QAjudge-CAIL~\cite{2020Iteratively} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{} & \\ \cline{1-1} \cline{3-9} Auto-Judge~\cite{2018Automatic} & & \multicolumn{1}{c|}{\multirow{2}{*}{Pleas$^{\rm r}$}} & \multicolumn{1}{c|}{Facts$^{\rm r}$} & Articles$^{\rm r}$ & \multicolumn{2}{c|}{\multirow{2}{*}{-}} & \multicolumn{2}{c|}{Plea judgments$^{\rm r}$} & \\ \cline{1-1} \cline{4-5} \cline{8-10} LJP-MSJudge~\cite{RN202} & & \multicolumn{1}{c|}{} & \multicolumn{2}{c|}{Debate data$^{\rm r}$} & \multicolumn{2}{c|}{} & \multicolumn{2}{c|}{Plea judgments$^{\rm a}$} & \href{https://github.com/mly-nlp/LJP-MSJudge}{Link} \\ \hline \end{tabular} \begin{tablenotes} \footnotesize \item[$^{\rm r}$]Extracted by machine. \end{tablenotes} \begin{tablenotes} \footnotesize \item[$^{\rm a}$]Annotated by legal experts. \end{tablenotes} \end{table} \begin{figure} \centering \includegraphics[width=6.2in]{distribution.pdf} \caption{The dataset density distribution for specific LJP task. }\label{fig:distribution} \end{figure} And then, under the proposed outcome-based taxonomy, existing LJP main tasks are briefly concluded as follows: \textbf{Article Recommendation Task}. As seen in Table \ref{table00} and Fig.~\ref{fig:distribution}, the hottest LJP tasks are article recommendation and charge prediction. Furthermore, these articles recommend tasks are classified into three main parts: many-vs-one, many-vs-many, one-vs-many according to the corresponding relationship between facts and their relevant articles as follows: \begin{itemize} \item Many-vs-one. Two cases are conducted: (1) Binary Violation. echr~\cite{RN220}, ECHR-CASES~\cite{2019Neural}, and ECtHR\_crystal\_ball~\cite{2018Medvedeva} are built to determine whether any particular law article was violated or not for given case facts. (2)Multi-label Violation. ECHR-CASES~\cite{2019Neural}, and CAIL2018 are used to predict which specific article has been violated or directly applicable to the given case. \item Many-vs-many. DPAM~\cite{RN224}, FLA~\cite{2017Learning}, CAIL-Long found optimal article set for each case. \item One-vs-many. MLMN~\cite{2021Learning} extracted all the relevant law articles for each fact in a law case. \end{itemize} \textbf{Charge Prediction Task}. As seen in Table \ref{table00}, there are also already many charge prediction tasks and their available datasets~\cite{2018Legal,2020Iteratively,2018few-shot,qiu2020easyaug} in the juridical field. Furthermore, three cases are summarized: \begin{itemize} \item Case-charge correspondence. Two cases are conducted: (1) One-vs-one. To decrease the complexity of judgment prediction, TOPJUDGE-CJO~\cite{2018Legal}, TOPJUDGE-PKU~\cite{2018Legal}, TOPJUDGE-CAIL~\cite{2018Legal}, Criminal-S~\cite{2018few-shot}, Criminal-M~\cite{2018few-shot}, and Criminal-L~\cite{2018few-shot} removed the cases with multiple defendants and multiple charges. (2) One-vs-many. 3.56\%~of cases with more than on charges contained in FLA~\cite{2017Learning} only consider the cases with one defendant, while 2.97\%~of defendants charged differently are included in MAMD~\cite{RN200}. \item Common-vs-Few shot. To examine the performance of methods on few-shot charges, all of the Criminal-S~\cite{2018few-shot}, Criminal-M~\cite{2018few-shot}, and Criminal-L~\cite{2018few-shot} keep 149 separate charges with frequencies greater than 10. While FLA~\cite{2017Learning} chooses to consider 50 different charges with frequencies greater than 80, the frequencies of charges greater than 100 are considered in TOPJUDGE-CJO~\cite{2018Legal}, TOPJUDGE-PKU~\cite{2018Legal}, and TOPJUDGE-CAIL~\cite{2018Legal}. \item Logical knowledge. Three cases are conducted: (1) Dependencies among LJP tasks. TOPJUDGE-CJO~\cite{2018Legal}, TOPJUDGE-PKU~\cite{2018Legal}, and TOPJUDGE-CAIL~\cite{2018Legal} are three datasets to verify the efficiency of the model based on the topological dependencies among law articles, charges, and prison term prediction. Similarly, the influence of the prediction of law articles on charge prediction is validated in~\cite{2017Learning}. (2) Domain knowledge. The pre-defined attributes of the disciminative charges~\cite{2018few-shot} have been utilized in the charge prediction. Coincidentally, the answering of predefined element questions to assist the interpretable charge prediction has been visualized~\cite{2020Iteratively}. (3) Fact-side representation. The charge prediction~\cite{2018Interpretable} is interpreted based on the extraction of Phrase-level facts. Furthermore, the relationship between the sentence-level fact and its corresponding charges has been modeled to the document-level charge prediction~\cite{paul-etal-2020-automatic}. \end{itemize} \textbf{Prison Term Prediction Task}. Given the present numbers of datasets, as shown in Fig.~\ref{fig:distribution}, the inadequacy of Prison term prediction datasets should be modified. CPTP~\cite{2019Charge}, TOPJUDGE-CJO~\cite{2018Legal}, TOPJUDGE-PKU~\cite{2018Legal} and TOPJUDGE-CAIL~\cite{2018Legal} are datasets built to predict the prison terms according to the relevant charges. \textbf{Court View generation Task}. Besides the law articles, the Court View is another explanation written by judges to interpret the judgment of a case in a country with the civil law system. Due to the difficulty of Court View generation task arising from complex logical reasoning about facts and relevant law articles, there are not too many papers on this topic, as shown in Fig. \ref{fig:distribution}. Two cases are concluded: (1) Dependencies of charge-label and Court View. Court-View-Gen~\cite{Hai2018Interpretable} has utilized charge-label to generate the charge-discriminative Court View for criminal cases. (2) Fact-side representation. AC-NLG~\cite{wu-etal-2020-de} has developed to generate Court Views for civil cases based on a pleas-aware side facts representation. \textbf{Plea Judgment Task}. Plea judgment task for court cases generally uses the fact description to predict its judgments on plaintiffs' pleas. Three cases are concluded: (1) Judge-summarized facts narrative. For example, Auto-Judge~\cite{2018Automatic} and ILDC~\cite{2021JUSTICE2021} have been present to the judges' final pro or con decision based on a text summary of the absolute neutral facts of each case. (2) Facts from court debate. LJP-MSJudge~\cite{RN202} predicts the verdicts of the plaintiffs' pleas based on the facts from real court debate. (3) Case material except for the plea judgments. To predict interpretable plea judgments based on case material masked with the plea judgments has been present in~\cite{malik2021ildc,strickson2020legal,sulea2017predicting}. \section{Datasets}\label{Datasets} \begin{table*} \centering \caption{The statistics of the existing LJP tasks. Here FSCS: Federal Supreme Court of Switzerland, FSC: French Supreme Court, UKC: UK’s highest court, SCOTUS: Supreme Court of the United States, SCI: Supreme Court of Indian, TSC: Thai Supreme Court, ECHR: European Court of Human Rights, SPC: Supreme People’s Court of China.} \label{table2} \setlength{\tabcolsep}{4pt} \begin{tabular}{|c|c|cc|c|c|c|c|} \hline \multirow{2}{*}{Dataset} & \multirow{2}{*}{Source} & \multicolumn{2}{c|}{Category} & \multirow{2}{*}{\#Cases} & \multirow{2}{*}{\#Articles} & \multirow{2}{*}{\#Charges} & \multirow{2}{*}{\#Prison terms} \\ \cline{3-4} & & \multicolumn{1}{c|}{Law Domain} & Legal System & & & & \\ \hline BStricks\_LDC~\cite{strickson2020legal} & UKC & \multicolumn{1}{c|}{\multirow{3}{*}{Generic}} & \multirow{4}{*}{Common-Law} & 4,959 & \multirow{4}{*}{-} & \multirow{3}{*}{-} & \multirow{6}{*}{-} \\ \cline{1-2} \cline{5-5} JUSTICE~\cite{2021JUSTICE2021} & \begin{tabular}[c]{@{}c@{}}SCUS\\ (Oyez)\end{tabular} & \multicolumn{1}{c|}{} & & 2,384 & & & \\ \cline{1-2} \cline{5-5} ILDC~\cite{malik2021ildc} & \multirow{2}{*}{SCI} & \multicolumn{1}{c|}{} & & 34,816 & & & \\ \cline{1-1} \cline{3-3} \cline{5-5} \cline{7-7} ACI~\cite{paul-etal-2020-automatic} & & \multicolumn{1}{c|}{\multirow{2}{*}{Criminal}} & & 4,338 & & 20 & \\ \cline{1-2} \cline{4-7} TSCC~\cite{kowsrihawat2018predicting} & TSC & \multicolumn{1}{c|}{} & \multirow{29}{*}{Civil-Law} & 1,207 & 122 & \multirow{3}{*}{-} & \\ \cline{1-3} \cline{5-6} DPAM~\cite{RN224} & \multirow{23}{*}{SPC} & \multicolumn{1}{c|}{\multirow{18}{*}{Criminal}} & & 17,160 & 70 & & \\ \cline{1-1} \cline{5-6} \cline{8-8} MLMN~\cite{2021Learning} & & \multicolumn{1}{c|}{} & & 1,189 & 86 & & 5 \\ \cline{1-1} \cline{5-8} CAIL2018~\cite{xiao2018cail2018} & & \multicolumn{1}{c|}{} & & 2,676,075 & 183 & 202 & 202 \\ \cline{1-1} \cline{5-8} TOPJUDGE-CJO~\cite{2018Legal} & & \multicolumn{1}{c|}{} & & 1,007,744 & 98 & 99 & 11 \\ \cline{1-1} \cline{5-8} TOPJUDGE-PKU~\cite{2018Legal} & & \multicolumn{1}{c|}{} & & 175,744 & 68 & 64 & 11 \\ \cline{1-1} \cline{5-8} TOPJUDGE-CAIL~\cite{2018Legal} & & \multicolumn{1}{c|}{} & & 113,536 & 105 & 122 & 11 \\ \cline{1-1} \cline{5-8} FLA~\cite{2017Learning} & & \multicolumn{1}{c|}{} & & 60,000 & 321 & 50 & \multirow{3}{*}{-} \\ \cline{1-1} \cline{5-7} RACP~\cite{2018Interpretable} & & \multicolumn{1}{c|}{} & & 100,000 & \multirow{7}{*}{-} & 51 & \\ \cline{1-1} \cline{5-5} \cline{7-7} MAMD~\cite{RN200} & & \multicolumn{1}{c|}{} & & 164,997 & & - & \\ \cline{1-1} \cline{5-5} \cline{7-8} CPTP~\cite{2019Charge} & & \multicolumn{1}{c|}{} & & 238,749 & & 157 & 226 \\ \cline{1-1} \cline{5-5} \cline{7-8} Court-View-Gen~\cite{Hai2018Interpretable} & & \multicolumn{1}{c|}{} & & 171,981 & & 51 & \multirow{7}{*}{-} \\ \cline{1-1} \cline{5-5} \cline{7-7} Criminal-S~\cite{2018few-shot} & & \multicolumn{1}{c|}{} & & 77,046 & & 149 & \\ \cline{1-1} \cline{5-5} \cline{7-7} Criminal-M~\cite{2018few-shot} & & \multicolumn{1}{c|}{} & & 191,960 & & 149 & \\ \cline{1-1} \cline{5-5} \cline{7-7} Criminal-L~\cite{2018few-shot} & & \multicolumn{1}{c|}{} & & 383,697 & & 149 & \\ \cline{1-1} \cline{5-7} QAjudge-CJO~\cite{2020Iteratively} & & \multicolumn{1}{c|}{} & & 15,120 & 19 & 20 & \\ \cline{1-1} \cline{5-7} QAjudge-PKU~\cite{2020Iteratively} & & \multicolumn{1}{c|}{} & & 14,000 & 19 & 20 & \\ \cline{1-1} \cline{5-7} QAjudge-CAIL~\cite{2020Iteratively} & & \multicolumn{1}{c|}{} & & 13,423 & 19 & 20 & \\ \cline{1-1} \cline{5-8} \multirow{2}{*}{CAIL-Long~\cite{xiao2021lawformer}} & & \multicolumn{1}{c|}{} & & 115,849 & 244 & 201 & 240 \\ \cline{3-3} \cline{5-8} & & \multicolumn{1}{c|}{\multirow{5}{*}{Civil}} & & 113,656 & 330 & 257 & \multirow{10}{*}{-} \\ \cline{1-1} \cline{5-7} DPAM~\cite{RN224} & & \multicolumn{1}{c|}{} & & 4,033 & 30 & \multirow{9}{*}{-} & \\ \cline{1-1} \cline{5-6} LJP-MSJudge~\cite{RN202} & & \multicolumn{1}{c|}{} & & 70,482 & \multirow{2}{*}{-} & & \\ \cline{1-1} \cline{5-5} AC-NLG~\cite{wu-etal-2020-de} & & \multicolumn{1}{c|}{} & & 66,904 & & & \\ \cline{1-1} \cline{5-6} Auto-Judge~\cite{2018Automatic} & & \multicolumn{1}{c|}{} & & 100,000 & 62 & & \\ \cline{1-3} \cline{5-6} echr~\cite{RN220} & \multirow{3}{*}{ECtHR} & \multicolumn{1}{c|}{\multirow{3}{*}{Human rights}} & & 584 & 3 & & \\ \cline{1-1} \cline{5-6} ECHR-CASES~\cite{2019Neural} & & \multicolumn{1}{c|}{} & & 11,478 & 66 & & \\ \cline{1-1} \cline{5-6} ECtHR\_crystal\_ball~\cite{2018Medvedeva} & & \multicolumn{1}{c|}{} & & 11,532 & 14 & & \\ \cline{1-3} \cline{5-6} SwissJudgmentPrediction~\cite{niklaus2021swiss} & FSCS & \multicolumn{1}{c|}{\multirow{2}{*}{Generic}} & & 85,268 & \multirow{2}{*}{-} & & \\ \cline{1-2} \cline{5-5} Sulea et al.~\cite{sulea2017predicting} & FSC & \multicolumn{1}{c|}{} & & 126,865 & & & \\ \hline \end{tabular} \end{table*} A significant challenge for LJP is the availability and potentiality of the datasets. In constructing datasets, there have been at least two lines of work, as seen in Table \ref{table00}. The first one employs a machine to extract the necessary metadata, such as using Regular Expression to identify and mask judgment results (~\cite{niklaus2021swiss,sulea2017predicting,strickson2020legal,malik2021ildc}) or to extract the input-output data samples(~\cite{RN220,2019Neural,2018Medvedeva,RN224,xiao2018cail2018,2018Legal,xiao2021lawformer,2017Learning,RN200,Hai2018Interpretable,2019Charge,2018Automatic}) from judgment documents of given court and applying the deep neural model to extract facts from Court judgment documents as~\cite{paul-etal-2020-automatic} for evaluating the LJP model. The second line of work recruits legal experts to annotate rationale sentences~\cite{malik2021ildc,2018Interpretable} as gold sentences or to annotate legal domain knowledge (which are not included in the judgment documents, such as ~\cite{2021Learning,2018few-shot,2020Iteratively}). Specially, we categorize public LJP datasets into two categories: task-specific datasets and multi-task datasets. Multi-task datasets are composed of multiple subtasks of LJP, while single-task datasets consist of a single subtask of LJP. \subsection{Single-Task Datasets} The following list outlines the different types of task-specific datasets released publicly. They are categorized based on their task's outcomes. \subsubsection{Article Prediction Datasets} HUDOC European Court of Human Rights (ECHR)\footnote{https://hudoc.echr.coe.int/} and China Judgments Online (CJO)\footnote{https://wenshu.court.gov.cn/} are two publicly available case databases, which include judgment, verdict, conciliation statement, decision letter, notice, et., published by the ECHR and the Supreme People’s Court of China, respectively. There are several datasets for articles related to tasks scraped from publicly available resources to unveil patterns driving judicial decisions, but they tend to be less related to the civil and administrative cases (see Table \ref{table2}). Dataset echr~\cite{RN220} is the first public English legal judgment prediction dataset, containing a total of 584 cases from the ECHR and articles 3, 6, and 8 from the European Convention of Human Rights, to judge whether the covering case has violated an article of the convention of human rights. Similarly, Thai Supreme Court Cases (TSCC) ~\cite{kowsrihawat2018predicting}, containing 1,207 criminal judgment records and 122 Law records from the Supreme Court of Thailand, is constructed to predict which specific Law records have been violated based on sequence models. Then, a substantially more extensive data set, ECHR-CASES~\cite{2019Neural}, has been constructed based on 11,478 cases tried by the ECHR and 66 articles from the European Convention of Human Rights, not only to judge whether there has been a violation of an article of the convention of human rights but also to determine the name of the violated articles. To verify the improvement on articles recommendation accuracy through establishing the fine-grained fact-article correspondences, a fact-article correspondence dataset, MLMN~\cite{2021Learning}, has been created based on 1,189 Crime judgment documents in CJO and 86 criminal law articles for fact-article correspondence annotation. \subsubsection{Charge Prediction Datasets} Case Information Disclosure (CID)\footnote{http://www.ajxxgk.jcy.gov.cn/html/index.html}, CJO are two publicly available case databases published by the Supreme People’s prosecution of China and the Supreme People’s Court of China, respectively. There have been several datasets for charge prediction tasks scraped from publicly available resources, but they tend to focus on Chinese mainly and have less considered in English (see Table~\ref{table2}). From CJO, FLA~\cite{2017Learning} collects 60,000 cases in total, 50 charges, 383 words per fact description averagely, 3.81 articles per case, and 3.56\% cases with more than one charge, 321 distinct articles, retains the cases with one defendant and treats the charges that appeared more than 80 times as positive data, vice versa as negative ones, to improve the charge prediction followed the prediction of the relevant law articles. CAIL2018~\cite{2018CAIL2018} is the first large-scale Chinese legal dataset to predict relevant law articles, charges, and prison terms, respectively. It includes 2,676,075 criminal cases published by the Supreme People’s Court of China, 183 criminal law articles, 202 charges, and prison terms. And this dataset only retains the cases with a single defendant and treats those charges and law articles whose frequency is larger than 30 as positive data. MAMD~\cite{RN200} used to predict multi-defendant charges has been built from the published legal documents in Case Information Disclosure (CIS), containing a total of 164,997 cases in which fact description, defendants’ names, and charges contained. Cases involving multiple defendants account for about 30$\%$, and in cases involving multiple defendants, the ratio of that all defendants are charged the same is about 90$\%$. RACP~\cite{2018Interpretable}, has been constructed from CJO, containing 100,000 documents in which rationale sentences were annotated based on the extracted fact description and charge labels. Similarly, ACI~\cite{paul-etal-2020-automatic} collected from the Supreme Court of India cases consists of 4,338 judgment documents with document-level charge label information facts were extracted by legal experts and automated method for 70 and 4,268 documents, and legal experts annotate sentence-level charges for 120 documents. Moreover, three datasets~\cite{2018few-shot} have been published with selected case’s fact part and extracted charges of judgment documents from CJO denoted as Criminal-S(small), Criminal-M(medium), Criminal-L(large). They removed the cases which have more than one charge in a verdict. \subsubsection{Prison Term Prediction Datasets} CJO is the publicly available case database published by the Supreme People’s Court of China, including judgment, verdict, conciliation statement, decision letter, notice, and so on. Several datasets on prison term prediction scraped from publicly available resources, mainly focusing on Chinese and rarely English (see Table \ref{table2}). \begin{table*} \centering \caption{The statistics of the pre-training datasets.} \label{table7} \setlength{\tabcolsep}{7pt} \resizebox{\textwidth}{1.8in}{ \begin{tabular}{|c|c|c|c|c|c|c|} \hline Dataset & Language & Model & Source & \#Documents & \#Size(MB) & Corpus \\ \hline \multirow{6}{*}{Chalkidis et al.~\cite{2020LEGAL}} & \multirow{19}{*}{English} & \multirow{6}{*}{\href{https: //huggingface.co/nlpaueb}{LEGAL-BERT~\cite{2020LEGAL}}} & EU legislation & 61,826 & 1,900 & \multirow{6}{*}{-} \\ \cline{4-6} & & & European Court of Justice (ECJ) cases & 19,867 & 600 & \\ \cline{4-6} & & & UK legislation & 19,867 & 1,400 & \\ \cline{4-6} & & & ECHR cases & 12,554 & 500 & \\ \cline{4-6} & & & US court cases & 164,141 & 3,200 & \\ \cline{4-6} & & & US contracts & 76,366 & 3,900 & \\ \cline{1-1} \cline{3-7} \multirow{7}{*}{LexGLUE~\cite{chalkidis2021lexglue}} & & \multirow{7}{*}{\begin{tabular}[c]{@{}c@{}}\href{https://github.com/ google-research/bert}{BERT}~\cite{devlin-etal-2019-bert}\\ \href{https://github.com/pytorch/fairseq}{RoBERTa}~\cite{liu2019roberta}\\ \href{https://github.com/microsoft/DeBERTa}{DeBERTa}~\cite{he2020deberta}\\ \href{https://github.com/allenai/longformer}{Longformer}~\cite{beltagy2020longformer}\\ \href{http://goo.gle/bigbird-transformer}{BigBird}~\cite{zaheer2020big}\\ \href{https: //huggingface.co/nlpaueb}{LEGAL-BERT~\cite{2020LEGAL}}\\ \href{https://github.com/reglab/ casehold}{CaseLaw-BERT}~\cite{zhengguha2021}\end{tabular}} & ECHR~\cite{2019Neural} & 1,1000 & 116 & \multirow{7}{*}{\href{https://huggingface.co/datasets/lex_glue}{Link}} \\ \cline{4-6} & & & ECHR~\cite{chalkidis2021paragraph} & 1,1000 & 116 & \\ \cline{4-6} & & & US Law~\cite{spaeth2020supreme} & 7,800 & 328 & \\ \cline{4-6} & & & EU Law~\cite{chalkidis2021multieurlex} & 65,000 & 492 & \\ \cline{4-6} & & & Contracts~\cite{tuggener2020ledgar} & 80,000 & 62 & \\ \cline{4-6} & & & Contracts~\cite{lippi2019claudette} & 9,414 & 3 & \\ \cline{4-6} & & & Harvard Law case~\cite{zhengguha2021} & 52,800 & 86 & \\ \cline{1-1} \cline{3-7} CaseHOLD~\cite{zhengguha2021} & & \href{https://github.com/reglab/ casehold}{CaseLaw-BERT}~\cite{zhengguha2021} & Harvard Law case~\cite{zhengguha2021} & 3,446,187 & 37,000 & \href{https://github.com/reglab/ casehold}{Link} \\ \cline{1-1} \cline{3-7} \multirow{5}{*}{CourtListener~\cite{bambroo2021legaldb}} & & \multirow{5}{*}{LegalDB~\cite{bambroo2021legaldb}} & US Board Of Tax Appeal & 11,059 & \multirow{5}{*}{8,000} & \multirow{5}{*}{\href{https://www.courtlistener.com/api/bulk-info/}{Link}} \\ \cline{4-5} & & & US Court Of Federal Claims & 13,410 & & \\ \cline{4-5} & & & Court Of Customs And Patents Appeal & 2,388 & & \\ \cline{4-5} & & & Supreme Court Of The United States & 31,470 & & \\ \cline{4-5} & & & \begin{tabular}[c]{@{}c@{}}Court Of Appeals (First–Eleventh Circuit)\end{tabular} & 269,622 & & \\ \hline \multirow{2}{*}{Xiao et al.~\cite{xiao2021lawformer}} & \multirow{2}{*}{Chinese} & \multirow{2}{*}{\href{https://github. com/thunlp/LegalPLMs}{Lawformer}} & SPC Criminal cases & 5,428,717 & 17,000 & \multirow{2}{*}{-} \\ \cline{4-6} & & & SPC Civil cases & 17,387,874 & 67,000 & \\ \hline \multirow{2}{*}{Douka et al.~\cite{2021Douka}} & \multirow{2}{*}{French} & \multirow{2}{*}{\href{http://master2-bigdata.polytechnique.fr/resources\#juribert}{JuriBERT}} & French Court cases & \multirow{2}{*}{123,361} & \multirow{2}{*}{6,300} & \multirow{2}{*}{-} \\ \cline{4-4} & & & Legifrance & & & \\ \hline \end{tabular}} \end{table*} To verify the influence of the charge-based prison term prediction (CPTP) on the prediction accuracy of the full prison term for each defendant, CPTP~\cite{2019Charge} has been constructed with 238,749 criminal cases [1,240] (in months) prison terms, and 157 types of charges. The fact-article correspondence dataset, MLMN, constructed in~\cite{2021Learning} can also boost the downstream task of legal decision prediction, where all judgment results are divided into five classes: exempt from criminal punishment, criminal detention, fixed-term imprisonment of not more than one year, 1 - 3 years and not less than three years. \subsubsection{Plea Judgment prediction Datasets} CJO, entscheidsuche.ch, IndianKanoon, Court de Cassation, and Oyez are the publicly available source case databases published by the Supreme People’s Court of China (SPC), the Federal Supreme Court of Switzerland (FSCS), the Supreme Court of India (SCI), the French Supreme Court and the Supreme Court of the United States (SCOTUS), respectively. Several datasets for pleas-related tasks are scraped from publicly available resources, but these large-scale datasets mainly focus on SPC and FSC cases (see Table \ref{table2}). For example, to predict the final judgment results based on the semantic interactions among facts, pleas, and laws, Auto-Judge~\cite{2018Automatic} consists of 100,000 divorce cases, 185,723 pleas and verdicts, and 62 law articles. To employ the input of the case from real courtrooms rather than the judge-summarized case narrative for the judgment prediction, LJP-MSJudge~\cite{RN202}, has been released with 70,482 Private Lending cases collected from CJO, 133,209 claims and verdicts, 4.1 million debates, and ten fact labels. Furthermore, Sulea et al.~\cite{sulea2017predicting} proposed a dataset comprising 126,865 unique court rulings firstly used to predict court rulings in the French Supreme Court cases. Indian Legal Documents Corpus (ILDC~\cite{malik2021ildc}) with 35k cases is introduced for court judgment prediction and explanation. Moreover, a labeled data set of 4,959 UK court cases~\cite{strickson2020legal} is also created for legal judgment prediction. A total of 2,384 SCOTUS cases from Oyez based on a series of manually balance procedures are also evaluated to predict the judicial judgment. In addition, SwissJudgmentPrediction~\cite{niklaus2021swiss} is a diachronic multilingual dataset of 85K cases from the Federal Supreme Court of Switzerland (FSCS), where 50k cases in German, 31k in French, and 4K in Italian. \subsubsection{Court view Generation Datasets} CJO is the publicly available case database published by the Supreme People’s Court of China, including judgment, verdict, conciliation statement, decision letter, notice, and so on. Several datasets for the generation tasks of rationales in the court view scraped from publicly available resources, but they tend to mainly focus on Chinese rather than English (see Table \ref{table00}). Court-View-Gen~\cite{Hai2018Interpretable} has been constructed from the published legal documents in CJO, from which they collected 171,981 cases with one defendant and one charge, a total of 51 charge labels, to explore the generation of court views based on charge labels. \subsection{Multi-Task Datasets} Multi-task datasets ( see Table \ref{table00} ) are the datasets that contain detailed and rich subtasks of judgment predictions to help the researchers make improvements on legal judgment prediction. For example, datasets QAjudge-CJO, QAjudge-PKU, and QAjudge-CAIL~\cite{2020Iteratively} have been gathered from China Judgments Online, Peking University Law Online, and Chinese AI and Law Challenge, respectively. These datasets consist of fact descriptions, applicable law articles, charges, and the term of penalty for each case. These three datasets filtered out cases with multiple defendants, multiple charges, infrequent charges, and articles less than 100 times. Furthermore, the large-scale publicly accessible high-quality Chinese legal judgment prediction dataset, CAIL2018~\cite{2018CAIL2018} has been released with 2,676,075 criminal cases, 183 criminal law articles, 202 charges, and prison terms. This dataset only retained the cases with a single defendant, those charges, and law articles whose frequency is larger than 30. Recently, a much larger scale dataset, CAIL-Long ~\cite{xiao2021lawformer}, was constructed to predict the judgment results. This dataset consists of 1,129,053 criminal cases and 1,099,605 civil cases. Specifically, each criminal case is annotated with the charges, the relevant laws, and the penalty term. Each civil case is annotated with the causes of actions and the relevant laws. In addition, from the perspective of court view generation, the joint generation of the judgment and the rationales as court view can improve the interpretability for the judgment of a case, where the judgment is a response to the plaintiff's claims. For example, AC-NLG~\cite{2020De} built 66,904 cases based on civil legal judgment documents from CJO, in which each case was categorized into plaintiff’s claim, facts description, and court’s view was further annotated the judgments and rationales. \subsection{Datasets for Pre-trained Language Model} As is well known, there have been many open access repositories to construct unlabelled pretraining corpora, as shown in Table~\ref{table7}. For example, CJO and HUDOC ECHR are publicly available case databases published by the Supreme People’s Court of China and ECHR. Furthermore, CourtListener\footnote{https://www.courtlistener.com/api/bulk-info/} and Légifrance websites consist of US court cases and raw French legal text. In addition, access to the Case Law Access Project is granted upon request. Inspired by the success of pre-trained language models (PLMs) in the generic domain, there have been several datasets scraped from publicly available legal resources to investigate the adaptation of PLMs to legal tasks as follows. For example, 12GB pre-trained unlabelled corpora of diverse English legal text~\cite{2020LEGAL} from several fields (e.g., legislation, court cases, contracts) has been scraped from publicly available resources to pre-train the different variations of BERT in the legal area. Then, to push towards a generic benchmark dataset for multiple legal NLP tasks in English, the Legal General Language Understanding Evaluation (LexGLUE~\cite{chalkidis2021lexglue}) is selected using criteria primarily from SuperGLUE. Moreover, 8GB of long legal documents from the US are also used as a legal domain pre-trained corpora to validate the efficiency of the LegalDB model~\cite{bambroo2021legaldb}. A large-scale pretraining dataset, Case Holdings On Legal Decisions (CaseHOLD), size 37GB with 3,446,187 legal decisions from Harvard Law case corpus, is constructed to explore the influence of difficulty and domain specificity on domain pretraining gains. While PLMs have proven very useful when adapted to the legal domain, the main effort focuses on the English language. Therefore, to utilizing PLMs to address legal judgment prediction tasks based on capturing the long-distance dependency on Chinese legal case documents up to 512 tokens, 84GB pre-trained unlabelled corpora~\cite{xiao2021lawformer} of Chinese legal cases scraped from CJO, and a large scale judgment prediction dataset, CAIL-Long has also been constructed(see Table \ref{table00}). In addition, a collection of a size of 6.3 GB raw French legal text is collected to explore the performance of the adaptation of domain-specific BERT models in the French language. However, all these datasets for legal PLMs tend to focus only on a single language corpus and have less considered a multi-language corpus (see Table \ref{table7}). \section{Evaluation Metrics}\label{Evaluation Metrics} From Fig. \ref{Eva}, we can obtain at least four categories for evaluating the outputs from LJP tasks, (e.g. text classification metrics for evaluating law articles, charges, plea judgments and Element answers; text classification with text regression metrics for evaluating prison terms according to its value distribution; text classification with text generation metrics for evaluating Fact snippets based on its generation methods; text generation metrics for evaluating the generated Court View.) \subsection{Evaluation of Text Classification} \begin{figure} \centering \includegraphics[width=3.2in]{ljpev.pdf} \caption{Evaluation metrics for different outputs from LJP tasks. }\label{Eva} \end{figure} \begin{table*} \centering \caption{Evaluation metrics used in papers which construct datasets for evaluating the performance of the existing LJP models. Here, EM: exact match rate, Acc@p: error-tolerant accuracy, where p is the maximum acceptable error rate.} \label{paperlist} \setlength{\tabcolsep}{4pt} \begin{tabular}{|c|c|cccc|} \hline Dataset & Output & \multicolumn{4}{c|}{Evaluation metrics} \\ \hline ECtHR\_crystal\_ball~\cite{2018Medvedeva} & \multirow{2}{*}{Articles} & \multicolumn{4}{c|}{\multirow{3}{*}{Acc}} \\ \cline{1-1} echr~\cite{RN220} & & \multicolumn{4}{c|}{} \\ \cline{1-2} MAMD~\cite{RN200} & Charges & \multicolumn{4}{c|}{} \\ \hline \multirow{3}{*}{CAIL-Long~\cite{xiao2021lawformer}} & Prison terms & \multicolumn{4}{c|}{LD} \\ \cline{2-6} & Articles & \multicolumn{4}{c|}{\multirow{4}{*}{MaF/MiF}} \\ \cline{2-2} & Charges & \multicolumn{4}{c|}{} \\ \cline{1-2} SwissJudgmentPrediction~\cite{niklaus2021swiss} & Plea judgments & \multicolumn{4}{c|}{} \\ \cline{1-2} TSCC~\cite{kowsrihawat2018predicting} & Articles & \multicolumn{4}{c|}{} \\ \hline ACI~\cite{paul-etal-2020-automatic} & Charges & \multicolumn{2}{c|}{\multirow{3}{*}{MaF}} & \multicolumn{1}{c|}{\multirow{6}{*}{MaP}} & \multirow{6}{*}{MaR} \\ \cline{1-2} ECHR-CASES~\cite{2019Neural} & \multirow{3}{*}{Articles} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-1} MLMN~\cite{2021Learning} & & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-1} \cline{3-4} DPAM~\cite{RN224} & & \multicolumn{1}{c|}{JS} & \multicolumn{1}{c|}{MaF} & \multicolumn{1}{c|}{} & \\ \cline{1-4} \multirow{2}{*}{RACP~\cite{2018Interpretable}} & Charges & \multicolumn{2}{c|}{MaF} & \multicolumn{1}{c|}{} & \\ \cline{2-4} & Fact snippets & \multicolumn{1}{c|}{\multirow{15}{*}{Acc}} & \multicolumn{1}{c|}{MaF} & \multicolumn{1}{c|}{} & \\ \cline{1-2} \cline{4-6} QAjudge-CJO,QAjudge-PKU,QAjudge-CAIL~\cite{2020Iteratively} & Elements answers & \multicolumn{1}{c|}{} & \multicolumn{3}{c|}{MaF} \\ \cline{1-2} \cline{4-6} JUSTICE~\cite{2021JUSTICE2021} & \multirow{3}{*}{Plea judgments} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{\multirow{13}{*}{MaF}} & \multicolumn{1}{c|}{\multirow{13}{*}{MaP}} & \multirow{13}{*}{MaR} \\ \cline{1-1} Sulea et al.~\cite{sulea2017predicting} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-1} BStricks\_LDC~\cite{strickson2020legal} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-2} \multirow{3}{*}{CAIL2018~\cite{xiao2018cail2018}} & Articles & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{2-2} & Charges & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{2-2} & Prison terms & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-2} \multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}TOPJUDGE-CJO~\cite{2018Legal}\\TOPJUDGE-PKU~\cite{2018Legal}\\TOPJUDGE-CAIL~\cite{2018Legal}\\ \end{tabular}} & Articles & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{2-2} & Charges & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{2-2} & Prison terms & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-2} Criminal-S,Criminal-M,Criminal-L~\cite{2018few-shot} & Charges & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-2} \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}QAjudge-CJO, QAjudge-PKU,\\QAjudge-CAIL~\cite{2020Iteratively}\\ \end{tabular}} & Articles & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{2-2} & Charges & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \cline{1-2} Auto-Judge~\cite{2018Automatic} & Plea judgments & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \hline FLA~\cite{2017Learning} & Charges & \multicolumn{2}{c|}{\multirow{2}{*}{MaF/MiF}} & \multicolumn{1}{c|}{MaP/Mip} & MaR/MiR \\ \cline{1-2} \cline{5-6} LJP-MSJudge~\cite{RN202} & \multirow{2}{*}{Plea judgments} & \multicolumn{2}{c|}{} & \multicolumn{1}{c|}{\multirow{2}{*}{MaP}} & \multirow{2}{*}{MaR} \\ \cline{1-1} \cline{3-4} \multirow{2}{*}{ILDC~\cite{malik2021ildc}} & & \multicolumn{1}{c|}{Acc} & \multicolumn{1}{c|}{MaF} & \multicolumn{1}{c|}{} & \\ \cline{2-6} & Fact snippets & \multicolumn{1}{c|}{JS} & \multicolumn{1}{c|}{ROUGE} & \multicolumn{1}{c|}{BLEU} & Meteor \\ \hline Court-View-Gen~\cite{Hai2018Interpretable} & \multirow{2}{*}{Court View} & \multicolumn{2}{c|}{ROUGE} & \multicolumn{2}{c|}{\multirow{2}{*}{BLEU}} \\ \cline{1-1} \cline{3-4} AC-NLG~\cite{wu-etal-2020-de} & & \multicolumn{1}{c|}{BERT SCORE} & \multicolumn{1}{c|}{ROUGE} & \multicolumn{2}{c|}{} \\ \hline CPTP~\cite{2019Charge} & Prison terms & \multicolumn{1}{c|}{S} & \multicolumn{1}{c|}{EM} & \multicolumn{2}{c|}{Acc@p} \\ \hline \end{tabular} \end{table*} To be specific, for the prediction of articles, charges, prison terms, plea judgments, fact snippets and element answers, we can take them as text classification problems, such as in Fig. \ref{Eva}. For a specific text classification task, suppose there are $M$ categories and $N$ law cases. This text classification task aims to predict the category label for the text description of each law case. Let $y_{ij}\in\{0, 1\} (i\in\{1, 2, \cdots, M\}, j\in\{1, 2, \cdots, N\})$ denote as the ground truth label of the category result. Let $\hat{y}_{ij}\in\{0, 1\} (i\in\{1, 2, \cdots, M\}, j\in\{1, 2, \cdots, N\})$ denote as the predict label of the category result. Then, we can obtain the true positive, false positive, false negative, true negative, precision, recall and metrics for the $i$-th category as follows: \begin{eqnarray*} &\hspace{-0.4cm} TP_{i}=\sum_{j=1}^{N}{[y_{ij}=1,\hat{y}_{ij}=1]}, \notag \\ &\hspace{-0.4cm}FP_{i}=\sum_{j=1}^{N}{[y_{ij}=0,\hat{y}_{ij}}=1], \notag \\ &\hspace{-0.4cm}FN_{i}=\sum_{j=1}^{N}{[y_{ij}=1,\hat{y}_{ij}=0]}, \notag \\ &\hspace{-0.4cm}TN_{i}=\sum_{j=1}^{N}{[y_{ij}=0,\hat{y}_{ij}=0]} , \notag \\ &\hspace{-0.4cm} P_{i}= \frac{TP_{i}}{TP_{i}+FP_{i}}, \notag \\ &\hspace{-0.4cm} R_{i}= \frac{TP_{i}}{TP_{i}+FN_{i}} \end{eqnarray*} Then, as in Table \ref{paperlist}, we can obtain the following evaluation metrics to evaluate the performance of LJP text classification. \begin{itemize} \item \textbf{Macro precision/ Macro recall/ Macro F value}. To evaluate the performance in the macro-level through averaging over each category, macro precision $MaP$, macro recall $MaR$ and macro F value $MaF$ are follows: \begin{eqnarray} &\hspace{-0.4cm} MaP=\frac{1}{M}\sum_{i=1}^{M} P_{i} \notag \\ &\hspace{-0.4cm} MaR=\frac{1}{M}\sum_{i=1}^{M} R_{i} \notag\\ &\hspace{-0.4cm} MaF=\frac{1}{M}\sum_{i=1}^{M} \frac{2P_{i}\times R_{i}}{P_{i}+R_{i}} \end{eqnarray} \item \textbf{Micro precision/ Micro recall/ Micro F value/ Acc}. To evaluate the performance in the micro-level through averaging over each law case, micro precision $MiP$, micro recall $MiR$, micro F value $MiF$ and $Acc$ are follows: \begin{eqnarray*} &\hspace{-0.4cm} MiP=\frac{\sum_{i=1}^{M}TP_{i}}{\sum_{i=1}^{M}TP_{i}+FP_{i}} \notag \\ &\hspace{-0.4cm} MiR=\frac{\sum_{i=1}^{M}TP_{i}}{\sum_{i=1}^{M}TP_{i}+FN_{i}} \notag\\ &\hspace{-0.4cm} MiF= \frac{2P_{micro}\times R_{micro}}{P_{micro}+R_{micro}} \notag\\ &\hspace{-0.4cm} Acc=\frac{\sum_{i=1}^{M}TP_{i}+TN_{i}}{\sum_{i=1}^{M}TP_{i}+FP_{i}+TN_{i}+FN_{i}} \end{eqnarray*} \end{itemize} \subsection{Evaluation of Text Generation} For the generation of court view, we can take them as text generation problems, such as BLEU-1, BLEU-2, BLEU-N, ROUGE-1, ROUGE-2, ROUGE-L and BERT SCORE~\cite{shen2019select,shen2019improving,zhao2019unsupervised,zhao2018comprehensive,wu-etal-2020-de,su2020diversifying,su2020moviechats,chang2021neural}. The following evaluation metrics to evaluate the performance of LJP text generation are summarized, as shown in Fig. \ref{Eva}. \begin{itemize} \item \textbf{Jaccard similarity}. To evaluate the similarity between two sets, Jaccard similarity is defined as the size of the intersection divided by the size of the union of the two sets, which is follows: \begin{equation} JS =\frac{\mid \{Candidates\} \cap \{References\} \mid}{\mid \{Candidates\} \cup \{References\} \mid} \end{equation} where, $\{Candidates\}$ denotes the text set predicted, and $\{Candidates\}$ denotes the text set of the reference. \item \textbf{BLEU}. To evaluate the exact form closeness between the candidate sentence and its reference sentences, BLEU is averaged geometrically computed for mutiple modified $n$-gram up to length $N$ precision (e.g. $n=1,2,3,4, N=4$), which is follows: \begin{equation} BLEU =BP \cdot \exp\biggl( \sum_{n=1}^{N} w_{n}\log p_{n} \biggr) \end{equation} where $BP$, $p_{n}$, $w_{n}$ are an exponential brevity penalty factor, modified $n$-gram precision and a weighted coefficients of modified $n$-gram precision for the up to $N$-gram combining system, respectively. \begin{equation} BP =\left\{ \begin{array}{lcl} 1, & & {if \quad c > r,}\\ e^{(1-r/c)}, & & {if \quad c \leq r.} \end{array} \right. \end{equation} where $c$ denotes the length of the candidate sentence and $r$ denotes the length of the reference sentences. \item \textbf{ROUGE}. To evaluate $n$-gram co-occurrence statistics between the computer-generated text and the referenced text created by humans, a family of ROUGE metrics is defined as a recall-based measure, which is follows: \begin{eqnarray*} \begin{aligned} & ROUGE-N \notag \\ & =\frac{\sum\limits_{S \in \{References\}}\sum\limits_{{gram}_{n} \in S}{Count}_{match}({gram}_{n})}{\sum\limits_{S \in \{References\}}\sum\limits_{{gram}_{n} \in S}{Count}({gram}_{n})} \end{aligned} \end{eqnarray*} where the numerator of $ROUGE-N$ denotes the number of $n$-grams co-occurring between a candidate text and a set of reference texts, and the denominator of $ROUGE-N$ denotes the number of $n$-grams in the set of reference texts. \begin{eqnarray} &\hspace{-0.4cm} R_{lcs}= \frac{LCS(X,Y)}{m} \notag \\ &\hspace{-0.4cm} P_{lcs}= \frac{LCS(X,Y)}{n} \notag\\ &\hspace{-0.4cm} \beta=\frac{P_{lcs}}{R_{lcs}} \notag \\ &\hspace{-0.4cm} ROUGE-L=\frac{(1+\beta^2)P_{lcs}R_{lcs}}{R_{lcs}+\beta^2P_{lcs}} \end{eqnarray} where $LCS(X,Y)$ is the length of a longest common subsequence of sequence $X$ of length $m$ and sequence $Y$ of length $n$. \item \textbf{Meteor}. To give an explicit word-to-word matching between the candidate text and its reference texts, Meteor is allowing backing-off from the exact unigram matching to porter stem matching and synonyms, which is follows: \begin{equation} Meteor=F3\times (1-penalty) \end{equation} where $F3$ denotes a harmonic metric by combining the unigram precision ($P$, the ratio of number of unigrams mapped to the total unigrams in the candidate text) and the unigram recall ($R$, the ratio of number of unigrams mapped to the total unigrams in the reference text). And $penalty$ denotes a penal function increases as the number of mapped subsequence chunks while decreasing as the number of unigrams mapped. \begin{eqnarray*} &\hspace{-0.4cm} F3=\frac{10PR}{R+9P} \notag \\ &\hspace{-0.4cm} penalty=0.5\times { \Big ( \frac{\#chunks}{\#unigrams\_matched}\Big )}^{3} \end{eqnarray*} where, $\{Candidates\}$ denotes the text set predicted, and $\{Candidates\}$ denotes the text set of the reference. \item \textbf{BERT SCORE}.To evaluate the semantically similarity between the candidate sentence and its reference sentence, BERT SCORE is defined based on the contextual embedding for vector representations for the word depending on its surrounding words, which is follows: \begin{eqnarray} &\hspace{-0.4cm} BERT-P=\frac{1}{\mid y \mid}\sum\limits_{y_{j}\in y}\max\limits_{x_{i}\in x}\mathbf{x}_{i}^{T}\mathbf{y}_{j} \notag \\ &\hspace{-0.4cm} BERT-R=\frac{1}{\mid x \mid}\sum\limits_{x_{i}\in x}\max\limits_{y_{j}\in y}\boldsymbol{x}_{i}^{T}\boldsymbol{y}_{j} \notag \\ &\hspace{-0.4cm} BERT-F= \frac{2BERT-R\times BERT-P}{BERT-P+BERT-R} \end{eqnarray} where $x=\langle x_{1}, \cdots, x_{m} \rangle$,$\langle \mathbf{x}_{1}, \cdots, \mathbf{x}_{m} \rangle$, $y=\langle y_{1}, \cdots, y_{n} \rangle$,$\langle \mathbf{y}_{1}, \cdots, \mathbf{y}_{n} \rangle$ denote tokenized reference sentence, sequence of embedding vectors for the tokenized reference sentence, tokenized candidate sentence, sequence of embedding vectors for the tokenized candidate sentence, respectively. \end{itemize} \subsection{Evaluation of Text Regression} For the prediction of prison term at a continuous interval, we can take them as text regression problems, such as in~\cite{2019Charge}. Given the difference between the predicted prison term $\hat{y}_{i}$ and the ground truth value ${y}_{i}$ of the the $i$-th case, the evaluation metrics employed to evaluate the performance of prison term prediction problems are summarized as follows: \begin{itemize} \item \textbf{Log distance}. To evaluate the tiny difference between the predicted prison term and its ground truth value based on distance, Log distance $LD$ is defined as follows: \begin{equation} LD=\sum_{i=1}^{N}\frac{|log({y}_{i}+1)-log(\hat{y}_{i}+1)|}{N} \end{equation} \item \textbf{S score}. As the metrics used in the CAIL2018 Competition~\cite{zhong2018overview}, $S$ score metric can be obtained to evaluate the similarity between two continuous stochastic variables : \begin{equation} S=\sum_{i=1}^{N}\frac{f(|log({y}_{i}+1)-log(\hat{y}_{i}+1)|)}{N} \end{equation} where, function $f(\cdot)$ satisfies: \begin{equation} f(v)=\left\{ \begin{array}{rcl} 1.0, & & {if \quad v \leq 0.2,}\\ 0.8, & & {if \quad 0.2 < v \leq 0.4,}\\ 0.6, & & {if \quad 0.4 < v \leq 0.6,}\\ 0.4, & & {if \quad 0.6 < v \leq 0.8,}\\ 0.2, & & {if \quad 0.8 < v \leq 1.0,}\\ 0.0, & & {if \quad 1.0 < v. } \end{array} \right. \end{equation} \end{itemize} \section{Methods}\label{methods} We introduce the methods for legal judgment prediction based on the publicly available datasets described in Section \ref{Datasets}. If the LJP dataset consists of multiple subtasks, the multi-task learning (MTL) method can be used to utilize the dependencies among prediction results of multiple subtasks (see Section \ref{Multi-Task method}). If the dataset is a task-specific dataset, Pre-trained language models (PTMs, Section \ref{Pre-trained Language method}) can be used for fine-tuning downstream tasks. The few-shot learning (FSL) method (Section~\ref{Few-Shot learning method}) can be used for a few-shot scenario that the distribution of the dataset's judgment results is imbalanced. \subsection{Multi-Task Learning}\label{Multi-Task method} Multi-task learning (MTL) has numerous successful usages in NLP tasks, which transfers useful information across relevant tasks by solving them simultaneously so that it has been applied to a wide range of areas, including NLP especially the legal domain. A family of multi-task learning methods focusing on utilizing logical dependencies among relative tasks is described as follows: For example, to improve performance for predicting charges in the civil law system (e. g. France, Germany, Japan, and China) according to the useful information of relevant articles, FLA~\cite{2017Learning} proposed a two-stack attention-based neural network, dubbed Fact-Law Attention (FLA), to jointly model the charge prediction task and the relevant article extraction task in a unified framework. Specifically, one stack for fact embedding based on a sentence-level and a document Bi-directional Gated Recurrent Units (Bi-GRU), and the other for article embedding, dynamically generated for each case according to the fact-side clues as extra guidance. Then, a topological multi-task learning framework model, TOPJUDGE\footnote{https://github.com/thunlp/TopJudge}~\cite{2018Legal}, has been proposed based on the facts of a case and topological dependencies among articles, charges, and prison terms. Specifically, in the civil law system, given the fact description of a specific case, applicable law articles are firstly decided by a judge, and then the charges according to the instructions of relevant law articles are determined. Based on these results, the judge further confirms the terms of the penalty. Furthermore, a Multi-Perspective Bi-Feedback Network (MPBFN) with the Word Collocation Attention (WCA) mechanism has been proposed in~\cite{2019Legal}. Specifically, the semantic vector of fact with word collocation and number semantic attention mechanism and the judgment results of pre-dependent tasks are utilized to make the forward prediction for its follow-up tasks. Meanwhile, the judgment results of follow-up tasks are also utilized to make a backward verification to check the rationality of their pre-order tasks. Another family of multi-task learning methods is also widely used since they distinguish confusing follow-up tasks utilized the discriminative information of pre-order tasks. For example, a discriminative confusing charges model is proposed by incorporating relevant essential attributes (Few-Shot charge prediction model\footnote{https://github.com/thunlp/attribute\_charge}~\cite{2018few-shot}) or by distinguishing confusing law articles (Law Article Distillation based Attention Network, LADAN\footnote{https://github. com/prometheusXN/LADAN }~\cite{2020Distinguish}). \subsection{Pre-trained Language Model}\label{Pre-trained Language method} Transformer-based~\cite{vaswani2017attention} pre-trained language models (PLMs), such as BERT~\cite{devlin-etal-2019-bert} and its variants (\cite{liu2019roberta,yang2019xlnet,beltagy2020longformer,chang2020dart,he2020deberta,zaheer2020big,sanh2019distilbert,lewis2019bart,JMLR:v21:20-074,xue2020mt5,liu2020multilingual,brown2020language}), have achieved state-of-the-art results in several downstream NLP tasks on generic benchmark datasets. As shown in Table \ref{table7}, inspired by the success of PLMs in the generic domain, there have been several approaches for applying BERT-based models in legal domain pretraining to explore state-of-the-art performance in downstream legal tasks. For example, LEGAL-BERT\footnote{https://huggingface.co/nlpaueb.}~\cite{2020LEGAL}, a new family of BERT models with 12 GB of English legal training corpora, consists of LEGAL-BERT-FP version (adapting standard BERT by additional pretraining on legal domain corpora) and LEGAL-BERT-SC version ( pretraining BERT from scratch on legal domain corpora). CaseLaw-BERT~\cite{zhengguha2021} is also the LEGAL-BERT-SC model but uses the case law corpus and custom domain-specific vocabulary. LegalDB is a DistillBERT model pre-trained on English legal-specific training corpora too. Lawformer~\cite{xiao2021lawformer} is a Longfomer-based model pre-trained on large-scale Chinese legal long case documents. JuriBERT~\cite{2021Douka} is a new set of BERT models, consisting of LEGAL-BERT-SC model pre-trained on French legal text datasets and adapting CamemBERT by additional pretraining on French legal text datasets. Besides the effort to the domain-specific pre-trained language models, an improvement of PLMs on legal tasks with a document length of longer than 512 has been another research pot in the legal domain. For example, a hierarchical version of BERT, HIER-BERT~\cite{2020LEGAL}, concatenates BERT-BASE with a hierarchical attention network to bypass BERT’s length limitation. Lawformer~\cite{xiao2021lawformer}, a Longformer-based pre-trained language model, combines the local sliding window attention and the global task motivated full attention to capturing the long-distance dependency for processing the Chinese legal documents with thousands of tokens. \subsection{Interpretable-Perspective Learning Framework} Interpretability in LJP, which means the ability of LJP systems to explain their predictions, has drawn increasing attention rapidly from academia and the legal industry, as people cannot wholly trust the machine-generated judgment results without any interpretation provided. The concept of interpretation~\cite{2016Generating} has been categorized into introspection explanation and justification explanation. Introspection explains how a model determines its final output. Justification explanation produces sentences detailing how the evidence is compatible with the system output. Reinforcement learning methods are widely used for introspection explanation in LJP. Rationales from input fact description, where rationales serve as the introspection explanation for the charge prediction, are extracted using a deep reinforcement learning method~\cite{2018Interpretable}. QAjudge\footnote{https://github.com/thunlp/QAjudge}~\cite{2020Iteratively} is based on reinforcement learning to interpret the judgments. Specifically, a question net will select questions from the given set, and an answer net will answer the question according to the fact description. Finally, a predicted net will produce judgment results based on the answers, and reward functions are designed to minimize the number of questions asked. Moreover, Multi-task learning methods in Section~\ref{Multi-Task method} can also be used for an introspection explanation of LJP. Correspondence-based methods among relative tasks can also be used as an introspection explanation of LJP. For example, a fine-grained fact-article correspondence method is proposed~\cite{2021Learning} for recommending relevant law articles to a given legal case since the existing recommended articles do not explain which specific fact each article is relevant. Charge-based prison term prediction (CPTP)~\cite{2019Charge} has been proposed to make the total prison term prediction more interpretable based on the fine-grained charge-prison term correspondence feature selection and aggregation. From the justification explanation aspect, Court Views~\cite{Hai2018Interpretable} has been considered as the explanation for the prediction of charges. \subsection{Few-Shot Learning Framework}\label{Few-Shot learning method} Few-shot learning has become a hot spot~\cite{zhao2017gated,2018few-shot,xu2020data,chang2021training,chang2021selectgen} since current works focus more on high-frequency judgment results than few-shot judgment results to ensure enough training data. Several few-shot learning methods can be used to predict few-shot judgment results. For example, discriminative attributes of charges~\cite{2018few-shot} are utilized to provide additional information for few-shot charges. A Sequence Enhanced Capsule model, dubbed the SECaps model~\cite{2018SECaps}, is based on the focal loss to predict few-shot charges. Moreover, an attentional and Counterfactual based Natural Language Generation (AC-NLG) method~\cite{2018SECaps} has been proposed, where the counterfactual decoder is used to address the imbalance problem in judgments. \begin{table} \centering \caption{The current results for ECHR-CASES.} \label{table10} \begin{tabular}{|c|cc|} \hline \multirow{3}{*}{Method} & \multicolumn{2}{c|}{Articles} \\ \cline{2-3} & \multicolumn{1}{c|}{Binary} & Multi-lable \\ \cline{2-3} & \multicolumn{1}{c|}{MaF} & MaF \\ \hline BOW-SVM & \multicolumn{1}{c|}{70.9±0.0} & 50.4±0.0 \\ \hline BIGRU-ATT & \multicolumn{1}{c|}{78.9±1.9} & 56.2±1.3 \\ \hline HAN & \multicolumn{1}{c|}{80.2±2.7} & 59.9±0.5 \\ \hline HIER-BERT & \multicolumn{1}{c|}{\textbf{80.1±1.1}} & \textbf{60.0±1.3} \\ \hline LEGAL-BERT-FP 100k ALL LEGAL & \multicolumn{1}{c|}{\textbf{88.3}} & 63.9 \\ \hline LEGAL-BERT-FP 500k ALL LEGAL & \multicolumn{1}{c|}{88.0} & 60.3 \\ \hline LEGAL-BERT-FP 100k SUB-DOMAIN & \multicolumn{1}{c|}{87.9} & 60.5 \\ \hline LEGAL-BERT-FP 500k SUB-DOMAIN & \multicolumn{1}{c|}{88.0} & \textbf{65.2} \\ \hline \end{tabular} \end{table} \section{Results \& Observations}\label{result} \begin{table*} \centering \caption{The current results for CAIL-Long dataset.} \label{table11} \begin{tabular}{|c|ccccc|cc|} \hline \multirow{3}{*}{Method} & \multicolumn{5}{c|}{Criminal} & \multicolumn{2}{c|}{Civil} \\ \cline{2-8} & \multicolumn{2}{c|}{Charges} & \multicolumn{2}{c|}{Articles} & Prison terms & \multicolumn{2}{c|}{Articles} \\ \cline{2-8} & \multicolumn{1}{c|}{MiF} & \multicolumn{1}{c|}{MaF} & \multicolumn{1}{c|}{MiF} & \multicolumn{1}{c|}{MaF} & LD & \multicolumn{1}{c|}{MiF} & MaF \\ \hline BERT & \multicolumn{1}{c|}{94.800} & \multicolumn{1}{c|}{68.200} & \multicolumn{1}{c|}{81.500} & \multicolumn{1}{c|}{52.9} & 1.286 & \multicolumn{1}{c|}{61.700} & 31.600 \\ \hline RoBERTa & \multicolumn{1}{c|}{94.700} & \multicolumn{1}{c|}{69.300} & \multicolumn{1}{c|}{81.100} & \multicolumn{1}{c|}{53.500} & 1.291 & \multicolumn{1}{c|}{60.200} & 29.900 \\ \hline L-RoBERTa & \multicolumn{1}{c|}{94.900} & \multicolumn{1}{c|}{70.800} & \multicolumn{1}{c|}{81.100} & \multicolumn{1}{c|}{53.400} & 1.280 & \multicolumn{1}{c|}{61.200} & 31.300 \\ \hline \textbf{Lawformer} & \multicolumn{1}{c|}{\textbf{95.400}} & \multicolumn{1}{c|}{\textbf{72.100}} & \multicolumn{1}{c|}{\textbf{82.000}} & \multicolumn{1}{c|}{\textbf{54.300}} & \textbf{1.264} & \multicolumn{1}{c|}{\textbf{63.000}} & \textbf{33.000} \\ \hline \end{tabular} \end{table*} \begin{table*} \centering \caption{The current results for CAIL-2018 dataset.} \label{table9} \resizebox{\textwidth}{1in}{ \begin{tabular}{|c|ccc|ccc|ccc|} \hline \multirow{2}{*}{Method} & \multicolumn{3}{c|}{Acc} & \multicolumn{3}{c|}{MaP} & \multicolumn{3}{c|}{MaR} \\ \cline{2-10} & \multicolumn{1}{c|}{Charges} & \multicolumn{1}{c|}{Articles} & Prison terms & \multicolumn{1}{c|}{Charges} & \multicolumn{1}{c|}{Articles} & Prison terms & \multicolumn{1}{c|}{Charges} & \multicolumn{1}{c|}{Articles} & Prison terms \\ \hline FLA+MTL & \multicolumn{1}{c|}{92.76} & \multicolumn{1}{c|}{93.23} & 57.63 & \multicolumn{1}{c|}{76.35} & \multicolumn{1}{c|}{72.78} & 48.93 & \multicolumn{1}{c|}{68.48} & \multicolumn{1}{c|}{64.30} & 45.00 \\ \hline CNN+MTL & \multicolumn{1}{c|}{95.74} & \multicolumn{1}{c|}{95.84} & 55.43 & \multicolumn{1}{c|}{86.49} & \multicolumn{1}{c|}{83.20} & 45.13 & \multicolumn{1}{c|}{79.00} & \multicolumn{1}{c|}{75.31} & 38.85 \\ \hline HARNN+MTL & \multicolumn{1}{c|}{95.58} & \multicolumn{1}{c|}{95.63} & 57.38 & \multicolumn{1}{c|}{85.59} & \multicolumn{1}{c|}{81.48} & 43.50 & \multicolumn{1}{c|}{79.55} & \multicolumn{1}{c|}{74.57} & 40.79 \\ \hline Few-Shot+MTL & \multicolumn{1}{c|}{96.04} & \multicolumn{1}{c|}{96.12} & 57.84 & \multicolumn{1}{c|}{88.30} & \multicolumn{1}{c|}{85.43} & 47.27 & \multicolumn{1}{c|}{80.46} & \multicolumn{1}{c|}{80.07} & 42.55 \\ \hline TOPJUDGE & \multicolumn{1}{c|}{95.78} & \multicolumn{1}{c|}{95.85} & 57.34 & \multicolumn{1}{c|}{86.46} & \multicolumn{1}{c|}{84.84} & 47.32 & \multicolumn{1}{c|}{78.51} & \multicolumn{1}{c|}{74.53} & 42.77 \\ \hline MPBFN-WCA & \multicolumn{1}{c|}{95.98} & \multicolumn{1}{c|}{96.06} & 58.14 & \multicolumn{1}{c|}{\textbf{89.16}} & \multicolumn{1}{c|}{85.25} & 45.86 & \multicolumn{1}{c|}{79.73} & \multicolumn{1}{c|}{74.82} & 39.07 \\ \hline LADAN+MTL & \multicolumn{1}{c|}{96.45} & \multicolumn{1}{c|}{96.57} & 59.66 & \multicolumn{1}{c|}{88.51} & \multicolumn{1}{c|}{86.22} & \textbf{51.78} & \multicolumn{1}{c|}{\textbf{83.73}} & \multicolumn{1}{c|}{\textbf{80.78}} & 45.34 \\ \hline LADAN+TOPJUDGE & \multicolumn{1}{c|}{96.39} & \multicolumn{1}{c|}{\textbf{96.62}} & 59.70 & \multicolumn{1}{c|}{88.49} & \multicolumn{1}{c|}{\textbf{86.53}} & 51.06 & \multicolumn{1}{c|}{82.28} & \multicolumn{1}{c|}{79.08} & 45.46 \\ \hline LADAN+MPBFN & \multicolumn{1}{c|}{\textbf{96.42}} & \multicolumn{1}{c|}{96.60} & \textbf{59.85} & \multicolumn{1}{c|}{88.45} & \multicolumn{1}{c|}{86.42} & 51.75 & \multicolumn{1}{c|}{83.08} & \multicolumn{1}{c|}{80.37} & \textbf{45.59} \\ \hline \end{tabular} } \end{table*} This section compares empirical results on LJP datasets via various NLP models. We focused on datasets from 8 sources: European Court of Human Rights (ECHR), Supreme People's Court of China (SPC), French Supreme Court (FSC), UK's highest Court (UKC), the Supreme Court of the United States (SCOTUS), French Supreme Court (FSC), (UKC)Supreme Court of Indian (SPC), Thai Supreme Court (TSC), and Federal Supreme Court of Switzerland (FSCS). We introduced 31 LJP datasets and six unlabelled pre-trained corpora above, but we focus on nine datasets from different source Court cases for looking into the results of experiments on them. Others have a limited size or limited numbers of experiments than the focused datasets. \subsection{ECHR cases} \begin{table*} \centering \caption{The current results for FSC, UKC, SCOTUS and SCI cases.} \label{FUS cases} \begin{tabular}{|c|c|c|cccc|} \hline \multirow{2}{*}{Dataset} & \multirow{2}{*}{Source} & \multirow{2}{*}{Method} & \multicolumn{4}{c|}{Plea judgments} \\ \cline{4-7} & & & \multicolumn{1}{c|}{Acc} & \multicolumn{1}{c|}{MaF} & \multicolumn{1}{c|}{MaP} & MaR \\ \hline Sulea et al.~\cite{sulea2017predicting} & FSC & \textbf{SVM} & \multicolumn{1}{c|}{\textbf{96.90}} & \multicolumn{1}{c|}{\textbf{97.00}} & \multicolumn{1}{c|}{\textbf{97.10}} & \textbf{96.90} \\ \hline \multirow{4}{*}{BStricks\_LDC~\cite{strickson2020legal}} & \multirow{4}{*}{UKC} & \textbf{TFIDF+LR} & \multicolumn{1}{c|}{\textbf{69.05}} & \multicolumn{1}{c|}{\textbf{69.02}} & \multicolumn{1}{c|}{\textbf{69.05}} & \textbf{69.02} \\ \cline{3-7} & & LDA+kNN & \multicolumn{1}{c|}{57.76} & \multicolumn{1}{c|}{57.63} & \multicolumn{1}{c|}{58.01} & 57.88 \\ \cline{3-7} & & Word2Vec+RF & \multicolumn{1}{c|}{64.21} & \multicolumn{1}{c|}{64.17} & \multicolumn{1}{c|}{64.17} & 64.18 \\ \cline{3-7} & & Count+RF & \multicolumn{1}{c|}{66.13} & \multicolumn{1}{c|}{66.12} & \multicolumn{1}{c|}{66.12} & 66.13 \\ \hline \multirow{7}{*}{JUSTICE~\cite{2021JUSTICE2021}} & \multirow{7}{*}{SCUS} & Perceptron & \multicolumn{1}{c|}{65.00} & \multicolumn{1}{c|}{65.00} & \multicolumn{1}{c|}{65.00} & 65.00 \\ \cline{3-7} & & SVM & \multicolumn{1}{c|}{60.00} & \multicolumn{1}{c|}{60.00} & \multicolumn{1}{c|}{60.00} & 60.00 \\ \cline{3-7} & & LR & \multicolumn{1}{c|}{61.00} & \multicolumn{1}{c|}{61.00} & \multicolumn{1}{c|}{61.00} & 61.00 \\ \cline{3-7} & & Naive Bayes & \multicolumn{1}{c|}{59.00} & \multicolumn{1}{c|}{59.00} & \multicolumn{1}{c|}{59.00} & 59.00 \\ \cline{3-7} & & MLP & \multicolumn{1}{c|}{64.00} & \multicolumn{1}{c|}{64.00} & \multicolumn{1}{c|}{64.00} & 64.00 \\ \cline{3-7} & & \textbf{kNN} & \multicolumn{1}{c|}{\textbf{68.00}} & \multicolumn{1}{c|}{\textbf{67.00}} & \multicolumn{1}{c|}{\textbf{69.00}} & \textbf{68.00} \\ \cline{3-7} & & Clalib. Claasifier & \multicolumn{1}{c|}{62.00} & \multicolumn{1}{c|}{62.00} & \multicolumn{1}{c|}{63.00} & 62.00 \\ \hline \multirow{5}{*}{ILDC~\cite{malik2021ildc}} & \multirow{5}{*}{SCI} & Doc2Vec+LR & \multicolumn{1}{c|}{60.91} & \multicolumn{1}{c|}{62.00} & \multicolumn{1}{c|}{63.03} & 61.00 \\ \cline{3-7} & & GloVe+BiGRU+att. & \multicolumn{1}{c|}{60.75} & \multicolumn{1}{c|}{64.35} & \multicolumn{1}{c|}{68.26} & 60.87 \\ \cline{3-7} & & RoBERTa & \multicolumn{1}{c|}{71.26} & \multicolumn{1}{c|}{71.77} & \multicolumn{1}{c|}{72.25} & 71.31 \\ \cline{3-7} & & \textbf{XLNet+BiGRU} & \multicolumn{1}{c|}{\textbf{77.78}} & \multicolumn{1}{c|}{\textbf{77.79}} & \multicolumn{1}{c|}{\textbf{77.80}} & \textbf{77.78} \\ \cline{3-7} & & XLNet+BiGRU+att. & \multicolumn{1}{c|}{77.01±0.52} & \multicolumn{1}{c|}{77.07±0.01} & \multicolumn{1}{c|}{77.32} & 76.82 \\ \hline \end{tabular} \end{table*} Table \ref{table10} shows the evaluation results of recent studies on ECHR-CASES. BOW-SVM is a frequently used classification baseline model using Support Vector Machine (SVM) based on the bag-of-words features. BIGRU-ATT is the standard sequence model Bi-directional Gated Recurrent Units (Bi-GRU,~\cite{bahdanau2014neural}) with attention, and Hierarchical Attention Network (HAN, ~\cite{yang2016hierarchical}) is also a sequential model. HIER-BERT is a Hierarchical Transformer model to bypass BERT's length limitation, and LEGAL-BERT-FP 100k/500k ALL LEGAL/SUB-DOMAIN are transformer models with running additional pre-training steps (e.g., up to 100k or 500k) of BERT-BASE on legal-domain corpora (such as all legal corpora or just ECHR-CASES). As the tendency, LEGAL-BERT-FP 100k ALL LEGAL widely outperforms the other methods in binary violation classification, and LEGAL-BERT-FP 500k SUB-DOMAIN and LEGAL-BERT-FP 100k ALL LEGAL perform excellently. These results indicate that one can consider further pre-training to port BERT to a new domain. \subsection{SPC cases} \subsubsection{CAIL-Long Dataset} Table \ref{table11} shows evaluation results of recent studies on CAIL-Long. Both BERT (~\cite{devlin-etal-2019-bert}) and RoBERTa (~\cite{liu1907roberta,cui2019pre}) are mainstream pre-trained language models (PLMs) with length limitations in the generic domain. Both L-RoBERTa and Lawformer are further pre-trained on the same legal corpus. Nevertheless, Lawformer is a Longformer-based PLMs on legal-domain corpora to process long documents. As the tendency, both in criminal and civil cases, Lawformer based on capturing the long-distance dependency for processing the long legal documents achieves the best performance, which indicates that one can consider Lawformer as the pre-trained model to finetune a legal document in Chinese longer than 512. \subsubsection{CAIL-2018 Dataset} Table \ref{table9} shows the evaluation results of recent studies on CAIL2018. For the detailed explanations of methods, see Section V. As the tendency, LADAN based on automatically extracting discriminative features of confusing articles from fact descriptions achieve best accuracy Acc, macro-precision (MaP), and macro-recall (MaR). MPBFN-WCA method shows better performance than the TOPJUDGE model due to bi-directional dependencies among LJP subtasks being utilized other than forwarding dependencies. Both the MPBFN-WCA method and the TOPJUDGE model perform poorly under the MP, MR, and F1 metrics, which indicates their shortage of predicting few-shot charges. In addition, the performance of Few-Shot on charge prediction is close to LADAN, but worse performance on prison term due to the limitation of predefined attributes to help to predict prison term. \subsection{FSC, UKC, SCOTUS, and SCI cases} \begin{table} \centering \caption{The evaluation results for fact snippets vs experts in ILDC dataset.} \label{ILDC} \begin{tabular}{|c|cccccc|} \hline \multirow{2}{*}{Expert} & \multicolumn{6}{c|}{Fact snippets vs Expets} \\ \cline{2-7} & \multicolumn{1}{c|}{JS} & \multicolumn{1}{c|}{R-1} & \multicolumn{1}{c|}{R-2} & \multicolumn{1}{c|}{R-L} & \multicolumn{1}{c|}{BLEU} & Meteor \\ \hline \textbf{Expert 1} & \multicolumn{1}{c|}{\textbf{0.333}} & \multicolumn{1}{c|}{0.444} & \multicolumn{1}{c|}{\textbf{0.303}} & \multicolumn{1}{c|}{0.439} & \multicolumn{1}{c|}{0.160} & 0.220 \\ \hline \textbf{Expert 2} & \multicolumn{1}{c|}{0.317} & \multicolumn{1}{c|}{\textbf{0.517}} & \multicolumn{1}{c|}{0.295} & \multicolumn{1}{c|}{0.407} & \multicolumn{1}{c|}{\textbf{0.280}} & \textbf{0.300} \\ \hline Expert 3 & \multicolumn{1}{c|}{0.328} & \multicolumn{1}{c|}{0.401} & \multicolumn{1}{c|}{0.296} & \multicolumn{1}{c|}{0.423} & \multicolumn{1}{c|}{0.099} & 0.180 \\ \hline \textbf{Expert 4} & \multicolumn{1}{c|}{0.324} & \multicolumn{1}{c|}{0.391} & \multicolumn{1}{c|}{0.297} & \multicolumn{1}{c|}{\textbf{0.444}} & \multicolumn{1}{c|}{0.093} & 0.177 \\ \hline Expert 5 & \multicolumn{1}{c|}{0.318} & \multicolumn{1}{c|}{0.501} & \multicolumn{1}{c|}{0.294} & \multicolumn{1}{c|}{0.407} & \multicolumn{1}{c|}{0.248} & 0.279 \\ \hline \end{tabular} \end{table} \begin{table*} \centering \caption{The current results for FSCS cases.} \label{FSCS cases} \begin{tabular}{|c|cccccc|} \hline \multirow{3}{*}{Method} & \multicolumn{6}{c|}{Plea judgments} \\ \cline{2-7} & \multicolumn{2}{c|}{de} & \multicolumn{2}{c|}{fr} & \multicolumn{2}{c|}{it} \\ \cline{2-7} & \multicolumn{1}{c|}{MiF} & \multicolumn{1}{c|}{MaF} & \multicolumn{1}{c|}{MiF} & \multicolumn{1}{c|}{MaF} & \multicolumn{1}{c|}{MiF} & MaF \\ \hline \textbf{Majority} & \multicolumn{1}{c|}{\textbf{80.3}} & \multicolumn{1}{c|}{44.5} & \multicolumn{1}{c|}{\textbf{81.5}} & \multicolumn{1}{c|}{44.9} & \multicolumn{1}{c|}{\textbf{81.3}} & 44.8 \\ \hline Stratified & \multicolumn{1}{c|}{66.7±0.3} & \multicolumn{1}{c|}{50.0±0.4} & \multicolumn{1}{c|}{66.3±0.2} & \multicolumn{1}{c|}{50.0±0.4} & \multicolumn{1}{c|}{69.9±1.8} & 48.8±2.4 \\ \hline Linear(BoW) & \multicolumn{1}{c|}{65.4±0.2} & \multicolumn{1}{c|}{52.6±0.1} & \multicolumn{1}{c|}{71.2±0.1} & \multicolumn{1}{c|}{56.6±0.2} & \multicolumn{1}{c|}{67.4±0.5} & 53.9±0.6 \\ \hline Native BERT & \multicolumn{1}{c|}{74.0±4.0} & \multicolumn{1}{c|}{63.7±1.7} & \multicolumn{1}{c|}{74.7±1.8} & \multicolumn{1}{c|}{58.6±0.9} & \multicolumn{1}{c|}{76.1±3.7} & 55.2±3.7 \\ \hline Multilingual BERT & \multicolumn{1}{c|}{68.4±5.1} & \multicolumn{1}{c|}{58.2±4.8} & \multicolumn{1}{c|}{71.3±4.3} & \multicolumn{1}{c|}{55.0±0.8} & \multicolumn{1}{c|}{77.6±2.4} & 53.0±1.1 \\ \hline \textbf{long Native BERT} & \multicolumn{1}{c|}{76.5±3.7} & \multicolumn{1}{c|}{67.9±1.8} & \multicolumn{1}{c|}{77.2±3.4} & \multicolumn{1}{c|}{68.0±1.8} & \multicolumn{1}{c|}{77.1±3.9} & \textbf{59.8±4.6} \\ \hline long Multilingual BERT & \multicolumn{1}{c|}{75.9±1.6} & \multicolumn{1}{c|}{66.5±0.8} & \multicolumn{1}{c|}{73.3±1.9} & \multicolumn{1}{c|}{64.3±1.5} & \multicolumn{1}{c|}{76.0±2.6} & 58.4±3.5 \\ \hline \textbf{hierarchical Native BERT} & \multicolumn{1}{c|}{77.1±3.7} & \multicolumn{1}{c|}{\textbf{68.5±1.6}} & \multicolumn{1}{c|}{80.2±2.0} & \multicolumn{1}{c|}{\textbf{70.2±1.1}} & \multicolumn{1}{c|}{75.8±3.5} & 57.1±6.1 \\ \hline hierarchical Multilingual BERT & \multicolumn{1}{c|}{76.8±3.2} & \multicolumn{1}{c|}{57.1±0.8} & \multicolumn{1}{c|}{76.3±4.1} & \multicolumn{1}{c|}{67.2±2.9} & \multicolumn{1}{c|}{72.4±16.6} & 55.5±9.5 \\ \hline \end{tabular} \end{table*} \begin{table} \centering \caption{The current results for TSC cases.} \label{TSC cases} \begin{tabular}{|c|cc|} \hline \multirow{2}{*}{Method} & \multicolumn{2}{c|}{Plea judgments} \\ \cline{2-3} & \multicolumn{1}{c|}{MiF} & MaF \\ \hline Naive Bayes & \multicolumn{1}{c|}{57.32} & 57.28 \\ \hline SVM & \multicolumn{1}{c|}{64.23} & 60.45 \\ \hline BiGRU & \multicolumn{1}{c|}{58.54} & 57.99 \\ \hline BiGRU + self-att. & \multicolumn{1}{c|}{59.76} & 59.11 \\ \hline BiGRU + att. & \multicolumn{1}{c|}{\textbf{66.68}} & \textbf{63.35} \\ \hline \end{tabular} \end{table} Table \ref{FUS cases} shows the evaluation results of recent studies on FSC, UKC, SCOTUS, and SCI cases. All Support Vector Machine (SVM), Logistic Regression (LR), K-Nearest Neighbor (kNN), Naive Bayes, Perceptron, multi-layer perceptron (MLP), calibrated classifier (Calib. Classifier), and Random Forest are classical feature-based machine learning models (e.g., using word/sentence embedding and TFIDF). RoBERTa and XLNet are mainstream transformer models. As the tendency, XLNet with BiGRU outperforms classical and sequential models on the ILDC dataset, the best performing classical model on UKC cases is TFIDF with LR on the top, kNN is the top-performing classical model on SCOTUS cases, and the classical model performs excellently on FSC cases. These results show that transformer-based sequence models may further improve the performance of classical models. In addition, Table \ref{ILDC} shows exact matching results between automatically extracted Fact snippets by machine and annotated references by experts on the ILDC dataset, indicating that an efficient explainable model for the LJP task may point a direction of future research. \subsection{FSCS cases} Table \ref{FSCS cases} shows the evaluation results of recent studies on FSCS cases. All Majority, Stratified and Linear (BoW) are baseline classifiers, where Majority selects the majority class across all the legal cases, Stratified predicts the judgment labels randomly, and Linear (BoW) is a linear classifier using TFIDF features. Long BERT introduces additional positional embedding to extend the limited sequence length of the standard BERT model. Moreover, hierarchical BERT separates and encodes the input tokens with a standard BERT encoder and then aggregates all segment encodings with an additional Bidirectional Long Short-Term Memory (BiLSTM) to form the representation of classification. As the tendency, the majority method performs best compared to other baseline models and BERT-based models in MiF. Considering the error margin, both the long BERT model and hierarchical BERT (German and French with 20K+ training samples) outperform the Italian ones with 3K training samples in MaF. These results indicate that imbalanced class distribution, the scale of a dataset, and the variants of BERT models may influence the performance. \subsection{TSC cases} Table \ref{TSC cases} shows the evaluation results of recent studies on TSC cases. SVM and Naive Bayes are frequently used classification baseline models. Both of these two models are non-neural models. As the tendency, sequence model BiGRU with attention outperforms the non-neural models on the TSCC dataset. To summarize, experiments on ECHR-CASES, CAIL-Long, ILDC, and FSCS cases indicate that further pre-trained BERT-based models on legal corpora could predict the judgment better than using classical/sequence models or that with BERT-based models on generic corpora. And, experiments on CAIL-2018 show that the combination of two families of MTL outperforms other models on solving multi-task simultaneously. And evaluation results on the ILDC dataset also indicate that interpretable learning for the LJP task is still challenging work. In addition, experiments on FSCS cases show that BERT-based methods without employing few-shot learning on imbalanced label distribution can underperform that on balanced label distribution. \section{Discussions \& Recommendations}\label{Discussions} This section analyzes different LJP datasets and solutions and discusses our findings. \begin{itemize} \item Sophisticated LJP Datasets from real courtrooms. As the performances on LJP are improved, doing more fine-grained and sophisticated real court judgment will become of more practical significance. Up to now, a large number of large-scale judge-summarized facts description-based LJP datasets, such as CAIL2018 or CAIL-Long in Table~\ref{table00}, have been built. However, these datasets could threaten the case logic representation quality and prediction correctness since they neglect the effect of the admissibility of evidence and facts in a real court setting. For all we know, the LJP dataset from real courtrooms is only LJP-MSJudge~\cite{RN202}, but this dataset only considers ten facts labels of 70,482 Private Lending cases. Hence, we propose the recommendations for a new dataset stating the actual legitimate intent, especially when the rules of proof are inadequate and the text of evidence is doubt or ambiguous. \item Complex legal logical reasoning. An ideal legal judgment predictor is expected to examine the case from different views~\cite{RN202} comprehensively. As shown in Table~\ref{table9}, improving the predicting accuracy of prison terms is highly urgent, although the accuracy of prediction for articles and charges is over 90\%. How to augment legal knowledge from various views and machine reasoning in NLP is of great significance. \item Adaptive interpretability. As shown in Table~\ref{FUS cases}, a pre-trained language model, XLNet with BiGRU, which outperforms classical and sequential models~\cite{malik2021ildc}, is the best performing model on the ILDC dataset. However, considering that the logic of practice judgments has its specialty for each law domain, the explanation for its black-box work will still be challenging in LJP tasks. \end{itemize} \section{Conclusion} In this survey, we first reveal the importance and history of legal judgment prediction. Then we compare and discuss the most recent benchmark datasets and experimental results of different methods. Based on our observations, we propose new recommendations for future datasets and also give the following suggestions for our future law judgment prediction model: predict whether the admissibility of evidence, complex reasoning features, and discriminative task-specific features can be incorporated into LJP datasets and existing neural network model for better performance, respectively. \section*{Acknowledgment} This work was supported in part by the Science Foundation of The China(Xi'an) Institute for Silk Road Research (2019YB05, and 2019YA07), the Innovation training project of Shaanxi college students(S202011560030), and in part by the Research Foundation of Xi'an University of Finance and Economics under Grant 18FCJH02. \bibliographystyle{elsarticle-num}
{'timestamp': '2022-04-12T02:31:34', 'yymm': '2204', 'arxiv_id': '2204.04859', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04859'}
arxiv
\section{Introduction} Despite some recent advances, automatic text summarization remains unreliable, elusive and of limited actual use in applications. Two main problems with current summarization methods are well known: evaluation and factual consistency. First, the current evaluation metrics are inadequate. They rely on human generated summaries which are wildly inconsistent and subjective. Second, there is no way to guarantee generated summaries have true facts consistent with the source text. Some techniques using large language models may introduce new facts into the summary. This latter problem renders automatic summarization unsuitable in a number of important domains such as law, journalism and government. In this paper, we propose a new automatic reference-less text summarization evaluation system that can measure the quality of any text summarization model based on factual consistency, comprehensiveness, and compression rate. The system works by generating dynamic, natural language documents, based on a set of generated facts from a certain domain. These documents are to be used as test input for any automatic text summarization system. Our working hypothesis is that since the input documents contain facts that are entirely known to the system, verifying factual consistency should be more feasible. However, factual consistency isn't the only criteria for summarization. To automatically measure the quality of a summary text, we consider three distinct goals of a good summarization system: consistency, comprehensiveness and compression. We define Consistency as the ratio of original source facts and facts appearing in the summary. Comprehensiveness is a score based on how much of the source facts are retained in the summary. Finally, compression is a simple measure of how much shorter the summary text is compared to the original source. While consistency and comprehensiveness scores are to be maximized, the compression score is to be minimized. This provides the basic tradeoff between larger summaries with more factual coverage and smaller summaries with fewer facts reproduced. As far as we know, we are the first to suggest a testing system that assesses text summarization models with factuality and information coverage. \section{Background} Automatic text summarization has achieved remarkable success with the help of deep neural networks and the development of standardized benchmark datasets. It can generate fluent, human-like summaries. However, the unreliability of the existing evaluation metrics/systems has hindered its practical usage and slowed down its progress. The current standard N-gram overlaps-based evaluation metrics such as ROUGE \cite{lin-2004-rouge} or BLEU \cite{papineni-etal-2002-bleu} have shown their limitations in measuring factual consistency \cite{2019, zhou-etal-2021-detecting, zhao2020reducing, goyal-durrett-2020-evaluating, kryscinski-etal-2020-evaluating} and information overlap \cite{deutsch-roth-2021-understanding} between the source document and its output summary. Also, as they rely on human-generated reference summaries, they are not only expensive and noisy but also prone to reference bias \cite{kedzie2019content}. To tackle these issues, researchers have introduced diverse reference-free approaches to evaluate desirable aspects of summarization such as factual consistency and information coverage. Zhao et al.\cite{zhao2020reducing} introduces entity-based factual consistency measurement by verifying if any entities in the output summary match with those in the source document. Similarly, Xu et al.\cite{xu-etal-2020-fact} suggests a fact-based evaluation by checking if facts in the output summary also appear in the source document. Moreover, QA-based \cite{scialom-etal-2019-answers, wang-etal-2020-asking, durmus-etal-2020-feqa}, sentence-level \cite{kryscinski-etal-2020-evaluating}, or more fine-grained token-level \cite{zhou-etal-2021-detecting} factual consistency evaluation metrics have been proposed with the advancement of natural language understanding using transfer learning. However, these approaches require a hard assumption that the trained neural models demonstrate a solid understanding of the text to trust the extracted facts or their embeddings. Furthermore, these neural-based approaches do not provide the natural interpretability of their evaluation scores which is especially crucial in measuring factual consistency. When it comes to measuring information coverage, the manual pyramid method \cite{nenkova-passonneau-2004-evaluating} has been served as a gold standard metric. Since manual evaluation entails time and cost, \cite{gao-etal-2018-pyreval, gao-etal-2019-automated} have simply automated the pyramid methods, and \cite{eyal-etal-2019-question, deutsch2021questionanswering} have recently proposed evaluation metrics that highly correlate with the pyramid method, adopting question answering (QA) models. However, these approaches are reference-based; therefore, they are susceptible to reference bias. Hence, \cite{louis-nenkova-2009-automatically} has fitted a linear regression with features such as KL-divergence to measure the information overlap without reference. More recently, \cite{wu-etal-2020-unsupervised, egan2021play} have used pre-trained language models such as BERT to measure the information overlap between the source and its system summary. But, these approaches still carry the aforementioned limitations as neural-based measurements. To address these issues, we propose an automatic text summarization evaluation metric by utilizing synthetic documents with dynamically generated facts. Since our system generates the source documents with the guarantee to contain only those facts, it is much more reliable than the other approaches that have limitations in extracting all the facts from the complex sentences in the source document. Moreover, it has natural interpretability as it explicitly demonstrates the facts used in the evaluation. \section{Approach} The main constraint of the current natural language understanding is its difficulty in understanding and extracting all the facts from a source document which normally contains complex sentences. So, our system instead creates a synthetic source document in different domains by dynamically generating relevant facts with the style and language commonly used in those domains. Then, it measures factual consistency and comprehensiveness by comparing the facts in the summary with those in the source document and produces an overarching quality score with a high compression rate penalty. Our system still requires extracting facts from the summaries, but since they are 100\% known and contain the same factual relations that were used in generating the synthetic source document, they should be easier to detect. \begin{figure}[htp] \centering \includegraphics[width=\linewidth]{thesis-system_design.jpeg} \caption{The overview of our text summarization evaluation system} \label{fig:sys_design} \end{figure} \autoref{fig:sys_design} describes the overview of our system. Based on the real-domain documents, we analyze and mine the most likely facts to generate realistic synthetic documents. Also, we manually create abstract fact trees and context free grammars to write the realistic sentences. Then, with the most probable facts and the predefined abstract fact trees, we populate the table of facts that would appear in the source document and fill the predefined grammars with those facts. Then, we generate synthetic source document using NLTK\cite{bird2009natural} with those grammars. After generating the synthetic document, it gets passed to a black box deep text summarizer to produce the system summary. The fact extractor then extracts the facts from the summary with the same factual relations used in the abstract fact tree and creates a table of the extracted facts. Lastly, the evaluator measures the factual consistency and comprehensiveness with high compression rate penalty by comparing the table of facts in the source and that of those in the summary. \subsection{Fact Representation} Facts in a sentence are the realistic lexicons with various linguistic patterns that capture the meaning of the sentence. They are generated with predefined context free grammars, and the total list of the linguistic relations is described in \autoref{tab:fact_table}. A (\textit{main clause, subordinate clause}) relation is simply represented as ((\textit{main noun, main verb}), (\textit{subordinate noun, subordinate verb})). \begin{table} \begin{center} \begin{tabular}{||c||} \hline Relation \\ \hline\hline (\textit{subject, verb, object})\\ \hline (\textit{noun modifier, noun}) \\ \hline (\textit{verb modifier, verb}) \\ \hline (\textit{phrase modifier, verb}) \\ \hline (\textit{phrase modifier, noun}) \\ \hline (\textit{clause modifier, verb}) \\ \hline (\textit{clause modifier, noun}) \\ \hline (\textit{main clause, subordinate clause}) \\ \hline \end{tabular} \caption{\label{tab:fact_table}A list of linguistic relations used in our system.} \end{center} \end{table} \subsubsection{Adding a lexicon} To add realistic lexicons to the text, we mined text summarization benchmark datasets such as CNN/Daily Mail \cite{DBLP:journals/corr/SeeLM17} as described in Section \ref{analyzer} and randomly chose a word based on its frequency. \subsubsection{Adding a grammar} To define grammars that generate practical text, we explored sentences appeared in text summarization benchmark datasets and created context free grammars accordingly. Then, we synthesized them to dynamically generate realistic document. \subsection{Analyzer} \label{analyzer} For analyzer, we used a pretrained english model from Spacy\cite{spacy2} to extract named entities and (\textit{noun, noun\_modifier}) and (\textit{(verb, verb\_modifier}) relations and counted the number of occurrences of those words or relations. \subsection{Generator} To generate a synthetic source document, we first manually predefine context free grammars and abstract fact trees as in \autoref{fig:predefined_ex}. In Figure \autoref{subfig:predefined_fact_tree}, the nodes of the tree are described as boxes and their attributes are marked with arrows. With the realistic facts from the analyzer and the abstract fact trees, we create a table of the facts that should appear in the synthetic article and fill the grammars with these facts. The table of the facts consists of an object (either \textit{noun} or \textit{verb}) and its attributes (\textit{modifiers}). For example, as in Figure \autoref{subfig:predefined_fact_tree}, an object, \textit{victim} has \textit{age}, \textit{sex}, and \textit{subject} as its attributes. Then, we parse the grammars and generate the documents. \autoref{fig:generated_text} exhibits the text generated from the generator. \begin{figure}[htp] \centering \subfigure[An example of predefined grammar]{% \label{subfig:predefined_grammar} \includegraphics[clip=False, width=0.5\columnwidth]{example_grammar.jpeg}% } \subfigure[A visualization of predefined fact tree]{% \label{subfig:predefined_fact_tree} \includegraphics[clip=False,width=\columnwidth]{example_fact_tree.jpeg}% } \caption{An example of a predefined grammar and corresponding abstract fact tree for the sentence \textit{"A 44 years old female victim got stabbed by 3 men at a Asian restaurant in New Jersey at 8 p.m. on Friday."}} \label{fig:predefined_ex} \end{figure} \begin{figure}[htp] \centering \includegraphics[width=\linewidth]{example_generated_data.jpeg} \caption{An example of Generated Text} \label{fig:generated_text} \end{figure} \subsection{Summarizer} To summarize the synthetic source document, we utilize four state of the art deep text summarization models: BART-large-cnn, BART-large-xsum\cite{DBLP:journals/corr/abs-1910-13461}, PEGASUS-cnn-dailymail, and PEGASUS-xsum\cite{zhang2019pegasus}. However, our system is not limited to only these text summarization models but can be expanded to any text summarization models. \autoref{fig:output_summaries} shows the summary of the generated document with these deep summarizers. \begin{figure}[htp] \subfigure[System summary from PEGASUS-cnn-dailymail]{% \includegraphics[width=\linewidth]{summaries/pegasus-cnn-dm.jpeg}% } \subfigure[System summary from PEGASUS-xsum]{% \includegraphics[width=\linewidth]{summaries/pegasus-xsum.jpeg}% } \subfigure[System summary from BART-large-cnn]{% \includegraphics[width=\linewidth]{summaries/bart-cnn-dm.jpeg}% } \subfigure[System summary from BART-large-xum]{% \includegraphics[width=\linewidth]{summaries/bart-xsum.jpeg}% } \caption{Output summaries of the synthetic document from the deep summarization models} \label{fig:output_summaries} \end{figure} \subsection{Fact Extractor} With a system generated summary, we utilize dependency parsing from Spacy\cite{spacy2} and extract facts from the summary based on the same factual relations used to represent facts in the text. \subsection{Evaluator} Given the table of facts in the source document and that of those in the summary, we measured the factual consistency, comprehensiveness, and compression rate. To find the overlaps between a source document and its abstractive summary, we checked if two nouns or verbs are synonyms or antonyms or how similar their senses are using wordnet. Also, since wordnet doesn't support the similarity measurement between adjectives or adverbs, we used glove word embeddings to measure their relatedness. Factual consistency is the fraction of the facts in the summary that are correct. Correctness means that they also appear in the source. The facts in the summary contain both intrinsic and extrinsic factually inconsistent facts. \begin{equation} Factual\ Consistency = \frac{|\textrm{source-summary\ facts\ overlap}|}{|\textrm{facts\ in\ summary}|} \end{equation} and, comprehensiveness is the fraction of the facts in the summary that also appear in the source document. \begin{equation} Comprehensiveness = \frac{|\textrm{source-summary\ facts\ overlap}|}{|\textrm{facts\ in\ source}|} \end{equation} Compression rate is defined as introduced in \cite{napoles-etal-2011-evaluating}: \begin{equation} Compreesion\ rate = \frac{|\textrm{tokens\ in\ summary}|}{|\textrm{tokens\ in\ source}|} \times 100 \end{equation} \section{Discussion} In this section, we discuss the strengths and limitations of our system compared to existing evaluation systems/metrics and the reasoning behind choosing three different evaluation criteria: factual consistency, comprehensiveness, and compression rate in evaluating the text summarization models. Since we create synthetic documents, we have a natural interpretability and control in understanding and extracting facts in the documents. For example, in these two sentences: \textit{"A woman is 44 years old. A woman is killed"}, it is extremely difficult to predict that the woman is the same entity with the deep learning as they are ambiguous; however, our system can handle this issue as we generate the text based on the facts of \textit{(woman, 44 years old) and (woman, killed)}. Another strength of our system is that it considers the partial facts. For example, in a given sentence of \textit{"A man is described wearing a blue jacket and black jeans."}, our system both considers two partial facts: \textit{"A man is wearing a blue jacket."} and \textit{"A man is wearing black jeans."} and measure its quality accordingly. However, our system is limited in matching implicit facts that appear differently in the source document and its summary. For example, considering these \textit{(subject, verb)} facts in \textit{"A woman is stabbed"} and \textit{"A woman is injured"}, even though \textit{(woman, injured)} implies \textit{(woman, injured)} to be true, it is extremely difficult to systematically describe that they are the same facts. Our system considers three different criteria: factual consistency, comprehensiveness, and compression rate in evaluating the text summarization models because they are the crucial standards that a good summary should have. The goal of summarization is to produce a shorter text that captures the overall meaning of the source document. In this context, if the summary is not factually consistent or comprehensive, then its quality should be measured poorly. Also, even though the summary is comprehensive, it should be scored less if it is not much shorter than the source document – if the summary is exactly same as the source document, it should be penalized. Therefore, we utilized these three criteria to measure the quality of the system summaries generated from deep text summarization models. Overall, our system describes the promising results as a new text evaluation metric system. \section{Acknowledgements} The authors thank professors Franz Kurfess, Alex Dekhtyar, and Stuart Russell for their valuable thoughts on this project. \bibliographystyle{plain}
{'timestamp': '2022-04-12T02:32:40', 'yymm': '2204', 'arxiv_id': '2204.04869', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04869'}
arxiv
\section{Introduction} \label{sec:intro} Image denoising is a fundamental and crucial task that is always used in the other high-level computer vision program as the front steps, receiving the attention of the academic circles. The main challenge in this task is to recover the clean image from the noisy image, and the problem can be modeled as: \begin{eqnarray} y &=& x+n \end{eqnarray} Where x, y, and n represent the clean image, noisy image, and noise matrix, respectively. Previous denoising methods can be divided into two mainstreams, and one is the traditional algorithm, which usually uses hypothetical prior information to address the problem, such as BM3D and NLM. Following the development of deep learning, Methods based on the CNN and Transformer architecture use the amount of clean-noisy training pairs to acquire the implicit noise distribution and image priors for denoising. Recently, the Transformer-based methods have been used in many vision tasks and acquired notable performance due to advantages in long-distance dependent information. Combining the advantages of the CNN-based method in local representations and the Transformer-based methods in long-distance dependent information to restore high-quality and detailed images becomes a vital issue. \begin{figure} \centering \includegraphics[width=1\linewidth]{ST.pdf} \caption{Overview of our SUMD architecture,containing two stages. We adopt CSFF and SAM modules from MPRNet~\cite{MPRNet}.} \label{fig:ST} \end{figure} This paper proposes SUMD, an efficient CNN-based architecture, to combine the advantages of the two methods mentioned in the previous paragraph for image denoising. We introduce the MD module to acquire the global context information to achieve these goals. Specifically, we reconstructed the low-rank information from the image to replace the long-distance dependent information extracted from the image. The MD module uses the non-negative matrix factorization method to reconstruct structural information, where the decomposition process uses the "one-step gradient" method to optimize named in ~\cite{MD}. At the same time, the parameters are initialized with a normal distribution and do not need to be saved that reduces a significant number of parameters. In order to further improve the low-rank global feature, we adopt the multi-stage progressive denoising strategy and build a relative global context feature within the current stage with different patch sizes through MD. Thereby the SUMD gradually denoises the more accurate images. Other denoising methods use the input patch to participate in the training process and add the image pyramid to obtain high-level information. The SUMD needs the high-level features and extracts the globally relative information using the non-overlapping patches as input. For example, their global feature representations are also different, with an image containing two independent objects(e.g., hands and T-shirt). It is evident that directly constituting the low-rank global representation will not pay attention to every detail for every object that appeared in the input and generate uncertain errors. Therefore, as mentioned earlier, while introducing multiple stages, the network at different stages is also focused on constructing global features at all levels in different scopes to achieve the goal of gradual recovery. Each stage of our SUMD is built upon Unet~\cite{Unet} and keeps the same hierarchical encoder-decoder structure and the skip-connection with add MD module. It guarantees global context information and avoids the shortcomings of Transformer-based methods that cannot effectively use the local features. It should be noted that for low-level vision tasks, local features play a vital role in the final denoising of the image. Overall, we summarize the contributions of this paper included: \begin{itemize} \item we propose SUMD, an effective and efficient multi-stage progressive network for image denoising. \item we assume the global context features as the low-rank information and utilize the matrix decomposition method to reconstruct it to further eliminate the interference of noise on the feature representation. The matrix decomposition approach is capable of acquiring the contextually-enriched and globally structured outputs. \item SUMD achieves state-of-the-art performance or comparable performance in both PSNR and SSIM indicators on many popular benchmarks. \end{itemize} \section{related work} \textbf{Traditional Methods} Traditional noise reduction algorithms have been a hot topic in the academic community in the past few decades. It has also promoted the development of methods based on deep learning in recent years. Previous work mainly used the prior hypothesis of the image or noise to design a model matching the hypothesis to perform the denoising program. Among them, the use of image prior includes sparse coding, non-local means, and the use of noise distribution assumptions includes AWGN denoiser. Although, these classical approaches have achieved good operating speed and accuracy results. However, the complexity and robustness of the traditional model are insufficient caused of the assumptions, and they cannot adapt to tasks in many situations. \noindent \textbf{Network architecture} The deep learning-based model implicitly captures prior information from the training on the amount of clean-noisy data pairs for image denoising. Depending on their outstanding performance on the generalization, DNN based model used in varieties of the complex practical environment with a single training. With the various assumptions and novel ideas, MLP, TNRD, DnCNN, RBDN, FFDNet, MIRNet are also developed with promising denoising performance. MPRNet~\cite{MPRNet} relied on the multi-stage progressive recovery strategy, through supervised attention module, cross-stage feature fusion module, and the state-of-the-art performance had been achieved in the fields of denoising, deblurring, and de-raining. Recently, the Transformer architecture has gradually been applied to the field of computer vision and has made outstanding contributions to the global feature representation of long-range dependence. The Uformer~\cite{Uformer}, a transformer-based model, achieves the best performance in the field of image denoising. However, because relative position embedding still cannot replace the accurate relative position information, the extraction of local features is still poor. \section{Method} \begin{figure*}[t] \centering \begin{center} \hfill \begin{minipage}[b]{.32\linewidth} \centering \includegraphics[width=1\linewidth]{HUS.pdf} \centerline{(a)}\medskip \end{minipage} \begin{minipage}[b]{.27\linewidth} \centering \includegraphics[width=1\linewidth]{ED.pdf} \centerline{(b)}\medskip \end{minipage} \begin{minipage}[b]{.18\linewidth} \centering \includegraphics[width=.9\linewidth]{BST.pdf} \centerline{(c)}\medskip \end{minipage} \begin{minipage}[b]{.19\linewidth} \centering \includegraphics[width=.9\linewidth]{MD.pdf} \centerline{(d)}\medskip \end{minipage} \end{center} \caption{(a) Top: The encoder block. Bottom: The decoder block. (b) The skip-connection between the encoder block and the decoder block. (c) BST Module (d) MD Module} \label{fig:components} \end{figure*} \begin{table*}[htpb] \centering \caption{The PSNR(dB) results of all competing methods on the three groups of test datasets. The best and second best results are highlighted in bold and Italic, respectively.} \label{tab:1} \begin{tabular}{cccccccccccc} \hline \multirow{2}{*}{Case} & \multirow{2}{*}{Datasets} & \multicolumn{8}{c}{Methods} \\ \cline{3-11} & & \multicolumn{1}{c}{CBM3D} & \multicolumn{1}{c}{DnCNN-B} & \multicolumn{1}{c}{MemNet} & \multicolumn{1}{c}{FFDNet} & \multicolumn{1}{c}{UDNet} & \multicolumn{1}{c}{VDN} & \multicolumn{1}{c}{NBNet} & \multicolumn{1}{c}{Uformer} & Ours \\ \hline \multirow{3}{*}{Case1} & Set5 & \multicolumn{1}{c}{27.76} & \multicolumn{1}{c}{29.85} & \multicolumn{1}{c}{30.10} & \multicolumn{1}{c}{30.16} & \multicolumn{1}{c}{28.13} & \multicolumn{1}{c}{30.39} & \multicolumn{1}{c}{\textit{30.59}} & \multicolumn{1}{c}{29.96} & \textbf{30.63} \\ \cline{2-11} & LIVE1 & \multicolumn{1}{c}{26.58} & \multicolumn{1}{c}{28.81} & \multicolumn{1}{c}{28.96} & \multicolumn{1}{c}{28.99} & \multicolumn{1}{c}{27.19} & \multicolumn{1}{c}{29.22} & \multicolumn{1}{c}{\textit{29.40}} & \multicolumn{1}{c}{29.36} & \textbf{29.52} \\ \cline{2-11} & BSD68 & \multicolumn{1}{c}{26.51} & \multicolumn{1}{c}{28.73} & \multicolumn{1}{c}{28.74} & \multicolumn{1}{c}{28.78} & \multicolumn{1}{c}{27.13} & \multicolumn{1}{c}{29.02} & \multicolumn{1}{c}{\textit{29.16}} & \multicolumn{1}{c}{28.76} & \textbf{29.22} \\ \hline \multirow{3}{*}{Case2} & Set5 & \multicolumn{1}{c}{26.34} & \multicolumn{1}{c}{29.04} & \multicolumn{1}{c}{29.55} & \multicolumn{1}{c}{29.60} & \multicolumn{1}{c}{26.01} & \multicolumn{1}{c}{29.80} & \multicolumn{1}{c}{\textit{29.88}} & \multicolumn{1}{c}{29.53} & \textbf{30.11} \\ \cline{2-11} & LIVE1 & \multicolumn{1}{c}{25.18} & \multicolumn{1}{c}{28.18} & \multicolumn{1}{c}{28.56} & \multicolumn{1}{c}{28.58} & \multicolumn{1}{c}{25.25} & \multicolumn{1}{c}{28.82} & \multicolumn{1}{c}{\textit{29.01}} & \multicolumn{1}{c}{29.00} & \textbf{29.14} \\ \cline{2-11} & BSD68 & \multicolumn{1}{c}{25.28} & \multicolumn{1}{c}{28.15} & \multicolumn{1}{c}{28.36} & \multicolumn{1}{c}{28.43} & \multicolumn{1}{c}{25.13} & \multicolumn{1}{c}{28.67} & \multicolumn{1}{c}{\textit{28.76}} & \multicolumn{1}{c}{28.48} & \textbf{28.88} \\ \hline \multirow{3}{*}{Case3} & Set5 & \multicolumn{1}{c}{27.88} & \multicolumn{1}{c}{29.13} & \multicolumn{1}{c}{29.51} & \multicolumn{1}{c}{29.54} & \multicolumn{1}{c}{27.54} & \multicolumn{1}{c}{29.74} & \multicolumn{1}{c}{\textit{29.89}} & \multicolumn{1}{c}{29.62} & \textbf{30.01} \\ \cline{2-11} & LIVE1 & \multicolumn{1}{c}{26.50} & \multicolumn{1}{c}{28.17} & \multicolumn{1}{c}{28.37} & \multicolumn{1}{c}{28.39} & \multicolumn{1}{c}{26.48} & \multicolumn{1}{c}{28.65} & \multicolumn{1}{c}{\textit{28.82}} & \multicolumn{1}{c}{28.71} & \textbf{28.93} \\ \cline{2-11} & BSD68 & \multicolumn{1}{c}{26.44} & \multicolumn{1}{c}{28.11} & \multicolumn{1}{c}{28.20} & \multicolumn{1}{c}{28.22} & \multicolumn{1}{c}{26.44} & \multicolumn{1}{c}{28.46} & \multicolumn{1}{c}{\textit{28.59}} & \multicolumn{1}{c}{28.38} & \textbf{28.66} \\ \hline \end{tabular} \end{table*} \subsection{Overview} As shown in Fig~\ref{fig:ST}, the proposed framework is composed of two horizontal stages while each stage consists of the U-shaped encoder-decoder structure. The MD module is assimilated into the Encoder/Decoder block, and the basic design of the original Unet~\cite{Unet} architecture is modified to adapt to the requirement of denoising tasks. Then, the original noisy image is divided into multiple non-overlapping patches as the input in different stages. However, unlike the image pyramid, the input maintains the original resolution, which makes this stage pay more attention to the information within the patch. It facilitates the MD module to construct the relative global feature map. Between the two neighbor stages, we use the supervised attention module(SAM) and cross-stage feature fusion module(CSFF), where these two modules come from~\cite{MPRNet}. Specifically, given a noisy image $I \in R ^ {3 \times H \times W}$ at a certain stage, the SUMD extracts a low-level feature map $ F_{in} \in R ^ {C \times H \times W} $ through the initial block composed of a combination of a $ 3 \times 3 $ convolution and the PReLU stacking two blocks. Subsequently, the low-level features are delivered to the horizontal U-shaped structure to extract information from different scales gradually and then restored to the original resolution by degrees to obtain the decoded feature map $ F_{out} \in R ^ {C \times H \times W} $. The feature of the upper decoder in each stage is processed by the SAM module and then merged into the initial feature map of the next stage. The remaining encoder/decoder features of each scale will be adjusted by the CSFF module and incorporated into encoder/decoder features of the next stage. After the multi-stage processing, we apply a $ 3 \times 3 $ convolution on final decoder feature of the last stage to obtain a residual image $ F_{R} \in R ^ {3 \times H \times W} $. Finally, the denoising image is obtained by $I_{out} = I_{in}+F_{R}$. \subsection{Horizontal U-shaped structure} To meet the needs of the denoising task, we modified the components of the Unet~\cite{Unet} to boost the whole framework more efficient and simplified that illustrated in Fig~\ref{fig:components}(a). Above all, we utilize a channel attention block in~\cite{CABS} to weight the initial feature map $ F_{in} \in R ^ {C \times H \times W} $ with the channel self-attention mechanism for offering the channel information to promote the function of the MD module. Then, the weighted feature input to the MD module to extract the relative global low-rank structural features. The channel attention module and MD module form a basic encoder block and apply in the encoder part of each scale. Following the encoder block, we use a $4 \times 4$ convolution with stride 2 to down-sample the feature maps and increase the number of channels. For example, given the upper input feature $F_{0} \in R^{C_{in} \times H \times W}$, the $k$-th scale of the encoder produces the feature maps $F_{k} \in R^{(C_{in}+k \times C_{up})},k=0,1,2$. In order to effectively extract high-level context features, we set three scales for the image pyramid. For the skip-connection between the encoder and the decoder at the same scale shown in Fig~\ref{fig:components}(b), we adopt stacked basic structure blocks(BST) shown in Fig~\ref{fig:components}(c) to further process features and maintain the details. For the image decoder, in addition to the features of the bottom scale that are direct as the input, the decoder block will not only receive the feature map refined by the skip-connection, but also the feature map of the previous scale will be up-sampled using $2 \times 2$ deconvolution with stride 2. The up-sampled feature decreases the channels and doubles the size of the feature maps. Unlike the encoder block, we switch the position of the channel attention block and the MD module, which stimulate the relative global feature selectively, to obtain better performance. \begin{figure*}[t] \centering \begin{center} \hfill \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_noisy.png} \centerline{18.25 dB} \centerline{Noisy} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_VDN.png} \centerline{36.39 dB} \centerline{VDN} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_CycleISP.png} \centerline{36.72 dB} \centerline{CycleISP} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_MPRNet.png} \centerline{36.98 dB} \centerline{MPRNet} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_MIRNet.png} \centerline{36.97 dB} \centerline{MIRNet} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_Uformer.png} \centerline{36.89 dB} \centerline{Uformer} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_SUMD.png} \centerline{37.11 dB} \centerline{Ours} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{S_reference.png} \centerline{} \centerline{Reference} \end{minipage} \quad \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_Noisy.png} \centerline{} \centerline{Noisy} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_VDN.png} \centerline{32.09 dB} \centerline{VDN} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_CycleISP.png} \centerline{32.27 dB} \centerline{CycleISP} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_MPRNet.png} \centerline{32.63 dB} \centerline{MPRNet} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_MIRNet.png} \centerline{32.54 dB} \centerline{MIRNet} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_NBNet.png} \centerline{33.27 dB} \centerline{NBNet} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_Uformer.png} \centerline{33.04 dB} \centerline{Uformer} \end{minipage} \begin{minipage}[b]{.12\linewidth} \centering \includegraphics[width=.9\linewidth]{D_SUMD.png} \centerline{33.70 dB} \centerline{Ours} \end{minipage} \end{center} \caption{Visual results from SIDD and DND datasets. Top row: sample from the SIDD datasets. Bottom row: sample from the DND datasets. Our results preserve the details and reconstruct the textures.} \label{fig:display} \end{figure*} \subsection{Matrix Decomposition Module} Matrix decomposition is to factorize a matrix into the product of several sub-matrices. The helpful information is usually assumed as low-rank information for a noisy image and could be factorized into the low-rank matrix and the noise matrix using matrix decomposition. For the CNN-based denoising method, the convolution has pretty performance in capturing local features, but tough to construct the global feature maps limited by the convolution kernel size and receptive field. Therefore, the characteristic information obtained after matrix decomposition perfectly complements the convolution. The formula of the matrix decomposition can be expressed as: \begin{eqnarray} I_{n} &=& I_{l} + N = DC + N \end{eqnarray} where $I_{n},I_{l},N \in R^{d \times hw}$ are the noisy image, the low-rank reconstruction and the noisy matrix, respectively. Among them, the factor of $I_l$ can be expressed as the product of the dictionary matrix $D \in R^{d \times r}$ and the corresponding codes $C\in R^{r\times hw}$,$h,w$ is the height and the width of input features. The MD module is composed of preprocessing and matrix decomposition, shown in Fig~\ref{fig:components}(d). We use the BST to process the input features further to adapt to the matrix decomposition program as the pre-component. We firstly shallow the channel from the $F_{in}$ to $F_d$. Then, using a series of linear transformations consisting of the $1\times 1$ convolution and ReLU activation, we map the output of the preprocessing to split the $F_d$ into the $k$ subspaces of the features following the assumption that a union of multiple subspaces is hidden in $I_{l}$. After that, we utilize the Multiplicative Update rules~\cite{MUR} to solve the non-negative matrix factorization(NMF)~\cite{NMF}, decomposing and reconstructing the features. During the optimization step, we apply the one-step gradient to conquer the gradient vanishing, or gradient explosion described in~\cite{MD}. After that, we concat each decomposed feature and put it into another $1\times 1$ convolution to recover the original channels. The whole process can be expressed as: \begin{align} & F_k = W_kF_{in}, k=1,...,K \nonumber \\ & D_k = MD(F_k), k=1,...,K \\ & F_{out}= W_{out}(Concat(D_1,...,D_k)), k=1,...,K \nonumber \end{align} where $F_{in} \in R^{C_{in} \times h \times w}$, $W_k \in R^{C_{mid} \times C_{in}}$ represents the input feature and the linear transformation for the $k$-th subspace, respectively. MD is the process of matrix decomposition. The input feature of the MD should be flattened along the H, W dimension. The $D_k \in R^{C_{mid} \times hw}$ of sub results are concated and then be transformed by the $W_{out} \in R^{C_{out} \times C_{mid \times K}}$. The $F_{out}$ is the reconstructed feature of the MD module. \section{Experiments} \begin{table*}[htpb] \centering \caption{The PSNR(dB) result of all competing methods on AWGN noise cases of three test datasets. The best and second best results are highlighted in bold and Italic, respectively.} \label{tab:2} \begin{tabular}{ccccccccccc} \hline \multirow{2}{*}{Case} & \multirow{2}{*}{Datasets} & \multicolumn{9}{c}{Methods} \\ \cline{3-11} & & \multicolumn{1}{c}{CBM3D} & \multicolumn{1}{c}{DnCNN-B} & \multicolumn{1}{c}{MemNet} & \multicolumn{1}{c}{FFDNet} & \multicolumn{1}{c}{UDNet} & \multicolumn{1}{c}{VDN} & \multicolumn{1}{c}{NBNet} & \multicolumn{1}{c}{Uformer} & Ours \\ \hline \multirow{3}{*}{$\sigma$=15} & Set5 & \multicolumn{1}{c}{33.42} & \multicolumn{1}{c}{34.04} & \multicolumn{1}{c}{34.18} & \multicolumn{1}{c}{34.30} & \multicolumn{1}{c}{34.19} & \multicolumn{1}{c}{34.34} & \multicolumn{1}{c}{\textit{34.64}} & \multicolumn{1}{c}{34.32} & \textbf{34.74} \\ \cline{2-11} & LIVE1 & \multicolumn{1}{c}{32.85} & \multicolumn{1}{c}{33.72} & \multicolumn{1}{c}{33.84} & \multicolumn{1}{c}{33.96} & \multicolumn{1}{c}{33.74} & \multicolumn{1}{c}{33.94} & \multicolumn{1}{c}{\textit{34.25}} & \multicolumn{1}{c}{34.11} & \textbf{34.38} \\ \cline{2-11} & BSD68 & \multicolumn{1}{c}{32.67} & \multicolumn{1}{c}{33.87} & \multicolumn{1}{c}{33.76} & \multicolumn{1}{c}{33.85} & \multicolumn{1}{c}{33.76} & \multicolumn{1}{c}{33.90} & \multicolumn{1}{c}{\textit{34.15}} & \multicolumn{1}{c}{33.88} & \textbf{34.24} \\ \hline \multirow{3}{*}{$\sigma$=25} & Set5 & \multicolumn{1}{c}{30.92} & \multicolumn{1}{c}{31.88} & \multicolumn{1}{c}{31.98} & \multicolumn{1}{c}{32.10} & \multicolumn{1}{c}{31.82} & \multicolumn{1}{c}{32.24} & \multicolumn{1}{c}{\textit{32.51}} & \multicolumn{1}{c}{32.13} & \textbf{32.60} \\ \cline{2-11} & LIVE1 & \multicolumn{1}{c}{30.05} & \multicolumn{1}{c}{31.23} & \multicolumn{1}{c}{31.26} & \multicolumn{1}{c}{31.37} & \multicolumn{1}{c}{31.09} & \multicolumn{1}{c}{31.50} & \multicolumn{1}{c}{\textit{31.73}} & \multicolumn{1}{c}{31.65} & \textbf{31.86} \\ \cline{2-11} & BSD68 & \multicolumn{1}{c}{29.83} & \multicolumn{1}{c}{31.22} & \multicolumn{1}{c}{31.17} & \multicolumn{1}{c}{31.21} & \multicolumn{1}{c}{31.02} & \multicolumn{1}{c}{31.35} & \multicolumn{1}{c}{\textit{31.54}} & \multicolumn{1}{c}{31.24} & \textbf{31.61} \\ \hline \multirow{3}{*}{$\sigma$=50} & Set5 & \multicolumn{1}{c}{28.16} & \multicolumn{1}{c}{28.95} & \multicolumn{1}{c}{29.10} & \multicolumn{1}{c}{29.25} & \multicolumn{1}{c}{28.87} & \multicolumn{1}{c}{29.47} & \multicolumn{1}{c}{\textit{29.70}} & \multicolumn{1}{c}{28.98} & \textbf{29.74} \\ \cline{2-11} & LIVE1 & \multicolumn{1}{c}{26.98} & \multicolumn{1}{c}{27.95} & \multicolumn{1}{c}{27.99} & \multicolumn{1}{c}{28.10} & \multicolumn{1}{c}{27.82} & \multicolumn{1}{c}{28.36} & \multicolumn{1}{c}{\textit{28.55}} & \multicolumn{1}{c}{28.42} & \textbf{28.67} \\ \cline{2-11} & BSD68 & \multicolumn{1}{c}{26.81} & \multicolumn{1}{c}{27.91} & \multicolumn{1}{c}{27.91} & \multicolumn{1}{c}{27.95} & \multicolumn{1}{c}{27.76} & \multicolumn{1}{c}{28.19} & \multicolumn{1}{c}{\textit{28.35}} & \multicolumn{1}{c}{27.78} & \textbf{28.40} \\ \hline \end{tabular} \end{table*} \begin{table*}[htpb] \centering \caption{Denoising results on the SIDD and DND datasets.} \label{tab:3} \begin{tabular}{cccccccccccc} \hline Datasets & Method & BM3D & CBDNet & RIDNet & VDN & DANet & MPRNet & MIRNet & NBNet & Uformer & ours \\ \hline \multirow{2}{*}{SIDD} & PSNR & 25.65 & 30.76 & 38.71 & 39.28 & 39.47 & 39.71 & 39.72 & 39.75 & \textit{39.77} & \textbf{39.77} \\ \cline{2-12} & SSIM & 0.685 & 0.754 & 0.914 & 0.909 & 0.918 & 0.958 & 0.959 & 0.959 & \textit{0.959} & \textbf{0.959} \\ \hline \multirow{2}{*}{DND} & PSNR & 34.51 & 38.06 & 39.26 & 39.38 & 39.59 & 39.80 & 39.88 & \textit{39.89} & \textbf{39.96} & 39.86 \\ \cline{2-12} & SSIM & 0.851 & 0.942 & 0.953 & 0.952 & 0.955 & 0.954 & 0.956 & \textit{0.955} & \textbf{0.956} & 0.955 \\ \hline \end{tabular} \end{table*} \subsection{Training details} The proposed architecture adopts the end-to-end strategy during the training process and requires no extra component for pre-training. In the experiment, we use 2 stage horizontal U-shaped structures as a fundamental model and set the initial channel number as 128. After upsampling or downsampling in the image pyramid, the number of channels will increase or decrease by 48. In the MD module, we set the $F_{d}$ to 3/4 $F_{in}$, the number of subspace $k$ as 2, and $r=\sqrt{hw}/l,l=1,2,3$, $l$ is the level of the Horizontal U-shaped structure. We use the Charbonnier loss to train our model, the formula as : \begin{equation} \mathcal{L}(D,\textbf{\textit{x}},\textbf{\textit{y}})= \sqrt{\left\| D(\textbf{\textit{x}})-\textbf{\textit{y}} \right\| ^2 + \epsilon ^2}, \end{equation} where $\textbf{\textit{x}},\textbf{\textit{y}},D(\cdot)$ represent noisy image, clean image and SUMD, respectively. In the training phase, we use Adam optimizer with the momentum term (0.9,0.999) and the weight decay of $1e-8$. At the same time, set the initial learning rate to $2 \times 10^{-4}$ gradually reduced to $1 \times 10^{-6}$ with the cosine annealing. We crop the patches of size $128 \times 128$ from the training pairs as a sample with a batch size of 32 for 300K iterations. We augment the training sample with random horizontal flip and random rotation with $90^{\circ} \times k, k=1,2,3$. \subsection{Synthetic Gaussian denosing} Following the~\cite{VDN,nbnet}, we use the same experimental setup, in which the training samples are part of BSD, ImageNet validation datasets, Waterloo Exploration Database. The validation test datasets are composed of Set5, LIVE1, and BSD68. In the generation of the noise data, we are consistent with the method in~\cite{VDN,nbnet} to facilitate fair comparison. We generate four noise masks, one of which is used for training and the other three types used for testing. The specific non-$i.i.d.$ Gaussian noise generation formula is as follows: \begin{eqnarray} \textbf{\textit{n}} &=& \textbf{\textit{n}}^1 \odot \textbf{\textit{M}} , n^1_{ij} \sim \mathcal{N}(0,1), \end{eqnarray} where $\textbf{\textit{M}}$ is a spatially variant mask. We can demonstrate the denoising results for multiple types of synthetic Gaussian noise under the training of a category of noise data. Table~\ref{tab:1} lists the denoising performance of 4 types of non-$i.i.d.$ Gaussian noise and compares them with the previous methods. From the table~\ref{tab:1}, our algorithm exceeds the previous arithmetic VDN~\cite{VDN} and NBNet~\cite{nbnet} and acquires an average improvement of more than 0.1 dB on the PSNR compared with the NBNet in every test case. Table~\ref{tab:2} illustrates the PSNR results in the scene of additive white Gaussian noise(AWGN) and accomplishes the better performance(average increase of 0.1 dB). Our method uses the MD module to reconstruct the context features without prior noise data distribution gradually. On the one hand, it separates the signal and the noise. On the other hand, it also makes the recovery of the detailed information of the image more accurate within the relative ranges. \subsection{Real Image denoising} \textbf{SIDD Dataset} To justify that our model is competent for real noise scenarios, we use the SIDD~\cite{SIDD}, a commonly used mobile phone real-noise benchmark, to evaluate the performance. We use 320 high-resolution images to train our model and evaluate the performance of the 1280 validation patches offered by the SIDD. We compare with the previous methods, such as VDN~\cite{VDN}, MPRNet~\cite{MPRNet}, MIRNet, NBNet~\cite{nbnet} and Uformer\cite{Uformer}, and quantitatively demonstrated the denoising capacity of various models in Table 3. We achieve the comparable performance of 39.77 dB with Uformer on PSNR and surpass the other methods at least 0.02 dB. In addition, we also provide a visual denoising comparison example from different models in the top row of Fig~\ref{fig:display}. \noindent \textbf{DND Dataset} We further utilize the DND~\cite{DND} datasets to demonstrate the capability of our model. Unlike the NBNet training strategy, we only train the model on the SIDD training set and directly use the best model from the SIDD, evaluating the performance on the DND benchmark that contained 1000 patches for testing. We present the visual comparisons of our results with the other state-of-the-art methods in Fig~\ref{fig:display}, and our model obtains 39.86 dB shown in Table~\ref{tab:3}, the comparable results without using any extra datasets. For instance, our method achieves 0.66 dB improvement over Uformer on DND. \begin{table}[htpb] \centering \caption{Ablation study on MD and other modules of the proposed in SUMD.} \label{tab:4} \begin{tabular}{ccc} \hline \#Stages & Stage Combination & PSNR \\ \hline 2 & Unet & 39.56 \\ 2 & Unet+HUS & 39.73 \\ 2 & Unet+HUS+MD & 39.77 \\ \hline 1 & Unet+HUS+MD & 39.68 \\ \hline \end{tabular} \end{table} \begin{table}[htpb] \centering \caption{Effect of the middle dimension of the MD module. The rate represents the original dimensions proportioned to the middle dimensions.} \label{tab:5} \begin{tabular}{cccccc} \hline ratio & w/o & 1:4 & 2:4 & 3:4 & 4:4 \\ \hline PSNR & 39.49 & 39.55 & 39.58 & 39.60 & 39.55 \\ \hline \end{tabular} \end{table} \subsection{Ablation Studies} \textbf{Multi-stages with MD Module} To demonstrate the performance of our MD module and HUS structure, we test each component on the various network settings. Table~\ref{tab:4} shows that the HUS merged into Unet has improved the 0.17 dB higher than the simple Unet structure in 2 stages on PSNR. Then, we compare our regular version to the model that replaced the MD module with a BST to keep a fair comparison. The results demonstrate a substantial drop in PSNR from 39.77 dB to 39.73 dB when we remove the MD module. From Table~\ref{tab:4}, we can also justify the effectiveness of the multi-stages architecture in our model. Compared with the single-stage and the two stages design. The PSNR has improved from 39.68 dB to 39.77 dB. \noindent \textbf{Integrated into simple Unet with HUS} In order to examine the performance of the design on a simple CNN denoising model, We shallow the channels from 128 to 80 and test the model with different middle dimensions on a single-stage Unet with HUS structure. In Table~\ref{tab:5}, We notice that the CNN with MD module can achieve about 0.1 dB higher than the w/o MD module. \noindent \textbf{Influence about the reducing rate} In Table~\ref{tab:5}, We also explore the appropriate K, a reducing rate of the middle dimensions of the MD module, boosting our model achieving the best performance. It is evident that when we set the rate k between 1/2 and 3/4, the MD can realize a low-ranked, compact, and representative feature to tackle the shortcoming of the CNN-based model that lacks global information. \section{Conclusion} In this work, we present a multi-stage progressive CNN-based model with the MD module to tackle the problem of global feature extraction. To compare with the Transformer long-distance dependent feature, we assume that the low-ranked features can substitute the global features and achieve comparable performance. In order to boost the MD module, we also adopt the multi-stages design that can limit the receptive field in a definite scope on the current stage and the channel attention block to weight feature from the different channels for promoting the critical feature maps decided in the final process. We also believe that how to utilize the MD module to extract the global feature will be a vital issue that can facilitate the CNN model to acquire the global structured features. \bibliographystyle{IEEEbib}
{'timestamp': '2022-04-12T02:32:08', 'yymm': '2204', 'arxiv_id': '2204.04861', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04861'}
arxiv
\section{Introduction} This paper combines four lines of research: (a) studying variations of domination problems, here the Roman domination~\cite{Cocetal2004,Dre2000a,HHS98}; (b) input-sensitive enumeration of minimal solutions, a topic that has drawn attention in particular from people also interested in domination problems \cite{AbuHeg2016,CouHHK2013,CouLetLie2015,GolHKKV2016,GolHegKra2016}; (c) related to (and motivated by) enumeration, extension problems have been introduced and studied in particular in the context of domination problems\footnote{Historically, a logical extension problem~\cite{BorGurHam98} should be mentioned, as it has led to \cite[Th\'eor\`eme 2.16]{Mar2013a}, dealing with an extension variant of 3-\textsc{Hitting Set}; also see \cite[Proposition 3.39]{Mar2013a} concerning implications for \textsc{Extension Dominating Set}.} in \cite{Bazetal2018,BonDHR2019,CasFKMS2019a,CasFGMS2021,KanLMNU2015,KanLMNU1516,Mar2013a}: is a given set a subset of any minimal dominating set?; (d) the \textsc{Hitting Set Transversal Problem} is the question if all minimal hitting sets of a hypergraph can be enumerated with polynomial delay (or even output-polynomial) only: this question is open for four decades by now and is equivalent to several enumeration problems in logic, database theory and also to enumerating minimal dominating sets in graphs, see \cite{CreKPSV2019,EitGot95,GaiVer2017,KanLMN2014}. By way of contrast, we show that enumerating all minimal Roman domination functions is possible with polynomial delay, a result which is quite surprising in view of the general similarities between the complexities of domination and Roman domination problems. \begin{figure}[bth] \begin{center} \includegraphics[width=.65\textwidth]{Roman-mymap.pdf} \end{center} \caption{\label{fig-Roman-map}The Roman Empire in the times of Constantine} \end{figure} \textsc{Roman Domination}\ comes with a nice (hi)story: namely, it should reflect the idea of how to secure the Roman Empire by positioning the armies (legions) on the various parts of the Empire in a way that either (1) a specific region $r$ is also the location of at least one army or (2) one region $r'$ neighboring $r$ has two armies, so that $r'$ can afford sending off one army to the region $r$ (in case of an attack) without diminishing self-defense capabilities. More specifically, Emperor Constantine had a look at a map of his empire (as discussed in~\cite{Ste99}, also see Fig.~\ref{fig-Roman-map}).\footnote{ The historical background is also nicely described in the online Johns Hopkins Magazine, visit \url{http://www.jhu.edu/~jhumag/0497web/locate3.html} to pre-view~\cite{ReVRos2000}.} Related is the island hopping strategy pursued by General MacArthur in World War II in the Pacific theater to gradually increase the US-secured areas. \textsc{Roman Domination}\ has received a lot of attention from the algorithmic community in the past 15 years~\cite{Ben2004,ChaCCKLP2013,Dre2000a,Fer08,Lie2007,Lieetal2008,LiuCha2013,Pagetal2002,PenTsa2007,ShaWanHu2010}. Relevant to our paper is the development of exact algorithms for \textsc{Roman Domination}: combining ideas from \cite{Lie2007,Roo2011}, an $\mathcal{O}(1.5014^n)$ exponential-time and -space algorithm (making use of known \textsc{Set Cover} algorithms via a transformation to \textsc{Partial Dominating Set}) was presented in~\cite{ShiKoh2014}. In \cite{Chaetal2009,CheHHHM2016,Favetal2009,HedRSW2013,KraPavTap2012,LiuCha2012,LiuCha2012a,MobShe2008,XinCheChe2006,XueYuaBao2009,YerRod2013a}, more combinatorial studies can be found. This culminated in a chapter on Roman domination, stretching over nearly 50 pages in the monograph~\cite{HayHedHen2020}. There is also an interesting link to the notion of a \emph{differential} of a graph, introduced in~\cite{Masetal2006}, see \cite{BerFerSig2014}, also adding further algorithmic thoughts, as expressed in \cite{AbuBCF2016,BerFer2014,BerFer2015}. For instance, in~\cite{BerFer2014} an exponential-time algorithm was published, based on a direct Measure-and-Conquer approach. One of the ideas leading to the development of the area of \emph{extension problems} (as described in~\cite{CasFGMS2021}) was to cut branches of search trees as early as possible, in the following sense: to each node of the search tree, a so-called pre-solution~$U$ can be associated, and it is asked if it is possible to extend $U$ to a meaningful solution~$S$. In the case of \textsc{Dominating Set}, this means that $U$ is a set of vertices and a `meaningful solution' is an inclusion-wise minimal dominating set. Notice that such a strategy would work not only for computing smallest dominating sets, but also for computing largest minimal dominating set, or for counting minimal solutions, or for enumerating them. Alas, as it has been shown by many examples, extension problems turn out to be quite hard problems. Even for combinatorial problems whose standard decision version is solvable in polynomial time (for instance, \textsc{Edge Cover}), its extension variation is \textsf{NP}-hard. In such a case, the approach might still be viable, as possibly parameterized algorithms exist with respect to the parameter `pre-solution size'. This would be interesting, as this parameter is small when a big gain can be expected in terms of an early abort of a search tree branch. In particular for \textsc{Extension Dominating Set}, this hope is not fulfilled. To the contrary, with this parameterization $|U|$, \textsc{Extension Dominating Set}\ is one of the few problems known to be complete for the parameterized complexity class \textsf{W}[3], as shown in~\cite{BlaFLMS2019}. With an appropriate definition of the notion of minimality, \textsc{Roman Domination}\ becomes one of the few examples where the hope seeing extension variants being efficiently solvable turns out to be true, as we will show in this paper. This is quite a surprising result, as in nearly any other way, \textsc{Roman Domination}\ behaves most similar to \textsc{Dominating Set}. Together with its combinatorial foundations (a characterization of minimal Roman domination functions), this constitutes the first main result of this paper. The main algorithmic exploit of this result is a non-trivial polynomial-space enumeration algorithm for minimal Roman domination functions that guarantees polynomial delay only, which is the second main result of the paper. As mentioned above, the corresponding question for enumerating minimal dominating sets is open since decades, and we are not aware of any other modification of the concept of domination that seems to preserve any other of the difficulties of \textsc{Dominating Set}, like classical or parameterized or approximation complexities, apart from the complexity of extension and enumeration. Our enumeration algorithm is a branching algorithm that we analyzed with a simple Measure \& Conquer approach, yielding a running time of $\mathcal{O}(1.9332^n)$, which also gives an upper bound on the number of minimal Roman dominating functions of an $n$-vertex graph. This result is complemented by a simple example that proves a lower bound of $\Omega(1.7441^n)$ for the number of minimal Roman dominating functions on graphs of order~$n$. \section{Definitions} Let $\mathbb{N}=\{1,2,3,\dots\}$ be the set of positive integers. For $n\in\mathbb{N}$, let $[n]=\{m\in\mathbb{N}\mid m\leq n\}$. We only consider undirected simple graphs. Let $G=\left(V,E\right)$ be a graph. For $U\subseteq V$, $G[U]$ denotes the graph induced by~$U$. For $v\in V$, $N_G(v)\coloneqq\{u\in V\mid \lbrace u,v\rbrace\in E\}$ denotes the \emph{open neighborhood} of~$v$, while $N_G[v]\coloneqq N_G(v)\cup\{v\}$ is the \emph{closed neighborhood} of~$v$. We extend such set-valued functions $X:V\to 2^V$ to $X:2^V\to 2^V$ by setting $X(U)=\bigcup_{u\in U}X(u)$. Subset $D\subseteq V$ is a \emph{dominating set}, or ds for short, if $N_G[D]=V$. For $D\subseteq V$ and $v\in D$, define the \emph{private neighborhood} of $v\in V$ with respect to~$D$ as $P_{G,D}\left( v\right)\coloneqq N_G\left[ v\right] \setminus N_G\left[D\setminus \lbrace v\rbrace\right]$. A function $f\colon V \to \lbrace 0,1,2 \rbrace$ is called a \emph{Roman dominating function}, or rdf for short, if for each $v\in V$ with $f\left(v\right) = 0$, there exists a $u\in N_G\left( v \right)$ with $f\left(u\right)=2$. To simplify the notation, we define $V_i\left(f\right)\coloneqq \lbrace v\in V\mid f\left( v\right)=i\rbrace$ for $i\in\lbrace0,1,2\rbrace$. The \emph{weight} $w_f$ of a function $f\colon V \to \lbrace 0,1,2 \rbrace$ equals $|V_1\left(f\right)|+2|V_2\left(f\right)|$. The classical \textsc{Roman Domination}\ problem asks, given $G$ and an integer $k$, if there exists an rdf for~$G$ of weight at most~$k$. Connecting to the original motivation, $G$ models a map of regions, and if the region vertex~$v$ belongs to~$V_i$, then we place $i$ armies on~$v$. For the definition of the problem \textsc{Extension Roman Domination}, we need to define the order $\leq$ on $\lbrace 0,1,2\rbrace^{V}$ first: for $f,g \in \lbrace 0,1,2\rbrace^{V}$, let $f\leq g$ if and only if $f\left(v\right)\leq g\left(v\right)$ for all $v\in V$. In other words, we extend the usual linear ordering $\leq$ on $\{0,1,2\}$ to functions mapping to $\{0,1,2\}$ in a pointwise manner. We call a function $f\in \lbrace 0,1,2\rbrace^{V}$ a \emph{minimal Roman dominating function} if and only if $f$ is a rdf and there exists no rdf $g$, $g\neq f$, with $g\leq f$.\footnote{According to \cite{HayHedHen2020}, this notion of minimality for rdf was coined by Cockayne but then dismissed, as it does not give a proper notion of \emph{upper Roman domination} number. However, in our context, this definition seems to be the most natural one, as it also perfectly fits the extension framework proposed in \cite{CasFGMS2022}. We will propose in \autoref{sec:alternative-notion} yet another notion of minimal rdf that also fits the mentioned extension framework.} The weights of minimal rdf can vary considerably. Consider for example a star $K_{1,n}$ with center~$c$. Then, $f_1(c)=2$, $f_1(v)=0$ otherwise; $f_2(v)=1$ for all vertices~$v$; $f_3(c)=0$, $f_3(u)=2$ for one $u\neq c$, $f_3(v)=1$ otherwise, define three minimal rdf with weights $w_{f_1}=2$, and $w_{f_2}=w_{f_3}=n+1$. \vspace{5pt} \noindent \centerline{\fbox{\begin{minipage}{.99\textwidth} \textbf{Problem name: }\textsc{Extension Roman Domination}, or \textsc{ExtRD} for short\\ \textbf{Given: } A graph $G=\left( V,E\right)$ and a function $f\in \lbrace 0,1,2 \rbrace^V.$\\ \textbf{Question: } Is there a minimal rdf $\widetilde{f} \in \lbrace 0,1,2\rbrace^V$ with $f\leq \widetilde{f}$? \end{minipage} }} \vspace{5pt} As our first main result, we are going to show that \textsc{ExtRD} can be solved in polynomial time in \autoref{sec:poly-time-ExtRD}. To this end, we need some understanding of the combinatorial nature of this problem, which we provide in \autoref{sec:properties-minimal-rdf}. The second problem that we consider is that of enumeration, both from an output-sensitive and from an input-sensitive perspective. \vspace{5pt} \noindent \centerline{\fbox{\begin{minipage}{.99\textwidth} \textbf{Problem name: }\textsc{Roman Domination Enumeration}, or \textsc{RDEnum} for short\\ \textbf{Given: } A graph $G=\left( V,E\right)$.\\ \textbf{Task: } Enumerate all minimal rdf ${f} \in \lbrace 0,1,2\rbrace^V$ of~$G$! \end{minipage} }} From an output-sensitive perspective, it is interesting to perform this enumeration without repetitions and with polynomial delay, which means that there is a polynomial $p$ such that between the consecutive outputs of any two minimal rdf of a graph of order~$n$ that are enumerated, no more than $p(n)$ time elapses, including the corner-cases at the beginning and at the end of the algorithm. From an input-sensitive perspective, we want to upper-bound the running time of the algorithm, measured against the order of the input graph. The obtained run-time bound should not be too different from known lower bounds, given by graph families where one can prove that a certain number of minimal rdf must exist. Our algorithm will be analyzed from both perspectives and achieves both goals. This is explained in \autoref{sec:enum-minimal-rdf-simple} and in \autoref{sec:enum-minimal-rdf-refined}. \section{Properties of Minimal Roman Dominating Functions} \label{sec:properties-minimal-rdf} \begin{theorem}\label{t_1_2_neigborhood} Let $G=\left(V,E\right)$ be a graph and $f: \: V \to \lbrace 0,1,2\rbrace$ be a minimal rdf. Then $N_G\left[V_2\left(f\right)\right]\cap V_1\left(f\right)=\emptyset$ holds. \end{theorem} \begin{pf} Assume that there exists a $\lbrace u,v\rbrace\in E$ with $f\left(v\right) = 2$ and $f\left(u\right)=1$. Let $$ \widetilde{f}:V\to \lbrace 0,1,2\rbrace,\: w\mapsto\begin{cases} f\left(w\right), &w\neq u\\ 0,& w=u \end{cases}$$ We show that $\widetilde{f}$ is a rdf, which contradicts the minimality of $f$, as $\widetilde{f}\leq f$ and $\widetilde{f}\left( u \right) < f\left( u\right)$ are given by construction. Consider $w \in V_0\left(\widetilde{f}\right)$. If $w= u$, $w$ is dominated by $v$, as $\lbrace u,v\rbrace\in E$. Consider $w\neq u$. Since $f$ is a rdf and $V_0\left(f\right)\cup\lbrace u\rbrace = V_0\left(\widetilde{f}\right)$, there exists a $t\in N_G\left[ w\right]\cap V_2\left(f\right)$. By construction of $\widetilde{f}$, $V_2\left(f\right)=V_2\left(\widetilde{f}\right)$ holds. This implies $N_G\left[ w\right]\cap V_2\left(\widetilde{f}\right)\neq \emptyset$. Hence, $\widetilde{f}$ is a rdf. \end{pf} \begin{theorem}\label{t_private_neighborhood} Let $G=\left(V,E\right)$ be a graph and $f: \: V \to \lbrace 0,1,2\rbrace$ be a minimal rdf. Then for all $v\in V_2\left( f \right)$, $P_{G\left[V_0\left(f\right) \cup V_2\left(f\right)\right], V_2\left(f\right)}\left(v\right) \nsubseteq \lbrace v \rbrace$ holds. \end{theorem} \begin{pf} Define $G'\coloneqq G\left[V\setminus V_1\left( f \right)\right] = G\left[V_0\left(f\right) \cup V_2\left(f\right)\right]$. In contrast to the claim, assume that there exists a $v\in V_2\left( f \right)$ with $P_{G', V_2\left(f\right)}(v) \subseteq \lbrace v \rbrace$. Define $$ \widetilde{f}:V\to \lbrace 0,1,2\rbrace,\: w\mapsto\begin{cases} f\left(w\right), &w\neq v\\ 1,& w=v \end{cases} $$ We show that $\widetilde{f}$ is a rdf, which contradicts the minimality of $f$, as $\widetilde{f}\leq f$ and $\widetilde{f}\left( v \right) < f\left( v\right)$ are given by construction. Let $u\in V_0\left(\widetilde{f}\right)=V_0\left({f}\right)$. We must show that some neighbor of $u$ belongs to $V_2\left(\widetilde{f}\right)=V_2\left(f\right) \setminus \lbrace v\rbrace$. Then, $\widetilde f$ is a rdf. First, assume that $u$ is a neighbor of~$v$. By the choice of~$v$, $u$ is not a private neighbor of~$v$. Hence, there exists a $w\in N_{G}\left[u\right] \cap\left( V_2\left(f\right) \setminus \lbrace v\rbrace\right) = N_{G}\left[u\right]\cap V_2\left(\widetilde{f}\right)$. Secondly, if $u\in V_0\left(\widetilde{f}\right)$ is not a neighbor of $v$, then there exists a $w\in V_2\left(f\right)\setminus\{v\}$ that dominates~$u$, i.e., $w\in N_{G}\left[u\right]\cap \left(V_2\left(f\right)\setminus \lbrace v\rbrace\right) = N_{G}\left[u\right]\cap V_2\left(\widetilde{f}\right)$. \end{pf} \noindent As each $v\in V_0\left(f\right)$ has to be dominated by a $w\in V_2\left(f\right)$, the next claim follows. \begin{corollary}\label{c_min_dom} Let $G=\left(V,E\right)$ be a graph and $f\in \lbrace 0,1,2\rbrace^V$ be a minimal rdf. Then, $V_2\coloneqq V_2\left(f\right)$ is a minimal ds of $G\left[ N_G[V_2]\right]$, with $N_G[V_2]=V_0\left(f\right)\cup V_2$. \end{corollary} \begin{remark} We can generalize the last statement as follows: Let $G=\left(V,E\right)$ be a graph and $f: \: V \to \lbrace 0,1,2\rbrace$ be a minimal rdf. Let $I\subseteq V_1(f)$ be an independent set in $G$. Then, $V_2\left(f\right)\cup I$ is a minimal ds of $G\left[ V_0\left(f\right)\cup V_2\left(f\right)\cup I\right]$. If $I$ is a maximal independent set in $G[V_1(f)]$, then $V_2\left(f\right)\cup I$ is a minimal ds of $G\left[ V_0\left(f\right)\cup V_2\left(f\right)\cup V_1(f)\right]$. \end{remark} \noindent This allows us to deduce the following characterization result. \begin{theorem}\label{t_porperty_min_rdf} Let $G=\left(V,E\right)$ be a graph, $f: \: V \to \lbrace 0,1,2\rbrace$ and abbreviate $G'\coloneqq G\left[ V_0\left(f\right)\cup V_2\left(f\right)\right]$. Then, $f$ is a minimal rdf if and only if the following conditions hold: \begin{enumerate} \item$N_G\left[V_2\left(f\right)\right]\cap V_1\left(f\right)=\emptyset$,\label{con_1_2} \item $\forall v\in V_2\left(f\right) :\: P_{G',V_2\left(f\right)}\left( v \right) \nsubseteq \lbrace v\rbrace$, also called \emph{privacy condition}, and \label{con_private} \item $V_2\left(f\right)$ is a minimal dominating set of $G'$.\label{con_min_dom} \end{enumerate} \end{theorem} \begin{pf} The ``only if'' follows by \autoref{t_1_2_neigborhood}, \autoref{t_private_neighborhood} and \autoref{c_min_dom}. Let $f$ be a function that fulfills the three conditions. Since $V_2\left(f\right)$ is a dominating set on $G'$, for each $u\in V_0\left( f\right)$, there exists a $v\in V_2\left(f\right)\cap N_{G}\left[u\right]$. Therefore, $f$ is a rdf. Let $\widetilde{f}:V \to \lbrace 0,1,2 \rbrace$ be a minimal rdf with $\widetilde{f}\leq f$. Therefore, $\widetilde{f}$ (also) satisfies the three conditions by \autoref{t_1_2_neigborhood}, \autoref{t_private_neighborhood} and \autoref{c_min_dom}. Assume that there exists a $v\in V$ with $\widetilde{f}\left( v\right) < f\left( v \right)$. Hence, $V_2\left(\widetilde{f}\right)\subseteq V_2\left(f\right)\setminus \lbrace v\rbrace$. \\ \textbf{Case 1:} $\widetilde{f}\left( v\right)=0, f\left( v \right) =1$. Therefore, there exists a $u\in N_G\left(v\right)$ with $f\left(u\right)\geq \widetilde{f}\left(u\right)=2$. This contradicts Condition~\ref{con_1_2}.\\ \textbf{Case 2:} $\widetilde{f}\left( v\right)\in\lbrace 0, 1\rbrace, f\left( v \right) =2$. Let $u\in N_G\left(v\right)$ with $f(u)=0$. This implies $\widetilde{f}(u)=0$ and $$\emptyset \neq N_G\left[u\right] \cap V_2\left(\widetilde{f}\right)\subseteq N_G\left[u\right] \cap V_2\left(f\right)\setminus \lbrace v \rbrace$$ holds. Therefore, $N_G\left( v \right) \subseteq N_G\left[ V_2\left(f\right) \setminus \lbrace v\rbrace\right]$. This contradicts Condition~\ref{con_private}. Thus, $\widetilde{f}=f$ holds and $f$ is minimal. \end{pf} \noindent We conclude this section with an upper bound on the size of $V_2(f)$. \begin{lemma}\label{lem:V2-bound} Let $G=\left(V,E\right)$ be a graph and $f: V \to \lbrace0,1,2\rbrace$ be a minimal rdf. Then $2 \: \vert V_2\left(f\right)\vert \leq \vert V \vert $ holds. \end{lemma} \begin{pf} Consider a graph $G=\left(V,E\right)$ and a minimal rdf $f:V\to\lbrace 0,1,2\rbrace$. For each $v\in V_2\left(f\right)$, let $P_f\left(v\right)= P_{G\left[V_0\left(f\right) \cup V_2\left(f\right)\right], V_2\left(f\right)}\left(v\right) \setminus \lbrace v \rbrace\subseteq V\setminus V_2\left(f\right) $. By \autoref{t_private_neighborhood}, these sets are not empty and, by definition, they do not intersect. Hence, we get: $$ \vert V \vert = \vert V_2\left( f\right) \vert +\vert V\setminus V_2\left( f\right) \vert \geq \vert V_2\left( f\right) \vert +\left\vert\bigcup_{v\in V_2\left(f\right)}P_f\left(v\right) \right\vert\geq 2\: \vert V_2\left( f\right) \vert\,. $$ Therefore, the claim is true. \end{pf} \section{A Polynomial-time Algorithm for \textsc{ExtRD}} \label{sec:poly-time-ExtRD} With \autoref{t_porperty_min_rdf}, we can construct an algorithm that solves the problem \textsc{Extension Roman domination} in polynomial time. \begin{algorithm} \caption{Solving instances of \textsc{ExtRD}}\label{alg} \begin{algorithmic}[1] \Procedure{ExtRD Solver}{$G,f$}\newline \textbf{Input:} A graph $G=\left(V,E\right)$ and a function $f\colon V\to \lbrace0,1,2\rbrace$.\newline \textbf{Output:} Is there a minimal Roman dominating function $\widetilde{f}$ with $f\leq \widetilde{f}$? \State $\widetilde{f}\coloneqq f$. \label{alg_init} \State $M_2\coloneqq V_2\left(f\right)$. \{ Invariant: $M_2=V_2(\widetilde{f})$ \} \label{alg_invariant} \State $ M \coloneqq M_2$. \{ All $v\in V_2(\widetilde{f})$ are considered below; invariant: $M\subseteq M_2$. \} \label{alg_before_while} \While{$M\neq \emptyset$} \State Choose $v\in M$. \{ Hence, $\widetilde{f}(v)=2$. \} \For {$u\in N\left(v\right)$} \If {$\widetilde{f}\left(u\right)=1$}\label{alg_if_no} \State $\widetilde{f}\left(u\right)\coloneqq 2$. \State Add $u$ to $M$ and to $M_2$. \EndIf \EndFor \State Delete $v$ from $M$. \EndWhile \For{$v\in M_2$}\label{alg_for_no} \If{$N_G\left(v\right)\subseteq N_G\left[M_2\setminus \lbrace v\rbrace\right]$}\label{alg_private_test} \State \textbf{Return No}. \label{alg_no} \EndIf \EndFor \For{$v\in V\setminus N_G\left[ M_2\right]$}\label{alg_fil_for} \State $\widetilde{f}\left(v\right)\coloneqq 1$. \EndFor \State\textbf{Return Yes}. \EndProcedure \end{algorithmic} \end{algorithm} \begin{theorem}\label{theorem:correctness_alg} Let $G=\left(V,E\right)$ be a graph and $f\colon V\to\lbrace0,1,2\rbrace$. For the inputs $G,f$, Algorithm~\ref{alg} returns yes if and only if $\left( G,f\right)$ is a yes-instance of \textsc{ExtRD}. In this case, the function~$\widetilde f$ computed by Algorithm~\ref{alg} is a minimal rdf. \end{theorem} \begin{pf}First observe that the invariants stated in Lines~\ref{alg_invariant} and~\ref{alg_before_while} of Algorithm~\ref{alg} are true whenever entering or leaving the while-loop. Let the answer of the algorithm be \emph{yes} and $\widetilde{f}$ be the function computed by the algorithm. We will show that~$\widetilde{f}$ satisfies the conditions formulated in \autoref{t_porperty_min_rdf}. Observing the if-condition in Line~\ref{alg_if_no}, clearly after the while-loop, no neighbor~$u$ of $v\in V_2\left(\widetilde{f}\right)$ fulfills $\widetilde{f}\left( u\right)=1$. Hence, $\widetilde{f}$ satisfies Condition~\ref{con_1_2}. If the function $\widetilde{f}$ would contradict Condition~\ref{con_private} of \autoref{t_porperty_min_rdf}, then we would get to Line~\ref{alg_no} and the algorithm would answer \emph{no}. As we are considering a \emph{yes}-answer of our algorithm, we can assume that this privacy condition holds after the for-loop of Line~\ref{alg_for_no}. We also can assume that $M_2=V_2\left(\widetilde{f}\right)$ is a minimal ds of the graph $G\left[N_G\left[M_2\right]\right]$. Otherwise, for such a $v\in M_2$ and each $u\in N_G\left(v\right)$, there would exist a $w\in N_G\left[u\right]\cap\left( M_2\setminus\lbrace v\rbrace\right)$. In this case, the algorithm would return \emph{no} in Line~\ref{alg_no}. In the for-loop of Line~\ref{alg_fil_for}, we update for all $v\in V\setminus N_G\left[ M_2\right]$ the value $\widetilde{f} \left( v\right)$ to~$1$. With the while-loop, this implies $N_G\left[M_2\right] = V_0\left(\widetilde{f}\right)\cup V_2\left(\widetilde{f}\right)$. Therefore, $V_2\left(\widetilde{f}\right)$ is a minimal ds of $G\left[V_0\left(\widetilde{f}\right)\cup V_2\left(\widetilde{f}\right)\right]$. Since we do not update the values of $\widetilde{f}$ to two in this last for-loop, Condition~\ref{con_private} from \autoref{t_porperty_min_rdf} holds. By the while-loop and the for-loop starting in Line~\ref{alg_fil_for}, it is trivial to see that Condition~\ref{con_1_2} also holds for the final $\widetilde{f}$. We can now use \autoref{t_porperty_min_rdf} to see that $\widetilde{f}$ is a minimal rdf. Since we never decrease $\widetilde{f}$ in this algorithm, starting with $\widetilde f=f$ in Line~\ref{alg_init}, we get $f\leq \widetilde{f}$. Therefore, $\left(G,f\right)$ is a \emph{yes}-instance of \textsc{ExtRD}. Now we assume that $\left(G,f\right)$ is a \emph{yes}-instance, but the algorithm returns \emph{no}. Therefore, there exists a minimal rdf $\overline{f}$ with $f\leq \overline{f}$. Since $N_G\left[V_2\left(\overline{f}\right)\right]\cap V_1\left(\overline{f}\right)=\emptyset$, $\widetilde{f}\leq \overline{f}$ holds for the function~$\widetilde{f}$ in Line~\ref{alg_for_no}. This implies $M_2=V_2\left( \widetilde{f}\right)\subseteq V_2\left(\overline{f}\right)$. The algorithm returns \emph{no} if and only if there exists a $v\in M_2$ with $$ N_G\left(v\right)\subseteq N_G\left[ M_2\setminus \lbrace v \rbrace\right]\subseteq N_G\left[V_2\left(\overline{f}\right)\setminus \lbrace v\rbrace\right].$$ Applying again Theorem~\ref{t_porperty_min_rdf}, we see that $\overline{f}$ cannot be a minimal rdf, contradicting our assumption. \end{pf} \noindent In \autoref{propos:runtime}, we prove that our algorithm needs polynomial time only. \begin{proposition}\label{propos:runtime} Algorithm~\ref{alg} runs in time cubic in the order of the input graph. \end{proposition} \begin{pf} Let $G=(V,E)$ be the input graph. Define $n=\vert V\vert$. Up to Line~\ref{alg_before_while}, the algorithm can run in linear time. As each vertex can only be once in $M$ and we look at the neighbors of each element in $M$, the while-loop runs in time $\mathcal{O}\left(n^2\right)$. In the for-loop starting in Line~\ref{alg_for_no}, we build for all $v\in M_2$ the set $N_G\left[M_2\setminus \lbrace v\rbrace\right]$. This needs $\mathcal{O}\left( n^3\right)$ time. The other steps of this loop run in time $\mathcal{O}\left(n^2\right)$. The last for-loop requires linear time. Hence, the algorithm runs in time $\mathcal{O}\left(n^3\right)$. \end{pf} \section{Enumerating Minimal RDF for General Graphs} \label{sec:enum-minimal-rdf-simple} For general graphs, our general combinatorial observations allow us to strengthen the (trivial) $\mathcal{O}^*(3^n)$-algorithm for enumerating all minimal rdf for graphs of order~$n$ down to $\mathcal{O}^*(2^n)$, as displayed in Algorithm~\ref{alg:enum}. To understand the correctness of this enumeration algorithm, the following lemma is crucial. \begin{algorithm} \caption{A simple enumeration algorithm for minimal rdf}\label{alg:enum} \begin{algorithmic}[1] \Procedure{RD Enumeration}{$G$}\newline \textbf{Input:} A graph $G=\left(V,E\right)$.\newline \textbf{Output:} Enumeration of all minimal rdf $f:V\to\{0,1,2\}$. \For {all functions $f:V\to\{1,2\}$} \For {all $v\in V$ with $f(v)=1$} \If {$\exists u\in N_G(v): f(u)=2$} \State $f(v)\coloneqq 0$. \EndIf \EndFor \State Build graph $G'$ induced by $f^{-1}(\{0,2\})=V_0(f)\cup V_2(f)$. \State $\text{private-test}\coloneqq 1$. \For {all $v\in V$ with $f(v)=2$} \If {$P_{G',V_2(F)}(v)\subseteq\{v\}$} \State $\text{private-test}\coloneqq 0$. \EndIf \EndFor \If{$\text{private-test}=1$ and if $f^{-1}(2)=V_2(f)$ is a minimal ds of $G'$} \State Output the current function $f:V\to\{0,1,2\}$. \EndIf \EndFor \EndProcedure \end{algorithmic} \end{algorithm} \begin{lemma}\label{lem:extend2} Let $G=(V,E)$ be a graph with $V_2\subseteq V$ such that $P_{G,V_2}\left( v \right) \nsubseteq \lbrace v\rbrace$ for each $v\in V_2$ holds. Then there exists exactly one minimal rdf $f\in \lbrace 0,1,2 \rbrace ^ V$ with $V_2=V_2\left(f\right)$. Algorithm~\ref{alg} can calculate $f$. \end{lemma} \begin{pf} Define \\[-4.5ex] $$f:V\to \lbrace 0, 1, 2\rbrace, v\mapsto \begin{cases} 2, & v \in V_2\\ 1, & v \notin N\left[ V_2\right]\\ 0, & \text{otherwise} \end{cases}$$ Hence, $N_G\left[ V_2 \right]=V_2\cup V_0\left(f\right)$. With the assumption $P_{G,V_2}\left( v \right) \nsubseteq \lbrace v\rbrace$, $V_2$ is a minimal ds of $G[V_2\cup V_0\left(f\right)]$. Furthermore, $N_G\left[V_2\right]\cap V_1\left(f\right)=\emptyset$. As $V_2=V_2\left(f\right)$, all conditions of \autoref{t_porperty_min_rdf} hold and $f$ is a minimal rdf. Let $\widetilde{f}\in\lbrace 0,1,2\rbrace^V$ be a minimal rdf with $V_2= V_2\left(\widetilde{f}\right)$. If there exists some $v\in V_0\left( f \right) \cap V_1\left(\widetilde{f}\right)$, this contradicts Condition~\ref{con_1_2}, as $v\in N_G\left[V_2\right] = N_G\left[V_2\left(\widetilde{f}\right)\right]$. Therefore, $ V_0\left( f\right)\subseteq V_0\left( \widetilde{f}\right) $ holds. By the assumption that $\widetilde{f}$ is a rdf, for each $v\in V_0\left( \widetilde{f} \right)$ there exists a $u\in V_2\left(\widetilde{f}\right)\cap N\left[v\right] = V_2\cap N\left[v\right]$. This implies $v\in N_G\left[V_2\right]\setminus V_2= V_0\left( f\right)$. Therefore, $ V_0\left( f\right) = V_0\left( \widetilde{f}\right)$ holds. This implies $f=\widetilde{f}$. \vspace{5pt} Define: $$\widehat{f}:V\to \lbrace 0, 1, 2\rbrace, v\mapsto \begin{cases} 2, & v\in V_2\\ 0, & v\notin V_2 \end{cases}.$$ It is trivial to see that $\widehat{f}\leq f$. By \autoref{theorem:correctness_alg}, Algorithm~\ref{alg} returns \emph{yes} for the input $\widehat{f}$. Let $\overline{f}$ be the the minimal rdf produced by Algorithm~\ref{alg}, given~$\widehat{f}$. We want to show that $V_2=V_2\left( \overline{f} \right)$. We do this by looking at the steps of the algorithm. Since $V_1\left( \widehat{f} \right) = \emptyset$, the algorithm never gets into the If-clause in Line~\ref{alg_if_no}. This is the only way to update a vertex to the value 2. Therefore, $V_2= V_2\left(\overline{f}\right)$. \end{pf} \begin{proposition} Let $G=\left(V,E\right)$ be a graph. For minimal rdf $f,g \in \lbrace0,1,2\rbrace ^ V$ with $V_2\left(f\right)=V_2\left(g\right)$, it holds $f=g$. \end{proposition} \begin{pf} By \autoref{t_private_neighborhood}, $V_2\left(f\right)$ fulfills the conditions of \autoref{lem:extend2}. Therefore, there exists a unique minimal rdf $h\in\lbrace0,1,2\rbrace ^ V$ with $V_2\left( h \right)=V_2\left( f \right) = V_2\left( g \right)$. Thus. $f=g=h$ holds. \end{pf} Hence, there is a bijection between the minimal rdf of a graph $G=(V,E)$ and subsets $V_2\subseteq V$ that satisfy the condition of \autoref{lem:extend2}. \begin{proposition}\label{prop:RomanEnum} All minimal rdf of a graph of order~$n$ can be enumerated in time $\mathcal{O}^*(2^n)$. \end{proposition} \begin{pf} Consider Algorithm~\ref{alg:enum}. The running time claim is obvious. The correctness of the algorithm is clear due to \autoref{t_porperty_min_rdf} and \autoref{lem:extend2}. \end{pf} The presented algorithm clearly needs polynomial space only, but it is less clear if it has polynomial delay. Below, we will present a branching algorithm that has both of these desirable properties, and moreover, its running time is below $2^n$. How good or bad such an enumeration is, clearly also depends on examples that provide a lower bound on the number of objects that are enumerated. The next lemma explains why the upper bounds for enumerating minimal rdf must be bigger than those for enumerating minimal dominating sets. \begin{lemma} A disjoint collection of $c$ cycles on five vertices yields a graph of order $n=5c$ that has $(16)^c$ many minimal rdf. \end{lemma} \begin{pf} Let $C_5$ be a cycle of length 5 with $V\left(C_5\right)=\lbrace v_1,\ldots,v_5 \rbrace$ and $E\left( C_5 \right) = \lbrace\lbrace v_i,v_{i+1}\rbrace\mid i\in [4] \rbrace \cup \lbrace \lbrace v_1,v_5 \rbrace \rbrace$. For a $f\in\lbrace0,1,2\rbrace^{V\left( C_5\right)}$ there are at least the following sixteen possibilities for $\left( f\left( v_1\right),\ldots,f\left( v_5\right)\right)$: \begin{itemize} \item zero occurrences of 2: $(1,1,1,1,1)$; \item one occurrence of 2: $(2,0,1,1,0)$ and four more cyclic shifts; \item two adjacent occurrences of 2: $(2,2,0,1,0)$ and four more cyclic shifts; \item two non-adjacent occurrences of 2: $(2,0,2,0,0)$ and four more cyclic shifts. \end{itemize} Therefore, there are at least 16 minimal rdf on $C_5$. To prove that these are all the minimal rdf, we use Lemma~\ref{lem:V2-bound}, which implies $\vert V_2\left(f\right)\vert\leq \frac{\vert V\left(C_5\right)\vert}{2} <3$. Hence, the number of minimal rdf on $C_5$ is at most $\binom{5}{0}+\binom{5}{1}+\binom{5}{2}=16$. \end{pf} \begin{corollary} There are graphs of order $n$ that have at least ${\sqrt[5]{16}\,}^n\in\Omega(1.7441^n)$ many minimal rdf. \end{corollary} We checked with the help of a computer program that there are no other connected graphs of order at most eight that yield (by taking disjoint unions) a bigger lower bound. \section{A Refined Enumeration Algorithm} \label{sec:enum-minimal-rdf-refined} In this section, we are going to prove the following result, which can be considered as the second main result of this paper. \begin{theorem}\label{thm:minimal-rdf-enumeration} There is a polynomial-space algorithm that enumerates all minimal rdf of a given graph of order $n$ with polynomial delay and in time $\mathcal{O}^*(1.9332^n)$. \end{theorem} Notice that this is in stark contrast to what is known about the enumeration of minimal dominating sets, or, equivalently, of minimal hitting sets in hypergraphs. Here, it is a long-standing open problem if minimal hitting sets in hypergraphs can be enumerated with polynomial delay. The remainder of this section is dedicated to describing the proof of this theorem. \subsection{A bird's eye view on the algorithm} As all along the search tree, from inner nodes we branch into the two cases if a certain vertex is assigned $2$ or not, it is clear that (with some care concerning the final processing in leaf nodes) no minimal rdf is output twice. Hence, there is no need for the branching algorithm to store intermediate results to test (in a final step) if any solution was generated twice. Therefore, our algorithm needs only polynomial space, as detailed in \autoref{prop:poly-space} and \autoref{cor:poly-space}. Because we have a polynomial-time procedure that can test if a certain given pre-solution can be extended to a minimal rdf, we can build (a slightly modified version of) this test into an enumeration procedure, hence avoiding unnecessary branchings. Therefore, whenever we start with our binary branching, we know that at least one of the search tree branches will return at least one new minimal rdf. Hence, we will not move to more than $N$ nodes in the search tree before outputting a new minimal rdf, where $N$ is upper-bounded by twice the order of the input graph. This is the basic explanation for the claimed polynomial delay, as detailed in \autoref{prop:poly-delay}. Let $G=(V,E)$ be a graph. Let us call a(ny partial) function \vspace{-15pt} \begin{equation*} \begin{split} f: V \longrightarrow \{0,1,2,\overline{1}, \overline{2}\} \end{split} \end{equation*} a \emph{generalized Roman domination function}, or grdf for short. Extending previously introduced notation, let $\overline{V_1}(f) = \{x\in V\mid f(x) = \overline{1}\}$, and $\overline{V_2}(f) = \{x\in V\mid f(x) = \overline{2}\}$. A vertex is said to be \emph{active} if it has not been assigned a value (yet) under~$f$; these vertices are collected in the set $A(f)$. Hence, for any grdf $f$, we have the partition $V=A(f)\cup V_0(f)\cup V_1(f)\cup V_2(f)\cup \overline{V_1}(f)\cup \overline{V_2}(f)$. After performing a branching step, followed by an exhaustive application of the reduction rules, any grdf~$f$ considered in our algorithm always satisfies the following \textbf{(grdf) invariants}: \begin{enumerate} \item $\forall x\in \overline{V_1}(f)\cup V_0(f)\,\exists y\in N_G(x):y\in V_2(f)$, \item $\forall x\in V_2(f):N_G(x)\subseteq \overline{V_1}(f) \cup V_0(f) \cup V_2(f)$, \item $\forall x\in V_1(f):N_G(x)\subseteq \overline{V_2}(f)\cup V_0(f)\cup V_1(f)$, \item if $\overline{V_2}(f)\neq\emptyset$, then $A(f)\cup \overline{V_1}(f)\neq \emptyset$.\footnote{This condition assumes that our graphs have non-empty vertex sets.} \end{enumerate} For the extension test, we will therefore consider the function $\hat f:V\to\{0,1,2\}$ that is derived from a grdf~$f$ as follows: $$\hat f(v)=\begin{cases}0, & \text{if }v\in A(f)\cup V_0(f)\cup \overline{V_1}(f)\cup \overline{V_2}(f)\\ 1, & \text{if }v\in V_1(f)\\ 2, & \text{if }v\in V_2(f) \end{cases}$$ The enumeration algorithm uses a combination of reduction and branching rules, starting with the nowhere defined function $f_\bot$, so that $A(f_\bot)=V$. The schematics of the algorithm is shown in Algorithm~\ref{alg:refined-enum}. To understand the algorithm, call an rdf $g$ as \emph{consistent} with a grdf $f$ if $g(v)=2$ implies $v\in A(f)\cup V_2(f)\cup \overline{V_1}(f)$ and $g(v)=1$ implies $v\in A(f)\cup V_1(f)\cup \overline{V_2}(f)$ and $g(v)=0$ implies $v\in A(f)\cup V_0(f)\cup \overline{V_1}(f)\cup \overline{V_2}(f)$. Below, we start with presenting some reduction rules, which also serve as (automatically applied) actions at each branching step, whenever applicable. The branching itself always considers a most attractive vertex $v$ and either gets assigned~2 or not. The running time analysis will be performed with a measure-and-conquer approach. Our simple measure is defined by $\mu(G,f)=|A(f)|+\omega_1 |\overline{V_1}(f)| + \omega_2 |\overline{V_2}(f)|\leq |V| $ for some constants $\omega_1$ and $\omega_2$ that have to be specified later. The measure never increases when applying a reduction rule. \begin{algorithm} \caption{A refined enumeration algorithm for minimal rdf}\label{alg:refined-enum} \begin{algorithmic}[1] \Procedure{Refined RD Enumeration}{$G,f$}\newline \textbf{Input:} A graph $G=\left(V,E\right)$, a grdf $f:V\to\{0,1,2,\overline{1},\overline{2}\}$.\newline \emph{Assumption:} There exists at least one minimal rdf consistent with $f$.\newline \textbf{Output:} Enumeration of all minimal rdf consistent with $f$. \If {$f$ is everywhere defined and $f(V)\subseteq \{0,1,2\}$} \State Output $f$ and return. \EndIf \State \{\,We know that $A(f)\cup \overline{V_1}(f)\neq\emptyset$.\,\} \State Pick a vertex $v\in A(f)\cup \overline{V_1}(f)$ of highest priority for branching. \State $f_2\coloneqq f $; $f_2(v)\coloneqq 2$. \State Exhaustively apply reduction rules to $f_2$. \{\,Invariants are valid for $f_2$.\,\} \If{$\textsc{GenExtRD Solver}\left(G,\widehat{f_2},\overline{V_2}(f_2)\right)$} \State $\textsc{Refined RD Enumeration}\left(G,{f_2}\right)$. \EndIf \State $f_{\overline{2}}\coloneqq f $; \textbf{if} $v\in A(f)$ \textbf{then} $f_{\overline{2}}(v)\coloneqq {\overline{2}}$ \textbf{else} $f_{\overline{2}}(v)\coloneqq 0$. \State Exhaustively apply reduction rules to $f_{\overline{2}}$. \{\,Invariants are valid for $f_{\overline{2}}$.\,\} \If{$\textsc{GenExtRD Solver}\left(G,\widehat{f_{\overline{2}}},\overline{V_2}(f_{\overline{2}})\right)$} \State $\textsc{Refined RD Enumeration}\left(G,{f_{\overline{2}}}\right)$. \EndIf \EndProcedure \end{algorithmic} \end{algorithm} \noindent We are now presenting details of the algorithm and its analysis. \subsection{How to achieve polynomial delay and polynomial space} In this section, we need a slight modification of the problem \textsc{ExtRD} in order to cope with pre-solutions. In this version, we add to an instance, usually specified by $G=\left( V, E\right)$ and $f:V\to \lbrace 0, 1, 2\rbrace$, a set $\overline{V_2}\subseteq V $ with $V_2\left(f\right)\cap \overline{V_2}=\emptyset$. The question is if there exists a minimal RDF $\widetilde{f}$ with $f \leq \widetilde{f}$ and $V_2\left(\widetilde{f}\right)\cap \overline{V_2}=\emptyset$. We call this problem a \emph{generalized} rdf extension problem, or \textsc{GenExtRD} for short. In order to solve this problem, we modify Algorithm \ref{alg} to cope with \textsc{GenExtRD} by adding an if-clause after Line~\ref{alg_if_no} that asks if $u\in\overline{V_2}$. If this is true, then the algorithm returns \emph{no}, because it is prohibited that $\tilde{f}(u)$ is set to~2, while this is necessary for minimal rdf, as there is a vertex $v$ in the neighborhood of $u$ such that $\tilde{f}(v)$ has been set to~1. We call this algorithm \textsc{GenExtRD Solver}. \begin{lemma}\label{lem:GenExtRD} Let $G=\left(V,E\right)$ be a graph, $f : V \to \lbrace0,1,2\rbrace$ be a function and $\overline{V_2} \subseteq V$ be a set with $V_2\left({f}\right)\cap \overline{V_2}=\emptyset$. \textsc{GenExtRD Solver} gives the correct answer when given the \textsc{GenExtRD} instance $(G,f,\overline{V_2})$. \end{lemma} \begin{pf} In Algorithm~\ref{alg}, the only statement where we give a vertex the value $2$ is in the if-clause of Line~\ref{alg_if_no}. The modified version would first check if the vertex is in $\overline{V_2}$. If this is true, there will be no minimal RDF solving this problem. Namely, if we give the vertex the value~$2$, this would contradict $V_2 \left( \widetilde{f} \right) \cap \overline{V_2}=\emptyset$. If the value stays $1$, this would contradict Condition~\ref{con_1_2}. By \autoref{theorem:correctness_alg}, $\widetilde{f}$ will be a minimal rdf with $V_2\left(\widetilde{f}\right) \cap \overline{V_2}=\emptyset$ if the algorithm returns \emph{yes}. Assume there exists a minimal RDF $\overline{f}$ with $V_2\left(\overline{f}\right) \cap \overline{V_2}=\emptyset$ but the algorithm returns \emph{no}. First we assume that \emph{no} is returned by the new if-clause. This implies that a vertex $u\in V_1\left( f \right)$ is in the neighborhood of a vertex $v\in V$ that has to have the value~2 in any minimal rdf that is bigger than $f$ (because \autoref{theorem:correctness_alg}). But this would lead to a similar contradiction as above. Therefore, the answer \emph{no} has to be returned in Line \ref{alg_no}. That would contradict Condition~\ref{con_private} or Condition~\ref{con_min_dom}. Thus the algorithm would correctly return \emph{yes}. \end{pf} Let $f$ be a generalized rdf at any moment of the branching algorithm. The next goal is to show that \textsc{GenExtRD Solver} could tell us in polynomial time if there exists a minimal rdf that could be enumerated by the branching algorithm from this point on. \begin{proposition} Let $G=\left(V,E\right)$ be a graph, $f : V \to \lbrace0,1,2,\overline{1},\overline{2}\rbrace$ be a partial function. Then, \textsc{GenExtRD Solver} correctly answers if there exists some minimal rdf $g: V \to \lbrace0,1,2\rbrace$ that is consistent with $f$ when \textsc{GenExtRD Solver} is given the instance $(G,\hat f,\overline{V_2}(f))$. \end{proposition} The following proof makes use of the grdf invariants presented above, which are only formally proved to hold in the next subsection, in \autoref{prop:invariants}. \begin{pf} We have to show two assertions: (1) If \textsc{GenExtRD Solver} answers \emph{yes} on the instance $(G,\hat f,\overline{V_2}(f))$, then there exists a minimal rdf $g: V \to \lbrace0,1,2\rbrace$ that is consistent with $f$. (2) If there exists a minimal rdf $g: V \to \lbrace0,1,2\rbrace$ that is consistent with $f$, then \textsc{GenExtRD Solver} answers \emph{yes} on the instance $(G,\hat f,\overline{V_2}(f))$. \smallskip\noindent \underline{ad (1)}: Assume \textsc{GenExtRD Solver} found a minimal rdf $g$ such that $\hat f\leq g$ and $V_2(g)\cap \overline{V_2}(f)=\emptyset$. Let $v\notin A(f)$. First assume that $g(v)=2$. Clearly, vertices in $V_2(f)=V_2(\hat f)$ do not get changed, as they cannot be made bigger. Hence, assume $v\notin V_2(f)$ exists with $g(v)=2$. As \textsc{GenExtRD Solver} will only explicitly set the value~2 for vertices originally set to~1 (by their $f$-assignment) that are in the neighborhood of vertices already set to value~2 and that do not belong to $\overline{V_2}(f)$, we have to reason about a possible $v\in V_1(f)=V_1(\hat f)$. By the third grdf invariant, the neighborhood of $v$ contains no vertex from $V_2(f)=V_2(\hat f)$, so that the case of some $v\notin V_2(f)$ with $g(v)=2$ can be excluded. Secondly, assume that $g(v)=1$. The case $v\in V_1(f)$ is not critical, and $v\in V_2(f)$ is not possible, as reasoned above. Notice that $g(v)=1$ was set in the last lines of the algorithm. In particular, $N_G(v)\cap V_2(g)=\emptyset$. As $V_2(f)\subseteq V_2(g)$, also $N_G(v)\cap V_2(f)=\emptyset$. By the first grdf invariant, $v\notin \overline{V_1}(f)\cup V_0(f)$. Hence, only $v\in \overline{V_2}(f)$ remains as a possibility. Thirdly, assume that $g(v)=0$. As $f(v)\in\{1,2\}$ is clearly impossible, $v\in V_0(f)\cup \overline{V_1}(f)\cup \overline{V_2}(f)$ must follow. Hence, $g$ is consistent with $f$. \smallskip\noindent \underline{ad (2)}: Assume that there exists a minimal rdf $g: V \to \lbrace0,1,2\rbrace$ that is consistent with $f$. We have to prove that $\hat f\leq g$ and that $V_2(g)\cap \overline{V_2}(f)=\emptyset$, because then \textsc{GenExtRD Solver} will correctly answer \emph{yes} by \autoref{lem:GenExtRD}. For $g(v)=2$, then consistency implies $f(v)\neq \overline{2}$, and trivially $\hat f(v)\leq g(v)$. For $g(v)=1$, $v\in A(f)\cup V_1(f)\cup \overline{V_2}(f)$, and hence $\hat f(v)\in\{0,1\}$, so that $\hat f(v)\leq g(v)$. If $g(v)=0$, then $v\in A(f)\cup V_0(f)\cup \overline{V_1}(f)\cup \overline{V_2}(f)=V_0(\hat f)$, so that again $\hat f(v)\leq g(v)$. \end{pf} An important consequence of the previous proposition is stated next. Notice that our algorithm behaves quite differently from what is known about algorithms the enumerate minimal ds. \begin{proposition}\label{prop:poly-delay} Procedure \textsc{Refined RD Enumeration}, on input $G=(V,E)$, outputs functions $f:V\to\{0,1,2\}$ with polynomial delay. \end{proposition} \begin{pf} Although the reduction rules are only stated in the next subsection, it is not hard to see by quickly browsing through them that they can be implemented to run in polynomial time. Moreover, \textsc{GenExtRD Solver} runs in polynomial time. Hence, all work done in an inner node of the search tree needs polynomial time only. By the properties of \textsc{GenExtRD Solver}, the search tree will never continue branching if no outputs are to be expected that are consistent with the current grdf (that is associated to that inner node). Hence, a run of the procedure \textsc{Refined RD Enumeration} dives straight through setting more and more values of a grdf, until it is everywhere defined with values from $\{0,1,2\}$, and then it returns from the recursion and dives down the next promising branch. Clearly, the length of any search tree branch is bounded by $|V|$, so that at most $2|V|$ many inner nodes are visited between any two outputs. This also holds at the very beginning (i.e., only polynomial time will elapse until the first function is output) and at the very end (i.e., only polynomial time will be spent after outputting the last function). This proves the claimed polynomial delay. \end{pf} \begin{proposition} Procedure \textsc{Refined RD Enumeration} correctly enumerates all minimal rdf that are consistent with the input grdf, assuming that at least one consistent rdf exists. \end{proposition} \begin{pf} As there exists a consistent rdf, outputting the input function is correct if the input function is already an rdf, which is checked, as we test if the given grdf is everywhere defined at has only images in $\{0,1,2\}$. Also, before \textsc{Refined RD Enumeration} is called recursively, we explicitly check if at least one consistent rdf exists. If the input grdf~$f$ is not everywhere defined or if $\overline{V_2}(f)\cup \overline{V_1}(f)\neq\emptyset$, then $A(f)\cup\overline{V_1}(f)\neq\emptyset$ by the fourth grdf invariant. Hence, whenever \textsc{Refined RD Enumeration} is called recursively, $A(f)\cup\overline{V_1}(f)\neq\emptyset$ holds, as these calls are immediately after applying all reduction rules exhaustively. Hence, by induction and based on the previous propositions, \textsc{Refined RD Enumeration} correctly enumerates all minimal rdf that are consistent with the input grdf. \end{pf} \begin{corollary}\label{cor:correct-enumeration} Procedure \textsc{Refined RD Enumeration} correctly enumerates all minimal rdf of a given graph $G=(V,E)$ when provided with the nowhere defined grdf $f_\bot$. \end{corollary} \begin{pf} Due to the previous proposition, it is sufficient to notice that all minimal rdf are consistent with $f_\bot$ and that the function that is constant~1 is a minimal rdf consistent with $f_\bot$. \end{pf} \begin{proposition}\label{prop:poly-space} Procedure \textsc{Refined RD Enumeration} never enumerates any minimal rdf consistent with the given grdf on the input graph $G=(V,E)$ twice. \end{proposition} \begin{pf} Notice that the enumeration algorithm always branches by deciding for a vertex~$v$ from $A(f)\cup \overline{V_1}(f)$, where $f$ is the current grdf, if $f(v)$ is updated to~$2$ or not, which means that either $v\in A(f)$ is set to $\overline{2}$, or $v\in \overline{V_1}$ is set to~0. Then, reduction rules may apply, but they never change the decision if, in a certain branch of the search tree, $f(v)=2$ is either true or false. Moreover, they never set any vertex to~$2$. As any minimal rdf that is ever output in a certain branch will be consistent with the grdf~$f$ associated to an inner node of the search tree, Procedure \textsc{Refined RD Enumeration} never enumerates any minimal rdf twice. \end{pf} An important consequence of the last claim is that there is no need to store all output functions in order to finally parse them to see into enumerating any of them only once. \begin{corollary}\label{cor:poly-space} Algorithm \textsc{Refined RD Enumeration} lists all minimal rdf consistent with the given grdf on the input graph $G=(V,E)$ without repetitions and in polynomial space. \end{corollary} \subsection{Details on reductions and branchings} For the presentation of the following rules, we assume that $G=(V,E)$ and a grdf $f$ is given. We also assume that the rules are executed exhaustively in the given order. \vspace{5pt} \noindent {\bf Reduction Rule LPN (Last Potential Private Neighbor).} If $v\in V_2(f)$ satisfies $|N_G(v)\cap (\overline{V_2}(f)\cup A(f))|=1$, then set $f(x) = 0$ for $\{x\}=N_G(v)\cap (\overline{V_2}(f)\cup A(f))$. \vspace{5pt} \noindent {\bf Reduction Rule $V_0$.} Let $v \in V_0(f)$. Assume there exists a unique $u\in V_2(f)\cap N_G(v)$. Moreover, assume that for all $x\in N_G(u)\cap (V_0(f)\cup \overline{V_1}(f)\cup \overline{V_2}(f))$, $|N_G(x)\cap V_2(f)|\geq 2$ if $x\neq v$. Then, for any $w \in N_G(v)\cap A(f)$, set $f(w) = \overline{2}$ and for any $w \in N_G(v)\cap \overline{V_1}(f)$, set $f(w) =0$. \vspace{5pt} \noindent {\bf Reduction Rule $V_1$.} Let $v \in V_1(f)$. For any $w \in N_G(v)\cap A(f)$, set $f(w) = \overline{2}$. For any $w \in N_G(v)\cap \overline{V_1}(f)$, set $f(w) =0$. \vspace{5pt} \noindent {\bf Reduction Rule $V_2$.} Let $v \in V_2(f)$. For any $w \in N_G(v)\cap A(f)$, set $f(w) = \overline{1}$. For any $w \in N_G(v)\cap \overline{V_2}(f)$, set $f(w) =0$. \vspace{5pt} \noindent {\bf Reduction Rule NPD (No Potential Domination).} If $v\in \overline{V_2}(f)$ satisfies $N_G(v)\subseteq \overline{V_2}(f)\cup V_0(f)\cup V_1(f)$, then set $f(v) = 1$ (this also applies to isolated vertices in $\overline{V_2}(f)$). \vspace{5pt} \noindent {\bf Reduction Rule NPN (No Private Neighbor).} If $v\in A(f)$ satisfies $N_G(v)\subseteq V_0 \cup\overline{V_1}(f)$, then set $f(v) = \overline{2}$ (this also applies to isolated vertices in $A(f)$). \vspace{5pt} \noindent {\bf Reduction Rule Isolate.} If $A(f)=\emptyset$ and if $v\in \overline{V_1}(f)$ satisfies $N_G(v)\cap\overline{V_2}(f)= \emptyset$, then set $f(v) = 0$. \vspace{5pt} \noindent {\bf Reduction Rule Edges.} If $u,v\in \overline{V_2}(f)\cup V_0(f)\cup V_1(f)$ and $e=uv\in E$, then remove the edge~$e$ from $G$. \vspace{5pt} \noindent In the following, we first take care of the claimed grdf invariants. \begin{proposition}\label{prop:invariants} After exhaustively executing the proposed reduction rules, as indicated in Algorithm~\ref{alg:refined-enum}, the claimed grdf invariants are maintained. \end{proposition} \begin{pf}We argue for the correctness of the grdf invariants by induction one by one. Notice that (trivially) all invariants hold if we start the algorithm with the nowhere defined grdf. \begin{enumerate} \item $\forall x\in \overline{V_1}(f)\cup V_0(f)\,\exists y\in N_G(x):y\in V_2(f)$. We need to show that $N_G(x) \cap V_2(f) \neq \emptyset$ holds for each $x\in V_0(f) \cup \overline{V_1}(f)$. For the inductive step, we only have to look at the reduction rules, since the branching rules only change the value to $0$ if the vertex was already in $\overline{V_1}(f)$. For each reduction rule where we set a value of a vertex to~$0$ or to~$\overline{1}$, there exists a vertex in the neighborhood with value~$2$, which is seen as follows. \begin{tabular}{rl} LPN:& We explicitly consider $x\in N_G(V_2(f))$ only to be set by $f(x)=0$.\\ $V_0$\,\&\,$V_1$:& We only set $w$ to $0$ if it has been in $\overline{V_1}$. By induction hypothesis, \\ &$w$ has a neighbor in $V_2(f)$.\\ $V_2$:& We explicitly consider $w\in N_G(V_2(f))$ only to be set to~$0$ or to~$\overline{1}$.\\ Isolate:& Only vertices from $\overline{V_1}(f)$ are set to~0; apply induction hypothesis. \end{tabular} \item $\forall x\in V_2(f):N_G(x)\subseteq \overline{V_1}(f)\cup V_0(f) \cup V_2(f)$. This property can only be invalidated if new vertices get the value~2 or if vertices from $\overline{V_1}(f)\cup V_0(f) \cup V_2(f)$ are changed to a value other than this or if edges are deleted (as vertices are never deleted). The only way in which a vertex gets~$v$ the value~2 is by branching. Immediately afterwards, the reduction rules are executed: LPN and $V_2$ will install the invariant for the neighborhood of~$v$. No reduction rule ever changes the value of a vertex from $V_0(f) \cup V_2(f)$, while vertices from $\overline{V_1}(f)$ might be set to~$0$ or~$2 $. The Reduction Rule Edges deletes no edges incident to vertices from $V_2(f)$. \item $\forall x\in V_1(f):N_G(x)\subseteq \overline{V_2}(f)\cup V_0(f)\cup V_1(f)$. The invariant is equivalent to the following three conditions: (a) $N(V_1(f))\cap A(f)=\emptyset$, (b) $N(V_1(f))\cap \overline{V_1}(f)=\emptyset$ and (c) $N(V_1(f))\cap V_2(f) =\emptyset$. Conditions (a) and (b) are taken care of by Reduction Rule $V_1$. Condition (c) immediately follows by the already proven second invariant. \item If $\overline{V_2}(f)\neq\emptyset$, then $A(f)\cup \overline{V_1}(f)\neq \emptyset$. Consider some $x\in \overline{V_2}(f)$. By the second invariant, $N_G(x)\cap V_2(f)=\emptyset$. By the Reduction Rule Edges, $N_G(x)\cap \left(\overline{V_2}(f)\cup V_0(f)\cup V_1(f)\right)=\emptyset$. As the Reduction Rule NPD did not apply, the only possible neighbors of $x$ are in $A(f)\cup \overline{V_1}(f)$.\qed \end{enumerate} \renewcommand{\qed}{} \end{pf} We have now to show the \emph{soundness} of the proposed reduction rules. In the context of enumerating minimal rdf, this means the following: if $f,f'$ are grdf of $G=(V,E)$ before or after applying any of the reduction rules, then $g$ is a minimal rdf that is consistent with $f$ if and only if it is consistent with $f'$. \begin{proposition}\label{prop:rdf-reductionrules-soundness} All proposed reduction rules are sound. \end{proposition} \begin{pf} For the soundness of the reduction rules, we also need the invariants proven to be correct in \autoref{prop:invariants}. We now prove the soundness of each reduction rule, one at a time. If possible, we apply Reduction Rule LPN first. Consider $v\in V_2(f)$ with $\{x\}=N_G(v)\cap (\overline{V_2}(f)\cup A(f))$. Before the branching step, due to the second invariant, neighbors of $V_2(f)$-vertices are either in $V_0(f)$, $V_2(f)$ or in $\overline{V_1}(f)$. As no reduction rule adds a vertex to $V_2(f)$, $v$ must have been put into $V_2(f)$ by the last branching step. By the first invariant, we know that all $y\in N_G(v)\cap\left( \overline{V_1}(f)\cup V_0(f)\right)$ are dominated by vertices different from~$v$. As $v\in V_2(f)$, it still needs a private neighbor to dominate. As $N_G(v)\cap (\overline{V_1}(f)\cup A(f))$ contains one element~$x$ only, setting $f(x)=0$ is enforced for any minimal rdf (see \autoref{t_private_neighborhood}). Next, we prove Reduction Rule $V_0$. We consider $v\in V_0(f)$ and $u\in V$ with $\{u\}=V_2(f)\cap N_G(v)$. We can use the rule, since $u$ needs a private neighbor which can only be $v$, by the assumption that every other neighbor of~$u$ is dominated at least twice. To maintain the property that $v$ is a private neighbor of~$u$, each $A(f)$-neighbor of~$v$ is set to~$\overline{2}$ and each $\overline{V_1}(f)$-neighbor of $v$ is set to~$0$. This annotates the fact that any minimal rdf~$g$ compatible with~$f$ will satisfy $(g(x)=2\implies x=u)$ for each $x\in N_G(v)$. The soundness of Reduction Rule $V_1$ and Reduction Rule $V_2$ mainly follows from \autoref{t_1_2_neigborhood}. Coming to the Reduction Rule NPD, notice that setting $f(v)=0$ would necessitate $f(u)=2$ for some neighbor $u$ of $v$, which is impossible. For the Reduction Rule NPN, we use the fact that $N_G(v) \cap V_2(f) \neq \emptyset$ holds for each $v\in V_0(f) \cup \overline{V_1}(f)$, which is the first invariant.\footnote{More precisely, we also have to check that the possibly newly introduced vertices in $V_0(f)$ or $\overline{V_1}(f)$ by the branching or by the reduction rules up to this point do maintain the invariant, but this is nothing else then re-checking the induction step of the correctness proof of this invariant, see the proof of \autoref{prop:invariants}.} This implies that there is no element left for $v$ to dominate (therefore it has no private neighbor except itself). Thus, if $v$ has the value $2$, then it would contradict with \autoref{t_private_neighborhood}. For the soundness of Reduction Rule Isolate, we note that, since $A(f)$ is empty, $v\in \overline{V_1}(f)$ can only have neighbors in $V_1(f)\cup V_2(f)\cup \overline{V_1}(f)$, as $\overline{V_2}(f)$-neighbors are prohibited. As Reduction Rule $V_1$ was (if possible) executed before, $N_G(v)\cap V_1(f)= \emptyset$ holds. Therefore, $v\in \overline{V_1}(f)$ would not have a private neighbor if $f(v)=2$, cf. the first invariant.\footnote{Again, one has to partially follow the induction step of the proof of \autoref{prop:invariants}.} Finally, the soundness of Reduction Rule Edges follows trivially from the fact that an element of $\overline{V_2}(f) \cup V_0(f) \cup V_1(f)$ cannot dominate any vertex in $\overline{V_2}(f) \cup V_0(f) \cup V_1(f)$. Hence, a minimal rdf $g$ is consistent with $f$ if and only it is consistent with $f'$, obtained by applying the Reduction Rule Edges to~$f$. \end{pf} In order to fully understand Algorithm~\ref{alg:refined-enum}, we need to describe priorities for branching. We describe these priorities in the following in decreasing order for a vertex $v\in A(f)\cup \overline{V_1}(f)$. \begin{enumerate} \item $v\in A(f)$ and $|N_{G}(v)\cap (A(f)\cup \overline{V_2}(f))|\geq 2$; \item any $v\in A(f)$; \item any $v\in \overline{V_1}(f)$, preferably if $|N_{G}(v)\cap \overline{V_2}(f)|\neq 2$. \end{enumerate} These priorities also split the run of our algorithm into phases, as whenever the algorithm was once forced to pick a vertex according to some lower priority, there will be never again the chance to pick a vertex of higher priority thereafter. It is useful to collect some \textbf{phase properties} that instances must satisfy after leaving Phase~$i$, determined by applying the $i^\text{th}$ branching priority. \begin{itemize} \item Before entering any phase, there are no edges between vertices $u,v$ if $u,v\in V_0(f)\cup V_1(f)\cup \overline{V_2}(f)$ or if $u\in V_2(f)$ and $v\in \overline{V_2}(f)\cup A(f)$ or if $u\in V_1(f)$ and $v\in \overline{V_1}(f)\cup A(f)$, as we can assume that the reduction rules have been exhaustively applied. \item After leaving the first phase, any active vertex with an active neighbor is either pendant or has only further neighbors from $\overline{V_1}(f)\cup V_0(f)$. \item After leaving the second phase, $A(f)=\emptyset$ and $N_G(\overline{V_2}(f))\subseteq \overline{V_1}(f)$. Moreover, any vertex $x\in \overline{V_2}(f)$ has neighbors in $\overline{V_1}(f)$. \item After leaving the third phase, $A(f)=\overline{V_2}(f)=\overline{V_1}(f)=\emptyset$, so that $f$ is a Roman dominating function. \end{itemize} \begin{proposition} The phase properties hold. \end{proposition} \begin{proof} We are considering the items on the list separately. \begin{itemize}\item Reduction Rule Edges shows the first claim. Reduction Rules $V_2$ and $V_1$ show the other two claims. \item By the branching condition, we know that after leaving the first phase, $|N_{G}(v)\cap (A(f)\cup \overline{V_2}(f))|< 2$ for any active vertex~$v$. Since $v$ has a neighbor in $A(f)$ (say $u$) this implies that there cannot be any other neighbor in $A(f)\cup \overline{V_2}(f)$. Moreover, by the Reduction Rule $V_1$, $N_G(v)\cap V_1(f)=\emptyset$, and by the Reduction Rule $V_2$, $N_G(v)\cap V_2(f)=\emptyset$. Hence, $N_G(v) \setminus \lbrace u\rbrace \subseteq \overline{V_1}(f)\cup V_0(f)$. \item The second phase branches on each $v\in A(f)$. Therefore, it ends if $A(f)=\emptyset$. Let $v\in \overline{V_2}(f)$. By Reduction Rule Edge, we get $N_G(v) \cap \left( \overline{V_2}(f) \cup V_0 \cup V_1 \right)=\emptyset$. Reduction Rule $V_2$ implies that $v$ does not have a neighbor in $V_2(f)$. Therefore we get $N_G(v) \subseteq \overline{V_1}(f)$. If $N_G(v)$ is empty, Reduction Rule NPD will be triggered. Therefore, $N_G(v)$ has at least one element. \item The third phase runs on the vertices in $\overline{V_1}(f)$. Thus, $\overline{V_1}(f)=\emptyset$ holds at the end of this phase. Since we never put a vertex into $A(f)$ again, $A(f)$ is empty. To get $\overline{V_2}(f) = \emptyset$, we can use the same argumentation as in the property before, since a vertex goes only from $A(f)$ to $\overline{V_2}(f)$.\qed \end{itemize} \end{proof} \subsection{A Measure \& Conquer Approach} We now present the branching analysis, classified by the described branching priorities. We summarize a list of all resulting branching vectors in \autoref{tab:branching-vectors}. \begin{table}[tb] \centering \begin{tabular}{|l|l|}\hline Phase \#& Branching vector\\\hline 1.1 & $(1-\omega_2,3-2\omega_1)$\\ 1.2 & $(1-\omega_2,1+2\omega_2)$\\ 1.3 & $(1-\omega_2,2+\omega_2-\omega_1)$\\\hline 2.1 \& 2.2.b & $(1-\omega_2,2)$\\ 2.2.a & $(1-\omega_2,1+\omega_2+\omega_1)$\\ 2.2.c & $(1+\omega_2,1)$\\\hline 3.1 & $(\omega_1,\omega_1+3\omega_2)$\\ 3.2.a & $(\omega_1,2\omega_1+\omega_2)$\\ 3.2.b \& 3.3.a & $(\omega_1+\omega_2,\omega_1+\omega_2)$\\3.3.b & $(2\omega_1+2\omega_2,2\omega_1+2\omega_2,2\omega_1+2\omega_2,2\omega_1+2\omega_2)$\\\hline \end{tabular} \caption{The branching vectors of different branching scenarios of the enumeration algorithm for listing all minimal Roman domination functions of a given graph} \label{tab:branching-vectors} \end{table} \subsubsection{Branching in Phase~1.} We are always branching on an active vertex $v$. In the first branch, we set $f(v) = 2$. In the second branch, we set $f(v) = \overline{2}$. In the first branch, in addition the Reduction Rule $V_2$ triggers at least twice. In order to determine a lower bound on the branching vector, we describe three worst-case scenarios; all other reductions of the measure can be only better. \begin{enumerate} \item $|N_G(v)\cap A(f)|=2$, i.e., $v$ has two active neighbors $x$ and $y$. The corresponding recurrence is: $T(\mu) = T(\mu-(1-\omega_2))+T(\mu-(1+2(1-\omega_1)))$, as either $v$ moves from $A(f)$ to $V_2(f)$ and $x,y$ move from $A(f)$ to $\overline{V_1}(f)$, or $v$ itself moves from $A(f)$ to $\overline{V_2}(f)$. The branching vector is hence: $(1-\omega_2,3-2\omega_1)$, as noted in the first row of \autoref{tab:branching-vectors}. \item $|N_G(v)\cap \overline{V_2}(f)|=2$. The corresponding recurrence is: $T(\mu) = T(\mu-(1-\omega_2))+T(\mu-(1+2\omega_2))$, see the second row of \autoref{tab:branching-vectors}. \item $|N_G(v)\cap A(f)|=1$ and $|N_G(v)\cap \overline{V_2}(f)|=1$, leading to $T(\mu) = T(\mu-(1-\omega_2))+T(\mu-(1+(1-\omega_1)+\omega_2))$, see \autoref{tab:branching-vectors}, third row. \end{enumerate} \subsubsection{Branching in Phase~2.} We are again branching on an active vertex $v$. By Reduction Rule NPN, we can assume that $N_G(v)\neq\emptyset$. In the first branch, we set $f(v) = 2$. In the second branch, we set $f(v) = \overline{2}$. \begin{enumerate} \item If $N_G(v)\cap A(f)=\{x\}$, then $N_G(v)\cap \overline{V_2}(f)=\emptyset$ in this phase. Therefore, in the first branch, $f(x)=0$ is enforced by Reduction Rule LPN. Notice that this might further trigger Reduction Rule $V_0$ if $N_G(x)\cap (A(f)\cup \overline{V_1}(f))$ contains vertices other than~$v$. The corresponding worst-case recurrence is: $T(\mu) = T(\mu-(1-\omega_2))+T(\mu-(1+1))$, see \autoref{tab:branching-vectors}, fourth row. \item If $N_G(v)\cap \overline{V_2}(f)=\{x\}$, then $N_G(v)\cap A(f)=\emptyset$ in this phase. Therefore, in the first branch, $f(x)=0$ is enforced by Reduction Rule LPN. We consider several sub-cases now. \begin{enumerate} \item $N_G(x)\cap \overline{V_1}(f)\neq\emptyset$. Reduction Rule $V_0$ will put all these vertices into $V_0(f)$. The corresponding worst-case recurrence is: $T(\mu) = T(\mu-(1-\omega_2))+T(\mu-(1+\omega_2+\omega_1))$, see \autoref{tab:branching-vectors}, fifth row. \item $|N_G(x)\cap A(f)|\geq 2$. Reduction Rule $V_0$ will put all these vertices into $\overline{V_2}(f)$ (except for $v$). The corresponding worst-case recurrence is: $T(\mu) = T(\mu-(1-\omega_2))+T(\mu-(1+\omega_2+(1-\omega_2)))$, see \autoref{tab:branching-vectors}, fourth row. \item Recall that by Reduction Rule Edges, $N_G(x)\cap (\overline{V_2}(f)\cup V_0(f)\cup V_1(f))=\emptyset$, so that (if the first two cases do not apply) now we have $N_G(x)\setminus\{v\}\subseteq V_2(f)$. By the properties listed above, also $N_G(x)\cap V_2(f)=\emptyset$ is clear, so that now $|N_G(x)|=1$, i.e., $x$ is a pendant vertex. In this situation, we do not gain anymore from the first branch, but when $f(v)=\overline{2}$ is set, Reduction Rule NPD triggers and sets $f(x)=1$. The corresponding worst-case recurrence is: $T(\mu) = T(\mu-(1+\omega_2))+T(\mu-(1-\omega_2+\omega_2))$, see \autoref{tab:branching-vectors}, sixth row. \end{enumerate} \end{enumerate} \subsubsection{Branching in Phase~3.} As $A(f)=\emptyset$, we are now branching on a vertex $v\in \overline{V_1}(f)$. Due to Reduction Rule Isolate, we know that $N_G(v)\cap\overline{V_2}(f)\neq \emptyset$. In the first branch, we consider setting $f(v)=2$, while in the second branch, we set $f(v)=0$. Again, we discuss several scenarios in the following. \begin{enumerate} \item Assume that $|N_G(v)\cap \overline{V_2}(f)|\geq 3$. If we set $f(v)=2$, then Reduction Rule $V_2$ triggers at least thrice. The corresponding worst-case recurrence is: $T(\mu) = T(\mu-\omega_1)+T(\mu-(\omega_1+3\omega_2))$, with a branching vector of $(\omega_1,\omega_1+3\omega_2)$, see \autoref{tab:branching-vectors}, seventh row. \item Assume that $|N_G(v)\cap \overline{V_2}(f)|=1$, i.e., there is some (unique) $u\in \overline{V_2}(f)$ such that $N_G(v)\cap \overline{V_2}(f)=\{u\}$. We consider two sub-cases: \begin{enumerate} \item If $|N_G(u)\cap \overline{V_1}(f)|\geq 2$, then if we set $f(v)=2$, then first Reduction Rule LPN triggers $f(u)=0$, which in turn sets $f(w)=0$ for all $w\in N_G(u)\cap \overline{V_1}(f)$, $w\neq u$, by Reduction Rule $V_0$. The corresponding worst-case recurrence is: $T(\mu) = T(\mu-\omega_1)+T(\mu-(\omega_2+2\omega_1))$, see \autoref{tab:branching-vectors}, eighth row. \item If $|N_G(u)\cap \overline{V_1}(f)|=1$, then $u$ is a pendant vertex. Hence, in the first branch, we have (as above) $f(v)=2$ and $f(u)=0$, while in the second branch, we have $f(v)=0$ and $f(u)=1$ by Reduction Rule NPD. This decreases the measure by $\omega_1+\omega_2$ in both branches, see \autoref{tab:branching-vectors}, nineth row. This scenario happens in particular if the graph $G'$ induced by $\overline{V_1}(f)\cup \overline{V_2}(f)$ contains a connected component which is a $P_2$. Therefore, we refer to this (also) as a \emph{$P_2$-branching} below. \end{enumerate} \item Assume that $|N_G(v)\cap \overline{V_2}(f)|=2$, i.e., there are some $u_1,u_2\in \overline{V_2}(f)$ such that $N_G(v)\cap \overline{V_2}(f)=\{u_1,u_2\}$. Notice that in the first branch, when $f(v)=2$, Reduction Rule $V_2$ triggers twice, already reducing the measure by $\omega_1+2\omega_2$. We consider further sub-cases: \begin{enumerate} \item If $|N_G(u_1)\cap \overline{V_1}(f)|=1$, then $u_1$ is a pendant vertex. As in the previous sub-case, this helps us reduce the measure in the second branch by $\omega_1+\omega_2$ due to Reduction Rule NPD, which obviously puts us in a better branching than \autoref{tab:branching-vectors}, nineth row. Similarly, we can discuss the case $|N_G(u_2)\cap \overline{V_1}(f)|=1$. \item If $|N_G(u_1)\cap \overline{V_1}(f)|=2$, then we know now that the graph $G'$ induced by $\overline{V_1}(f)\cup \overline{V_2}(f)$ is bipartite after removing edges between vertices from $\overline{V_1}(f)$, and vertices from $\overline{V_1}(f)$ all have degree two and vertices from $\overline{V_2}(f)$ all have degree at least two. The worst case for the following branching is hence given by a $K_{2,2}$ as a connected component in $G'$: Testing now all possibilities of setting the $\overline{V_2}(f)$-vertices to $0$ or to $1$ will determine all values of the $\overline{V_1}(f)$-vertices by reduction rules. Hence, we have in particular for the $K_{2,2}$ a scenario with four branches, and in each branch, the measure is reduced by $2\omega_2+2\omega_1$ \emph{($K_{2,2}$-branching)}. \end{enumerate} \end{enumerate} \begin{proposition}\label{prop:run-time}On input graphs of order~$n$, Algorithm \textsc{Refined RD Enumeration} runs in time $\mathcal{O}^*(1.9332^n)$. \end{proposition} \begin{pf} We follow the run-time analysis that led us to the branching vectors listed in \autoref{tab:branching-vectors}. The claim follows by choosing as weights $\omega_1= \frac{2}{3}$ and $\omega_2=0.38488$. \end{pf} The two worst-case branchings (with the chosen weights $\omega_1= \frac{2}{3}$ and $\omega_2=0.38488$) are 1.1, 3.2.b and 3.3. If we want to further improve on our figures, we would have to work on a deeper analysis in these cases. For the $P_2$-branching, it might be an idea to combine it with the branchings where it could ever originate from. Notice that adjacent $\overline{V_1}$-$\overline{V_2}$-vertices can be only produced in the first branching phase. But we would then have to improve also on Phase 3.3, the worst case being a $K_{2,2}$-branching in Case 3.3 (b). \smallskip\noindent Let us finally summarize the corner-stones of our reasoning. \begin{proof}[\autoref{thm:minimal-rdf-enumeration}] Several important properties have been claimed and proved about Algorithm~\ref{alg:refined-enum} that show the claim of our second main theorem. \begin{itemize} \item The algorithm correctly enumerates all minimal rdf; see \autoref{cor:correct-enumeration}. \item The algorithm needs polynomial space only; see \autoref{cor:poly-space}. \item The algorithm achieves polynomial delay; see \autoref{prop:poly-delay}. \item The algorithm runs in time $\mathcal{O}^*(1.9332^n)$ on input graphs of order~$n$; see \autoref{prop:run-time}.\qed \end{itemize} \end{proof} \section{An Alternative Notion of Minimal RDF} \label{sec:alternative-notion} So far, we focused on an ordering of the functions $V\to\{0,1,2\}$ that was derived from the linear ordering $0<1<2$. Due to the different functionalities, it might be not that clear if 2 should be bigger than 1. If we rather choose as a basic partial ordering $0<1,2$, with $1,2$ being incomparable, this yields another ordering for the functions $V\to\{0,1,2\}$, again lifted pointwise. Being reminiscent of partial orderings, let us call the resulting notion of minimality PO-minimal rdf. Recall that the notion of minimality for Roman dominating functions that we considered so far and that we also view as the most natural interpretation of this notion has been refuted in the literature, because it leads to a trivial notion of \textsc{Upper Roman Domination}, because the minimal rdf $f:V\to\{0,1,2\}$ with biggest sum $\sum_{v\in V}f(v)$ is achieved by the constant function $f=1$. This is no longer true for the (new) problem \textsc{Upper PO-Roman Domination}. Also, this can be seen as a natural pointwise lifting of the inclusion ordering, keeping in mind that $f\leq_{PO}g$ iff $V_1(f)\subseteq V_1(g)$ and $V_2(f)\subseteq V_2(g)$. More interesting for the storyline of this paper are the following results: \begin{theorem}\label{t_porperty_min_rdf} Let $G=\left(V,E\right)$ be a graph, $f: \: V \to \lbrace 0,1,2\rbrace$ and abbreviate $G'\coloneqq G\left[ V_0\left(f\right)\cup V_2\left(f\right)\right]$. Then, $f$ is a PO-minimal rdf if and only if the following conditions hold: \begin{enumerate} \item$N_G\left[V_2\left(f\right)\right]\cap V_1\left(f\right)=\emptyset$,\label{con_1_2_PO} \item $V_2\left(f\right)$ is a minimal dominating set of $G'$.\label{con_min_dom_PO} \end{enumerate} \end{theorem} \begin{pf} First we look into the ``only if''-part. The first condition follows analogously from \autoref{t_1_2_neigborhood}. For the other condition, we assume that there exists a graph $G=\left(V,E\right)$ and a PO-minimal-rdf $f: V \to \lbrace 0,1,2\rbrace$ such that $V_2(f)$ is not a minimal dominating set in $G'$. Since $f$ is a rdf, $V_2(f)$ is a dominating set in~$G'$. Thus, $V_2(f)$ is not irredundant in $G'$. Hence, there exists a $v\in V_2(f)$ such that $N[v] \subseteq N_G[V_2(f)\setminus \lbrace v\rbrace]$. Define $$ \widetilde{f}:V\to \lbrace 0,1,2\rbrace,\: w\mapsto\begin{cases} f\left(w\right), &w\neq v\\ 0,& w=v \end{cases}. $$ Clearly, vertices $w\in \left( V_0(f) \cup V_1(f)\right)\setminus N_G[v]$ are dominated by $\widetilde{f}$. But $N_G[v]$ is also dominated, since $N_G[v] \subseteq N_G[V_2(f)\setminus \lbrace v\rbrace]$ holds. This would contradict the PO-minimality of $f$. Let $f$ be a function that fulfills the two conditions. Since $V_2\left(f\right)$ is a dominating set in $G'$, for each $u\in V_0\left( f\right)$, there exists a $v\in V_2\left(f\right)\cap N_{G}\left[u\right]$. Therefore, $f$ is a rdf. Let $\widetilde{f}:V \to \lbrace 0,1,2 \rbrace$ be a PO-minimal rdf such that $\widetilde{f}$ is smaller than $f$ with respect to the partial ordering. Therefore, $\widetilde{f}$ (also) satisfies the two conditions. Assume that there exists a $v\in V$ with $\widetilde{f}\left( v\right) < f\left( v \right)$. Hence, $V_2\left(\widetilde{f}\right)\subseteq V_2\left(f\right)\setminus \lbrace v\rbrace$. \noindent \textbf{Case 1:} $\widetilde{f}\left( v\right)=0 ~and~ f\left( v \right) =1$. Therefore, there exists a vertex $u\in N_G\left(v\right)$ with $f\left(u\right)\geq \widetilde{f}\left(u\right)=2$. This contradicts Condition~\ref{con_1_2}. \noindent \textbf{Case 2:} $\widetilde{f}\left( v\right)=0 ~and~ f\left( v \right) =2$. Thus, for each $u\in V_0(f) \cap N_G[v]\subseteq V_0(\widetilde{f})\cap N_G[v]$ there exists a $w\in V_2(\widetilde{f})\cap N_G(u)\subseteq V_2(f)\cap N_G(u)$. This implies, that $V_2(f)$ is not irredundant in $G'$, which contradicts the second condition. Therefore, $\widetilde{f} = f$ holds and $f$ is PO-minimal. \end{pf} Based on this characterization of PO-minimality, we can again derive a positive algorithmic results for the corresponding extension problem. \begin{theorem}\label{theorem:P_ExtPoRDF} The extension problem \textsc{ExtPO-RDF} can be solved in polynomial time. \end{theorem} \begin{pf} For this problem, we have to modify Algorithm \ref{alg} again. This time, we have to modify Line \ref{alg_private_test} to \textbf{if} $N_G[v]\subseteq N[M_2\setminus \lbrace v\rbrace]$ \textbf{do}. The rest of the proof is analogous to the proof of \autoref{theorem:correctness_alg}. \end{pf} Furthermore, we can show that for PO-minimal rdf, the simple enumeration algorithm is already provably optimal. \begin{theorem} There is a polynomial-space algorithm that enumerates all PO-minimal rdf of a given graph of order $n$ in time $\mathcal{O}^*(2^n)$ with polynomial delay. Moreover, there is a family of graphs $G_n$, with $G_n$ being of order $n$, such that $G_n$ has $2^n$ many PO-minimal rdf. \end{theorem} \begin{pf} The algorithm itself works similar to Algorithm~\ref{alg:enum}, but we have to integrate the extension tests as in Algorithm~\ref{alg:refined-enum}. Therefore, we need to combine our two modifications for Algorithm~\ref{alg}. This new version would solve the \textsc{GenExtPO-RDF}, where a graph $G=(V,E)$, a function $f:V\to\lbrace0,1,2\rbrace$ and a set $\overline{V_2}$ are given and we need to find a PO-minimal rdf $\widetilde{f}$ with $f\leq \widetilde{f}$ and $\overline{V_2}\cap V_2\left( f\right)=\emptyset$ (to prove this, combine the proofs of \autoref{lem:GenExtRD} and \autoref{theorem:P_ExtPoRDF}). To see optimality of the enumeration algorithm, notice that the null graph (edge-less graph) of order~$n$ has any mapping $f:V\to\{1,2\}$ as a PO-minimal rdf. \end{pf} It follows that the (relatively simple) enumeration algorithm is optimal for PO-minimal rdf. If one dislikes the fact that our graph family is disconnected, consider the star $K_{1,n}$ that has $2^{n}+1$ many different PO-minimal rdf: If $V(K_{1,n})=\{0,1,\dots,n\}$, with $0$ being the center and $i\in\{1,\dots,n\}$ being the `ray vertices' of this star, then either put $f(0)=2$ and $f(i)=0$ for $i\in\{1,\dots,n\}$, or $f(j)=1$ for $j\in \{0,1,\dots,n\}$, or $f(0)=0$ and $f(i)\in\{1,2\}$ is arbitrary for $i\in\{1,\dots,n\}$ (except for $f(j)=1$ for $j\in \{1,\dots,n\}$). This example proves that there cannot be any general enumeration algorithm running in time $\mathcal{O}((2-\varepsilon)^n)$ for any $\varepsilon>0$, even for connected graphs of order~$n$. \section{Conclusions} While the combinatorial concept of Roman domination leads to a number of complexity results that are completely analogous to what is known about the combinatorial concept of domination, the two concepts lead to distinctively different results when it comes to enumeration and extension problems. These are the main messages and results of the present paper. We are currently working on improved enumeration and also on counting of minimal rdf in special graph classes. Our first results are very promising; for instance, there are good chances to completely close the gap between lower and upper bounds for enumerating minimal rdf for some graph classes. Another line of research is looking into problems that are similar to Roman domination, in order to better understand the specialties of Roman domination in contrast to the classical domination problem. What makes Roman domination behave different from classical domination when it comes to finding extensions or to enumeration? Finally, let us mention that our main branching algorithm also gives an input-sensitive enumeration algorithm for minimal Roman dominating functions in the sense of Chellali \emph{et al.}~\cite{CheHHHM2016}. However, we do not know of a polynomial-delay enumeration algorithm in that case. This is another interesting line of research. Here, the best lower bound we could find was a repetition of a $C_4$, leading to $\sqrt[4]{8}\geq 1.68179$ as the basis.
{'timestamp': '2022-04-12T02:26:46', 'yymm': '2204', 'arxiv_id': '2204.04765', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04765'}
arxiv
\section{Introduction} Sign language is a visual language used for daily communication in the deaf community. Sign language translation (SLT) can play an important role in bridging the communication gap between the deaf and the hearing people. SLT has received increasing attention by the research community \cite{camgoz2018neural,camgoz2020multi,zhou2021improving,zhou2021spatial,yin-etal-2021-including}. \begin{table}[!tbp] \centering \begin{tabular}{c|c|cc} \hline Corpus & P14T & \multicolumn{2}{c}{EN-DE} \\ \hline Sentences & 8,257 & \multicolumn{2}{c}{1,920,209} \\ \hline Words & 72,783 & \multicolumn{1}{c|}{53,008,851} & 50,486,398 \\ \hline \end{tabular} \caption{Statistics of a SLT dataset and a NMT dataset. P14T denotes the largest publicly available SLT dataset PHOENIX14T. The EN-DE denotes the English-German parallel data from WMT18 \cite{bojar-etal-2018-findings}. The size of SLT dataset is several orders of magnitude smaller than NMT dataset. Therefore, SLT task is essentially a low-resource problem.} \label{table1} \end{table} Recently, \citet{camgoz2018neural} contributed the first publicly available SLT dataset, namely PHOENIX14T, which is also the most popular SLT dataset at present. The dataset contains less than 9K parallel sign language videos, sign glosses and spoken language sentences. In their work, the authors formalized the SLT into a Neural Machine Translation (NMT) problem. \begin{figure*}[!htbp] \centering \includegraphics[scale=0.35]{slt} \caption{Cascaded Sign Language Translation. The sign language glosses are consistent meaning and order with sign gestures. However, the word order of sign glosses is different from spoken language sentences as the grammar of sign and spoken languages are vastly different. The spoken language sentence is more clear and coherent. A continuous sign language recognition model is used to recognize sign glosses from sign videos in the first stage. Then, a NMT model is applied to translate the glosses into spoken language sentences in the second stage.} \label{fig1} \end{figure*} And they also found that using gloss as the representation of intermediate supervision can significantly improve the performance of the SLT model compared to an end-to-end method. More specifically, SLT can be divided into two stages: 1) using a Continuous Sign Language Recognition (CSLR) model to recognize sign glosses from sign videos, and 2) using a NMT model to translate the glosses into spoken language sentences. Figure \ref{fig1} depicts two stages of Cascaded SLT. Based on the pipeline approach, \citet{yin-read-2020-better} proposed the STMC-Transformer model and achieved the state-of-the-art performance for SLT. STMC-Transformer first recognized glosses by applying the state-of-the-art CSLR model \cite{zhou2020spatial} and then translated the glosses into spoken sentences by employing vanilla Transformer \cite{vaswani2017attention} as a NMT model. However, SLT systems cannot leverage large-scale annotation data to train deep model like NMT as the size of SLT dataset is several orders of magnitude smaller than NMT dataset. Table \ref{table1} describes the size of dataset of NMT and SLT. The significantly important cause for this gap is that the collection and the annotation of sign language dataset is extremely difficult and expensive. Therefore, SLT task is essentially a low-resource problem. Currently, contrastive learning has become a very popular technique in computer vision and natural language processing community with solid performance \cite{chen2020simple,he2020momentum,chen2020big,wu2020clear,fang2020cert,carlsson2020semantic,giorgi2020declutr,yan-etal-2021-consert}. Recent works \cite{li2020prototypical,pan-etal-2021-contrastive,qin-etal-2021-erica} also demonstrate that contrastive learning has tremendous potential in low-resource scenarios, especially for NMT. \citet{pan-etal-2021-contrastive} proposes a multilingual contrastive learning framework mRASP2 for multilingual NMT which achieves significant improvements (10.26 BLEU) on the 30 zero-shot translation directions. Inspired by the above works, we propose a novel token-level contrastive learning framework to alleviate the low-resource situation for sign language translation, called ConSLT. Unlike previous works whose goal is to obtain better sentence representation, our model aims to learn effective token representation by pushing apart tokens from different sentences. Following the two-stage SLT method, we first use the state-of-the-art CSLR model \cite{zhou2020spatial} to recognize glosses from sign videos. Then, we pass each sign gloss to the Transformer model twice to obtain two different hidden layer representations for each token as “positive pairs”. For each token, we randomly sample K tokens that are not in the current sentence from the vocabulary as negative examples. An overview of ConSLT can be seen in Figure \ref{fig2}. We evaluate ConSLT on the challenging PHOENIX14T dataset. The experimental results demonstrate that our method improves the performance of SLT and outperforms previous state-of-the-art methods. The main contributions of our work are summarized as follows: \begin{itemize} \item we propose a novel token-level contrastive learning method for sign language translation. \item To the best of our knowledge, we are the first to explore contrastive learning for sign language translation from the perspective of NLP. \item ConSLT achieves state-of-the-art performance in translation accuracy on the challenging public dataset PHOENIX14T. \end{itemize} \section{Related Works} \subsection{Sign Language Translation} \citet{camgoz2018neural} first propose an end-to-end neural SLT model that combines Convolutional Neural Networks (CNNs) and the attention-based sequence-to-sequence model to jointly learn how to align and translate from sign videos to spoken language sentences. \citet{camgoz2020multi} proposes a multi-channel SLT architecture to model the inter and intra contextual relationships between different sign channels. \citet{zhou2021spatial} design a spatial-temporal multi-cue network for SL recognition and translation to learn the spatial-temporal collaboration of different visual cues with an end-to-end manner. \citet{camgoz2020sign} introduce a novel framework based on vanilla Transformer due to the superiority of Transformer in sequence modeling tasks. The framework jointly learns CSLR and SLT by introducing gloss as an intermediate supervision to alleviate the long-term dependency issues. \citet{xie2021pisltrc} adopt the Content-aware and Position-aware Temporal Convolution (CPTcn) and the Disentangled Relative Position Encoding (DRPE) to gather neighboring temporal features and inject position information for enhancing the frame-wise sign representation, respectively. \citet{zhou2021improving} propose a two-stage sign back-translation (SignBT) approach, i.e., text-to-gloss and gloss-to-sign, to generate synthetic parallel data as a supplement for SLT training. CDM \cite{jin2021contrastive} employ contrastive constraints between the video frames and spoken language words for signer-independent SLT. Despite the fact that above works have achieved varied degrees of progress, they all pay attention to the improvement of visual feature module. However, we believe that NLP techniques are crucial to translation quality of SLT. \citet{yin-read-2020-better} propose the STMC-Transformer and explore SLT with Transformer on the translation system. Our work also focuses on the translation stage. Unlike the STMC-Transformer, we introduce contrastive loss in the translation stage to learn effective token representations. \subsection{Contrastive Learning} Contrastive learning aims to learn effective representations by contrasting positive pairs and negative pairs. It has been widely used to learn better visual representations for computer vision tasks \cite{oord2018representation,grill2020bootstrap,zhuang2021local}. \citet{chen2020simple} apply a stochastic data augmentation module (cropping, color distortions and Gaussian blur) to generate two correlated views for given data examples. \citet{he2020momentum} elaborately design a momentum update mechanism to build dynamic dictionaries for contrastive learning. \citet{li2020prototypical} propose Prototype Contrastive Learning to implicitly encode the semantic structure of data into the embedding space. Recently, contrastive learning has also gained significant attention in natural language processing community \cite{fang2020cert,carlsson2020semantic,giorgi2020declutr,yan-etal-2021-consert}. \citet{wu2020clear} carefully design and test different data augmentations and combinations to learn a noise-invariant sentence representation. mRASP2 model \cite{pan-etal-2021-contrastive} leverages monolingual data and bilingual data under a unified training framework to close the representation gap of different languages by introducing contrastive learning and aligned augmentation. \citet{gao2021simcse} apply the dropout \cite{srivastava2014dropout} twice acting as minimal data augmentation to obtain two different embeddings as “positive pairs” for each sentence. The above works mainly focus on obtaining better sentence representation. \citet{wei2021learning} learn universal representations across languages by conducting instance-wise comparison at both sentence-level and word-level during pre-training. Different from word-level contrastive learning in \cite{wei2021learning} that aims to distinguish words semantically related to sentences for learning universal representations across languages. Our contrastive learning methods pay attention to generate more accurate and fluent tokens by learn token-level representation for sign language translation. \begin{figure*}[!tbp] \centering \includegraphics[scale=0.58]{model} \caption{Illustration of the ConSLT. For contrastive learning part, we pass each sign gloss to the Transformer model twice to obtain two different hidden layer representations for each token as “positive pairs”. For each token, we randomly sample K tokens from a candidate tokens set $C$ as negative examples, where $C$ denotes all tokens from vocabulary $V$ but not in the current sentence $S$.} \label{fig2} \end{figure*} \section{Approach} Given a sign video $\mathcal{F}_i=\left(f_{1}, \ldots, f_{T}\right)$ with $T$ frames, we first employ a CSLR model to generate its corresponding sign gloss sequence $\mathcal{G}_i=\left(g_{1}, \ldots, g_{U}\right)$ with $U$ glosses. Then, a NMT model translates the gloss sequence into spoken language sentence $\mathcal{S}_i=\left(w_{1}, \ldots, w_{L}\right)$ with $L$ words. Moreover, $\mathcal{V}=\left(v_{1}, \ldots, v_{M}\right)$ is the vocabulary of natural spoken language with $M$ tokens. An overview of our framework for SLT is illustrated in Figure \ref{fig2}. \subsection{Recognition} In the first stage, we apply the state-of-the-art CSLR model STMC \cite{zhou2020spatial} to recognize sign glosses from sign videos. The STMC model consists of the spatial multi-cue module, the temporal multi-cue module and sequence learning module. We formulate the process as: \begin{equation} \mathcal{G}_{i}=\Phi(\mathcal{F}_{i}) \label{eq1} \end{equation} where $\Phi(\cdot)$ denotes STMC network. $\mathcal{F}_i$ represents a sign video sequence and $\mathcal{G}_i$ represents a sign gloss sequence generated by STMC network.We refer to the original STMC paper \cite{zhou2020spatial} for more architecture details. \subsection{Translation} In the second stage, we use Transformer to learn a mapping function to translate from a sign gloss sequence to a spoken language sentence. A little different from vanilla Transformer \cite{vaswani2017attention}, we choose a larger setting with a 2-layer encoder and a 2-layer decoder to prevent over-fitting owing to limited training data. The training loss is cross entropy defined as: \begin{equation} \mathcal{L}_{\mathrm{ce}}=\sum_{\mathcal{G}_{i}, \mathcal{S}_{i} \in \mathcal{D}}-\log P_{\theta}\left(\mathcal{S}_{i} \mid \mathcal{G}_{i}\right) \label{eq2} \end{equation} where $\mathcal{D}$ denotes all parallel datasets. ($\mathcal{G}_{i}$, $\mathcal{S}_{i}$) denote $i$-th parallel sentence pair in $D$. $\theta$ is the parameter of Transformer model. \begin{table*}[!t] \resizebox{160mm}{35mm}{ \begin{tabular}{lcccccccc} \hline \multicolumn{1}{l|}{} & \multicolumn{4}{c|}{Dev} & \multicolumn{4}{c}{Test} \\ \hline \multicolumn{1}{l|}{\textbf{\textit{S2T}}} & BLEU-1 & BLEU-2 & BLEU-3 & \multicolumn{1}{c|}{BLEU-4} & BLEU-1 & BLEU-2 & BLEU-3 & BLEU-4 \\ \hline \multicolumn{1}{l|}{RNN-SLT} & 31.87 & 19.11 & 13.16 & \multicolumn{1}{c|}{9.94} & 32.24 & 19.03 & 12.83 & 9.58 \\ \multicolumn{1}{l|}{SL-Transf} & 46.56 & 34.03 & 26.83 & \multicolumn{1}{c|}{22.12} & 47.20 & 34.46 & 26.75 & 21.80 \\ \multicolumn{1}{l|}{PiSLTRc} & 47.37 & 35.41 & 28.09 & \multicolumn{1}{c|}{23.17} & 48.50 & 35.97 & 28.37 & 23.40 \\ \multicolumn{1}{l|}{SignBT} & \textbf{51.11} & \textbf{37.90} & \textbf{29.80} & \multicolumn{1}{c|}{\textbf{24.45}} & 50.80 & 37.75 & 29.72 & 24.32 \\ \multicolumn{1}{l|}{MCT} & - & - & - & \multicolumn{1}{c|}{22.38} & - & - & - & 21.32 \\ \multicolumn{1}{l|}{STMC-T} & 47.60 & 36.43 & 29.18 & \multicolumn{1}{c|}{24.09} & 46.98 & 36.09 & 28.70 & 23.65 \\ \hline \hline \multicolumn{1}{l|}{\textbf{\textit{S2G2T}}} & BLEU-1 & BLEU-2 & BLEU-3 & \multicolumn{1}{c|}{BLEU-4} & BLEU-1 & BLEU-2 & BLEU-3 & BLEU-4 \\ \hline \multicolumn{1}{l|}{RNN-SLT} & 42.88 & 30.30 & 23.02 & \multicolumn{1}{c|}{18.40} & 43.29 & 30.39 & 22.82 & 18.13 \\ \multicolumn{1}{l|}{SL-Transf} & 47.73 & 34.82 & 27.11 & \multicolumn{1}{c|}{22.11} & 48.47 & 35.35 & 27.57 & 22.45 \\ \multicolumn{1}{l|}{SignBT} & 49.33 & 36.43 & 28.66 & \multicolumn{1}{c|}{23.51} & 48.55 & 36.13 & 28.47 & 23.51 \\ \multicolumn{1}{l|}{STMC-Transf} & 48.27 & 35.20 & 27.47 & \multicolumn{1}{c|}{22.47} & 48.73 & 36.53 & 29.03 & 24.00 \\ \hline \multicolumn{1}{l|}{\textbf{ConSLT}} & 50.47 & 37.54 & 29.62 & \multicolumn{1}{c|}{24.31} & \textbf{51.29} & \textbf{38.62} & \textbf{30.79} & \textbf{25.48} \\ \hline \end{tabular}} \caption{Comparison with methods for SLT on PHOENIX14T. \textbf{\textit{S2T}} denotes the end-to-end SLT model. \textbf{\textit{S2G2T}} denotes the cascaded SLT model. (the higher the better)} \label{table2} \end{table*} \subsection{Token-level Contrastive Learning} Most previous works based on contrastive learning aim to obtain better sentence representations. However, NMT generates each word by conditioning on previously generated words. In other words, NMT is a token level NLP task. Thus, we propose a model based on token-level contrastive learning, which aims to learn effective token representation by pushing apart tokens from different sentences. \textbf{Positive pairs}. Given a gloss-translation pairs $(\mathcal{G}_{i}, \mathcal{S}_{i})$, we pass $\mathcal{G}_{i}$ to the Transformer model twice. Since the dropout mechanism randomly drops part of units in fully-connected layers and attention probabilities of the Transformer, we can obtain two different hidden layer representations, denoted as $\mathcal{H}_{i}=\{h_j\}_{j=1}^{L}$ and $\mathcal{H}_{i}^{+}=\{h_{j}^{+}\}_{j=1}^{L}$, where $\mathcal{H}_{i}$, $\mathcal{H}_{i}^{+} \in \mathbb{R}^{L \times d}$. $L$ is the sequence length and $d$ is the hidden size. We construct the “positive pairs” ($h_j, h_{j}^{+}$) from $\mathcal{H}_{i}$ and $\mathcal{H}_{i}^{+}$ for each token. \textbf{Negative pairs}. We randomly sample $K$ token representations from candidate token representations $\mathcal{C}_{i}$ to construct a set of negative samples $\mathcal{Z}_{j}=\{z_k\}_{k=1}^{K}$ for each token representation $h_j$. $\mathcal{C}_{i}$ denotes all tokens from vocabulary $\mathcal{W}$ but not in the current sentence $\mathcal{S}_i$, i.e., $\mathcal{C}_{i} \subset \mathcal{W} \backslash \mathcal{S}_i$. $\mathcal{W}$ is the weight matrix of linear output layer, which is an $|V| \times d$ matrix, where $|V|$ denotes the vocabulary size. Each row of $\mathcal{W}$ is the $d$-dimension vector representation of token from vocabulary. Thus, We can construct the “negative pairs” ($h_j, \mathcal{Z}_{j}$) for each token. \textbf{Distance Metric}. Previous work used inner product operation or cosine function to calculate similarity of positive and negative pairs. We adopt KL-divergence as the distance metric of contrastive learning as we believe that KL loss is more stringent compared to cosine loss. When the cosine loss of two vectors is 1, KL loss is not necessarily 0. For example, given two vectors $a=[1.0, 2.0, 3.0]$ and $b=[20.0, 40.0, 60.0]$, then $cos(a,b)=1$, but $KL(a,b)=4.04$. Experimental results in Table \ref{diff_cl} show the effectiveness of our method. The objective of contrastive learning is to minimize the following loss: \begin{equation} \mathcal{L}_{\mathrm{ctr}}=-\sum_{\mathcal{G}_{i} \in \mathcal{D}} \sum_{h_{j} \in \mathcal{H}_{i}} \log \frac{e^{\Omega\left(h_{j}, h_{j}^{+} \right) / \tau}}{\sum_{k \in K} e^{\Omega \left(h_{j}, z_{k} \right) / \tau}} \label{eq3} \end{equation} \begin{equation} \Omega\left(h_{j}, h_{j}^{+} \right) = \frac{1}{2}(KL(h_{j}||h_{j}^{+})+KL(h_{j}^{+}||h_{j})) \label{eq4} \end{equation} where $\tau$ is a temperature hyperparameter. We calculate the bidirectional KL-divergence as the KL-divergence is a non-symmetric measure. Finally, during the training of ConSLT, the model can be optimized by jointly minimizing the translation loss and contrastive training loss: \begin{equation} \mathcal{L}=\mathcal{L}_{\mathrm{ce}}+\alpha\mathcal{L}_{\mathrm{ctr}} \label{eq5} \end{equation} where $\alpha$ is the coefficient weight to balance the two training losses. \section{Experiments} \subsection{Dataset and Metrics} PHOENIX14T \cite{camgoz2018neural} is the current benchmark for SLT, and we evaluate our model on this challenging dataset. PHOENIX14T is a dataset from the German Weather Forecast, a parallel corpus containing sign language videos, gloss annotations, and spoken language translations. The dataset is divided into Train, Dev and Test with sizes 7095, 519 and 642, respectively. The corpus contains sign languages from 9 different signers with 1066 different sign language glosses and 2887 different words translated into spoken German. To measure the SLT performance, we apply BLEU \cite{papineni-etal-2002-bleu} scores, which are common metrics for NMT. BLEU measures the quality of translation based on precision. And we use BLEU-1,2,3,4 to measure the translation of different phrase levels based the multi-bleu.pl script\footnote{https://github.com/moses-smt/mosesdecoder}. \subsection{Implementation Details} \label{subsec_details} We follow the STMC-Transformer \cite{yin-read-2020-better} with PyTorch \cite{paszke2019pytorch} and Open-NMT \cite{klein-etal-2017-opennmt} to implement ConSLT and set hyperparameters. \\ \textbf{Network Details}: Both encoder and decoder of Transformer have 2 layers. The size of the word embedding, the hidden and the feed-forward are 512, 512 and 2048, respectively. We use 8 attention heads for each layer. And the total parameters count of ConSLT is 17.7$M$. \\ \textbf{Training}: We init network parameters with Xavier \cite{pmlr-v9-glorot10a} uniform. And we use a shared weight matrix for the input and output word embeddings in the decoder during training. We adopt the Adam optimizer \cite{kingma2014adam} with $\beta_1= 0.9$, $\beta_2=0.998$, and Noam learning rate schedule. Networks are trained with batch size 2,048 and initial learning rate 0.6. The dropout rate and label smoothing \cite{when2019rafael} is set to 0.3 and 0.1, respectively. we follow \cite{yan-etal-2021-consert} to set the temperature $\tau$ in Eq.\ref{eq3} with 0.1. We carry out grid-search of the number of negative samples $K \in \{100,200,300,400,500\}$ and the $\alpha \in \{0.1,0.3,0.5,0.7,1,2.5,5,10,20\}$ of Eq.\ref{eq5} on PHOENIX14T development set. The experimental results are shown in Figure \ref{diff_num} and Figure \ref{diff_a}, respectively. And we set $K$ and $\alpha$ to 500 and 0.5 in our experiments, respectively. Note that we evaluate accuracy on the dev dataset every 100 steps and perform early stopping with patience 3. ConSLT requires to be trained on 1 NVIDIA TITAN RTX GPU with 24 GB memory for 4 hours. \\ \textbf{Decoding}: For decoding during the inference process, the generated \textit{<unk>} tokens are replaced by the source token with the highest attention weight. We also employ the beam search strategy with width 6. \begin{table}[!tbp] \centering \begin{tabular}{l|cccc} \hline & B-1 & B-2 & B-3 & B-4 \\ \hline w/o CL & 48.73 & 36.53 & 29.03 & 24.00 \\ w/ S-CL + cos & 48.48 & 37.17 & 29.49 & 24.36 \\ w/ T-CL + cos & 49.91 & 37.60 & 29.88 & 24.59 \\ w/ S-CL + KL & 50.82 & 38.04 & 30.23 & 25.07 \\ w/ T-CL + KL & \textbf{51.57} & \textbf{38.81} & \textbf{30.91} & \textbf{25.48} \\ \hline \end{tabular} \caption{Results of ablation study on the PHOENIX14T test set. (B-n: BLEU-n)} \label{diff_cl} \end{table} \begin{table}[!tbp] \centering \begin{tabular}{c|cccc} \hline & B-1 & B-2 & B-3 & B-4 \\ \hline Batch & 50.69 & 37.93 & 30.09 & 24.79 \\ Vocab & 51.20 & 38.33 & 30.45 & 25.14 \\ Vocab-Sent & \textbf{51.57} & \textbf{38.81} & \textbf{30.91} & \textbf{25.48} \\ \hline \end{tabular} \caption{BLEU scores with different sampling strategies of negative samples on the PHOENIX14T test set.} \label{diff_s} \end{table} \subsection{Comparison Results} In Table.\ref{table2}, we compare ConSLT with several methods for the SLT on the PHOENIX14T dataset. Our results are averaged over 10 runs with different random seeds. The \textbf{RNN-SLT} \cite{camgoz2018neural} only adopt full frame features from Re-sign. \textbf{SL-Transf} \cite{camgoz2020sign} models utilize pre-trained features from CNN-LSTM-HMM and jointly learn sign language recognition and translation. \textbf{PiSLTRc} \cite{xie2021pisltrc} uses position-informed temporal convolution base on \textbf{SL-Transf}. \textbf{SignBT} \cite{zhou2021improving} uses Sign Back-Translation for data augmentation. \textbf{MCT} \cite{camgoz2020multi} and \textbf{STMC-T} \cite{zhou2021spatial} are evaluated under multi-cue setting. \textbf{STMC-Transf} \cite{yin-read-2020-better} uses vanilla Transformer for SL translation with STMC gloss. Our method can substantially improve translation quality for SLT, largely outperforming the previous state-of-the-art. Specifically, compared with the \textbf{SignBT}, ConSLT achieves competitive results on the PHOENIX-2014-T dev set as \textbf{SignBT} utilizes external monolingual data through sign back translation. To our surprise, ConSLT outperforms SignBT 1.16 BLEU-4 on the PHOENIX-2014-T test set. Moveover, ConSLT gains an improvement of 1.83 BLEU-4 on PHOENIX14 test set compared with the end-to-end spatial-temporal multi-cue network \textbf{STMC-T}, 1.48 BLEU-4 compared with \textbf{STMC-Transf}. Experiments demonstrates that introducing contrastive learning could bring notable performance gain for SLT. \section{Analysis} \begin{figure}[!tbp] \centering \begin{tikzpicture}[baseline] \centering \begin{axis}[ every axis/.append style={line width=0.8pt}, xlabel={The number of negative samples}, yticklabel style={/pgf/number format/precision=2,/pgf/number format/fixed zerofill}, ylabel={BLEU-4}, enlargelimits=0.05, xmin=100, xmax=500, ymin=24.5, ymax=25.5, xtick={100,200,300,400,500}, ytick={24.50,24.75,25.00,25.25,25.50}, legend pos=north west, ymajorgrids=true, xmajorgrids=true, grid style=dashed, ] \addplot[ color=red, mark=triangle, ] coordinates { (100,24.72) (200,25.17) (300,25.28) (400,25.27) (500,25.48) }; \end{axis} \end{tikzpicture} \caption{The effect of different number of negative samples on the PHOENIX14T test set.} \label{diff_num} \end{figure} \begin{figure*}[!tbp] \centering \subfigure[STMC-Transformer]{ \includegraphics[scale=0.42]{stmc} } ~~~~~~ \subfigure[ConSLT]{ \includegraphics[scale=0.42]{ours} } \caption{Visualization of token embeddings in (a) STMC-Transformer, (b) ConSLT trained on PHOENIX14T.} \label{visual} \end{figure*} \subsection{Ablation Study} We perform the ablation study to investigate the influence of contrastive learning for SLT. First, following SimCSE \cite{gao2021simcse}, we train a model with sentence-level contrastive learning framework. More specifically, we pass the sign gloss to the vanilla Transformer \cite{vaswani2017attention} and obtain two sentence representations as “positive pairs”. We treat other sentence representations within a minibatch as negative examples. To make the comparisons fair, we apply cosine function and KL-divergence to calculate the distance of positive and negative pairs for the ablation experiments, respectively. We also set the number of negative samples to 500. For notation, \textbf{w/o CL} means no contrastive learning method, \textbf{S-CL} means sentence-level contrastive learning, \textbf{T-CL} means our token-level contrastive learning. As shown in Table \ref{diff_cl}, we can see that the different contrastive learning methods used in SLT all bring significant improvements. Furthermore, ConSLT gains improvements of +0.41 BLEU scores, compared with sentence-level contrastive learning. This further demonstrates that ConSLT is more suitable for SLT as our approach can obtain fine-grained token representations. As illustrated in Table \ref{diff_cl}, ConSLT which adopt KL-divergence as the distance metric of contrastive learning is better than cosine function. We speculate about the possible reason is that learning similar representations via KL-divergence is more difficult than via cosine function. Therefore, ConSLT achieves better performance in SLT. \subsection{Sampling strategy of negative samples} We further conduct comparative experiments to analyze the effectiveness of sampling strategy of negative samples in contrastive learning. We explore three sampling strategies. For notation, \textbf{Batch} denotes randomly sampling negative samples for each token from a mini-batch. \textbf{Vocab} denotes randomly sampling negative samples for each token from the vocabulary of spoken language sentences. \textbf{Vocab-Sent} denotes randomly sampling negative samples for each token from the vocabulary but not in the current sentence. Table \ref{diff_s} presents the results. \textbf{Vocab} substantially outperforms \textbf{Batch}. This gap is because the tokens in the vocabulary are more diverse than those in a mini-batch. Moreover, \textbf{Vocab-Sent} performs better than other methods. This indicates that the tokens in the same sentence should be semantically similar due to the contextual relationship, which is similar to predicting the masked token based on its contextual information in the masked language model. It also enhances the relationship between the masked token and its context. Therefore, the different tokens from the same sentence cannot be pushed apart. The comparative experiments also demonstrate ConSLT can obtain better token representations for SLT. \subsection{The number of negative samples} Different number of negative samples may affect the translation performance, so we further test our model with respect to different number of negative samples. We vary $K$ in $\{100,200,300,400,500\}$ to see the difference. We report the results in Figure \ref{diff_num}, from which we observe that the performance improves steadily when increasing the number of negative samples. The result supports the insight of \citet{chen2020simple} that more negative samples benefit the performance for contrastive learning. Note that when we increase K to 600, the out-of-memory issues on GPU will be triggered. \begin{table*}[!t] \scriptsize \centering \begin{tabular}{|ll|} \hline REF & morgen reichen die temperaturen von zweiundzwanzig grad an der ostsee bis zweiunddreißig grad am oberrhein. \\ & (tomorrow the temperatures will range from twenty-two degrees on the baltic sea to thirty-two degrees on the upper rhine.) \\ STMC-Transf & morgen temperaturen von zweiundzwanzig grad an der ostsee bis zweiunddreißig grad am oberrhein. \\ & (tomorrow temperatures from twenty-two degrees on the baltic sea to thirty-two degrees on the upper rhine.) \\ OUR & morgen \textbf{reichen die} temperaturen von zweiundzwanzig grad an der ostsee bis zweiunddreißig grad am oberrhein. \\ & (tomorrow the temperatures will range from twenty-two degrees on the baltic sea to thirty-two degrees on the upper rhine.) \\\hline \hline REF & im westen und nordwesten fallen einzelne schauer. \\ & (individual showers fall in the west and north-west.) \\ STMC-Transf & im westen und nordwesten gibt es einzelne schauer. \\ & (in the west and northwest there are a few showers.) \\ OUR & im westen und nordwesten fallen \textbf{nur} einzelne schauer. \\ & (in the west and northwest there are only a few showers.) \\ \hline \hline REF & und zum wochenende wird es dann sogar wieder ein bisschen kälter. \\ & (and at the weekend it even gets a little colder again.) \\ STMC-Transf & zum wochenende wird es dann auch wieder kälter. \\ & (at the weekend it gets colder again.) \\ OUR & \textbf{und} zum wochenende wird es dann auch wieder kälter. \\ & (and at the weekend it gets colder again.) \\ \hline \hline REF & der wind weht schwach bis mäßig am meer auch frisch. \\ & (the wind blows weak to moderate at the sea also fresh.) \\ STMC-Transf & schwacher bis mäßiger an der see teilweise frischer wind. \\ & (weak to moderate at the lake partly fresh wind.) \\ OUR & der wind weht schwach bis mäßig \textbf{an den küsten} auch frisch. \\ & (the wind blows weak to moderate on the coasts also fresh.) \\ \hline \hline REF & und nun die wettervorhersage für morgen freitag den achten oktober. \\ & (and now the weather forecast for tomorrow, friday, october eighth.) \\ STMC-Transf & und nun die wettervorhersage für morgen freitag den achtundzwanzigsten oktober. \\ & (and now the weather forecast for tomorrow, friday, october twenty-eighth.) \\ OUR & und nun die wettervorhersage für morgen freitag den \textbf{achten oktober}. \\ & (and now the weather forecast for tomorrow, friday, october eighth.) \\ \hline \hline REF & am tag von schleswig holstein bis nach vorpommern und zunächst auch in brandenburg gebietsweise länger andauernder regen. \\ & (On the day from Schleswig-Holstein to Western Pomerania and initially also in Brandenburg, there was prolonged rain in some areas.) \\ STMC-Transf & herrlicher sonnenschein in schleswig holstein in brandenburg in brandenburg bis morgen früh. \\ & (wonderful sunshine in schleswig holstein in brandenburg in brandenburg until tomorrow morning.) \\ OUR & also von schleswig holstein bis nach nordrhein westfalen in sachsen und brandenburg wird es morgen den ganzen tag bei \textbf{dauerregen}. \\ & (so from schleswig holstein to north rhine westphalia in saxony and brandenburg it will rain all day tomorrow.) \\ \hline \end{tabular} \caption{Qualitative comparison of STMC-Transformer and Our method on PHEONIX-2014T. REF refers to the reference German translation.} \label{case} \end{table*} \subsection{Visualizing Token Embeddings} We also visualize the token embeddings learned by ConSLT on PHOENIX14T. The visualization is generated employing t-SNE \cite{vandermaaten2008tsne} where each point represents a token from vocabulary. As shown in Figure \ref{visual} (a), we can obvious that the majority of token embeddings are squeezed into a more narrow space, which is consistent with the representation collapse phenomenon proposed by \citet{gao2018representation}. As a comparison shown in Figure \ref{visual} (b), this problem is alleviated by the token-level contrast of hidden representations. Our token-level contrastive learning can produce a more uniform representation space compared with STMC-Transformer to generate more accurate and fluent tokens for sign language translation. \subsection{ Qualitative Analysis} We show several examples of different models in the SLT task. As the annotation of PHOENIX14T is in German, we provide its corresponding English translation. Compared with the \textbf{STMC-Transf} model, our method generates spoken language sentences with better accuracy and fluency. In the first three examples in the table \ref{case}, comparing the translation of our model with that of \textbf{STMC-Transf}, our model pays more attention to details and sentence fluency. And in the third example, it even translates conjunctions like und (and). In the fourth example, our model translates “am meer” (near the sea) into “an den küsten” (on the coasts), which has the similar meaning. Comparing the translations of the two models, it is obvious that our model translates the whole sentence more completely and smoothly. In the fifth example, “achten oktober” (eighth october) is mistranslated by \textbf{STMC-Transf} as “achtundzwanzigsten oktober” (twenty eighth october), due to the lack of sufficient training data and sufficient context, so specific numbers are often difficult to translate accurately. While our model can learn better token representations to obtain the correct translation. In the sixth example, the original word appears as “regen” (rain), and our model translates it as “dauerregen” (continuous rain). While \textbf{STMC-Transf} translates it as “sonnenschein” (sunshine), which is wrong. From these examples, we can see that our model generates more complete sentences and fewer under-translation sentences. Our model can achieve smoother and more accurate translations. \section{Conclusion} In this work, we propose ConSLT, a contrastive learning framework for SLT, which aims to learn effective token representations by pushing apart tokens from different sentences. We also explore the impact of different contrastive strategies and provide fine-grained analysis for interpreting how our approach works. The experimental results demonstrate that contrastive learning can significantly improve translation quality for SLT. We hope our work will provide a new perspective for future researches on SLT. As to the limitations of this work, ConSLT depends on generating an intermediate gloss sequence to perform the SLT task. However, gloss sequences are not always available due to the expensive annotation and difficult collection. In future work, we will continue to study end-to-end SLT from the perspective of NLP. \input{acl_latex.bbl} \bibliographystyle{acl_natbib}
{'timestamp': '2022-04-12T02:34:16', 'yymm': '2204', 'arxiv_id': '2204.04916', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04916'}
arxiv
\section{Introduction} \emph{Functional Connectome} (FC) refers to the network of interactions between units of the brain, such as individual neurons or brain regions, with respect to their activity over time \citep{reid2012functional}. The aim of finding the FC is to provide insight into how neurons interact to form brain function. FC can be represented by a graph whose nodes represent neurons and edges indicate a relationship between the activity of connected neurons. The edges can either represent undirected stochastic associations between activity of neurons or directed causal relationships between activity of neurons. While association between neural activity describes whether neuron $A$ and neuron $B$ are active in a correlated manner, the ultimate goal of functional connectomics is to answer causal queries, such as whether the activity in neuron $A$ causes neuron $B$ to be active $(A\rightarrow B)$, or is it the other way around $(B\rightarrow A)$? Else, does a neuron $C$ intermediate the correlation between $A$ and $B$ $(A\leftarrow C \rightarrow B)$ \citep{reid2019advancing,cassidy2021functional,sanchez2021combining}? When the interactions are causal, the network is termed as \emph{causal functional connectome} (CFC). The CFC maps how neural activity flows within neural circuits, and provides the possibility for inference of neural pathways essential for brain functioning and behavior, such as sensory-motor-behavioral pathways \citep{finn2015functional}. Several approaches aim to infer CFC, such as Granger Causality (GC), Dynamic Causal Modeling (DCM), and Directed Probabilistic Graphical Models (DPGM), each having their applicability and challenges, as surveyed in \citep{biswas2021statistical}. GC obtains the directed functional connectivity from observed neural activity in a way that tells whether a neuron’s \emph{past} is predictive of another neuron's future, however it is unclear whether the prediction implies causation. In contrast, DCM compares \emph{specific} mechanistic biological models based on data evidence, in which, model parameters represent causal influences between hidden neural states \citep{sharaev2016effective}. On the other hand, DPGM is a generic procedure to obtain causal relationships between nodes of a network from observations, using the \emph{directed Markov} property. DPGM is non-parametric in the sense of capturing arbitrary functional relationships among the nodes and is predictive of the consequence of counterfactual interventions to the network \citep{lauritzen2001causal,maathuis2018handbook}. Such properties make DPGM a popular approach for causal modeling in various disciplines such as genomics and econometrics~\citep{gomez2020functional, ahelegbey2016econometrics, ebert2012causal, kalisch2010understanding, deng2005structural, haigh2004causality,wang2017potential,sinoquet2014probabilistic, mourad2012probabilistic, wang2005new, liu2018functional, friedman2004inferring}. The utility of DPGM in obtaining CFC from neural data has been investigated in \citep{biswas2021statistical}. DPGM, applicable to i.i.d. observations, can model causal relations between whole time series of different neurons in sense of average over time or at a specific time. Thereby, standard DPGM does not explicitly model the inter-temporal causal relations between neural activity in the time series. For inference of the DPGM, the PC algorithm is one of the widely used causal inference algorithms that assumes independent and identically distributed (i.i.d.) sampling of the nodes of the network and absence of latent confounders \citep{spirtes2000causation,pearl2009causality}. However, in neural time series scenario, causal relations are between neural activity at different times. Assuming independent sampling of nodes of the common DPGM is not suitable as the nodes correspond to a time series with temporal dependency. Moreover, DPGM typically generate a Directed Acyclic Graph (DAG), while neural activity is often comprised of feedback loops over time \citep{fiete2010spike,arbabshirani2019autoconnectivity,borisyuk1999oscillatory,jutras2010synchronous}. Though adaptations aim to include cycles in the DPGM they have a more complicated output \citep{richardson1996automated}. Addressing these limitations will improve the utility of DPGM for finding CFC in the neural time series scenario and is the focus of this work. In this work, we develop a novel approach for modeling and estimating causal functional connectivity by adapting directed probabilistic graphical models to the time series scenario. We introduce the \emph{Time-Aware PC} (TPC) algorithm. It uses the PC algorithm as a starting point and adapts it to the neural time series setup by following processes such as time-delay, bootstrapping and pruning. These ensure that the inferred CFC is robust and well suited to the setup. The proposed CFC graphical model incorporates feedback loops in functional connectivity and is non-parametric, yet we show that the CFC graphical model accurately represents the causal relationships in the unknown dynamical process of neural activity. Furthermore, the proposed CFC graphical model is predictive of the consequence of counterfactual interventions, such as the alteration in the CFC due to ablation or external control of certain neurons. We apply the proposed methodology on neural signals simulated from different paradigms and CFC motifs and demonstrate the utility of TPC in recovering the generating motifs. We also apply the TPC on public benchmark datasets and compare the performance in recovery of the ground truth CFC with other approaches. We further demonstrate the use of TPC to obtain the CFC among sampled neurons in mice brain from electrophysiological neural signals. The following is a list of acronyms used in this paper: Functional Connectivity (FC), Causal Functional Connectivity (CFC), Granger Causality (GC), Dynamic Causal Model (DCM), Directed Probabilistic Graphical Model (DPGM), Directed Markov Property (DMP), Functional Magnetic Resonance Imaging (fMRI), Probabilistic Graphical Model (PGM), i.i.d. (Independent and Identically Distributed), Markov Property (MP), Directed Acyclic Graph (DAG), Peter Clark (PC), Greedy Equivalence Search (GES), Greedy Interventional Equivalence Search (GIES), Continuous Time Recurrent Neural Network (CTRNN), True Positive (TP), False Positive (FP), True Negative (TN), False Negative (FN), True Positive Rate (TPR), False Positive Rate (FPR). \section{Causal Functional Connectivity for Static Variables - Review}\label{sec:dgm} In this section, we provide a concise summary of DPGM for finding CFC for static variables, i.e. variables with \textbf{i.i.d. samples}, and extend in later sections to incorporate temporal dependence in time series. Let us consider a brain network $V=\{v_1,\ldots, v_N\}$ with $N$ neurons labeled as $v_1,\ldots,v_N$ and $X_v (t) \in \mathbb{R}$ denote a random variable measuring the activity of neuron $v$ at time $t$. Examples for such variables are instantaneous membrane potential, instantaneous firing rate, etc. Let $Y_v$ denote a scalar-valued random variable corresponding to $v\in V$, e.g., the neural recording at time $t$: $Y_v=X_v(t)$, average of recordings over time $Y_v=\bar{X}(v)$, and for a set of neurons $A\subset V$, $\bm{Y}_A$ denotes the random vector $(Y_v, v\in A)$. Let $G=(V,E)$ denote a \emph{directed acyclic graph} (DAG), i.e., a directed graph without directed cycles, over the neurons in $V$ and with directed edges $E$. Nodes $u$ and $v \in V$ are said to be \emph{adjacent} if $v\rightarrow u \in E$ or $u\rightarrow v \in E$. A \emph{path} is a sequence of distinct nodes in which successive nodes are adjacent. For a path $\pi = (v_0,\ldots, v_k)$, if every edge of $\pi$ is of the form $v_{i-1}\rightarrow v_{i}$ then $v_0$ is an \emph{ancestor} of $v_k$ and $v_k$ is a \emph{descendant} of $v_0$. The set of \emph{non-descendants} of $v$, denoted $nd_G(v)$, contains nodes $u\in V\setminus \{v\}$ that are not descendants of $v$. The set of \emph{parents} of $v\in V$ is denoted as $pa_G(v) =\{u\in V: u\rightarrow v\in E\}$. We mark the set $nd_G (v)\setminus pa_G (v)$ as the set that contains all nodes which are older ancestors of $v$ before its parents \citep{lauritzen2001causal,maathuis2018handbook}. We use the convention that $u-v \in G \Rightarrow u\rightarrow v \in G$ and $u\leftarrow v \in G$. With these notations, we highlight the \emph{Directed Markov Property} (DMP) and its functional equivalence for DPGM. The DMP connects probabilistic conditional independencies between nodes of a directed graph with relationships of causal influence by ensuring that the influence of each node's ancestors beyond parents reaches to the node exclusively via its parents. Furthermore, the functional equivalence for DPGM shows that, the edges in a DPGM satisfying the DMP are consistent with causal functional interactions among the nodes. \paragraph{Directed Markov Property (DMP)} $(Y_v,v\in V)$ is said to satisfy the \emph{Directed Markov Property} with respect to the DAG $G$ if and only if, \begin{equation}\label{eq:dgmarkov} Y_v\perp\!\!\!\!\perp \bm{Y}_{nd_G (v)\setminus pa_G (v)}|\bm{Y}_{pa_G (v)} \end{equation} The DMP translates the edges in the DAG into conditional independencies, such that each node $Y_v$ and its older ancestors $\bm{Y}_{nd_G (v)\setminus pa_G (v)}$ are conditionally independent given its parents $\bm{Y}_{pa_G}(v)$. The DMP can be equivalently represented with functional relationships between parent and child instead of conditional independencies, which is described in the following theorem \citep{bollen1989structural}. \paragraph{Functional Equivalence of DMP}\label{thm:fnequiv} If $Y_v$ satisfies \begin{equation}\label{eq:causaleff-structural}Y_v = g_v(Y_{pa_{\tilde{G}}(v)}, \epsilon_v), v\in V\end{equation} where $\epsilon_v$ are independent random variables and $g_v$ are measurable functions for $v\in V$ and $\tilde{G}$ is a DAG with vertices $V$, then $Y_v, v\in V$ satisfies the Directed Markov Property with respect to $\tilde{G}$. Conversely, if $Y_v,v\in V$ satisfies the Directed Markov Property with respect to a DAG $\tilde{G}$, then there are independent random variables $\epsilon_v$ and measurable functions $g_v$ for which Eq. (\ref{eq:causaleff-structural}) holds. This shows that if $Y_v, v\in V$ satisfies the DMP with respect to the DAG $G$, then $G$ admits a natural causal interpretation, due to its functional equivalence: parent nodes of $v$ in $G$ causally influence the child node $v$ \citep{drton2017structure}. \paragraph{PC algorithm} Let $Y_v, v\in V$ satisfy the DMP with respect to the DAG $G$. The PC algorithm is a popular method to infer $G$ from observed data \citep{spirtes2000causation}. The PC algorithm uses a consistent statistical test, such as Fisher's Z-transform when $Y_v, v\in V$ are Gaussian variables, and kernel and distance based tests for non-Gaussian variables \citep{kalisch2007estimating,tillman2009nonlinear}. The algorithm first represents the observed variables by nodes of a graph and starts with an empty set of edges and puts an undirected edge between each pair of nodes if they are independent or conditionally independent given any other variable(s) determined by the statistical test. This results in the undirected skeleton graph, which is then converted into a DAG by directing the undirected edges using rules for orientation. The PC algorithm estimates several DAGs $\hat{G}_{i}$ based on i.i.d. samples of $Y_v,v\in V$, and outputs a single completed partially directed acyclic graph (CPDAG) $\hat{G}$ defined as follows: $\hat{G}$ has a directed edge from node $v \rightarrow w$ if $v\rightarrow w$ is present in all the DAGs $\hat{G}_{i}$. It has an undirected edge between $v$ and $w$ if either directions between them are present among the DAGs $\hat{G}_{i}$. It has no edge between $v$ and $w$ if no edge is present between them in any of the DAGs $\hat{G}_{i}$. The CPDAG $\hat{G}$ is uniquely identifiable from observed data. The PC algorithm assumes \emph{causal sufficiency} of the input variables: A set $V$ of variables is causally sufficient for a population if and only if in the population every common cause of any two or more variables in $V$ is in $V$, or has the same value for all units in the population. Another method, the FCI algorithm, is applicable when causal sufficiency does not hold \citep{spirtes1999algorithm}. However, while the PC algorithm can identify direct causes, FCI algorithm cannot distinguish between direct and indirect causes. Let $P$ denote the probability distribution of $Y_v, v\in V$. The PC algorithm also assumes \emph{faithfulness} of the DAG $G$ to $Y_v, v\in V$: if the DMP with respect to $G$ encompasses all the conditional independence relations due to $P$, $G$ is said to be \emph{faithful} to $Y_v, v\in V$. Using a consistent statistical test for conditional independence, and assuming causal sufficiency and faithfulness, the PC algorithm estimate, $\hat{G}$, is consistent for $G$; that is, $\hat{G}$ converges in probability to $G$ with increasing number of samples in data \citep{zhang2012strong,spirtes2000causation}. \section{Causal Functional Connectivity for Time Series} In this section, we propose a novel methodology for modeling and estimation of the CFC for time series. This methodology is generic and applicable to various time series including neural recordings. The CFC is represented by a graph with nodes as neurons, each corresponds to a time series of neural activity, and edges indicating causal connectivity. In the following, we show we can explicitly model causal relations within and between time series in a DPGM framework and use it to define the CFC. \subsection{Unrolled Graphical Modeling of Time Series} \label{subsec: causalfc-temporal} We aim to incorporate the causal influence of the activity of neuron $u$ at time $t_1$ upon the activity of neuron $v$ at time $t_2$ in our proposed model. To do that, we \emph{unroll} the time series $X_v(t), v\in V,0\leq t\leq T$ into nodes $(v,t)$ for neuron $v$ and time $t$ where the node $(v,t)$ corresponds to the variable $X_v(t)$. We use directed edges between the nodes $(v,t)$ to represent causal relations between $X_v(t)$. For example, the edge $(u,t_1)\rightarrow (v,t_2)$ represents the causal influence of the activity of neuron $u$ at time $t_1$, $X_v(t_1)$ upon the activity of neuron $v$ at time $t_2$, $X_v(t_2)$. Let $\bm{V} = \{(v,t), v\in V,0\leq t\leq T\}$ be the set of nodes in the unrolled time series, $\bm{E}$ be the set of directed edges between the nodes and $\bm{G}=(\bm{V},\bm{E})$ be the \emph{Unrolled Graph} for the time series (See Figure \ref{fig:causal-def-example}-middle). We assume that $\bm{G}$ is a DAG in which there are no cycles in the edges in $E$. \begin{figure}[t] \centering \includegraphics[width = \textwidth]{ExampleUnrolledGraph.pdf} \caption{Causal modeling of the neural time series (left) by the \emph{Unrolled Causal Graph} (middle), and then rolling back its edges (red) to define the \emph{Rolled CFC-DPGM} (right).}\label{fig:causal-def-example} \end{figure} Causal relationships between neurons are either forward in time: (1) from neurons $u$ at time $t_1$ to neuron $v$ at time $t_2$ for $t_1<t_2$, represented by $(u,t_1)\rightarrow (v,t_2)$ for $t_1<t_2$ in $\bm{G}$; or, (2) contemporaneous: when causal influences occur more rapidly than the sampling interval of the time series, represented in $\bm{G}$ by $(u,t)\rightarrow (v,t)$ at time $t$ \citep{swanson1997impulse,runge2019inferring}. Causal relations cannot direct backward in time, that is, $\bm{G}$ will not contain $(u,t_1)\rightarrow (v,t_2)$ for $t_1>t_2$. Furthermore, for the contemporaneous causal influences, we do not allow the activity of $u$ at time $t$ to have causal influence on itself at time $t$, that is $(u,t)\rightarrow (u,t)$ is not allowed, while $(u,t)\rightarrow (v,t)$ is allowed. These considerations imply the absence of cycles in $\bm{G}$, thereby justifying the assumption for $\bm{G}$ to be a DAG to model the causal interactions in the unrolled time series. In practice, the true causal interactions between $X_v(t)$ are unknown. Yet, when $\bm{X} = \{X_v(t):(v,t)\in \bm{V}\}$ satisfies the DMP with respect to DAG $\bm{G}$, then it implies that $\bm{G}$ captures the causal functional interactions among $X_v(t)$, as we show in the functional equivalence of DMP in Section \ref{sec:dgm}. We refer to such a DAG $\bm{G}$ as the \emph{Unrolled Causal Graph} for the time series $X_v(t),v\in V,t\in T$. \subsection{Rolled CFC-DPGM} Typically for signals, effective CFC representation refers to relations between neurons rather than relations between different signals' times. Thereby, we propose to roll back the unrolled causal DAG $\bm{G}$ to define CFC between neurons (See Figure \ref{fig:causal-def-example}-right). The rolled graph is based on the principle that the existence of a causal relationship from neuron $u$ at time $t_1$ to neuron $v$ at time $t_2$, $(u,t_1)\rightarrow (v,t_2)\in \bm{G}$ for $t_1<t_2$, would imply that $u$ is connected to $v$ in the rolled CFC. In practice, the causal interactions weaken as the time-gap $t_2-t_1$ grows. Thereby, we consider a maximum time-delay of interaction, $\tau$, so that $(u,t_1)$ and $(v,t_2)$ would not share a significant influence between them if the time gap $t_2-t_1>\tau$ for all neurons $u,v$. Such a consideration of the maximum time-delay aids in making statistical inference from the time series data. Thus, if $(u,t_1)\rightarrow (v,t_2)$ in $\bm{G}$ for some $t_1\leq t_2\leq t_1+\tau$, then the CFC graph between neurons should include $u\rightarrow v$. We consolidate these concepts to define causal functional connectivity between neurons based on DPGM, in the following. \begin{definition}[Rolled CFC-DPGM]\label{def:causalfc_td} Let $\bm{X}$ satisfy the DMP with respect to DAG $\bm{G}=(\bm{V},\bm{E})$. The \emph{Rolled CFC-DPGM} for neurons in $V$ with maximum time-delay of interaction $\tau$, is defined as the directed graph $F_{\tau}$ having edge $u\rightarrow v$ if $(u,t_1)\rightarrow (v,t_2) \in \bm{E} \text{ for some } 0\leq t_1 \leq t_2 \leq t_1+\tau$. $u$, $v\in V$ could be either the same neuron or distinct neurons. \end{definition} We show an example in Figure \ref{fig:causal-def-example}, where for neurons $V=\{1,2,3\}$, their unrolled DAG $\bm{G}$ is represented by Figure \ref{fig:causal-def-example}-middle. When the neural data $\bm{X}$ satisfies the directed Markov Property with respect to $\bm{G}$, the CFC graph with maximum time delay of interaction $\tau = 1$ is given by Figure \ref{fig:causal-def-example}-right. Note that the same CFC graph would be obtained by taking any value of $\tau\geq 1$. \textbf{Property}: The transformation from unrolled DAG $\bm{G}$ to Rolled CFC, $F_{\tau}$, is a well-defined function, meaning that starting from the same unrolled DAG $\bm{G}$ we will not have multiple possible CFC and there will be a unique CFC $F_{\tau}$.\\ \underline{Proof}: By contradiction, consider two distinct CFCs $F_{\tau,1}$ and $F_{\tau,2}$ with $F_{\tau,1}\neq F_{\tau,2}$ obtained from the unrolled DAG $\bm{G} = (\bm{V}, \bm{E})$. Since $F_{\tau,1}\neq F_{\tau,2}$, so $\exists i,j\in V$ such that $i\rightarrow j \in F_{\tau,1}$ but $i\rightarrow j \notin F_{\tau,2}$, where $i,j$ could be either the same or distinct neurons. Using the definiton \ref{def:causalfc_td} of Rolled CFC-DPGM, $i\rightarrow j \in F_{\tau,1}$ implies that for some $0\leq t_1\leq t_2\leq t_1 + \tau$, $(i,t_1)\rightarrow (j,t_2) \in \bm{E}$. But $i\rightarrow j \notin F_{\tau,2}$ contradicts this as it implies that $(i,t_1)\not\rightarrow (j,t_2) \in \bm{E}$ for any $0\leq t_1\leq t_2\leq t_1 + \tau$. \paragraph{Contemporaneous and Feedback Interactions} We highlight that the Rolled CFC-DPGM in Definition \ref{def:causalfc_td} incorporates contemporaneous interactions, which can arise if the causal influences occur more rapidly than the sampling interval of the time series or the aggregation interval for aggregated time series. Such a scenario can arise for example in spiking neural datasets where peri-stimulus time histograms aggregate the spike trains over time intervals \citep{shinomoto2010estimating,stevenson2008inferring}, and in Functional Magnetic Resonance Imaging (fMRI) datasets where low sampling rates is typical \citep{stephan2007comparing}. However, if the time span in sampling and aggregation is expected to be less than the time scale of causal interactions, then one can impose $t_1 < t_2$ to exclude contemporaneous interactions. Additionally, the Rolled CFC-DPGM accomodates self-loops in neural interactions \citep{mullins2016unifying,sheffield2016cognition}, by checking whether $(u,t_1)\rightarrow (u,t_2)\in \bm{E}$ for some $0\leq t_1< t_2\leq t_1+\tau$ in determining whether $u\rightarrow u \in F_{\tau}$. Longer feedback loops are also incorporated. For example, the existence of $u\rightarrow v\rightarrow u \in F_{\tau}$ is determined by checking whether $(u,t_1)\rightarrow (v,t_2)$ and $(v,t_2)\rightarrow (u,t_3)\in \bm{E}$ for some $0\leq t_1\leq t_2\leq t_3\leq t_1+\tau$. By virtue of the technique of unrolling and rolling back, the Rolled CFC-DPGM captures causality while including cycles, since the Unrolled Graph is still a DAG and thereby meets the requirement for satisfying DMP. \begin{figure}[t!] \centering \vspace{5mm} \includegraphics[width = \textwidth]{TPC.pdf} \caption{Illustration of Steps 1-7 in the TPC Algorithm: Time Delay, Bootstrap, PC, Orient, Rolled CFC-DPGM, Robust edges and Pruning.} \label{fig:TPC} \end{figure} \subsection{Estimation from data: Time-Aware PC (TPC) Algorithm} \label{alg:estimate-cfcpdgm} In this section we outline the steps to estimate the Rolled CFC-DPGM from dataset $\bm{X}=\{X_v(t):v\in V, 0\leq t\leq T\}$, $\dim V=N$, which constitute the Time-Aware PC (TPC) Algorithm. The output of TPC is a Rolled CFC that contains edges found significant in the duration of recording. The TPC Algorithm first aims to estimate the unrolled DAG for $X_v(t), v\in V, 0\leq t \leq \tau$, considering maximum time-delay of interaction $\tau$. The unrolled DAG has nodes as $(v,t), v\in V, 0\leq t \leq \tau$ and with respect to which $X_v(t), v\in V, 0\leq t \leq \tau$ satisfies the DMP. To perform the estimation, TPC constructs samples for a node $(v,t)$ consisting of time delayed instances of $X_v(t)$, denoted $X_{vt,k}$, with a time delay of $2(\tau+1)k$, i.e. with a shift backward of the signal $X_v$ by $2(\tau+1)k$. Such a time-delay of multiples of $2(\tau+1)$ ensures a substantial time-gap of $2(\tau+1)$ units between samples, that reduces interdependence between the samples, considering the maximum time-delay of interaction $\tau$. This operation increases the number of considered time-series by a multiple of $\tau+1$ such that for original recordings of $N$ nodes in $X_v$, there would be $N(\tau+1)$ nodes in $X_{vt}$. \begin{algorithm}[ht!] \caption{TPC\label{algo:TPC}} \SetAlgoLined \SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output} \Input{Recordings of activity of neurons in $V$ over time $(X_v(t):v\in V, t\in 0:T)$; maximum delay of interaction between neurons $\tau$; significance level $\alpha$;\\ For bootstrapping: window width $L$; $m$ iterations; bootstrap stability cutoff $\gamma$;} \Output{CFC estimate, denoted $F_{\tau}$.} \Begin{ \begin{enumerate} \item[Step 1.] \underline{Time-Delayed Samples.} For $v\in V, 0\leq t\leq \tau$, construct $k$-th sample for $(v,t)$, denoted $X_{vt,k}$, by time-delay of $2(\tau+1)k$: $X_{vt,k}=X_v(t+2(\tau+1)k)$, $0\leq k \leq K = \frac{T-\tau}{2(\tau+1)}$. \item[Step 2.] \underline{Bootstrap.} For $v\in V, 0\leq t\leq \tau$, select a random window from $X_{vt,k}$ to obtain $X_{vt,k}^*$, by drawing a random integer $r\in [0,K-L]$, and $X_{vt,k}^* = X_{vt,r+k}, 0\leq k \leq L$. \item[Step 3.] \underline{PC.} Use PC algorithm to estimate the unrolled DAG for $X_v(t)$ over $v\in V$, $0\leq t\leq \tau$, with the samples $X_{vt,k}^*, 0\leq k \leq L$, for $X_v(t)$. Denote the output as $\bm{G}_{\tau}^*$. \item[Step 4.] \underline{Orient.} Reverse the edge directions of edges $(v,t_1)\rightarrow (u,t_2)\in \bm{G}_{\tau}^*$, when $0\leq t_2<t_1 \leq \tau, u\in V, v\in V$ and update $\bm{G}_{\tau}^*$. \item[Step 5.]\underline{Rolled CFC-DPGM.} \begin{enumerate}\item Convert $\bm{G}_{\tau}^*$ to rolled CFC-DPGM $F_{\tau}^*$ with max. delay of interaction $\tau$ using Def. \ref{def:causalfc_td}. \item Find the connectivity weights $w_{\tau}^{*}(u,v)$ for connections $u\rightarrow v \in F_{\tau}^{*}$ by Def. \ref{def:causalFCweight}. \end{enumerate} \item[Step 6.]\underline{Robust edges.} \begin{enumerate} \item Repeat Steps 2-5 to obtain $m$ iterates of the rolled CFC-DPGM: $F_{\tau}^{*i}$, and connectivity weights $w_{\tau}^{*i}(u,v)$, $i=1:m$. \item Output a single CFC, $F_{\tau}$, with only those edges whose relative frequency of occurrence among $F_{\tau}^{*i}$ is above $\gamma$. \item Output single Connectivity Weights, $w_{\tau}(u,v)$, for connections $u\rightarrow v\in F_{\tau}$, as the average of $\{w_{\tau}^{*i}(u,v):u\rightarrow v \in F_{\tau},u\rightarrow v \in F_{\tau}^{*i}, i\in 1:m\}$ when the set is non-empty and $0$ otherwise. \end{enumerate} \item[Step 7.]\underline{Pruning.} Remove from $F_{\tau}$ those edges $u\rightarrow v \in F_{\tau}$ with $\vert w_{\tau}(u,v) \vert < w_0$, where, $w_0 = \frac{1}{10}\max\{ \vert w_{\tau}(u,v) \vert: u\rightarrow v \in F_{\tau}\}$. \end{enumerate} } \end{algorithm} In Step 2, TPC selects random windows from $X_{vt,k}$ to obtain $X_{vt,k}^*$. The process is called \emph{bootstrap} since in the next step, on each window, the PC algorithm is applied to estimate the unrolled DAG for $X_v(t), v\in V, 0\leq t \leq \tau$, with nodes being $(v,t), v\in V, 0\leq t\leq \tau$. These operations provide a set of graphs modeling a sample of the unrolled DAG of each window. In Step 3, on each window, the PC algorithm outputs the unrolled DAG as a completed partially directed acyclic graph (CPDAG), defined as the graph union of DAGs that satisfy DMP with respect to the window, and denoted by $\bm{G}_{\tau}^*$ \citep{pearl2009causal}. In Step 4, TPC \emph{corrects} the edges in $\bm{G}_{\tau}^*$ which direct from future to past time by reversing them, to be consistent with the temporal direction of causal interactions in the time series. In Step 5, the re-oriented Unrolled graph $\bm{G}_{\tau}^*$ is transformed to give the Rolled CFC-DPGM denoted $F_{\tau}^*$. At this step, weights for edges in $F_{\tau}^*$ are also obtained using interventional connectivity weights (\ref{def:causalFCweight}), that quantifies the causal effect of intervention on each neuron to its connected neurons. In Step 6, a single CFC consensus $F_{\tau}$ is obtained by keeping only those edges which have relative frequency of occurrence among $F_{\tau}^{*i}$ to be greater than the cut-off $\gamma$, where $F_{\tau}^{*i}, i=1,\ldots,m$ is obtained over $m$ iterations of Steps 2-5. A single connectivity weight consensus for an edge in $F_{\tau}$ is achieved by averaging over the weights for the same edge, whenever present, over the $m$ iterates. The resampling procedure promotes detection of stable edges \citep{maathuis2009estimating}. Finally, in Step 7, $F_{\tau}$ is pruned to further reduce spurious edges, by removing the edges which have exceedingly low connectivity weights, determined by those edges in $F_{\tau}$ whose weights are less than a tenth in magnitude compared to the maximum magnitude for edge weights in $F_{\tau}$. The TPC algorithm is outlined in Alg. \ref{algo:TPC} and Figure \ref{fig:TPC}. \subsection{Connectivity weights in the CFC} In this section, we define the connectivity weights obtained by TPC. Connectivity weights refer to a weight $w_{uv}$ for connections $u\rightarrow v$ in the CFC graph. We consider \emph{interventional causal effects} to define connectivity weights. Interventional causal effects quantify how much effect an intervention applied to neuron $u$ will have on neuron $v$. \paragraph{Definition 2: Interventional causal effects in Unrolled DAG.} Let $\bm{X}$ satisfy the Directed Markov Property with respect to $\bm{G}=(\bm{V},\bm{E})$. The \emph{interventional causal effect} of $X_u (t) = x_{u,t}$ on $X_v (t')$, where $x_{u,t}$ are fixed values, for $u,v\in V, 0\leq t\neq t'\leq T$, is defined in interventional calculus by Pearl et. al as follows \citep{pearl2009causality,huang2012pearl,maathuis2009estimating} \begin{equation}\label{eq:causaleffect} \frac{\partial}{\partial x} E(X_v (t') \vert X_u (t) = x) \vert_{x=x_{u,t}}\end{equation} Assuming $X_u (t), u\in V$ are jointly Gaussian, the causal effect does not depend on the value of $x_{u, t}$, and the causal effect of $X_{u} (t)$ on $X_v (t')$ from Eq. (\ref{eq:causaleffect}) takes the following form, \begin{equation}\label{eq:causaleffectgaussian} w_{u,t}^{v,t'}=\left\{\begin{array}{lr} 0, & \text{ if }(v,t') \in pa_{\bm{G}}(u,t),\\ \text{coefficient of }X_u (t) \text{ in }X_v (t') \sim X_u (t) + X_{pa_{\bm{G}}(u,t)} & \text{ if } (v,t') \notin pa_{\bm{G}}(u,t) \end{array}\right. \end{equation} where $X_v (t') \sim X_u (t) + X_{pa_{\bm{G}}(u,t)}$ is shorthand for linear regression of $X_v (t')$ on $X_u (t)$ and $X_{pa_{\bm{G}}(u,t)} = \{X_a (b) : (a,b) \in pa_G(u,t)\}$. Note that when $\bm{X}$ satisfy the Directed Markov Property with respect to $\bm{G}=(\bm{V},\bm{E})$, the causal effects are defined in interventional calculus literature for all pairs of nodes in $\bm{V}$ and not that only for those pairs which are adjacent. And, if $u\rightarrow v \in \bm{E}$ then the interventional causal effect from $v$ to $u$ is $0$ \citep{maathuis2009estimating}. Under the Gaussian assumption, we define the \emph{interventional causal effect} of the activity of neuron $u$ at time $t$ on the activity of neuron $v$ at time $t'$ to be $w_{u,t}^{v,t'}$ for $0\leq t<t'\leq T$, $u,v \in V$. Using this, we define weights for the connection from $u$ to $v$ for $u,v$ in the rolled CFC-DPGM $F_{\tau}$, following the way $F_{\tau}$ is defined from $\bm{G}$. \paragraph{Definition 3: Interventional connectivity weights in Rolled CFC-DPGM.}\label{def:causalFCweight} Let $\bm{X}$ satisfy DMP with respect to the DAG $\bm{G}=(\bm{V},\bm{E})$ and $F_{\tau}$ is the Rolled CFC-DPGM with max delay $\tau$. If neurons $u,v$ are connected as $u\rightarrow v$ in $F_{\tau}$, then, the \emph{weight of connection} from neuron $u$ to $v$ with max delay $\tau$, denoted by $w_{\tau}(u,v)$, is defined as the average of the causal effects: $w_{u,t}^{v,t'}$ for $(u,t)\rightarrow (v,t')\in \bm{E}$, $0\leq t\leq t'\leq t+\tau$. \paragraph{Connectivity weights in TPC Algorithm.} After the CFC graph $F_{\tau}^*$ is obtained in Step 3-5a in TPC algorithm, the interventional connectivity weights for connections in $F_{\tau}^*$ are obtained in Step 5b to define the connectivity weights $w_{\tau}^{*i}(u,v)$ for connections $u\rightarrow v \in F_{\tau}^{*i}$. Then bootstrapping in Step 6 ensures greater stability of the estimated connectivity weights. Step 6 outputs a single connectivity weight $w_{\tau}(u,v)$ for connections $u\rightarrow v$ in $F_{\tau}$, as the average of $\{w_{\tau}^{*i}(u,v):u\rightarrow v \in F_{\tau},u\rightarrow v \in F_{\tau}^{*i}, i\in 1:m\}$ when the set is non-empty and $0$ otherwise. Therefore, this finds a connectivity weight for the edge $u\rightarrow v\in F_{\tau}$ by taking the average of connectivity weight of the edge $u\rightarrow v \in F_{\tau}^{*i}$ whenever it exists over $i$. \paragraph{Pruning by Connectivity Weights.} After the rolled CFC-DPGM and Connectivity Weights have been inferred by the TPC Algorithm, spurious connections can be pruned further in Step 7 of TPC (\ref{algo:TPC}), by discarding those connections whose connectivity weight is less than a threshold. For this threshold, we use a factor of 10 of the maximum Connectivity Weight in the rolled CFC-DPGM. From the interpretation of regression coefficients in Eq. (\ref{eq:causaleffectgaussian}), a negative connectivity weight (\ref{def:causalFCweight}) from neuron $u\rightarrow v$ in $F_{\tau}$ indicates an inhibitory connection, in which, increased activity $X_u (t)$ of the pre-synaptic neuron $u$ at time $t$ causes subjugation of activity $X_v (t')$ of the post-synaptic neuron $v$ at a following time $t'$, when activity of the neurons that are causally connected to neuron $v$ at time $t$, are kept fixed. In a similar manner, a positive FC weight from neuron $u\rightarrow v$ in $F_{\tau}$ indicates an excitatory connection. In this way the strength of the functional connection, which also indicates it's excitatory and inhibitory nature is learnt from the data. \subsection{Properties of Rolled CFC-DPGM}\label{sec:properties} We highlight properties of the Rolled CFC-DPGM, obtained by TPC, in capturing causal relationships in neural dynamics in a non-parametric manner and being predictive of the impact of counterfactual interventions to the neurons in the CFC. \paragraph{Non-parametric Causal Relations.} The following theorem shows that the CFC given by the model is consistent with the ground truth causal relationships between neural activity at different time without requiring any assumptions on the functional form of the relationships. That is, we show that if past time points of neurons in $A_v\subset V$ influence the present time point of $v\in V$ by an arbitrary function with independent random noise, then neurons in $A_v$ are connected to the neuron $v$ in their Rolled CFC-DPGM. This means that causal relationships among the neurons, in their unknown arbitrary dynamical equation, are accurately represented by the CFC without prior knowledge of the functional form of the relationships. The benefit of Rolled CFC-DPGM is that it uses a non-parametric graphical model for the temporal relationships between neurons and does not assume a parametric equation for the temporal relationships. Furthermore, the Rolled CFC-DPGM provides a framework to answer causal questions related to the consequence of interventions and counterfactuals. \begin{theorem}[Consistency with Time Series Causal Relations]\label{thm:causal-fc-td} For neurons $v\in V$ with activity $X_v(t)$ at time $t$, if \begin{equation}\label{eq:thmfirst} X_v(t) = g_{v,t} (X_{u_{v,1}}(t_{v,1}),\ldots,X_{u_{v,K}}(t_{v,K}),\epsilon_{v}(t)), \end{equation} $\text{for some } u_{v,i} \in V$ and $t_{v,i}\in [t-\tau,t]$ with either $u_{v,i}\neq v$ or $t_{v,i}\neq t$, for $1\leq i\leq K$, where $\tau$ is the maximum time-delay of interaction, and $g_{v,t}$ is a measurable function and $\epsilon_v(t)$ are independent random variables, then the graph $F_{\tau}$ with nodes $V$ and parents of $v$, $pa_{F{\tau}}(v)$, given by \[pa_{F{\tau}}(v) = \{u_{v,1},\ldots, u_{v,K}\}\] is the Rolled CFC-DPGM between the neurons in $V$. \end{theorem} \vspace{-4mm} \begin{proof} See Appendix \ref{proof:thm1}. \end{proof} \paragraph{Interventional Properties} The Rolled CFC-DPGM can answer questions concerning counterfactual interventions on neurons without experimentally performing the interventions, i) Ablation of a neuron $A$, ii) Activity of neuron $B$ is externally modulated. In the following corollary we show how conclusions can be drawn for such queries. \begin{corthm}[Intervention]\label{cor:intervention} For neurons $v\in V$ following the dynamics in equation Eq. (\ref{eq:thmfirst}), let us consider there is an experimental or counterfactual intervention on neurons $v_1,\ldots,v_k \in V$ during $t\in T_I$, such as ablation or external control. 1) For ablation of $v_1,\ldots, v_k$ the connections incident as well as outgoing from them are removed. 2) During $t\in T_I$, for external control, all connections incident on $v_1,\ldots, v_k$ are removed in the Rolled CFC-DPGM $F_{\tau}$ and other connections remain intact. \end{corthm} \vspace{-4mm} \begin{proof} See Appendix \ref{proof:thm2}. \end{proof} \vspace{-2mm} This corollary justifies the usage of causal reasoning with the edges of the CFC alone to answer the interventional queries. Answers to the questions by causally reasoning are as follows: i) When neuron $A$ is ablated, one just deletes all the edges incident and originating from neuron $A$ since $A$ has a fixed value after ablation and neither do other neurons influence the activity of neuron $A$ nor does $A$ influence the activity of any other neuron. ii) When activity of neuron $B$ is externally controlled, one simply removes the edges incident on neuron $B$, because activity of neuron $B$ no longer depends on its parent neurons in the CFC obtained before intervention rather the activity of neuron $B$ depends on the external control. Edges originating from neuron $B$ in the CFC from before the intervention should remain intact during the intervention since the functional pathways from $B$ to its descendant neurons in the CFC remain intact during external control. To illustrate the properties of non-parametric causal relations (Theorem \ref{thm:causal-fc-td}) and interventions (Corollary \ref{cor:intervention}), we consider the following example. \begin{figure}[t] \centering \includegraphics[width=0.7\textwidth]{ExampleCFCTheory.pdf} \caption{Rolled CFC-DPGM (left) for neurons 1-4 with dynamics as in Example \ref{ex:dir-gm}, and consequence of intervention on neurons labelled A and B by (i) Ablation of A and (ii) External modulation of B.} \label{fig:example4} \end{figure} \begin{exmp}\label{ex:dir-gm} Let $V$ denote a network of 4 neurons, labeled $\{1,2,3,4\}$ with neural activity $X_v(t), v\in V$ related as, \begin{align*} X_1 (t) &= g_{1,t} (\epsilon_{1}(t))\\ X_2 (t) &= g_{2,t} (X_2 (t-1), X_3(t-1), X_3(t-2), \epsilon_{2}(t))\\ X_3 (t) &= g_{3,t} (X_3 (t-1), X_1(t-1), \epsilon_{3}(t))\\ X_4 (t) &= g_{4,t} (X_2(t-1), \epsilon_{4}(t)) \end{align*} for independent random variables $\epsilon_v (t)$ and measurable functions $g_{v,t}$, $v=1,2,3,4; 0\leq t\leq 1000$ msec. By Theorem \ref{thm:causal-fc-td} it follows that the graph: $2\rightarrow 2, 3\rightarrow2, 3\rightarrow 3,1\rightarrow 3, 2\rightarrow 4$ as in Figure \ref{fig:example4}-left is the CFC among the neurons considering maximum time delay of interaction to be 1 msec or higher. Suppose one asks the question of type (i), how would the functional connectome change if neuron (A) were ablated? According to Corollary \ref{cor:intervention}, the resulting CFC would be $1\rightarrow 3, 3\rightarrow 3$ as in Figure \ref{fig:example4}-middle by removing the connections to and from neuron $2$ according to Corollary \ref{cor:intervention}. Suppose one asks the question of type (ii), how would the functional connectome change if activity of neuron (B) were to be externally controlled by optogenetics? According to Corollary \ref{cor:intervention}, the resulting CFC would be $3\rightarrow 2, 2\rightarrow 2, 2\rightarrow 4$ as in Figure \ref{fig:example4}-right by removing the parent connections of neuron $3$ according to Corollary \ref{cor:intervention}. \end{exmp} \section{Comparison Study of TPC with other Approaches to Causal Functional Connectivity}\label{sec:valid} We compare the performance of TPC with different existing CFC inference approaches to recover relationships in ground truth dynamical equations by generating synthetic data from three simulation paradigms. In particular, we estimate their CFC using GC, DPGM and TPC. The simulation paradigms correspond to specific model assumptions to assess the impact of model assumptions on the performance of the approaches (See Appendix \ref{simul:details}). We measured the algorithms' performance using CFC inference for 25 different simulations and summarized the results using three metrics: (1) Combined Score (CS), (2) True Positive Rate (TPR), (3) 1 - False Positive Rate (IFPR). Let True Positive (TP) represent the number of correctly identified edges, True Negative (TN) represent the number of correctly identified missing edges, False Positive (FP) represent the number of incorrectly identified edges, and False Negative (FN) represent the number of incorrectly identified missing edges across simulations. IFPR is defined as: $\text{IFPR}=\left(1-\frac{\text{FP}}{\text{FP+TN}}\right)\cdot 100,$ which measures the ratio of the number of correctly identified missing edges by the algorithm to the total number of true missing edges. Note that the rate is reported such that $100\%$ corresponds to no falsely detected edges. TPR is defined $\text{TPR}=\left(\frac{\text{TP}}{\text{TP} + \text{FP}}\right)\cdot 100$ as the ratio of the number of correctly identified edges by the algorithm to the total number of true edges in percent. The Combined Score (CS) is given by Youden's Index \citep{vsimundic2009measures,hilden1996regret}, as follows, $\text{CS} = \text{TPR} - \text{FPR}$. \begin{figure} \centering \includegraphics[width=0.95\textwidth]{ComparisonSimulations.pdf} \caption{(a) CFC inference by GC, DPGM, and TPC, is compared on three examples of motifs and simulation paradigms; from left to right: Linear Gaussian, Non-linear Non-Gaussian, CTRNN. Table: 4-neurons motifs that define the Ground Truth CFC (row 1) are depicted along with inferred CFC over several simulation instances according to the three different methods (row 2-4). Each inferred CFC has an edge $v\rightarrow w$ that corresponds to an edge detected in any of the inference instances. The percentage (blue) next to each edge indicates the number of times the edge was detected out of all instances. (b) $\text{IFPR}$ (green) , TP rate (orange) and Combined Score (Purple) of each method are shown for each motif.} \label{fig:simul_eval} \end{figure} In the motifs and simulation paradigms that we consider, there are $4$ neurons and $16$ possible edges (including self-loops) per simulation resulting with total of $400$ possible edges across $25$ simulations. Figure \ref{fig:simul_eval} compares in detail the results for GC, DPGM and TPC in inference of true CFC for noise level $\eta =1$ and thresholding parameter $\alpha = 0.05$. Here we also report the percentage of the simulations that has each estimated edge present. Higher percentage indicates higher confidence in the detection of that edge. Figure \ref{fig:comp_noise} compares the Combined Score of the approaches over different values of noise level $\eta$ and thresholding parameter $\alpha$ for each simulation paradigm. \begin{itemize}[leftmargin=0pt] \item[] In \textit{Linear Gaussian scenario (left column in Figure \ref{fig:simul_eval})}, the connections between neurons in the Ground Truth CFC are excitatory due to positive coefficients in the linear dynamical equation for neural activity. GC generates a sparse set of edges in which it correctly detects a single edge $3\rightarrow 4$ among the three edges of the true CFC but misses two other edges. DPGM generates a large number of edges (9 out of 16), many of which are spurious, though it has a high percentage for expected edges in the Ground Truth CFC ($1\rightarrow 3, 3\rightarrow 4$ with $87 \%$ and $100 \%$ respectively). TPC obtains the Ground Truth CFC, with no spurious edges and obtains the expected edges in all of the trials ($1\rightarrow 3, 2\rightarrow 3, 3\rightarrow 4$ with $100 \%$, $100 \%$ and $100 \%$ respectively). Overall, GC, DPGM and TPC produce $\text{IFPR} = 100\%, 88.5\%, 100\%$, $\text{TPR}=33.3\%, 71.0\%$, and $100 \% $, and CS $= 33\%, 59\%, 100\%$ respectively. Thereby, among the three methods, we conclude that TPC detects the edges perfectly, while GC is highly specific to correct edges, but since it does not detect two out of three edges it is not as sensitive as DPGM. \item[] In the \textit{Non-linear Non-Gaussian scenario (second column)}, in the Ground Truth CFC consists of $1\rightarrow 3, 3\rightarrow 4$ excitatory due to $\sin(x)$ being an increasing function, while $2\rightarrow 3$ is an inhibitory connection due to $\cos(x)$ being a decreasing function for $x\in [0,1]$ in the dynamical equation. As previously, GC consistently detects a sparse set of edges (single edge $1\rightarrow 3$ with $100\%$) which is one of the three true edges. DPGM again generates a large number of edges, some of which are spurious. In the majority of trials ($97 \%$ and $93 \%$, respectively), DPGM correctly obtains two of the three true edges $1\rightarrow 3$ and $2\rightarrow 3$. In contrast, TPC obtains no spurious edges and the true edges were detected for all the trials ($1\rightarrow 3$, $2\rightarrow 3$,$3\rightarrow 4$ with $100\%, 100\%, 100\%$). In summary, GC, DPGM and TPC yielded $\text{IFPR} = 100\%, 97.6\%, 100\%$ and $\text{TPR} = 33.3\%, 63.7\%, 100\%$ and CS $=33\%, 61\%, 100\%$. For this scenario, TPC again has the highest performance among the methods. \item[] In \textit{CTRNN scenario (third column)}, self-loops are present for each neuron, and due to positive weights and increasing activation function $\sigma(\cdot)$ in their dynamical equation, the connections in the Ground Truth CFC are excitatory. GC obtains two of the three true non-self edges $1\rightarrow 3, 2\rightarrow 3$ for $52\%, 48\%$ of the trials. DPGM detects spurious edges, but also infers the non-self true edges $1\rightarrow 3, 2\rightarrow 3$ for $100\%$ of the trials. In comparison, TPC infers no spurious edges and all the self true edges for $100\%$ of the trials and non-self true edges $1\rightarrow 3$ and $2\rightarrow 3$ for $88\%, 76\%$ of the trials. In summary, IFPR of GC, DPGM and TPC is $100\%, 96.7\%, 90\%$ and $\text{TPR}$ is $16.7\%, 33.3\%, 77.3\%$ and CS is $17\%, 30\%, 67\%$ respectively. Among all methods, TPC has the highest TPR, followed by DPGM and lastly GC. Since GC does not detect any false edges, it has the highest IFPR, followed by DPGM and lastly TPC, though all of them have IFPR of at least $90\%$. In terms of the CS, TPC has the highest performance compared to other methods. \end{itemize} \begin{figure}[t!] \centering \includegraphics[width=0.8\textwidth]{ComparisonNoise.pdf} \caption{Combined Score of the three methods of CFC inference - TPC (red), DPGM (blue), GC (gray), over varying noise levels in simulation $\eta = 0.1,0.5,1.0,\ldots,3.5$, for simulated motifs from Linear Gaussian, Non-linear Non-Gaussian and CTRNN paradigms (left to right), with thresholding parameter $\alpha = 0.01, 0.05, 0.1$ (top to bottom).} \label{fig:comp_noise} \end{figure} We compare Combined Score of TPC and other approaches across varying levels of simulation noise $\eta$ from $0.1$ to $3.5$ and thresholding parameter $\alpha = 0.01,0.05,0.1$ in Figure \ref{fig:comp_noise}. In the Linear Gaussian scenario, we note that TPC has a CS of $\approx 100\%$ across all levels of simulation noise and thresholding parameter $\alpha$, and is followed by DPGM in performance and lastly GC. In the Non-linear Non-Gaussian scenario, TPC has the highest CS compared to other methods across levels of noise and $\alpha$. In the CTRNN scenario, the performance of all the three approaches is lower compared to the other simulation paradigms for different level of $\eta$ and $\alpha$, yet TPC has higher CS compared to the other methods over the different parameter values. \begin{figure}[t!] \centering \includegraphics[width=0.7\textwidth]{ConnectivityWeights.pdf} \caption{Inference of interventional connectivity weights by the TPC algorithm with max delay $1$ msec for the example motifs from the three simulation paradigms: Linear Gaussian VAR, Non-linear Non-Gaussian VAR, CTRNN (left to right). Top row: Ground Truth CFC with excitatory (red) and inhibitory (green) connections; Bottom row: Estimated CFC labeled with edge weights (median [min,max] over all instances) and inferred nature whether excitatory (red) or inhibitory (green).} \label{fig:connweights} \end{figure} We demonstrate the connectivity weights obtained by TPC and inferred nature of connections, whether excitatory or inhibitory, across simulations for noise level $\eta=1$ and thresholding parameter $\alpha = 0.05$ in Figure \ref{fig:connweights}. In the \textit{Linear Gaussian scenario}, the estimated connectivity weight of $1\rightarrow 3$, $2\rightarrow 3$, $3\rightarrow 4$ are $2.12, 0.96, 1.96$, across simulation trials. Since the weights are positive, thereby the connections are labeled to be excitatory in all simulation trials, which agrees with the Ground Truth. In the \textit{Non-linear Non-Gaussian scenario}, the estimated weight for the connection $2\rightarrow 3$ is $-1.27$ in median and ranges between $-1.51,-1.13$. Therefore the weight is always negative and labeled inhibitory in the simulation trials. The weight for $1\rightarrow 3,2\rightarrow 3$ are $3.47,2.57$ in median and ranges between $3.15,3.74$ and $2.21,2.97$ respectively. Their weights are always positive and labeled excitatory in all the simulation trials. These labels for the nature of connections obtained by TPC agrees with the ground truth. In the \textit{CTRNN scenario}, the estimated connectivity weight for $1\rightarrow 1, 1\rightarrow 3, 2\rightarrow 2, 2\rightarrow 3, 3\rightarrow 3, 4\rightarrow 4$ are $0.74, 2.80, 0.72, 2.64, 0.93, 0.88$ in median respectively and ranges over positive values in all the simulation trials. Thereby the connections are labeled excitatory in all the simulations trials, which agrees with the Ground Truth. \section{Application to Benchmark Data} We applied TPC to find the CFC from datasets in the public benchmarking platform - \emph{CauseMe} \citep{bussmann2021neural}, and compared with benchmarked approaches in the platform in their performance to recover causal interactions present in the datasets. We used the \emph{River Runoff} (real data) and \emph{Logistic Map} (synthetic data) benchmarking datasets (See Appendix \ref{data:bm}). We compare the approaches PCMCI-GPDC \citep{runge2019detecting}, selVAR \citep{pmlr-v123-weichwald20a} - which are among the top of the leaderboard for performance on the benchmarking datasets, GC, DPGM (estimated by the PC algorithm), and TPC (Our). \begin{table}[t] \centering \begin{tabular}{lll}\toprule \multicolumn{3}{c}{\textbf{Combined [True, 1-False] Rates (\%)}}\\\midrule \textbf{Algorithm} & \textbf{River-Runoff (Real)} & \textbf{Logistic Map (Synthetic)}\\\midrule GC & ~~~~~37 [45, 92] & ~~~~79 [86, 93]\\ PCMCI & ~~~~~45 [\underline{100}, 45] & ~~~~86 [89, 97]\\ selVAR & ~~~~~54 [91, 63] & ~~~~\textbf{87} [88, \underline{99}]\\ DPGM & ~~~~~60 [64, \underline{96}] & ~~~~19 [27, 92]\\ TPC (Our) &\textbf{72(+12\%)} [\underline{100}, 72] & 84(-3\%) [\underline{90}, 94]\\\bottomrule \end{tabular} \vspace{2mm} \caption{Comparison of CFC inference by GC, DPGM, PCMCI-GPDC and selVAR, and TPC on benchmarking datasets. For each dataset, each method's Combined Score, True Positive Rate, and 1-False Positive Rate are reported (Higher value is better).}\label{tab:causalsummarybm} \end{table} As previously, we measured the performance of the algorithms using 1 - False Positive Rate (IFPR), True Positive Rate (TPR) and Combined Score given by Youden's Index (CS = TPR - FPR) (See Table \ref{tab:causalsummarybm}). The River Runoff dataset is comprised of contemporaneous interactions and is expected to demonstrate the performance of the methods in an empirical setting. The Logistic Map dataset is synthetic and excludes contemporaneous interactions and shows the performance of the methods when the ground truth connectivities are specifically controlled for. In terms of CS, TPC has recorded the best performance with a score of $72\%$, followed by DPGM, selVAR, PCMCI-GPDC and GC at $60\%,54\%,45\%, 37\%$ respectively. TPC exceeds the second best approach \textbf{by 12\%}. In terms of TPR, TPC and PCMCI have the highest scores at $100\%$, followed by selVAR, DPGM and GC at $91\%,64\%, 45\%$ respectively. In terms of IFPR, DPGM has the best performance with a score of $96\%$ closely followed by GC at $92\%$, TPC at $72\%$, and selVAR and PCMCI with $63\%, 45\%$. DPGM and GC turn out to have higher IFPR than TPC because they detect fewer false edges, but that is achieved by their detection of fewer edges altogether including fewer true edges leading to a low TPR. In contrast, TPC has greater sensitivity in detecting edges, whose benefit is that TPC detects all the true edges correctly leading to $100\%$ TPR. In terms of both TPR and IFPR, TPC maintains a better trade-off, and thereby a better CS compared to other methods. For the logistic map dataset, in terms of CS, selVAR, PCMCI-GPDC and TPC have scores of $87\%, 86\%, 84\%$ respectively, followed by GC with $79\%$ and lastly DPGM with $19\%$. In terms of TPR, TPC has the highest score of $90\%$, followed by PCMCI, selVAR, GC and TPC with TPR of $89\%, 88\%, 86\%, 79\%$ respectively, with DPGM having comparatively lowest TPR of $27\%$. In terms of IFPR, all the approaches have a score of at least $90\%$. Thereby, TPC achieves a high CS of $84\%$, short of $3\%$ from the best CS by selVAR of $87\%$. The results indicate that in the real benchmark dataset of River-Runoff, TPC outperforms all methods by a substantial gap, whereas, in the synthetic benchmark dataset of Logistic Map, TPC has Combined Score of $84\%$, being in the top group of $84-87\%$ CS performance. While selVAR and PCMCI achieve a CS of $87\%$ and $86\%$ respectively in the synthetic dataset, they achieve a low CS of $54\%$ and $45\%$ in the real dataset. Since the synthetic dataset is generated by a model controlling coupling strength between variables, low noise and devoid of contemporaneous interactions, thereby most of the methods including TPC perform fairly well in the range of $80\%$. In contrast, in the real dataset, the coupling between variables as well as noise are not controlled and contemporaneous interactions are expected to be present as the sampling resolution is greater than the time taken for interactions between the variables. Thereby, the real dataset provides a challenge for the methods where TPC outperforms other approaches with a CS and shows significant improvement in performance than the other methods. Presence of TPC in top group of performance for both benchmarks indicates the generality and applicability of TPC to various scenarios. \section{Application to Neurobiological Data} \begin{figure}[t] \centering \includegraphics[width=1.2\textwidth]{ComparisonNeuropixels.pdf} \caption{Comparison and demonstration of the FC inferred for a benchmark of mice brain data from the Allen Institute’s Neuropixels dataset, by three methods for FC inference: Associative FC using Sparse Partial Correlation, and Causal FC using GC and TPC. The estimated FC is represented by its adjacency matrix with edge weights, which is symmetric for Associative FC and asymmetric for Causal FC. The mice were subject to different stimuli, among which we selected four stimuli categories with distinct characteristics: Natural Scenes, Static Gratings, Gabor Patches and Full-Field Flashes. The neurons are clustered by the region of brain: Visual Cortex, Hippo-Campal Formation, and Thalamus, which are further divided into sub-regions. In the adjacency matrices, a non-zero entry in $(i,j)$ represents the connection of neuron $i\rightarrow j$. } \label{fig:cfcneuropixels} \end{figure} We proceed and test the methods on neural data consisting of electrophysiological recordings in the Visual Coding Neuropixels dataset of the Allen Brain Observatory ~\citep{de2020large,allenbrainobs}. We compare TPC with Granger Causality (GC) and Sparse Partial Correlation, that are popular methods for obtaining CFC and Associative Functional Connectivity (AFC) from electrophysiological neural recordings. The dataset consists of sorted spike trains and local field potentials recorded simultaneously from up to six cortical visual areas, hippocampus, thalamus, and other adjacent structures of mice, while the mice passively view a stimuli shown to them. The stimuli include static gratings, drifting gratings, natural scenes/images and natural movies, which are shown to the mice with repetitions. The data has been recorded from the neurons with the recently developed technology of Neuropixels which allows real-time recording from hundreds of neurons across the brain simultaneously by inserting multiple probes into the brain~\citep{neuropixels}. Details of the dataset are in Appendix \ref{data:desc}. Figure \ref{fig:cfcneuropixels} shows the adjacency matrices for the FC obtained by the methods for one trial in each of the stimuli categories. For each stimuli categories, the AFC constitutes a distinct pattern of connectivity among the neurons. It is expected that the CFC will be a directed subgraph of the AFC and be consistent with the overall patterns present in the AFC \citep{dadgostar2016functional, wang2016efficient}. However, the patterns present in the CFC obtained by GC do not match with the AFC. In contrast, the overall patterns present in the CFC obtained by TPC indeed match with the AFC. On a detailed level, there are differences between TPC-CFC and AFC: TPC results in a directed graph thereby its adjacency matrix is asymmetric while AFC is an undirected graph with symmetric adjacency matrix. Furthermore, the CFC obtained by TPC includes self-loops represented by the diagonals of the adjacency matrix and results in a sparse matrix devoid of noise since the connections passed conditional independence tests and bootstrap stability thresholds. In the CFC obtained by TPC (see Figure \ref{fig:cfcneuropixels}), a greater extent of connectivity within the active neurons in Primary Visual Cortex is evoked by natural scenes, in Posteromedial and Anteromedial Visual Cortex by static gratings, in Anterolateral Visual Cortex and Thalamus by full-field flashes, compared to other stimuli. All four stimuli exhibit distinct patterns of connectivity in the Cornu Ammonis regions of the Hippo-Campal Formation. Natural Scenes and Static gratings evoke more prominent connectivity within the Subiculum compared to other stimuli. \subsection{Graphical Comparison of Estimated CFC over Stimuli} To study the differences in functional connectivity between the stimuli categories, we investigate the topological patterns in the CFC estimated above. The topological patterns can be summarized by graph theoretic measures \citep{sporns2004organization,van2008small,ueda2018brain}, as follows. The graph measures were computed using the \emph{Networkx} Python library \citep{hagberg2008exploring}, over different trials of each stimuli. \begin{itemize} \item Betweenness centrality: the fraction of all shortest paths that pass through a node, averaged over nodes, indicating the average effect of individual nodes on information flow among the remaining network's nodes. \item Transitivity: the fraction of all possible triangles present in the graph, indicating prevalence of clustered connectivity. \item Assortativity: measures the similarity of connections in the graph with respect to the node degree. \item Clustering Coefficient: the average of all clustering coefficients in the network, reflecting the tightness of connections between nodes. \item Global Efficiency: average inverse shortest path length, reflecting node's ability to propagate information with other nodes in the graph. \item Local Efficiency: measures the global efficiency for the neighborhood of a node, averaged over nodes, indicating efficiency of transmitting information by nodes with their neighborhood in the graph. \end{itemize} \begin{figure}[t!] \centering \includegraphics[width= \textwidth]{CFCGraphicalAnalysis.pdf} \caption{This figure compares the distribution of graph measures of CFC obtained by TPC over different stimuli: natural scenes, static gratings, gabor patches and flashes. The distribution for each graph measure and stimuli is shown by a boxplot.} \label{fig:fig7} \end{figure} The results of the graph measures for different stimuli are summarized by boxplots. The boxplot of a graph measure (e.g. betweenness centrality) for a stimulus (e.g. natural scenes) shows the distribution of the values of the graph measure over trials for that stimulus, with the top and bottom of the box indicating the upper and lower quartiles of the distribution, the middle of the box indicating the median, while the whiskers extend to show the rest of the distribution excluding outliers, which are marked by points (See Figure \ref{fig:fig7}). In Figure \ref{fig:fig7}, in terms of \emph{betweenness centrality}, natural scenes have higher score compared to other stimuli, followed by static gratings, then flashes and lastly gabor patches. This shows that during natural scenes, the active neurons have a more remarkable effect on the neural information flow, compared to other stimuli, while gabor patches have the least remarkable effect. In terms of \emph{transitivity}, the scores between the stimuli are close, though static gratings have a relatively higher transitivity, followed by natural scenes, flashes and gabors. This indicates that static gratings evoked a relatively higher prevalence of clustered connectivity, followed by natural scenes, flashes and lastly gabor patches. In terms of \emph{assortativity}, the stimuli did not evoke a comparatively distinct score as well. In terms of \emph{clustering coefficient}, natural scenes and static gratings have higher scores compared to flashes and gabors. This shows that, natural scenes and static gratings have the most tightness of connections between nodes in the graph, flashes have a comparatively lower tightness of connections, while gabor patches have the least score. In terms of \emph{global efficiency}, natural scenes have the highest score, while, static gratings have comparatively lower score, followed by flashes and gabor patches. This shows that natural scenes evoked comparatively highest efficiency of information propagation in the CFC globally, followed by static gratings, flashes and gabors. In terms of \emph{local efficiency}, the trend across stimuli is similar to global efficiency, while natural scenes and static gratings evoked a more similar local efficiency compared to global efficiency. This shows that the efficiency in information propagation in local neighborhoods of neurons is higher for natural scenes and static gratings to a similar extent, but with higher efficiency compared to flashes and gabor patches. \section{Discussion} In this paper, we propose a novel methodology, the TPC Algorithm, for finding causal functional connectivity between neurons from neural time series using Directed Probabilistic Graphical Models (DPGM). In particular, we extend the applicability of DPGM to CFC inference from time series by unrolling and implementing the Directed Markov Property (DMP) to obtain the unrolled DAG reflecting causal spatial and temporal interactions. We then roll the DAG back to obtain the CFC graph. The methodology exhibits interpretability of causal interactions over time between neural entities. It also incorporates time delays in interactions between neurons as well as the presence of feedback-loops. The model and the approach are non-parametric, meaning that it does not require the specification of a parametric dynamical equation for neural activity. We show that if the neural activity obeys an arbitrary dynamical process, the Rolled CFC-DPGM is consistent with respect to the causal relationships implied by the dynamical process. We determine that the Rolled CFC-DPGM is predictive of counterfactual queries such as ablation or modulation. We show that the answers can be provided by using simple causal reasoning with the edges of the rolled CFC-DPGM. We demonstrate the utilization of the methodology in obtaining CFC from simulations and compare the performance of TPC with other methods such as Granger Causality (GC) and common DPGM. Furthermore, we apply the methods to benchmarks of time-series causal inference and neurobiological dataset from mice brain presented with various visual stimuli. The results provide insights into the CFC between neurons in the mouse brain in a variety of stimuli scenario. We also compare the topological patterns in the estimated CFC between different stimuli using graph-theoretic measures. \begin{table}[t!] \caption{Comparative summary of different approaches for causal modeling.} \label{tab:causalsummary} \begin{tabular}{p{2.5cm} p{2.4cm} p{2.4cm} p{2.4cm} p{2.8cm} p{2.8cm}}\toprule & \textbf{GC} & \textbf{DCM} & \textbf{DPGM} & \textbf{TPC} \\\midrule Form of Causality & Non-zero parameters in VAR model & Coupling parameters in biological model & Directed Markov Graph & Directed Markov Graph over time-delayed variables \\\midrule Inclusion of temporal relationships & \textcolor{ForestGreen}{\textbf{Yes}} & \textcolor{ForestGreen}{\textbf{Yes}} & \textcolor{Maroon}{\textbf{No}}, formulation for static variables & \textcolor{ForestGreen}{\textbf{Yes}}, adapts DPGM for inter-temporal relationships\\\midrule Inclusion of contemporaneous relationships & \textcolor{Maroon}{\textbf{No}} & \textcolor{ForestGreen}{\textbf{Yes}}, by a differential equation & \textcolor{Maroon}{\textbf{No}} & \textcolor{ForestGreen}{\textbf{Yes}}, if $(i,t)\rightarrow (j,t)$ then $i\rightarrow j$.\\\midrule Generalizable Statistical Model & \textcolor{ForestGreen}{\textbf{Yes}} & \textcolor{Maroon}{\textbf{No}} & \textcolor{ForestGreen}{\textbf{Yes}} & \textcolor{ForestGreen}{\textbf{Yes}}\\\midrule Non-parametric Model & \textcolor{ForestGreen}{\textbf{Yes}}, parametric and non-parametric approaches exist. & \textcolor{Maroon}{\textbf{No}}, biologically mechanistic non-linear model. & \textcolor{ForestGreen}{\textbf{Yes}}, equivalent to an arbitrary functional relationship between nodes. & \textcolor{ForestGreen}{\textbf{Yes}}, equivalent to an arbitrary functional relationship between neural activity at different times.\\\midrule Supports CFC Inference & \textcolor{ForestGreen}{\textbf{Yes}} & \textcolor{Maroon}{\textbf{No}}, suitable for comparing model hypotheses & \textcolor{ForestGreen}{\textbf{Yes}} & \textcolor{ForestGreen}{\textbf{Yes}}\\\midrule Cycles (including self-loops) Occuring In The Model & \textcolor{ForestGreen}{\textbf{Yes}} for VAR model (neuron $i\rightarrow i$ when $A_{ii}(k)\neq 0$ for some $k$). & \textcolor{ForestGreen}{\textbf{Yes}} ($i\rightarrow i$ when $\theta_{ii}\neq 0$) & \textcolor{Maroon}{\textbf{No}}, it is a DAG & \textcolor{ForestGreen}{\textbf{Yes}} ($i\rightarrow i$ when $(i,t)\rightarrow (i,t')$ for some $t<t'$)\\\midrule Incorporation of Interventional and Counterfactual queries & \textcolor{Maroon}{\textbf{No}} & \textcolor{Maroon}{\textbf{No}} & \textcolor{ForestGreen}{\textbf{Yes}} but for static variables. & \textcolor{ForestGreen}{\textbf{Yes}}, adapts for temporal scenario, can predict the consequence on CFC of counterfactual intervention to neural activity.\\ \bottomrule \end{tabular} \end{table} The distinctive and useful aspect of TPC is that it takes into consideration neural interactions over time. In neuroscience literature, causality is typically referred to as ``a cause of an observed neural event (the ‘effect’) as a preceding neural event whose occurrence is necessary to observe the effect"~\citep{reid2019advancing}. The approach of unrolling causal graphs over time and considering time-delays in TPC incorporates this definition by essentially finding whether the previous time values of the neurons impact the present value of a particular neuron by the obtained directed graph. By virtue of the Directed Markov Property, TPC incorporates causality of neural interactions in a non-parameteric, model-free manner and incorporates interventional properties. The bootstrapping step filters spurious connections by repeating the inference of CFC over several subsampled blocks of the time series and discarding those connections that are absent in multiple repetitions. Pruning further selects edges by discarding edges with exceedingly low edge weight. In contrast, parametric approaches, such as GC, do not satisfy the Directed Markov Property, thereby not incorporating interventional properties. Furthermore, in comparative studies with simulated, benchmark and real neurobiological datasets, we found the performance of TPC to be better compared to other approaches. We conclude by summarizing, in Table \ref{tab:causalsummary}, the differences and benefits of TPC in a comparison with other approaches including variants of the PC algorithm (DPGM) which satisfy DMP in a static data setting, and other approaches that do not obey the DMP, such as Granger Causality (GC) and Dynamic Causal Model (DCM), outlining their strengths and weaknesses with respect to several criteria of causality in functional connectomics. Indeed, capturing as many causal criteria is fundamental to any approach from statistical and application points of view. Our exposition of properties of each approach and the comparative study show that each of the methods address different aspects of modeling causality of neural interaction and mapping them in the form of a graph \citep{biswas2021statistical}. The comparative table demonstrates that with respect to the model that each approach is assuming, GC requires a linear model in its common use, though recent non-linear and non-parametric extensions, have been applied. DCM requires a strict well defined mechanistic biological model and thus can only compare different models based on evidence from data. In comparison, DPGM and TPC have the advantage of not requiring modeling of the neural dynamics using a parametric equation or assumption of a linear model. While DPGM is developed for static variables, and as such cannot address temporal and contemporaneous relationships and must obey DAG architechture, TPC is suited for time series setting and extends DPGM for spatiotemporal data. TPC obtains the CFC that follows Directed Markov Property extended to include inter-temporal relationships in a time-series setting such that parent-child relations between neurons are equivalent to arbitrary functional relationships between their neural activity over time. In terms of incorporating contemporaneous interactions arising when causal interactions happen faster than sampling rate, while GC and DPGM do not, TPC is able to incorporate contemporaneous interactions by design. In terms of incorporating self-loops in neural activity, while DPGM typically produces a DAG, TPC incorporates self-loops in neural activity. In regards to guarantee of causality, GC can provide useful insights into a system's dynamical interactions in different conditions, however its causal interpretation is not guaranteed as it focuses on the predictability of future based on past observations of variables. DCM uses the parameters for coupling between hidden neural states in competing biological models to indicate CFC, however it compares hypothetical models based on evidence from data which relevance to causality is not guaranteed (Friston et al., 2003). In summary, TPC extends DPGM to the time-series setting and provides a probabilistic foundation for causality which is predictive of the consequence of possible intervention like neuron ablation and neuromodulation. While TPC provides a powerful causal framework for time series, its current version relies on the PC algorithm which in turn assumes \emph{causal sufficiency}, that is, all the causes of the input variables are present within the input variables. In the presence of latent confounders, the PC can lead to spurious edges. These are partly remediated by the TPC Algorithm by discarding spurious edges in the Bootstrap and Pruning steps, but some of these effect may remain. To address this, an alternative strategy that could be considered is replacing the PC algorithm with the FCI algorithm in Step 3 of TPC (\ref{algo:TPC}) since the FCI algorithm exhibits statistical consistency, that converges in probability to the true causal relationships, given i.i.d. samples in the presence of latent confounders \citep{spirtes1999algorithm}. However, the FCI algorithm identifies indirect connections only and not direct connections, thereby would result in a CFC with indirect causal connections. Under the assumptions of 1) causal sufficiency, 2) faithfulness, and 3) given i.i.d. samples, the PC algorithm's estimated causal DAG is statistically consistent. In light of these assumptions, the step 2 of the TPC algorithm constructs samples with a time-delay of $2(\tau+1)$ between samples from a bootstrap window, for max time-delay of interaction $\tau$, which are used as an input to the PC algorithm in the next step. The time-delay between samples of $2(\tau+1)$ reduces between-sample dependence. And, the samples being constructed from a short bootstrap window instead of the entire time series aids to make their distribution fairly identical. Yet, specifications of $\tau$ of lower value could lead to between-sample dependence and rapid perturbations to the time series in a bootstrap window can lead to distribution changes between samples in a bootstrap window, leading to potential reduction in efficacy of edge detection by the PC algorithm. To improve overall efficacy in such scenarios and curb spurious edge detections, the bootstrap step of the TPC algorithm outputs many CFCs over random time windows and preserves only stable edges over the set of CFCs. In the pruning step, the edges in the CFC are pruned if having an exceedingly low connectivity weight. In conclusion, TPC provides a probabilistic and interpretable formulation for CFC modeling and inference in the context of neural time series. We have established the statistical properties of the model as well as demonstrated its performance in estimation of CFC. We have demonstrated TPC application in continuous time series datasets, however TPC is similarly applicable to discrete time series datasets by simply using a statistical conditional independence test for discrete data in the algorithm. This can be especially relevant for count datasets such as spiking neuron datasets. \bibliographystyle{unsrt} \input{main.bbl}
{'timestamp': '2022-04-13T02:29:05', 'yymm': '2204', 'arxiv_id': '2204.04845', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04845'}
arxiv
\section{Revisiting Graph Augmentations} \label{sec:aug_study} Graph Contrastive Learning (GCL) aims to learn representations that are invariant to different augmentations. However, it is rarely studied what information is preserved or perturbed across augmented graph views. In this section, we attempt to identify such information by examining the effect of graph augmentation techniques on graph geometric structure and node attributes from the spectral perspective. \subsection{Representative Augmentation Techniques} According to Table~\ref{tab:graph_aug_summary}, the most commonly used four graph augmentation techniques for GCL are: attribute masking, edge adding, edge dropping~\cite{you2020graph} and graph diffusion~\cite{you2020graph}. \begin{itemize} \item Attribute Masking: randomly masks a fraction of features for all the nodes. \item Edge Adding/Dropping: randomly adds/drops a fraction of edges from the original graph. \item Graph Diffusion: the Personalized PageRank (PPR) based graph diffusion is defined as, $\alpha\left(\mathbf{I}-(1-\alpha) \mathbf{A}_{sym}\right)^{-1}$, where $\alpha$ is the diffusion factor. \end{itemize} \subsection{Effect of Augmentations on Geometric Structure} \begin{wrapfigure}{r}{0.4\textwidth} \vspace{-45pt} \begin{center} \includegraphics[width=1.0\textwidth]{images/ER0.2_FM0.2_new.pdf} \end{center} \vspace{-10pt} \caption{{Frobenius distance between the decomposed symmetric normalized Laplacian matrices of the original graph and the augmented graph with 20\% edge dropping.} The experiment is independent conducted 10 times and the average value is reported.} \label{fig:er_fm_observation} \vspace{-10pt} \end{wrapfigure} First, we investigate the effect of different augmentations, e.g., edge adding, edge dropping and graph diffusion, on adjacency matrix. As we introduced in Section~\ref{subsec:laplacian_concept}, the graph Laplacians are widely used in GNNs, therefore we measure the difference of Laplacians caused by graph augmentations in different frequency bands. The $m$-th component symmetric normalized Laplacian is defined as ${\mathbf{L}}^{m}_{sym}$. Correspondingly, we denote the decomposed $m$-th symmetric normalized Laplacian for the augmented graph as ${\widetilde{\mathbf{L}}}_{sym}^{m}$. To measure the impact of graph augmentations for different frequency components, we employ the Frobenius norm as the metric to measure the distance, $\|{\mathbf{L}}^{m}_{sym} - {\widetilde{\mathbf{L}}}^{m}_{sym}\|_F$. The results of edge dropping on two homophilic graphs, e.g., Cora and CiteSeer~\cite{sen2008collective, namata2012query}, and two heterophilic graphs, e.g., Chameleon and Squirrel~\cite{rozemberczki2021twitch}, are summarized in Figure~\ref{fig:er_fm_observation} and the results of other graph augmentation techniques are in Appendix~\ref{apd:aug_study}. We observed that graph augmentations have less impact on low-frequency components and more impact on middle and high-frequency components. Our conclusion is aligned with the previous works~\cite{entezari2020all, chang2021not} in the graph adversarial attack domain, in which they find that, for the graph structure modification, perturbations on the low-frequency components are smaller than that in the middle or high-frequency ones. \subsection{Effect of Augmentations on Features} \vspace{-5pt} \begin{wraptable}{r}{6cm} \vspace{-20pt} \caption{Distance between original node features and augmented node features with 30\% attribute dropping. We set $R=0.8\times F$.} \label{tab:feat_freq_analysis} \begin{tabular}{ccc}\\ \toprule & F-Low & F-High \\\hline Cora & 0 & 7.949 \\ \hline CiteSeer & 0 & 5.609 \\ \hline Chameleon & 0 & 12.566 \\ \hline Squirrel & 0 & 15.836 \\ \bottomrule \end{tabular} \end{wraptable} To further study the effect of the commonly used graph augmentation method, attribute masking, on node attribute from spectral view. We denote the Fourier transform and inverse Fourier transform as $\mathcal{F}(\cdot)$ and $\mathcal{F}^{-1}(\cdot)$. We use $\mathbf{H}^\mathcal{F}$ to denote the transformed node features. Therefore, we have $\mathbf{H}^{\mathcal{F}}=\mathcal{F}(\mathbf{X})$ and $\mathbf{X}=\mathcal{F}^{-1}(\mathbf{H}^{\mathcal{F}})$. We decompose the node attribute $\mathbf{X}=\left\{\mathbf{X}^{l}, \mathbf{X}^{h}\right\}$, where $\mathbf{X}^{l}$ and $\mathbf{X}^{h}$ denote the low-frequency and high-frequency components of $\mathbf{X}$ respectively. We have the following four equations: $$ \begin{array}{rlr} \mathbf{H}^{\mathcal{F}}=\mathcal{F}(\mathbf{X}), & \mathbf{H}^{l}, \mathbf{H}^{h}=t(\mathbf{H}^{\mathcal{F}}; R), \\ \mathbf{X}^{l}={\mathcal{F}}^{-1}\left(\mathbf{H}^{l}\right), & \mathbf{X}^{h}=\mathcal{F}^{-1}\left(\mathbf{H}^{\mathcal{F}}\right), \end{array} $$ where $t(\cdot ; R)$ denotes a thresholding function that separates the low and high frequency components from $\mathbf{H}^f$ according to a hyperparameter, $m$. Because the column of $\mathbf{H}^{\mathcal{F}}$ in the left is corresponding to the low frequency component, we define $t(\cdot ; m)$ as: \begin{equation} \begin{aligned} &\mathbf{H}^{l}_{ij}= \begin{cases}\mathbf{H}^{\mathcal{F}}_{ij}, & \text { if } j \leq R \\ 0, & \text { otherwise }\end{cases}, &\mathbf{H}^{h}_{ij}= \begin{cases}0, & \text { if } j \leq R \\ \mathbf{H}^{\mathcal{F}}_{ij}, & \text { otherwise }\end{cases}. \end{aligned} \end{equation} Further, we denote the node attribute with attribute masking as $\widetilde{\mathbf{X}}$ and its corresponding low and high frequency components as $\widetilde{\mathbf{X}}^l$, $\widetilde{\mathbf{X}}^h$. We investigate the influence of attribute masking on node features by computing the Frobenius distance of matrix, and denote $\|{\mathbf{X}}^l - \widetilde{\mathbf{X}}^l \|_F$ as F-norm-low and $\|{\mathbf{X}}^h - \widetilde{\mathbf{X}}^h \|_F$ as F-norm-high. The results on four datasets are summrized in Table~\ref{tab:feat_freq_analysis}. We surprisingly find that the attribute masking will always affect the high frequency component. \subsection{Concluding Remarks} As demonstrated by previous works~\cite{bo2021beyond, li2021beyond}, for heterophilic graphs, the information carried by high-frequency components is more effective for downstream classification performance. However, as we analyzed, the middle- and high-frequency information are perturbed by commonly used graph augmentation techniques. With the information maximization objective, only the invariant information (low-frequency) is encouraged to be captured by the learned embedding~\cite{you2020graph}. Although existing graph augmentation algorithms promote the success of GCL on traditional (homophilic) benchmarks, they result in sub-optimal representations when the high-frequency information is crucial (heterophilic graphs). \section{Appendix} \subsection{Dataset Information} \label{apd:dataset_section} We evaluate our models on eight node classification homophilic benchmarks: Cora, Citeseer, Pubmed, WikiCS, Coauthor-CS, Coauthor-Physics, Amazon-Computer and Amazon-Photo and seven non-homophilic benchmarks: Chameleon, Squirrel, Deezer, Penn94 (FB100), Twitch-gamers, Twitch-DE, Genius. The datasets are collected from real-world networks from different domains and we provide dataset statistics in Table~\ref{tab:data_stat}. For the 8 homophilic graph data, we use the processed version provided by PyTorch Geometric~\cite{fey2019fast}. Besides, for the 6 heterophilic graph data, 3 of them, e.g., Chameleon, Squirrel and Actor are provided by PyTorch Geometric. The other three dataset, genius, twitch-DE and twitch-gamers can be obtained from the official github repository\footnote{\url{https://github.com/CUAI/Non-Homophily-Large-Scale}}, in which the standard splits for all the 6 heterophilic graph datasets can also be obtained. \begin{table}[h] \centering \small \caption{Statistics of datasets used in experiments.} \label{tab:data_stat} \setlength{\tabcolsep}{2.5pt}{ \begin{tabular}{l | rrrrrr} \toprule \text { Name } & \text { Nodes } & \text { Edges } & \text { Classes } & \text { Feat. } & $h_{node}$ & $h_{edge}$ \\ \hline \text { Cora } & 2,708 & 10,556 & 7 & 1,433 & .825 & .810 \\ \text { CiteSeer } & 3,327 & 9,228 & 6 & 3,703 & .717 & .736 \\ \text { PubMed } & 19,717 & 88,651 & 3 & 500 & .792 & .802 \\ \text { Coauthor CS } & 18,333 & 327,576 & 15 & 6,805 & .832 & .808 \\ \text { Coauthor Phy. } & 34,493 & 991,848 & 5 & 8,451 & .915 & .931 \\ \text { Amazon Comp. } & 13,752 & 574,418 & 10 & 767 & .785 & .777 \\ \text { Amazon Photo } & 7,650 & 287,326 & 8 & 745 & .836 & .827 \\ \hline \text { Chameleon } & 2,277 & 36,101 & 5 & 2,325 & .103 & .234 \\ \text { Squirrel } & 5,201 & 216,933 & 5 & 2,089 & .088 & .223 \\ \text { Actor } & 7,600 & 33,544 & 5 & 9,31 & .154 & .216 \\ \text { Twitch-DE } & 9,498 & 153,138 & 2 & 2,514 & .529 & .632 \\ \text { Twitch-gamers } & 168,114 & {\bf 6,797,557} & 2 & 7 & .552 & .545 \\ \text { Genius } & {\bf 421,961} & 984,979 & 2 & 12 & .477 & .618 \\ \bottomrule \end{tabular}} \end{table} \vspace{-5pt} \subsection{Implementation Details} \label{apd:model_detail} \textbf{Model Architecture and hyperparamters.} As we described in Section~\ref{sec:exp}, we employ a two-layer GCN~\cite{kipf2016semi} as the encoder for all methods. Following the previous works~\cite{kipf2016semi, lim2021new, lim2021large}, we apply the l2-normalization for the raw features before training and use batch normalization within the graph encoder. The hyperparameters setting for all experiments are summarized in Table~\ref{tab:hyper_args}. We would like to release our code after acceptance. \\ \textbf{Linear evaluation of embeddings.} In the linear evaluation protocol, the final evaluation is over representations obtained from pretrained model. When fitting the linear classifier on top of the frozen learned embeddings, the gradient will not flow back to the encoder. We optimize the one layer linear classifier 1000 epochs using Adam with learning rate 0.0005.\\ \textbf{Hardware and software infrastructures.} Our model are implemented with PyTorch Geometric 2.0.3~\cite{fey2019fast}, PyTorch 1.9.0~\cite{paszke2017automatic}. We conduct experiments on a computer server with four NVIDIA Tesla V100 SXM2 GPUs (with 32GB memory each) and twelve Intel Xeon Gold 6240R 2.40GHz CPUs. \begin{table}[h] \centering \caption{Hyperparameter settings for all experiments.} \label{tab:hyper_args} \small \begin{tabular}{l|llllll} \toprule & lr. & $K_{pos}$ & $K_{neg}$ & b & T & K \\ \hline Cora & .0022 & 5 & 100 & 256 & 2 & 512 \\ CiteSeer & .0022 & 10 & 100 & 256 & 2 & 512 \\ PubMed & .002 & 10 & 100 & 512 & 2 & 512 \\ WikiCS & .0016 & 5 & 100 & 512 & 2 & 512 \\ Amz-Comp. & .0016 & 5 & 100 & 256 & 2 & 512 \\ Amz-Photo & .0021 & 5 & 100 & 512 & 2 & 512 \\ Coauthor-CS & .0016 & 5 & 100 & 256 & 2 & 512 \\ Coauthor-Phy. & .0021 & 5 & 100 & 512 & 2 & 512 \\ Chameleon & .0025 & 5 & 100 & 256 & 3 & 512 \\ Squirrel & .0025 & 5 & 100 & 256 & 3 & 512 \\ Actor & .0025 & 10 & 100 & 256 & 4 & 512 \\ Twitch-DE & .0025 & 10 & 100 & 256 & 4 & 512 \\ Twitch-gamers & .0025 & 5 & 100 & 256 & 4 & 128 \\ Genius & .0025 & 10 & 100 & 256 & 3 & 512 \\ \bottomrule \end{tabular} \end{table} \subsection{More Results for the Study of Graph Augmentation} \label{apd:aug_study} We decomposed the Laplacian matrix into 10 parts and compute the average Frobenius distance for each part over 10 independent runs. As shown in Figure~\ref{fig:ea_fm_observation} and Figure~\ref{fig:fusion_observation}, both the edge adding with 20\% edges and diffusion with $\alpha=0.2$ have less impact on the low frequency components. \begin{figure}[h] \centering \begin{subfigure}[b]{0.49\textwidth} \centering \includegraphics[width=\textwidth]{images/EA0.2_FM0.2_new.pdf} \caption{Edge Adding.} \label{fig:ea_fm_observation} \end{subfigure} \begin{subfigure}[b]{0.49\textwidth} \centering \includegraphics[width=\textwidth]{images/PPR0.2_new.pdf} \caption{Graph Diffusion.} \label{fig:fusion_observation} \end{subfigure} \end{figure} \vspace{-5pt} \subsection{Detailed Proofs} \subsubsection{Proof of Lemma \ref{lem:emb}} \label{apd: lemma_emb_proof} {\it Proof.} We first calculate the expectation of aggregated embedding: \begin{equation} \begin{small} \begin{aligned} \mathbb{E}[ f_\theta(\mathbf{x}_i)] =\mathbb{E} \bigg[ \mathbf{W} \sum_{j \in \mathcal{N}(i)} \frac{1}{\mathbf{D}_{ii} }\mathbf{x}_j \bigg] = \mathbf{W} \mathbb{E}_{y \sim P_{y_i}, \mathbf{x} \sim P_y(\mathbf{x}) } [\mathbf{x}] \end{aligned} \end{small} \end{equation} This equation is based on the assumption \ref{ass:label} such that $\mathbf{x}_{j} \sim P_{y_i}(\mathbf{x})$ for every $j$. Now we provide a concentration analysis. Because each feature $\mathbf{x}_i$ is a sub-Gaussian variable, then by Hoeffding's inequality, with probability at least $1-\delta'$ for each $d \in [1,F]$, we have, \begin{equation} \begin{small} \begin{aligned} \bigg | \frac{1}{\mathbf{D}_{ii}} \sum_j (\mathbf{x}_{j,d} - \mathbb{E}[\mathbf{x}_{j,d}]) \bigg | \le \sqrt{ \frac{ \log(2/\delta')}{2\mathbf{D}_{ii}\|\mathbf{x}_{j,d} \|_{\psi_2}} } \end{aligned} \end{small} \end{equation} where $\| \mathbf{x}_{j,d}\|_{\psi_2}$ is sub-Gaussian norm of $\mathbf{x}_{j,d}$. Furthermore, because each dimension of $\mathbf{x}_j$ is i.i.d., thus we define $\| \mathbf{x}_j \|_{\psi_2} = \| \mathbf{x}_{j,d} \|_{\psi_2}$ Then we apply a union bound by setting $\delta' = F \delta$ on the feature dimension $k$. Then with probability at least $1-\delta$ we have \begin{equation} \begin{small} \begin{aligned} \bigg | \frac{1}{\mathbf{D}_{ii}} \sum_j (\mathbf{x}_{j,d} - \mathbb{E}[\mathbf{x}_{j,d}]) \bigg | \le \sqrt{ \frac{ \log(2F/\delta)}{2\mathbf{D}_{ii}\|\mathbf{x} \|_{\psi_2}} } \end{aligned} \end{small} \end{equation} Next, we use the matrix perturbation theory, \begin{equation} \begin{small} \begin{aligned} \bigg \| \frac{1}{\mathbf{D}_{ii}} \sum_j (\mathbf{x}_{j,d} - \mathbb{E}[\mathbf{x}_{j,d}]) \bigg \|_2 & \le \sqrt{F} \bigg | \frac{1}{\mathbf{D}_{ii}} \sum_j (\mathbf{x}_{j,d} - \mathbb{E}[\mathbf{x}_{j,d}]) \bigg | \\ & \le \sqrt{ \frac{F \log(2F/\delta)}{2\mathbf{D}_{ii}\|\mathbf{x} \|_{\psi_2}} } \end{aligned} \end{small} \end{equation} Finally, plug the weight matrix into the inequality, \begin{equation} \begin{small} \begin{aligned} \| f_\theta(\mathbf{x}_i) - \mathbb{E}[f_\theta(\mathbf{x}_i)] \| \le \sigma_{\max}(\mathbf{W})\bigg \| \frac{1}{\mathbf{D}_{ii}} \sum_j (\mathbf{x}_{j,k} - \mathbb{E}[\mathbf{x}_{j,k}]) \bigg \|_2 \end{aligned} \end{small} \end{equation} where $\sigma_{\max}$ is the largest singular value of weight matrix. \subsubsection{Proof of Theorem \ref{thm:homo_sim}} \label{apd: theorem_homo_sim_proof} {\it Proof.} The concentration analysis is based on the result obtained in Lemma \ref{lem:emb}. We first write down the detailed expression for each pair of $i,j$, \begin{equation} \begin{small} \begin{aligned} s_{i,j} \equiv \mathbf{x}^\top_i \mathbf{W}^\top \mathbf{W} \mathbf{x}_j \end{aligned} \end{small} \end{equation} We first bound $\mathbf{x}^\top_i \mathbf{x}_j$. Because $\mathbf{x}_i$ and $\mathbf{x}_j$ are independently sampled from an identical distribution, then the product $\mathbf{x}^\top_i \mathbf{x}_j$ is sub-exponential. This can been seen from Orilicz norms relation that $\| x^2 \|_{\psi_1} = (\| x^2 \|_{\psi_2})^2$, where $\| \mathbf{x}\|_{\psi_2}$ is sub-exponential norm of $\mathbf{x}^2$. Then by the Hoeffding's inequality for sub-exponential variable, with a probability at least $1-\delta$, we have \begin{equation} \begin{small} \begin{aligned} | \mathbf{x}^\top_i \mathbf{x}_j - \mathbb{E}_{\mathbf{x}_i \sim P_{y_i} ,\mathbf{x}_j \sim P_{y_j} } [\mathbf{x}^\top_i \mathbf{x}_j] | \le \sqrt{ \frac{ \sigma^2_{\max}(\mathbf{W}^\top \mathbf{W}) \log(2/\delta)}{2\|\mathbf{x}^2 \|_{\psi_1}} } \end{aligned} \end{small} \end{equation} Because that the aggregated feature is normalized by the degree of corresponding node, we have, for each pair of $i,j$ \begin{equation} \begin{small} \begin{aligned} |s_{i,j} - \mathbb{E}[s_{i,j}]| \le \sqrt{ \frac{ \log(2/\delta)\sigma^2_{\max}(\mathbf{W}^\top \mathbf{W}) }{2\|\mathbf{x}^2 \|_{\psi_1}\mathbf{D}_{ii} \mathbf{D}_{jj}} } \le \sqrt{ \frac{ \sigma^2_{\max}(\mathbf{W}^\top \mathbf{W}) \log(2/\delta)}{2\|\mathbf{x}^2 \|_{\psi_1}D^2} } \end{aligned} \end{small} \end{equation} where $D =\min_i \mathbf{D}_{ii}$ for $i \in [1, N]$. Finally we apply a union bound over a pair of $i,j$. Then with probability at least $1-\delta$ we have \begin{equation} \begin{small} \begin{aligned} \big| \mathbf{Z}_i^\top \mathbf{Z}_j - \mathbb{E}[\mathbf{Z}_i^\top \mathbf{Z}_j] \big| \le \sqrt{ \frac{\sigma^2_{\max}(\mathbf{W}^\top \mathbf{W}) \log(2N^2/\delta)}{2D^2 \|\mathbf{x}^2 \|_{\psi_1}} } \end{aligned} \end{small} \end{equation} \vspace{-10pt} \subsubsection{Proof of Lemma \ref{lem:equiv}} \label{apd:lemma_equivalence_proof} To prove this lemma, we first introduce the concept of the probability adjacency matrix. For the transformed graph $\widehat{\mathcal{G}}$, we denote its probability adjacency matrix as $\widehat{\mathbf{W}}$, in which $\hat{w}_{ij} = \frac{1}{\widehat{E}}\cdot \widehat{\mathbf{A}_{ij}}$. $\hat{w}_{ij}$ can be understood as the probability that two nodes have an edge and the weights sum to $1$ because the total probability mass is 1: $\sum_{i,j}\hat{w}_{i,j^{\prime}}=1$, for $v_i, v_j \in \mathcal{V}$. Then the corresponding symmetric normalized matrix is $\widehat{\mathbf{W}}_{sym}=\widehat{\mathbf{D}}^{-1/2}_{\mathbf{w}} \widehat{\mathbf{W}} \widehat{\mathbf{D}}^{-1/2}_{\mathbf{w}}$, and the $\widehat{\mathbf{D}} = diag\big([ \hat{w}_{1}, \ldots, \hat{w}_{N}]\big)$, where $ \hat{w}_{i} = \sum_{j}\hat{w}_{ij}$. We then introduce the Matrix Factorization Loss which is defined as: \begin{equation} \begin{small} \label{equ:mf_loss} \begin{aligned} \min _{\mathbf{F} \in \mathbb{R}^{N \times k}} \mathcal{L}_{\mathrm{mf}}(\mathbf{F}):=\left\|\widehat{\mathbf{A}}_{sym}-\mathbf{F} \mathbf{F}^{\top}\right\|_{F}^{2}. \end{aligned} \end{small} \end{equation} By the classical theory on low-rank approximation, Eckart-Young-Mirsky theorem~\cite{eckart1936approximation}, any minimizer $\widehat{\mathbf{F}}$ of $\mathcal{L}_{\mathrm{mf}}(\mathbf{F})$ contains scaling of the smallest eigenvectors of $\mathbf{L}_{sym}$ (also, the largest eigenvectors of $\widehat{\mathbf{A}}_{sym}$) up to a right transformation for some orthonormal matrix $\mathbf{R} \in \mathbb{R}^{k \times k}$. We have $\widehat{\mathbf{F}}=\mathbf{F}^{*}$. $\operatorname{diag}\left(\big[\sqrt{1-\lambda_{1}}, \ldots, \sqrt{1-\lambda_{k}}\big]\right) \mathbf{R}$, where $\mathbf{F}^{*} =\left[\mathbf{u}_{1}, \mathbf{u}_{2}, \cdots, \mathbf{u}_{k}\right] \in \mathbb{R}^{N \times k}$. To proof the Lemma~\ref{lem:equiv}, we first present the Lemma~\ref{lem:equiv_matrix_same}. \begin{lem}[] \label{lem:equiv_matrix_same} For transformed graph, its probability adjacency matrix, and adjacency matrix are equal after symmetric normalization, $\widehat{\mathbf{W}}_{sym} = \widehat{\mathbf{A}}_{sym}$. \end{lem} \vspace{-10pt} {\it Proof.} For any two nodes $v_i, v_j \in \mathcal{V}$ and $i\neq j$, we denote the the element in $i$-th row and $j$-th column of matrix $\widehat{\mathbf{W}}_{sym}$ as $\widehat{\mathbf{W}}_{sym}^{ij}$. \begin{equation} \begin{small} \begin{aligned} {\widehat{\mathbf{W}}_{sym}}^{ij} = \frac{1}{\sqrt{\sum_{k} \hat{w}_{ik}} \sqrt{\sum_{k} \hat{w}_{kj}} } \frac{1}{E} {\widehat{\mathbf{A}}}^{ij} = \frac{1}{\sqrt{\sum_{k} \widehat{\mathbf{A}}_{ik}} \sqrt{\sum_{k} \widehat{\mathbf{A}}_{kj} } } {\widehat{\mathbf{A}}}^{ij} = \widehat{\mathbf{A}}_{sym}^{ij}. \end{aligned} \end{small} \end{equation} By leveraging the Lemma~\ref{lem:equiv_matrix_same}, we present the proof of Lemma~\ref{lem:equiv}. {\it Proof.} We start from the matrix factorization loss over $\widehat{\mathbf{A}}_{sym}$ to show the equivalence. \begin{equation} \label{equ:equivalence_1} \begin{small} \begin{aligned} & \quad \quad \| \widehat{\mathbf{A}}_{sym} -\mathbf{F}\mathbf{F}^{\top} \|^2_F = \| \widehat{\mathbf{W}}_{sym} -\mathbf{F}\mathbf{F}^{\top} \|^2_F \\ & = \sum_{ij} \big( \frac{\hat{w}_{ij}}{\sqrt{\hat{w}_i} \sqrt{\hat{w}_j}} - {f}_{\mathrm{mf}}(v_i)^{\top} {f}_{\mathrm{mf}}(v_j) \big)^2\\ &=\sum_{ij} ({f}_{\mathrm{mf}}(v_i)^{\top}{f}_{\mathrm{mf}}(v_j))^2 -2 \sum_{ij} \frac{\hat{w}_{ij}}{\sqrt{\hat{w}_i}\sqrt{\hat{w}_j}} {f}_{\mathrm{mf}}(v_i)^{\top}{f}_{\mathrm{mf}}(v_j) + \| \hat{\mathbf{W}}_{sym} \|^2_{F} \\ \end{aligned} \end{small} \end{equation} \begin{equation} \begin{small} \begin{aligned} &= \sum_{ij} \hat{w}_i \hat{w}_j \big[ \big(\frac{1}{\sqrt{\hat{w}_i}} \cdot{f}_{\mathrm{mf}}(v_i) \big)^{\top} \big( \frac{1}{\sqrt{\hat{w}_j}} \cdot{f}_{\mathrm{mf}}(v_j) \big) \big]^2 \\ &\quad\quad\quad\quad\quad-2\sum_{ij} \hat{w}_{ij} \big(\frac{1}{\sqrt{\hat{w}_i}} \cdot{f}_{\mathrm{mf}}(v_i) \big)^{\top} \big( \frac{1}{\sqrt{\hat{w}_j}} \cdot{f}_{\mathrm{mf}}(v_j) \big) + C\\ \end{aligned} \end{small} \end{equation} where ${f}_{\mathrm{mf}}(v_i)$ is the $i$-th row of the embedding matrix $\mathbf{F}$. The $\hat{w}_i$ which can be understood as the node selection probability which is proportional to the node degree. Then, we can define the corresponding sampling distribution as $P_{deg}$. If and only if $\sqrt{w_{i}} \cdot f_{\theta}\circ g_{\omega}(v_i)= {f}_{\mathrm{mf}}(v_i)=\mathbf{F}_i$, we have: \begin{equation} \label{equ:equivalence_2} \begin{small} \begin{aligned} &\mathbb{E}_{v_i \sim P_{deg} \atop v_j \sim P_{deg}}\left( f_{\theta}\circ g_{\omega} (v_i)^{\top} f_{\theta}\circ g_{\omega}(v_j) \right)^2 \\ &- 2~\mathbb{E}_{v_i \sim Uni(\mathcal{V}) \atop v_{i^+}\sim Uni(\mathcal{N}(v_i))} \left( f_{\theta}\circ g_{\omega}(v_i)^{\top} f_{\theta}\circ g_{\omega}(v_{i^{+}}) \right) + C \end{aligned} \end{small} \end{equation} where $\mathcal{N}(v_i)$ denotes the neighbor set of node $v_i$ and $Uni(\cdot)$ is the uniform distribution over the given set. Because we constructed the transformed graph by selecting the top-$K_{pos}$ nodes for each node, then all nodes have the same degree. We can further simplify the objective as: \begin{equation} \label{equ:equivalence_3} \begin{small} \begin{aligned} \mathbb{E}_{v_i \sim Uni(\mathcal{V}) \atop v_j \sim Uni(\mathcal{V})}\left( \mathbf{Z}_i^{\top}\mathbf{Z}_j \right)^2 - 2~\mathbb{E}_{v_i \sim Uni(\mathcal{V}) \atop v_{i^+}\sim Uni(S^i_{pos})} \left( \mathbf{Z}_i^{\top} \mathbf{Z}_{i^{+}} \right) + C. \end{aligned} \end{small} \end{equation} Due to the node selection procedure, the factor $\sqrt{w_{i}}$ is a constant and can be absorbed by the neural network, $f_{\theta}\circ g_{\omega}$. Besides, because $\mathbf{Z}_i = f_{\theta}\circ g_{\omega}(v_i)$, we can have the Equation~\ref{equ:equivalence_3}. Therefore, the minimizer of matrix factorization loss is equivalent with the minimizer of the contrastive loss. \subsubsection{Proof of Theorem \ref{thm:gcl_bound}} \label{apd:theorem_gcl_bound_proof} Recently, Haochen et al.~\cite{haochen2021provable} presented the following theoretical guarantee for the model learned with the matrix factorization loss. \begin{lem}[] \label{thm:orig_mf_bound} For a graph $\mathcal{G}$, let $f^{*}_{\mathrm{mf}} \in \arg \min _{f_{\mathrm{mf}}: \mathcal{V} \rightarrow \mathbb{R}^{K}}$ be a minimizer of the matrix factorization loss, $\mathcal{L}_{\mathrm{mf}}(\mathbf{F})$, where $\mathbf{F}_i = f_{\mathrm{mf}}(v_i)$. Then, for any label $\mathbf{y}$, there exists a linear classifier $\mathbf{B}^{*} \in \mathbb{R}^{c \times K}$ with norm $\left\|\mathbf{B}^{*}\right\|_{F} \leq 1 /\left(1-\lambda_{K}\right)$ such that \begin{equation} \begin{small} \begin{aligned} \mathbb{E}_{v_i} \left[ \left\| \vec{y}_i-\mathbf{B}^{*} f_{\mathrm{mf}}^{*}(v_i)\right\|_{2}^{2} \right] \leq \frac{\phi^{\mathbf{y}}}{\lambda_{K+1}}, \end{aligned} \end{small} \end{equation} where $\vec{y}_i$ is the one-hot embedding of the label of node $v_i$. The difference between labels of connected data points is measured by $\phi^{{\mathbf{y}}}$, $ \phi^{{\mathbf{y}}}:=\frac{1}{E} \sum_{v_i, v_j \in \mathcal{V}} {\mathbf{A}}_{ij} \cdot \mathbbm{1}\left[{y}_i \neq {y}_j\right]. $ \end{lem} {\it Proof.} This proof is a direct summary on the established lemmas in previous section. By Lemma \ref{lem:equiv} and Lemma \ref{thm:orig_mf_bound}, we have, \begin{equation} \begin{small} \begin{aligned} \mathbb{E}_{v_i} \left[ \left\| \vec{y}_i- \mathbf{B}^{*} f_{\mathrm{gcl}}^{*}(v_i)\right\|_{2}^{2} \right] \leq \frac{\phi^y }{\hat{\lambda}_{K+1}} \end{aligned} \end{small} \end{equation} where $\hat{\lambda}_i$ is the $i$-th smallest eigenvalue of the Laplacian matrix $\widehat{\mathbf{L}}_{sym} = \mathbf{I} - \widehat{\mathbf{A}}_{sym}$. Note that $\phi^y$ in Lemma \ref{thm:orig_mf_bound} equals $1- h_{edge}$. Then we apply Theorem \ref{thm:homo_sim} and conclude the proof: \begin{equation} \begin{small} \begin{aligned} \mathbb{E}_{v_i} \left[ \left\| \vec{y}_i-\mathbf{B}^{*} f_{\mathrm{gcl}}^{*}(v)\right\|_{2}^{2} \right] \leq \frac{1 - h_{edge} }{\hat{\lambda}_{K+1}} \le \frac{\bar \phi+ \sqrt{ \frac{\sigma^2_{\max}(\mathbf{W}^\top \mathbf{W}) \log(2N^2/\delta)}{2D^2 \|\mathbf{x}^2 \|_{\psi_1}} } }{\hat{\lambda}_{K+1}} \end{aligned} \end{small} \end{equation} \section{Conclusion} \label{sec:conclusion} In this work, we first investigate the effect of graph augmentation techniques--a crucial part of existing graph contrastive learning algorithms. Specifically, they tend to preserve the low-frequency information and perturb the high-frequency information, which mainly contributes to the success of augmentation-based GCL algorithms on the homophilic graph, but limits its application on the heterophilic graphs. Then, motivated by our theoretical analyses of the features aggregated by Graph Neural Networks, we propose an augmentation-free graph contrastive learning method, \textsc{AF-GCL}, wherein the self-supervision signal is constructed based on the aggregated features. We further provide the theoretical guarantee for the performance of \textsc{AF-GCL}\ as well as the analysis of its efficacy. Empirically, we show that \textsc{AF-GCL}\ outperforms state-of-the-art GCL algorithms on 4 out of 8 homophilic graph benchmarks and achieves competitive performance on the remaining 4 datasets. Besides, as the first method which can work well on both homophilic and heterophilic graphs, \textsc{AF-GCL}\ outperforms all those GCL algorithms and supervised methods on 5 out of 6 heterophilic graph benchmarks and achieve competitive performance on the remaining one. Admittedly, we mainly focus on the node classification problem. We would like to leave the exploration of regression problem and graph classification problem in the future. \section{Experiments} \begin{table}[t] \small \centering \caption{Graph Contrastive Learning on Homophilic Graphs. The highest performance of unsupervised models is highlighted in boldface. \text{OOM} indicates Out-Of-Memory on a 32GB GPU.} \label{tab:homo_result} \scalebox{0.8}{ \setlength{\tabcolsep}{3.5pt}{ \begin{tabular}{l | llllllll} \toprule Models & {Cora} & {CiteSeer} & {PubMed} &{WikiCS} & {Amz-Comp.} & {Amz-Photo} &{Coauthor-CS} &{Coauthor-Phy.} \\ \hline MLP & 47.92 $\pm$ 0.41 & 49.31 $\pm$ 0.26 & 69.14 $\pm$ 0.34 & 71.98 $\pm$ 0.42 & 73.81 $\pm$ 0.21 & 78.53 $\pm$ 0.32 & 90.37 $\pm$ 0.19 & 93.58 $\pm$ 0.41 \\ GCN & 81.54 $\pm$ 0.68 & 70.73 $\pm$ 0.65 & 79.16 $\pm$ 0.25 & 93.02 $\pm$ 0.11 & 86.51 $\pm$ 0.54 & 92.42 $\pm$ 0.22 & 93.03 $\pm$ 0.31 & 95.65 $\pm$ 0.16 \\ \hline DeepWalk & 70.72 $\pm$ 0.63 & 51.39 $\pm$ 0.41 & 73.27 $\pm$ 0.86 & 74.42 $\pm$ 0.13 & 85.68 $\pm$ 0.07 & 89.40 $\pm$ 0.11 & 84.61 $\pm$ 0.22 & 91.77 $\pm$ 0.15 \\ Node2cec & 71.08 $\pm$ 0.91 & 47.34 $\pm$ 0.84 & 66.23 $\pm$ 0.95 & 71.76 $\pm$ 0.14 & 84.41 $\pm$ 0.14 & 89.68 $\pm$ 0.19 & 85.16 $\pm$ 0.04 & 91.23 $\pm$ 0.07 \\ \hline GAE & 71.49 $\pm$ 0.41 & 65.83 $\pm$ 0.40 & 72.23 $\pm$ 0.71 & 73.97 $\pm$ 0.16 & 85.27 $\pm$ 0.19 & 91.62 $\pm$ 0.13 & 90.01 $\pm$ 0.71 & 94.92 $\pm$ 0.08 \\ VGAE & 77.31 $\pm$ 1.02 & 67.41 $\pm$ 0.24 & 75.85 $\pm$ 0.62 & 75.56 $\pm$ 0.28 & 86.40 $\pm$ 0.22 & 92.16 $\pm$ 0.12 & 92.13 $\pm$ 0.16 & 94.46 $\pm$ 0.13 \\ DGI & 82.34 $\pm$ 0.71 & 71.83 $\pm$ 0.54 & 76.78 $\pm$ 0.31 & 75.37 $\pm$ 0.13 & 84.01 $\pm$ 0.52 & 91.62 $\pm$ 0.42 & 92.16 $\pm$ 0.62 & 94.52 $\pm$ 0.47 \\ GMI & 82.39 $\pm$ 0.65 & 71.72 $\pm$ 0.15 & 79.34$ \pm$ 1.04 & 74.87 $\pm$ 0.13 & 82.18 $\pm$ 0.27 & 90.68 $\pm$ 0.18 & \text{OOM} & \text{OOM} \\ MVGRL & {\bf 83.45} $\pm$ {\bf 0.68} & {\bf 73.28} $\pm$ {\bf 0.48} & 80.09 $\pm$ 0.62 & 77.51 $\pm$ 0.06 & 87.53 $\pm$ 0.12 & 91.74 $\pm$ 0.08 & 92.11 $\pm$ 0.14 & 95.33 $\pm$ 0.05 \\ GRACE & 81.92 $\pm$ 0.89 & 71.21 $\pm$ 0.64 & {\bf 80.54} $\pm$ {\bf 0.36} & 78.19 $\pm$ 0.10 & 86.35 $\pm$ 0.44 & 92.15 $\pm$ 0.25 & \underline{92.91 $\pm$ 0.20} & 95.26 $\pm$ 0.22 \\ GCA & 82.07 $\pm$ 0.10 & 71.33 $\pm$ 0.37 & 80.21 $\pm$ 0.39 & \underline{78.40 $\pm$ 0.13} & 87.85 $\pm$ 0.31 & 92.49 $\pm$ 0.11 & 92.87 $\pm$ 0.14 & \underline{95.68 $\pm$ 0.05} \\ BGRL & 81.44 $\pm$ 0.72 & 71.82 $\pm$ 0.48 & 80.18 $\pm$ 0.63 & 76.96 $\pm$ 0.61 & {\bf 89.62} $\pm$ {\bf 0.37} & {\bf 93.07} $\pm$ {\bf 0.34} & 92.67 $\pm$ 0.21 & 95.47 $\pm$ 0.28 \\ \midrule \textsc{AF-GCL} & \underline{83.32 $\pm$ 0.13} & \underline{72.09 $\pm$ 0.42} & \underline{80.25 $\pm$ 0.75} & {\bf 78.95} $\pm$ {\bf 0.51} & \underline{{89.27} $\pm$ {0.25}} & \underline{92.89 $\pm$ 0.49} & {\bf 92.91} $\pm$ {\bf 0.10} & {\bf 95.75} $\pm$ {\bf 0.15} \\ \bottomrule \end{tabular}} } \label{tab:IR_performance} \end{table} \begin{table}[t] \centering \small \caption{Graph Contrastive Learning on Heterophilic Graphs. The highest performance of unsupervised models is highlighted in boldface. \text{OOM} indicates Out-Of-Memory on a 32GB GPU.} \label{tab:heter_result} \setlength{\tabcolsep}{5pt}{ \begin{tabular}{l | llllll} \toprule Models & Chameleon & Squirrel & Actor & Twitch-DE & Twitch-gamers & Genius \\ \hline MLP & 47.59 $\pm$ 0.73 & 31.67 $\pm$ 0.61 & 25.62 $\pm$ 0.59 & 69.44 $\pm$ 0.17 & 60.71 $\pm$ 0.18 & 86.62 $\pm$ 0.11 \\ GCN & 66.45 $\pm$ 0.48 & 53.03 $\pm$ 0.57 & 30.28 $\pm$ 0.60 & 73.43 $\pm$ 0.07 & 62.74 $\pm$ 0.03 & 87.72 $\pm$ 0.18 \\ \hline DeepWalk & 60.18 $\pm$ 1.25 & 45.83 $\pm$ 0.95 & 27.81 $\pm$ 0.81 & 72.40 $\pm$ 0.39 & 62.63 $\pm$ 0.16 & 74.65 $\pm$ 0.13 \\ Node2cec & 31.23 $\pm$ 0.98 & 29.99 $\pm$ 0.81 & 28.46 $\pm$ 0.45 & 71.38 $\pm$ 0.15 & 62.29 $\pm$ 0.11 & 72.51 $\pm$ 0.14 \\ \hline GAE & 52.85 $\pm$ 0.41 & 41.83 $\pm$ 0.79 & 31.02 $\pm$ 1.42 & 68.81 $\pm$ 0.35 & 57.18 $\pm$ 0.25 & 80.56 $\pm$ 0.15 \\ VGAE & 57.28 $\pm$ 0.12 & 46.31 $\pm$ 0.26 & 40.96 $\pm$ 1.13 & 64.97 $\pm$ 0.04 & 61.35 $\pm$ 0.05 & 81.82 $\pm$ 1.04 \\ DGI & 65.79 $\pm$ 1.27 & 47.99 $\pm$ 0.64 & 51.80 $\pm$ 0.98 & 72.45 $\pm$ 0.19 & {\bf 63.36 $\pm$ 0.07} & 86.82 $\pm$ 0.45 \\ GMI & 64.93 $\pm$ 1.58 & 42.48 $\pm$ 1.06 & 37.51 $\pm$ 0.83 & 73.36 $\pm$ 0.14 & OOM & OOM \\ MVGRL & 53.73 $\pm$ 1.26 & 39.05 $\pm$ 0.81 & \underline{55.52 $\pm$ 0.74} & 66.09 $\pm$ 0.26 & OOM & OOM \\ GRACE & 66.14 $\pm$ 0.53 & 53.09 $\pm$ 0.86 & 50.06 $\pm$ 0.62 & \underline{73.79 $\pm$ 0.22} & OOM & OOM \\ GCA & 66.21 $\pm$ 0.77 & 53.34 $\pm$ 0.79 & 49.83 $\pm$ 0.41 & 73.09 $\pm$ 0.09 & OOM & OOM \\ BGRL & \underline{67.29 $\pm$ 0.70} & \underline{55.48 $\pm$ 0.63} & 51.88 $\pm$ 0.39 & 73.54 $\pm$ 0.16 & 62.63 $\pm$ 0.26 & \underline{87.27 $\pm$ 0.03} \\ \midrule AF-GCL & {\bf 69.34 $\pm$ 0.81} & {\bf 57.46 $\pm$ 0.48} & {\bf 58.83 $\pm$ 0.82} & {\bf 74.15 $\pm$ 0.09} & \underline{63.17 $\pm$ 0.11} & {\bf 91.61 $\pm$ 0.29} \\ \bottomrule \end{tabular}} \end{table} \label{sec:exp} By extensive experiments, we show the efficacy, efficiency, and scalability of \textsc{AF-GCL}\ for both homophilic and heterophilic graphs. The results on homophilic and heterophilic graph benchmarks are presented in Section~\ref{subsec:homo_result} and Section~\ref{subsec:heter_result} respectively. The scalability and complexity analysis are given in Section~\ref{subsec:memo_analysis}. In Section~\ref{subsec:dim_analysis}, we analyze the effect of the hidden dimension size. Experiment details are given in Appendix~\ref{apd:model_detail}. \textbf{Datasets.} We analyze the quality of representations learned by \textsc{AF-GCL}\ on transductive node classification benchmarks. Specifically, we evaluate the performance of using the pretraining representations on 8 benchmark homophilic graph datasets, namely, Cora, Citeseer, Pubmed~\cite{kipf2016semi} and Wiki-CS, Amazon-Computers, Amazon-Photo, Coauthor-CS, Coauthor-Physics~\cite{shchur2018pitfalls}, as well as 6 heterophilic graph datasets, namely, Chameleon, Squirrel, Actor~\cite{pei2020geom}, Twitch-DE, Twitch-gamers, and Genius~\cite{lim2021new}. The datasets are collected from real-world networks from different domains; their detailed statistics are summarized in Table~\ref{tab:data_stat} and the detailed descriptions are in Appendix~\ref{apd:dataset_section}. \textbf{Baselines.} We consider representative baseline methods belonging to the following three categories (1) Traditional unsupervised graph embedding methods, including DeepWalk~\cite{perozzi2014deepwalk} and Node2Vec~\cite{grover2016node2vec} , (2) Self-supervised learning algorithms with graph neural networks including Graph Autoencoders (GAE, VGAE)~\cite{kipf2016variational} , Deep Graph Infomax (DGI)~\cite{velickovic2019deep} , Graphical Mutual Information Maximization (GMI)~\cite{peng2020graph}, and Multi-View Graph Representation Learning (MVGRL)~\cite{hassani2020contrastive}, graph contrastive representation learning (GRACE)~\cite{zhu2020deep} Graph Contrastive learning with Adaptive augmentation (GCA)~\cite{zhu2021graph}, Bootstrapped Graph Latents (BGRL)~\cite{thakoor2021bootstrapped}, (3) Supervised learning and Semi-supervised learning, e.g., Multilayer Perceptron (MLP) and Graph Convolutional Networks (GCN)~\cite{kipf2016semi}, where they are trained in an end-to-end fashion. \textbf{Protocol.} We follow the evaluation protocol of previous state-of-the-art graph contrastive learning approaches. Specifically, for every experiment, we employ the linear evaluation scheme as introduced in ~\cite{velickovic2019deep}, where each model is firstly trained in an unsupervised manner; then, the pretrained representations are used to train and test via a simple linear classifier. For the datasets that came with standard train/valid/test splits, we evaluate the models on the public splits. For datasets without standard split, e.g., Amazon-Computers, Amazon-Photo, Coauthor-CS, Coauthor-Physics, we randomly split the datasets, where 10\%/10\%/80\% of nodes are selected for the training, validation, and test set, respectively. For most datasets, we report the averaged test accuracy and standard deviation over 10 runs of classification. While, following the previous works~\cite{lim2021new, lim2021large}, we report the test ROC AUC on genius and Twitch-DE datasets. \textbf{Implementation.} We employ a two-layer GCN~\cite{kipf2016semi} as the encoder for all baselines due to its simplicity. Note, although the GCN will encourage the learning of low-frequency information~\cite{balcilar2020analyzing}, Ma el al.~\cite{ma2021homophily} demonstrated that GCN is enough to capture the information within heterophilic graphs following our Assumption~\ref{ass:label}. Further, the propagation for a single layer GCN is given by, \begin{equation*} \mathrm{GCN}_{i}(\mathbf{X}, \mathbf{A})=\sigma\left(\bar{\mathbf{D}}^{-\frac{1}{2}} \bar{\mathbf{A}} \bar{\mathbf{D}}^{-\frac{1}{2}} \mathbf{X} \mathbf{W}_{i}\right), \end{equation*} where $\bar{\mathbf{A}}=\mathbf{A}+\mathbf{I}$ is the adjacency matrix with self-loops, $\bar{\mathbf{D}}$ is the degree matrix, $\sigma$ is a non-linear activation function, such as ReLU, and $\mathbf{W}_{i}$ is the learnable weight matrix for the $i$'th layer. The proposed contrastive loss (Equation~\eqref{equ:the_loss}) is in expectation format. Its empirical version can be written as, \begin{equation} \label{equ:emp_loss} \begin{aligned} \widehat{\mathcal{L}} = -\frac{2}{N\cdot K_{pos}}\sum_{i}^N \sum_{i^+}^{K_{pos}} \left[ \mathbf{Z}_i^{\top} \mathbf{Z}_{i^+} \right] + \frac{1}{N\cdot K_{neg}} \sum_{j}^N \sum_{k}^{K_{neg}} \left[ \left( \mathbf{Z}_j^{\top} \mathbf{Z}_{k} \right)^2 \right], \end{aligned} \end{equation} where to approximate the expectation over negative pairs (second term of Equation~\eqref{equ:the_loss}), we sample $K_{neg}$ nodes for each node. Notably, the empirical contrastive loss is an unbiased estimation of the Equation~\eqref{equ:the_loss}. \subsection{Performance on Homophilic Graph} \label{subsec:homo_result} The homophilic graph benchmarks have been studied by several previous works~\cite{velickovic2019deep, peng2020graph, hassani2020contrastive, zhu2020deep, thakoor2021bootstrapped}. We re-use their configuration and compare \textsc{AF-GCL}\ with those methods. The result is summarized in Table~\ref{tab:homo_result}. The augmentation-based GCL methods can outperform the corresponding supervised training model. As we analyzed in Section~\ref{sec:aug_study}, those methods implicitly perturb the high-frequency information across different augmentation views, and the commonly adopted InfoNCE loss~\cite{van2018representation} enforce the target GNN model to capture the low-frequency information by enforcing the learned representation invariant with different augmentations. And the low-frequency information contributes to the success of the previous GCL methods on the homophilic graphs, which is aligned with previous analysis~\cite{nt2019revisiting, balcilar2020analyzing}. Compare with augmentation-based GCL methods, \textsc{AF-GCL}\ outperforms previous methods on three datasets and achieves second-best performance on the other datasets, which shows the effectiveness of the augmentation-free design on homophilic graphs. In other words, the proposed contrastive learning objective based on the ``embedding concentration property'' always demonstrates top-2 accuracy among all compared baselines. Note that in our analysis, these baselines are indeed tailored for homophilic graphs and \textsc{AF-GCL}\ is a theoretically-justified contrastive learning framework without augmentations. \subsection{Performance on Heterophilic Graph} \label{subsec:heter_result} We further assess the model performance on heterophilic graph benchmarks that introduced by Pei et al.~\cite{pei2020geom} and Lim et al.~\cite{lim2021large}. Different from the experiments on homophilic graphs, existing contrastive learning methods cannot outperform a vanilla superivsed GCN on most of the datasets. As shown in Table~\ref{tab:heter_result}, \textsc{AF-GCL}\ achieves the best performance on 5 of 6 heterophilic graphs by an evident margin. For the Twitch-gamers dataset, \textsc{AF-GCL}\ is competitive with the best one, since it is the heterophilic dataset with the highest node homophily degree. The relatively high homophilic property allows the previous method to work well. Besides, we notice that for the two graphs with the lowest homophily degree, Chameleon and Squirrel, \textsc{AF-GCL}\ outperform the previous methods with a large margin. The result verifies that our proposed method is suitable for heterophilic graphs. Interestingly, some of the baselines even cannot scale to some graphs and perform poorly on the others. We believe it is due to the high computational cost and loss of the high-frequency information after graph augmentations, which is an innate deficiency of these methods. \vspace{-5pt} \begin{table}[h] \centering \caption{Computational requirements on a set of standard benchmark graphs. OOM indicates runing out of memory on a 32GB GPU.} \label{tab:memo} \setlength{\tabcolsep}{4pt}{ \begin{tabular}{l | lllll} \toprule \text {Dataset} & \text {Coauthor-CS} & \text {Coauthor-Phy.} & \text {Genius} & \text {Twitch-gamers} \\ \hline \text {\# Nodes} & 18,333 & 34,493 & 421,961 & 168,114 \\ \text {\# Edges} & 327,576 & 991,848 & 984,979 & 6,797,557 \\ \hline \text {GRACE} & 13.21 {GB} & 30.11 {GB} & {OOM} & {OOM} \\ \text {BGRL} & 3.10 {GB} & 5.42 {GB} & {8.18} {GB} & {26.22} {GB} \\ \text {\textsc{AF-GCL}} & 2.07 {GB} & 3.21 {GB} & 6.24 {GB} & {22.15} {GB} \\ \bottomrule \end{tabular}} \end{table} \vspace{-10pt} \subsection{Computational Complexity Analysis} \label{subsec:memo_analysis} In order to illustrate the advantages of \textsc{AF-GCL}, we provide a brief comparison of the time and space complexities between \textsc{AF-GCL}, the previous strong contrastive method, GCA~\cite{zhu2021graph}, and the memory-efficient contrastive method, BGRL~\cite{thakoor2021bootstrapped}. GCA is the advanced version of GRACE~\cite{zhu2021graph} and performs a quadratic all-pairs contrastive computation at each update step. BGRL, inspired by the bootstrapped design of contrastive learning methods in CV~\cite{grill2020bootstrap}, conducts the pairwise comparison between the embeddings learned by an online encoder and a target encoder. Although BGRL does not require negative examples, the two branch design, two different encoders and four embedding table still need to be kept during training, making it hard to scale. Consider a graph with N nodes and E edges, and a graph neural network (GNN), $f$, that compute node embeddings in time and space $O(N + E)$. This property is satisfied by most popular GNN architectures, e.g., convolutional~\cite{kipf2016semi}, attentional~\cite{velivckovic2017graph}, or message-passing~\cite{gilmer2017neural} networks and have been analyzed in the previous works~\cite{thakoor2021bootstrapped}. BGRL performs four GNN computations per update step, in which twice for the target and online encoders, and twice for each augmentation, and a node-level projection; GCA performs two GNN computations (once for each augmentation), plus a node-level projection. Both methods backpropagate the learning signal twice (once for each augmentation), and we assume the backward pass to be approximately as costly as a forward pass. Both of them will compute the augmented graphs by feature masking and edge masking on the fly, the cost for augmentation computation is nearly the same. Thus the total time and space complexity per update step for BGRL is $6C_{encoder}(E + N) + 4C_{proj}N + C_{prod}N + C_{aug}$ and $4 C_{encoder}(E + N) + 4C_{proj}N + C_{prod}N^2 + C_{aug}$ for GCA. The $C_{prod}$ depends on the dimension of node embedding and we assume the node embeddings of all the methods with the same size. For our proposed method, only one GNN encoder is employed and we compute the inner product of $b$ nodes to construct positive samples and $K_{pos}$ and $K_{neg}$ inner product for the loss computation. Then for \textsc{AF-GCL}, we have: $2C_{encoder}(E + N) + 2C_{proj}N + C_{prod}(K_{pos}+K_{neg})^2$. We empirically measure the peak of GPU memory usage of \textsc{AF-GCL}, GCA and BGRL. As a fair comparison, we set the embedding size as 128 for all those methods on the four datasets and keep the other hyper-parameters of the three methods the same as the main experiments. The result is summarized in Table~\ref{tab:memo}. \vspace{-5pt} \begin{table}[h] \centering \caption{The performance of \textsc{AF-GCL}\ with different hidden dimension. The average accuracy over 10 runs is reported.} \label{tab:dim_study} \begin{tabular}{l|llll} \toprule & WikiCS & Amz-Comp. & Actor & Twitch-DE \\ \hline $K=256$ & 78.01 & 88.51 & 57.90 & 73.48 \\ $K=512$ & 78.95 & 89.27 & 58.83 & 74.15 \\ $K=1024$ & 79.11 & 89.79 & 59.04 & 74.67 \\ \bottomrule \end{tabular} \end{table} \subsection{Representation Size Analysis} \label{subsec:dim_analysis} As implied by Theorem~\ref{thm:gcl_bound}, a larger hidden dimension leads to better performance. We empirically verify that on four datasets. The result is summarized in Table~\ref{tab:dim_study} and we can see that the performance increases consistently with larger $K$. \section{Introduction} \label{intro} Graph Neural Networks (GNNs)~\cite{kipf2016semi, xu2018powerful, velivckovic2017graph, hamilton2017inductive} have attracted great attention due to their success in various applications involving graph-structured data, such as node classification~\cite{kipf2016semi}, edge prediction~\cite{kipf2016variational}, graph classification~\cite{xu2018powerful}, etc. Most of these tasks are semi-supervised and therefore require a certain number of labels to guide the learning process. However, in many real-world applications (e.g., chemistry and healthcare), labels are scarcely available. Self-supervised learning (SSL), as an appropriate paradigm for such label-scarce settings, has been extensively studied in Computer Vision (CV). Besides, contrastive learning, the most representative SSL technique, has achieved state-of-the-art performance~\cite{jaiswal2021survey}. This has motivated the self-supervised learning, especially contrastive learning, approaches~\cite{xie2021self} on graph data. Contrastive learning is essentially learning representations invariant to data augmentations which are thoroughly explored on visual data~\cite{hataya2020faster, lim2019fast}. Leveraging the same paradigm, Graph Contrastive Learning (GCL) encourages the representations to contain as less information about the way the inputs are transformed as possible during training, i.e. to be invariant to a set of manually specified transformations. However, the irregular structure of the graph complicates the adaptation of augmentation techniques used on images, and prevents the extending of theoretical analysis for visual contrastive learning to a graph setting. In recent years, many works~\cite{you2020graph, peng2020graph, hassani2020contrastive, zhu2021graph, zhu2020deep, zhu2020transfer} focus on the empirical design of hand-craft graph augmentations for graph contrastive learning from various levels, including node dropping, edge perturbation, attribute masking, subgraph~\cite{you2020graph}, and graph diffusion~\cite{hassani2020contrastive}. Although experiments have demonstrated the effectiveness of the GCL algorithms~\cite{zhu2021empirical}, those empirical studies are limited to the homophilic graphs, where the linked nodes are likely from the same class, e.g. social network and citation networks~\cite{mcpherson2001birds}. In heterophilic graphs, similar nodes are often far apart (e.g., the majority of people tend to connect with people of the opposite gender~\cite{zhu2020beyond} in dating networks), which urges the investigation on the generalization of GCL frameworks on both homophilic and heterophilic graphs. To fill this gap, we first investigate the empirical success of GCL algorithms. As discussed in~\cite{you2020graph, zhu2021empirical}, existing GCL algorithms learn invariant representations across different graph augmentation views. In this work, we take a closer look at what information is preserved or perturbed by commonly used graph augmentations. By analyzing the graph structure and features from the view of frequency, we observe that graph augmentations mainly preserve low-frequency information and corrupt middle and high-frequency information of the graph. By enforcing the model to learn representations invariant to the perturbations through maximizing the agreement between a graph and its augmentations, the learned representations will only retain the low-frequency information. As demonstrated in~\cite{balcilar2020analyzing}, the low-frequency information is critical for the homophilic graph. However, for heterophilic graph, the low-frequency information is insufficient for learning effective representations. Under this circumstance, the middle and high-frequency information, capturing the difference between nodes, may be more effective~\cite{bo2021beyond, li2021beyond}, but typically overlooked by existing GCL algorithms. Thus, it rises a natural question, that is, \emph{is it possible to design a generic graph contrastive learning method effective on both homophilic and heterophilic graphs?} In this work, we answer the above question affirmatively by providing a new perspective of achieving SSL on graphs. Specifically, based on our analysis of the concentration property of aggregated features on both homophilic and heterophilic graphs, we propose a novel {\it augmentation-free graph contrastive learning} method, named \textsc{AF-GCL}. Different from the large body of previous works on the graph contrastive learning, in which the construction of self-supervision signals is heavily relying on graph augmentation, \textsc{AF-GCL}\ constructs positive/negative pairs based on the aggregated node features and directly optimizes the distance of representations in high-dimensional space. As a simple yet effective approach, \textsc{AF-GCL}\ frees the model from dual branch design and graph augmentations, which enable the proposed method to easily scale to large graphs. In addition, we present a theoretical guarantee for the performance of embedding learned by AF-GCL in downstream tasks, and our theoretical analysis provides an understanding of when and why \textsc{AF-GCL}\ can work well. Experimental results show that \textsc{AF-GCL}\ outperforms state-of-the-art GCL algorithms on 4 out of 8 homophilic graph benchmarks and achieve competitive performance on the remaining 4 datasets. Besides, as the first method which can work well on both homophilic and heterophilic graphs, \textsc{AF-GCL}\ outperforms all those GCL algorithms and supervised methods on 5 out of 6 heterophilic graph benchmarks and achieves competitive performance on the remaining one. Furthermore, we analyze the computational complexity of \textsc{AF-GCL}\ and empirically show that our method performs well with significantly less computational overhead. Our contribution could be summarized as: \begin{itemize}[leftmargin=15pt] \vspace{-15pt} \setlength\itemsep{-0.7em} \item We first analyze the efficacy of graph augmentation techniques for GCL as well as its limitations from a spectral point of view. We show that augmentation-based GCL is sensitive to the graph's homophily degree. \item We then illustrate the concentration property of representations obtained by the neighborhood feature aggregation, which in turn inspires our novel augmentation-free graph contrastive learning method, \textsc{AF-GCL}. \item We further present a theoretical guarantee for the performance of \textsc{AF-GCL}, as well as the analyses of \textsc{AF-GCL}'s robustness to the graph's homophily degree. \item Experimental results show that without complex designs, compared with SOTA GCL methods, \textsc{AF-GCL}\ achieves competitive or better performance on 8 homophilic graph benchmarks and 6 heterophilic graph benchmarks, with significantly less computational overhead. \end{itemize} \section{Methodology} As analyzed in the previous section, the aforementioned graph augmentation techniques are less effective for heterophilic graphs (see also experimental results in Table~\ref{tab:heter_result}). To design a universal self-supervision signal, we are motivated to analyze the concentration property of aggregated node feature $\mathbf{Z}$ (Section~\ref{sec:concentration}) for both homophilic and heterophilic graphs. Namely, nodes of the same class are closer with each other under different degree of homophily. Leveraging the concentration property, we propose an augmentation-free method (Section~\ref{sec:Method}), \textsc{AF-GCL}, to construct positive and negative pairs for contrastive learning. \begin{figure*}[h] \centering \includegraphics[width=0.9\textwidth]{images/model.png} \caption{Overview of the proposed \textsc{AF-GCL}.} \label{fig:model} \end{figure*} \subsection{Analysis of Aggregated Features} \label{sec:concentration} We follow prior work \cite{deshpande2018contextual,baranwal2021graph} to assume that the node feature follows the Gaussian mixture model \cite{reynolds2009gaussian}. For simplicity, we focus on the two-classes problem. Conditional on the (binary-) label $y$ and a latent vector ${\bf u} \sim \mathcal{N}( \mathbf{0}, \mathbf{I}_F/F)$, the features are governed by: \begin{equation} \label{eq:feature} {\bf x}_i = y_i {\bf u} + \frac{ \vec{\mathbf{\mu}}_i}{\sqrt{F}}, \end{equation} where random variable $\vec{\mathbf{\mu}}_i \in \mathbb{R}^F$ has independent standard normal entries and $y_i \in \{-1, 1 \}$ representing latent classes. In other words, the features of nodes with class $y_i$ follow the same distribution depending on $y_i$, \textit{i.e.}, $\mathbf{x}_i \sim P_{y_i}(\mathbf{x})$. Furthermore, we make an assumption on the neighborhood patterns, \begin{ass} \label{ass:label} For node $i$, its neighbor's labels are independently sampled from a distribution $P({y_i})$. \end{ass} The above assumption implies that the neighbor's label is generated from a distribution only dependent on the label of the central node, which contains both cases of homophily and heterophily. With this assumption, we prove the following Lemma~\ref{lem:emb} that all aggregated node features with the same label have the same embedding regardless of homophily or heterophily. Specifically, we define learned embedding through a GCN and MLP by $\mathbf{Z}$ as shown in Figure \ref{fig:model}, and $\mathbf{Z}_i$ is the learned embedding with respect to input $\mathbf{x}_i$. To simplify the analysis, we introduce $\mathbf{W}$ being the equivalent linear weight after dropping non-linearity in GCN and MLP. \begin{lem}[Adaption of Theorem 1 in \cite{ma2021homophily}] \label{lem:emb} Consider a graph $G$ following the assumption \ref{ass:label} and Eq. (\ref{eq:feature}), then the expectation of embedding is given by \begin{equation} \mathbb{E}[\mathbf{Z}_i] = \mathbf{W} ~ \mathbb{E}_{y \sim P({y_i}), \mathbf{x} \sim P_y(\mathbf{x}) } [\mathbf{x}], \end{equation} Furthermore, with probability at least $1-\delta$ over the distribution for graph, we have: \begin{equation} \| \mathbf{Z}_i - \mathbb{E}[\mathbf{Z}_i] \|_2 \le \sqrt{ \frac{\sigma^2_{\max}(\mathbf{W})F \log(2F/\delta)}{2\mathbf{D}_{ii}\|\mathbf{x} \|_{\psi_2}} }, \end{equation} where the sub-gaussian norms $\|\mathbf{x} \|_{\psi_2} \equiv \min_i \|\mathbf{x}_{i,d} \|_{\psi_2}$, $d \in [1,F]$ and $\sigma^2_{\max}(\mathbf{W})$ is the largest singular value of $\mathbf{W}$, because each dimension in feature is independently distributed. \end{lem} We leave the proof of the above lemma in Appendix~\ref{apd: lemma_emb_proof}. The above lemma indicates that, for any graph where the feature and neighborhood pattern of each node is sampled from the distributions depending on the node label, the GCN model is able to map nodes with the same label to an area centered around the expectation in the embedding space. \subsection{Augmentation-Free Graph Contrastive Learning (\textsc{AF-GCL})} \label{sec:Method} \begin{algorithm}[b] \caption{Augmentation-Free Graph Contrastive Learning (\textsc{AF-GCL}).} \begin{algorithmic} \label{alg:afgcl} \STATE \textbf{Input:} Graph neural network $f_{\theta}$, MLP $g_{\omega}$, input adjacency matrix $\mathbf{A}$, node features $\mathbf{X}$, batch size $b$, number of hops $T$, number of positive nodes $K_{pos}$.\\ \FOR{epoch $\leftarrow$ 1, 2, $\cdots$} \STATE 1.Obtain the node embedding, $\mathbf{H}=f_{\theta}(\mathbf{X}, \mathbf{A})$. \\ \STATE 2.Obtain the hidden representation, $\mathbf{Z}=g_{\omega}(\mathbf{H})$. \\ \STATE 3.Sample $b$ nodes for seed node set $S$. \\ \STATE 4.Construct the node pool $P$ with the $T$-hop neighbors of each node in the node set $S$.\\ \STATE 5.Select top-$K_{pos}$ similar nodes for every $v_i \in S$ to form the positive node set $S^{i}_{pos}$. \\ \STATE 6.Compute the contrastive objective with Eq.~\eqref{equ:the_loss} and update parameters by applying stochastic gradient. \ENDFOR\\ \textbf{return} Final model $f_{\theta}$. \end{algorithmic} \end{algorithm} The above theoretical analysis reveals that, for each class, the embedding obtained from neighbor aggregation will concentrate toward the expectation of embedding belonging to the class. Inspired by this, we design the self-supervision signal based on the obtained embedding and propose a novel augmentation-free graph contrastive learning algorithm, \textsc{AF-GCL}, which selects similar nodes as positive node pairs. As shown in the previous analysis, the concentration property is independent with homophily and heterophily assumptions, therefore \textsc{AF-GCL}\ generalizes well on both homophilic and heterophilic graphs. And the augmentation-free design makes \textsc{AF-GCL}\ get rid of the commonly adapted dual-branch design~\cite{zhu2021empirical} and significantly reduce the computational overhead. As shown in Figure~\ref{fig:model}, in each iteration, the proposed framework first encodes the graph with a graph encoder $f_{\theta}$ denoted by $\mathbf{H}=f_\theta(\mathbf{X}, \mathbf{A})$. Notably, our framework allows various choices of the network architecture without any constraints. Then, a MLP projection head with L2-normalization, $g_{\omega}$, is employed to project the node embedding into the hidden representation $\mathbf{Z} = g_{\omega}(\mathbf{H})$. At each iteration, $b$ nodes are sampled to form the seed node set $S$; and their surrounding $T$-hop neighbors consist the node pool, $P$. For each seed node $v_i \in S$, the top-$K_{pos}$ nodes with highest similarity from the node pool are selected as positive set for it, and denote as $S^{i}_{pos} = \{v_i, v_{i}^1, v_{i}^2, \ldots, v_{i}^{K_{pos}} \}$. Specifically, \begin{equation} \begin{aligned} v_{i}^1, v_{i}^2, \ldots, v_{i}^{K_{pos}} = \argmax_{v_j \in P} \left( \mathbf{Z}_i^{\top} \mathbf{Z}_j, K_{pos}\right), \end{aligned} \end{equation} where $\argmax(\cdot, K_{pos})$ denotes the operator for the top-$K_{pos}$ selection, and because the hidden representation is normalized, the inner product of hidden representations is equal to the cosine similarity. The framework is optimized with the following objective: \begin{equation} \label{equ:the_loss} \begin{aligned} \mathcal{L}_{gcl} = -2~\mathbb{E}_{v_i \sim Uni(\mathcal{V})\atop v_{i^+} \sim Uni(S^{i}_{pos})} \left[ \mathbf{Z}_i^{\top} \mathbf{Z}_{i^+} \right] + \mathbb{E}_{v_j \sim Uni(\mathcal{V}) \atop v_k \sim Uni(\mathcal{V})} \left[ \left( \mathbf{Z}_j^{\top} \mathbf{Z}_{k} \right)^2 \right]. \end{aligned} \end{equation} where the node $v_{i^+}, v_j $ and $v_k$ are uniformly sampled from their corresponding set. Overall, the training algorithm \textsc{AF-GCL}\ is summarized in Algorithm~\ref{alg:afgcl}. \section{Preliminary} \label{sec:preliminary} \subsection{Notation} \label{subsec:notation} Let $\mathcal{G}=(\mathcal{V}, \mathcal{E})$ denote an undirected graph, where $\mathcal{V} = \{v_i\}_{i\in[N]}$ and $\mathcal{E} \subseteq$ $\mathcal{V} \times \mathcal{V}$ denote the node set and the edge set respectively. We denote the number of nodes and edges as $N$ and $E$, and the label of nodes as $\mathbf{y}\in \mathbb{R}^N$, in which $y_i \in [1, c], c\geq2$ is the number of classes. The associated node feature matrix denotes as $\mathbf{X} \in \mathbb{R}^{N \times F}$, where $\mathbf{x}_{i} \in \mathbb{R}^{F}$ is the feature of node $v_i \in \mathcal{V}$ and $F$ is the input feature dimension. The adjacent matrix denotes as $\mathbf{A} \in\{0,1\}^{N \times N}$, where $\mathbf{A}_{i j}=1$ if $\left(v_i, v_j\right) \in \mathcal{E}$. Our objective is to unsupervisedly learn a GNN encoder $f_{\theta}: \mathbf{X}, \mathbf{A} \rightarrow \mathbb{R}^{N \times K}$ receiving the node features and graph structure as input, that produces node representations in low dimensionality, i.e., $K \ll F$. The representations can benefit the downstream supervised or semi-supervised tasks, e.g., node classification. \subsection{Homophilic and Heterophilic Graph} Various metrics have been proposed to measure the homophily degree of a graph. Here we adopt two representative metrics, namely, node homophily and edge homophily. The edge homophily~\cite{zhu2020beyond} is the proportion of edges that connect two nodes of the same class: \begin{equation} \begin{small} \begin{aligned} h_{edge}=\frac{\left|\left\{\left(v_{i}, v_{j}\right):\left(v_{i}, v_{j}\right) \in \mathcal{E} \wedge y_{i}=y_{j}\right\}\right|}{E}, \end{aligned} \end{small} \end{equation} And the node homophily~\cite{pei2020geom} is defined as, \begin{equation} \begin{small} \begin{aligned} h_{node}=\frac{1}{N} \sum_{v_i\in \mathcal{V}} \frac{\left|\left\{v_{j}:\left(v_{i}, v_{j}\right) \in \mathcal{E} \wedge y_{i}=y_{j}\right\}\right|}{ \left| \left\{ v_{j}:\left(v_{i}, v_{j}\right) \in \mathcal{E} \right\} \right| }, \end{aligned} \end{small} \end{equation} which evaluates the average proportion of edge-label consistency of all nodes. They are all in the range of $[0, 1]$ and a value close to $1$ corresponds to strong homophily while a value close to $0$ indicates strong heterophily. As conventional, we refer the graph with high homophily degree as homophilic graph, and the graph with low homophily degree as heterophilic graph. And we provided the homophily degree of graph considered in this work in Table~\ref{tab:data_stat}. \subsection{Graph Laplacian and Variants} \label{subsec:laplacian_concept} We define the Laplacian matrix of the graph as $\mathbf{L}=\mathbf{D}-\mathbf{A}$, where $\mathbf{D}=\operatorname{diag}\left(d_{1}, \ldots, d_{N}\right)$, $d_{i}=\sum_{j} \mathbf{A}_{i, j}$. The symmetric normalized Laplacian, is defined as $\mathbf{L}_{s y m}=\mathbf{D}^{-\frac{1}{2}} \mathbf{L} \mathbf{D}^{-\frac{1}{2}}=\mathbf{U} \mathbf{\Lambda} \mathbf{U}^{\top}$. Here $\mathbf{U} \in \mathbb{R}^{N \times N}=\left[\mathbf{u}_{1}, \ldots, \mathbf{u}_{N}\right]$, where $\mathbf{u}_{i} \in \mathbb{R}^{N}$ denotes the $i$-th eigenvector of $\mathbf{L}_{s y m}$ and $\mathbf{\Lambda}=$ $\operatorname{diag}\left(\lambda_{1}, \ldots, \lambda_{N}\right)$ is the corresponding eigenvalue matrix. $\lambda_{1}$ and $\lambda_{N}$ be the smallest and largest eigenvalue respectively. The affinity (transition) matrices can be derived from the Laplacian matrix, $\mathbf{A}_{\text {sym }}=\mathbf{I}-\mathbf{L}_{\text {sym }}=\mathbf{D}^{-1 / 2} \mathbf{A} \mathbf{D}^{-1 / 2}=\mathbf{U} (\mathbf{I} - \mathbf{\Lambda})\mathbf{U}^{\top}$. The $\mathbf{L}_{sym}$ has eigenvalue from $0$ to $2$ and is widely used in the design of spectral graph neural networks, such as Graph Convolutional Network (GCN)~\cite{kipf2016semi}. For the Laplacian matrix, the smaller eigenvalue is corresponding to the lower frequency~\cite{balcilar2020analyzing}. Following the previous work~\cite{entezari2020all}, we define the decomposed components of ${\mathbf{L}}_{sym}$ under different frequency bands as ${\mathbf{L}}^m_{sym}$ which has eigenvalues in $\big[{\lambda}_{N}\cdot\frac{(m-1)}{M}, {\lambda}_{N}\cdot\frac{m}{M}\big)$, and $m \in [1, M], M\in \mathcal{Z}^+$ denotes the number of partition of the spectrum. More specifically, $ {\mathbf{L}}^m_{s y m}={\mathbf{U}} {\mathbf{\Lambda}}^m {\mathbf{U}}^{\top}, {\mathbf{\Lambda}}^m = \operatorname{diag}\left({\lambda}_{1}^m, \ldots, {\lambda}_{N}^m\right)$, where for $i \in [1, N]$, $$ {\lambda}_{i}^m= \begin{cases} {\lambda}_{i}, \text { if } \lambda_{i} \in \big[{\lambda}_{N}\cdot\frac{(m-1)}{M}, {\lambda}_{N}\cdot\frac{m}{M}\big) \\ 0, \text { otherwise }\end{cases}, $$ Note, the sum of all decomposed components is equal to the symmetric normalized Laplacian matrix, ${\mathbf{L}}_{sym} = \sum_{m=0}^{\ceil{N/M}}{\mathbf{L}}^m_{sym}$. \section{Related Work} \label{sec:Related Work} \vspace{-8pt} \subsection{Graph Contrastive Learning} \vspace{-5pt} Contrastive learning aims to learn consistent representations under proper transformations and has been widely applied to the visual domain. Graph Contrastive Learning (GCL) leverages the idea of CL on the graph data. However, due to the complex, irregular structure of graph data, it is more challenging to design appropriate strategies for constructing positive and negative samples on the graph than that on visual or textual data. Regarding graph augmentation, many previous studies~\cite{you2020graph, peng2020graph, hassani2020contrastive, zhu2021empirical, zhu2021graph, zhu2020deep, zhu2020transfer} propose data augmentation techniques for general graph-structured data, e.g., attribute masking, edge removing, edge adding, subgraph, graph diffusion. Specifically, MVGRL~\cite{hassani2020contrastive} employs graph diffusion to generate graph views with more global information; GCC~\cite{qiu2020gcc} use the subgraph induced by random walks to serve as different views. GraphCL~\cite{you2020graph} study multiple augmentation methods for graph-level representation learning. GRACE~\cite{zhu2020deep} constructs node-node pairs by using edge removing and feature masking. GCA~\cite{zhu2021graph} proposes adaptive augmentation techniques to further consider important topology and attribute information. BGRL~\cite{grill2020bootstrap} gets rid of the design of negative pairs, but its design of positive pairs also relies on edge removing and feature masking. We summarized the graph augmentation methods employed by the representative GCL methods in Table~\ref{tab:graph_aug_summary}. To the best of our knowledge, the current state-of-the-art GCL algorithms are highly reliant on graph augmentations, but none of the existing work studies the effect and limitation of current graph augmentation techniques in GCL. \begin{table*}[h] \vspace{-2pt} \centering \caption{Summary of graph augmentations used by representative GCL models. $\text{Multiple}^*$ denotes multiple augmentation methods including edge removing, edge adding, node dropping and subgraph induced by random walks.} \label{tab:graph_aug_summary} \begin{tabular}{c|c|c} \toprule \text { Method } & \text { Topology Aug. } & \text { Feature Aug. } \\ \hline \text { MVGRL~\cite{hassani2020contrastive} } & \text { Diffusion } & - \\ \text { GCC~\cite{qiu2020gcc}} & \text { Subgraph } & - \\ \text { GraphCL~\cite{you2020graph} } & \text { $\text{Multiple}^*$ } & \text { Feature Dropout } \\ \text { GRACE~\cite{zhu2020deep} } & \text { Edge Removing } & \text { Feature Masking } \\ \text { GCA~\cite{zhu2021graph} } & \text { Edge Removing } & \text { Feature Masking } \\ \text { BGRL~\cite{grill2020bootstrap} } & \text { Edge Removing } & \text { Feature Masking } \\ \bottomrule \end{tabular} \vspace{-2pt} \end{table*} \subsection{Understanding Contrastive Learning} \vspace{-8pt} Previous theoretical guarantees for contrastive learning follow conditional independence assumption (or its variants)~\cite{arora2019theoretical, lee2020predicting, tosh2021contrastive, tsai2020self}. Specifically, they assume the two contrastive views are independent conditioned on the label and show that contrastive learning can provably learn representations beneficial for downstream tasks. In addition, Wang et al.\cite{wang2020understanding} investigated the representation geometry of supervised contrastive loss and showed that the contrastive loss favors data representation uniformly distributed over the unit sphere yet aligning across semantically similar samples. Haochen et al.\cite{haochen2021provable} analyzed the contrastive learning on the augmented image dataset through the novel concept augmentation graph with a new loss function that performs spectral decomposition on the graph. However, all those theoretical analyses mainly focus on the classification problem with image datasets. Since graphs are far more complex due to the non-Euclidean property, the analysis for image classification cannot be trivially extended to graph setting Besides, on the other line of research, contrastive learning methods~\cite{khosla2020supervised, oord2018representation, peng2020graph, zhu2021graph} leveraging the information maximization principle (InfoMax)~\cite{linsker1988infomaxprinciple} aim to maximize the Mutual Information (MI) between the representation of one data point and that of its augmented version by contrasting positive pairs with negative-sampled counterparts. The key idea is that maximizing mutual information between representations extracted from multiple views can force the representations to capture information about higher-level factors (e.g., presence of certain objects or occurrence of certain events) that broadly affect the shared context. The employed loss functions, e.g. Information Noise Contrastive Estimation (InfoNCE) and Jensen-Shannon Divergence (JSD), are proved to be lower bounds of MI~\cite{gutmann2010noise, nowozin2016f, poole2019variational}. Although the idea of information maximization principle has been used in GCL domain~\cite{velickovic2019deep, zhu2020transfer, zhu2021graph}, the higher-level factors invariant across different graph augmentation views is under-defined. In this work, we take a closer look at the graph augmentations via the lens of spectral theory and analyze what information is preserved in different augmentation views. \section{Theoretical Analyses} \label{theo} In this section, we aim to derive a performance guarantee for \textsc{AF-GCL}. Note that we leave all the proof in the appendix. First, we introduce the concept of \emph{transformed graph} as follows, which is constructed based on the original graph and the selected positive pairs. \begin{defi} [Transformed Graph] \label{def:transformed_graph} Given the original graph $\mathcal{G}$ and its node set $\mathcal{V}$, the transformed graph, $\widehat{\mathcal{G}}$, has the same node set $\mathcal{V}$ but with the selected positive pairs by \textsc{AF-GCL}\ as the edge set, $\widehat{\mathcal{E}} = \bigcup_{i} \{ (v_i, v_{i}^k)|_{k=1}^{K_{pos}} \}$. \end{defi} \begin{figure}[h] \centering \includegraphics[width=8.0cm]{images/transformed_graph.png} \vspace{-1mm} \caption{Transformed Graph formed with Positive Pairs.} \label{fig:transformed_graph} \vspace{-1.2mm} \end{figure} We also illustrate the transformed graph with Figure~\ref{fig:transformed_graph}. And we denote the adjacency matrix of transformed graph as as $\widehat{\mathbf{A}} \in\{0,1\}^{N \times N} $, the number of edges as $\hat{E}$, and the symmetric normalized matrix as $\widehat{\mathbf{A}}_{sym}=\widehat{\mathbf{D}}^{-1/2} \widehat{\mathbf{A}} \widehat{\mathbf{D}}^{-1/2}$. Then we show that optimizing a model with the contrastive loss (Equation~\eqref{equ:the_loss}) is equivalent to the matrix factorization over the transformed graph, as stated in the following lemma: \begin{lem} \label{lem:equiv} Denote the learnable embedding for matrix factorization as $\mathbf{F}\in\mathbb{R}^{N\times K}$. Let $\mathbf{F}_{i} = f_{\theta}\circ g_{\omega}(v_i)$. Then, the matrix factorization loss function $\mathcal{L}_{\mathrm{mf}}$ is equivalent to the contrastive loss (Equation~\eqref{equ:the_loss}), up to an additive constant: \begin{equation} \label{equ:loss_equiv} \begin{small} \begin{aligned} &\mathcal{L}_{\mathrm{mf}}(\mathbf{F}) = \left\|\widehat{\mathbf{A}}_{sym}-\mathbf{F} \mathbf{F}^{\top}\right\|_{F}^{2} = \mathcal{L}_{gcl} + \text{const} \end{aligned} \end{small} \end{equation} \end{lem} The above lemma bridges the graph contrastive learning and the graph matrix factorization and therefore allows us to provide the performance guarantee of \textsc{AF-GCL}\ by leveraging the power of matrix factorization. In addition, we provide an analysis for the inner product of hidden representations, namely $\mathbf{Z}_i^\top \mathbf{Z}_j$: \begin{thm} \label{thm:homo_sim} Consider a graph $G$ following the assumption \ref{ass:label} and Eq. (\ref{eq:feature}). Then with probability at least $1-\delta$ we have, \begin{equation} \big| \mathbf{Z}_i^\top \mathbf{Z}_j - \mathbb{E}[\mathbf{Z}_i^\top \mathbf{Z}_j] \big| \le \sqrt{ \frac{\sigma^2_{\max}(\mathbf{W}^\top \mathbf{W}) \log(2N^2/\delta)}{2D^2 \|\mathbf{x}^2 \|_{\psi_1}} } \end{equation} where $D =\min_i \mathbf{D}_{ii} $ and sub-exponential norms $\| \mathbf{x}^2 \|_{\psi_1} = \min_i \| \mathbf{x}_{i,d}^2 \|_{\psi_1}$ for $d \in [1,F]$. \end{thm} By above theorem, we demonstrate that inner product of hidden representations approximates to its expectation with a high probability. Furthermore, suppose that the expected homophily over distribution of graph feature and label, i.e., $y \sim P({y_i}), \mathbf{x} \sim P_y(\mathbf{x})$, through similarity selection satisfies $\mathbb{E} [h_{edge}(\mathcal{\hat G})] = 1 - \bar \phi$. Here $\bar \phi = \mathbb{E}_{y \sim P({y_i}), \mathbf{x} \sim P_y(\mathbf{x})}[y_i \neq y_j]$. Then combining with Lemma~\ref{lem:equiv} and Theorem~\ref{thm:homo_sim}, we can now provide a theoretical guarantee for \textsc{AF-GCL}: \begin{thm} \label{thm:gcl_bound} Let $f^{*}_{\mathrm{gcl}} \in \arg \min _{f: \mathcal{X} \rightarrow \mathbb{R}^{K}}$ be a minimizer of the GCL loss, $\mathcal{L}_{\mathrm{gcl}}$. Then there exists a linear classifier $\mathbf{B}^{*} \in \mathbb{R}^{c \times K}$ with norm $\left\|\mathbf{B}^{*}\right\|_{F} \leq 1 /\left(1-\lambda_{K}\right)$ such that, with a probability at least $1-\delta$ \begin{equation} \begin{small} \begin{aligned} \mathbb{E}_{v_i} \left[ \left\| \vec{y}_i-\mathbf{B}^{*} f_{\mathrm{gcl}}^{*}(v)\right\|_{2}^{2} \right] \leq \frac{\bar \phi }{\hat{\lambda}_{K+1}} + \sqrt{ \frac{\sigma^2_{\max}(\mathbf{W}^\top \mathbf{W}) \log(2N^2/\delta)}{2D^2 \|\mathbf{x}^2 \|_{\psi_1}\hat{\lambda}^2_{K+1}} }, \end{aligned} \end{small} \end{equation} $\hat{\lambda}_{i}$ are the $i$ smallest eigenvalues of the symmetrically normalized Laplacian matrix of the transformed graph. \end{thm} \textbf{Interpreting the bound.} The above theorem implies that if the transformed graph has a larger homophily degree (smaller ${\bar \phi}$), the bound of the prediction error will be lower. In other words, if the percentage of two nodes in positive pairs belonging to the same class is higher, the pre-trained GNN model tends to have better performance. Besides, the theorem reveals a trend that with the increase of hidden representation dimension $K$, a lower bound will be obtained.
{'timestamp': '2022-04-12T02:32:49', 'yymm': '2204', 'arxiv_id': '2204.04874', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04874'}
arxiv
\section{Method} \begin{figure*} \centering \includegraphics[width=\textwidth]{imgs/intro.pdf} \caption{ Comparison of GESMR against a fixed MR GA and SAMR. Fixed MR GA only evolves the solution with a given MR. SAMR evolves pairs of solutions and MRs. GESMR co-evolves a population of solutions and a population of MRs separately. Each MR is assigned a group and the MRs are evolved using the best function value gain in the MR's corresponding group. } \label{fig:viz_algo} \end{figure*} \label{sec:method} This section first provides the formal problem definition, a discussion of the general class of genetic algorithms, and then briefly describes a previous adaptive mutation rate (MR) method and its associated vanishing MR problem. Finally this section proposes the Group Elite Selection of Mutation Rates (GESMR) algorithm that addresses this problem with better performance and almost no \linebreak extra overhead. \subsection{Problem Formulation} \label{sec:formulation} Consider the general optimization problem where the goal is to find the best decision variable $x^* \in \mathbb{R}^d$ that minimizes a target function $f$ (e.g. the negative fitness function in the genetic algorithm literature). The objective is therefore \begin{equation} \argmin_{x \in \mathbb{R}^d} f(x). \label{eq:objective} \end{equation} \subsection{Genetic Algorithms and the Mutation Rate} A genetic algorithm (GA) evolves a population of $N+1$ candidate solutions/individuals $x_0, \dots, x_N$ over time that progressively minimize the objective in Eq.~\ref{eq:objective}. At each evolution time step $t$, the current population is $\{x^{(t)}_i\}_{i=0}^{N}$. To produce the next generation, a GA consists of 1) selection of individuals, 2) mutation of individuals, and 3) crossover of individuals. The common truncation selection method with one elite is used in this paper. Truncation selection creates a new set of $N+1$ solutions by keeping the single best ``elite" solution from the population (known as \emph{elitism}) and uniformly sampling the rest of the $N$ solutions from the top $\eta_x$ portion of the population with replacement (better solution has lower $f(x)$ value) \cite{Such2017-rn}. Since it is a common way to mutate a continuous genotype $x$ \cite{Such2017-rn}, the Gaussian mutation operator $M: \mathbb{R}^d \rightarrow \mathbb{R}^d$ is used, which produces $x'$ with \begin{equation} x' \sim M(x; \sigma) \triangleq x + \sigma \epsilon, ~~\text{and}~~ \epsilon \sim \mathcal{N}(0, I). \end{equation} where $\mathcal{N}(0, I)$ denotes a standard multi-variate normal distribution in $\mathbb{R}^d$. $\sigma \in \mathbb{R}_{\geq0}$ represents the \textbf{mutation rate} (MR), which constrains how different $x'$ could be from $x$. Crossover is used to mix information between solutions, essentially allowing traits to be transferred to another solution. For the sake of simplicity and to isolate the mutation operator, which is the main focus of this work, no crossover operator is used since crossover is not a necessary mechanism in GAs \cite{Such2017-rn}. For conventional GA algorithms, a fixed MR is chosen a priori based on the user's preference or prior knowledge. Clearly, a too small $\sigma$ will slow down evolution and a too large $\sigma$ will tend towards random search, a tuned $\sigma$ is needed. It has also been shown that the optimal $\sigma$ changes over the course of evolution, e.g. a small $\sigma$ is often needed to ``fine tune" the solutions at the end of evolution \cite{Cervantes2009-me}. As a result, the adaptive MR field studies how to dynamically adapt this $\sigma$ for faster learning and better convergence. Among previous adaptive MR methods, a well-known and commonly used method is the self-adaptation of MR (SAMR) \cite{Kramer2010-ia, Aleti2016-wn, Back1992-al, Gomez2004-sh, Thierens2002-dq}. This method attaches to each solution $x_i$ its own MR, $\sigma_i$. These pairs $\{(x_i, \sigma_i)\}$ are then evolved, by selection on the pairs and mutating the $x_i$ using $\sigma_i$ and mutating $\sigma_i$ using an external fixed meta MR $\tau$. In practice, a well-known drawback of SAMR is that the MRs produced could prematurely converge to zero over time \cite{Rudolph2001-zf, Clune2008-lh, Glickman2000-mr}, which is referred to here as the \textbf{vanishing mutation rate problem} (VMRP). One might try to simply clip the MR to a lower bound, but a single lower bound that maintains exploration early on while still allowing for fine tuning later may not exist \cite{Cervantes2009-me}. Therefore, there exists a need for a better adaptive MR strategy. \subsection{Group Elite Selection of Mutation Rates} \label{sec:algorithm} \input{content/algo_box_mat} This section presents Group Elite Selection of Mutation Rates (GESMR), to adapt MRs on the fly, along with empirical evidence that GESMR mitigates the VMRP and outperforms previous adaptive MR methods. For visualization of GESMR, refer to Fig.~\ref{fig:viz_algo}. GESMR keeps a set of $K$ positive scalar MRs $\{\sigma_k\}_{k=1}^K$, where $N \equiv 0 \pmod{K}$, and co-evolves them with the $N+1$ candidate solutions, so that the $\sigma$s do not decay to zero. At each optimization step $t$, the current population, $\{x_i^{(t)}\}_{i=0}^N$ is first sorted in ascending order of $f(x_i^{(t)})$, giving $\{\hat{x}_i^{(t)}\}_{i=0}^N$. Truncation selection with one elite is applied to get the next generation parents, $\{\tilde{x}_i^{(t)}\}_{i=0}^N$, with \begin{equation} \tilde{x}_i^{(t)} = \begin{cases} \hat{x}_0^{(t)} \qquad &i=0\\ \sim \mathcal{U}\{\hat{x}_0^{(t)}, \dots, \hat{x}_{m-1}^{(t)}\} \qquad &i=1,\dots,N \end{cases} \label{eq:select_solutions} \end{equation} and $m=\eta_xN$ (number of solutions for parent selection). Then, the \emph{non-elite} solutions, $\{\tilde{x}_1^{(t)}\}_{i=1}^N$ are split into $K$ groups of equal size (i.e. each group has $N/K$ solutions) and each group is assigned a different $\sigma_k$. Without loss of generality, $\sigma_k$ corresponds to $\{\tilde{x}^{(t)}_{(k-1)N/K+1}, \dots, \{\tilde{x}^{(t)}_{kN/K}\}$. To form the next generation, each $\tilde{x}^{(t)}_i$ is then mutated according to its corresponding $\sigma_k$, while the elite is unaltered: \begin{equation} x^{(t+1)}_i = \begin{cases} \tilde{x}^{(t)}_0 \qquad &i=0 \\ \sim M(\tilde{x}^{(t)}_i; \sigma_{\floor{iK/N}})\qquad &i = 1, \dots, N \end{cases} \label{eq:mutate_solutions} \end{equation} After the next generation of $\{x^{(t+1)}_i\}_{i=0}^N$ are found, GESMR \linebreak evolves the MRs, $\{\sigma_k\}_{k=1}^K$ using another separate but similar GA with one elite, truncation selection, and a different mutation operator. For each $\sigma_k$, its negative fitness is calculated by considering the \emph{best} change in function value it has produced: \begin{equation} \Delta_k^{(t)}\triangleq\Delta(\sigma_k^{(t)}) = \min_{i=(k-1)N/K+1}^{kN/K} \big(f(x^{(t+1)}_i) - f(\tilde{x}^{(t)}_i)\big). \label{eq:delta_algo} \end{equation} First the MR population is sorted by this $\Delta_k^{(t)}$, producing $\{ \hat{\sigma}_{k=1}^K \}$. Truncation selection with one elite is applied to get the next generation parent MRs $\{ \sigma_k \}_{k=1}^K$ with \begin{equation} \tilde{\sigma}_k^{(t)} = \begin{cases} \hat{\sigma}_1^{(t)} \qquad &k=1\\ \sim \mathcal{U}\{\hat{\sigma}_1^{(t)}, \dots, \hat{\sigma}_l^{(t)}\} \qquad &k=2,\dots,K \end{cases} \label{eq:select_mrs} \end{equation} and $l = \eta_\sigma K$ (number of MRs for parent selection). The mutation operator associated with the $\sigma$s is $$\sigma' \sim M_\sigma(\sigma;\tau) \triangleq \sigma \tau^{\epsilon} ~~\text{and}~~ \epsilon\sim\mathcal{U}(-1, 1)$$ where $\mathcal{U}(-1, 1)$ represents a continuous uniform distribution on $\mathbb{R}$ and $\tau$ represents a fixed meta mutation rate. The next generation of MRs is produced by mutating the parent MRs, while the elite parent is unaltered: \begin{equation} \sigma^{(t+1)}_i = \begin{cases} \tilde{\sigma}^{(t)}_1 \qquad &i=1 \\ \sim M_\sigma(\tilde{\sigma}^{(t)}_i; \tau)\qquad &i = 2, \dots, K \end{cases} \label{eq:mutate_mrs} \end{equation} One full step of GESMR is described in Alg.~\ref{alg:algo}. The performance of GESMR depends on the number of groups, $K$. When $K=1$, GESMR recovers the fixed-MR method. When $K=N$, each solution aside from the elite is assigned a different MR, a method reminiscent of the SAMR method. The experiment section shows that in practice the optimal $K$ lies between $1$ and $N$, and uncovers a heuristic on how to choose such a $K$. \section{Introduction} Biological evolution has produced an incredible diversity of life that is seen everywhere. In this process, the solutions and the \linebreak mechanisms co-evolve end-to-end, including the mutation rate \linebreak \cite[MR;][]{Metzgar2000-ji}. Self-adaptation of MRs (SAMR) is a technique common in the literature of genetic algorithms (GA) that encapsulates this idea of end-to-end evolution of the MR along with the individuals \cite{Meyer-Nieberg2007-nz,Back1992-al,Smith1996-cg,Dang2016-fp}. The idea is to assign each individual its own MR, creating a pair. The pairs are then evolved end-to-end using the assigned MR for mutating the individual and a ``meta" MR for mutating the assigned MR. However, this approach often runs into the problem that the MRs produced decay to zero, causing evolution to stop at a sub-optimal value. If instead the MR were fixed at some moderate value, evolution would continue and find a better function value \cite{Clune2008-lh, Rudolph2001-zf,Glickman2000-mr}. This premature convergence can be attributed to the fact that most mutations hurt the fitness of an individual \cite{Clune2008-lh}, and thus an effective way for an individual to preserve its fitness into the next generation is to have no mutation. Thus, SAMR ignores the long-term goal of evolution to explore the fitness landscape and find better solutions in future generations \cite{Clune2008-lh}. To counteract this effect, this paper proposes a novel GA based on supportive co-evolution \cite{Goldman2012-hc} of solutions and MRs, entitled \linebreak Group Elite Selection of Mutation Rates (GESMR). After assigning each MR to a group of solutions, the solutions are evolved using that MR, and the MRs are evolved according to the \emph{best} change in function value from the MR's solution group, defined as the ``group elite". By targeting the MR that produces the \emph{best} change in function value, given many mutation samples, GESMR can mitigate the vanishing MR problem. Additionally, GESMR is straightforward to implement and requires no more function evaluations than a fixed MR GA, and thus can be applied to a wide range of GA problems. In prior work, a related approach using the idea of group elites was formulated as a multi-armed bandit problem and applied to entire genetic operators in an ad-hoc manner \cite{Fialho2008-ud, Whitacre2009-uv}. In contrast, this paper demonstrates that the approach is most effective when focused on MRs, and it also makes it possible to understand this result both empirically and theoretically. Evaluation of GESMR is performed on common benchmark test optimization problems from the GA literature. To show that the method scales well to harder problems, it is also evaluated on neuroevolution for image classification in the MNIST/Fashion-MNIST domain and on reinforcement learning for control in the CartPole, Pendulum, Acrobot, and MountainCar domains. For comparison, results of several adaptive MR algorithms including an oracle optimal fixed MR, an oracle look-ahead MR (that uses foresight to determine MR), self-adaptive MR, the multi-armed bandit method \cite{Fialho2008-ud}, and some common heuristic methods \cite{Rechenberg1978-np} are also reported. GESMR outperforms other algorithms in most tasks. Even when SAMR prematurely converges, like in problems with especially \linebreak rugged fitness landscapes \cite{Clune2008-lh}, GESMR does not. As a matter of fact, GESMR performs as well as the oracle look-ahead MR in function value and even matches the MR to the empirically estimated \emph{long-term optimal MR}. To explain why, the statistical distribution of the change in function value for a spectrum of MRs for different function landscapes is empirically analyzed and visualized. This analysis shows that SAMR is minimizing an MR objective whose optimal MR is zero in rugged landscapes, while GESMR is minimizing an objective whose optimal MR is nonzero. \section{Conclusion} In this paper, a novel and simple adaptive mutation rate (MR) \linebreak method, group elite selection mutation rate (GESMR), was proposed to mitigate the vanishing mutation rate problem (VMRP), along with empirical analysis that grounds its success over self-adaptation of mutation rates (SAMR). Comprehensive experiment results showed that GESMR outperforms previous adaptive MR methods in final value and convergence speed. GESMR also consistently matches its MRs to the empirically estimated long-term optimal MR. Thus, this work provides the next step in designing self-adaptive machine learning algorithms. \section{Experiment} The experiments in this section are designed to answer the following questions: \begin{enumerate} \item How does GESMR compare to other methods in terms of the quality of function values found and how quickly it converges to those values? \item Does SAMR suffer from the Vanishing Mutation Rate Problem (VMRP)? Does GESMR solve this problem, and can it produce MRs that are optimal in a long-term sense? \item What parts of GESMR are vital to its success? \item Why is GESMR more successful than SAMR? \item What is the optimal group size in GESMR and how much does this parameter matter? \item Does GESMR generalize to the high-dimensional loss landscapes of neuroevolution? \item Does GESMR generalize to neuroevolution for reinforcement learning control tasks? \end{enumerate} \subsection{Comparison Algorithms} For comparison, the following MR selection and adaptation algorithms are evaluated in various optimization problems: \begin{itemize} \item \textsuperscript{\textdagger}\textbf{OFMR}: Optimal fixed MR found with a grid search; \item \textsuperscript{\textdagger}\textbf{LAMR-$G$}: MR determined at every $G$ generations by \linebreak ``looking ahead," that is, by running a grid search multiple times and picking the MR that produces the best elite in another evolution run (initialized with the current population and run for $G$ generations); \item \textbf{FMR}: A fixed MR of $\sigma=0.01$; \item \textbf{1CMR} A fixed MR of $\sigma = 1/d$ \cite{Ochoa2002-ni}; \item \textbf{15MR}: MR is doubled if the percentage of beneficial mutations is above 1/5 in the current generation and cut in half if not \cite{Rechenberg1978-np}; \item \textbf{UCB/$R$}: The adaptive MR method proposed by \citet{Fialho2008-ud}, implemented with a multi-armed bandit with $R$ arms (each corresponding to a different MR), and sampling an arm every generation using the upper confidence bound algorithm \cite{Fialho2008-ud}; \item \textbf{SAMR}: Self-adaptation of MR, where each solution is assigned its own MR and evolved end-to-end; \item \textbf{GESMR}: The method of Algorithm~\ref{alg:algo}; \item \textbf{GESMR-AVG}: The method of Algorithm~\ref{alg:algo} with the min in Eq.~\ref{eq:delta_algo} replaced with the mean; \item \textbf{GESMR-FIX}: The method of Algorithm~\ref{alg:algo} with the MRs fixed to the initial population and not evolved further. \end{itemize} Details for the parameters of these algorithms are provided in Appendix~A. The \textdagger represents that the algorithm is an oracle using foresight (looking ahead of the current evolution step) to determine the MR and should not be compared against directly. Note that \textbf{LAMR-$G$} specifically uses foresight to determine the best MR for the next $G$ generations. With sufficiently large $G$, its MRs thus serve as an empirical estimate of the optimal long-term MRs at any point during evolution. \subsection{Test Optimization Functions} All algorithms are evaluated on common test functions: Ackley, Griewank, Rastrigin, Rosenbrock, Sphere, and Linear \cite{Surjanovic2013-fl}. Definitions of these test functions are provided in Appendix~B.1. Each function is evaluated for dimension $d\in\{2, 10, 100, 1000\}$, with the initial population sampled from $\mathcal{N}(\mathbf{0}, \mathbf{I})$ and $\mathcal{N}(\mathbf{0}, 10^2\mathbf{I})$ (referenced in table as std with values 1 and 10). These functions were chosen because they are common in the GA literature and they span a diverse range of ruggedness for function landscapes \cite{Malan2009-jz}. All results are averaged over five seeds. Fig.~\ref{fig:fits_mrs_test} shows selected runs from this experiment, displaying the elite function value and the average MR over generations. The full list of final elite function values are reported in Table~1 in Appendix~B.2, serving as a statistic on how good the final solution is. The full list of average elite function values over all evolution iterations are reported in Table~2 in Appendix~B.2, serving as a statistic on how quickly the algorithm converges to a good solution. Mean squared error between the log MR of an algorithm and the log MR of LAMR-100 (averaged over generations) are reported in Table~3 in Appendix~B.2, serving as a statistic on how close to optimal the MRs are. Additionally, all of the tables bold the statistically significant results which are computed by a t-test. \begin{figure} \centering \includegraphics[width=\columnwidth]{imgs/fits_mrs_test.png} \caption{ Elite function value and average mutation rate (MR) over generations of evolution by different adaptive MR methods, applied to four test optimization problems. Notice GESMR outperforms other methods in function value and is able to match its MR to the one from LAMR-$100$. } \label{fig:fits_mrs_test} \end{figure} To answer Question 1, GESMR outperforms other methods, excluding the oracles, in almost all domains both in terms of the final function value and in terms of quickness of convergence to good values. To answer Question 2, SAMR only succeeds and matches the performance of LAMR when the function landscape is relatively non-rugged, like in the Rosenbrock and Sphere functions. In the rugged functions, SAMR consistently produces MRs that are sub-optimal and smaller than those produced by even OFMR, and thus also lags behind in elite function value during evolution. Thus, SAMR struggles with the VMRP, as shown in previous work \cite{Rudolph2001-zf, Clune2008-lh, Meyer-Nieberg2007-nz}. However, GESMR overcomes this phenomenon and surprisingly consistently \emph{matches its average MR to the long-term optimal MR} produced by LAMR-$100$ (i.e.\ red and black lines match in Fig.~\ref{fig:fits_mrs_test}, and GESMR has consistently the lowest error in Table~3 in Appendix~B.2). The limitations of of all methods except 15MR, SAMR, and \linebreak GESMR can be seen in the linear test function. The optimal MR for this case is $\sigma\to\infty$, but other methods are unable to approximate this result because they limit themselves to an upper bound (ex. UCB-$R$ is limited by the largest MR in its arms). On the other hand, GESMR quickly keeps scaling up the MR until reaching a very large MR. GESMR is also arbitrarily precise, fine tuning MRs with an evolutionary process. In contrast, UCB-$R$ and the grid search methods constrain the MRs to a quantized range. To answer Question 3, GESMR-AVG and GESMR-FIX were run as an ablation of GESMR, with the results shown in Fig.~\ref{fig:fits_mrs_test} and Tables~1,~2,~3 in Appendix~B.2. GESMR outperforms both of them, suggesting that the use of the best mutation statistic and the evolution of MRs are both vital to its success. \subsection{Empirical Analysis of GESMR vs. SAMR} \label{sec:empiricalanalysis} To answer Question 4, two objectives for $\sigma$ are defined based on a change of function value, and these objectives are shown to be related to the GESMR-AVG, GESMR, and SAMR methods. These objectives are then analyzed empirically (in this section) and theoretically (in Section~\ref{sec:theoreticalanalysis} to explain the behavior of the algorithms. Consider the \textbf{change in function value} of a mutation given a solution and an MR: \begin{equation} \Delta(x, \sigma) \sim f(M(x;\sigma)) - f(x). \label{eq:delta_analysis} \end{equation} For simplicity, this variable will be denoted as $\Delta$. Let $\akset{\Delta_q}_{q=1}^{N/K}$ represent independently and identically distributed instances of $\Delta$ where $q$ indexes an individual within its group. To minimize $f(x)$ in evolution, a $\sigma$ must be chosen to minimize $\Delta(x,\sigma)$ in some capacity (denoted as an ``MR objective"). Consider two MR objectives \begin{itemize} \item \textbf{mean objective}, $\sigma^*_\mu = \argmin_\sigma \EX_{x,\epsilon}[\Delta(x,\sigma)]$ and \item \textbf{outlier objective}, $\sigma^*_\text{min} = \argmin_\sigma \EX_{x,\epsilon}[\min_q \Delta_q(x,\sigma)]$. \end{itemize} The expectations in the objectives are over $x$ sampled from the current population and the noise in the mutation operator, $\epsilon$. For simplicity, these objectives are denoted as $\argmin_\sigma \EX[\Delta]$ and \linebreak $\argmin_\sigma \EX[\min_q\Delta_q]$, respectively. The mean objective \linebreak corresponds to the algorithm GESMR-AVG, which selects $\sigma$s directly to minimize a sample average of $\Delta$. The outlier objective corresponds to the algorithm GESMR, which selects $\sigma$s directly to minimize the \emph{best} (lowest-value) sample of $\akset{\Delta_q}$. SAMR does not select $\sigma$s directly, but rather selects $(x_i, \sigma_i)$ pairs to minimize $f(x_i)$. However, because $x_i$ is produced using the parent of $\sigma_i$, SAMR also selects pairs $(x_i,\sigma_i)$ indirectly based on $\sigma_i$s that produce non-deleterious mutations over generations consistently. This mechanism is intuitively associated with the mean objective. \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{imgs/landscape_mut.png} \caption{ Visualization of mutations and the distribution of the change in function value from the mutations, $\Delta(x, \sigma)$ (defined in Eq.~\ref{eq:delta_analysis}), for nine labeled mutation rates, $\sigma$, at one point, $x$, on the 2-D Ackley function. The left plots show an image representation of the 2-D function landscape where lighter colors are higher values and annotates the original solution and some mutated solutions. The right plots show the empirical histogram of $\Delta(x, \sigma)$ and annotates the mean and minimum samples of this histogram. Only moderate $\sigma$s are able to mutate to the global minimum. } \label{fig:landscape_mut} \end{figure} \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{imgs/curve_template.png} \caption{ A representation of $\sigma$ versus $\Delta(x,\sigma)$ (defined in Eq.~\ref{eq:delta_analysis}) colored by the empirical probability density function, $p_{\Delta} (\delta; \sigma)$ and the respective log distribution for the 2-D Ackley function. Many samples of $\Delta(x,\sigma)$ are generated from $x\sim\mathcal{N}(0, I)$, and a logarithmic range of $\sigma$s, and put into bins of a $\sigma$-$\Delta$ grid, colored by the number of samples the bin has. Annotated are the $\sigma$ versus $\EX[\Delta; \sigma]$ (mean of $\Delta$s) and $\EX[\min_q\Delta_q; \sigma]$ (min of $\Delta$s) curves, and the $\sigma$s that minimize them. Importantly, notice that $\sigma^*_\mu=0$ and $\sigma^*_\text{min}>0$. } \label{fig:curve_template} \end{figure} To analyze general function landscapes outside of evolution, $x$ is either fixed to a point or sampled from a distribution, and many more samples for $\akset{\Delta_q}$ are used. Fig.~\ref{fig:landscape_mut} shows a histogram of samples from $\Delta$ and visualizes their respective mutations across values of $\sigma$ for a single $x$ in the Ackley 2-D function, highlighting that the best mutation comes from a $\sigma$ that is not too small and not too large. Fig.~\ref{fig:curve_template} represents this same information, but sampling $x\sim \mathcal{N}(0,I)$, for a continuous range of $\sigma$ as a visualization of the probability density function (PDF), $p_{\Delta}(\delta; \sigma)$. The sigma versus the mean objective and the outlier objective curves as well as their optimal $\sigma$ solutions, $\sigma^*_\mu$ and $\sigma^*_\text{min}$ are shown over the PDF. Fig.~\ref{fig:curves} displays this same plot for several other test optimization problems. \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{imgs/curves.png} \caption{ A representation of the $\sigma$ versus $\Delta(x,\sigma)$(defined in Eq.~\ref{eq:delta_analysis}) colored by the empirical probability density function $p_{\Delta} (\delta; \sigma)$, and the respective log distribution for several different test optimization functions of different dimensionality. Many samples of $\Delta(x,\sigma)$ are generated from $x\sim\mathcal{N}(0, I)$ and a logarithmic range of $\sigma$s and put into bins of a $\sigma$ versus $\Delta$ 2-D grid, colored by the number of samples the bin has. Annotated are the $\sigma$ versus $\EX[\Delta; \sigma]$ (mean of $\Delta$s), $\EX[\min_q\Delta_q; \sigma]$ (min of $\Delta$s), and $\EX[\max_q\Delta_q; \sigma]$ (max of $\Delta$s) curves, and the optimal $\sigma$ that minimizes the first two curves. All curves show that $\sigma^*_\mu\to 0$ and $\sigma^*_\text{min}>0$. } \label{fig:curves} \end{figure} As Fig.~\ref{fig:curves} shows $\EX[\Delta]$ often increases monotonically with $\sigma$. As a result, the optimal MR tends to go to zero, i.e. $\sigma^*_\mu \to 0$. Interestingly, $\EX[\min_q\Delta_q]$ is zero for $\sigma=0$, and \emph{decreases} monotonically as $\sigma$ increases until $\sigma=\sigma^*_\text{min}$, and then increases monotonically with $\sigma$, leading to $\sigma^*_\text{min} \not\to 0$. These behaviors hold true for all landscapes tested, except for the non-rugged linear landscape. These results answer Question~4 by showing empirically that GESMR targets higher MRs than SAMR in many problems, demonstrating that it has the capacity to mitigate the VMRP. Theoretical analysis of GESMR and SAMR further grounds this empirical finding to prove that GESMR will always avoid a fully vanishing MR. \subsection{Theoretical Analysis of GESMR vs. SAMR} \label{sec:theoreticalanalysis} In this section, the behavior of the mean and outlier MR objectives are analyzed as $\sigma\to0$ and $\sigma\to \infty$ \textit{during} evolution. The current population of $x$ is assumed to be already \textit{partially} optimized, i.e., better than those of random search (which is the initialization). Partial optimization also means that the evolution has not yet converged, and thus the gradient of the function at the solutions, $\nabla f(x)$, is nonzero. Assume $\sigma\to\infty$, fully and randomly exploring the solution space without exploiting the current solutions. Then, \linebreak $\EX[\Delta]=\EX_{x'}[f(x')]-\EX_x[f(x)]$ (first expectation is over all mutants, $x'$) becomes a constant only based on the function landscape and the distribution of $x$. $\EX[\min_q\Delta_q]$ becomes, by definition, random search of the function landscape. Since $x$ is already partially optimized, random search must yield a strictly worse expected solution than $x$. So, $\EX[\Delta] > \EX[\min_q\Delta_q] > 0$, and thus \emph{both MR objectives are positive}. Assume $\sigma=0$ (i.e. no mutation), fully exploiting the current solution without exploring the solution space. Then, \emph{both MR objectives vanish} as $\EX[\Delta] = \EX[\min_q\Delta_q] = 0$. The most interesting case is when $\sigma$ is small but not zero, i.e.\ $0<\sigma<\sigma_c$. For a sufficiently small $\sigma_c$ the function landscape can be approximated as linear with $f(M(x;\sigma)) \approx f(x)+\sigma\epsilon^T\nabla f(x)$. Then, $\Delta(x,\sigma) = f(M(x;\sigma))-f(x)= \sigma\epsilon^T\nabla f(x)$. Since $\epsilon \sim \mathcal{N}(0, I)$, it follows that $\Delta(x,\sigma) \sim \mathcal{N}(0, \sigma^2\Vert\nabla f(x)\Vert^2)$, which leads to $\EX[\Delta]=0$. A further useful constraint is provided by Theorem~\ref{the:mingaus}: \begin{theorem} \label{the:mingaus} Let $Z_\sigma^{(1)},\dots, Z_\sigma^{(q)} \sim \text{iid } \mathcal{N}(0,\sigma^2)$.\\ \hspace*{3ex}\text{If~} $Y_\sigma = \min(Z_\sigma^{(1)},\dots, Z_\sigma^{(q)})$, \text{then} $\EX[Y_\sigma] = \sigma \EX[Y_{\sigma=1}]$ \text{with}\\ \hspace*{3ex}$\EX[Y_{\sigma=1}]<0$. \end{theorem} \begin{proof} By definition, $f_z(z) = \phi(z/\sigma)$ and $F_z(z) = \Phi(z/\sigma)$. Then,\\[-3.5ex] \begin{align*} P(Y_\sigma\leq y) = 1-P(Y_\sigma\geq y) &= 1-P(Z_\sigma^{(1)}\geq y, \dots, Z_\sigma^{(q)}\geq y)\\ &=1-(1-\Phi(y/\sigma))^q\\ f_{Y_\sigma}(y)&=\frac{1}{\sigma}q(1-\Phi(y/\sigma))^{q-1}\phi(y/\sigma)\\ \EX[Y_\sigma]&=\int_y \frac{y}{\sigma}q(1-\Phi(y/\sigma))^{q-1}\phi(y/\sigma)\\ &=\sigma \int_y y q(1-\Phi(y))^{q-1}\phi(y)\\ &=\sigma \EX[Y_{\sigma=1}]. \end{align*} {\indent In addition, $\EX[Y_{\sigma=1}]<0$ because $Y_{\sigma=1}$ is the minimum of $q>1$} {\indent zero-mean standard normal random variables.} \qedhere \end{proof} \noindent By Theorem~\ref{the:mingaus}, $\EX[\min_q\Delta_q]\propto \sigma \Vert\nabla f(x)\Vert <0$. Thus, in this range of $\sigma$, \emph{the outlier objective \textit{decreases} linearly as $\sigma$ increases, while the mean objective still vanishes}. Using these three cases, consider the MR objectives as $\sigma$ varies from $0$ to $\infty$. $\EX[\Delta]$ starts at $0$ and takes a theoretically unknown (but empirically monotonic) path to a positive value. $\EX[\min_q\Delta_q]$ starts at $0$, \textit{decreases} to below $0$ until a certain $\sigma_c$, then takes a theoretically unknown (but empirically monotonic) path to a positive value. This theoretical analysis guarantees that $\sigma^*_\text{min}>0$, a condition that cannot be put on $\sigma^*_\mu$. Thus, this section and Section~\ref{sec:empiricalanalysis} empirically and theoretically answer Question~4, i.e.\ explain \emph{why} GESMR-AVG and SAMR often suffer from the VMRP in rugged landscapes, and \emph{how} GESMR overcomes this limitation. In short, GESMR-AVG and SAMR assume that $\sigma$ produce non-deleterious mutations consistently, whereas most mutations are actually deleterious \cite{Clune2008-lh}. This condition is possible only if $\sigma\to 0$, which GESMR incorporates into the algorithm itself. \subsection{Ablation on the Group Size Parameter} To answer Question 5, and to evaluate the optimal number of \linebreak groups, $K$, evolution was run on the Ackley, Griewank, Rosenbrock, and Sphere functions with $d=100$ and $K$ equal to all factors of $N$ for various values of $N$. It turns out that if the number of groups is too small, i.e. $K\to 1$, or too big, i.e. $K\to N$, the performance drops very fast (Fig.~\ref{fig:group_size}). In general, $K=\sqrt{N}$ is a reasonable value, but as $N\to\infty$, the optimal $K\to N^{3/4}$. This finding suggests that the number-of-groups hyperparameter can be set according to $N$ and does not need tuning. \begin{figure} \centering \includegraphics[width=\columnwidth]{imgs/group_size.png} \caption{ Elite final function value of GESMR versus the number of groups, $K$, as the population size, $N$ increases in the Ackley 100-D function. As $N\to\infty$, the optimal $K\to N^{3/4}$, suggesting $K$ does not need tuning. } \label{fig:group_size} \end{figure} \subsection{Neuroevolution for Image Classification} \begin{figure} \centering \includegraphics[width=\columnwidth]{imgs/fits_mrs_mnist.png} \caption{ Elite function value and average mutation rate (for different mutation rate control strategies) versus generations of neuroevolution applied to image classification in MNIST and Fashion-MNIST. GESMR outperforms most methods except 15MR, which appears to be an especially good fit for this problem. } \label{fig:fits_mrs_mnist} \end{figure} To answer Question 6, the algorithms were run on the high dimensional loss landscapes of neuroevolution for image classification with the common MNIST and Fashion-MNIST datasets \cite{LeCun1998-wt, Xiao2017-kj}. The details of the datasets, the NN architecture evolved, and the experimental setup are provided in Appendix~C. Each algorithm was run independently five times and the mean loss and the standard error measured. GESMR outperforms all other methods, including FMR and \linebreak SAMR, but does not beat 15MR (Fig.~\ref{fig:fits_mrs_mnist}). Presumably, 15MR's hyperparameter of 1/5 is especially suited to the MNIST loss landscapes but might have trouble generalizing to other problems, like the test optimization problems and the reinforcement learning control problems. \subsection{Neuroevolution for Reinforcement Learning} Reinforcement learning (RL) tasks are amenable to the neuroevolution approach because the approach tolerates long time-horizon rewards well \cite{Salimans2017-ji, Such2017-rn}. To answer Question 7, the algorithms were evaluated on four common RL control tasks: CartPole, Pendulum, Acrobot, and MountainCar \cite{Brockman2016-bx}. In all these tasks, a controller maps the robot's input observations to either continuous or discrete actions to maximize a cumulative reward. The details of these environments, the neural architecture evolved, and the experimental setup are provided in the Appendix~D. Each algorithm was run independently five times and the mean and standard error of performance was measured. The results are shown in Fig.~\ref{fig:fits_mrs_rl} in the Appendix~D. GESMR generally outperformed other methods including the baseline fixed MR and SAMR. Presumably, GESMR fails in MountainCar because the reward signal is very sparse (zero rewards provide no way to appropriately select for MRs). \subsection{Comparison against CMA-ES} CMA-ES is not a pure adaptive MR GA method: It stores a covariance matrix to control the spread of the population, rather than storing a single MR \cite{Hansen2016-qa}. This matrix grows quadratically with the solution vector length. However, CMA-ES still provides an interesting comparison given a fixed computational budget. Fig.~\ref{fig:gesmr_vs_cmaes} shows that GESMR outperforms CMA-ES significantly in four of the most challenging test optimization problems, even \linebreak though CMA-ES uses much more memory (quadratic in the solution space). Thus, not only does GESMR scale to higher dimensional problems, it also outperforms CMA-ES when both are given the same running time. \begin{figure} \centering \includegraphics[width=\columnwidth]{imgs/rebuttal.png} \caption{ Elite final function values of GESMR and CMA-ES on four challenging problems in the 100-D solution space with a fixed computational budget. Whereas CMA-ES is only able to complete 50 generations, GESMR is completes approximately 1000, resulting in an order of magnitude better values. } \label{fig:gesmr_vs_cmaes} \end{figure} \section{Related Work} Research on mutation rates (MRs) is one of the most studied sub-fields of genetic algorithms \cite{Aleti2016-wn, Eiben1999-ez, Karafotias2015-cr, Kramer2010-ia, Hassanat2019-iz, Back1996-tv}. \paragraph{Fixed MRs:} Lots of theoretical and empirical work has been done on finding the optimal fixed MR for specific problems \cite{Greenwell1995-kx, Bottcher2010-xw}, finding heuristics like the MR should be proportional to $1/L$ where $L$ is the length of the genotype \cite{Ochoa2002-ni, Doerr2019-ol}. Evolutionary bilevel optimization tries to find the optimal evolutionary parameters, including MR, by running an inner evolution with an outer loop searching over parameters \cite{Sinha2018-rd, Liang2015-dg}. However, it is commonly known that the optimal MR is constantly changing during evolution \cite{Patnaik1986-qb}. \paragraph{Deterministic MRs:} Deterministic MRs are common but these are ad hoc functions to change the MR as a function of the number of generations, and may not generalize to unseen problems with different landscapes \cite{Aleti2016-wn}. \paragraph{Adaptive MRs:} Adaptive MRs are also common \cite{Thierens2002-dq, Srinivas1994-by, Patnaik1986-qb, Doerr2019-ol, Sewell2006-gp} but these rely on another ad hoc system to determine how to alter the MR given feedback from the evolution. A common technique is to maintain a MR that produces mutations of which only one-fifth are beneficial \cite{Karafotias2015-cr, Rechenberg1978-np}, by increasing MR when the percentage of successful mutations is greater than $1/5$ (and vice versa). Although this technique is based on empirical findings, it is ad-hoc, does not generalize to different landscapes, requires a hardcoded threshold, and has been shown to lead to premature convergence when elitism is employed \cite{Rudolph2001-zf}. \paragraph{Self-Adaptive MRs:} Perhaps the most promising and evolutionarily plausible class of adapting MRs is that of self-adapting MRs \cite{Kramer2010-ia, Aleti2016-wn, Back1992-al, Gomez2004-sh, Thierens2002-dq}. This technique concatenates an MR to each individual and evolves the MRs and individuals in one end-to-end evolutionary process. However, many previous works have shown this process to be brittle and lead to premature convergence of evolution as the MRs decay and vanish \cite{Rudolph2001-zf, Glickman2000-mr, Clune2008-lh, Meyer-Nieberg2007-nz}. In the instances where self-adapting MRs succeed, the authors attribute the cause to be from a relatively smooth fitness landscape \cite{Clune2008-lh, Glickman2000-mr}, or high selection pressure \cite{Maschek2010-ap}. The cause of general premature convergence in rugged landscapes is attributed to the fact that most mutations are deleterious, causing self-adaptation to prefer solutions that mutate less and preserve the fitness of each individual \cite{Clune2008-lh, Glickman2000-mr}. \citet{Clune2008-lh} mention that, in this way, evolution is short-sighted: it cannot adapt MRs to be optimal for the long-term, only optimizing for short-term performance. \paragraph{Outlier-Based MRs:} Some works have proposed looking at the best mutation produced by a certain mutation operator to judge the quality of the operator \cite{Fialho2008-ud, Whitacre2009-uv}, with the motivation that an operator that produces infrequent large fitness gains is preferred to one that produces frequent small fitness gains. However, these works model the operator selection as a multi-armed bandit problem. This technique is not only unnatural to evolution, it is also limited by the expressiveness of the arms used and assumes independent arms, thus failing to capture the continuous spectrum that the MR exists in. \paragraph{CMA-ES:} One of the most successful forms of adapting the \linebreak spread of a population during an evolutionary search is with Covariance Matrix Adaptation Evolution Strategy (CMA-ES) \cite{Hansen2016-qa}. It relies on maintaining a covariance matrix, which requires quadratic time and space in the solution vector length. Thus, CMA-ES does not scale to larger problems like deep neuroevolution with millions of parameters \cite{Such2017-rn}. In contrast, GESMR and GAs in general are linear wrt.\ solution length. \subsection{GESMR Algorithm} In this section, the Group Elite Selection of Mutation Rates (GESMR) is proposed to produce MRs for the $\EX[\min_i\Delta_i]$ objective from the previous section. This method is essentially co-evolving a population of solutions and a population of MRs in a way that does not decay the MRs to zero. The detailed psuedocode for this algorithm is in Algorithm~\ref{alg:algo}. A population of $K$ MRs is initialized (usually logarithmically varying from $\num{1e-2}$ to $\num{1e2}$), alongside the $N$ individual solutions (Algorithm~\ref{alg:algo}, Line X). At each generation, the population of $N$ solutions is randomly split into $K$ groups of $N/K$ solutions (Line X). Each group is assigned an MR from the current population of MRs. The population of solutions and population of MRs are evolved according to a simple GA described in the problem formulation. Each solution is evaluated using the functional value of the solution, $f(x)$. Each solution is mutated according to its assigned MR. Each MR evaluated using the \emph{best} change in function value (over one generation) seen in the $N/K$ samples of the MR group. This processes involves storing mild statistics on the change of function value for different MRs in each generation. \section{General Experiment Setup} All algorithms for all experiments (except the group size ablation experiment) are run with a population size of $N+1=101$. The test optimization problems are run for $T\in\akset{100, 300, 1000, 2500}$ generations with problem dimensionality $d\in\akset{2, 30, 100, 1000}$, respectively. The Linear function is always only run for $T=100$ generations. The MNIST/Fashion-MNIST experiments are run for $T=1000$ generations. All reinforcement learning experiments are run for $T=100$ generations. \textbf{OFMR} finds the optimal fixed MR using a grid search over a logarithmic range of ten MRs ranging from \num{1e-3} to \num{1}. For each MR in the grid search, an entire evolution is run to evaluate it. The MR whose evolution provides the best final elite function value is picked as the optimal fixed MR, and another fixed MR evolution is run with this MR value. \textbf{LAMR-$G$} changes the MR every $G$ generations, and picks the MR according to a grid search over a logarithmic range of 10 MRs ranging from \num{1e-3} to \num{1}. For each MR in the grid search, the current population is used to initialize another evolution run that ooks ahead for $G$ generations. The MR whose evolution provides the best final elite is used for the next $G$ generations in the main evolution run. In this way, LAMR-$G$ is able to adapt MRs for the long-term by directly looking ahead $G$ generations and picking an that MR performs the best. \textbf{FMR} sets the MR to a fixed \num{1e-2}, as is commonly done when the user is left to define an MR. \textbf{1CMR} sets the MR to a fixed $1/d$ where $d$ is the dimensionality of the solution space \cite{Ochoa2002-ni}. The goal is to search carefully in problems with high dimensionality and explore more in problems with low dimensionality. \textbf{15MR} starts with the MR equal to \num{1e-2} and adapts MRs based on the percentage of beneficial mutations in the current generation (i.e.\ those that result in a negative function value change) If the percentage is greater than 1/5, the MR is doubled, else it is cut in half. This factor of two is chosen to match the meta-MRs in SAMR and GESMR in order to compare adaptability fairly between methods. \textbf{UCB/$R$} creates a multi-armed bandit problem with $R$ arms corresponding to MRs that are spaced logarithmically between \linebreak \num{1e-3} and 1. The upper confidence bound (UCB) algorithm is utilized to solve the problem. At each generation, an MR is sampled from UCB; the reward that is reported back is the \textit{best} (lowest) change in function value from mutations for the current generation. With \textbf{SAMR}, solutions are paired up with MRs spaced logarithmically between \num{1e-3} and \num{1e3}. The solutions are mutated according to their assigned MR and the MRs are mutated with the same equation as with GESMR, using the meta-MR $\tau=2$. With \textbf{GESMR}, the population of MRs are initialized by spacing them logarithmically between \num{1e-3} and \num{1e3}. They are mutated using the meta-MR $\tau=2$. \input{content/data_table} \input{content/data_table_auc} \input{content/data_table_mselog} \section{Details of the Function Optimization Experiment} Detailed definitions of the test functions are given in this Appendix, followed by detailed results. \subsection{Test Function Definitions} \begin{description} \vspace*{1ex} \item \textbf{Ackley}: \vspace*{-1ex} \begin{align} f(x) = &-a\exp{\akparen{-b\sqrt{\frac1d \sum_{i=1}^d x_i^2}}}\\ &-\exp{\akparen{\frac1d \sum_{i=1}^d \cos{(cx_i)}}}+a+\exp{(1)}, \end{align} with $a=20, b=0.2, c=2\pi$. \vspace*{1ex} \item \textbf{Griewank}: \vspace*{-1ex} \begin{align} f(x) = &\sum_{i=1}^d\frac{x_i^2}{4000}-\prod_{i=1}^d \cos{\akparen{\frac{x_i}{\sqrt{i}}}}+1. \end{align} \vspace*{1ex} \item \textbf{Rastrigin}: \vspace*{-1ex} \begin{align} f(x) = &10d+\sum_{i=1}^d\akbrack{x_i^2-10\cos{(2\pi x_i)}}. \end{align} \vspace*{1ex} \item \textbf{Rosenbrock}: \vspace*{-1ex} \begin{align} f(x) = &\sum_{i=1}^{d-1} \akbrack{100(x_{i+1}-x_i^2)^2+(x_i-1)^2}. \end{align} \vspace*{1ex} \item \textbf{Sphere}: \vspace*{-1ex} \begin{align} f(x) = &\sum_{i=1}^d x_i^2. \end{align} \vspace*{1ex} \item \textbf{Linear}: \vspace*{-1ex} \begin{align} f(x) = &\sum_{i=1}^d x_i. \end{align} \end{description} \subsection{Function Optimization Results} The full results of the test optimization functions are shown in Tables~\ref{tbl::data_table},~\ref{tbl::data_table_auc},~\ref{tbl::data_table_mselog}. Table~\ref{tbl::data_table} summarizes the final elite function value achieved by each algorithm in all the test function optimization runs. Table~\ref{tbl::data_table_auc} summarizes the average elite function value over generations from each algorithm in all the test function optimization runs. Table~\ref{tbl::data_table_mselog} summarizes the mean squared error between the average log MR of a given algorithm with the log MR of LAMR-$100$ (the oracle long-term MR). These result show that GESMR outperforms other methods in the high dimensional and rugged function landscapes. GESMR also produces MRs that match the oracle long-term optimal MR, showing that GESMR empirically produces MRs suited for the long-term. GESMR also scales well to the high dimensions of neuroevolution. \clearpage \clearpage \clearpage \clearpage \section{Details of the Image Classification Experiment} MNIST and Fashion-MNIST are common image classification \linebreak datasets of hand written digits and clothes, respectively \cite{LeCun1998-wt, Xiao2017-kj}. The inputs are 28$\times$x28 grayscale images and the output is one of ten classification labels. Both datasets consists of 60,000 training images 10,000 evaluation images. For these problems, $f$ is the negative log-likelihood function (i.e.\ the cross-entropy loss) as is common in supervised learning. The evolved neural-network architecture contains three 3$\times$3 \linebreak Conv2D layers with 10 channels, each one followed by a 2$\times$2 MaxPooling layer and a ReLU nonlinearity. The resulting feature maps are collapsed into a vector and fed into a 10$\times$10 Dense layer followed by a ReLU and another 10$\times$10 Dense layer. after which they are fed into a Softmax function to output ten class probabilities. \section{Details of the Reinforcement Learning Experiment} CartPole, Pendulum, Acrobot, and MountainCar are common reinforcement learning control tasks. In each of these tasks, the performance of a robot controller is evaluated in a simulated environment \cite{Brockman2016-bx}. CartPole consists of balancing a single pole on a one-dimensional cart for as long as possible or until 200 timesteps have passed, rewarded for how long the pole stays up. Pendulum consists of a robot trying to swing up a pendulum, rewarded for maintaining as much of an upward angle as possible. Acrobot consists of moving a joint with two links such that the bottom link swings to as high as possible. MountainCar consists of a car with a weak engine in valley between two hills; it must be moved back and forth between the hills to gain enough energy to reach the top of the target hill. In all environments, $f$ is the negative cumulative reward of an episode (averaged over five episodes). The evolved neural-network architecture contains a dense layer to map the number of observations to 128 hidden neurons with a ReLU activation function, and another dense layer mapping the 128 neurons to the number of actions. If the action space is discrete, a Softmax function is applied to output action probabilities. The detailed results are shown in Figure~\ref{fig:fits_mrs_rl}. \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{imgs/fits_mrs_rl.png} \caption{ Elite function value and average mutation rate (MR) over generations of neuroevolution using different MR control strategies applied to the reinforcement learning control tasks of CartPole, Pendulum, Acrobot, and MountainCar. GESMR outperforms most other methods in CartPole, Pendulum, and Acrobot, but fails in MountainCar. } \label{fig:fits_mrs_rl} \end{figure} \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]{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*} Always use midrule to separate table header rows from data rows, and use it only for this purpose. This enables assistive technologies to recognise table headers and support their users in navigating tables more easily. \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{A woman and a girl in white dresses sit in an open car.} \end{figure} Your figures should contain a caption which describes the figure to the reader. Figure captions are placed {\itshape below} the figure. Every figure should also have a figure description unless it is purely decorative. These descriptions convey what’s in the image to someone who cannot see it. They are also used by search engine crawlers for indexing images, and when images cannot be loaded. A figure description must be unformatted plain text less than 2000 characters long (including spaces). {\bfseries Figure descriptions should not repeat the figure caption – their purpose is to capture important information that is not already provided in the caption or the main text of the paper.} For figures that convey important and complex new information, a short text description may not be adequate. More complex alternative descriptions can be placed in an appendix and referenced in a short figure description. For example, provide a data table capturing the information in a bar chart, or a structured list representing a graph. For additional information regarding how best to write figure descriptions and why doing this is so important, please see \url{https://www.acm.org/publications/taps/describing-figures/}. \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}
{'timestamp': '2022-04-12T02:29:14', 'yymm': '2204', 'arxiv_id': '2204.04817', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04817'}
arxiv
\section{Introduction} The population dynamics of time-evolving individuals appears in various scientific fields, such as cell population in biology \cite{yang2018scalable, schiebinger2019optimal}, air in meteorology \cite{fisher2009data}, and healthcare statistics \cite{manton2008cohort} in medicine. However, tracking individuals over a long period is often difficult due to experimental costs and other constraints such as privacy issues in the case of human social life. Furthermore, it can sometimes be impossible to track the time evolution. For example, since all cells are destroyed once measured using single-cell RNA sequencing, we cannot analyze the behavior of individual cells over time in cell transcriptome measurements. Instead, we only obtain individual samples from cross-sectional populations without alignment across time steps at a few distinct time points. Under these constraints on data measurements, our goal is to better understand not only the time evolution at the population level, but also the time evolution of individual samples in the populations. Existing methods attempt to estimate population-level dynamics using a recurrent neural network (RNN) \cite{hashimoto2016learning} or the Jordan-Kinderlehrer-Otto (JKO) flow \cite{bunne2021jkonet}. \citet{hashimoto2016learning} proposed using RNN with noise-based regularization to model the diffusion process described by stochastic differential equations (SDEs). Recent studies have attempted to interpolate the trajectories of individual samples between cross-sectional populations at multiple time points by using optimal transport (OT) \cite{yang2018scalable, schiebinger2019optimal}, or CNF \cite{tong2020trajectorynet}. Using a CNF generates continuous-time non-linear trajectories of individual samples from multiple time points. In addition, \citet{tong2020trajectorynet} proposed a regularization for CNF that encourages a straight trajectory on the basis of OT theory. Since the probability distribution transformation based on ordinary differential equations (ODEs) is used in CNF, the behavior of each sample is described by its initial condition in a completely deterministic manner. However, individual samples in population are known to move stochastically and diffuse in nature, including biological system \cite{kolomgorov1937study}. To handle the stochastic and complex behavior of individual samples, we propose to model the advection-diffusion processes by using SDEs to describe the time evolution of the sample. Furthermore, on the basis of \textit{the principle of least action}, we estimate the sample trajectories that minimize \textit{action}, defined by the time integral of the Lagrangian determined from the prior knowledge. We formulate this problem as the LSB problem, which is a special case of the stochastic optimal transport (SOT) problem, and propose an approximate solution method Neural Lagrangian Schr\"{o}dinger bridge (NLSB). In NLSB, we train regularized neural SDE \cite{tzen2019neural, tzen2019theoretical, li2020scalable} by minimizing the Wasserstein loss between the ground-truth and the predicted population. The Lagrangian design defining regularization allows the sample trajectory to reflect various prior knowledge such as OT, manifold geometry, and local velocity arrows proposed by \citet{tong2020trajectorynet}. In addition, we parameterize a potential function instead of the drift function. Adopting the model architecture of the potential function from OT-Flow \cite{onken2021ot} will speed up the computation of the gradient of the potential function and the regularization term. As a result, we capture the dynamics at the population level as well as or better than conventional methods, and can more accurately predict the trajectory of individual sample from the population. In short, our contributions are summarized as follows. \begin{enumerate} \item We formulate the LSB problem to estimate the stochastic sample trajectory according to the principle of least action. \item We propose NLSB to approximate the LSB problem efficiently by using neural SDE with regularization on the basis of the prior knowledge introduced by the Lagrangian. \item Our model architecture of the potential function enables its gradient and diagonal components of the Hessian to be computed explicitly, resulting in fast computation. \end{enumerate} \section{Background} \subsection{Flows Regularized by Optimal Transport} A CNFs \cite{chen2018neural} is a method for learning the continuous transformation between two distributions $p$ and $q$ by modeling the ordinary differential equation (ODE): \begin{align*} \frac{\mathrm{d}\mathbf{x}(t)}{\mathrm{d}t} = \mathbf{v}_{\theta}(\mathbf{x}, t), \qquad \text{subject to} \quad \mathbf{x}(t_0) \sim p,\ \mathbf{x}(t_1) \sim q. \end{align*} Several regularizations of CNFs that lead to straight trajectories have been proposed on the basis of the OT theory. RNODE \cite{finlay2020train}, OT-Flow \cite{onken2021ot}, and TrajectoryNet \cite{tong2020trajectorynet} introduced a regularization $\tilde{\mathcal{R}}_e$ inspired by the dynamic OT formulation \cite{benamou2000computational}. Potential Flow \cite{yang2020potential} and OT-Flow modeled the potential function $\Phi$ that satisfies $\mathbf{v} = - \nabla \Phi$ instead of modeling the velocity function $\mathbf{v}$. They also proposed an additional OT-based regularization $\tilde{\mathcal{R}}_h$ derived from the Hamilton–Jacobi–Bellman (HJB) equation \cite{evansintroduction} satisfied by the potential function. These OT-based regularizations have resulted in faster CNFs \cite{onken2021ot, finlay2020train} and improved the modeling of cellular dynamics \cite{tong2020trajectorynet}. \begin{align} \label{ot_loss_L} \tilde{\mathcal{R}}_{e} &= \int_{t_0}^{t_1} \int_D \frac{1}{2} || \mathbf{v}_{\theta}(\mathbf{x}, t) ||^2 \mathrm{~d} \rho_t(\mathbf{x}) \mathrm{~d}t, \\ \label{ot_loss_R} \tilde{\mathcal{R}}_{h} &= \int_{t_0}^{t_1} \int_D \left| \partial_t \Phi_{\theta}(\mathbf{x}, t) - \frac{1}{2} || \nabla_\mathbf{x} \Phi_{\theta}(\mathbf{x},t)||^2 \right| \mathrm{~d} \rho_t(\mathbf{x}) \mathrm{~d}t, \end{align} where $\rho_t$ is the probability measure of the sample $\mathbf{x}$ at the time $t$. \subsection{Neural Stochastic Differential Equations} SDE has been used to model real-world random phenomena in a wide range of areas, such as chemistry, biology, mechanics, economics and finance \cite{higham2001algorithmic}. As an extension of neural ODEs, neural SDE has been proposed to model drift and diffusion functions with neural networks, as shown in the following equation: \begin{gather} \label{ito_sde} \mathrm{d} \mathbf{X}_t = \mathbf{f}_{\theta}(\mathbf{X}_t, t) \mathrm{~d}t + \mathbf{g}_{\phi}(\mathbf{X}_t, t) \mathrm{~d} \mathbf{W}_t, \end{gather} where $\{ \mathbf{X}_t \}_{t \in [t_0, t_{K-1}]}$ is a continuous $\mathbb{R}^d$-valued stochastic process, $\mathbf{f}_{\theta} : \mathbb{R}^d \times [t_0, t_{K-1}] \mapsto \mathbb{R}^d$ is a drift function, $\mathbf{g}_{\phi}: \mathbb{R}^d \times [t_0, t_{K-1}] \mapsto \mathbb{R}^{d \times m}$ is a diffusion function and $\{ \mathbf{W}_t \}_{t \in [t_0, t_{K-1}]}$ is an $m$-dimensional Brownian motion. \citet{tzen2019neural, tzen2019theoretical} proposed neural SDEs as the continuous limit of deep latent Gaussian models optimized in the framework of variational inference. \citet{li2020scalable} extended the adjoint sensitivity method in neural ODEs to neural SDEs, enabling efficient calculation of gradients. Furthermore, they combined this method with gradient-based stochastic variational inference for latent stochastic differential equations (latent SDEs). Other approaches have been proposed, such as training neural SDEs as generative adversarial networks (GANs) \cite{kidger2021neural} and training methods using score matching \cite{song2020score}. \subsection{Stochastic Optimal Transports for Marginal Flows} As a framework for comparing probability distributions, OT theory has many applications in machine learning, such as generative modeling and domain adaptation, and in a wide range of scientific fields, such as single-cell biology and neuroscience. \citet{mikami1990variational} generalized the OT problem and defined the SOT problem as a random mechanics problem determined by \textit{the principle of least action}. The SOT problem for the case in which the two endpoint marginals are fixed to $\mu_0$ and $\mu_1$ is represented as \begin{gather*} V(\mu_0, \mu_1):= \inf_{\mathbf{X}} \left\{\mathbb{E}\left[\int_{t_0}^{t_1} L\left(t, \mathbf{X}_{t}; \boldsymbol{\beta}_{\mathbf{X}}(\mathbf{X}_t, t) \right) d t\right] \middle| \mathbf{X}_t \in \mathcal{A},\ \mathbf{X}_{t_0} \sim \mu_0,\ \mathbf{X}_{t_1} \sim \mu_1 \right\}, \end{gather*} where $L(t, \mathbf{x}, \mathbf{u}): [t_0, t_1] \times \mathbb{R}^d \times \mathbb{R}^d \mapsto \mathbb{R}_+$ is continuous and convex in $\mathbf{u}$. $\mathcal{A}$ is the set of all $\mathbb{R}^d$-valued, continuous semimartingales $\{ \mathbf{X}(t) \}_{t_0 \leq t \leq t_1}$ on a complete filtered probability space such that there exists a Borel measurable $\boldsymbol{\beta}_{\mathbf{X}}(\mathbf{X}_t, t): C([t_0, t_1]) \times [t_0, t_1] \mapsto \mathbb{R}^d$ for which $\omega \mapsto \boldsymbol{\beta}_{\mathbf{X}}(\omega, t)$ is $\boldsymbol{B}(C([t_0, t_1]); \mathbb{R}^d)_+$-measurable and $\mathbf{X}(t) = \mathbf{X}(0) + \int_{t_0}^{t} \boldsymbol{\beta}(\mathbf{X}_t, t) \mathrm{~d}t + \int_{t_0}^{t} \boldsymbol{\sigma}(\mathbf{X}_t, t) \mathrm{~d} \mathbf{W}_t$ for all $t \in [t_0, t_1]$ and $E \left[\int_{t_0}^{t_1} \left\{ | \boldsymbol{\beta}(\mathbf{X}_t, t) | + | \boldsymbol{\sigma}( \mathbf{X}_t, t) |^2 \right\} \mathrm{~d}t \right] < \infty$. They also introduced another similar version of the SOT for a flow of marginal distributions which satisfies the Fokker–Planck (FP) equation. \begin{gather} \label{SOT for Marginal Flows} \mathrm{v}(\mu_0, \mu_1):= \inf_{\mathbf{f}, \rho} \left\{ \int_{t_0}^{t_1} \int_{\mathbb{R}^d} L\left(t, \mathbf{x}; \mathbf{f}( \mathbf{x}, t) \right) \mathrm{~d} \rho_t(\mathbf{x}) \mathrm{~d}t \middle| \rho_{t_k} = \mu_k,\ (\mathbf{f}, \rho_t) \ \text{satisfies the FP equation} \right\}, \end{gather} where $\rho_t$ is the probability measure of the random variable $\mathbf{x}$ at the time $t$. When $\mathbf{u} \mapsto L$ is quadratic, $V(\mu_0, \mu_1) = \mathrm{v}(\mu_0, \mu_1)$ proved in \cite{mikami1990variational}. Especially when $L(t, \mathbf{x}, \mathbf{u}) = \frac{1}{2}||\mathbf{u}||^2$, the problem \ref{SOT for Marginal Flows} is regarded as stochastic optimal control (SOC) problem \cite{pavon1991free, dai1991stochastic} with the additional terminal constraint and the special case of Schr\"{o}dinger bridge (SB) \cite{jamison1975markov} problem. Furthermore, if we assume that the sample motion is deterministic by replacing the FP equation with the continuity equation, the problem \eqref{SOT for Marginal Flows} is reduced to a dynamic OT formulation proposed by Brenier and Benamou \cite{benamou2000computational}. \section{Proposed Method} \begin{figure}[t] \centering \includegraphics[width=\columnwidth]{fig/Overview.png} \caption{Overview} \label{fig: overview} \end{figure} In this section, we first introduce Lagrangian-Schr\"{o}dinger bridge (LSB) problem. We next present an approximate solution for the LSB problem: Neural Lagrangian Schr\"{o}dinger bridge (NLSB). Finally, we give specific examples of our methodology for specific use cases. Figure \ref{fig: overview} illustrates the position of the LSB problem in the transport problem with endpoint constraints and the relationship between the NLSB and existing methods. \subsection{Lagrangian Schr\"{o}dinger Bridge} We consider the problem of estimating dynamics at both the population and sample-trajectory levels by using probability densities at two known end points. To solve this problem, we need two pieces of prior knowledge about the target system. \begin{enumerate} \item The stochastic behavior of individual samples yields the population diffusion phenomenon. \item Individual samples are encouraged to move according to \textit{the principle of least action}. \end{enumerate} The principle of least action states that when a sample moves from point A to point B, its trajectory is such that the corresponding action has the smallest possible value, which is known as a fundamental principle in dynamical systems. We propose to explicitly model diffusion phenomena as well as drift by using SDEs for the time evolution of the sample and to explore the sample paths that minimize \textit{action} defined by the time integral of the Lagrangian. Later in Section \ref{section: examples of Lagrangian}, we will give some examples of prior information described by the Lagrangian. We formulate this problem as a special case of the SOT problem and call it \textit{the Lagrangian-Schdehlinger Bridge (LSB) problem}. \begin{dfn}[LSB problem] \begin{align} \label{LSB problem} \begin{aligned} &\underset{\theta, \phi} {\text{minimize}} && \int_{t_0}^{t_1} \int_D L(t, \mathbf{x}, \mathbf{f}_{\theta}(\mathbf{x}, t)) \mathrm{~d} \rho_t(\mathbf{x}; \theta, \phi) \mathrm{~d} t, \\ &\text{subject to} && \mathrm{d} \mathbf{X}_t = \mathbf{f}_{\theta}(\mathbf{X}_t, t) \mathrm{~d}t + \mathbf{g}_{\phi}(\mathbf{X}_t, t) \mathrm{~d} \mathbf{W}_t, && \\ &&& \rho_{t_0} = \mu_{0},\ \rho_{t_1} = \mu_{1}, \end{aligned} \end{align} where $\rho_t$ is the probability measure of the random variable $\mathbf{X}_t$, depending on the functions $\mathbf{f}$ and $\mathbf{g}$. \end{dfn} If the Lagrangian $L(t, \mathbf{x}, \mathbf{u}) = \frac{1}{2}||\mathbf{u}||^2$ and the class of SDEs to be searched is smaller, the LSB problem reduces to a special case of the SB problem. We discuss this linkage in detail in Appendix \ref{appendix: connection between SB and SOC}. The LSB problem is more challenging than the SOT problem constrained by the FP equation given by Eq.\,\eqref{SOT for Marginal Flows} because the SDE solution needs to reflect both the information of the sample paths and the time evolution of the probability distribution. \subsection{Neural Lagrangian Schr\"{o}dinger Bridge} \label{NLSB} In this section, we propose to solve the LSB problem by using neural SDEs \eqref{ito_sde} with regularization. As shown in Eq.\,\eqref{LSB problem}, the LSB is expressed with optimization over Ito SDE with constraints at time $t_0$ and $t_1$. Relaxing this constraint to minimizing Wasserstein-2 cost at time $t_1$, i.e. $\mathcal{W}_2(\mu_1, \mid \mid \rho_{t_1})$ makes it possible to approximate the LSB problem by using regularized neural SDEs. We propose to approximate the LSB problem by learning neural SDEs with the gradients of the loss: \begin{gather} \label{eq: theoretical loss} \mathcal{W}_2(\mu_1, \mid \mid \rho_{t_1}) + \mathcal{R}_e(\theta; t_{0}, t_{1}) + \mathcal{R}_h(\theta, \phi; t_{0}, t_{1}), \end{gather} where $\mathcal{R}_e$ and $\mathcal{R}_h$ are the action cost and the HJB regularization, respectively. Let $D_{i, j}(\cdot; \phi)$ be the entry in the $i$-th row and $j$-th column of the diffusion coefficient matrix $\mathbf{D}_{\phi} = \mathbf{g}_{\phi} \mathbf{g}_{\phi}^\top$ and $\Phi_{\theta}$ be the potential function satisfying $\mathbf{f}_{\theta} = \left[ \nabla_{\mathbf{u}} L \right]^{-1} \left(- \nabla_{\mathbf{x}} \Phi_{\theta} \right)$. Then $\mathcal{R}_e$ and $\mathcal{R}_h$ are defined by \begin{align} \label{sot_loss_L} \mathcal{R}_e(\theta; t_0, t_1) &= \int_{t_0}^{t_1} \int_D L(t, \mathbf{x}, \mathbf{f}_{\theta}(\mathbf{x}, t)) \mathrm{~d} \rho_t(\mathbf{x}) \mathrm{~d}t, \\ \begin{split} \label{sot_loss_R} \mathcal{R}_h(\theta, \phi; t_0, t_1) &= \int_{t_0}^{t_1} \int_D \left| \partial_t \Phi_{\theta}(\mathbf{x}, t) + \frac{1}{2} \sum_{i, j}^d D_{i,j}(\mathbf{x},t; \phi) \left[\nabla_{\mathbf{x}}^2 \Phi_{\theta}(\mathbf{x}, t)\right]_{i,j} + h(\mathbf{x}, t) \right| \mathrm{~d} \rho_t(\mathbf{x}) \mathrm{~d}t, \\ h(\mathbf{x}, t) &= L(t, \mathbf{x}, \mathbf{f}_{\theta}( \mathbf{x}, t)) - \left. \nabla_{\mathbf{u}} L(t, \mathbf{x}, \mathbf{u}) \right|_{\mathbf{u}=\mathbf{f}_{\theta}( \mathbf{x}, t)}^{\top} \mathbf{f}_{\theta}( \mathbf{x}, t). \end{split} \end{align} The objective function of the LSB problem with the constraint at time $t_1$ relaxed by the Wasserstein-2 cost can be described as $\mathcal{R}_e + \lambda \mathcal{W}_2$ where $\lambda$ is Lagrange multiplier. This objective function can be reinterpreted with $\mathcal{W}_2$ as the main cost and the action cost $\mathcal{R}_e$ as the regularization. To find additional equations characterizing the solution, we transform the LSB problem into the SOT problem constrained by the FP equation shown in Eq.\,\eqref{SOT for Marginal Flows} using the relationship between the FP equation and Ito SDE. The FP equation corresponding to Ito SDE \eqref{ito_sde} is represented as \begin{gather} \label{eq: FP} \frac{\partial p_{t}}{\partial t}=-\operatorname{div}\left(p_{t} \mathbf{f}_{\theta}\right) + \sum_{i, j}^d \frac{\partial^2}{\partial x_i\partial x_j} \left[ D_{i,j}(\mathbf{x}, t; \phi) p_{t}(\mathbf{x}) \right], \end{gather} where $p_t$ is the probability density of the probability measure $\rho_t$. Then, we derive the optimality conditions for the SOT problem \eqref{SOT for Marginal Flows} by introducing a new Lagrangian $\mathcal{L}$ with a space-time-dependent potential function $\Phi(\mathbf{x}, t)$ (See Appendix \ref{appendix: derivation of NLSB} for details). According to the conditions characterizing the saddle-point of the Lagrangian $\mathcal{L}$, we can derive that the potential function $\Phi_{\theta}$ needs to satisfy the relation $\mathbf{f}_{\theta} = \left[ \nabla_{\mathbf{u}} L \right]^{-1} \left(- \nabla_{\mathbf{x}} \Phi_{\theta} \right)$ and the HJB equation. Therefore, we model the potential function directly from the above relation instead of the drift function. Furthermore, we propose the HJB regularization $\mathcal{R}_h$ that encourages the potential function to satisfy the HJB equation. \subsection{Examples of Lagrangian in Neural Lagrangian Schr\"{o}dinger Bridge} \label{section: examples of Lagrangian} In this section, we provide the three Lagrangian examples of the NLSB in Table \ref{tab: Lagrangian examples} and three use case. The examples demonstrate that the Lagrangian design allows a variety of prior knowledge to be reflected in the sample trajectories. \subsubsection*{Potential-free system} Without a specific external force on the individual sample, the principle of least action typically indicates that when a sample moves from point A to point B, it tries to minimize the travel distance in the sense of the Euclidean distance. This means that the drift is encouraged to be linear and the stochastic movement to be small, i.e., the Lagrangian is formulated as $L(t, \mathbf{x}, \mathbf{u}) = \frac{1}{2}||\mathbf{u}||^2$. \subsubsection*{Cellular system} \citet{tong2020trajectorynet} proposed to introduce the prior knowledge of manifold geometry and local velocity arrows such as RNA-velocity for modeling cellular systems. In the NLSB, these prior knowledge can be handled consistently by designing the Lagrangian. First, we introduce a density-based penalty to constrain the sample trajectories on the data manifold. We estimate the density function $U(\mathbf{x})$ from the data, e.g., by using kernel density estimation and add it to the Lagrangian. Next, we redefine the velocity regularization, which is formulated as cosine similarity maximization in \cite{tong2020trajectorynet}, as a squared error minimization and add it to the Lagrangian as well. Therefore, the Lagrangian for the cellular system is defined by \begin{gather} L(t, \mathbf{x}, \mathbf{u}) = \frac{1}{2}||\mathbf{u}(\mathbf{x}, t)||^2 - U(\mathbf{x}) + \frac{1}{2}||\mathbf{u}(\mathbf{x}, t) - \mathbf{v}(\mathbf{x}, t)||^2, \end{gather} where $\mathbf{v}(\mathbf{x}, t)$ is the reference velocity of the cell at the position $\mathbf{x}$ and the time $t$. \subsubsection*{Random dynamical system} Let $M(\mathbf{x})$ be the mass matrix of the sample which is positive definite, $U(\mathbf{x}, t)$ be the potential energy of the system, and $L(t, \mathbf{x}, \mathbf{u}) = \frac{1}{2} \mathbf{u}(\mathbf{x}, t)^{\top}M(\mathbf{x})\mathbf{u}(\mathbf{x}, t) - U(\mathbf{x}, t)$ be the Lagrangian in the generalized coordinate system of the Newtonian dynamical system. Then, the individual samples are encouraged to follow \textit{the equations of motion} of the Newtonian mechanics on average. In practice, we can roughly incorporate information such as obstacles and regions where samples cannot or are likely to exist in the form of potential functions. It is also easy to introduce a potential function estimated by other methods. \begin{table}[tb] \caption{Examples of the Lagrangian in Neural Lagrangian Schr\"{o}dinger bridge} \centering \vspace{0.2cm} \begin{adjustwidth}{-0.8cm}{} \begin{tabular}{ccc} \toprule $L(t, \mathbf{x}, \mathbf{u})$ & $\mathbf{f}_{\theta}( \mathbf{x}, t)$ & $h(\mathbf{x}, t)$ \\ \midrule \vspace{0.2cm} $\frac{1}{2} ||\mathbf{u}(\mathbf{x}, t)||^2$ & $- \nabla_{\mathbf{x}} \Phi_{\theta}(\mathbf{x}, t)$ & $-\frac{1}{2}||\mathbf{f}_{\theta}(\mathbf{x}, t)||^2$ \\ \vspace{0.2cm} $\frac{1}{2} ||\mathbf{u}(\mathbf{x}, t)||^2 - U(\mathbf{x}) + \frac{1}{2} ||\mathbf{u}(\mathbf{x}, t)- \mathbf{v}(\mathbf{x}, t)||^2$ & $ \frac{1}{2}( \mathbf{v}(\mathbf{x}, t) - \nabla_{\mathbf{x}} \Phi_{\theta}(\mathbf{x}, t))$ & $-U(\mathbf{x}) -||\mathbf{f}_{\theta}(\mathbf{x}, t)||^2 + \frac{1}{2}||\mathbf{v}(\mathbf{x}, t)||^2$ \\ $\frac{1}{2} \mathbf{u}(\mathbf{x}, t)^{\top}M(\mathbf{x})\mathbf{u}(\mathbf{x}, t) - U(\mathbf{x}, t)$ & $-M(\mathbf{x})^{-1}\nabla_{\mathbf{x}} \Phi_{\theta}(\mathbf{x}, t)$ & $-U(\mathbf{x}, t) - \frac{1}{2}\mathbf{f}_{\theta}(\mathbf{x}, t)^{\top}M(\mathbf{x})\mathbf{f}_{\theta}(\mathbf{x}, t)$ \\ \bottomrule \end{tabular} \end{adjustwidth} \label{tab: Lagrangian examples} \end{table} \section{Implementation Details of Neural Lagrangian Schr\"{o}dinger Bridge} \subsection{Training for Neural Lagrangian Schr\"{o}dinger Bridge} In this section, we describe a practical learning method for neural SDEs by minimizing loss \eqref{eq: theoretical loss} using the training data. First, for the data, only individual samples from a cross-sectional population with no alignment across time steps at $K$ separate time points are available. Let $T = \{ t_0,\ \dots,\ t_{K-1} \}$ be a set of time points and denote the data set at time $t_i$ as $\mathcal{X}_{t_i}$. Next, we describe how we calculate the loss \eqref{eq: theoretical loss} using the training data $\{ \mathcal{X}_{t_i} \}_{t_i \in T}$. The first term, the Wasserstein cost, is computed using the L2-Sinkhorn divergence $\overline{\mathcal{W}}_{\epsilon}$ between the observed data and the predicted sample at all observation points in $T$ except the initial point at time $t_0$. The Sinkhorn divergence can efficiently approximate the Wasserstein distance and solve the bias problem when using the Sinkhorn algorithm. The prediction sample is obtained by numerically simulating neural SDE from the training data at one previous time point by a standard SDE solver such as the Euler-Maruyama method. We used the GeomLoss library \footnote{\url{https://www.kernel-operations.io/geomloss/}} with default settings for the Sinkhorn divergence calculations. The second and third terms, $\mathcal{R}_e$ and $\mathcal{R}_h$, are also approximated on the sample paths obtained from the numerical simulations of SDE. Therefore, the computational cost of empirical $\mathcal{R}_e$ and $\mathcal{R}_h$ is not high and can be further accelerated by the model architecture described in the next section. To summarize, we minimize the subsequent loss for the model parameters $\theta,\ \phi$. \begin{gather*} \label{eq: empirical loss} \ell(\theta, \phi) = \sum_{t_k \in T \setminus t_0} \left( \overline{\mathcal{W}}_{\epsilon}(\mu_{k} \mid \mid \rho^{\theta, \phi}_{t_{k}}) + \lambda_e(t_{k-1}, t_{k}) \mathcal{\hat{R}}_e(\theta; t_{k-1}, t_{k}) + \lambda_h(t_{k-1}, t_{k}) \mathcal{\hat{R}}_h(\theta, \phi; t_{k-1}, t_{k}) \right), \end{gather*} where $\mu_{k},\ \rho_{t_{k}}^{\theta, \phi}$ are the ground-truth and predicted probability measures at time $t_k$ expressed by data samples, respectively. $\mathcal{\hat{R}}_e(t_{k-1}, t_k)$ and $\mathcal{\hat{R}}_h(t_{k-1}, t_k)$ are empirical quantities computed on the simulated sample paths from $t_{k-1}$ to $t_{k}$ with data $\forall \mathbf{x}(t_{k-1}) \in \mathcal{X}_{t_{k-1}}$ as the initial value. $\lambda_e(t_{k-1}, t_{k})$ and $\lambda_h(t_{k-1}, t_{k})$ are the weight coefficients to be tuned that is set for the interval $[t_{k-1}, t_k]$. \subsection{Model Architecture Selection for Speedup} We adopt the model architecture of the potential function $\Phi_{\theta}$ proposed by OT-Flow \cite{onken2021ot} because it has two advantages in our framework. First, it can compute the gradient $ \nabla_{\mathbf{x}} \Phi$ explicitly, which enables us to calculate the drift function easily. Second, the model is designed for the fast and exact computation of the diagonal component of the potential function's Hessian. Moreover, when we assume that the diffusion model's output is a diagonal matrix, i.e. $\mathbf{g}_{\phi}(\mathbf{x}, t) \in \mathbb{R}^{d \times d}$ and $\mathbf{g}_{i, j} = 0 \ (i \neq j)$, the function $\mathbf{D}_{\phi}$ is also a diagonal matrix, and the $\sum_{i, j}$ in the second term of $\mathcal{R}_h$ shown in Eq.\,\eqref{sot_loss_R} turns into the sum of the diagonal components only. Combining these two tricks enables speeding up the computation of $\mathcal{R}_h$, which requires the expensive computation of the Hessian of the potential function $\Phi$. While this model architecture trick was originally used for speeding up the computation of the Jacobian term in neural ODE maximum likelihood training, we propose to use it as a technique to speed up the computation of $R_h$. We use a two-layer fully connected neural network (FCNN) for the diffusion function. We also adopted the device used by \citet{kidger2021neural} in which the activation function tanh is used after the final layer to prevent the output of the diffusion function from becoming excessively large. For details of the model architecture, see Appendix \ref{appendix: Model architecture}. \section{Experiments} We evaluated our methods on two datasets. First, we used artificial synthetic data generated from one-dimensional SDEs, where the predicted trajectory and uncertainty can be compared with the ground-truth and easily evaluated by visualization. Second, we used the evolution of single-cell populations obtained from a developing human embryo system. We set the Lagrangian to $L(t, \mathbf{x}, \mathbf{u})=\frac{1}{2}||\mathbf{u}||^2$ for comparison with OT-based regularization of Eq.\,\eqref{ot_loss_L}. We compared our methods against standard neural SDE, OT-Flow \cite{onken2021ot} and TrajectoryNet \cite{tong2020trajectorynet}. We used the same network as NLSB for the drift and diffusion functions of neural SDE and trained only with Sinkhorn divergence in Eq.\,\eqref{eq: empirical loss}. The model architecture of the OT-Flow potential function was the same as that of our model. The base models of OT-Flow and TrajectoryNet were trained with the standard neural ODEs scheme. +OT represents a model trained with the OT-based regularization defined by Eqs.\,\eqref{ot_loss_L} and \eqref{ot_loss_R}. We used only $\tilde{\mathcal{R}}_e$ for TrajectoryNet; we used both $\tilde{\mathcal{R}}_e$ and $\tilde{\mathcal{R}}_h$ for OT-Flow. We set the interval-dependent coefficients $\tilde{\lambda}_e(t_{k-1}, t_k),\ \tilde{\lambda}_h(t_{k-1}, t_k)$ for the OT-based regularization as well as Eq.\,\eqref{eq: empirical loss}. See Appendix \ref{experimental details} for more details on hyperparameters, learning rates, and optimizers. \subsection{Synthetic Population Dynamics: Time-Dependent Ornstein–Uhlenbeck Process} \label{Synthetic Population Dynamics} \subsubsection*{Data} We used a time-dependent one-dimensional Ornstein–Uhlenbeck (OU) process defined by the following SDE: \begin{gather*} \mathrm{d}X_t = (\mu t - \theta X_t) \mathrm{~d}t + \left( \frac{2t\sigma}{t_{K-1}} \right) \mathrm{~d} W_t, \end{gather*} where $\mu=0.4,\ \theta=0.1,\ \sigma=0.8$, and $\ t_{K-1} = 4$. First, we simulated the trajectories of several individuals from $t=0$ to $4$ and then extracted only the data at the time of $T=\{0, 1, 2, 3, 4\}$ as snapshots for training. We generated $2048$ and $512$ samples for each time point as training and validation data, respectively. \subsubsection*{Performance metrics} We evaluated the estimation performance of the dynamics in the time interval $[t_0, t_{K-1}]$ by using two metrics: marginal distribution discrepancy (MDD) and conditional distribution discrepancy (CDD). A smaller MDD between $\mu_t$ and $\rho_t$ calculated on the basis of the Wasserstein-2 distance $\mathcal{W}(\mu_t, \rho_t)$ indicates better prediction of population-level dynamics at time $t$. We calculated MDD at $12$ equally spaced time points and the earth mover's distance with L2 cost (EMD-L2) between $1000$ samples generated from the ground-truth SDE and $1000$ samples predicted by the model. When evaluating the SDE-based method, we ran $100$ simulations from the same initial values, computing the MDD value each time and computing their mean and variance. \sloppy A smaller CDD between $\mu_{\mathbf{x}(t) \mid \mathbf{x}(t_0)}$ and $\rho_{\mathbf{x}(t) \mid \mathbf{x}(t_0)}$ using the Wasserstein-2 distance $\mathcal{W}(\mu_{\mathbf{x}(t) \mid \mathbf{x}(t_0)}, \rho_{\mathbf{x}(t) \mid \mathbf{x}(t_0)})$ indicates better prediction of the distribution followed by the time-evolving samples $\mathbf{x}(t)$ in subsequent time, given the initial state $\mathbf{x}(t_0)$. In short, it is a metric for evaluating the trajectories with uncertainty at the individual data sample level. In the actual CDD calculation, we first prepared $1000$ samples $\mathbf{x}(t_0)$ at the initial time point. We then generated $100$ trajectories from each initial sample by the trained model and the ground-truth SDE, and calculated the EMD-L2 for the samples from $\mu_{\mathbf{x}(t) \mid \mathbf{x}(t_0)}$ and $\rho_{\mathbf{x}(t) \mid \mathbf{x}(t_0)}$ at 12 equally spaced time points. Note that in the case of ODE-based methods such as OT-Flow and TrajectoryNet, we cannot calculate CDD because these methods cannot deal with trajectory uncertainty. \subsubsection*{Results} \begin{figure}[tb] \centering \begin{subfigure}[t]{0.5\hsize} \includegraphics[width=\linewidth]{fig/mdd_forward_allstep.png} \caption{MDD at 12 time points on synthetic OU process data.} \label{fig: ou-sde MDD} \end{subfigure}\hfil \begin{subfigure}[t]{0.5\hsize} \includegraphics[width=\linewidth]{fig/cdd_allstep.png} \caption{CDD at 12 time points on synthetic OU process data.} \label{fig: ou-sde CDD} \end{subfigure}\hfil \caption{Numerical evaluation on synthetic OU process data. All MDD and CDD values were computed between the ground-truth and the estimated samples within generated trajectories all-step ahead from initial samples $\mathbf{x}(t_0)$.} \label{fig: experiment result for synthetic data} \end{figure} \begin{figure}[tb] \centering \begin{subfigure}[t]{0.49\hsize} \includegraphics[width=\linewidth]{fig/ou-sde.png} \caption{ground-truth SDE} \label{fig: OU process} \end{subfigure}\hfil \begin{subfigure}[t]{0.49\hsize} \includegraphics[width=\linewidth]{fig/NeuralSDE_ou-sde.png} \caption{Neural SDE} \label{fig: neural SDE on OU process} \end{subfigure}\hfil \newline \centering \begin{subfigure}[t]{0.5\hsize} \includegraphics[width=\linewidth]{fig/NLSB_ou-sde.png} \caption{NLSB (Ours)} \label{fig: NLSB on OU process} \end{subfigure}\hfil \begin{subfigure}[t]{0.25\hsize} \includegraphics[width=\linewidth]{fig/TrajectoryNet+OT_ou-sde.png} \caption{TrajectoryNet + OT} \label{fig: TrajectoryNet on OU process} \end{subfigure}\hfil \begin{subfigure}[t]{0.25\hsize} \includegraphics[width=\linewidth]{fig/OT-Flow+OT_ou-sde.png} \caption{OT-Flow + OT} \label{fig: OT-Flow on OU process} \end{subfigure}\hfil \caption{1D OU process data and predictions. The five colored point clouds in the background are the ground-truth data given at each time point. The pink area and the light blue line are the one-sigma empirical confidence intervals and their boundaries for each trajectory, respectively. All trajectories were generated by all-step prediction from the initial samples at the time $t=0$.} \label{fig: visualization of the 1D Ornstein-Uhlenbeck process and predictions} \end{figure} The evaluation results are shown in Figure \ref{fig: experiment result for synthetic data}, and the visualization of trajectories is shown in Figure \ref{fig: visualization of the 1D Ornstein-Uhlenbeck process and predictions}. Figures \ref{fig: experiment result for synthetic data} show that NLSB outperforms neural SDE and is comparable to other ODE-based methods in estimating populations with small variance. In contrast, the SDE-based methods outperform ODE-based methods when estimating populations with a large variance. That indicates that NLSB can approximate population-level dynamics even when the population variance is large or small. Furthermore, NLSB has a smaller CDD value than neural SDE. Figure \ref{fig: neural SDE on OU process} shows that the average behavior of the data samples $E[\hat{X}(t) \mid X(0)]$ estimated by neural SDE is different from that of the ground-truth SDE (see Figure \ref{fig: OU process}), especially in the interval $t \in [0, 1]$. In contrast, the estimation by NLSB in Figure \ref{fig: NLSB on OU process} is much closer to the ground-truth. These results show that the prior knowledge introduced by the Lagrangian helps to approximate the dynamics at the individual sample level. \subsection{Single-Cell Population Dynamics} \subsubsection*{Data} We evaluated on embryoid body single-cell RNA sequencing (scRNA-seq) data \cite{moon2019visualizing}. This data shows the differentiation of human embryonic stem cells from embryoid bodies into diverse cell lineages, including mesoderm, endoderm, neuroectoderm, and neural crest, over $27$ days. During this period, cells were collected at five different snapshots ($t_0$: day $0$ to $3$, $t_1$: day $6$ to $9$, $t_2$: day $12$ to $15$, $t_3$: day $18$ to $21$, $t_4$: day $24$ to $27$). The collected cells were then measured by scRNAseq, filtered at the quality control stage, and mapped to a low-dimensional feature space using a principal component analysis (PCA). We reused the pre-processed data available in the released repository of TrajectoryNet \footnote{\url{https://github.com/KrishnaswamyLab/TrajectoryNet}}. For details, see Appendix E.2 in \cite{tong2020trajectorynet}. Following \cite{tong2020trajectorynet}, we modeled the trajectory in a five-dimensional PCA space. We split the dataset into train, validation($\sim 8.5 \%$) and test data ($\sim 15\%$). \subsubsection*{Performance metrics} Unlike the experiment described in Section \ref{Synthetic Population Dynamics}, there are no ground-truth trajectories in the real data. Thus, MDD can be calculated only at the time of observation, and the CDD between the ground truth and predicted trajectories cannot be calculated. To evaluation of the trajectories, we compared the predicted trajectories when training on all training data and when the model was trained on all but one intermediate snapshot at time $t_k$. Let $\mathcal{D}_{-t_k}$ be the training data set excluding the intermediate snapshot at time $t_k$. These trajectories should be similar if the model can estimate the trajectories with good accuracy in the interval where no observational data are available. Therefore, we calculated CDD between the conditional probability measures predicted by using the model trained on all data and trained on the data $\mathcal{D}_{-t_k}$, in the interval $[t_{k-1}, t_{k+1}]$. Larger CDD between them around the excluded time point $t_k$ indicates poorer performance in interpolating sample trajectories. For the calculations of MDD and CDD, we used not only EMD-L2 but also EMD-L1 to more accurately measure the distance between distributions with a wide base. When evaluating the SDE-based methods, we calculated the mean and standard deviation of $100$ MDD scores. \subsubsection*{Results} \begin{table}[tb] \caption{Evaluation results for population-level dynamics at time of observation for scRNA-seq data. The MDD value at $t_k$ is computed between the ground-truth and the samples predicted from the previous ground-truth samples at $t_{k-1}$ for each $k = 1, 2, 3$ and $4$.} \begin{subtable}{\textwidth} \vspace{0.2cm} \centering \begin{tabular}{lcccc} \toprule MDD (EMD-L2) $\downarrow$ & $t_1$ & $t_2$ & $t_3$ & $t_4$ \\ \midrule Neural SDE & $\bm{0.62} \pm 0.018$ & $0.78 \pm 0.024$ & $\bm{0.77} \pm 0.017$ & $\bm{0.75} \pm 0.016$ \\ NLSB (Ours) & $0.64 \pm 0.017$ & $\bm{0.77} \pm 0.019$ & $\bm{0.77} \pm 0.013$ & $0.76 \pm 0.012$ \\ OT-Flow & $0.74$ & $0.96$ & $0.93$ & $0.95$ \\ OT-Flow + OT & $0.75$ & $0.93$ & $0.93$ & $0.88$ \\ TrajectoryNet & $0.64$ & $0.87$ & $0.78$ & $0.89$ \\ TrajectoryNet + OT & $0.66$ & $0.87$ & $0.78$ & $0.97$ \\ \bottomrule \end{tabular} \end{subtable} \\ \par\bigskip \begin{subtable}{\textwidth} \centering \begin{tabular}{lcccc} \toprule MDD (EMD-L1) $\downarrow$ & $t_1$ & $t_2$ & $t_3$ & $t_4$ \\ \midrule Neural SDE & $\bm{1.11} \pm 0.030$ & $\bm{1.40} \pm 0.046$ & $\bm{1.38} \pm 0.030$ & $\bm{1.34} \pm 0.025$ \\ NLSB (Ours) & $1.15 \pm 0.028$ & $\bm{1.40} \pm 0.035$ & $\bm{1.38} \pm 0.023$ & $1.36 \pm 0.019$ \\ OT-Flow & $1.31$ & $1.73$ & $1.68$ & $1.69$ \\ OT-Flow + OT & $1.33$ & $1.65$ & $1.69$ & $1.56$ \\ TrajectoryNet & $1.15$ & $1.60$ & $1.42$ & $1.58$ \\ TrajectoryNet + OT & $1.20$ & $1.60$ & $1.41$ & $1.72$ \\ \bottomrule \end{tabular} \end{subtable} \label{tab: RNA MDD} \end{table} \begin{table}[tb] \caption{Mean value of CDD evaluated at $7$ equally spaced time points within time period $[t_{k-1}, t_{k+1}]$ around excluded time point $t_k$ for each $k = 1, 2$ and $3$. The CDD value at the time $t \in [t_{k-1}, t_{k+1}]$ was computed between the two groups of predicted samples generated from the previous samples at $t_{k-1}$ using the model trained on all data and the data $\mathcal{D}_{-t_k}$.} \centering \vspace{0.2cm} \begin{tabular}{lccc} \toprule Mean CDD (EMD-L2 $\mid$ EMD-L1) $\downarrow$ & $[t_0, t_2]$ & $[t_1, t_3]$ & $[t_2, t_4]$ \\ \midrule Neural SDE & $1.30 \mid 2.47$ & $0.79 \mid 1.40$ & $0.82 \mid 1.47$ \\ NLSB (Ours) & $\bm{0.72} \mid \bm{1.30}$ & $\bm{0.66} \mid \bm{1.18}$ & $\bm{0.70} \mid \bm{1.26}$\\ \bottomrule \end{tabular} \label{tab: RNA CDD} \end{table} Table \ref{tab: RNA MDD} shows that the SDE-based methods can predict population-level dynamics with a comparable or better performance against all existing ODE-based methods, even for high-dimensional real data. In particular, the SDE-based methods significantly outperform the ODE-based ones in predicting the transitions where the samples from $t_1$ to $t_2$ and from $t_3$ to $t_4$ are highly diffuse, indicating that the explicit modeling of diffusion is effective. (see Figure \ref{fig: visualization of the predicted samples} in Appendix \ref{appendix: visualization_rna}). Overall, the standard deviation of the MDD values is smaller for NLSB than for neural SDE, demonstrating less variation in the approximation accuracy of the marginal distribution. Table \ref{tab: RNA CDD} shows that NLSB generates robust trajectories with and without data at the intermediate time point than neural SDE. This result suggests that the LSB-based regularization helps interpolate trajectories. See the Appendix \ref{appendix: visualization_rna} for a visualization of trajectories with uncertainty. \section{Discussion} In this work, we proposed a novel framework for estimating stochastic sample trajectories that reflect prior knowledge about the target system. Unlike existing methods with OT \cite{yang2018scalable, schiebinger2019optimal}, or CNF \cite{tong2020trajectorynet} for a biological system, we explicitly modeled the diffusion phenomena by using SDEs for the time evolution of samples with stochastic behavior. This allowed us to handle the uncertainty of the trajectory (Fig.\,\ref{fig: visualization of the conditional distribution}) and to successfully capture the diffuse transitions (Tab.\,\ref{tab: RNA MDD} and Fig.\,\ref{fig: visualization of the predicted samples}). In contrast, \citet{vargas2021solving} and \citet{bunne2022recovering} estimated the sample trajectories of biological systems using the SDE solution to the SB problem. \citet{vargas2021solving} proposed an iterative proportional maximum likelihood (IPML) algorithm to solve the SB problem. They recasted the iterations of the dynamic iterative proportional fitting procedure (IPFP) algorithm as a regression based maximum likelihood objective. \citet{bunne2022recovering} proposed GSB-Flow, in which two SB problems are solved sequentially. The first SB problem with Gaussian marginals was solved in closed form, and the next SB problem using the closed-form solution as the reference path was solved by maximum likelihood training. Compared with these methods, our method handled a wider class of SDEs, and the diffusion function of the SDE was learned from data. Moreover, designing the Lagrangian enables us to flexibly incorporate prior knowledge about the target system into the model along with \textit{the principle of least action}. Our Lagrangian-based regularization also treated the biological constraints proposed by \citet{tong2020trajectorynet} and \citet{maoutsa2021deterministic} in a unified manner. In experiments, Figures \ref{fig: ou-sde CDD} and \ref{fig: NLSB on OU process}, and Table \ref{tab: RNA CDD} indicate that the prior knowledge introduced by the Lagrangian is useful to estimate the trajectories of individual samples with stochastic behavior. \section{Conclusion} We demonstrated that NLSB can estimate the population-level dynamics with the same or better performance than existing methods and that the prior knowledge introduced by the Lagrangian is effective in estimating more accurate trajectories of individual samples in the populations. Future work includes developing methods that can handle reaction phenomena with advection and diffusion phenomena. \section*{Acknowledgments} We thank the lab members for their discussions and inspiration for our research.
{'timestamp': '2022-04-20T02:19:54', 'yymm': '2204', 'arxiv_id': '2204.04853', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04853'}
arxiv
\section{% \ifnum0=1% \addtocounter{alphasect}{1} \fi% \oldsection}% \renewcommand\thesection{% \ifnum0=1% \Alph{alphasect}% \else \arabic{section}% \fi% }% \newenvironment{alphasection}{% \ifnum0=1% \errhelp={Let other blocks end at the beginning of the next block.} \errmessage{Nested Alpha section not allowed} \fi% \setcounter{alphasect}{0} \def0{1} }{% \setcounter{alphasect}{0} \def0{0} }% \title{DualPrompt: Complementary Prompting for Rehearsal-free Continual Learning} \author{\textbf{Zifeng Wang\textsuperscript{1}\thanks{Work done during internship at Google Cloud AI Research.} \quad Zizhao Zhang\textsuperscript{2} \quad Sayna Ebrahimi \textsuperscript{2} \quad Ruoxi Sun\textsuperscript{2} \quad Han Zhang\textsuperscript{3} } \\ \textbf{Chen-Yu Lee\textsuperscript{2} \quad Xiaoqi Ren\textsuperscript{2}\quad Guolong Su\textsuperscript{3}\quad Vincent Perot\textsuperscript{3} \quad Jennifer Dy\textsuperscript{1} \quad Tomas Pfister\textsuperscript{2}} \\ \textsuperscript{1}Northeastern University \quad \textsuperscript{2}Google Cloud AI \quad \textsuperscript{3}Google Research } \begin{document} \maketitle \begin{abstract} Continual learning aims to enable a single model to learn a sequence of tasks without catastrophic forgetting. Top-performing methods usually require a rehearsal buffer to store past pristine examples for experience replay, which, however, limits their practical value due to privacy and memory constraints. In this work, we present a simple yet effective framework, DualPrompt\xspace, which learns a tiny set of parameters, called \emph{prompts}, to properly instruct a pre-trained model to learn tasks arriving sequentially without buffering past examples. DualPrompt\xspace presents a novel approach to attach complementary prompts to the pre-trained backbone, and then formulates the objective as learning task-invariant and task-specific ``instructions". With extensive experimental validation, DualPrompt\xspace consistently sets state-of-the-art performance under the challenging class-incremental setting. In particular, DualPrompt\xspace outperforms recent advanced continual learning methods with relatively large buffer sizes. We also introduce a more challenging benchmark, Split ImageNet-R, to help generalize \emph{rehearsal-free} continual learning research. Source code is available at \url{https://github.com/google-research/l2p}. \end{abstract} \section{Introduction} The central goal of continual learning (CL) is to learn a sequence of tasks with a single model without suffering from \emph{catastrophic forgetting} \cite{mccloskey1989catastrophic} -- a significant deterioration in performance on previously seen data. Many existing methods aim at preserving and extending the acquired knowledge during the continual learning process~\cite{hadsell2020embracing,mai2021online}. Architecture-based methods assign isolated parameters to encode learned knowledge from different tasks~\cite{li2019learn,loo2020generalized,mallya2018packnet,serra2018overcoming,wang2020learn}. However, they often introduce a substantial number of additional parameters and sometimes involve simplified assumption like known test time task identity~\cite{ebrahimi2020adversarial,mallya2018packnet,mallya2018piggyback}, which falls into the setting of task-incremental learning. However, the task-incremental setting is usually considered over-simplified~\cite{buzzega2020dark,mai2021online,masana2020class}, since task identity is not known at test time in the real world. Our work focuses on more difficult class-incremental setting with unknown test-time task identity. \begin{figure}[t] \centering \includegraphics[width=0.9\linewidth]{figures/intro_compare.pdf} \caption{The average accuracy comparison on Split ImageNet-R, suggesting that the accuracy degradation is significant for representative rehearsal-based methods like DER++~\cite{buzzega2020dark} and ER~\cite{chaudhry2019tiny} when buffer size shrinks. Notably, they require a large rehearsal buffer (5000 images $\approx 20\%$ of the whole training set) to close the gap to our method. In contrast, GDumb~\cite{prabhu2020gdumb} matches their result by training only on the i.i.d sampled buffer, without continual learning. The additional parameters size required by DualPrompt\xspace is only about the bytes of one $224{\times}224$ RGB image. See Experiments section for discussion on compared methods.} \label{fig:intro} \end{figure} Another line of work, rehearsal-based CL methods, preserve past knowledge directly by keeping data from prior tasks in a rehearsal buffer~\cite{buzzega2020dark,cha2021co2l,pham2021dualnet}. Due to their conceptual simplicity, generalizability to various settings, and superior ability to mitigate catastrophic forgetting, rehearsal-based methods have been widely recognized as the reigning state-of-the-art~\cite{chaudhry2020using,buzzega2020dark} in the challenging class-incremental setting. Nevertheless, the dependence on rehearsal buffer has been criticised in the community \cite{serra2018overcoming,hadsell2020embracing,prabhu2020gdumb,lomonaco2020rehearsal}. While the performance of these methods is sensitive to the size of the buffer, GDumb~\cite{prabhu2020gdumb} argues that performing supervised training directly on a relatively large buffer already surpasses most recent CL methods. Critically, these methods cannot be used in applications with privacy concerns \cite{shokri2015privacy} or when memory budget is highly constrained \cite{smith2021memory}. Thus, it is desirable to develop a parsimonious, rehearsal-free continual learning method that can achieve similar or higher level of performance. A recent method, Learning to Prompt (L2P) \cite{wang2021learning} approaches this problem from a brand-new perspective -- it proposes to leverage learnable \emph{prompt} parameters to encode knowledge in a much more succinct way (i.e. prompt pool) than buffer, thus a rehearsal buffer is no longer necessary. Prompt techniques are originally introduced in natural language processing (NLP) for task adaptation \cite{liu2021pre} of large-scale pre-trained models by attaching fixed or learnable ``instructions'', since prompts are designed to instruct the model to properly reuse learned representations, instead of learning new representations from scratch. L2P successfully formulates the problem of learning new tasks as training small prompt parameters attached to a pre-trained frozen model. L2P takes an exciting step towards rehearsal-free continual learning, although the performance is still lower than rehearsal-based methods. In L2P, one single prompt pool is designed to transfer knowledge from one task to another without distinguishing between the common features among all tasks versus the features that are unique to each task. We argue such a design could be sub-optimal from the perspective of theory of Complementary Learning Systems (CLS)~\cite{mcclelland1995there,kumaran2016learning}, an intuition that many recent advanced CL methods are based on \cite{chaudhry2019tiny,pham2021dualnet,buzzega2020dark}. CLS suggests that humans learn continually via the synergy between two learning systems: the hippocampus focuses on learning pattern-separated representation on specific experiences, and the neocortex focuses on learning more general and transferable representation from past experience sequences. Thus, they are able to learn task-specific knowledge separately without interference while leveraging task-invariant knowledge to have greater learning capacity to learn future tasks better. However, previous CLS-driven methods still decouple or expand the backbone parameters learn the two kinds of knowledge~\cite{ebrahimi2020adversarial,pham2021dualnet,pham2020contextual}. Thus, they still rely on constructing a rehearsal buffer repeatedly to consolidate decoupled knowledge to prevent catastrophic forgetting. In this paper, we present DualPrompt\xspace, a rehearsal-free continual learning approach to explicitly learn two sets of disjoint prompt spaces, \emph{G(eneral)-Prompt} and \emph{E(xpert)-Prompt}, that encode task-invariant and task-specific instructions, respectively. DualPrompt\xspace directly decouples the higher-level prompt space, which turns out to be more effective and memory efficient that conventional methods which focus on the lower-level latent representation space. We further explore where and how to attach both types of prompts is crucial to steer the backbone model to learn with less forgetting and to achieve effective knowledge sharing, thus significantly enhancing the effectiveness of continual learning. Moreover, we introduce Split ImageNet-R, a new CL benchmark based on ImageNet-R \cite{hendrycks2020many} to the community. The intra-class diversity for each task in Split ImageNet-R is large (see Appendix~\ref{app:split_imr} for representative examples), thus a small buffer is not sufficient to represent past experiences. Figure~\ref{fig:intro} showcases that the size of rehearsal buffer needed is non-trivial for even advanced methods to perform well. While rehearsal-based methods require a large buffer (up to $20\%$ of total training data) to achieve a competitive average accuracy, our method DualPrompt\xspace shows superior performance despite not using any rehearsal buffer. In summary, our work makes the following contributions: \begin{itemize} \item We propose DualPrompt\xspace, a simple and effective rehearsal-free CL method, comprised of G-Prompt\xspace and E-Prompt\xspace for learning task-invariant and task-specific knowledge, respectively. The method is fairly simple to apply without data or memory access concerns which is favorable for real-world CL scenarios. \item DualPrompt\xspace explores various design choices to incorporate these two types of prompts into the pre-trained models. For the first time, we empirically discover that properly attaching prompts to the backbone model is crucial to the effectiveness of continual learning. \item We introduce a new CL benchmark, Split ImageNet-R to help validate the method. DualPrompt\xspace sets new state-of-the-art performance on multiple benchmarks under the challenging class-incremental setting, and beats rehearsal-based methods with relatively large buffer size. \end{itemize} \section{Related work} \textbf{Continual learning.} We discuss three related categories of continual learning methods: regularization-based, rehearsal-based and architecture-based methods. \textit{Regularization-based methods} \cite{kirkpatrick2017overcoming,zenke2017continual,li2017learning,aljundi2018memory} address catastrophic forgetting by regularizing important parameters for learned tasks. Although these methods mitigate forgetting under simpler task-incremental setting, their performance under more challenging class-incremental setting \cite{mai2021online}, or more challenging datasets \cite{wu2019large} is not satisfactory. \textit{Architecture-based methods} assign isolated parameters for each task. These methods can be further categorized as expanding the model \cite{rusu2016progressive,yoon2017lifelong,li2019learn,loo2020generalized,zhao2022deep}, or dividing the model \cite{mallya2018packnet,serra2018overcoming,wang2020learn,ke2020continual,ebrahimi2020adversarial}. However, a major part of the work is limited to the task-incremental setting \cite{serra2018overcoming,mallya2018packnet,mallya2018piggyback,ke2020continual}, while other work only considers specific convolutional-based architectures \cite{wortsman2020supermasks,pham2020contextual,ebrahimi2020adversarial}. However, DualPrompt\xspace aims at more challenging class-incremental setting, and focus on pre-trained transformer-based models. Moreover, architecture-based method generally require substantially large amount of additional parameters to assist model separation \cite{wang2020learn,ke2020continual,yan2021dynamically}. On the contrary, DualPrompt\xspace is much lightweight and only require negligible amount of parameters ($0.2\% - 0.6\%$ of full model size). \textit{Rehearsal-based methods} save data from learned tasks in a rehearsal buffer to train with the current task. Although these methods share this quite simple idea, they are very effective even in the class-incremental setting. Several advanced rehearsal-base methods achieve state-of-the-art performance \cite{buzzega2020dark,cha2021co2l}. However, rehearsal-based methods deteriorates when buffer size \cite{cha2021co2l} decreases, and are eventually not applicable to data privacy sensitive scenarios \cite{shokri2015privacy}. Some recent methods are inspired from the Complementary Learning Systems (CLS). However, ACL~\cite{ebrahimi2020adversarial} is limited to the task-incremental setting, DualNet~\cite{pham2021dualnet} requires specific architecture design, and both methods still rely on a rehearsal buffer to work well. Our DualPrompt\xspace tackles continual learning from a rehearsal-free perspective, standing upon a wise utilization of pre-trained models, thus getting rid of the shortcomings of rehearsal-based methods. \noindent \textbf{Prompt-based learning.} As an emerging transfer learning technique in natural language processing (NLP), prompt-based learning (or prompting), applies a fixed function to condition the model, so that the language model gets additional instructions to perform the downstream task. However, the design of a prompting function is challenging and requires heuristics. To this end, recent work propose to apply prompts as learnable parameters, achieving outstanding performance on transfer learning \cite{lester2021power,li2021prefix}. Prompts capture task-specific knowledge with much smaller additional parameters, than its competitors, such as Adapter~\cite{wang2020k,pfeiffer2020adapterfusion} and LoRA~\cite{hu2021lora}. As discussed above, L2P \cite{wang2021learning} is the only work that connects prompting and continual learning. Differently, DualPrompt\xspace takes inspiration from CLS and presents a different approach to attach complementary prompts to the pre-trained backbone to learn task-invariant and task-specific instructions. We show DualPrompt\xspace outperforms L2P consistently. \section{Prerequisites} \subsection{Continual learning problem setting} Continual learning is defined as training machine learning models on a continuum of data from a sequence of tasks. We denote the sequence of tasks as $\mathcal{D} = \{\mathcal{D}_1, \cdots, \mathcal{D}_T\}$, where the $t$-th task $\mathcal{D}_t=\{({\bm{x}}_{i, t}, y_{i, t})\}_{i=1}^{n_t}$ contains tuples of the input sample ${\bm{x}}_{i, t} \in \mathcal{X}$ and its corresponding label $y_{i, t} \in \mathcal{Y}$. The model $f_\theta: \mathcal{X} \to \mathcal{Y}$ is parameterized by $\theta$, such that it predicts the label $y = f_\theta({\bm{x}}) \in \mathcal{Y}$ given an unseen test sample ${\bm{x}}$ from arbitrary tasks. Data from the previous tasks is not available when training future tasks. We use the widely-adopted assumption that the task boundaries are clear and the task switch is sudden at training time \cite{chaudhry2018efficient,pham2021dualnet}. Moreover, we consider the more challenging class-incremental learning~\cite{chaudhry2018efficient} setting, \emph{i.e.}, task identity is unknown for each example at test time. Also, following the settings in prior work \cite{wang2021learning}, we assume a pre-trained sequence model, \emph{e.g.}, a vision transformer (ViT) \cite{vit,zhang2021aggregating} on ImageNet, is available, a wide-used assumption in recent literature of the computer vision community. Unlike many rehearsal-based methods \cite{chaudhry2019tiny,buzzega2020dark}, we do not assume any form of rehearsal buffer as a prerequisite. \subsection{Prompt-based learning} \label{sec:prompt} Prompt-based learning (or prompting) was first proposed in NLP for transfer learning. The main idea of prompting is to add extra instruction for pre-trained models to perform downstream tasks conditionally \cite{liu2021pre}. Prompt Tuning~\cite{lester2021power}, one of the recent emerging techniques, proposes to attach a set of prompt parameters to frozen transformer-based language models \cite{raffel2020exploring} to perform downstream NLP tasks. The prompts are usually prepended to the input sequence to instruct the model prediction. We briefly illustrate the idea of Prompt Tuning below. As we mainly focus on vision-related continual learning setting, here we introduce the definition of Prompt Tuning using the ViT based sequence models~\cite{dosovitskiy2020image,vaswani2017attention}. In ViT, the input embedding layer transforms the input image into a sequence-like output feature ${\bm{h}} \in {\mathbb{R}} ^{L \times D}$, where $L$ is the sequence length and $D$ is the embedding dimension. When solving downstream tasks, the pre-trained backbone is kept frozen as a general feature extractor, and the prompt parameters ${\bm{p}} \in {\mathbb{R}} ^{L_{{\bm{p}}} \times D}$ with sequence length $L_{{\bm{p}}}$ and embedding dimension $D$ are prepended to the embedding feature along the sequence length dimension to form the extended embedding feature. Finally, the extended feature is sent to the rest of the model for performing classification tasks. Prompt serves as a lightweight module to encode high-level instruction to instruct the backbone to leverage pre-trained representations for downstream tasks. \begin{figure*}[t] \centering \includegraphics[width=0.95\linewidth]{figures/method.pdf} \caption{Overview of DualPrompt\xspace. \textbf{Left}: At test time, an input is transformed by a query function to match the closest task key ${\bm{k}}_t$ and the corresponding E-Prompt\xspace ${\bm{e}}_t$. Then the shared G(eneral)-Prompt ${\bm{g}}$ and the matched E(xpert)-Prompt ${\bm{e}}_t$ are attached to multiple MSA layers of a pre-trained transformer. At training time, the E-Prompt\xspace is selected by task identity and the selected E-Prompt\xspace and G-Prompt\xspace are trained together with the classifier. \textbf{Right}: A prompting function is illustrated where the G-prompt is split equally and attached to the key and value replicas of the hidden feature (see Section~\ref{sec:combiner}) before passing them to the preceding MSA layer. } \label{fig:overview} \end{figure*} \section{DualPrompt\xspace} Our proposed method, DualPrompt\xspace is illustrated in Figure~\ref{fig:overview}. We first introduce the complementary learning components, G- and E-prompts, in Section~\ref{sec:g-e-prompt} by showcasing how they work with a single multi-head self-attention (MSA) layer. We then explore design choices of attaching prompts to the backbone Section~\ref{sec:combiner}. We finally present the overall objective for DualPrompt\xspace in Section~\ref{sec:main_obj}. \subsection{Complementary G-Prompt and E-Prompt} \label{sec:g-e-prompt} Given a pre-trained ViT $f$ with $N$ consecutive MSA layers, we further extend the notations introduced in \ref{sec:prompt} by denoting the input embedding feature of the $i$-th MSA layer as ${\bm{h}}^{(i)}, i = 1, 2, \cdots, N$. \textbf{G-Prompt\xspace:} ${\bm{g}} \in \mathbb{R}^{L_g \times D}$ with sequence length $L_g$ and embedding dimension $D$, is a shared parameter for all tasks. Suppose we would like to attach G-Prompt\xspace to the $i$-th MSA layer, G-Prompt\xspace transforms ${\bm{h}}^{(i)}$ via a \emph{prompting function}: \begin{equation} \label{eq:gprompt} {\bm{h}}_g^{(i)} = {f_{\text{prompt}}} \left({\bm{g}}, {\bm{h}}^{(i)}\right), \end{equation} where ${f_{\text{prompt}}}$ defines the approach how to attach the prompts to the hidden embeddings. Section~\ref{sec:combiner} discusses the details. \textbf{E-Prompt\xspace:} $\mathbf{E} = \{{\bm{e}}_t\}_{t=1}^{T}$ is a set of task-dependent parameters, where ${\bm{e}}_t \in \mathbb{R}^{L_e \times D}$ has a sequence length of $L_e$ and the same embedding dimension $D$ as the G-Prompt\xspace, and $T$ is the total number of tasks. Different from the shared G-Prompt\xspace, each ${\bm{e}}_t$ is associated with a task-specific key ${\bm{k}}_t \in \mathbb{R}^{D}$, which is also a learnable parameter that aims to capture representative features of a task. For an input example from the $t$-th task, to attach E-Prompt\xspace to the $j$-th MSA layer, we apply the prompting function in a similar way: \begin{equation} \label{eq:eprompt} {\bm{h}}_e^{(j)} = {f_{\text{prompt}}} \left({\bm{e}}_t, {\bm{h}}^{(j)}\right). \end{equation} Moreover, we update the corresponding ${\bm{k}}_t$ to match the feature of the input instance via a matching loss $\mathcal{L}_{\text{match}}$, such that ${\bm{k}}_t$ becomes ``closer'' to examples from the $t$-th task than other keys. At test time, inspired by the strategy proposed in \cite{wang2021learning}, we propose to adopt a query function $q$ on the test sample to search for the best match from the task keys, and select the corresponding E-Prompt\xspace to use. Although it is interesting to design various matching and query strategies by introducing additional components, it actually violates the principle of parsimony in continual learning \cite{hadsell2020embracing,wang2020learn}. Fortunately, as suggested in \cite{wang2021learning}, we can directly use the whole pre-trained model as the query function: $q({\bm{x}}) = f({\bm{x}})[0]$ (the feature vector corresponding to \verb|[class]| token~\cite{dosovitskiy2020image}), and cosine similarity as $\gamma$. Thus, the matching loss takes the following form: \begin{equation} \label{eq:match_loss} \mathcal{L}_{\text{match}}({\bm{x}}, {\bm{k}}_t) = \gamma(q({\bm{x}}), {\bm{k}}_t), \quad {\bm{x}} \in \mathcal{D}_t. \end{equation} For a test example ${\bm{x}}$, we simply choose the best matched task key index via ${\operatorname{argmin}}_{t}\ \gamma(q({\bm{x}}), {\bm{k}}_t)$. We show the relationship between query accuracy and final performance in Appendix~\ref{app:perfect_match}. We empirically discover this matching loss and the corresponding query mechanism works fairly well for all benchmarks. \subsection{Prompt attaching: where and how?}\label{sec:combiner} G- and E-prompts encode respective type of instructions during training with the backbone and cooperatively instruct the model to make predictions at inference. We have showcased how to attach them to a single MSA layer in Section~\ref{sec:g-e-prompt}. Most existing prompt-related work simply place prompts only at the first MSA~\cite{wang2021learning,lester2021power}, or at every MSA layer~\cite{li2021prefix,liu2021p}. However, we argue that it is crucial to explore \emph{where} and \emph{how} to attach both types of prompts, under the continual visual learning setting. We motivate our design choices below. \textbf{Where: Decoupled prompt positions.} Intuitively, different layers of the backbone have different levels of feature abstraction~\cite{raghu2021vision}. Therefore, when learning tasks sequentially, some layers of representations can have higher responses to task-specific knowledge than others, vise versa for task-invariant knowledge. This motivates us to give the two types of prompts more flexibility to attach to the most proper positions in a decoupled way, thus different instructions can interact with the corresponding representations more effectively. With a slight abuse of notation, we introduce the multi-layered extension of both types of prompts: ${\bm{g}} = \{{\bm{g}}^{(l)}\}_{l=\texttt{start}_{\vg}}^{\texttt{end}_{\vg}}$, where ${\bm{g}}^{(l)} \in \mathbb{R}^{L_g \times D}$ is the G-Prompt to be attached to the $l$-th MSA layer. We also define ${\bm{e}}_t = \{{\bm{e}}^{(l)}_t\}_{l=\texttt{start}_{\ve}}^{\texttt{end}_{\ve}}$ similarly. In this way, we are able to attach the G-Prompt\xspace ${\bm{g}}^{(l)}$ from the $\texttt{start}_{\vg}$-th to the $\texttt{end}_{\vg}$-th MSA layers, and attach the E-Prompt\xspace ${\bm{e}}^{(l)}_t$ from the $\texttt{start}_{\ve}$-th to the $\texttt{end}_{\ve}$-th MSA layers. And most importantly, $(\texttt{start}_{\vg}, \texttt{end}_{\vg})$ and $(\texttt{start}_{\ve}, \texttt{end}_{\ve})$ could be totally different or non-overlapping. In our experiments, we empirically search for a certain set of $\texttt{start}_{\vg}, \texttt{end}_{\vg}, \texttt{start}_{\ve}, \texttt{end}_{\ve}$ on a validation set and discover that it performs consistently well across different benchmarks. Note that we make a simplified assumption that the chosen indices of MSA layers to attach prompts are contiguous, which already achieves state-of-the-art performance in our empirical evaluation. However, there could be more advanced ways to auto-search the configuration even for the non-contiguous setting, which we treat as valuable future work. \textbf{How: Configurable prompting function.} The prompting function ${f_{\text{prompt}}}$ controls the way we combine prompts with the embedding features. From another perspective, ${f_{\text{prompt}}}$ directly affects how the high-level instructions in prompts interact with low-level representations. Thus, we believe a well-designed prompting function is also vital for the overall continual learning performance. Although DualPrompt\xspace is compatible with various prompting functions, here we exemplify and study two mainstream realizations in the NLP community - Prompt Tuning (Pro-T)~\cite{lester2021power} and Prefix Tuning (Pre-T)~\cite{li2021prefix}. Specifically, applying a prompting function can be viewed as modifying the inputs of the MSA layers \cite{vaswani2017attention}. Let the input to the MSA layer be ${\bm{h}} \in \mathbb{R}^{L \times D}$, and we further denote the input query, key, and values for the MSA layer to be ${\bm{h}}_Q, {\bm{h}}_K, {\bm{h}}_V$, respectively. Recall that the MSA layer is proposed by \cite{vaswani2017attention}: \begin{equation*} \begin{aligned} &\operatorname{ MSA }({\bm{h}}_Q, {\bm{h}}_K, {\bm{h}}_V) =\operatorname { Concat }\left(\operatorname { h }_{1}, \ldots, \operatorname { h }_{\mathrm{m}}\right) W^{O} \\ &\text { where} \operatorname{h}_{\mathrm{i}} =\operatorname{Attention}\left({\bm{h}}_Q W_{i}^{Q}, {\bm{h}}_K W_{i}^{K}, {\bm{h}}_V W_{i}^{V}\right), \end{aligned} \end{equation*} where $W^{O}$, $W_{i}^{Q}$, $W_{i}^{K}$, and $W_{i}^{V}$ are projection matrices. $m$ is the number of heads. In ViT, ${\bm{h}}_Q = {\bm{h}}_K = {\bm{h}}_V$. For simplicity, we define a unified prompt parameter ${\bm{p}} \in \mathbb{R}^{L_{p} \times D}$ (${\bm{p}}$ could be either single-layered G or E-Prompt). \textbf{Prompt Tuning (Pro-T)} prepends prompts to the input tokens, which is equivalent to concatenate the same prompt parameter ${\bm{p}}$ to ${\bm{h}}_Q$, ${\bm{h}}_K$, and ${\bm{h}}_V$, \begin{equation} f_{\operatorname{prompt}}^{\operatorname{{Pro-T}}}({\bm{p}}, {\bm{h}}) = \operatorname{ MSA }([{\bm{p}};{\bm{h}}_Q], [{\bm{p}};{\bm{h}}_K], [{\bm{p}};{\bm{h}}_V]), \end{equation} where $[\cdot;\cdot]$ defines the concatenation operation along the sequence length dimension. The output length increases, resulting the output dimension as $\mathbb{R}^{(L+L_p) \times D}$. The operation is equivalent to how \verb|[class]| is added \cite{dosovitskiy2020image} at the first MSA layer. \textbf{Prefix Tuning (Pre-T)} splits ${\bm{p}}$ into ${\bm{p}}_K, {\bm{p}}_V \in \mathbb{R}^{L_p/2 \times D}$, and prepends them to to ${\bm{h}}_K$ and ${\bm{h}}_V$ respectively, while keep ${\bm{h}}_Q$ as-is: \begin{equation} f_{\operatorname{prompt}}^{\operatorname{{Pre-T}}}({\bm{p}}, {\bm{h}}) = \operatorname{ MSA }({\bm{h}}_Q, [{\bm{p}}_k;{\bm{h}}_K], [{\bm{p}}_v;{\bm{h}}_V]). \end{equation} Compared with Pro-T, the output sequence length remains the same as input ${\bm{h}} \in \mathbb{R}^{L \times D}$. Section~\ref{sec:exp-combiner} studies both versions empirically and discusses the intuition behind their difference in performance from a continual learning perspective. \subsection{Overall objective for DualPrompt\xspace} \label{sec:main_obj} The full picture of DualPrompt\xspace at training and test time is described in Algorithm~\ref{alg:dualprompt_train} and~\ref{alg:dualprompt_test}, respectively, in Appendix~\ref{app:algorithm}. Following the design patterns discussed in Section~\ref{sec:combiner}, we denote the architecture with prompts attached by $f_{{\bm{g}}, {\bm{e}}_t}$. Then we transform our input ${\bm{x}}$ from the $t$-th task via $f_{{\bm{g}}, {\bm{e}}_t}$ and send it to the classification head $f_\phi$ parametrized by $\phi$ for prediction. Finally, we train both types of prompts, the task keys, as well as the newly-initialized classification head in an end-to-end fashion: \begin{equation} \label{eq:full_loss} \underset{{\bm{g}}, {\bm{e}}_t, {\bm{k}}_t, \phi}{\operatorname{min}} \mathcal{L}(f_\phi(f_{{\bm{g}}, {\bm{e}}_t}({\bm{x}})), y) + \lambda \mathcal{L}_{\text{match}} \left({\bm{x}}, {\bm{k}}_t \right), \quad {\bm{x}} \in \mathcal{D}_t, \end{equation} where $\mathcal{L}$ is the cross-entropy loss, $\mathcal{L}_{\text{match}}$ is the matching loss defined in~\eqref{eq:match_loss}, and $\lambda$ is a scalar balancing factor. \section{Experiments} \subsection{Evaluation benchmarks} \textbf{Split ImageNet-R}. The Split ImageNet-R benchmark is build upon ImageNet-R \cite{hendrycks2020many} by dividing the 200 classes randomly into 10 tasks with 20 classes per task. We split the dataset into training and test set with 24,000 and 6,000 images respectively. We further sample $20\%$ from the training set as validation data for prompt attaching design search. The original ImageNet-R includes newly collected data of different styles, such as cartoon, graffiti and origami, as well as hard examples from ImageNet~\cite{deng2009imagenet} that standard models, \emph{e.g.}, ResNet~\cite{he2016deep}, fail to classify. We believe the Split ImageNet-R is of great importance to the continual learning community, for the following reasons: 1) Split ImageNet-R contains classes with different styles, which is closer to the complicated real-world problems. 2) The significant intra-class diversity (see Appendix~\ref{app:split_imr}) poses a great challenge for rehearsal-based methods to work effectively with a small buffer size (see Figure~\ref{fig:intro}), thus encouraging the development of more practical, rehearsal-free methods. 3) Pre-trained vision models are useful in practice for many fields \cite{ridnik2021imagenet,kolesnikov2020big}, including continual learning. However, their training set usually includes ImageNet. Thus, Split ImageNet-R serves as a relative fair and challenging benchmark, and an alternative to ImageNet-based benchmarks \cite{rebuffi2017icarl,wu2019large} for continual learning that uses pre-trained models. \textbf{Split CIFAR-100.} Split CIFAR-100 is a widely-used benchmark in continual learning literature. It splits the original CIFAR-100 \cite{krizhevsky2009learning} into 10 disjoint tasks, with 10 classes per task. Although it is a relatively simple task for image classification under the i.i.d. setting, it sufficiently makes advanced CL methods expose large forgetting rate in class-incremental learning. \textbf{5-datasets.} 5-datasets is a collection of five diverse image classification datasets, CIFAR-10~\cite{krizhevsky2009learning}, MNIST~\cite{lecun1998mnist}, Fashion-MNIST~\cite{xiao2017fashion}, SVHN~\cite{netzer2011reading}, and notMNIST~\cite{notmnist}. Despite the simplicity of each task in 5-datasets, the benchmark mimics the real-world setting where task diversity is large, thus contributing to a more comprehensive evaluation of CL methods. We use Split ImageNet-R and Split CIFAR-100 to demonstrate our main results in Section~\ref{sec:exp-class-inc}, and additionally conduct experiments on 5-datasets for completeness in the Appendix~\ref{app:5-datasets}. \subsection{Comparison with state-of-the-arts} \label{sec:exp-class-inc} We compare DualPrompt\xspace against representative baselines and state-of-the-art methods. Please refer to Appendix~\ref{app:exp_details} for experimental details. We use the widely-used \emph{Average accuracy} (higher is better) and \emph{Forgetting} (lower is better)~\cite{lopez2017gradient,chaudhry2018efficient,mai2021online} as our evaluation metrics. The definitions of both metrics are in Appendix~\ref{app:eval_metrics}. To make the comparison fair and precise, we first compare DualPrompt\xspace with regularization-, rehearsal- and prompt-based methods, which are compatible with transformer-based models, in Table~\ref{table:cifar_imagenet}. We then compare DualPrompt\xspace with architecture-based methods, which are mostly compatible with ConvNets, using a different protocol in Table~\ref{table:architecture}. \begin{itemize} \item \textbf{Regularization-based methods.} \textsf{EWC} \cite{kirkpatrick2017overcoming} and \textsf{LwF} \cite{li2017learning} are representative regularization-based methods that are widely compared. \item \textbf{Rehearsal-based methods.} \textsf{ER} \cite{chaudhry2019tiny,hayes2019memory}, \textsf{GDumb} \cite{prabhu2020gdumb}, \textsf{BiC} \cite{wu2019large}, \textsf{DER++} \cite{buzzega2020dark} and \textsf{Co$^2$L} \cite{cha2021co2l}. As earlier methods, ER and GDumb achieve very strong performance not only in their own work, but in later literature \cite{mai2021online,buzzega2020dark} as well. BiC is also a strong method in the class-incremental learning setting. DER++ and Co$^2$L are the latest SOTA methods. We chose a medium and a large buffer size for these rehearsal-based methods, based on recommendation of prior work~\cite{buzzega2020dark,mehtaempirical,cha2021co2l,wang2021learning}. \item \textbf{Prompt-based method.} \textsf{L2P} is the current state-of-the-art prompt-based method, we configure DualPrompt\xspace to have the similar amount of additional parameters as L2P for fair comparison. \item \textbf{Naive baselines.} For better demonstration of the relative effectiveness of all methods, we also include: \textsf{FT-seq}, the naive sequential training, and \textsf{Upper-bound}, the usual supervised finetuning on the i.i.d.~data of all tasks. \end{itemize} To ensure fair comparison, every aforementioned methods start from the same ImageNet pre-trained ViT-B/16 \cite{vit}, following the setting in~\cite{wang2021learning}. We carefully re-implement these method and use hyper-parameters by referring to their original source code. Moreover, we make the pre-trained model fully trainable for all methods (except L2P and DualPrompt\xspace), as we empirically observe they could not learn as good with a frozen backbone due to limited learning capacity. \begin{table*}[t!] \caption{Results on class-incremental learning (i.e., task identity is unknown at test time). We compare and group methods by buffer sizes. 0 means no rehearsal is used, when most SOTA methods are not applicable anymore. Note that the chosen buffer sizes here are considered sufficiently large sizes that are used in prior works for Split CIFAR-100 \cite{chaudhry2018efficient,buzzega2020dark}. They are large enough even for training a supervised counterpart -- e.g. GDumb~\cite{prabhu2020gdumb} trains on the i.i.d sampled buffer with this size and demonstrated competitive results, making continual training unnecessary. } \label{table:cifar_imagenet} \begin{center} \scalebox{0.8}{ \begin{tabular}{l||c|cc||c|cc} \toprule \multirow{2}{*}{\textbf{Method}} & \multirow{2}{*}{\textbf{Buffer size}} & \multicolumn{2}{c||}{\textbf{Split CIFAR-100}} & \multirow{2}{*}{\textbf{Buffer size}} & \multicolumn{2}{c}{\textbf{Split ImageNet-R}} \\ & & Avg. Acc ($\uparrow$) & Forgetting ($\downarrow$) & & Avg. Acc ($\uparrow$) & Forgetting ($\downarrow$) \\ \midrule ER \cite{chaudhry2019tiny} & \multirow{6}{*}{1000} & 67.87\scriptsize{$\pm$0.57} & 33.33\scriptsize{$\pm$1.28} & \multirow{6}{*}{1000} & {55.13\scriptsize{$\pm$1.29}} & 35.38\scriptsize{$\pm$0.52} \\ BiC \cite{wu2019large} & & 66.11\scriptsize{$\pm$1.76} & 35.24\scriptsize{$\pm$1.64} && 52.14\scriptsize{$\pm$1.08} & 36.70\scriptsize{$\pm$1.05} \\ GDumb \cite{prabhu2020gdumb} & & 67.14\scriptsize{$\pm$0.37} & - && 38.32\scriptsize{$\pm$0.55} & - \\ DER++ \cite{buzzega2020dark} & & 61.06\scriptsize{$\pm$0.87} & 39.87\scriptsize{$\pm$0.99} && 55.47\scriptsize{$\pm$1.31} & 34.64\scriptsize{$\pm$1.50} \\ Co$^2$L \cite{cha2021co2l} & & 72.15\scriptsize{$\pm$1.32} & 28.55\scriptsize{$\pm$1.56} && 53.45\scriptsize{$\pm$1.55} & 37.30\scriptsize{$\pm$1.81} \\ \midrule ER \cite{chaudhry2019tiny} &\multirow{6}{*}{5000 }& 82.53\scriptsize{$\pm$0.17} & 16.46\scriptsize{$\pm$0.25} &\multirow{6}{*}{5000 }& 65.18\scriptsize{$\pm$0.40} & 23.31\scriptsize{$\pm$0.89} \\ BiC \cite{wu2019large} & & 81.42\scriptsize{$\pm$0.85} & 17.31\scriptsize{$\pm$1.02} && 64.63\scriptsize{$\pm$1.27} & 22.25\scriptsize{$\pm$1.73} \\ GDumb \cite{prabhu2020gdumb} & & 81.67\scriptsize{$\pm$0.02} & - && 65.90\scriptsize{$\pm$0.28} & - \\ DER++ \cite{buzzega2020dark} & & 83.94\scriptsize{$\pm$0.34} & 14.55\scriptsize{$\pm$0.73} && 66.73\scriptsize{$\pm$0.87} & 20.67\scriptsize{$\pm$1.24} \\ Co$^2$L \cite{cha2021co2l} & & 82.49\scriptsize{$\pm$0.89} & 17.48\scriptsize{$\pm$1.80} && 65.90\scriptsize{$\pm$0.14} & 23.36\scriptsize{$\pm$0.71} \\ \midrule FT-seq & \multirow{5}{*}{0} & 33.61\scriptsize{$\pm$0.85} & 86.87\scriptsize{$\pm$0.20} & \multirow{5}{*}{0} & 28.87\scriptsize{$\pm$1.36} & 63.80\scriptsize{$\pm$1.50}\\ EWC \cite{kirkpatrick2017overcoming} & & 47.01\scriptsize{$\pm$0.29} & 33.27\scriptsize{$\pm$1.17} && 35.00\scriptsize{$\pm$0.43} & 56.16\scriptsize{$\pm$0.88} \\ LwF \cite{li2017learning} & & 60.69\scriptsize{$\pm$0.63} & 27.77\scriptsize{$\pm$2.17} && 38.54\scriptsize{$\pm$1.23} & 52.37\scriptsize{$\pm$0.64} \\ {L2P} \cite{wang2021learning} & & {83.86\scriptsize{$\pm$0.28}} & {7.35\scriptsize{$\pm$0.38}} &&{61.57\scriptsize{$\pm$0.66}} & {9.73\scriptsize{$\pm$0.47}} \\ \bf{DualPrompt\xspace} & & \bf 86.51\scriptsize{$\pm$0.33} & \bf 5.16\scriptsize{$\pm$0.09} & & \bf 68.13\scriptsize{$\pm$0.49} & \bf 4.68\scriptsize{$\pm$0.20} \\ \midrule Upper-bound & -& 90.85\scriptsize{$\pm$0.12} & - & - & 79.13\scriptsize{$\pm$0.18} & - \\ \bottomrule \end{tabular} } \end{center} \end{table*} Table~\ref{table:cifar_imagenet} reports the performance of all comparing methods on Split CIFAR-100 and Split ImageNet-R. Our proposed method, DualPrompt\xspace, outperforms all methods consistently, including non-rehearsal based methods and rehearsal-based methods with a large buffer size. When the buffer size is 5000 (10\% of the CIFAR-100 training set and $>$20\% of the ImageNet-R training set), all rehearsal-based methods are fairly close to GDumb, indicating that performing rehearsal-based continual learning likely provide no performance gain than supervised training on the buffered data as GDumb does. \textit{DualPrompt\xspace achieves better performance without any buffered data}. Moreover, from Table~\ref{table:cifar_imagenet}, as well as Figure~\ref{fig:intro}, we can observe the performance of rehearsal-based methods drops sharply when the buffer size shrinks. This again suggests the clear advantage of DualPrompt\xspace as a rehearsal-free method. For the non-rehearsal based methods, only L2P performs close to our methods. Nevertheless, DualPrompt\xspace still beats L2P significantly by a 3\%-7\% margin on Average accuracy, thanks to our novel design of the two complementary prompts, which successfully reduces catastrophic forgetting. \begin{table*}[t!] \small \caption{ Comparison with architecture-based methods on Split CIFAR-100. We use \texttt{Diff = Upper-Bound Acc - Method Acc} (lower is better), to measure how close the performance to the upper-bound of the used backbone.} \label{table:architecture} \begin{minipage}{0.98\textwidth} \begin{center} \scalebox{0.9}{ \begin{tabular}{l|c|lc|c|>{\centering\arraybackslash}p{1.8cm}>{\centering\arraybackslash}p{1.8cm}} \toprule \multirow{2}{*}{\textbf{Method}} & \multirow{2}{*}{\textbf{Backbone}} & \multirow{2}{*}{\textbf{Avg. Acc ($\uparrow$)}} & \multirow{2}{*}{\textbf{Diff ($\downarrow$)}} & \multirow{2}{*}{\textbf{Buffer size}} & \multicolumn{2}{c}{\textbf{Additional Parameters}} \\ & & & & & MB & \% \\ \midrule Upper-bound & \multirow{5}{*}{ResNet18}& 80.41$^\dagger$ & - & - & - & - \\ SupSup~\cite{wortsman2020supermasks} & & 28.34\scriptsize{$\pm$2.45}$^\ddagger$ & 52.07 & 0 & 3.0 & 6.5\% \\ DualNet~\cite{pham2021dualnet} & & 40.14\scriptsize{$\pm$1.64}$^\ddagger$ & 40.27 & 1000 & 5.04 & 10.9\% \\ RPSNet~\cite{rajasegaran2019random} & & 68.60$^\dagger$ & 11.81 & 2000 & 181 & 404\% \\ DynaER~\cite{yan2021dynamically} & & 74.64$^\dagger$ & 5.77 & 2000 & 19.8 & 43.8\% \\ \midrule Upper-bound & \multirow{2}{*}{ResNet152}& 88.54$^\dagger$ & - & - & - & - \\ DynaER~\cite{yan2021dynamically} & & 71.01\scriptsize{$\pm$0.58}$^\ddagger$ & 17.53 & 2000 & 159 & 68.5\% \\ \midrule Upper-bound & \multirow{3}{*}{ViT-B/16}& 90.85\scriptsize{$\pm$0.12}$^\ddagger$ & - & - & - & - \\ {L2P} \cite{wang2021learning} & & {83.86\scriptsize{$\pm$0.28}}$^\ddagger$ & 6.99 & 0 & 1.94 & 0.56\% \\ \bf{DualPrompt\xspace} & & \bf 86.51\scriptsize{$\pm$0.33} & \bf 4.34 & 0 & \bf 1.90 & \bf 0.55\% \\ \bottomrule \end{tabular} } \\ \scriptsize{$^\dagger$Reported by the original papers. $^\ddagger$ Reproduced using their original codebases.} \end{center} \end{minipage} \end{table*} \textbf{Architecture-based methods.} We compare against representative class-incremental learning methods, including DualNet~\cite{pham2021dualnet}, SupSup~\cite{wortsman2020supermasks}, DynaER~\cite{yan2021dynamically} and RPSNet~\cite{rajasegaran2019random}. All these methods are based on ResNet-18, as recommended in the original work. We either directly taken reported results in their original work or strictly follow the original implementation and hyper-parameter settings of these methods to reproduce the results. Some other well-known methods \cite{ke2020continual,ebrahimi2020adversarial,pham2020contextual} are not compared here because they either have been outperformed by our compared methods or only verified on simpler task-incremental setting. Prior architecture-based methods, which are based on ConvNet, are not trivial to migrate to transformer-based models. Moreover, different architecture-based methods usually add different amount of additional parameters. To enable a relative fair comparison between these methods, we introduce a metric to measure how close the performance of a certain method is to the upper-bound performance, \emph{i.e.} trained under the i.i.d. setting, of a given architecture. Table~\ref{table:architecture} shows the results on Split-CIFAR100. DualPrompt\xspace achieves the best accuracy and its difference to upper-bound is only $4.34\%$, with minimal additional parameters and no buffer. The strongest competitor on ResNet, DynaER, on the contrary, requires a buffer of $2,000$ images and include $43.8\%$ additional parameters. \subsection{Does stronger backbones naively improve CL?} Our method builds upon more advanced yet bigger backbones than many previous methods. We think understand this question is very important for fair comparison and future research. Although pre-trained ViT is a stronger backbone than common ConvNets, it is not necessarily translate to continual learning performance. The observations we shown here are similar to what reported in a very recent study about how large architecture help continual learning~\cite{mirzadeh2022architecture}. First, this fact can be seen from Table \ref{table:cifar_imagenet}, where well-known general methods still suffer large forgetting rate given this backbone. % We have tried to use ImageNet pre-trained ResNet for competing methods in Table~\ref{table:architecture}, which leads to no improvement upon the reported numbers in Table~\ref{table:architecture}. This further indicates that a pre-trained model is not a ``panacea'' for continual learning without being leveraged properly. We also equip best-performing DynaER~\cite{yan2021dynamically} with ImageNet pre-trained ResNet152 (60M parameters), which has close upper-bound performance to ViT-B/16 (86M). DynaER learns weight masks, a popular strategy for architecture-based methods \cite{wortsman2020supermasks}, to dynamically expand architectures. However, results in Table~\ref{table:architecture} show worse performance (we sweep their suggested hyper-parameters to report the best performance), a similar observation is shown in their original paper when scaling DynaER to ResNet32. That being said, how to effectively utilize large models under traditional architecture-based methods remains an open question. DualPrompt\xspace is novel at wisely leveraging the state-of-the-art vision backbones to solve challenges in continual learning. \subsection{Exploration of where and how to attach prompts} \label{sec:exp-combiner} We have shown the best performing model of DualPrompt\xspace in Section~\ref{sec:exp-class-inc}. In this section, we explore \textit{where and how} to attach prompts and enhance their influences to the overall performance. We also present critical empirical observations that lead to interesting future research. \noindent \textbf{Position of prompts.} To explore the most proper position to insert the G-Prompt\xspace and E-Prompt\xspace, we use a heuristic search strategy on the validation set of Split ImageNet-R. We first set $\texttt{start}_{\ve} = \texttt{end}_{\ve}$, \emph{i.e.}, only insert E-Prompt\xspace at a single MSA layer. The lower line of Figure~\ref{fig:prompt_depth} shows that placing E-Prompt\xspace at the 5th MSA layer leads to the best performance. We then search extend E-Prompt\xspace to multi-layer and found that $\texttt{start}_{\ve} = 3, \texttt{end}_{\ve} = 5$ performs the best (see Appendix~\ref{app:multi_layer}). We then study the case of $\texttt{start}_{\vg} = \texttt{end}_{\vg}$ based on the optimal setting of E-Prompt\xspace. Interestingly, the upper line of Figure~\ref{fig:prompt_depth} shows that placing G-Prompt\xspace at the 2nd MSA layer leads to the best performance. We also extend G-Prompt\xspace into its multi-layered counterparts and conduct searching experiments and find the best choice to be $\texttt{start}_{\vg} = 1, \texttt{end}_{\vg} = 2$ (see Appendix~\ref{app:multi_layer}). Interestingly, we observe that the best depth are different, and the final layers to attach G- and E-Prompts are non-overlapping. In particular, $\texttt{start}_{\vg} > \texttt{start}_{\ve}$, which suggests that G-Prompt\xspace captures task-invariant knowledge better at shallower layer, while E-Prompt\xspace captures task-specific knowledge better at deeper layer. This observation also fits the intuition that different layers in deep learning models capture different types of knowledge~\cite{raghu2021vision,zeiler2014visualizing}, and thus naturally fit different prompts. This also justifies decoupling positions of G- and E-Prompts as a reasonable option. Moreover, when attaching them to top layers, both E-Prompt\xspace and G-Prompt\xspace exhibit the worst performance. We speculate prompts need to be attached to shallower layers in order to condition more layers of the pre-trained model and thereby offer effective instructions. \begin{figure}[t] \centering \begin{minipage}{0.48\textwidth} \centering \includegraphics[width=.9\textwidth]{figures/val_prompt_depth.pdf} \captionof{figure}{Effects of position to attach prompts on Split ImageNet-R validation set. We empirically observe that attaching G- and E-Prompts to the 2nd and 5th MSA layer results in the best performance.} \label{fig:prompt_depth} \end{minipage} \hfill \begin{minipage}{0.48\textwidth} \centering \includegraphics[width=.9\textwidth]{figures/prompt_visualization.pdf} \captionof{figure}{t-SNE visualization of G- and E-prompts. Each point represents a prompt vector of dimension $768$. E-Prompt\xspace{s} are taken from the final model, while G-Prompt\xspace{s} are taken from model snapshots after trained on each task.} \label{fig:prompt_visualization} \end{minipage} \end{figure} \noindent \textbf{Prompting function: Prompt v.s. Prefix.} We further study the role of prompting function on Split CIFAR-100 and Split ImageNet-R. In prior prompt-based CL work, L2P, only Pro-T is applied without further investigation. In Table~\ref{table:prompt_vs_prefix}, we observe that Pre-T version leads to a better performance on both datasets. Besides its empirically better performance, Pre-T is actually more scalable and efficient when attached to multiple layers, since it results in unchanged sequence length. Nevertheless, prompting function is a flexible component of our method, and designing better prompting function is also an open research question, so we can easily plug-in any newly proposed prompting function to DualPrompt\xspace and evaluate its effectiveness on given continual learning tasks. \begin{table}[t] \centering \captionof{table}{Comparison of different prompting functions: Prompt Tuning (Pro-T) v.s. Prefix Tuning (Pre-T).} \scalebox{0.8}{ \begin{tabular}{ >{\centering\arraybackslash}p{1.8cm}|>{\centering\arraybackslash}p{2.2cm}| >{\centering\arraybackslash}p{1.4cm}| >{\centering\arraybackslash}p{1.4cm}} \toprule \multicolumn{2}{c|}{\textbf{Prompting function}} & Pro-T & Pre-T \\ \midrule Split & Avg. Acc ($\uparrow$) & 83.81 & \bf86.51 \\ CIFAR-100 & Forgetting ($\downarrow$) & 5.94 & \bf5.16 \\ \midrule Split & Avg. Acc ($\uparrow$) & 64.99 & \bf68.13 \\ ImageNet-R & Forgetting ($\downarrow$) & 6.81 & \bf4.68 \\ \bottomrule \end{tabular} } \label{table:prompt_vs_prefix} \end{table} \begin{table}[t] \centering \captionof{table}{Ablation study on Split ImageNet-R. ML means multi-layered.} \vspace{0.2cm} \centering \scalebox{0.8}{ \begin{tabular}{ccc|cc} \toprule \multirow{2}{*}{\textbf{G-P}} & \multirow{2}{*}{\textbf{E-P}} & \multirow{2}{*}{\textbf{ML}} & \multicolumn{2}{c}{\textbf{Split ImageNet-R}} \\ & & & Avg. Acc ($\uparrow$) & Forgetting ($\downarrow$) \\ \midrule & & & {27.01} & {7.57} \\ \checkmark & & & 63.41 & 6.52 \\ & \checkmark & & 65.10 & 5.52 \\ \checkmark & \checkmark & & 66.77 & 5.74 \\ \checkmark & & \checkmark & 63.85 & 7.50 \\ & \checkmark & \checkmark & 66.91 & 4.77 \\ \checkmark & \checkmark & \checkmark & \bf68.13 & \bf 4.68\\ \bottomrule \end{tabular} } \label{table:ablation} \end{table} \subsection{Ablation study} \label{sec:ablation} Based on the optimal parameters searched in the previous section, we present the ablation study results in Table~\ref{table:ablation} to show the importance of each component of DualPrompt\xspace on Split ImageNet-R. Note that G-P (G-Prompt\xspace) and E-P (E-Prompt\xspace) alone represent the optimal single-layered version for each type of prompts ($\texttt{start}_{\vg}=\texttt{end}_{\vg}=2, \texttt{start}_{\ve}=\texttt{end}_{\ve}=5$), while ML represents the optimal multi-layered version ($\texttt{start}_{\vg}=1, \texttt{end}_{\vg}=2, \texttt{start}_{\ve}=3, \texttt{end}_{\ve}=5$). When all components are absent, we simply have a naive baseline with a frozen pre-trained backbone and trainable classification head. In general, all components contribute to the final performance. Interestingly, adding a single-layered G-Prompt\xspace alone brings substantial improvement upon the baseline, indicating that the task-invariant knowledge obtained by G-Prompt\xspace generalizes pretty well across tasks. However, simply sharing knowledge between tasks introduces inevitable forgetting, due to the fact that task-specific knowledge is not properly decoupled. Thus, E-Prompt\xspace alone consistently outperforms G-Prompt\xspace alone, since E-Prompt\xspace mitigates forgetting by separating knowledge learned from different tasks. However, only applying E-Prompt\xspace ignores the task-invariant knowledge, which helps to learn future tasks. Thus, when adding G-Prompt\xspace and E-Prompt\xspace together to the backbone, it further enhances the overall performance by selectively decoupling the task-invariant knowledge into G-Prompt\xspace and task-specific knowledge into E-Prompt\xspace. We also observe that extending both prompts to its multi-layered counterparts helps consistently in all cases, due to the fact that properly adding more prompt parameters through different layers offers more representation power. \textbf{Visualization of G- and E-prompts.} To further understand different types of instructions learned within G- and E-prompts, we visualize these two types of prompts using t-SNE~\cite{van2008visualizing} in Figure~\ref{fig:prompt_visualization}. For a prompt with shape $L\times D$, we treat it as $L$ prompts with dimension $D$. E-Prompt\xspace{s} are taken from the final model after trained on the sequence of all tasks, while the G-Prompt\xspace{s} are taken from different model snapshots after training on each task. We can observe that E-Prompt\xspace{s} are well-separated, indicating they are learning task-specific knowledge. Meanwhile, the G-Prompt\xspace{s} are quite centered and only differ slightly between tasks, which suggests they are learning task-invariant knowledge. \section{Conclusion} In this paper, we present a novel method, DualPrompt\xspace, that achieves rehearsal-free continual learning under the challenging class-incremental setting. DualPrompt\xspace presents a novel way to attach complementary prompts to a pre-trained model to learn decoupled knowledge. To comprehensively validate the proposed method, we propose a new continual learning benchmark, Split ImageNet-R, besides study on the widely-used benchmarks. DualPrompt\xspace sets state-of-the-art performance in all metrics, surprisingly needs much lower additional memory compared with previous architecture-based and rehearsal-based methods. Empirical investigations are conducted to understand the inner-workings. Since large-scale pre-trained models are widely used in practice for their great representation power, we believe DualPrompt\xspace serves as a starting point for real-world rehearsal-free continual learning systems. Moreover, we recommend DualPrompt\xspace as a unified framework for future prompt-based continual learning research, for its simplicity, flexibility, and strong performance. \bibliographystyle{plain}
{'timestamp': '2022-04-12T02:28:29', 'yymm': '2204', 'arxiv_id': '2204.04799', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04799'}
arxiv
\section{Introduction} \indent \Acp{DT} are central to the digital transformation that we are currently witnessing. In essence, \acp{DT} will be a driving force for an end-to-end digitization beyond the Industry 4.0 borders \cite{khan2022digital}. By extending the fundamental \ac{DT} concept towards massive twinning, a plethora of complex real-world \acp{DT} are expected to emerge~\cite{han2021multi}. This is crucial for enabling anticipated \ac{IoE} applications such as extended reality and connected robotics and autonomous systems~\cite{chaccour2022seven}. Guaranteeing a high-fidelity representation of such \acp{DT} that have a dynamic nature constrains the underlying communication network with a set of stringent wireless requirements. For instance, extreme reliability, hyper-mobile connectivity, near-zero latency, and high data rates are necessary to sustain high \ac{QoS} for such dynamic \acp{DT}. One measure that can bring us closer to guaranteeing such requirements is the integration of \acp{DT} with an intelligent edge backbone. Furthermore, an \ac{AI}-native edge plays a pivotal role in supporting fully-autonomous \ac{IoE} services in 6G networks \cite{chaccour2021edge}. In fact, deploying \acp{DT} for autonomous IoE applications operating in non-stationary real-world scenarios necessitates adopting an intelligent wireless edge that can seamlessly adapt the digital duplicate to the changes in the underlying application states. \\ \indent Several works \cite{lu2021adaptive,lin2021stochastic,lu2020low,sun2020dynamic} studied the implementation of \acp{DT} at the edge in an attempt to meet their stringent requirements and meet their challenges. The authors in \cite{lu2021adaptive} proposed coupling \ac{DRL} with \ac{TL} to solve the \ac{DT}-edge placement and migration problems in dynamic environments. The work in \cite{lin2021stochastic} proposed a dynamic congestion control scheme to manage the stochastic demand in \ac{DT}-edge networks. The authors in \cite{lu2020low} developed a solution for the dynamic association problem in DT-edge networks while balancing the accuracy and cost of a blockchain-\ac{FL} scheme. In~\cite{sun2020dynamic}, the authors studied the use of a \ac{DT} for capturing the air-ground network dynamics that assist network elements in designing incentives for a \ac{DT}-edge \ac{FL} scheme. While the works in \cite{lu2020low,sun2020dynamic,lu2021adaptive,lin2021stochastic} shed light on interesting issues that accompany \ac{DT}-edge networks from different dynamic perspectives, they consider major limiting assumptions. The works in \cite{lu2020low,sun2020dynamic,lin2021stochastic} assume the \acp{DT} to operate under ideal stationary conditions. Nonetheless, realistic \acp{DT} that emulate a digital replica of novel \ac{IoE} applications operate in dynamic non-stationary environments. Meanwhile, even though the work in \cite{lu2021adaptive} considers non-stationary conditions when using \ac{TL}, it disregards the knowledge gained with the \emph{continuous} evolution of the \acp{DT}. Clearly, there is a lack in works that comprehensively consider the practical operation of evolving \acp{DT} under real dynamic considerations. In fact, enabling a dynamic \ac{DT} in a massive twinning context is governed by defining the duality between physical and digital entities. This duality is triggered on multiple fronts that require merging new dimensions and metrics, including: (i) \textit{synchronization} between the \ac{PT} and the \ac{CT} to preserve the real-time interaction and diminish the possibility of interrupting the \ac{CT} operations and simulations, (ii) \textit{accuracy} of the \ac{CT} in reflecting the real-time PT status by maintaining a precise duplicate throughout the various phases experienced by the PT, and (iii) \textit{history-awareness} of the evolving \ac{DT} states by incorporating the knowledge attained from past experiences into future states. \emph{Hence, a fundamental step towards achieving a massive twinning framework can be accomplished by enabling simultaneously synchronous, accurate, and history-aware \acp{DT} that can continuously operate in dynamic non-stationary environments.} The main contribution of this paper is a novel edge \ac{CL} approach to accurately model the evolving affinity between a \ac{PT} and its corresponding \ac{CT} in a real dynamic environment, while preserving their synchronization. In particular, a CT is simulated as a \ac{DNN} at the wireless network edge to model an autonomous vehicle traversing through an episodically dynamic environment. This vehicular PT is equipped with \ac{IoT} sensors that capture the relevant data used in determining the autonomous driving actions. As the distribution of the \ac{IoT} data changes with each episode, the vehicular agent adapts its driving policy accordingly. Consequently, the \ac{CT} must update its model to preserve the \ac{DT} accuracy, which leads to a de-synchronization gap between the twins. While taking the history-awareness of \acp{DT} into account, the \ac{CT} model update process is formulated as a dual objective optimization problem to minimize the loss over all encountered episodes while reducing de-synchronization time. To limit the progressive increase in de-synchronization time over episodes, we propose a \ac{CL}-based \ac{EWC} technique that contracts the ongoing historical experience as regularization terms into the learning cost. As the impact of \ac{EWC} regularization on \ac{CT} evolution increases with number of episodes encountered, we use a variant of \ac{EWC} to address the \emph{plasticity-stability} effect in \acp{DT}. \textit{To the best of our knowledge, this is the first work to model \acp{DT} in a dynamic environment by addressing the synergy between synchronization, accuracy, and ongoing history.} Simulation results show that our proposed method to model \acp{DT} can outperform state-of-art benchmarks by providing near optimal accuracy measures over all encountered episodes within the minimal de-synchronization time. \vspace{-0.15cm} \section{System Model} \subsection{DT-Edge Model} Consider a \ac{DT} system in which the \ac{PT} is an autonomous vehicle connected to a \ac{BS}, as shown in Fig.~\ref{System Model}. To empower this vehicle with autonomous functionality, it is equipped with a large set of \ac{IoT} sensors that continuously capture data used in executing real-time driving decisions. For instance, the type of data generated by the \ac{IoT} sensors can range from intra-vehicular analytics to inter-vehicular range sensing that are necessary to fine-tune the vehicle's speed. Moreover, the \ac{BS} is equipped with a \ac{MEC} server that runs a real-time \ac{DT} simulation of the autonomous driving vehicle. In particular, the vehicular \ac{CT} simultaneously replicates the \ac{PT}'s driving decisions as a function of the \ac{IoT} data uploaded to the \ac{DT}-edge layer. This real-time \ac{DT} simulation is managed in a deep learning framework, where a \ac{DNN} model $\mathcal{M}_0$ that represents the \ac{CT} is trained over a dataset $\mathcal{D}_0$ comprising historical actions exhibited by the \ac{PT}. The upload time of \ac{IoT} data to the \ac{DT}-edge layer is assumed to be negligible. As a result of the dynamic changes in the space, time, as well as the driving conditions; the environment experienced by the vehicle will vary in a \emph{non-stationary} fashion. These dynamic and non-stationary variations are reflected in the generated \ac{IoT} data readings and their respective probability distributions. Thus, the \ac{PT} and its respective \ac{CT} are required to adjust their driving policy to cope with those variations. Henceforth, we consider a \ac{PT} to be operating in a dynamic environment, where the environment changes over a set $\mathcal{K}$ of $K$ sequential time episodes~\cite{sun2022learning}. For tractability, although the inter-episode variations are non-stationary, we assume that the intra-episode environment variations are stationary. In our model, the learning agent has full knowledge of the time frames, i.e., the start and end of each episode. As a result of dynamic changes in the \ac{PT} environment, the learning agent of the \ac{PT} autonomously updates its driving policy. \emph{Consequently, considering the history-aware nature of \acp{DT}, the \ac{CT} should adapt its \ac{DNN} model} \emph{to encompass the current episode $k \in \mathcal{K}$ while reflecting the knowledge from its past experiences.} At the start of each episode $k$, a dataset $\mathcal{D}_k = \{\boldsymbol{x}_{ki},y_{ki}\}_{i=1}^{i=I_k}$ of the vehicle actions is collected, where $I_k = |\mathcal{D}_k|$ and the pair $\{\boldsymbol{x}_{ki},y_{ki}\} \sim \mathcal{P}_k$ represents the $i^{\mathrm{th}}$ data vector of the IoT sensor measurements and the corresponding decision taken by the vehicle, during episode $k$, respectively. Then, this dataset $\mathcal{D}_k$ is uploaded to the DT-edge layer to update a DNN model $\mathcal{M}_k$ in episode $k$. \begin{figure \includegraphics[scale=0.39]{Figures/System_Model} \caption{\small{Illustration of the edge dynamic digital twins system performing a simulation of the physical system in a non-stationary environment}} \label{System Model} \vspace{-0.50cm} \end{figure} \vspace{-0.20cm} \subsection{Learning over the DT-Edge} The model $\mathcal{M}_k$ is assumed to have $l$ fully-connected layers where $l = 1,2,\ldots,L$. In addition, each layer is composed of $a_{lm}$ neurons, where $m=m_1,m_2,\ldots,m_l$ is the number of neurons in each layer. Moreover, $\mathcal{M}_k$ is characterized with weights $\boldsymbol{w}_k^{n_k} \in \mathbb{R}^{n}$ reached upon performing $n_k$ training iterations, with $n = \sum_{l=1}^{L-1} m_l m_{l+1}$ being the dimension size of the model weights vector. Due to the aforementioned dynamic spatio-temporal conditions, the data probability distribution $\mathcal{P}_k$, where $\mathcal{D}_k \sim \mathcal{P}_k$, experiences non-stationary variations with respect to $k$ episodes. Hence, to procure a comprehensive update that describes the entire \ac{PT} evolution, the \ac{CT} should adapt its model to the current episode $k$ while reflecting the experience gained over the preceding $k-1$ episodes. In accordance, we define a loss function that measures the performance of $\mathcal{M}_k$ over all collected \ac{PT} actions, as follows: \vspace{-0.28cm} \begin{equation} \mathcal{L}(\boldsymbol{w}_k^{n_k}, \mathcal{A}_k) = \frac{1}{|\mathcal{A}_k|} \sum_{j=0}^{k}\sum_{i=1}^{I_k} \psi(\boldsymbol{w}_k^{n_k},\boldsymbol{x}_{ji},y_{ji}), \vspace{-0.28cm} \end{equation} where $\mathcal{A}_k = \bigcup_{j=0}^{k} \mathcal{D}_j$ is the \emph{non-iid} accumulated dataset of all \ac{PT} actions until current episode $k$ and $\psi(\cdot)$ is a generic loss function. The training process over the \emph{non-iid} dataset is then carried out using \ac{GD} iterations to minimize the loss function as follows: $ \boldsymbol{w}_{k}^{n_k} \leftarrow \boldsymbol{w}_{k}^{n_k-1} - \eta \nabla \mathcal{L}(\boldsymbol{w}_k^{n_k-1}, \mathcal{A}_k), $ where $\eta$ is the learning rate. Since the \ac{DT} simulation is an explicitly synchronous process, the \ac{CT} cannot perform simulation and learning tasks simultaneously. Thus, we assume that the simulation process is halted throughout the updating process of $\mathcal{M}_k$, which gives rise to a synchronization gap between the twins. To capture the time during which the \ac{DT} is out-of-service, we define the \emph{de-synchronization time} as the time needed to update $\mathcal{M}_k$ during each episode $k$, as follows: \vspace{-0.27cm} \begin{equation} \Delta T_k (n_k) = \frac{|\mathcal{A}_k|}{f}\Lambda n_k, \vspace{-0.1cm} \end{equation} where $\Lambda$ is the number of CPU cycles required to train one data sample, and $f$ is the CPU frequency of the \ac{MEC} server. Next, we formulate a dual objective optimization problem to guarantee \emph{episodic history-aware \ac{CT} model updates to accurately represent the \ac{PT}, while limiting the de-synchronization time between the twins.} \subsection{Problem Formulation} Our goal is to jointly maximize the \ac{DT}'s accuracy and minimize the corresponding de-synchronization time over each episode. In particular, we tend to guarantee a synchronous \ac{DT} simulation where the \ac{CT} model accurately adapts to each episode sequentially while abiding by the knowledge acquired from previous experience. Thus, it is necessary to find the optimal number of iterations need to learn the corresponding weights while achieving an optimal tradeoff between enhancing model accuracy and limiting de-synchronization time. Thus, at the beginning of each non-stationary episode $k$ the learning agent needs to optimize the following problem, in a sequential fashion: \vspace{-0.2cm} \begin{subequations} \label{opt1} \begin{IEEEeqnarray}{s,rCl'rCl'rCl} & \underset{n_k}{\text{min}} &\quad& \alpha\mathcal{L}(\boldsymbol{w}_k^{n_k}, \mathcal{A}_k) + (1-\alpha) \Delta T_k(n_k), \label{obj1}\\ &\text{s.t.} && \alpha \in [0,1], n_k \in \mathbb{Z} \label{c3}, \vspace{-0.2cm} \end{IEEEeqnarray} \end{subequations} where $\alpha$ is a bias coefficient that controls the accuracy and synchronization tradeoff in our application.\\ \indent This is a dual objective optimization problem that minimizes the loss function and the de-synchronization time to maintain an accurate \ac{CT} model in real-time, by controlling the number of \ac{GD} iterations in each episode. Solving problem~\eqref{opt1} using classical machine learning schemes is challenging due to the growth of the accumulated dataset size that is included in the \ac{GD} computations over each episode -- a unique feature of \acp{DT} over wireless networks.\\ \indent As the size of the accumulated dataset increases with the number of episodes encountered, the de-synchronization time grows linearly with the additional time required to update the model. Given that the episodes have equal importance and contribution to the learning model, the complete ongoing history of experiences should be considered in the loss function. On the one hand, disregarding the previous \ac{DT} experiences violates the history-awareness requirement of our \ac{DT}. On the other hand, training over the accumulated dataset will jeopardize synchronization and violate \ac{DT} latency requirements. Thus, it is necessary to propose a novel solution that can ensure a swift model adaptation in each episode while fulfilling the synchronization and history-aware \ac{DT} requirements. Next, we develop a novel edge \ac{CL} paradigm that balances the accuracy and de-synchronization time in the \ac{CT} update process while taking the historical experience into consideration. \vspace{-0.15cm} \section{Edge CL for Dynamic DTs} \label{solution} In this section, we present a \ac{CL}-based solution that can mitigate the progressive increase in de-synchronization time which accompanies the growth of accumulated dataset size. In general, \ac{CL} is recognized as an incremental learning scheme that enables agents to learn individual tasks sequentially~\cite{delange2021continual}, without the need to learn over all of the previously encountered tasks' data. Accordingly, by considering the \ac{DT} performance over each episode as an individual task, \ac{CL} can promote individual episode learning while preserving the knowledge gained from encountered episodes. Thus, by alleviating the need to learn over the accumulated dataset, the increase in de-synchronization time can diminish noticeably. With respect to our \acp{DT} system, our solution will embrace the \ac{EWC} technique that was introduced to mitigate the \emph{catastrophic forgetting} phenomenon that captures the affinity of DNNs to forget the weights related to previous tasks upon consecutive model updates~\cite{kirkpatrick2017overcoming}. In particular, \ac{EWC} enables selective regularization of model weights that are essential to reflect the \ac{CT} experience in each episode. Hence, a major portion of the \ac{DT} history is conveyed within the \ac{DNN} weights and contracted as quadratic penalty terms inserted into the loss function. Thus, regularizing the history can limit \emph{catastrophic forgetting} and the increase in de-synchronization time.\\ \indent First, the \ac{DNN} weights are acquired by employing a sequential Bayesian approach. In particular, to estimate the posterior distribution of the \ac{DNN} weights given the accumulated data $\mathcal{A}_k$ and, assuming that the episodes are independent, the log posterior distribution is defined according to the Bayes rule~\cite{kirkpatrick2017overcoming} as: $ \text{log }p(\boldsymbol{w}_{k}^{n_k}|\mathcal{A}_k) \displaystyle \propto \text{log }p(\mathcal{D}_k|\boldsymbol{w}_k^{n_k} ) + \text{log } p(\boldsymbol{w}_{k}^{n_k}|\mathcal{A}_{k-1}),$ where $\text{log }p(\mathcal{D}_k|\boldsymbol{w}_k^{n_k} )$ is the loss in the current episode $k$ and $\text{log } p(\boldsymbol{w}_{k}^{n_k}|\mathcal{A}_{k-1})$ is the prior probability. Thus, training the model $\mathcal{M}_k$ is carried out by a minimization over the negative log posterior function to yield the solution weights $\boldsymbol{w}_k^{*}$ in episode $k$ as: \vspace{-0.13cm} \begin{equation}\label{tr1} \vspace{-0.11cm} \boldsymbol{w}_k^{*}= \arg\underset{\boldsymbol{w}_k^{n_k}}{\min} \ \left (-\text{log }p(\boldsymbol{w}_{k}^{n_k}|\mathcal{A}_k) \right), \vspace{-0.02cm} \end{equation} Here,~\eqref{tr1} represents the \ac{DT} simulation that reflects the \ac{DT}'s state in episode $k$. Furthermore, the ongoing \ac{DT} history is implicitly reflected throughout the prior term that provides a bias of the experience gained over the preceding $k-1$ episodes. In essence, the term $\text{log }p(\mathcal{D}_k|\boldsymbol{w}_k^{n_k} )$ is related to the CT simulation error while minimizing the loss function with respect to $\mathcal{D}_k$ and $\boldsymbol{w}_k^{n_k}$. The prior term $\text{log } p(\boldsymbol{w}_{k}^{n_k}|\mathcal{A}_{k-1})$ is intractable as shown in ~\cite{chen2018lifelong}, which limits the evaluation of the posterior distribution as a direct term. To evaluate this term, one can formulate its Laplace approximation~\cite{huszar2017quadratic}, and, thus, approximate it through its second order Taylor expansion in the neighborhood of $\boldsymbol{w}_{k-1}^{*}$ as: $\text{log }p(\boldsymbol{w}_k^{n_k}|\mathcal{A}_{k-1}) \approx \frac{1}{2} (\boldsymbol{w}_k^{n_k} - \boldsymbol{w}_{k-1}^{*})^{\top} \boldsymbol{H}(\boldsymbol{w}_{k-1}^{*}) (\boldsymbol{w}_k^{n_k} - \boldsymbol{w}_{k-1}^{*})$, where $\boldsymbol{H}(\boldsymbol{w}_{k-1}^{*}) = \frac{\partial^{2}}{\partial \boldsymbol{w}_{k}^2 } \text{log } p(\boldsymbol{w}_k|\mathcal{A}_{k-1})\arrowvert_{\boldsymbol{w}_k = \boldsymbol{w}_{k-1}^{*}}$is the Hessian of the log prior probability function evaluated at $\boldsymbol{w}_{k-1}^{*}$. Moreover, the first and second terms of the Taylor expansion are neglected since they are evaluated near the optimal solution $\boldsymbol{w}_{k-1}^{*}$. Furthermore, the Hessian in this case can be represented in terms of the Fisher information matrix that shows the importance of each weight in this episode. Without loss of generality, the Fisher information matrix is defined as $\boldsymbol{F}_{k} = -\mathbb{E}_{(\boldsymbol{x}_k,y_k) \sim \mathcal{D}_k}(\boldsymbol{H}(\boldsymbol{w}_{k}^{*}))$. Assuming that the weight parameters are independent of each other, we can estimate the Fisher information matrix in terms of its diagonal elements while setting the rest to zero~\cite{van2019three}. Hence, after quantifying the terms related to the posterior probability, we define the \emph{recursive loss function} that combines both current and \ac{EWC} losses in episode $k$ as follows: \vspace{-0.28cm} \begin{equation} \label{recursive loss} \mathcal{L}(\boldsymbol{w}_k^{n_k})= \mathcal{L}(\boldsymbol{w}_k^{n_k}, \mathcal{D}_k)+ \sum_{j=0}^{k-1}\sum_{d} \frac{\lambda}{2} F_{j,dd}\left(w_{k,d}^{n_k} - w_{j,d}^*\right)^2, \vspace{-0.2cm} \end{equation} where $\mathcal{L}(\boldsymbol{w}_k^{n_k}, \mathcal{D}_k)$ is the CT simulation error on $\mathcal{D}_k$, $F_{j,dd}$ is the diagonal value of the Fisher information matrix in episode $j$ that relates to the weight $d$, $\lambda$ is a hyperparameter that determines the relative weighting of learning the new episode in comparison to remembering the previous episodes experience, $w_{k,d}$ is the weight in episode $k$, and $w_{j,d}^{*}$ is the optimal solution weight for parameter $d$ in episode $j$. The \ac{EWC} loss term in \eqref{recursive loss} can substantially increase with the number of episodes encountered, which consequently jeopardizes the model's robustness. Hence, the model's ability to \emph{continuously} update its weights will be dominated by the rigid effect of the regularization terms. Eventually, this will lead to a \emph{stable} \ac{CT} model that is constrained by its history and cannot evolve further. On the other hand, when the effect of regularization is minimal, the model is susceptible to losing its experience which leads to a \emph{plastic} \ac{CT} model that is vulnerable to \emph{catastrophic forgetting}. This phenomenon is known as the \emph{stability-plasticity dilemma}~\cite{parisi2019continual}. To address this dilemma, we must equip the \ac{CT} model with higher degrees of freedom to smoothly address stability and plasticity effects along different episodes. To achieve that, we propose adopting a modified \ac{EWC} version called \ac{EWC}++~\cite{chaudhry2018riemannian}. Here, the Fisher information matrix is estimated through a moving average after calculating the Fisher matrix in each episode $k$. Accordingly, the averaged Fisher elements are estimated at the end of each episode $k$ as: $ \Tilde{F}_{{k,dd}} = \gamma F_{k,dd} + (1-\gamma) \Tilde{F}_{{(k-1),dd}}$, where $\gamma$ is a hyperparamater. After setting the value of $\gamma$ and calculating the averaged Fisher elements at each episode, the modified recursive loss function can be expressed as: \begin{equation*} \small \tilde{\mathcal{L}}(\boldsymbol{w}_k^{n_k})= \mathcal{L}(\boldsymbol{w}_k^{n_k}, \mathcal{D}_k)+ \sum_{d} \frac{\lambda}{2} \Tilde{F}_{{(k-1),dd}}\left(w_{k,d}^{n_k} - w_{(k-1),d}^*\right)^{2}. \vspace{-0.25cm} \end{equation*} This loss deals with the current and previous episode Fisher values along with the previous weights $\boldsymbol{w}_{k-1}^{*}$ only. Essentially, implementing this modified loss function can yield a representative \ac{CT} model that \emph{continually} learns while countering the stability-plasticity effects and mitigating the increase in de-synchronization time. Hence, this modified loss function will replace that of \eqref{obj1} to solve problem \eqref{opt1}. Henceforth, the problem in \eqref{opt1} can be then interpreted as a modified loss minimization problem by controlling $n_k$ that achieves the desired balance between accuracy and de-synchronization of the \ac{DT}s according to $\alpha$. Solving this modified loss minimization problem through \ac{GD} iterations will yield the optimal $n_k^{*} $ and its corresponding $\boldsymbol{w}_{k}^{*}$ for episode $k$. \section{Simulation Results and Analysis} For our simulations, we consider a \ac{CT} operating over a \ac{MEC} server at a \ac{BS} for $k = 4 $ sequential episodes. The \ac{CT} must \emph{sequentially} learn a classification task of identifying the handwritten digits from $0$ to $9$ of the permuted MNIST dataset, which is a variant of the standard MNIST dataset having image pixels permuted independently for each episode. For our model, we use a \ac{MLP} having $L=2$ hidden layers, each having $m_{l} = 256$ neuron units with ReLu activations $\forall l = \{1,2\}$. We set $\psi(\cdot)$ as the cross-entropy function. Unless otherwise stated, we set $I_k = 15000$, $\eta = 0.01$, $\Lambda= 125440$ cycles/sample, $f= \SI{4}{GHz}$, $\lambda = 75000$, and $\gamma = 0.5$~\cite{chaudhry2018riemannian, zenke2017continual}. A dataset of $1000$ images was procured, by collecting images from the different permutations used to test the trained model. In our experiments, we compare the proposed \ac{CL} solution presented with two benchmark methods: a) An \emph{exhaustive learning} scheme that accumulates all the training data throughout its history and current episode, b) A \emph{single task learning} approach that solely relies on the training data seen in the current episode. \\ \indent Fig.~\ref{remembering} shows the achieved accuracy on the test set over 400 training iterations for the different methods, where each 100 iterations refers to one sequential episode. From Fig.~\ref{remembering}, we observe that the proposed CL solution achieves near optimal performance reaching an accuracy of $90\%$, compared to the optimal solution of $95\%$ resulting from the exhaustive learning scheme. Meanwhile, the single task learning method did not retain all of its knowledge between episodes which resulted in an accuracy of only $50\%$. The results showcase how the proposed \ac{CL} method is capable of learning incrementally without revisiting data from previous episodes.\\ \indent Fig.~\ref{bar} presents the de-synchronization time in each episode. Here, the exhaustive learning scheme achieves a high accuracy, at the expense of a significantly increased de-synchronization time. In this figure, we observe de-synchronization times of $\SI{45}{s}$ and $\SI{190}{s}$ in episodes $1$ and $4$, respectively. In contrast, the proposed \ac{CL} solution has a clear advantage by maintaining its de-synchronization time at $45$ s throughout the $4$ episodes, while reaching a near optimal accuracy. Although single task learning has a similar de-synchronization time to \ac{CL}, this comes at the expense of a deteriorated accuracy of $50\%$ at the end of the 4 episodes. \begin{figure}[t!] \begin{minipage}{0.49\linewidth} \centering \includegraphics[scale=0.30]{Figures/Fig1-cropped} \subcaption{} \label{remembering} \end{minipage} \begin{minipage}{0.49\linewidth} \centering \includegraphics[scale=0.3]{Figures/Fig3-cropped.pdf} \subcaption{} \label{bar} \end{minipage} \caption{\small{a) Accuracy (\%) versus the number of iterations $n_k$, b) De-synchronization time upon training over 4 sequential episodes}.} \label{fig:performance} \vspace{-0.3cm} \end{figure} \begin{figure}[t!] \centering \includegraphics[width=0.30\textwidth]{Figures/Fig2-cropped} \caption{\small{Accuracy (\%) over first episode versus iterations $n_k$}} \label{forgetting} \vspace{-0.7cm} \end{figure} \indent Fig.~\ref{forgetting} compares the model robustness to \emph{catastrophic forgetting} upon training the different methods over $4$ sequential episodes. This is verified by measuring the model's accuracy on the first episode after training on each episode successively. Initially, it can be seen that all the methods achieve a similar accuracy of $94\%$ over the first episode. As the number of episodes increases, we can see that the proposed \ac{CL} is capable of reaching an accuracy of $84\%$ in contrast to a $58\%$ attained accuracy by single task learning. Clearly, unlike the exhaustive method, the \ac{CL} methodology is a lightweight scheme that permits accumulating the gained knowledge without the need to revisit data from preceding episodes. That said, the proposed approach achieves an accuracy that is only $14\%$ lower than that of exhaustive learning. Henceforth, this showcases the resilience of the proposed \ac{CL} method to \emph{catastrophic forgetting} despite its minimal de-synchronization time.\\ \indent Fig.~\ref{tradeoff} presents the relationship between the training loss and de-synchronization time, where the \ac{CL} solution proposed is implemented in a single episode for the different values of $n_k$. Fig.~\ref{tradeoff} demonstrates the presence of an explicit tradeoff between training loss and the de-synchronization time when solving for the optimal value of $n_k^*$ that is dependent on $\alpha$. By varying $\alpha$ for $0 \leq \alpha \leq 1$, $\Delta T$ can increase with the increase in $n_k$ reaching $\SI{47}{s}$ for 100 iterations performed. Consequently, by increasing $n_k$, the parameters converge to their optimal values $\boldsymbol{w}_k^{*}$, which minimizes the training loss accordingly. \begin{figure \centering \includegraphics[width=0.30\textwidth]{Figures/fig4-cropped.pdf} \caption{\small{Training loss and de-synchronization time $\Delta T$ (s) versus the number of iterations $n_k$ during one episode.}} \label{tradeoff} \vspace{-0.5cm} \end{figure} \vspace{-0.2cm} \section{Conclusion} In this paper, we have proposed a novel edge \ac{CL} framework to enable a robust synergy between a \ac{CT} and \ac{PT} in a dynamic environment. To guarantee an accurate and synchronous \ac{CT}, we have posed its model update process as a dual objective optimization problem. We have adopted an \ac{EWC} technique to overcome the increase in the de-synchronziation time. To address the stability-plasticity tradeoff accompanying the progressive growth of the regularization terms, we have proposed a modified \ac{CL} paradigm that considers a fair execution between historical episodes. Ultimately, we have shown that the proposed approach can achieve an accurate and synchronous CT that can balance between adaptation and stability. \bibliographystyle{IEEEtran} \def\baselinestretch{0.82
{'timestamp': '2022-04-12T02:28:17', 'yymm': '2204', 'arxiv_id': '2204.04795', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04795'}
arxiv
\section{CompDefect: automatic software defect identification, categorization and repair} \label{approach} \begin{figure*}[!htbp] \centerline{ \includegraphics[width=0.95\textwidth]{CompDefect-framework.pdf} } \caption{{(a) The overall framework of \sc {CompDefect}}. (b) The detail of encoder. (c) The detail of decoder. } \label{fig:framework} \end{figure*} Multi-task deep learning model~\cite{crawshaw2020multi} aims at training with the same dataset for multiple tasks simultaneously by using the shared representations to learn the common ideas between a few related tasks, which consequently increase efficiency the data and potentially accelerate learning speed for related or downstream tasks. In this paper, our {\sc CompDefect} is a typical multi-task deep learning model, which aims at automatically identifying whether a modification to a function will introduce defect, categorize the type of defect and repairing such a defect by generating patches, simultaneously. Generally, the first two tasks in {\sc CompDefect} is treated as a multiclass classification task, while the last one is a sequence generation task. The classification task and the generation task share one common encoder to extract semantic structure information from the function body. When executing the generation task, the knowledge of the classification task is utilized to help generate a better code repair. In the rest of this section, we first give the definition of the two tasks. Subsequently, we introduce details of {\sc CompDefect}, including its encoder and decoder. We use GraphCodeBERT~\cite{guo2020graphcodebert} as the encoder of {\sc CompDefect} and use Transformer decoder~\cite{vaswani2017attention} as the decoder of {\sc CompDefect}. For training {\sc CompDefect}, we need three versions of a function as the input. That is the clean version of a function, the buggy version of a function and the fixed version of a function. The buggy version represents the state when the defect was introduced into the function, the clean version represents the state before the defect was introduced, and the fixed version represents the state when the defect was fixed. {The overall framework of our approach is illustrated in Fig.~\ref{fig:framework}, which contains three sub-figures. The left one (i.e., Fig.~\ref{fig:framework}(a)) illustrates the structure of {\sc CompDefect}, while the other two represent the encoder (i.e., Fig.~\ref{fig:framework}(b) is GraphCodeBERT) and decoder (i.e., Fig.~\ref{fig:framework}(c) is Transformer Decoder) used in our proposed {\sc CompDefect}, respectively. Following that, we define the target multi-task object function since {\sc CompDefect} tries to maximize two objective functions of tasks. Finally, we illustrate the workflow how {\sc CompDefect} works in the application usage.} \subsection{Task Definition} \subsubsection{Defect Identification and Categorization: Multiclass Classification} The first task of {\sc CompDefect} is to automatically identify defect in each changed function and categorize the type of defect. To do so, {\sc CompDefect} needs to give the types of defect if it is identified as a defect-prone one. We formulate this task as a multiclass classification learning problem. For a given hunk in a commit, let \textbf{$\mathit{Func}_{\mathit{buggy}}$} be the source code of buggy version of the specific function where the modified statement exists, \textbf{$\mathit{Func}_{\mathit{clean}}$} be the source code of clean version of corresponding function before the defect is introduced. The target is to automatically determine the status $y_i$ of the change between the two versions of the function. {Let $y_i$ represents the label of the function (i.e., clean or the type of defect) after the modification is introduced. } In particular, our goal is to build a model $\theta$ with $\mathit{ \left \langle Func_{clean},Func_{buggy}\right \rangle}$ tuple to maximize the probability $P_{\theta}\left( y_i \mid \left \langle \mathit{Func_{clean},Func_{buggy}}\right \rangle; i \in [1, num\_labels] \right)$, over training dataset. Mathematically, our task is defined as finding ${L_1(X)}$, such that: \begin{gather} \mathit{L_1(X)} = argmax_{y_i} \sum_{}^{} log\ P_{\theta}\left( y_i \mid \left \langle {Func_{clean},Func_{buggy}}\right \rangle; i \in [1, num\_labels] \right) \end{gather} $P_{\theta}\left( y_i \mid \left \langle \mathit{Func_{clean},Func_{buggy}}\right \rangle; i \in [1, num\_labels] \right)$ can be seen as the conditional likelihood of predicting the status $y_i$ given the $\mathit{ \left \langle Func_{clean},Func_{buggy}\right \rangle}$ input tuple. \subsubsection{Defect Repair: Sequence Generation} The second task is to immediately and automatically generate the fixed patch if a changed function is identified as a bug-inducing one. It is a sequence generation task and the source is buggy function while the target is the corresponding fixed ones, denoted as $Y=\{y_1, y_2, \dots, y_N\}$. Let $Y_{j-1}$ be the generated sequence outputted by the decoder of {\sc CompDefect} at position of $\mathit{j}$-$1$, {mathematically $Y_{j-1}=\{y_1, y_2, \dots, y_{j-1}\}$ }, and $\mathit{X_{Encoder}}$ be the encoded output of the encoder with two inputs (i.e., $\mathit{Func_{clean}}$, $\mathit{Func_{buggy}}$). Therefore, our task is to maximize the probability $y_{j}^{k}, j \in [1, N], k \in [1, \mathit{vocab\_size}]$ with $\langle Y_{j-1}, \mathit{X_{Encoder}} \rangle$ tuple over training dataset. Mathematically, our task is defined as finding $L_2(X)$, such that: \begin{equation} \mathit{L_2(X) = argmax_{y_{j}^{k}} \sum_{}^{} log\ {P_{\theta}}\left (y_{j}^{k} \mid \langle Y_{j-1}, X_{Encoder} \rangle; j \in [1,N]; k\in [1, \mathit{vocab\_size}] \right)} \end{equation} $P_{\theta}\left (y_{j}^{k} \mid \langle Y_{j-1}, X_{Encoder} \rangle; j \in [1,N]; k\in [1, \mathit{vocab\_size}] \right)$ can be seen as the conditional likelihood of predicting the status $y_{j}^{k}$ given the $\mathit{ \langle Y_{j-1}, X_{Encoder} \rangle }$ input tuple. \subsection{Classification Task} As for this task, we use GraphCodeBERT~\cite{guo2020graphcodebert} as the encoder of {\sc CompDefect}, which is a pre-trained model for programming language considering the structure of code. In particular, it utilizes the semantic-level information of code (i.e., data flow) for pretraining instead of using syntactic-level structure of code (i.e., abstract syntax tree). Data flow of a code is represented as a graph, in which nodes represent variables, while edges represent the relation among variables. GraphCodeBERT learns a good code representation from source code and its code structure through completing two structure-aware pre-training tasks: data flow edges prediction and variable-alignment across source code and data flow. GraphCodeBERT is designed on the basic of Transformer neural architecture~\cite{vaswani2017attention} by introducing a graph-guided masked attention function to integrate the code structure. The input of {\sc CompDefect}'s encoder involves two function bodies: clean version of function and buggy version of function. Then, we use tree sitter\footnote{https://tree-sitter.github.io/tree-sitter/}, a parser generator tool and an incremental parsing library, to transform the two functions into code tokens to build the data flow graph (DFG), which can help to construct the dependencies among variables. In particular, for a source code $C = \{c_1, c_2,\dots, c_m\}$, {\sc CompDefect} first parses the source code into an abstract syntax tree (AST), which includes syntax information of the code. Besides, the leaves in AST are used to identify the sequence of variable $ V = \{v_1, v_2, \dots, v_k\}$. Therefore, the variable is treated as a node of the graph, while the relationship between $v_i$ and $v_j$ is treated as an directed edge from $v_i$ to $v_j$of graph $e= \left \langle v_i,v_j \right \rangle$, which means the value of $v_j$ comes from $v_i$. We denote the collection of directed edges as $E=\{e_1, e_2,\dots, e_l\}$ and consequently the graph is denoted as $G(C)=(V,E)$, which represents dependency relationship among variables in the source code $C$. Then, for the clean version of function, we concatenate clean code and the collection of variables as the input sequence $\mathit{X_{clean}=\{[CLS], C_{clean}, [SEP], V_{clean}\}}$ and accordingly, the buggy version of function is transformed as $\mathit{X_{buggy}=\{[CLS], C_{buggy}, [SEP], V_{buggy}\}}$. $[CLS]$ is a special token in front of the whole sequence, $[SEP]$ is another special token to split two kinds of data types. After that, we concatenate $\mathit{X_{clean}}$ and $\mathit{{X_{buggy}}}$ vertically to assemble the whole input $X$ for {\sc CompDefect}. {\sc CompDefect} takes the sequence $X$ as the input and transforms it into input vectors $H^{0}$. This vector will be transformed for $N$ times, that is, $\mathit{H^{n}=\mathit{transform}_{n}(H^{n-1}), n \in [1,N]}$, in which $N$ represents the maximum number of layers in encoder. Finally, we have the semantic structure embedding representation in the last hidden layer,\begin{small} $H^N = \left\{ h_{[CLS]}^N, h_{C}^N,h_{[SEP]}^N, h_{V}^N\right\}$\end{small}, in which $h_{C}^N = \{h_{c_1}^N, h_{c_2}^N,...h_{c_n}^N\}$ and $h_V^{N} = \{h_{v_1}^N,h_{v_2}^N,...,h_{v_n}^N\}$. Therefore, we get the contextualized representation of the buggy function $\mathit{H^N_{buggy}}$ and the clean function $\mathit{H^N_{clean}}$. To learn the relation between the vector of the clean function $\mathit{h_{[CLS]_{clean}}^N}$ and the vector of buggy function $\mathit{h_{[CLS]_{buggy}}^{N}}$, we adopt neural tensor network (i.e., NTN, denoted as $\Gamma$) and denote the relation as $\mathit{h_{NT}}$. The three vectors are combined as $\mathit{h_{change}}$, which be fed into feed forward neural network for feature fusion. {\sc CompDefect} finally outputs the probability of each class after a $\mathit{softmax}$ operating on the result of $\mathit{tanh}$ activation function. More precisely, the classification operation sequence is formulated as follows: \begin{gather} h_{NT}=\operatorname{ReLU}\left( { \left (h_{[\mathit{CLS}]_{\mathit{buggy}}}^{N} \right )}^\mathsf{T} \Gamma^{[1, \ldots, n]} {h}_{[\mathit{CLS}]_{\mathit{clean}}}^{N}+b_{\mathit{NT}}\right)\\ h_{\mathit{change}} = h_{\mathit{NT}} \oplus h_{[\mathit{CLS}]_{\mathit{buggy}}}^{N} \oplus h_{[\mathit{CLS}]_{\mathit{clean}}}^N\\ e = \operatorname{\mathit{tanh}}\left (\operatorname{FFN}\left (h_{\mathit{change}}\right ) \right) = \operatorname{tanh}\left ({W_e}h_{\mathit{change}} + b_e \right )\label{equtation:e}\\ y = \operatorname{Softmax}(p)= \operatorname{Softmax} (\operatorname{FFN(e)}) = \operatorname{Softmax}( W_pe + b_e) \end{gather} To train a good model for our task, we reuse the pre-trained weights of GraphCodeBERT from Hugging Face\footnote{https://huggingface.co/} to initialize the encoder and fine-tune on our collected dataset. \subsection{Sequence Generation Task} As for this task, we use Transformer decoder~\cite{vaswani2017attention} as the decoder of {\sc CompDefect}, which can generate fix patch for the identified buggy function. The decoder of {\sc CompDefect} consists of two phases: training phase and generating phase. In the former phase, the decoder starts from special token [SOS] to generate fixed code tokens according to the language model. For the result in $j$-th position $y_j$, the input of decoder is the output of {\sc CompDefect}'s encoder and the output generated by decoder in (${j}$-1)-th position, denoted as $Y_{j-1} = \left\{y_1, y_2, \dots, y_{j-1}\right\}$. $Y_{j-1}$ is converted into $H_j^0$ and subsequently transformed into $H_j^n = \mathit{transfom_n}(H_j^{n-1}), n \in [1,N]$ by the decoder network. $N$ is the maximum number of layers in decoder. Following that, we use $\mathit{softmax}$ function to convert the output values based on last hidden state into probabilities to choose the most likely token from a vocabulary. More precisely, \begin{gather} e_j = \mathit{tanh}\left(\mathit{FFN}\left(H_j^N\right)\right) = \mathit{tanh}\left({W}H_{j}^N + b \right)\\ p_j = \mathit{FFN\left(e_j\right)} = We_j + b\\ y_j = \mathit{softmax}\left({p_j}\right) \end{gather} in which, $\mathit{FFN}$ represents a feed-forward network and $\mathit{tanh}$ is used as the activation function. To fully use the information embedded in encoder, we use a cross multi-head attention vector $e_{\mathit{cross}}$: \begin{gather} e_{\mathit{cross}}=e \oplus h_{C_{\mathit{buggy}}}^{N} \oplus h_{[\mathit{SEP}]_{{\mathit{buggy}}}}^{N} \oplus h_{V_{\mathit{buggy}}}^{N} \end{gather} Notice that we use $e$, the vector in the encoder phase of {\sc CompDefect} before $\mathit{softmax}$ operation in Equation~(\ref{equtation:e}), instead of $h_{{[\mathit{CLS}]}_{\mathit{buggy}}}^{N}$ to except this attention to focus on the knowledge of classification tasks when performing generation tasks. In the generation phase, it can be used to generate patches on testing dataset. In the process of generation, for generating $y_j$, we use beam search strategy to generate multiple potential patches $Y_{j-1}$, as done in prior work~\cite{chen2019sequencer,tufano2019empirical}. Beam search works through memorizing the $n$ best sequences up to the current state of decoder. $n$, set as 10 in our study, is commonly referred to as width or beam size, and an infinite $n$ beam search corresponds to a complete breath-first-search. The successors of these memorized states are computed and sorted based on their cumulative probability. Then, the next $n$ best sequences are passed to the next state of decoder. When evaluating {\sc CompDefect}, we only choose the sequence with the highest probability. \subsection{Optimization of {\sc CompDefect}} When a model has more than one task, a few task-specific objective functions need to be combined into a single aggregated one that the model tries to maximize it. Therefore, it is extremely important to exactly combine various objective functions into one that is the most suitable for multi-task learning. In {\sc CompDefect}, there mainly exists two tasks: multiclass classification task and sequence generation task. Since in our usage scenario (i.e., function-level software defect prediction and defect repair), we think the two tasks are equivalently important. Thus, {\sc CompDefect} addresses the multi-task optimization by balancing the individual objective functions for the two different tasks. {That is, the final optimization function($L_3(X)$) is the sum of two individual objective functions($L_1(X)$ for classification task, and $L_2(X)$ for sequence generation task), which is the one that {\sc CompDefect} tries to maximize. Formally,} \begin{gather} L_3(X) = L_1(X) + L_2(X) \end{gather} Notice that our model {\sc CompDefect} is flexible, we can optimize our model based on how developers perceive the importance of the two tasks by changing the weights of the objective functions. { \subsection{The Workflow of {\sc CompDefect} in Application Stage} } \begin{figure*}[htbp] \centerline{ \includegraphics[width=1\textwidth]{application-workflow.pdf} } \caption{The workflow of {\sc CompDefect} in application stage.} \label{fig:applicationworkflow} \end{figure*} { We illustrate how {\sc CompDefect} can be used to process a new commit in Fig.~\ref{fig:applicationworkflow}. The figure provides an example of a commit(7ebbfdf26432552edeb1057555fb51596a1ca5b6) from $sonarqube$ project. Given a commit, {\sc CompDefect} firstly identifies hunks. Then, it figures out the corresponding function body where the modification exists. After that, it filters out those hunks whose modification is not a single-statement one or the modification occurs outside the scope of a function. Following that, {\sc CompDefect} extracts the previous function body of the current version using PyDriller~\cite{Spadini2018}. Finally, the two versions are fed into {\sc CompDefect} to judge whether it has a defect, to categorize the type of defect, and to repair it automatically when it is identified as the defective one. } \section{Conclusion and Future Work} \label{conclusion} In this paper, we propose a comprehensive defect prediction and repair framework named {\sc CompDefect}, which can identify whether a function changed in a commit is defect-prone, categorize the type of defect, and repair such a defect automatically. Generally, the first two tasks in {\sc CompDefect} is treated as a multiclass classification task, while the last one is treated as a sequence generation task. The whole input of {\sc CompDefect} consists of three parts: the clean version of function (i.e., the version before the defect introduced), the buggy version of function and the fixed version of function. For the first task, {\sc CompDefect} identifies the defect type through multiclass classification. For the second task, {\sc CompDefect} repairs the defect once identified or keeps it as the same originally. Moreover, we also build a new function-level dataset on the basis of ManySStuBs4J to evaluate the performance of {\sc CompDefect}. The new dataset is the largest function-level dataset with comprehensive information. It contains three versions of a certain function and multiple types of defect. By comparing with state-of-the-art baselines in various settings, {\sc CompDefect} can achieve superior performance on classification and defect repair. { In the future, we firstly want to make our approach an online available tool for practical usage. Then, we will extract more non-single-statement defective functions and further improve our model to address this situation. } \section{Introduction} \label{introduction} Software development process is evolving rapidly with frequently changing requirement, various development environment, and diverse application scenarios. It tends to release software versions in a short-term period. Such a rapid software development process and limited Software Quality Assurance (SQA) resources have formed a strong contradiction. Thus, many continuous code quality tools (e.g., CI/CD, static analysis) have been widely adopted~\cite{pornprasit2021jitline}. However, SQA teams cannot effectively inspect every commit with limited SQA resources. Therefore, it is important to identify defects as early as possible to prioritize limited resource (e.g., time and effort) on specific program modules. Just-In-Time defect prediction (JIT-DP)~\cite{kamei2013large,liu2017code,pornprasit2021jitline,hoang2019deepjit} is a novel technique to predict whether a commit will introduce defects in the future and it can help practitioners prioritize limited SQA resources on the most risky commits during the software development process. Compared with coarse-grained level (i.e., class/file/module) defect prediction approaches, JIT-DP works at the fine-grained level to provide hints about potential defects. Though many approaches have been proposed to make a great process in JIT-DP, there still has several limitations in previous work. \begin{itemize} \item \textbf{Code semantic information and code structure information are not fully used}. Many approaches~\cite{huang2018identifying,McIntoshK18,yang2017tlel} are proposed based on the commit-level metrics proposed by Kamei et al.~\cite{kamei2013large}. These metrics are quantitative indicators of modified codes without considering the semantic of codes. Recently, deep learning based approaches~\cite{hoang2019deepjit,hoang2020cc2vec} consider the semantic (i.e., the code tokens' implication around its modified context) and the structure information (e.g., the relation among commits, $hunk$s\footnote{https://git-scm.com/}, modified files, modified lines, and tokens) of a change. However, the semantic information is not comprehensive~\cite{hoang2019deepjit} but only represents the modified lines and is part of the understanding of the code commit. The structure information is not real representation of code structure~\cite{hoang2020cc2vec} but only represents the structure of $\mathit{git\ diff}$. Therefore, the semantic information (e.g., the code tokens' implication around its modified or unmodified context) and the structure information (e.g., data flow information of code) should be deeply excavated and fully used simultaneously. \item \textbf{Prediction type is coarse-grained.} Existing work~\cite{kamei2013large,hoang2019deepjit,huang2017supervised} can only predict whether a commit is buggy or clean without more information about the type of defect. Information about the defect type (e.g., $\mathit{Missing\ Throws\ Exception}$ and $\mathit{Less\ Specific\ If}$) may help developers better understand the categories of defect and consequently help fix it. \item \textbf{Location of the defect is not accurate enough}. Currently, JIT-DP approaches can only predict the defect-proneness of a commit. However, a commit may involves several hunks which may modify a few functions existing in many files. Therefore, it may be unclear where the defect exactly exists if a commit is predicted as buggy one. \item \textbf{Solution to automatically fix defects once identified is scarcely provided}. Some approaches~\cite{kamei2013large,pornprasit2021jitline} focus on defect identification, while some approaches~\cite{chen2019sequencer,gazzola2017automatic} focus on defect repair. However, none of prior works treat defect identification task and defect repair task simultaneously. \end{itemize} In this paper, to address these limitations, we propose a comprehensive defect prediction and repair framework named {\sc CompDefect} by building a multi-task deep learning model, which can identify whether {a changed function in a commit} is defect-prone, categorize the type of defect, and repair the defect automatically. Considering that defect repair is an important but difficult software engineering problem, in this paper, we focus on simple types of defect~\cite{karampatsis2020often,chen2019sequencer,wen2018context,saha2017elixir}, such as defects with single statement fixes, or that match a small set of defect templates. Therefore, to make {\sc CompDefect} usable in practical applications, we simplify the usage scenario to single statement defects. In general, {\sc CompDefect} consists of two stages: an offline learning stage and an online application stage. In the offline learning stage, we first build a large-scale function-level dataset named Function-SStuBs4J by extracting the function body where the modified lines exists in ManySStuBs4J dataset, which is originally collected by Rafael-Michael et al.~\cite{karampatsis2020often} from 1,000 popular open-source Java projects and summarized into 16 defect patterns. In particular, we need to extract three versions of each function body context where the modified lines exists in a commit: the clean version, the buggy version, and the fixed version. The clean version means the version before the defect was introduced, the buggy version means the version when defect was introduced into the function, and the fixed version means the version when the defect was fixed. Then, the three versions are treated as the input of {\sc CompDefect} to complete two main tasks: \textbf{(1) a multiclass classification task} and \textbf{(2) a code sequence generation task}. The first task can help to identify the buggy function and categorize the type of defect, while the second task can generate the patch to repair the defect. In online application stage, {for a given commit, we firstly identify the modifications in each $hunk$. Then, for each modification, we extract the function body where the modification exists. After that, we extract the corresponding previous function body before the modification occurs.} Finally, each modified function has two versions of function body (i.e., the current version and the version before the modification introduced), which are fitted into the trained {\sc CompDefect} to predict its defect-proneness and subsequently repair it once identified as defect-inducing one. { Moreover, since {\sc CompDefect} identifies the defect-proneness of each function where the modification occurs in a commit, {\sc CompDefect} can locate the bug in a commit in a more fine-grained way. That is, {\sc CompDefect} locates the defect at hunk-level rather than commit-level. } To verify the effectiveness of our proposed model {\sc CompDefect}, we conduct a comprehensive studies on Function-SStuBs4J with state-of-the-art approaches on a few tasks involving: defect identification task~\cite{hoang2019deepjit,hoang2020cc2vec}, defect categorization task~\cite{devlin2018bert}, and defect repair task~\cite{chen2019sequencer}. Comparing with several state-of-the-art baselines, the superiority of {\sc CompDefect} is highlighted. In particular, for defect identification task, on average, {\sc CompDefect} improves DeepJIT and CC2Vec by 39.0\% and 41.7\%, by 34.7\% and 37.3\% in terms of F1-score and AUC, respectively. For defect categorization task, on average, {\sc CompDefect} also improves pre-trained models (i.e., BERT, RoBERTa and CodeBERT) by at least 63.0\%. For defect repair task, {\sc CompDefect} still outperforms SequenceR and make an improvement by 23.9\% and 29.5\% in terms of BLEU and Accuracy, respectively. In summary, this paper makes the following main contributions: \begin{itemize} \item \textbf{Technique.} We propose a comprehensive defect prediction and repair framework named {\sc CompDefect} for function-level software maintenance, which can automatically identify the defect-proneness of a changed function in a commit, categorize the type the defect, and repair defect with appropriate patch by studying the relations among three different versions of the changed method/function. {\sc CompDefect} can fully use both the code semantic information (e.g., code tokens' context) and code structure information (e.g., data flow) of the changed function simultaneously and the experimental study also highlights the promising ability on a set of software maintenance tasks: defect identification, defect categorization, and defect repair. \item \textbf{Dataset.} We extend and purify a new function-level simple statement dataset named Function-SStuBs4J on the basic of ManySStuBs4J. This dataset can provide more contextual information of modified functions in commits. To the best of our knowledge, this is the first function-level multiclass dataset which can provide comprehensive information of a changed function in a commit and its corresponding repaired patch. \item \textbf{Replication.} We have also released our replication package including the extended dataset and the source code of {\sc CompDefect}, to facilitate other researchers and practitioners to replicate our work and evaluate their ideas. \textbf{This replication package is now publicly available on Zenodo. \begin{center}\href{https://zenodo.org/record/5353354\#.YS8iYtMzZhE}{https://zenodo.org/record/5353354\#.YS8iYtMzZhE}\end{center}} \end{itemize} The rest of the paper is organized as follows. Section~\ref{approach} introduces the details of our proposed model {\sc CompDefect} including the tasks definition and technical details. Section~\ref{setting} describes the experimental setting involving dataset, baselines, evaluation metrics, experiment setup and research questions we want to investigate. Following that, the results to research questions and analysis are provided in Section~\ref{results}. Then, the threats to validity are described in Section~\ref{threats}. Finally, the related work and conclusion of this paper are subsequently presented in Section~\ref{relatedwork} and Section~\ref{conclusion}, respectively. \section{Related Work} \label{relatedwork} \subsection{Just-in-Time Defect Prediction} JIT defect prediction has been an active research topic in recent years since it can identify defect-inducing commit at a fine-grained level at check-in time. Mockus et al.~\cite{mockus2000predicting} extracted historical information in commit to build a classifier to predict the risk of new commits. Kamei et al.~\cite{kamei2013large} proposed 14 change-level metrics from five dimensions, which are used to build an effort-aware prediction model with the help of Logistic Regression. Following that, Yang et al.~\cite{yang2015deep,yang2017tlel} subsequently proposed two approach for JIT defect prediction. In particular, Yang et al.~\cite{yang2015deep} firstly used Deep Belief Network (DBN) to extract higher-level information from the initial change-level metrics, then Yang et al.~\cite{yang2017tlel} combined decision tree and ensemble learning to build a two-layer ensemble learning model for JIT defect prediction. To further improve Yang et al's model, Young et al.~\cite{young2018replication} proposed a new deep ensemble approach by using arbitrary classifiers in the ensemble and optimizing the weights of the classifiers. Later, Liu et al.~\cite{liu2017code} proposed code churn and evaluated it in effort-aware settings. Chen et al.~\cite{chen2018multi} treated the effort-aware JIT defect prediction task as a multi-objective optimization problem and consequently a set of effective features are selected to build the prediction model. Then, Cabral et al.~\cite{cabral2019class} proposed a new sampling technology to address the issues of verification latency and class imbalance evolution in online JIT defect prediction setting. Besides, Yan et al.~\cite{yan2020just} proposed a two-phase framework which can handle the identification and localization tasks at the same time. Recently, Hoang et al.~\cite{hoang2019deepjit,hoang2020cc2vec} proposed two newly approaches, which use modern deep learning model to learn the representation of commit message and code changes. Apart from above approaches, researchers also conduct studies on JIT defect prediction from various aspects. McIntosh et al.~\cite{McIntoshK18} investigated the impact of systems evolution on JIT defect prediction models via a longitudinal case study of 37,524 changes from the rapidly evolving QT and OpenStack systems. They found that the interval between training periods and testing periods has side-effect on the performance of JIT models and JIT models should be trained using six months (or more) of historical data. Besides, Wan et al.~\cite{wan2018perceptions} discussed the drawbacks of existing defect prediction tools and highlighted future research directions through literature review and a survey of practitioners. After that, Tabassum et al.~\cite{tabassum2020investigation} conducted a study of JIT defect prediction in realistic online learning scenarios and concluded that the model trained with both within and cross-project data can outperform the model trained with within-project data only. Recently, Zeng et al.~\cite{Zeng2021Deep} revisited the deep learning based JIT defect prediction models and found that deep learning based approaches may not work better than simplistic model LApredict they proposed. Different from the existing work (i.e., commit-level JIT defect prediction), our model {\sc CompDefect} focus on function-level single-statement JIT defect prediction, which is more fine-grained defect identification task. Besides, previous work only give two coarse-grained outputs: defect-inducing or clean. {\sc CompDefect} can categorize the type of defect-inducing functions. \subsection{Defect Repair} Defect repair~\cite{gazzola2017automatic} is an active research topic and achieve a great progress. However, the current state of automated defect repair is limited to simple small fixes, mostly one-line patches~\cite{wen2018context,saha2017elixir}. Gupta et al.~\cite{gupta2017deepfix} proposed a defect repair tool named DeepFix for fixing compiler errors in introductory programming courses. DeepFix takes the whole program and outputs a single line fix. Ahmed et al.~\cite{ahmed2018compilation} also focused on compiler error fix and proposed another defect repair tool named TRACER, which outperforms DeepFix in terms of success rate. Martin et al.~\cite{white2019sorting} proposed DeepRepair to leverage the learned code similarities to select repair ingredients from code fragments which are similar to the buggy code. Tufano et al.~\cite{tufano2019empirical} performed an empirical study to assess the feasibility of using neural machine translation techniques for learning bug-fixing patches for real defects. They trained an Encoder-Decoder model which can translate buggy code into its fixed version. Hideaki et al.~\cite{hata2018learning} proposed a similar network and applied it to one-line diffs. Considering the complexity of defect repair, similar to previous work, our model {\sc CompDefect} also focus on the one-line code fix scenario. However, different from the existing work, the input of {\sc CompDefect} is the source code of changed function in a commit and it aims to provide a foundation for connecting defect identification and defect repair. {\sc CompDefect} can categorize the type of a defect and can fix it at the check-in time. \subsection{Pre-Trained Models in NLP and SE} Pre-trained technologies have achieved a big success in Natural Language Processing (NLP)~\cite{devlin2018bert,yang2019xlnet,liu2019roberta} and pre-trained models associated with programming languages~\cite{feng2020codebert,karampatsis2020scelmo,lewis2019bart} also make a great process of code intelligence. Kanade et al.~\cite{kanade2019pre} pre-trained a BERT model on a massive corpus of Python source codes through two tasks: masked language modeling and next sentence prediction. Lewis et al.~\cite{lewis2019bart} adopted a standard Transformer-based neural network to train a sequence-to-sequence model named BART. Later, Feng et al.~\cite{feng2020codebert} used Transformer-based neural architecture to propose a bimodal pre-trained model named CodeBERT for programming language and natural language by masked language modeling and replaced token detection. CodeBERT aims at learning general-purpose representations for supporting downstream NL-PL applications (e.g., code search, code documentation generation). Karampatsis et al.~\cite{karampatsis2020scelmo} pre-trained contextual embeddings on a JavaScript corpus by using the ELMo frame, which can be further used for program repair task. Guo et al.~\cite{guo2020graphcodebert} proposed a pre-trained model named GraphCodeBERT which can leverage code structure to learn code representation to improve code understanding. Recently, pre-trained models are widely used in software engineering (SE) and these models are used to learn the representation of source code. Gao et al.~\cite{gao21todo} proposed an approach named TDCleaner, a BERT-based neural network, to automatically detect and remove obsolete TODO comments from software repositories. In this paper, we also use GraphCodeBERT to generate the representation of function. \section{Results and Analysis} \label{results} \subsection{RQ1: How does {\sc CompDefect} perform on defect identification compared with state-of-the-art baselines?} \noindent \textbf{Motivation.} Just-in-time (JIT) defect prediction has received much attention in the software engineering and many state-of-the-art approaches are proposed~\cite{hoang2019deepjit,hoang2020cc2vec,huang2017supervised}. These approaches are built from simple model (e.g., CBS+) on manually designed features to complex model (e.g., DeepJIT) on semantic features and have make a great progress in JIT scenario. As for {\sc CompDefect} based on neural network, it can also identify whether a commit is a defect-inducing one by predicting if the modification to a function will introduce a defect. Therefore, we want to make a comparison between {\sc CompDefect} with those state-of-the-art semantic features based approaches. \noindent \textbf{Approach.} We treat recently proposed DeepJIT~\cite{hoang2019deepjit} and CC2Vec~\cite{hoang2020cc2vec} as the baseline methods and the introduction of them can be found in Section~\ref{setting}. There are two differences between {\sc CompDefect} and the two baselines: 1) the two methods can only estimate the defect-proneness of a commit at the commit level and a commit may contain a few hunks which changes a few functions, while {\sc CompDefect} estimates whether a function in a hunk of a commit is defect-inducing. That is, {\sc CompDefect} can estimate the defect-proneness of a commit at the hunk(function)-level, which means {\sc CompDefect} is more fine-grained than the baseline ones. 2) the two baselines can only predict a commit as a defect-inducing one or clean one, while {\sc CompDefect} can not only predict a commit defect-proneness but also can categorize the types of defect. Considering the two differences and to make a fair commit-level comparison, we make the following two hypothesizes for {\sc CompDefect}: 1) a function in a hunk of a commit will be treated as a buggy one if {\sc CompDefect} predicts it as a non-clean one; 2) a commit is predicted as defect-inducing one if there exists a least one function in a hunk of a commit predicted by {\sc CompDefect} as the defect-inducing one, otherwise the commit is predicted as a clean one. Besides, we use the widely used performance measures (i.e., Precision, Recall, F1-score, and AUC) to evaluate the difference among those methods. \noindent \textbf{Result.} The evaluation results are reported in Table~\ref{tab:rq1}. The best performance is highlighted in bold. According to the results, we find that our approach {\sc CompDefect} has the significant advantage over DeepJIT and CC2Vec on all performance measures. In particular, {\sc CompDefect} obtains 0.679 and 0.785 in terms of F1-score and AUC, which improves DeepJIT and CC2Vec by 39.0\% and 41.7\%, by 34.7\% and 37.3\% in terms of F1-score and AUC, respectively. As for Precision and Recall, {\sc CompDefect} also has a large improvement. Specifically, {\sc CompDefect} improves DeepJIT and CC2Vec by 32.8\% and 38.2\%, by 43.2\% and 44.2\% in terms of Precision and Recall, respectively. Besides, we surprisingly find that in our scenario, CC2Vec performs a little worse than DeepJIT, which, to some extent, means CC2Vec cannot capture more information than DeepJIT for existing state-of-the-art technique can utilize. \begin{table}[htbp] \centering \caption{Comparison among DeepJIT, CC2Vec and {\sc CompDefect} } \scalebox{1}{ \begin{tabular}{|c|c|c|c|c|c|} \hline \multicolumn{2}{|c|}{\textbf{Approach}} & \textbf{Precision} & \textbf{Recall } & \textbf{F1-score} & \textbf{AUC} \\ \hline \hline \multicolumn{2}{|c|}{{DeepJIT}} & 0.504 & 0.352 & 0.414 & 0.513 \\ \hline \multicolumn{2}{|c|}{{CC2Vec}} & 0.464 & 0.345 & 0.396 & 0.492 \\ \hline \multicolumn{2}{|c|}{{{\sc CompDefect}}} &\textbf{0.750} & \textbf{0.619} & \textbf{0.679} & \textbf{0.785} \\ \hline \multirow{2}[1]{*}{\textbf{$Improv.$}} & {$DeepJIT$} & 32.8\% & 43.2\% & 39.0\% & 34.7\% \\ \cline{2-6} & {$CC2Vec$} & 38.2\% & 44.2\% & 41.7\% & 37.3\% \\ \hline \end{tabular}% } \label{tab:rq1} \end{table}% \subsection{RQ2: How does {\sc CompDefect} perform on defect categorization compared with state-of-the-art baselines?} \noindent \textbf{Motivation.} Even though many approaches~\cite{kamei2013large,chen2018multi,hoang2020cc2vec,liu2017code} have been proposed for just-in-time defect prediction scenario, these approaches can only predict a commit as defect-inducing or not. They cannot categorize the type of defect. Different from previous work, {\sc CompDefect} can categorize the type of defect the defect-inducing function belongs. We totally consider 16 types of defects, which is introduced in Section~\ref{dataset}. Reporting the type of defect rather than ``buggy-or-clean'' can help developers better understand such a defect. {\sc CompDefect} makes a few progress in JIT-DP scenario even we only consider the one-statement function-level modification setting. \noindent \textbf{Approach.} To verify the effectiveness of {\sc CompDefect} in defect categorization task, we choose a pre-trained language representation BERT~\cite{devlin2018bert} and its optimized variants RoBERTa~\cite{liu2019roberta} and CodeBERT~\cite{feng2020codebert}, which are widely used in natural language processing and software engineering~\cite{gao21todo,pan2021automating}, and then be used for downstream tasks that we care about (like multiclass classification). We use these pretrained models (i.e., ``bert-base-uncased'', ``roberta-base'' and ``microsoft/codebert-base'') from Huggingface\footnote{https://huggingface.co/bert-base-uncased}. For a fair comparison, the input of these baselines is the same as the input of {\sc CompDefect}. That is, the buggy version function and the clean version function are treated as the input. In addition, since the limitation of the maximum length of baselines' input, we use the same strategy in {\sc CompDefect} to concatenate the two function vertically to assemble the whole input. Besides, for evaluate the performance of {\sc CompDefect} and these baselines in defect categorization scenario, we also use the four performance measures (i.e., Precision, Recall, F1-score and AUC). These classification metrics are defined for binary cases by default. When extending these binary metrics to multiclass, we use the ``macro'' averaging strategies, which are widely adopted in prior work~\cite{pan2021automating,arya2019analysis,wood2018detecting,huang2018automating}. ``macro'' strategy first calculates each metric for each class and then report the average value among all classes. \noindent \textbf{Result.} The evaluation results are reported in Table~\ref{tab:rq2} and the best results are highlighted in bold. On average, we find that {\sc CompDefect} outperforms baselines by 63\%, 218\% and 239\% in terms of Precision, Recall, and F1-score, respectively. In particular, {\sc CompDefect} improves BERT by 33\%, 250\% and 284\% in terms of Precision, Recall and F1-score, respectively. Compared with RoBERTa, {\sc CompDefect} improves RoBERTa by 77\%, 245\% and 275\% in terms of Precision, Recall and F1-score, respectively, which means that even though {\sc CompDefect} and RoBERTa have the same architecture, {\sc CompDefect} can learn more information with its related task (i.e., defect fix). Compared with CodeBERT, {\sc CompDefect} improves CodeBERT by 78\%, 158\% and 159\% in terms of Precision, Recall and F1-score, respectively, which also means {\sc CompDefect} can benefit from multi-task learning. In terms of AUC, {\sc CompDefect} still performs best. All the results indicate the priority of {\sc CompDefect} on categorizing the types of defects. \begin{table}[htbp] \centering \caption{Comparison among BERT, RoBERTa, CodeBERT and {\sc CompDefect} on explaining the types of defect} \scalebox{1}{ \begin{tabular}{|c|c|c|c|c|c|c|} \hline \multicolumn{2}{|c|}{\textbf{Approach}} & \textbf{Precision} & \textbf{Recall} & \textbf{F1-score} & \textbf{AUC$_{OVO}$} & \textbf{AUC$_{OVR}$} \\ \hline \hline \multicolumn{2}{|c|}{BERT} & 0.301 & 0.084 & 0.083 & 0.693 & 0.731 \\ \hline \multicolumn{2}{|c|}{RoBERTa} & 0.227 & 0.086 & 0.085 & 0.712 & 0.751 \\ \hline \multicolumn{2}{|c|}{CodeBERT} & 0.226 & 0.115 & 0.124 & 0.695 & 0.754 \\ \hline \multicolumn{2}{|c|}{\sc CompDefect} & \textbf{0.401 } & \textbf{0.295 } & \textbf{0.319 } & \textbf{0.723 } & \textbf{0.776 } \\ \hline \multirow{4}[0]{*}{$Improv.$} & $BERT$ & 33\% & 250\% & 284\% & 4\% & 6\% \\ \cline{2-7} & $RoBERTa$ & 77\% & 245\% & 275\% & 2\% & 3\% \\ \cline{2-7} & $CodeBERT$ & 78\% & 158\% & 159\% & 4\% & 3\% \\ \cline{2-7} & $Avg.$ & 63\% & 218\% & 239\% & 3\% & 4\% \\ \hline \multicolumn{7}{l}{``OVO'': stands for one-vs-one; ``OVR'': stands for one-vs-rest.}\\ \end{tabular}% } \label{tab:rq2}% \end{table}% \subsection{RQ3: How does {\sc CompDefect} perform on defect repair compared with the state-of-the-art baseline?} \noindent \textbf{Motivation.} Defect repair research is active and mostly dominated by techniques based on static analysis~\cite{mechtaev2016angelix} and dynamic analysis~\cite{wen2018context}. Even a great progress has been achieved, currently, the state of automated defect repair is limited to simple cases, mostly one-line patches~\cite{wen2018context,saha2017elixir}. Recently, defect repair tools based on machine learning especially for deep learning technology are proposed, which promotes the further development of defect repair. In particular, SequenceR, proposed by Chen et al.~\cite{chen2019sequencer}, is one of the most outstanding ones, which also mainly focus on one-line patch scenario. Therefore, we want to evaluate the performance difference between {\sc CompDefect} and SequenceR.\\ \textbf{Approach.} SequenceR can solely address one-line level bug fix. That is, it cannot identify whether a function is defect-inducing one and cannot categorize the type of defect in such a function. Therefore, we filter negative functions in original dataset and keep only positive functions. We refer to it as Function-SStuBs4J$_{\mathit{positive}}$, which contains 16 types of positive functions. Besides, SequenceR firstly does an abstraction operation on function. However, some function in Function-SStuBs4J$_{\mathit{positive}}$ cannot be executed successfully with the tool provided by SequenceR. Thus, we filter out these functions and finally Function-SStuBs4J$_{\mathit{positive}}$ has the positive function with 14 types. {We split 80\%, 10\% and 10\% of Function-SStuBs4J$_{\mathit{positive}}$ as training data (7,474 functions), validation data (934 functions) and testing data (934 functions), respectively}, and the distribution among each type of function as same as the original one. For a fair comparison, we train SequenceR and {\sc CompDefect} ({referred as {\sc CompDefect}$_\mathit{positive}$}) on the filtered training data, optimize them on the filtered validation data, and finally evaluate them on the filtered testing dataset. Moreover, for fully evaluating the capability of {\sc CompDefect}, we want to directly evaluate the {\sc CompDefect} trained on original training data (i.e., training data from Function-SStuBs4J, denoted as Training$_{\mathit{original}}$) on the testing data of Function-SStuBs4J$_{\mathit{positive}}$, denoted as Testing$_{\mathit{positive}}$. However, since Function-SStuBs4J$_{\mathit{positive}}$ and Function-SStuBs4J are not exactly the same split, Training$_{\mathit{original}}$ may contains the functions in Testing$_{\mathit{positive}}$. So, for a fair comparison, we identify the intersection of Training$_{\mathit{original}}$ and Testing$_{\mathit{positive}}$, and remove the intersection from Testing$_{\mathit{positive}}$ and denote it as Testing$_{\mathit{positive}\_\mathit{filtered}}$. For evaluating the two methods, we adopt two widely used performance measures: BLEU and Accuracy. \newline\noindent \textbf{Result.} { The evaluation results are reported in Table~\ref{tab:rq3} and the best results are highlighted in bold. On Testing$_{positive}$, {\sc CompDefect}$_\mathit{positive}$ performs better than SequenceR and outperforms SequenceR by 23.9\% and 29.5\% in terms of BLEU and Accuracy, respectively. On Testing$_{positive\_filtered}$, {\sc CompDefect}$_\mathit{positive}$ can also improve SequenceR by 29.6\% in terms of BLEU and perform similarly as SequenceR in terms of Accuracy. {\sc CompDefect} also outperform SequenceR on both performance measure. Besides, when comparing {\sc CompDefect} with {\sc CompDefect}$_\mathit{positive}$, we find that {\sc CompDefect} has better performance, which indicates that {\sc CompDefect} benefits from the multi-task learning and learns useful information from negative functions for defect repair. } \begin{table}[htbp] \centering \caption{Comparison between SequenceR and {\sc CompDefect} on defect repair } \scalebox{1}{ \begin{tabular}{|c|c|c|c|} \hline \textbf{Testing Data} & \textbf{Approach} & \textbf{BLEU} & \textbf{Accuracy} \\ \hline \hline \multirow{2}[0]{*}{{Testing$_{positive}$}} & {SequenceR} & 0.734 & 0.136 \\ \cline{2-4} & \textbf{{\sc CompDefect}$_\mathit{positive}$} & \textbf{0.964} & \textbf{0.193} \\ \hline \hline \multirow{3}[0]{*}{{Testing$_{positive\_filtered}$}} & {SequenceR} & 0.677 & 0.147 \\ \cline{2-4} & \textbf{{\sc CompDefect}$_\mathit{positive}$} & 0.962 & 0.130 \\ \cline{2-4} & {{\sc CompDefect}} & \textbf{0.972} & \textbf{0.232} \\ \hline \end{tabular}% } \label{tab:rq3}% \end{table \section{Experimental Setting} \label{setting} We first introduce the dataset we experiment on, then we present the baselines for different type of tasks. Following that, the evaluation metrics, experimental settings, and research questions are presented subsequently. \subsection{Dataset} \label{dataset} Program repair is an extremely important but difficult software engineering problem. Fixing simple defects (e.g., one-line defects or defects that fall into a small set of templates) is a good way to obtain acceptable performance. ManySStuBs4J~\cite{karampatsis2020often} is a collection of single-statement defect-fix change and have two versions: small size version and large size version. The small version contains 25,539 single-statement defect-fix changes mined from 100 popular open-source Java Maven projects, while the large version contains 153,652 single-statement defect-fix changes mined from 1,000 popular open-source Java projects. This dataset is annotated by whether those changes match any of a set of 16 defect patterns that appear often. To make our paper self-contained, we provide a brief introduction of each pattern as follows. \begin{itemize} \item \textbf{Change Identifier Used}. It checks whether an identifier that appears in an expression in a statement is replaced by another. It is easy for developers to accidentally use different identifiers instead of having the same type of expected identifier. Copying and pasting code is a potential source of such errors. \item \textbf{Change Numeric Literal}. It checks whether one numeric literal is replaced by another one. It is easy for developers to mix two numeric values in a program. \item \textbf{Change Boolean Literal}. It checks whether a Boolean literal was replaced. That is, True is replaced with False and vice-versa. \item \textbf{Change Modifier}. It checks whether a variable, function, or class is declared with the wrong modifiers. \item \textbf{Wrong Function Name}. It checks whether the function was incorrectly called. Functions with similar names and the similar signature are usual pitfall for developers. \item \textbf{Same Function More Args}. It checks whether an overloaded version of a function with more parameters is called. Functions with multiple overloads often make it confusing to developers. \item \textbf{Same Function Less Args}. It checks whether an overloaded version of the function with less arguments is called. For example, a developer may call a function with at least one default parameter and forget to initialize the parameter. \item \textbf{Same Function Change Caller}. It checks whether the caller object in the function call expression is replaced by another object. When there are multiple variables having the same type, the developer may perform an operation unexpectedly. \item \textbf{Same Function Swap Args}. It checks whether a function is called with some of its parameters swapped. When multiple function parameters are of the same type, developers can easily swap two of them without realizing if they do not accurately remember what each argument represents. \item \textbf{Change Binary Operator}. It checks whether a binary operator is replaced with another one of the same type by accident. For example, developers may often mix up comparison operators in expressions. \item \textbf{Change Unary Operator}. It checks whether a unary operator is replaced with another operator of the same type by accident. For example, developers may often forget ! operator in boolean expressions. \item \textbf{Change Operand}. It checks whether one of the operands in a binary operation is wrong. \item \textbf{More Specific If}. It checks whether an additional condition (\&\& operand) is added to the condition of an if statement. \item \textbf{Less Specific If}. It checks whether an additional condition which either itself or the original one needs to hold ($||$ operand) is added to the condition of the if statement. \item \textbf{Missing Throws Exception}. It checks whether the defect-fix adds a throw clause in a function declaration. \item \textbf{Delete Throws Exception}. It checks whether the defect-fix deletes a throw clause in a function declaration. \end{itemize} However, the details of this dataset is too simple to satisfy our task's requirement. That is, the original dataset mainly contains the types of defect, {the one statement buggy code and one statement fixed code.} However, our model needs the whole information about a changed function to capture more information inside the code. Besides, our study aims at defect identification, we also need to collect negative commits from studied projects since the original dataset only contains the positive commits. Therefore, we need an extension version of the large size of ManySStuBs4J using the improved toolkit\footnote{https://github.com/h4iku/repairSStuBs}, which fixes the issues in the process of original dataset extraction. \begin{figure*}[!htbp] \centerline{ \includegraphics[width=1.05\textwidth]{data-extraction-process.pdf}} \caption{The process of single statement commits filtering and function body extraction.} \label{fig:dataextractprocess} \end{figure*} \begin{figure*}[hbtp] \centerline{ \includegraphics[width=1\textwidth]{example.pdf} } \caption{The different contents of a specific function in different states: clean version, buggy version and fixed version.} \label{fig:example} \end{figure*} Firstly, we take ManySStuBs4J as the basis of the new dataset. We need more information of changed function in a commit to extend the dataset from two aspects since we try to combine the defect identification task, defect categorization task and defect repair task together: { 1) extract the function body where the defect-inducing statement or the defect-fix statement exists; 2) extract the clean function body before the defect-inducing statement was introduced. } { Secondly, the data extraction and extension process is illustrated in Fig.~\ref{fig:dataextractprocess}. Notice that we start from the COMMIT rather than the FUNCTION. In particular, as for extracting the positive/negative functions, we follow the same steps (e.g., selecting the same Java projects, identifying non-defect-fixing/defect-fixing commits, selecting single statement changes, creating Abstract Syntax Trees and filtering out clear refactoring) as the authors of ManySStuBs4J~\cite{karampatsis2020often} took: \begin{itemize} \item \textbf{Step 1}. We identify bug-fixing(non-bug-fixing) commits whose commit message contains one(none) of these keywords (i.e., error, buy, fix, issue, mistake, incorrect, fault, defect, flaw, and type). That is, we use the opposite selection strategy between selecting positive commits and negative commits. \item \textbf{Step 2}. We follow the same strict criteria using in ManySStuBs4J~\cite{karampatsis2020often} to select the commits with single statement modification. \item \textbf{Step 3}. We identify each scope of the modification (i.e., hunk in git) in the filtered commits and extract their corresponding bug-fixing(non-bug-fixing) function bodies. That is, we split one commit into hunks and extract the function body of modification in each hunk. \item \textbf{Step 4}. The SZZ algorithm is used to identify their corresponding bug-inducing(non-bug-inducing) commits. Right now, we can extract the corresponding bug-inducing(non-bug-inducing) function bodies. \item \textbf{Step 5}. We can extract the corresponding clean versions (i.e., the last version in time before the bug-inducing(non-bug-inducing) functions are modified) using PyDriller. Therefore, we can obtain the three versions of the function body for positive/negative functions. \end{itemize} } { Meanwhile, we also design four criteria for filtering unsuitable functions in (Steps 3-5), such as: } 1) Modified statements exist outside a function. This work focuses on the simple scenario, that is, function-level single statement defect prediction and defect repair. Therefore, we filter out those statements that lie outside the scope of a function, for example, statements for defining a global variable or object in a class. 2) Defects are introduced in newly added files or functions. {\sc CompDefect} needs three versions of a specific function. For newly added defective one, the clean version does not exist. Therefore, we filter out such cases. 3) Function names cannot be identified. On one hand, the modifications in a commit are made to the function name and then it is difficult to solve. On the other hand, the line of function is mapped incorrectly. In ManySStuBs4J, the authors label the line number of buggy or fixed code based on the result of AST, which may not be exactly correct with the original line in source code file. 4) Other failed issues. When errors occur in PyDriller or in original dataset, we cannot get the correct result. Take an example from the project of Activiti\footnote{This Activiti is a light-weight workflow and Business Process Management (BPM) Platform targeted at business people, developers and system admins.} shown in Fig.~\ref{fig:example}. There exists a function named $\mathit{getStencilset}$\footnote{This function is located at `` modules/activiti-modeler/src/main/java/org/activiti/rest/editor/main/StencilsetRestResource.java''. This fixed version is submitted at ``c015d11303339f50254a10be7335fd33546911ab'', while the buggy version is introduced at ``159d1ef8e0cf059165b17bb546f47f639559dfa9''.}. We extract three versions of this function: clean version, buggy version and fixed version. Buggy version means the state when the defect-inducing statement is introduced, clean version means the state before the defect-inducing statement is introduced, and fixed version means the state when the defect is fixed. The relationship among the three version can be illustrated in Fig.~\ref{fig:functionextractprocess}. We extract the three versions of function with the help of PyDriller~\cite{Spadini2018}, which is a Python framework that helps developers on mining software repositories. \begin{figure}[hbtp] \centerline{ \includegraphics[width=1\textwidth]{function-extraction-process.pdf} } \caption{The extraction process of the three versions of function and their relationship.} \label{fig:functionextractprocess} \end{figure} Finally, we build the dataset and name it as \textbf{Function-SStuBs4J} for defect identification, defect categorization and defect repair and the statistical information is shown in Table~\ref{tab:dataset}. \begin{table}[htbp] \centering \caption{The statistics for Function-SStuBs4J} \scalebox{.8}{ \begin{tabular}{|l|c|c||c|c|c|} \hline \textbf{Defect Type} & \textbf{Count} & \textbf{Ratio} & \multicolumn{1}{l|}{\textbf{Defect Type}} & \textbf{Count} & \textbf{Ratio} \\ \hline \hline Same Function Change Caller & 381 & 1.81\% & \multicolumn{1}{l|}{Same Function More Args} & 441 & 2.1\% \\ \hline Change Identifier Used & 1,599 & 7.6\% & \multicolumn{1}{l|}{Same Function More Args} & 1,169 & 5.55\% \\ \hline Change Modifier & 329 & 1.56\% & \multicolumn{1}{l|}{Same Function Swap Args} & 139 & 0.66\% \\ \hline Change Numeric Literal & 991 & 4.71\% & \multicolumn{1}{l|}{Change Boolean Literal} & 330 & 1.57\% \\ \hline Change Operand & 161 & 0.76\% & \multicolumn{1}{l|}{Less Specific If} & 484 & 2.3\% \\ \hline Change Binary Operator & 523 & 2.48\% & \multicolumn{1}{l|}{More Specific If} & 570 & 2.71\% \\ \hline Change Unary Operator & 338 & 1.61\% & \multicolumn{1}{l|}{Missing Throws Exception} & 10 & 0.05\% \\ \hline Wrong Function Name & 3,012 & 14.31\% & \multicolumn{1}{l|}{Delete Throws Exception} & 32 & 0.15\% \\ \hline \multicolumn{1}{|c|}{\textbf{ALL}} & \multicolumn{5}{c|}{\textbf{21,047}} \\ \hline \multicolumn{1}{|c|}{\textbf{Positive}} & \multicolumn{5}{c|}{\textbf{10,509}} \\ \hline \multicolumn{1}{|c|}{\textbf{Negative}} & \multicolumn{5}{c|}{\textbf{10,538}} \\ \hline \end{tabular}% } \label{tab:dataset} \end{table}% \subsection{Baselines} \label{baseline} Since there has no existing work which can identify whether a modification to a function may introduce defects, subsequently categorize the type of defect, and consequently repair it automatically, we make a comprehensive comparison among three types of baselines and {\sc CompDefect}: baselines for defect identification, baselines for defect categorization and baselines for program repair. For the defect identification task, we consider two well-known methods as baselines: DeepJIT~\cite{hoang2019deepjit} and CC2Vec~\cite{hoang2020cc2vec} since they are deep-learning based methods using the textual information of code. We briefly introduce the two methods as follows. \noindent $\blacksquare\ $\textbf{DeepJIT} is an end-to-end deep learning framework for Just-in-Time defect prediction. DeepJIT adopts a Convolutional Neural Network (CNN) model to automatically learn high-dimensional semantic features for commits. In particular, DeepJIT uses two CNN models to learn the representation of two parts of the input: one CNN for the commit message and another one for the code commits. Finally, the concatenation of two representations is treated as the input of fully-connected layer to output the probability of defect-introducing commit. \noindent $\blacksquare\ $\textbf{CC2Vec} is a distributed representation learning framework of commit. CC2Vec believes that the commit has hierarchical structure, which is ignored by DeepJIT. In particular, one commit is composed of a few changed files, one changed file is composed of a few hunks\footnote{https://git-scm.com/}, one hunk is composed of a few changed lines and one changed line is composed of a few changed tokens. To grasp the information of hierarchical structure in commits, CC2Vec models the Hierarchical Attention Network (HAN) with the help of the attention mechanism and multiple comparison functions are used to identify the difference of modified code (i.e., added code and removed code). CC2Vec targets at learning a representation of code commits guided by their accompanying commit messages, which represents the semantic intent of the code commits. For defect categorization task, we choose three methods BERT~\cite{devlin2018bert}, RoBERTa~\cite{liu2019roberta} and CodeBERT~\cite{feng2020codebert} as the baselines and briefly introduce them as follows. \noindent $\blacksquare\ $\textbf{BERT} is designed to pre-train deep bidirectional representations from unlabeled text by jointly conditioning on both left and right context in all layers and its capability of capturing the semantic and context information of sentence has been verified in many work~\cite{gao21todo,lewis2019bart,zhang2020sentiment}. BERT consists of 12-layer transformers and each of the transformers is composed of a self-attention sub-layer with multiple attention heads. BERT takes sequence of tokens as the input of embedding component. Given a sequence of tokens $x=\{x_1, ..., x_T\}$ with length of $T$, BERT will calculate the contextualized representations $H^l= \{h_{1}^{l}, ..., h_{T}^{l}\} \in \Re ^{T \times D}$, where $l$ represents the $l_{th}$ transformer layer and $D$ represents the dimension of the representation vector. As a result, the pre-trained BERT model can be fine-tuned with just one additional output layer to create state-of-the-art models for a wide range of tasks, such as binary or multiclass classification. \noindent $\blacksquare\ $\textbf{RoBERTa} is a robustly optimized version of BERT by iterating on BERT's pretraining procedure (e.g., training the model longer, using bigger batches over more data) and {\sc CompDefect}'s encoder has the same architecture with RoBEATa. \noindent \textbf{CodeBERT} is another pre-trained model on the basic of BERT for programming language, which is a multi-programming-lingual model pre-trained on NL(Natural Language)-PL(Programming Language) pairs in six programming languages (i.e., Python, Java, JavaScript, PHP, Ruby and Go). For defect repair task, we also consider one state-of-the-art method SequenceR~\cite{chen2019sequencer} as baseline. We briefly introduce it as follows. \noindent $\blacksquare\ $\textbf{SequenceR} is a sequence-to-sequence deep learning model which aims at automatically fixing defects by generating one-line patches. The one-line patch means that the defect can be fixed by replacing a single buggy line with a single correct line. SequenceR proposes a novel buggy context abstraction process to organize the fault localization information into a representation. Such a representation preserves concise, suitable and valuable information for deep learning model understanding the context of the bug and consequently be used to predict the fix. Then, the representation is fed to a trained sequence-to-sequence model to execute patch inference. In particular, it generates multiple single-lines of code that will be treated as the potential one-line patches for the defect. Finally, SequenceR generates the most suitable patches by formatting the code and replacing the buggy line with the proposed lines. \subsection{Evaluation Metrics} There are four statistics with respect to classification task: (i) True Positive (TP) represents the number of functions classified as defective and they are truly defective ones. (ii) True Negative (TN) represents the number of functions classified as non-defective and they are truly non-defective ones. (iii) False Positive (FP) represents the number of functions classified as defective and they are truly non-defective ones. (iv) False Negative (FN) represents the number of non-defective functions and they are truly defective ones. Therefore, based on the four possible statistics, three widely used performance measures (i.e., $Precision$, $Recall$ and $F1$-$score$) can be defined to evaluate the performance of {\sc CompDefect} and baselines as follows: \noindent $\blacksquare\ $\textbf{Precision}: the proportion of functions that are correctly classified as defective among those labeled as defective: $ Precision=\frac{TP}{TP+FP}$. \noindent $\blacksquare\ $\textbf{Recall}: the proportion of defective functions that are correctly classified: $ Recall=\frac{TP}{TP+FN} $. \noindent $\blacksquare\ $\textbf{F1-score}: the harmonic mean of precision and recall. It evaluates if an increase in precision (or recall) outweighs a reduction in recall (or precision), respectively: $ F1\text{-}score=\frac{2 \times Precision \times Recall}{Precision + Recall} $. \noindent $\blacksquare\ $\textbf{AUC}: the Area Under the receiver operator characteristics Curve (AUC) is also used to measure the discriminatory power of {\sc CompDefect} and baselines, i.e., the ability to differentiate between defective or non-defective functions. AUC calculates the area under the curve plotting the true positive rate (TPR) versus the false positive rate (FPR), while applying multiple thresholds to determine if a function is defect-inducing or not. The value of AUC ranges between 0 (the worst discrimination) and 1 (the perfect discrimination). Besides, to better evaluate how approaches perform on defect repair task, we consider two widely used metrics: BLEU (Bilingual Evaluation Understudy)~\cite{papineni2002bleu} and Accuracy~\cite{chen2019sequencer}. \noindent $\blacksquare\ $\textbf{BLEU}: it is a widely used measure for neural machine translation task~\cite{klein2017opennmt} and software related task~\cite{gu2016deep,jiang2017automatically}. In our task, it is used to calculate the similarity between the generated code snippet and the referenced correct code snippet. It has a score range of 0 and 1. The higher the BLEU score, the closer the generated code is to the referenced one. It first computes the geometric average of the modified $n$-gram precisions (i.e., $p_n$) by using $n$-grams up to the maximum number of grams $N$ (i.e., set as 4 in our paper) and positive weights $w_n$ summing to one. Then, it computes the brevity penalty BP, $ BP=\begin{cases} 1,& if\ c>r \\ e^{(1-r/c)}, & if\ c\le r \end{cases} $ ,in which, $c$ represents the length of the candidate code snippet and $r$ represents the effective reference corpus length. Finally, the BLEU score can be calculated as follows: $ BLEU = BP\cdot exp\left ( \sum_{n=1}^{N}w_nlog{p_n} \right ) $ \noindent $\blacksquare\ $\textbf{Accuracy}: the target of defect repair model is to fix as many defects as possible. Therefore, we also use accuracy to evaluate the effectiveness of models for defect fixing, it is calculated as the ratio between the number of correctly fixed defects by an approach and the number of total defects to be fixed. \subsection{Empirical setting.} We implement our {\sc CompDefect} in Python with the help of Pytorch framework and pre-trained model on Huggingface\footnote{https://huggingface.co/}. The pre-trained GraphCodeBERT model is used as the encoder for embedding training samples, which can leverage semantic structure of code to learn code representation and also can be easily extended for downstream tasks. Besides, we also use Transformer decoder~\cite{vaswani2017attention} as the generator of fixed code. In our model, each version function is embedding as a 768 dimensional vector. During the training phase, the parameters of {\sc CompDefect} are optimized using Adam with a batch size of 32. We also use $ReLu$ and $tanh$ as the activation function. A dropout of 0.1 is used for dense layers before calculating the final probability. The maximum number of epoch in our experiment is 50. The models (i.e., {\sc CompDefect} and baselines) with the best performance on the validation set is used for our evaluations. As for dataset split, we use 80\%, 10\% and 10\% of original dataset as training data, validation data and testing data, respectively. Notice that, for each part of the data, we keep the distribution among each type of function as same as the original one. \subsection{Research Questions} To comprehensively evaluate the effectiveness of {\sc CompDefect}, we investigate the following research questions. \begin{itemize} \item\textbf{RQ1:} How does {\sc CompDefect} perform on defect identification compared with state-of-the-art baselines? \item\textbf{RQ2:} How does {\sc CompDefect} perform on defect categorization compared with state-of-the-art baselines? \item\textbf{RQ3:} How does {\sc CompDefect} perform on defect repair compared with the state-of-the-art baseline? \end{itemize} \section{Threats to Validation} \label{threats} \textbf{Threats to Internal Validity} mainly lie in the potential faults in the implementation of our model. To minimize such threats, we not only implement these methods by pair programming but also make full use of the pre-trained models such as GraphCodeBERT~\cite{guo2020graphcodebert} and BERT~\cite{devlin2018bert}. Besides, we directly use the original source code of baselines and the same hyperparameters used in original method are adopted in our paper. All of the datasets used in our study are publicly available from previous work~\cite{karampatsis2020often}, and we extend these dataset for our investigated scenario. \noindent \textbf{Threats to External Validity} mainly lie in the studied projects used in this study. To reduce such threats, we opted to selecting high popularity Java projects. The popularity of a project is determined by computing the sum of $z$-scores of forks and stars~\cite{karampatsis2020often}. However, all studied projects are open source projects, it is still unknown whether our {\sc CompDefect} can work well on commercial projects. In the future, we plan to reduce this threat by considering more additional commercial projects. \noindent \textbf{Threats to Construct Validity} mainly lie in the adopted performance metrics in our evaluations. To reduce such threat, we use different types of performance measure for different tasks. For classification task, we use the widely-used Area Under the Curve (AUC) score to evaluate the performance of the each method and it needs to be set a threshold manually. We also consider some widely performance metrics which need to manually set a threshold e.g., Precision, Recall and F1-score. For generation task, we use two well-known metrics namely BLEU and Accuracy.
{'timestamp': '2022-04-12T02:31:25', 'yymm': '2204', 'arxiv_id': '2204.04856', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04856'}
arxiv
\section{Introduction} \input{intro} \section{Related Work} \input{related_work} \section{Features and Classifiers} \label{sec:data} \subsection{Features Extraction} We extract a multitude of features from voice. We use the OpenSMILE toolkit \cite{eyben2010opensmile}, using the inbuilt \textit{emobase2010.conf} configuration file. This configuration file extract features such as intensity and loudness, cepstrum (e.g MFCC), LPC, pitch and voice quality (e.g jitter, shimmer). The OpenSMILE feature configuration file thus extracts a 1582 dimensional feature vector per audio recording. We call this Ovec feature in Section \ref{sec:results} We use features extracted from the pre-trained PANN model \cite{kong2019panns} on audio datasets and from the pre-trained model on VGG dataset \cite{45611}. We extract feature representations from the PASE model \cite{pase, pase+} and combine them for analysis. The PASE model feature representation is extracted from the CNN block containing 64 units prior to the linear feed forward network. PASE features were generated with the dimensionality of 256 x number of frames. The PASE features were then normalized to the training dataset to generate feature representation which is scaled with zero mean and unit variance. We extract the spectral features of audio files using librosa \cite{mcfee2015librosa} as our audio processing library. The spectral features include, \begin{itemize}[leftmargin=*] \itemsep0em \item \texttt{Zero Crossing Rate} - The rate at which the speech signal passes the zero value. \item \texttt{Spectral Centroids} - The weighted mean of frequencies in the speech spectrogram. \item \texttt{Spectral Roll Off} - This computes the roll off frequency, the point under which 85\% of the power signal is contained. \item \texttt{Tempo} - It is a measure of the beats per minute in the signal. \item \texttt{Root Mean Square Energy} - This computes RMS energy per frame in the signal based on audio samples. \item \texttt{MFCC} - Mel-Frequency Cepstral Coefficients a.k.a.the coefficients of Mel-frequency cepstrum, are one of the most commonly considered spectral features. We used the first 20 coefficients for this experiment. \item \texttt{MFCC Delta First Order} - Temporal MFCC delta features. \item \texttt{MFCC Delta Second Order} - Acceleration MFCC delta features. \end{itemize} For all these spectral features except Tempo, we extracted several statistical features such as min, max, mean, rms (root mean square), median, inter quartile range, first, second and third quartile, standard deviation, skew, and kurtosis, to get better representation of the data. This collectively returned a (14,1) statistical feature per spectral feature. For MFCCs we concatenate the 14 dimension spectral feature per MFCC coefficient, obtaining a 280 sized vector. Eventually, we obtain 833 spectral features which we call as the Custom feature extractor as referred in section \ref{sec:results}. We extracted the YAMNet based feature extractor as well as Open-L3 \cite{Cramer:LearnMore:ICASSP:19} based feature extractor for each voice recording to compare their performance with Vggish \cite{hershey2017cnn} based feature extractor. \subsection{Classifier Description} \subsubsection{CNN model with Pase and Spectrogram features} We built CNN models as our base classifier. Based on the scale of our collected dataset, one important aspect we want to have is the generalization of our algorithm. In the CNN experiments, we use two set of features: the spectrogram and the problem agnostic speech encoder (PASE) \cite{pase, pase+} features. Pase features are designed to be general, robust and transferable features that capture the meaningful information of speech and less likely to contain the superficial features which were sufficient for the training data only. \subsubsection{Machine learning based binary classifiers} We use simpler machine learning based binary classifiers such as RandomForest, Support Vector machines, Logistic regression in order to perform classification. \section{Data and Experiments} \label{sec:experiments} \subsection{Dataset and its description} In this section, we describe the collection process and the statistics of the COVID-19 voice dataset. We used a dataset collected under clinical supervision and curated by Merlin Inc., a private firm in Chile. The subjects usually have symptoms of coughing, sneezing, breathing difficulties etc. So these related symptoms were also recorded with the voice information to account for symptomatic and asymtomatic COVID-19 diagnosis. The COVID positive or negative label was indicated by the subject's lab-certified test results. Additionally metadata also contained information about preexisting conditions such as smoking preference, asthma and detailed comments about the speakers health during the dataset generation. The data samples were recorded over a smartphone, and sampled at 8khz. The dataset consists of 421 positive cases and 989 negative cases. Each case here represents a unique speaker. To control the phonemic variation of the recordings, we asked the subjects to record their voice speaking alphabets a-z, counting from 1-20 and producing coughs. To limit the physical contact and to simulate real application scenario, subjects recorded in a quiet room environment. The total duration of the positive files is 17.5 hours and negative files is 20.5 hours with over 37 hours of total data. \subsection{Experiments} We perform numerous experiments for the detection of COVID where the input is only the voice signal. Each speaker has six voice recordings namely cough, the elongated vowels /AH/, /UW/ and /IY/, alphabet and count. In all experiments, the speakers in the training set were separate from those in the test set to ensure that the models do not inadvertently simply capture speaker identity. Thus, we split the data in $k$ fold cross-validation sets based on speaker identity. We run various classifiers on our data such as RandomForest (RF), Support Vector Machines (SVMs) with Radial Basis Function and Logistic Regression (LR). We analysed all the spectral features on each of these classifiers including combination of features like Ovec and Custom. The RandomForest runs on $k$ fold equal to 3, 5 and 10. We run grid search on all these classifiers to find the best parameters, particularly experimenting with $\gamma$. We report the performance in the Section \ref{sec:results}. \section{Results and Discussion} \label{sec:results} From the dataset consisting of a total of 1410 speakers (or 8460 audio recordings), the entire metadata was received for a total of 815 speakers, out of which there were 296 males and 519 females. \subsection{Age based Analysis} We have broadly categorized the ages into four groups, including the ones whose age was missing, shown in Table \ref{tab:gender_table}. \begin{itemize}[leftmargin=*] \itemsep0em \item Group 1 : age $<=$ 30 years \item Group 2 : 30 $<$ age $<=$ 40 years \item Group 3 : 40 years $<$ age \item Group 4 : Age was missing \end{itemize} For patients with age $>$ 40, our classifier is capable of recognizing COVID-19 patients accurately 65\% of the times whereas those with age $<$ 30, classifier is capable of accurately detecting 56\% of the times. \begin{table}[h] \centering \begin{tabular}{|c|c|c|c|c|} \hline \textbf{Gender} \textbf{Group1} & \textbf{Group2} & \textbf{Group3} & \textbf{Group4} \\ \hline \hline Male & 65 & 80 & 80 & 71\\ Female & 127 & 129 & 145 & 115 \\ \hline \end{tabular} \caption{Gender based age analysis} \label{tab:gender_table} \vspace{-2mm} \end{table} The classifier is more reliably able to detect COVID-19 in case of females over males. \begin{figure}[h] \centering \includegraphics[width=8.5cm, height=4cm]{images/symptoms_0_plot_2.png} \includegraphics[width=8.5cm, height=4cm]{images/symptoms_1_plot_2.png} \caption{The top figures shows the distribution of symptoms in COVID-19 positive patients and the lower figure is the distribution of symptoms in COVID-19 negative individuals (breath-diff stands for breathing difficulty). The rows represents each symptom whereas the column represents the frequency of occurrence of a symptom which are marked by dots} \end{figure} We find Sore-throat is present in most of COVID-19 cases where we are able to detect COVID-19 in 57\% of the cases. When sneeze is present, the classifier is capable of detecting COVID-19 in 47\% of the cases. When cough is a known symptom for the speaker, then our classifier detects COVID-19 in 73\% of the cases. \subsection{Smokers and People with Asthma} Having a previous history of asthma or smoking might put people at a higher risk of COVID \cite{asthma}. We received data where people had a history of asthma and/or were smokers. Table \ref{tab:asthma_table} shows the statistics in our data. Our experimental results indicate asthama is more correlated to COVID-19 than smoking. For the patients with COVID-19 and smoking habit, our classifier is accurate by detecting COVID-19 in 66 \% of cases whereas those with COVID-19 and asthama cases we are able to detect COVID-19 accurately in 80 \% of the cases. \begin{table}[h] \centering \begin{tabular}{c|c|c} \textbf{Gender} & \textbf{Has Asthma} & \textbf{Is Smoker} \\ \hline \hline Male & 12 & 95\\ Female & 38 & 139 \end{tabular} \caption{Gender based asthma and smoker statistics} \vspace{-4mm} \label{tab:asthma_table} \end{table} \subsection{Difference in days of diagnosis and data collection } The data collection process introduces a delay between the COVID onset and when the voice sample was recorded. Each speaker is labelled for the day they got diagnosed and the day they recorded their data. Table \ref{tab:diagnosis_table} shows number of people distribution depending on when they were diagnosed (eg. 1 week ago, between 1-2 weeks or greater than 2 weeks) \begin{table}[h] \centering \begin{tabular}{ |c|c| } \hline \textbf{Diagnosis Day Range} & \textbf{Number of People} \\ \hline \hline Diagnosis day $<=$ 7 days & 95 \\ \hline 7 days $<$ Diagnosis day $<=$ 14 days & 209 \\ \hline Diagnosis day $>$ 14 days & 159 \\ \hline Diagnosis day not known & 37 \\ \hline \end{tabular} \caption{Difference between Diagnosis Day and Data collection day} \vspace{-4mm} \label{tab:diagnosis_table} \end{table} In general, we find that COVID-19 can be more reliably detected for patients whose voice samples have been collected within 14 days of diagnosis, than for those whose samples were collected after this period. \begin{table}[] \centering \resizebox{1.0\columnwidth}{!}{ \begin{tabular}{|c|c|c|c|} \hline \textbf{Classifier} & \textbf{Feature} & \textbf{AUC} \\ \hline \hline Random Forest & Ovec & 0.76 \\ Random Forest & PANN & 0.78 \\ Random Forest & vggish & 0.59 \\ Random Forest & Open-L3 & 0.64 \\ Random Forest & YAMNet & 0.72 \\ Random Forest & Custom Feat & 0.82 \\ Random Forest & Ovec + Custom Feat & 0.84 \\ Random Forest & Ovec + Custom Feat + vggish & 0.82 \\ Random Forest & Ovec + custom feature + YAMNet & 0.86 \\ CNN & Spectrogram & 0.69 \\ CNN & PASE & 0.73 \\ \hline \end{tabular} } \caption{Results obtained on the full dataset set. Here Ovec refers to features obtained using OpenSMILE, PASE using PASE architecture, custom spectral feature. Random Forest classifier is robust and have improved performance in comparison to CNN based classifier} \label{tab:my_label} \vspace{-4mm} \end{table} \subsection{Audio type analysis} We analyze classifier performance according to the audio-type, to identify which type of recording is most suited to capture the voice signatures related to COVID-19. Our results indicate that vowel /IY/ and vowel /UW/ are better at detecting COVID-19 than other types of audio samples. Cough samples are also useful in detecting COVID-19. \subsection{Overall Classifier results} Table \ref{tab:my_label} proves our hypothesis that a binary classifier such as Random Forest can perform better for COVID-19 detection than CNN counterparts when faced with limited data. Our experiments have observed that Open-L3 features perform the same as vggish feature representations. Figure \ref{fig:Best} shows the best AUC score achieved of 0.94 and ROC score of 0.85 for the Random forest based classifier with Ovec and custom features on a trimmed down dataset where 20\% samples were heard to contain noise in the recordings. \begin{figure}[h] \centering \begin{subfigure}[b]{0.23\textwidth}\centering \includegraphics[width=\textwidth,height=3cm]{images/roc_auc.png} \end{subfigure} \begin{subfigure}[b]{0.23\textwidth}\centering \includegraphics[width=\textwidth,height=3cm]{images/prec_recall.png} \end{subfigure} \hspace*{\fill} \caption{AUC of 0.94 and ROC of 0.85 is obtained using Random Forest based classifier with Ovec and custom feature vector} \label{fig:Best} \end{figure} \section{Conclusion} \label{sec:discuss} Motivated by the urgent need to have alternative methods to augment the medical tests, we designed the experimental setup for the COVID-19 analysis using a wide variety of voice samples. Our analysis provided insights into the type of voice sample which would work best for detecting COVID-19 patients which is the \/eee\/ and \/ooo\/ sounds. Our COVID-19 dataset used in the study was acquired through self-recording using a smartphone application making acquistion feasible at large scale. The preliminary results imply a feasibility for the use of this globally accessible data collection for Sars-COV-2 detection although it doesn't replace RT-PCR or RAT tests. Our results prove that using a binary classifiers such as Random Forest are more feasible to separate between COVID-19 vs non COVID-19 speakers over data intensive neural network classifiers. We find these binary classifiers to generate better and robust results given the limited amount of data available for analysis. \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-12T02:28:39', 'yymm': '2204', 'arxiv_id': '2204.04802', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04802'}
arxiv
\section{Related Works} \clearpage \bibliographystyle{icml2020} \section{Computing Regret Values with Q Values} \section{Oracles and Modules} The illustrative figures of different oracles and modules are displayed in Figure~\ref{fig:udef_oracles_and_modules}. \begin{figure}[H] \centering \subfigure[RO]{ \includegraphics[width=0.175\textwidth]{figures/ro.pdf} \label{fig:ro} } \subfigure[AO]{ \includegraphics[width=0.175\textwidth]{figures/ao.pdf} \label{fig:ao} } \subfigure[Pre-tran.]{ \includegraphics[width=0.175\textwidth]{figures/pre.pdf} \label{fig:pre} } \subfigure[Post-tran.]{ \includegraphics[width=0.175\textwidth]{figures/post.pdf} \label{fig:post} } \caption{Design of neural networks in UDEF. We note that both LAO and GAO share the same structure.} \label{fig:udef_oracles_and_modules} \end{figure} \newpage \section{Details of Pretraining Procedure} In this section, we present the detailed pseudo codes of different subroutines in UDEF. \begin{algorithm}[ht] \caption{Pretraining of Average Oracle} \begin{algorithmic}[1] \STATE Initialize the AO net's parameters $\psi$ \WHILE{not terminate} \STATE Determine the number of actions, $k$ \STATE Randomly sample a batch of games, $\bm{X}$ \STATE Compute the solutions of $\bm{X}$ as labels $\bm{y}$ \STATE Using $\langle\bm{X}, \bm{y}\rangle$ to train $\psi$ \ENDWHILE \end{algorithmic} \end{algorithm} If the dimension of LAS is larger than or equal to the number of actions, we can select a set of neurons to train the transform modules independently. We can also train the two modules jointly by using AO. \begin{algorithm}[ht] \caption{Pretraining of Transform Modules} \begin{algorithmic}[1] \STATE Given the pretrained AO $\psi$, the pre-transform and post-transform modules $\phi_{1}$ and $\phi_{2}$ \WHILE{not terminate} \STATE Randomly sample a batch of Q values and reaching probabilities $\bm{X}$ \STATE Compute the solutions under $\psi$ of $\bm{X}$ as labels $\bm{y}$ \STATE Using $\langle\bm{X}, \bm{y}\rangle$ to train $\phi_{1}$ and $\phi_{2}$ \ENDWHILE \end{algorithmic} \end{algorithm} \section{Conclusion} In this work, we propose UDEF, a novel unified perspective of DEF, which leverages the powerful expressivity of neural networks to unify the two widely-used frameworks, i.e., PSRO and CFR. The four novel components of UDEF include: i) a novel response oracle, ii) two transform modules, iii) two average oracles, and iv) a novel optimization method to select the components of the two frameworks. Experiments demonstrate the effectiveness of UDEF. We believe that this work unifies and generalizes the two largely independent frameworks and may accelerate research on both frameworks from a unified perspective. \section{Experiments} \begin{figure*}[!htbp] \centering \subfigure[NFSP with $hs=0.1$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_nfsp_0_1.pdf}\label{fig:udef_nfsp_0_1}} \subfigure[NFSP with $hs=0.5$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_nfsp_0_5.pdf}\label{fig:udef_nfsp_0_5}} \subfigure[NFSP with $hs=0.9$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_nfsp_0_9.pdf}\label{fig:udef_nfsp_0_9}} \subfigure[CFR with $hs=0.1$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_cfr_0_1.pdf}\label{fig:udef_cfr_0_1}} \subfigure[CFR with $hs=0.5$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_cfr_0_5.pdf}\label{fig:udef_cfr_0_5}} \subfigure[CFR with $hs=0.9$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_cfr_0_9.pdf}\label{fig:udef_cfr_0_9}} \caption{Results of \textsc{NashConv} of UDEF with optimizing transform modules only in NFSP and Deep CFR. The legend in the figure should read as $\langle hs, meta\_train, meta\_lr, meta\_steps, meta\_train\_max\rangle$.} \label{fig:tran_opt} \end{figure*} In this section, we present the experiment results of UDEF. \subsection{Experiment Setup} We focus on Leduc poker, which is a widely used experimental domain in equilibrium finding~\cite{southey2005bayes,lanctot2019openspiel,muller2019generalized}. We compare our UDEF algorithm to NFSP~\cite{heinrich2015fictitious} and Deep CFR~\cite{brown2019deep}. To this end, we pretrain the pre-transform and the post-transform modules with PSRO and CFR with a batch of 1000 for $10^4$ episodes. The DRL algorithm used in RL is DQN~\cite{mnih2015human}, where an online and a target Q networks are introduced to perform the TD-learning. The Q, RP and policy networks in RO are configured as multilayer perceptrons (MLPs) with one hidden layer containing 256, 64 and 256 hidden neurons, respectively. We use MSE loss and employ the Adam optimizer~\cite{kingma2015adam} with a default learning rate of $0.01$ for training the RO. The sampling policy generating new experiences uses $hs\in\{0.1, 0.5, 0.9\}$ to represent the approximation of PSRO and CFR and the combination of both. For the distillation of the policy, we train the policy for 5 episodes. The two transform modules are MLPs with one hidden layer of 64 neurons. We choose the dimension of LAS as 16, which is more than twice the number of actions in Leduc poker, i.e., 3, and enables us to pretrain the transform modules with both PSRO and CFR methods simultaneously. Similarly to policy networks, we use MSE loss and Adam optimizer with a learning rate of $5\cdot 10^{-3}$ for pretraining. For the training of AO and transform modules, we choose $\eta=0.95$ to smooth the current average policy and the new response. Throughout the experiment, we vary the values of the learning rate, the update steps and the max number of iterations to optimize AO and transform modules. We denote these values as $meta\_lr$, $meta\_steps$ and $meta\_train\_max$, respectively. The values differ in different algorithms, as described in next sections. In each iteration, we sample the experiences from game with $10^4$ episodes for RO and $10^3$ episodes for augmenting the meta-game. The maximum number of iterations is 50. All results are averaged over 3 seeds. \begin{figure*}[ht] \centering \subfigure[NFSP with $hs=0.1$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_neural_nfsp_0_1.pdf}\label{fig:udef_neural_nfsp_0_1}} \subfigure[NFSP with $hs=0.5$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_neural_nfsp_0_5.pdf}\label{fig:udef_neural_nfsp_0_5}} \subfigure[NFSP with $hs=0.9$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_neural_nfsp_0_9.pdf}\label{fig:udef_neural_nfsp_0_9}} \subfigure[CFR with $hs=0.1$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_neural_cfr_0_1.pdf}\label{fig:udef_neural_cfr_0_1}} \subfigure[CFR with $hs=0.5$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_neural_cfr_0_5.pdf}\label{fig:udef_neural_cfr_0_5}} \subfigure[CFR with $hs=0.9$]{\includegraphics[width=0.325\textwidth]{figures/results/udef_neural_cfr_0_9.pdf}\label{fig:udef_neural_cfr_0_9}} \caption{Results of \textsc{NashConv} of UDEF with optimizing transform modules and average oracles in NFSP and Deep CFR. The legend in the figure should read as $\langle hs, meta\_train, meta\_lr, meta\_steps, meta\_train\_max\rangle$.} \label{fig:tran_opt_ao} \end{figure*} \subsection{Optimizing Transform Modules Only} In the first experiment, we optimize the transform modules where the AOs are represented by explicit functions. The results are shown in Figure~\ref{fig:tran_opt}. We select the NFSP and linear CFR with the neural network representation of the transform modules as our baselines, where linear CFR accelerates CFR by two orders of magnitude~\cite{brown2019solving}. For NFSP (the top row of Figure~\ref{fig:tran_opt}), we set $meta\_lr=10^{-4}$, $meta\_steps\in\{2, 5, 10\}$ and the optimization of the AO and transform modules is fixed during the training as $meta\_train\_max=50$. For $hs=0.1$ and $0.5$, we observe that the training outperforms the baseline for all values of $meta\_steps$. On the contrary, for $hs=0.9$ the training becomes more unstable: setting $meta\_steps=2$ or $5$ results in worse performance and $meta\_steps=10$ may only become competitive with the baseline. For the CFR results (the bottom row of Figure~\ref{fig:tran_opt}), we set $meta\_lr=10^{-5}$ as we observe that all results with $meta\_lr=10^{-4}$ as in NFSP are not stable and worse than the baseline, which implies that CFR is more sensitive to the optimizing of the transform modules than NFSP. The similar results are also observed with varying $meta\_steps\in\{1, 2, 5\}$. When $hs=0.5$ or $0.9$ and $meta\_steps=1$ and $2$, UDEF outperforms the baselines. We note that varying $meta\_train\_max$ does not influence the results much. \subsection{Optimizing Transform Modules and AOs} In the second experiment, we optimize both transform modules and AOs. We focus on optimizing the LAO, where GAO is represented by an explicit function. The neural network structure of the LAO is Conv1D-based meta solver proposed in~\cite{feng2021discovering}. We randomly sample $10^6$ random games and compute the corresponding LAO values as labels to pretrain the LAO. In each iteration, we use the LAO to generate the values for averaging the responses and optimize LAO simultaneously with transform modules. The experimental results are shown in Figure~\ref{fig:tran_opt_ao}. The results with NFSP (the top row of Figure~\ref{fig:tran_opt_ao}) suggest that the neural network representation of LAO increases instability during training, compared with the explicit functions, as the training of AO and transform modules influences more parameters of UDEF. Still, we observe that setting $meta\_steps$ properly results in UDEF outperforming the NFSP. Similarly as in previous section, the larger $hs$ gets the more unstable the training becomes. For $hs=0.5$, UDEF consistently outperforms the baseline. With CFR (the bottom row of Figure~\ref{fig:tran_opt_ao}), UDEF outperforms the baseline when $hs=0.1$. However, for $hs$ equal to $0.5$ or $0.9$, UDEF becomes inferior in all configurations. This indicates that optimizing both AO and the transform modules makes the training extremely unstable. Overall, we make three key observations: i) increasing the value of $hs$, i.e., generating new experiences from historical responses, rather than from a new response, makes the algorithms unstable when optimizing AOs and the transform modules, ii) as linear CFR uses linear average as LAO, which puts more weights on later responses, linear CFR becomes more unstable compared to NFSP and may result in instability of training even without the optimization of AO and the transform modules, and iii) UDEF is sensitive to the hyperparameters of training -- more sophisticated hyperparameter selection methods, as well as the optimizing methods, is hence required to increase the representation power of neural networks in UDEF. \section{Introduction} Extensive-form games provide a versatile framework capable of representing multiple agents, imperfect information, and stochastic events~\cite{shoham2008multiagent}. A lot of research has been done in the domain of two-player zero-sum extensive-games, and the developed methods have been successfully applied to real-world defender-attacker scenarios~\cite{tambe2011security}, heads-up limit/no-limit hold’em poker~\cite{bowling2015heads,brown2018superhuman,moravvcik2017deepstack}, multiplayer hold’em poker~\cite{brown2019superhuman}, and no-press diplomacy~\cite{gray2020human,bakhtin2021no}. Both in theory and applications, two paradigms proved themselves superior to their alternatives in extensive-form game solving: policy space response oracles (PSRO)~\cite{lanctot2017unified,muller2019generalized} which provide a unified solution of fictitious play~\cite{heinrich2015fictitious} and double oracle~\cite{mcmahan2003planning,jain2011double} algorithms, and counterfactual regret minimization (CFR)~\cite{zinkevich2007regret,lanctot2009monte}. Despite their initial success, scaling both approaches to games of real-world sizes proved troublesome, as action spaces reached hundreds of thousands of actions. This motivated the use of universal approximators capable of efficient representation of computationally demanding functions required in both CFR and PSRO. The resulting algorithms are commonly referred to as \enquote{deep} alternatives of thereof because they employ deep neural networks as approximators~\cite{brown2019deep,srinivasan2018actor,moravvcik2017deepstack,steinberger2020dream}. Together they form the framework of \textbf{deep equilibrium finding} (DEF), which we define as: \begin{displayquote} \emph{Finding the equilibrium of games through methods empowered by deep neural networks.} \end{displayquote} Even though PSRO and CFR share some similarities, there are some key differences: i) PSRO methods use Q value to obtain the policy, while CFR methods rely on counterfactual regret values; ii) PSRO use meta-strategies, e.g., a Nash strategy, to average the strategies over action probabilities, while CFR methods take the average strategy to approximate Nash equilibrium; and iii) the sampling methods for computing new responses differ as well -- PSRO methods take the new response itself to sample in the game and CFR methods use the previous responses. These differences make both frameworks often regarded as distinct and the research on each framework is to a large extent evolving independently. A very natural and important question often asked in the literature is then which framework is superior to the other. There are no clear answers as we observe contradicting evidence -- fictitious play is claimed to be superior to CFR in~\cite{ganzfried2020fictitious} while the opposite conclusion is reached in~\cite{brown2019deep}. We believe no simple answer exists as the performance of both frameworks seems intrinsically linked to structural properties of games, and their relation to efficient computability remain unexplored. Therefore, we analyze an alternative question: \emph{can we represent the two frameworks in a unified way and select among them automatically?} To this end, we propose a unified framework for deep equilibrium finding. Our Unified DEF (UDEF) relies on following four main contributions: i) a novel response oracle (RO) which can compute Q values, reaching probability values and baseline values, which provides necessary values for both PSRO and CFR algorithms; ii) two transform modules, i.e., pre-transform and post-transform, represented by neural networks, first transform the outputs of RO to a latent additive space (LAS), which can be the action probabilities as PSRO or counterfactual values as CFR, and then transform from LAS to action probabilities for execution; iii) two average oracles, i.e., local average oracle (LAO) and global average oracle (GAO), where LAO operates on LAS and GAO is used for evaluation only; and iv) a novel method inspired by fictitious play to optimize the transform modules and average oracles, which can automatically select the optimal combinations of components of the two frameworks. Experiments on Leduc poker game demonstrate that UDEF can outperform both original frameworks. We believe that this work unify and generalize the two largely independent frameworks and can accelerate the research on both frameworks from a unified perspective. \section{Preliminaries} We focus on fully rational sequential interactions represented using imperfect-information extensive-form games. Imperfect-information games is a general model capable of modelling finite multiplayer games with limited observations. This section first describes this model. Later on, we explain how the two renowned DEF algorithms leverage it to compute rational strategies. \subsection{Imperfect-Information Games} An imperfect-information game (IIG) ~\cite{shoham2008multiagent} is a tuple ($N, H, A, P, \mathcal{I}, u$), where $N = \{1,...,n\}$ is a set of players and $H$ is a set of histories (i.e., the possible action sequences). The empty sequence $\emptyset$ corresponds to a unique root node of game tree included in $H$, and every prefix of a sequence in $H$ is also in $H$. $Z \subset H$ is the set of the terminal histories. $A(h) = \{a:(h,a) \in H\}$ is the set of available actions at a non-terminal history $h \in H$. $P$ is the player function. $P(h)$ is the player who takes an action at the history $h$, i.e., $P(h) \mapsto P \cup \{c\}$. $c$ denotes the ``chance player'', which represents stochastic events outside of the players' control. If $P(h) = c$ then chance determines the action taken at history $h$. Information sets $\mathcal{I}_i$ form a partition over histories $h$ where player $i \in \mathcal{N}$ takes action. Therefore, every information set $I_i \in \mathcal{I}_i$ corresponds to one decision point of player $i$ which means that $P(h_1) = P(h_2)$ and $A(h_1) = A(h_2)$ for any $h_1, h_2 \in I_i$. For convenience, we use $A(I_i)$ to represent the set $A(h)$ and $P(I_i)$ to represent the player $P(h)$ for any $h \in I_i$. For $i \in N$, $u_i: Z \rightarrow \mathbb{R}$ specifies the payoff of player $i$. A player's behavioral strategy $\sigma_i$ is a function mapping every information set of player $i$ to a probability distribution over $A(I_{i})$. A joint strategy profile $\sigma$ consists of a strategy for each player $\sigma_1, \sigma_2, ...$, with $\sigma_{-i}$ referring to all the strategies in $\sigma$ except $\sigma_i$. Let $\pi^{\sigma}(h)$ be the reaching probability of history $h$ if players choose actions according to $\sigma$. Given a strategy profile $\sigma$, the overall value to player $i$ is the expected payoff of the resulting terminal node, $u_i(\sigma) = \sum_{h \in Z}\pi^\sigma(h)u_i(h)$. We denote all possible strategies for player $i$ as $\Sigma_{i}$. The canonical solution concept is Nash Equilibrium (NE). The strategy profile $\sigma$ forms a NE between the players if \begin{equation} u_{i}(\sigma) \geq u_{i}(\sigma_{i}', \sigma_{-i}), \forall i\in N. \end{equation} To measure of the distance between $\sigma$ and NE, we define $\textsc{NashConv}_{i}(\sigma)=\max_{\sigma_{i}'} u_{i}(\sigma_{i}', \sigma_{-i}) - u_{i}(\sigma)$ for each player and $\textsc{NashConv}(\sigma)=\sum_{i\in N}\textsc{NashConv}_{i}(\sigma)$. Other solution concepts such as (coarse) correlated equilibrium require different measures~\cite{marris2021multi}. Though our method is general and may be applied to different solution concepts, we focus on NE in this paper. \subsection{PSRO and CFR} We present a brief introduction to existing DEF algorithms. \paragraph{PSRO.} PSRO is initialized with a set of randomly-generated policies $\hat{\Sigma}_{i}$ for each player $i$. At each iteration of PSRO, a meta-game $M$ is built with all existing policies of players and then a meta-solver computes a meta-strategy, i.e., distribution, over polices of each player (i.e., Nash, $\alpha$-rank or uniform distributions). The joint meta-strategy for all players is denoted as $\bm{\alpha}$, where $\alpha_{i}(\sigma)$ is the probability that player $i$ takes $\sigma$ as his strategy. After that, an oracle computes at least one policy for each player, which is added into $\hat{\Sigma}_{i}$. We note when computing the new policy for one player, all other players' policies and the meta-strategy is fixed, which corresponds to a single-player optimization problem and can be solved by DQN or policy gradient algorithms. NFSP can be viewed as a special case of PSRO with the uniform distributions as the meta-strategies. \paragraph{CFR.} Let $\sigma^t_i$ be the strategy used by player $i$ in round $t$. We define $u_i(\sigma, h)$ as the expected utility of player $i$ given that the history $h$ is reached and then all players play according to strategy $\sigma$ from that point on. Let us define $u_i(\sigma, h\cdot a)$ as the expected utility of player $i$ given that the history $h$ is reached and then all players play according to strategy $\sigma$ except player $i$ who selects action $a$ in history $h$. Formally, $u_i(\sigma,h)=\sum_{z \in Z}\pi^\sigma(h,z)u_i(z)$ and $u_i(\sigma, h\cdot a)=\sum_{z \in Z}\pi^\sigma(h \cdot a,z)u_i(z)$. The \textit{counterfactual value} $u_i^\sigma(I)$ is the expected value of an information set $I$ given that player $i$ attempts to reach it. This value is the weighted average of the value of each history in an information set. The weight is proportional to the contribution of all players other than $i$ to reach each history. Thus, $u_i^\sigma(I) = \sum_{h\in I} \pi^\sigma_{-i}(h)\sum_{z \in Z}\pi^\sigma(h,z)u_i(z)$. For any action $a \in A(I)$, the counterfactual value of an action $a$ is $u_i^\sigma(I,a)= \sum_{h\in I} \pi^\sigma_{-i}(h)\sum_{z \in Z}\pi^\sigma(h \cdot a,z)u_i(z)$. The \textit{instantaneous regret} for action $a$ in information set $I$ in iteration $t$ is $r^t(I,a)=u_{P(I)}^{\sigma^t}(I,a)-u_{P(I)}^{\sigma^t}(I)$. The cumulative regret for action $a$ in $I$ in iteration $T$ is $R^T(I,a) =\sum_{t=1}^{T}r^t(I,a)$. In CFR, players use \textit{Regret Matching} to pick a distribution over actions in an information set proportional to the positive cumulative regret on those actions. Formally, in iteration $T+1$, player $i$ selects actions $a\in A(I)$ according to probabilities \begin{equation} \sigma^{T+1}(I,a)= \begin{cases} \frac{R^T_{+}(I,a)}{\sum_{b \in A(I)}R^T_{+}(I,b)} & \text{if $\sum\limits_{b \in A(I)}R^T_{+}(I,b) >0$} \\ \frac{1}{|A(I)|}& \text{otherwise,} \end{cases}\nonumber \end{equation} where $R^T_{+}(I,a)=\max\{R^T(I,a),0\}$ because we are concerned about the cumulative regret when it is positive only. If a player acts according to CFR in every iteration, then in iteration $T$, $R^T(I) \leq \Delta_i\sqrt{|A_i|}\sqrt{T}$ where $\Delta_i= \max_z u_i(z)-\min_zu_i(z)$ is the range of utility of player $i$. Moreover, $R^T_i \leq \sum_{I\in \mathcal{I}_i}R^T(I) \leq |\mathcal{I}_i|\Delta_i\sqrt{|A_i|}\sqrt{T}$. Therefore, $\lim_{T \rightarrow \infty}\frac{R^T_i}{T} = 0$. In two-player zero-sum games, if both players' average regret $\frac{R^T_i}{T} \leq \epsilon$, their average strategies $(\overline{\sigma}^T_1,\overline{\sigma}^T_2)$ form a $2\epsilon$-equilibrium~\cite{waugh2009abstraction}. Most previous works focus on tabular CFR, where counterfactual values are stored in a table. Recent works adopt deep neural networks to approximate the counterfactual values and outperform their tabular counterparts~\cite{brown2019deep,steinberger2019single,li2019double,li2021cfr}. \section{Related Works} The first line of works we base our approach on is derived from policy space response oracle (PSRO)~\cite{lanctot2017unified,muller2019generalized}, which is a generalization of the classic double oracle methods~\cite{mcmahan2003planning}. Given a game (e.g., poker), PSRO constructs a higher-level meta-game by simulating outcomes for all match-ups of a population of players’ policies. Then, it trains new policies for each player (via an oracle) against a distribution over the existing meta-game policies (typically an approximate Nash equilibrium, obtained via a meta-solver), appends these new policies to the meta-game population, and iterates. The widely-used neural fictitious self-play (NFSP)~\cite{heinrich2016deep} algorithm, which is an extension of fictitious play~\cite{brown1951iterative}, is a special case of PSRO. Recent works focus on improving the scalability~\cite{mcaleer2020pipeline,smith2020iterative}, improving the diversity of computed responses~\cite{perez2021modelling}, introducing novel meta-solvers, i.e., $\alpha$-rank and correlated equilibrium ~\cite{muller2019generalized,marris2021multi}, and applying to mean-field games~\cite{muller2021learning}. The second line is counterfactual regret (CFR) minimization, which is a family of iterative algorithms that are the most popular approach to approximately solve large imperfect-information games~\cite{zinkevich2007regret}. The original CFR algorithm relies on the traverse of the entire game tree, which is impractical for large-scale games. Therefore, sampling-based CFR variants ~\cite{lanctot2009monte,gibson2012generalized} are proposed to solve large-scale games, which allows CFR to update regrets on parts of the tree for a single agent. Nowadays, neural network function approximation is applied to CFR to solve larger games. Deep CFR~\cite{brown2019deep} is a fully parameterized variant of CFR that requires no tabular sampling. Single Deep CFR~\cite{steinberger2019single} removes the need for an average network in Deep CFR and thereby enabled better convergence and more efficient training. Other extensions also demonstrate the effectiveness of neural networks in CFR~\cite{li2019double,li2021cfr,schmid2021player}. \section{Unified Deep Equilibrium Finding (UDEF)} \begin{algorithm}[t] \caption{Deep Equilibrium Finding (DEF)} \label{alg:def} \begin{algorithmic}[1] \STATE policy lists for players $\mathcal{L}=\times\mathcal{L}_{k}$ \WHILE{TO is \textbf{False}} \STATE Local AO (LAO) to obtain average policies $\bar{\mathcal{L}}=\times\bar{\mathcal{L}_{k}}$, which is used for the next iteration \STATE RO to find new responses against opponents' policies \ENDWHILE \STATE Global AO (GLO) for evaluation. \end{algorithmic} \end{algorithm} After introducing the context, we move to the main part of the paper where we present the unified perspective of the deep equilibrium finding. The existing DEF algorithms may be represented as Algorithm~\ref{alg:def}, which consists three oracles: \begin{itemize} \item \textbf{Response Oracle} (RO): The response oracle identifies an ``optimal'' response to the opponents' static policies. The response will specify the behavioral strategy at each infoset, based on either Q values as in PSRO or the counterfactual values as in CFR. \item \textbf{Average Oracle} (AO): There are two AOs. The local AO (LAO) is used to compute the sampling policy to sample the experiences from the game, and the global AO (GAO) is used for evaluation. Specifically, the LAO in PSRO can be Nash equilibrium strategies or the $\alpha$-rank distribution and the GAO is the last strategy used for sampling. In CFR, the LAO can be uniform or linear average, as well as the GAO. \item \textbf{Termination Oracle} (TO) determines whether to end the learning process or continue, which is most often driven by the chosen solution concept, e.g., the exploitability in case of the Nash equilibrium. \end{itemize} The structure of the unified DEF (UDEF) framework proposed in this work is displayed in Figure~\ref{fig:ro_with_tran}. After RO which computes the new response (denoted as new resp.) we plug the pre-transform module (denoted as pre-tran.) to interpret the results to an linear additive space (LAS), where LAO can take the average of the responses -- the historical responses (denoted as his. resp.) and the new response (new resp.) -- in the hidden space. Then, we plug the post-transform module (denoted as post-tran.) to transform the results from the linear additive space to the policy which is used in the next iteration. The GAO is also used for evaluation only. \begin{figure}[ht] \centering \includegraphics[width=0.35\textwidth]{figures/flows/udef.pdf} \caption{Unified Deep Equilibrium Finding (UDEF)} \label{fig:ro_with_tran} \end{figure} \subsection{Design of Oracles and Modules in UDEF} Here we describe the design of the neural networks in the oracles and modules in UDEF, which plays a fundamental role in generalizability of UDEF. \paragraph{Response Oracle.} The response oracle computes the player's new policy against the average policy of the opponents. In PSRO and its variants, the response oracle returns a Q-value network, where the action with the maximum Q value is taken at each infoset. In CFR and its variants, the response oracle returns the counterfactual regret values, and the action is picked according to regret matching. We observe that the counterfactual regret values may be computed from the Q values, with a baseline value (BV) computed through the sampling policy. For MC-CFR~\cite{Lanctot09mccfr}, the reaching probability is also important for computing the counterfactual values. Any attempt for unification thus relies on estimating both the Q values and the reaching probabilities (RP). Due to estimation errors, when the infoset is closer to the root node, the reaching probability estimation is more accurate; when the infoset is closer to the terminal nodes, the Q value estimation is more accurate. With both Q value and reaching probability, we may hence balance the usage of both for more accurate decision making. For computing the counterfactual regret values from Q values, we introduce a policy network to track the sampling policy and use it to compute the baseline values efficiently. For their usage in RO, the Q values and RP values are obtained from the Q and RP networks, respectively, and the BV is calculated by taking the average of Q values and the action probabilities output by the policy network. To summarize, the RO includes three networks: i) a Q value network to estimate the Q value\footnote{A practical implementation of DQN~\cite{mnih2015human} employs an online Q network and a target Q network for TD-learning.}, ii) an RP network to estimate the reaching probability of the current infoset, and iii) a policy network which tracks the sampling policy and is used for computing counterfactual regret values. \paragraph{Average Oracles.} We design two average oracles. For the local average oracle, we use the network introduced in~\cite{feng2021discovering} and generalize it to represent the linear average function used in CFR variants. For GAO, we can also use the same structure as LAO to make the oracle differentiable, or use explicit functions as adopted in PSRO and CFR. \paragraph{Transform Modules.} The two transform modules play important roles in generalizability of the UDEF framework. The pre-transform module takes the Q values, the reaching probabilities (RP) and the baseline values (BV), which is the weighted average of the Q values with the weights outputed by the policy network in RO, as the input and has two branches as the outputs. For the first branch, we use Parametric Rectified Linear Unit (\texttt{PReLU})~\cite{he2015delving} as the activation function for each dimension of LAS where \begin{align} \text{PReLU}(y_{i})= \begin{cases} y_{i}, & \text{if} \quad y_{i}\geq 0 \\ a_{i}\cdot y_{i}, & \text{if} \quad y_{i}< 0, \end{cases} \end{align} where $a_{i}$ is optimized. We note that if $a_{i}=0$, PReLU becomes similar to CFR$^{+}$ and if $a_{i}=1$, it is equal to vanilla CFR. The same approach is adopted in~\cite{srinivasan2018actor}. The second branch uses \texttt{softmax} as the activation function. The post-transform module transforms the values in LAS to the probability distribution over legal actions. Therefore, we use \texttt{softmax} function as the activation function of the final layer. To handle the illegal actions, we include a large negative value as the penalty to the values of the illegal actions before the \texttt{softmax} operation of both pre-transform and post-transform modules, which ensures the probability of selecting illegal actions remains zero. \subsection{Optimization of UDEF} Given the architecture of different modules in UDEF, in this section, we provide the details of the training procedure. We first introduce the pretraining scheme of the AOs and transform module to speed up the training and then describe how the modules are optimized. \textbf{Pretraining.} The random initialization of the AOs and the transform modules may result in the training being difficult. We hence pretrain them with either PSRO or CFR as the staring point. The two pretraining scheme are: \begin{itemize} \item \emph{CFR-pretraining.} We first pre-train the AO to a linear average function. We also pretrain the pre-transform module to compute the counterfactual regret values and the post-transform module to do the regret-matching. \item \emph{PSRO-pretraining.} We first pre-train the AO to the following solution concepts: Nash strategy, uniform strategy, and $\alpha$-rank strategy. The pre-transform module and the post-transform module are pre-trained to be softmax and identity function, respectively. \end{itemize} \begin{algorithm} \caption{Optimization of RO} \label{alg:dqn_rp} \begin{algorithmic}[1] \STATE Initialize the Q and target Q network $\theta$ and $\bar{\theta}$ \STATE Initialize the RP network $\phi$ and the policy network $\zeta$ \WHILE{Not terminated} \STATE Simulate the game with sampling policies of players, and push $\langle s, a, s', r, rp_{s}, rp_{s'}\rangle$ to replay buffer\label{alg:dqn_rp_rollout} \STATE Distill sampling policy into a new policy network $\zeta'$~\label{alg:dqn_rp_distill} \STATE Train the Q network by minimizing the TD-error: $ \theta = \theta - \nabla [r+\mathbb{E}[\bar{\theta}(s')]-\theta(s)]^{2} $~\label{alg:dqn_rp_td} \STATE Update the target Q network: $\bar{\theta}=\tau \bar{\theta}+(1-\tau)\theta$ \STATE Train the RP network by minimizing the MSE error: \\ $\phi = \phi - \lambda_{\phi} \nabla [(rp_{s}-\psi(s))^{2} + (rp_{s'}-\psi(s'))^{2}] $~\label{alg:dqn_rp_rp} \STATE Update $\zeta$ with $\zeta'$~\label{alg:dqn_rp_zeta} \ENDWHILE \end{algorithmic} \end{algorithm} \paragraph{Optimizing RO.} The algorithm for optimizing the RO is shown in Algorithm~\ref{alg:dqn_rp}. We first simulate the game by sampling policies of players to generate new experiences, both the transition of states and the reaching probability into the replay buffer (Line~\ref{alg:dqn_rp_rollout}). One of the key differences of PSRO and CFR lies in the sampling method for generating new experiences: PSRO uses the new response to sample the experiences, while CFR uses the historical responses. We hence introduce a smooth parameter $hs\in[0, 1]$ to balance the sampling with historical responses and the new response. If $hs=0$, we use the historical responses with the transform modules for generating the new experience, which corresponds to the sampling method of CFR. If $hs=1$, we use the new response with the transform modules. After generating the new experiences, we distill the sampling policy into a new policy network $\zeta'$~(Line~\ref{alg:dqn_rp_distill}), where the policy network is the sampling of the current iteration and is used for computing baseline values in the next iteration. We use reinforcement learning methods, e.g., DQN~\cite{mnih2015human}, to estimate the Q values through minimizing the TD-error where $\mathbb{E}[\bar{\theta}(s')]$ is the expected Q values of $s'$~(Line~\ref{alg:dqn_rp_td}). We use the sampling policy to compute $\mathbb{E}[\bar{\theta}(s')]$, which differs from the $max$ action used in DQN~\cite{mnih2015human}. Therefore, we distill the policy into $\zeta'$ first and only update $\zeta$ after training both Q and RP networks~(Line~\ref{alg:dqn_rp_zeta}). We use the supervised method to train the RP network. The RP network is then employed to predict the reaching probabilities of both $s$ and $s'$ for a transition~(Line~\ref{alg:dqn_rp_rp}). \begin{algorithm} \caption{Optimizing of AOs and transform modules} \label{alg:meta_optim} \begin{algorithmic}[1] \STATE Given the current joint strategy profile $\sigma$, the two AOs and two transform modules' parameters $\psi=\{\psi_{lao}, \psi_{gao}, \psi_{pre}, \psi_{post}\}$ \FOR{$i\in N$} \STATE Compute the best response $\sigma'_{i}$ against $\sigma_{-i}$ \ENDFOR \STATE Train the parameters in $\psi$ to approximate the joint policy $\eta\sigma_{i}+(1-\eta)\sigma'_{i}$ with the loss of action probability \end{algorithmic} \end{algorithm} \paragraph{Optimizing AOs and Transform Modules.} Our objective is to optimize the AO and the two transform modules to find the optimal parameters of UDEF~\cite{feng2021discovering}. However, it is difficult to compute the gradients of $\textsc{NashConv}(\sigma)$ in IIGs, especially for large domains. Therefore, we employ the idea of fictitious play~\cite{heinrich2015fictitious}. Suppose that the current policy for evaluation is $\sigma$, and $\sigma'_{i}$ is a new best response against $\sigma_{-i}$. We optimize the three modules to approximate the policy $\eta\sigma_{i}+(1-\eta)\sigma'_{i}$, where $\eta$ is a smoothing parameter. The details of the process are described in Algorithm~\ref{alg:meta_optim}, and proposition~\ref{prop:exploit} proves that it decreases $\textsc{NashConv}(\sigma)$. After the update of LAO, GAO and transform modules, we recompute the meta-game, as well as the values for LAO and GAO, and start a new iteration. We may also use the idea of PSRO, where the meta-game is built between the policy $\sigma$ and new responses $\sigma'_{i}, \forall i\in N$, and NE or $\alpha$-rank distribution~\cite{lanctot2017unified,muller2019generalized} is used to generate the target policy during the optimization. We will investigate this idea and other efficient optimization methods in future works. \begin{proposition} \label{prop:exploit} The $\textsc{NashConv}(\sigma)$ is decreased through approximating the new average policy $\eta\sigma_{i}+(1-\eta)\sigma'_{i}$. \end{proposition} \begin{proof} For each player $i$, suppose the utility of playing $\sigma_{i}$ against $\sigma_{-i}$ is $u_{i}$ and the utility of playing $\sigma'_{i}$ against $\sigma_{-i}$ is $u'_{i}$. Because $\sigma'_{i}$ is the best-response, $u'_{i}\geq u_{i}$. If $u'_{i}= u_{i}$, $\textsc{NashConv}_{i}(\sigma)=0$ for $i$ and the modules are not updated. In case $u'_{i}>u_{i}$, the utility of playing $\eta\sigma_{i}+(1-\eta)\sigma'_{i}$ is $\eta u_{i} + (1-\eta) u'_{i}$, which is strictly greater than $u_{i}$. Therefore, the $\textsc{NashConv}_{i}(\sigma)$ of player $i$ is decreased when training AO and transform modules to approximate the policy $\eta\sigma_{i}+(1-\eta)\sigma'_{i}$. This result holds for each player, $\textsc{NashConv}(\sigma)$ thus can be decreased. \end{proof} \section{Analysis of UDEF} In this section, we prove the equivalence of UDEF to PSRO and CFR under specific configurations. As such, UDEF unifies and generalizes the two main directions of DEF. \begin{proposition}[UDEF $\rightarrow$ PSRO] Let the pre-transform module be equal to softmax and the post-transform module to the identity function. Then UDEF reduces to PSRO. \end{proposition} \begin{proof} As RO outputs the Q values, when the pre-transform module is the softmax, the output of the pre-transform module is a distribution over actions, which corresponds to the behavioral strategy. Note that the Q values of illegal actions are penalized with a large negative value, which ensures that the probabilities of illegal action are always zero. PSRO will operate on the action probabilities, i.e., the values in LAS correspond to the action probabilities. After applying the LAO on the outputs of all responses, where the values can correspond to a uniform distribution, an NE strategy or an $\alpha$-rank distribution, we obtain the averaged values in LAS, which is still a distribution over actions. If the post-transform module is an identity mapping, the output of this oracle is exactly the softmax distribution over Q values. Because PSRO makes computing the best-response a single-agent RL problem, we use only the Q values from the new response for sampling the new experiences, i.e., $hs=0$. PSRO uses the policy the opponent responses to for evaluation, therefore, the GAO is a vector with zero values everywhere except for the last element, which is one. \end{proof} \begin{proposition}[UDEF $\rightarrow$ CFR] Let the pre-transform module map Q$\rightarrow$ Regret values and the post-transform module represent regret matching. Then UDEF reduces to CFR. \end{proposition} \begin{proof} The Q values, RP values and the BV are obtained from the RO. The training procedure displayed in Algorithm~\ref{alg:dqn_rp} ensures that the BV is the average value of the Q values weighted by the sampling policy. The counterfactual regret value is a linear combination of Q values, RP values, and the BV. As such, it can be approximated by the pre-transform module represented by a neural network. The LAO is uniform in vanilla CFR~\cite{zinkevich2007regret} and a linear average in linear CFR~\cite{brown2019solving}. Both of the LAOs can be approximated by a neural network as well. The post-transform module implements regret matching, which can also be approximated by a neural network. One of the key differences between PSRO and CFR lies in the fact that the policy CFR uses for evaluation differs from the policy the opponent plays against. The GAO in CFR is the uniform distribution in vanilla CFR and the linear average in the linear CFR, which can both be also represented by a neural network. Because CFR utilizes the historical responses to generate new experiences, we set $hs=1$ as the sampling policy. \end{proof} \begin{table}[ht] \caption{Summary of different algorithms.} \label{tab:summary} \centering \begin{tabular}{c|l|c|c|c|c} \toprule\toprule \multicolumn{2}{c|}{} & NFSP & PSRO & CFR & LCFR\\ \midrule \multicolumn{2}{c|}{RO}& \multicolumn{2}{c|}{DQN} & \multicolumn{2}{c}{DQN+RP+BV}\\ \midrule \multirow{2}{*}{AO}&LAO & Uni. & Nash& Uni. & Lin.\\ \cmidrule{2-6} &GAO & \multicolumn{2}{c|}{$[0, \dots, 1]$} & Uni.&Lin.\\ \midrule \multicolumn{2}{c|}{Pre-tran.} & \multicolumn{2}{c|}{Softmax} & \multicolumn{2}{c}{Regret}\\ \cmidrule{1-6} \multicolumn{2}{c|}{Post-tran.} & \multicolumn{2}{c|}{Identity} & \multicolumn{2}{c}{Match} \\ \midrule \multicolumn{2}{c|}{Sampling} & \multicolumn{2}{c|}{new response} & \multicolumn{2}{c}{historical responses} \\ \bottomrule\bottomrule \end{tabular} \end{table} A summary of the correspondences of different algorithms with the configurations of UDEF is depicted in Table~\ref{tab:summary}. Whenever the average oracles and transform modules are represented by neural networks, we may efficiently shift between different algorithms in a differentiable way. UDEF hence operates on a much more general space than any of the existing algorithms, which can be potentially used to search for more powerful equilibrium finding algorithms. \section{Related Works} \clearpage \balance \bibliographystyle{icml2022}
{'timestamp': '2022-04-12T02:34:53', 'yymm': '2204', 'arxiv_id': '2204.04930', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04930'}
arxiv
\section{Experimental Set-up} \subsection{Real-world Dataset}\label{sec:apdx_dataset} \input{appendix_files/dataset} \subsection{Link Prediction} For link prediction, we split 5\% and 10\% of edges for validation and test set, respectively. We fix the negative edges for the test set and sample negative edges for the training set at each iteration. \subsection{Synthetic Dataset}\label{sec:apdx_dataset_syn} \input{appendix_files/dataset_syn} \subsection{Distribution of Degree and Homophily of Datasets}\label{sec:apdx_dist_degree_and_homophily} \input{appendix_files/dist_degree_and_homophily} \subsection{Model \& Hyperparameter Configurations}\label{sec:apdx_model} \input{appendix_files/model_details} \subsection{CGAT Implementation}\label{sec:apdx_cgat} \input{appendix_files/cgat} \subsection{Wall-clock Time Experimental Set-up}\label{sec:apdx_wall_clock_time} \input{appendix_files/wall_clock_time} \clearpage \section{Results} \subsection{Proof of Proposition}\label{sec:apdx_proof} \input{appendix_files/proof} \subsection{Full Result of Synthetic Graph Experiments}\label{sec:apdx_synthetic} \input{appendix_files/synthetic} \subsection{Label-agreement Study for Other Datasets and Deeper Models}\label{sec:apdx_label_agreement} \input{appendix_files/label_agreement} \subsection{Wall-clock Time Result}\label{sec:apdx_wall_clock_time_result} \input{appendix_files/wall_clock_time_result} \subsection{Sensitivity Analysis of Hyper-parameters}\label{sec:apdx_sensitivity} \input{appendix_files/sensitivity} \subsection{Datasets} \paragraph{Real-world datasets} We use a total of 17 real-world datasets (Cora, CiteSeer, PubMed, Cora-ML, Cora-Full, DBLP, ogbn-arxiv, CS, Physics, Photo, Computers, Wiki-CS, Four-Univ, Chameleon, Crocodile, Flickr, and PPI) in diverse domains (citation, co-authorship, co-purchase, web page, and biology) and scales (2k - 169k nodes). We try to use their original settings as much as possible. To verify research questions 1 and 2, we choose four classic benchmarks: Cora, CiteSeer, PubMed in the transductive setting, and PPI in the inductive setting. See appendix~\ref{sec:apdx_dataset} for detailed description, splits, statistics (including degree and homophily), and references. \paragraph{Synthetic datasets}\label{sec:synthetic-data} We generate random partition graphs of $n$ nodes per class and $c$ classes~\citep{fortunato2010community}, using \texttt{NetworkX} library~\citep{hagberg2008exploring}. A random partition graph is a graph of communities controlled by two probabilities $p_{in}$ and $p_{out}$. If the nodes have the same class labels, they are connected with $p_{in}$, and otherwise, they are connected with $p_{out}$. To generate a graph with an average degree of $d_{avg} = n \cdot \delta$, we choose $p_{in}$ and $p_{out}$ by $p_{in} + (c - 1) \cdot p_{out} = \delta$. The input features of nodes are sampled from overlapping multi-Gaussian distributions~\citep{abu2019mixhop}. We set $n$ to 500, $c$ to 10, and choose $d_{avg}$ between $1$ and $100$, $p_{in}$ from $\{ 0.1\delta, 0.2\delta, \dots, 0.9\delta \}$. We use 20 samples per class for training, 500 for validation and 1000 for test. \subsection{Experimental Set-up} We follow the experimental set-up of GAT with minor adjustments. All parameters are initialized by Glorot initialization~\citep{glorot2010understanding} and optimized by Adam~\citep{kingma2014adam}. We apply L2 regularization, dropout~\citep{srivastava2014dropout} to features and attention coefficients, and early stopping on validation loss and accuracy. We use ELU~\citep{clevert2016fast} as a non-linear activation $\rho$. Unless specified, we employ a two-layer SuperGAT with $F = 8$ features and $K = 8$ attention heads (total 64 features). All models are implemented in PyTorch~\citep{paszke2019pytorch} and PyTorch Geometric~\citep{Fey2019Fast}. See appendix \ref{sec:apdx_model} for detailed model and hyperparameter configurations. \paragraph{Baselines} For all datasets, we compare our model against representative graph neural models: graph convolutional network (GCN)~\citep{kipf2017semi}, GraphSAGE~\citep{hamilton2017inductive}, and graph attention network (GAT)~\citep{velickovic2018graph}. Furthermore, for Cora, CiteSeer, and PubMed, we choose recent graph neural architectures that learn aggregation coefficients (or discrete structures) over edges: constrained graph attention network (CGAT\footnote{Since CGAT uses node labels in the loss function, it is difficult to use it in semi-supervised learning. So, we modify its auxiliary loss for SSL. See appendix~\ref{sec:apdx_cgat} for details.})~\citep{wang2019improving}, graph learning-convolutional network (GLCN)~\citep{jiang2019semi}, learning discrete structure (LDS)~\citep{franceschi2019learning}, graph agreement model (GAM)~\citep{stretcu2019graph}, and NeuralSparse (NS in short)~\citep{zheng2020robust}. For the PPI, we use CGAT as an additional baseline. \subsubsection{Citation Network} We use a total of 7 citation network datasets. Nodes are documents, and edges are citations. The task for all citation network datasets is to classify each paper's topic. \paragraph{Cora, CiteSeer, PubMed} We use three benchmark datasets for semi-supervised node classification tasks in the transductive setting~\citep{sen2008collective, yang2016revisiting}. The features of the nodes are bag-of-words representations of documents. We follow the train/validation/test split of previous work~\citep{kipf2017semi}. We use 20 samples per class for training, 500 samples for the validation, and 1000 samples for the test. \paragraph{Cora-ML, Cora-Full, DBLP} These are other citation network datasets from \citet{bojchevski2018deep}. Node features are bag-of-words representations of documents. For CoraFull with features more than 5000, we reduce the dimension to 500 by performing PCA. We use the split setting in \citet{shchur2018pitfalls}: 20 samples per class for training, 30 samples per class for validation, the rest for the test. \paragraph{ogbn-arxiv} The ogbn-arxiv is a recently proposed large-scale dataset of citation networks~\citep{hu2020open, wang2020microsoft}. Nodes represent arXiv papers, and edges indicate citations between papers, and node features are mean vectors of skip-gram word embeddings of their titles and abstracts. We use the public split by publication dates provided by the original paper. \subsubsection{Co-author Network} \paragraph{CS, Physics} The CS and Physics are co-author networks in each domain~\citep{shchur2018pitfalls}. Nodes are authors, and edges mean whether two authors co-authored a paper. Node features are paper keywords from the author's papers, and we reduce the original dimension (6805 and 8415) to 500 using PCA. The split is the 20-per-class/30-per-class/rest from \citet{shchur2018pitfalls}. The goal of this task is to classify each author's respective field of study. \subsubsection{Amazon Co-purchase} \paragraph{Photo, Computers} The Photo and Computers are parts of the Amazon co-purchase graph~\citep{mcauley2015image, shchur2018pitfalls}. Nodes are goods, and edges indicate whether two goods are frequently purchased together, and node features are a bag-of-words representation of product reviews. The split is the 20-per-class/30-per-class/rest from \citet{shchur2018pitfalls}. The task is to classify the categories of goods. \subsubsection{Web Page Network} \paragraph{Wiki-CS} The Wiki-CS dataset is computer science related page networks in Wikipedia~\citep{mernyei2020wiki}. Nodes represent articles about computer science, and edges represent hyperlinks between articles. The features of nodes are mean vectors of GloVe word embeddings of articles. There are 20 standard splits, and we experiment with five random seeds for each split (total 100 runs). The task is to classify the main category of articles. \paragraph{Chameleon, Crocodile} These datasets are Wikipedia page networks about specific topics, Chameleon and Crocodile~\citep{rozemberczki2019multi}. Nodes are articles, and edges are mutual links between them. Node features are a bag-of-words representation with informative nouns in the article. The number of features is 13183, but we use a reduced dimension of 500 by PCA. The split is 20-per-class/30-per-class/rest from \citet{shchur2018pitfalls}. The original dataset is for the regression task to predict monthly traffic, but we group values into six bins and make it a classification problem. \paragraph{Four-Univ} The Four-Univ dataset is a web page networks from computer science departments of diverse universities~\citep{craven1998learning}. Nodes are web pages, edges are hyperlinks between them, and node features are TF-IDF vectors of web page's contents. There are five graphs consists of four universities (Cornell, Texas, Washington, and Wisconsin) and a miscellaneous graph from other universities. As the original authors suggested\footnote{\url{http://www.cs.cmu.edu/afs/cs.cmu.edu/project/theo-20/www/data/}}, we use three graphs of universities and a miscellaneous graph for training, another one graph for validation (Cornell), and the other one graph for the test (Texas). Classification labels are types of web pages (student, faculty, staff, department, course, and project). \subsubsection{Flickr} The Flickr dataset is a graph of images from Flickr~\citep{mcauley2012image, Zeng2020GraphSAINT}. Nodes are images, and edges indicate whether two images share common properties such as geographic location, gallery, and users commented. Node features are a bag-of-words representation of images. We use labels and split in in \citet{Zeng2020GraphSAINT}. For labels, they construct seven classes by manually merging 81 image tags. \subsubsection{Protein-Protein Interaction} The protein-protein interaction (PPI) dataset~\citep{zitnik2017predicting, hamilton2017inductive, subramanian2005gene} is a well-known benchmark in the inductive setting. A graph is given for human tissue, the nodes are proteins, the node's features are biological signatures like genes, and the edges illustrate proteins' interactions. The dataset consists of 20 training graphs, two validation graphs, and two test graphs. This dataset has multi-labels of gene ontology sets. \begin{table}[t] \centering \caption{Average degree and homophily of real-world graphs.} \label{tab:degree_homophily} \begin{tabular}{lll} \hline Dataset & Degree & Homophily \\ \hline Four-Univ & 1.83 $\pm$ 1.71 & 0.16 \\ PPI & 28.0 $\pm$ 39.26 & 0.17 \\ Chameleon & 15.85 $\pm$ 18.20 & 0.21 \\ Crocodile & 15.48 $\pm$ 15.97 & 0.26 \\ Flickr & 10.08 $\pm$ 31.75 & 0.32 \\ Cora-Full & 6.41 $\pm$ 8.79 & 0.59 \\ ogbn-arxiv & 7.68 $\pm$ 9.05 & 0.63 \\ Wiki-CS & 26.40 $\pm$ 36.04 & 0.68 \\ CiteSeer & 2.78 $\pm$ 3.39 & 0.72 \\ PubMed & 4.50 $\pm$ 7.43 & 0.79 \\ Cora-ML & 5.45 $\pm$ 8.24 & 0.81 \\ DBLP & 5.97 $\pm$ 9.35 & 0.81 \\ Computers & 35.76 $\pm$ 70.31 & 0.81 \\ Cora & 3.90 $\pm$ 5.23 & 0.83 \\ CS & 8.93 $\pm$ 9.11 & 0.83 \\ Photo & 31.13 $\pm$ 47.27 & 0.85 \\ Physics & 14.38 $\pm$ 15.57 & 0.91 \\ \hline \end{tabular} \end{table} \begin{table}[t] \centering \caption{Statistics of the real-world datasets.} \label{tab:real-world-stats} \resizebox{\textwidth}{!}{% \begin{tabular}{lllllllll} \hline Dataset & \# Nodes & \# Edges & \# Features & \# Classes & Split & \# Training Nodes & \# Val. Nodes & \# Test Nodes \\ \hline Four-Univ & 4518 & 3426 & 2000 & 6 & fixed & 4014 (3 Gs) & 248 (1 G) & 256 (1 G) \\ PPI & 56944 & 818716 & 50 & 121 & fixed & 44906 (20 Gs) & 6514 (2 Gs) & 5524 (2 Gs) \\ Chameleon & 2277 & 36101 & 500 & 6 & random & 120 & 180 & 1977 \\ Crocodile & 11631 & 180020 & 500 & 6 & random & 120 & 180 & 11331 \\ Flickr & 89250 & 449878 & 500 & 7 & fixed & 44625 & 22312 & 22313 \\ Cora-Full & 19793 & 63421 & 500 & 70 & random & 1395 & 2049 & 16349 \\ ogbn-arxiv & 169343 & 1166243 & 128 & 40 & fixed & 90941 & 29799 & 48603 \\ Wiki-CS & 11701 & 297110 & 300 & 10 & fixed & 580 & 1769 & 5847 \\ CiteSeer & 3327 & 4732 & 3703 & 6 & fixed & 120 & 500 & 1000 \\ PubMed & 19717 & 44338 & 500 & 3 & fixed & 60 & 500 & 1000 \\ Cora-ML & 2995 & 8158 & 2879 & 7 & random & 140 & 210 & 2645 \\ DBLP & 17716 & 52867 & 1639 & 4 & random & 80 & 120 & 17516 \\ Computers & 13752 & 245861 & 767 & 10 & random & 200 & 300 & 13252 \\ Cora & 2708 & 5429 & 1433 & 7 & fixed & 140 & 500 & 1000 \\ CS & 18333 & 81894 & 500 & 15 & random & 300 & 450 & 17583 \\ Photo & 7650 & 119081 & 745 & 8 & random & 160 & 240 & 7250 \\ Physics & 34493 & 247962 & 500 & 5 & random & 100 & 150 & 34243 \\ \hline \end{tabular}% } \end{table} \section{Introduction} \input{files/introduction} \section{Related Work} \input{files/related_work} \section{Model} \input{files/model} \section{Experiments}\label{sec:experiments} \input{files/experiments} \section{Results}\label{sec:results} \input{files/results} \section{Conclusion} \input{files/conclusion} \subsubsection*{Acknowledgments} This research was supported by the Engineering Research Center Program through the National Research Foundation of Korea (NRF) funded by the Korean Government MSIT (NRF-2018R1A5A1059921) \clearpage \subsubsection{Citation Network} We use a total of 7 citation network datasets. Nodes are documents, and edges are citations. The task for all citation network datasets is to classify each paper's topic. \paragraph{Cora, CiteSeer, PubMed} We use three benchmark datasets for semi-supervised node classification tasks in the transductive setting~\citep{sen2008collective, yang2016revisiting}. The features of the nodes are bag-of-words representations of documents. We follow the train/validation/test split of previous work~\citep{kipf2017semi}. We use 20 samples per class for training, 500 samples for the validation, and 1000 samples for the test. \paragraph{Cora-ML, Cora-Full, DBLP} These are other citation network datasets from \citet{bojchevski2018deep}. Node features are bag-of-words representations of documents. For CoraFull with features more than 5000, we reduce the dimension to 500 by performing PCA. We use the split setting in \citet{shchur2018pitfalls}: 20 samples per class for training, 30 samples per class for validation, the rest for the test. \paragraph{ogbn-arxiv} The ogbn-arxiv is a recently proposed large-scale dataset of citation networks~\citep{hu2020open, wang2020microsoft}. Nodes represent arXiv papers, and edges indicate citations between papers, and node features are mean vectors of skip-gram word embeddings of their titles and abstracts. We use the public split by publication dates provided by the original paper. \subsubsection{Co-author Network} \paragraph{CS, Physics} The CS and Physics are co-author networks in each domain~\citep{shchur2018pitfalls}. Nodes are authors, and edges mean whether two authors co-authored a paper. Node features are paper keywords from the author's papers, and we reduce the original dimension (6805 and 8415) to 500 using PCA. The split is the 20-per-class/30-per-class/rest from \citet{shchur2018pitfalls}. The goal of this task is to classify each author's respective field of study. \subsubsection{Amazon Co-purchase} \paragraph{Photo, Computers} The Photo and Computers are parts of the Amazon co-purchase graph~\citep{mcauley2015image, shchur2018pitfalls}. Nodes are goods, and edges indicate whether two goods are frequently purchased together, and node features are a bag-of-words representation of product reviews. The split is the 20-per-class/30-per-class/rest from \citet{shchur2018pitfalls}. The task is to classify the categories of goods. \subsubsection{Web Page Network} \paragraph{Wiki-CS} The Wiki-CS dataset is computer science related page networks in Wikipedia~\citep{mernyei2020wiki}. Nodes represent articles about computer science, and edges represent hyperlinks between articles. The features of nodes are mean vectors of GloVe word embeddings of articles. There are 20 standard splits, and we experiment with five random seeds for each split (total 100 runs). The task is to classify the main category of articles. \paragraph{Chameleon, Crocodile} These datasets are Wikipedia page networks about specific topics, Chameleon and Crocodile~\citep{rozemberczki2019multi}. Nodes are articles, and edges are mutual links between them. Node features are a bag-of-words representation with informative nouns in the article. The number of features is 13183, but we use a reduced dimension of 500 by PCA. The split is 20-per-class/30-per-class/rest from \citet{shchur2018pitfalls}. The original dataset is for the regression task to predict monthly traffic, but we group values into six bins and make it a classification problem. \paragraph{Four-Univ} The Four-Univ dataset is a web page networks from computer science departments of diverse universities~\citep{craven1998learning}. Nodes are web pages, edges are hyperlinks between them, and node features are TF-IDF vectors of web page's contents. There are five graphs consists of four universities (Cornell, Texas, Washington, and Wisconsin) and a miscellaneous graph from other universities. As the original authors suggested\footnote{\url{http://www.cs.cmu.edu/afs/cs.cmu.edu/project/theo-20/www/data/}}, we use three graphs of universities and a miscellaneous graph for training, another one graph for validation (Cornell), and the other one graph for the test (Texas). Classification labels are types of web pages (student, faculty, staff, department, course, and project). \subsubsection{Flickr} The Flickr dataset is a graph of images from Flickr~\citep{mcauley2012image, Zeng2020GraphSAINT}. Nodes are images, and edges indicate whether two images share common properties such as geographic location, gallery, and users commented. Node features are a bag-of-words representation of images. We use labels and split in in \citet{Zeng2020GraphSAINT}. For labels, they construct seven classes by manually merging 81 image tags. \subsubsection{Protein-Protein Interaction} The protein-protein interaction (PPI) dataset~\citep{zitnik2017predicting, hamilton2017inductive, subramanian2005gene} is a well-known benchmark in the inductive setting. A graph is given for human tissue, the nodes are proteins, the node's features are biological signatures like genes, and the edges illustrate proteins' interactions. The dataset consists of 20 training graphs, two validation graphs, and two test graphs. This dataset has multi-labels of gene ontology sets. \begin{table}[t] \centering \caption{Average degree and homophily of real-world graphs.} \label{tab:degree_homophily} \begin{tabular}{lll} \hline Dataset & Degree & Homophily \\ \hline Four-Univ & 1.83 $\pm$ 1.71 & 0.16 \\ PPI & 28.0 $\pm$ 39.26 & 0.17 \\ Chameleon & 15.85 $\pm$ 18.20 & 0.21 \\ Crocodile & 15.48 $\pm$ 15.97 & 0.26 \\ Flickr & 10.08 $\pm$ 31.75 & 0.32 \\ Cora-Full & 6.41 $\pm$ 8.79 & 0.59 \\ ogbn-arxiv & 7.68 $\pm$ 9.05 & 0.63 \\ Wiki-CS & 26.40 $\pm$ 36.04 & 0.68 \\ CiteSeer & 2.78 $\pm$ 3.39 & 0.72 \\ PubMed & 4.50 $\pm$ 7.43 & 0.79 \\ Cora-ML & 5.45 $\pm$ 8.24 & 0.81 \\ DBLP & 5.97 $\pm$ 9.35 & 0.81 \\ Computers & 35.76 $\pm$ 70.31 & 0.81 \\ Cora & 3.90 $\pm$ 5.23 & 0.83 \\ CS & 8.93 $\pm$ 9.11 & 0.83 \\ Photo & 31.13 $\pm$ 47.27 & 0.85 \\ Physics & 14.38 $\pm$ 15.57 & 0.91 \\ \hline \end{tabular} \end{table} \begin{table}[t] \centering \caption{Statistics of the real-world datasets.} \label{tab:real-world-stats} \resizebox{\textwidth}{!}{% \begin{tabular}{lllllllll} \hline Dataset & \# Nodes & \# Edges & \# Features & \# Classes & Split & \# Training Nodes & \# Val. Nodes & \# Test Nodes \\ \hline Four-Univ & 4518 & 3426 & 2000 & 6 & fixed & 4014 (3 Gs) & 248 (1 G) & 256 (1 G) \\ PPI & 56944 & 818716 & 50 & 121 & fixed & 44906 (20 Gs) & 6514 (2 Gs) & 5524 (2 Gs) \\ Chameleon & 2277 & 36101 & 500 & 6 & random & 120 & 180 & 1977 \\ Crocodile & 11631 & 180020 & 500 & 6 & random & 120 & 180 & 11331 \\ Flickr & 89250 & 449878 & 500 & 7 & fixed & 44625 & 22312 & 22313 \\ Cora-Full & 19793 & 63421 & 500 & 70 & random & 1395 & 2049 & 16349 \\ ogbn-arxiv & 169343 & 1166243 & 128 & 40 & fixed & 90941 & 29799 & 48603 \\ Wiki-CS & 11701 & 297110 & 300 & 10 & fixed & 580 & 1769 & 5847 \\ CiteSeer & 3327 & 4732 & 3703 & 6 & fixed & 120 & 500 & 1000 \\ PubMed & 19717 & 44338 & 500 & 3 & fixed & 60 & 500 & 1000 \\ Cora-ML & 2995 & 8158 & 2879 & 7 & random & 140 & 210 & 2645 \\ DBLP & 17716 & 52867 & 1639 & 4 & random & 80 & 120 & 17516 \\ Computers & 13752 & 245861 & 767 & 10 & random & 200 & 300 & 13252 \\ Cora & 2708 & 5429 & 1433 & 7 & fixed & 140 & 500 & 1000 \\ CS & 18333 & 81894 & 500 & 15 & random & 300 & 450 & 17583 \\ Photo & 7650 & 119081 & 745 & 8 & random & 160 & 240 & 7250 \\ Physics & 34493 & 247962 & 500 & 5 & random & 100 & 150 & 34243 \\ \hline \end{tabular}% } \end{table} \subsection{Datasets} \paragraph{Real-world datasets} We use a total of 17 real-world datasets (Cora, CiteSeer, PubMed, Cora-ML, Cora-Full, DBLP, ogbn-arxiv, CS, Physics, Photo, Computers, Wiki-CS, Four-Univ, Chameleon, Crocodile, Flickr, and PPI) in diverse domains (citation, co-authorship, co-purchase, web page, and biology) and scales (2k - 169k nodes). We try to use their original settings as much as possible. To verify research questions 1 and 2, we choose four classic benchmarks: Cora, CiteSeer, PubMed in the transductive setting, and PPI in the inductive setting. See appendix~\ref{sec:apdx_dataset} for detailed description, splits, statistics (including degree and homophily), and references. \paragraph{Synthetic datasets}\label{sec:synthetic-data} We generate random partition graphs of $n$ nodes per class and $c$ classes~\citep{fortunato2010community}, using \texttt{NetworkX} library~\citep{hagberg2008exploring}. A random partition graph is a graph of communities controlled by two probabilities $p_{in}$ and $p_{out}$. If the nodes have the same class labels, they are connected with $p_{in}$, and otherwise, they are connected with $p_{out}$. To generate a graph with an average degree of $d_{avg} = n \cdot \delta$, we choose $p_{in}$ and $p_{out}$ by $p_{in} + (c - 1) \cdot p_{out} = \delta$. The input features of nodes are sampled from overlapping multi-Gaussian distributions~\citep{abu2019mixhop}. We set $n$ to 500, $c$ to 10, and choose $d_{avg}$ between $1$ and $100$, $p_{in}$ from $\{ 0.1\delta, 0.2\delta, \dots, 0.9\delta \}$. We use 20 samples per class for training, 500 for validation and 1000 for test. \subsection{Experimental Set-up} We follow the experimental set-up of GAT with minor adjustments. All parameters are initialized by Glorot initialization~\citep{glorot2010understanding} and optimized by Adam~\citep{kingma2014adam}. We apply L2 regularization, dropout~\citep{srivastava2014dropout} to features and attention coefficients, and early stopping on validation loss and accuracy. We use ELU~\citep{clevert2016fast} as a non-linear activation $\rho$. Unless specified, we employ a two-layer SuperGAT with $F = 8$ features and $K = 8$ attention heads (total 64 features). All models are implemented in PyTorch~\citep{paszke2019pytorch} and PyTorch Geometric~\citep{Fey2019Fast}. See appendix \ref{sec:apdx_model} for detailed model and hyperparameter configurations. \paragraph{Baselines} For all datasets, we compare our model against representative graph neural models: graph convolutional network (GCN)~\citep{kipf2017semi}, GraphSAGE~\citep{hamilton2017inductive}, and graph attention network (GAT)~\citep{velickovic2018graph}. Furthermore, for Cora, CiteSeer, and PubMed, we choose recent graph neural architectures that learn aggregation coefficients (or discrete structures) over edges: constrained graph attention network (CGAT\footnote{Since CGAT uses node labels in the loss function, it is difficult to use it in semi-supervised learning. So, we modify its auxiliary loss for SSL. See appendix~\ref{sec:apdx_cgat} for details.})~\citep{wang2019improving}, graph learning-convolutional network (GLCN)~\citep{jiang2019semi}, learning discrete structure (LDS)~\citep{franceschi2019learning}, graph agreement model (GAM)~\citep{stretcu2019graph}, and NeuralSparse (NS in short)~\citep{zheng2020robust}. For the PPI, we use CGAT as an additional baseline. \section{Experimental Set-up} \subsection{Real-world Dataset}\label{sec:apdx_dataset} \input{appendix_files/dataset} \subsection{Link Prediction} For link prediction, we split 5\% and 10\% of edges for validation and test set, respectively. We fix the negative edges for the test set and sample negative edges for the training set at each iteration. \subsection{Synthetic Dataset}\label{sec:apdx_dataset_syn} \input{appendix_files/dataset_syn} \subsection{Distribution of Degree and Homophily of Datasets}\label{sec:apdx_dist_degree_and_homophily} \input{appendix_files/dist_degree_and_homophily} \subsection{Model \& Hyperparameter Configurations}\label{sec:apdx_model} \input{appendix_files/model_details} \subsection{CGAT Implementation}\label{sec:apdx_cgat} \input{appendix_files/cgat} \subsection{Wall-clock Time Experimental Set-up}\label{sec:apdx_wall_clock_time} \input{appendix_files/wall_clock_time} \clearpage \section{Results} \subsection{Proof of Proposition}\label{sec:apdx_proof} \input{appendix_files/proof} \subsection{Full Result of Synthetic Graph Experiments}\label{sec:apdx_synthetic} \input{appendix_files/synthetic} \subsection{Label-agreement Study for Other Datasets and Deeper Models}\label{sec:apdx_label_agreement} \input{appendix_files/label_agreement} \subsection{Wall-clock Time Result}\label{sec:apdx_wall_clock_time_result} \input{appendix_files/wall_clock_time_result} \subsection{Sensitivity Analysis of Hyper-parameters}\label{sec:apdx_sensitivity} \input{appendix_files/sensitivity} \section{Introduction} \input{files/introduction} \section{Related Work} \input{files/related_work} \section{Model} \input{files/model} \section{Experiments}\label{sec:experiments} \input{files/experiments} \section{Results}\label{sec:results} \input{files/results} \section{Conclusion} \input{files/conclusion} \subsubsection*{Acknowledgments} This research was supported by the Engineering Research Center Program through the National Research Foundation of Korea (NRF) funded by the Korean Government MSIT (NRF-2018R1A5A1059921) \clearpage
{'timestamp': '2022-04-12T02:32:53', 'yymm': '2204', 'arxiv_id': '2204.04879', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04879'}
arxiv
\section{Introduction} A great variety of modern, as well as of traditional networks, are dynamic in nature as their link availability changes over time. Information and communication networks, social networks, transportation networks, and various physical systems are only a few indicative examples of such inherently dynamic networks~\cite{Holme-Saramaki-book-13,michailCACM}. All these application areas share the common characteristic that the network structure, i.e.~the underlying graph topology, is subject to \emph{discrete changes over time}. In this paper, embarking from the foundational work of Kempe et al.~\cite{kempe}, we adopt the following simple and natural model for time-varying networks, which is given by a graph with sets of time-labels associated with its edges, while the vertex set is fixed. \begin{definition}[Temporal Graph] \label{def:temporal-graph} A \emph{temporal graph} is a pair $(G,\lambda)$, where $G=(V,E)$ is an underlying (static) graph and $\lambda :E\rightarrow 2^{\mathbb{N}}$ is a \emph{time-labeling} function which assigns to every edge of $G$ a set of discrete-time labels. \end{definition} For an edge~$e \in E$ in the underlying graph~$G$ of a temporal graph~$(G,\lambda)$, if $t \in \lambda(e)$ then we say that $e$ is \emph{active} at time~$t$ in $(G,\lambda)$. That is, for every edge $e\in E$, $\lambda (e)$ denotes the set of time slots at which $e$ is \emph{active}. Due to their relevance and applicability in many areas, temporal graphs have been studied from various perspectives and under different names such as \emph{dynamic}~\cite{GiakkoupisSS14,CasteigtsFloccini12}, \emph{evolving}~\cite{xuan,Ferreira-MANETS-04,clementi10}, \emph{time-varying}~\cite{FlocchiniMS09,TangMML10-ACM,krizanc1}, and \emph{graphs over time} \cite{Leskovec-Kleinberg-Faloutsos07}. For a comprehensive overview on the existing models and results on temporal graphs from a distributed computing perspective see the surveys~\cite{CasteigtsFloccini12,flocchini1,flocchini2}. Mainly motivated by the fact that, due to causality, information can be transfered in a temporal graph along sequences of edges whose time-labels are increasing, the most traditional research on temporal graphs has focused on temporal paths and other ``path-related'' notions, such as e.g.~temporal analogues of distance, reachability, exploration and centrality~\cite{KlobasMMNZ21,HeegerHMMNS21,akrida16,Erlebach0K21,MertziosMS19,michailTSP16,akridaTOCS17,EnrightMMZ21,ZschocheFMN20,CasteigtsHMZ21}. To complement this direction, several attempts have been recently made to define meaningful ``non-path'' temporal graph problems which appropriately model specific applications. Motivated by the contact patterns among high-school students, Viard et al.~\cite{viardCliqueTCS16}, introduced $\Delta$-cliques, an extension of the concept of cliques to temporal graphs (see also~\cite{himmel17,BHMMNS18}). Chen et al.~\cite{ChenMSS18} presented an extension of the cluster editing problem to temporal graphs, in which all vertices interact with each other at least once every $\Delta$ consecutive time steps within a given time interval. Furthermore, Akrida et al.~\cite{AkridaMSZ20} introduced the notion of temporal vertex cover (also with a sliding time window), motivated by applications of covering problems in sensor networks. Further examples of meaningful ``non-path'' temporal graph problems include variations of temporal graph coloring~\cite{MertziosMZ21,yu2013algorithms,ghosal2015channel} in the context of planning and channel assignment in mobile sensor networks, and the temporally transitive orientations of temporal graphs~\cite{MertziosMRSZ21}. The problems \textsc{Temporal Vertex Cover} (or \textsc{TVC}) and \textsc{Sliding-Window Temporal Vertex Cover} (or \textsc{$\Delta$-TVC} for time-windows of a fixed-length $\Delta$) have been established as natural extensions of the well-known \textsc{Vertex Cover} problem on static graphs~\cite{AkridaMSZ20}. Given a temporal graph $\mathcal{G}$, the aim of \textsc{TVC} is to cover every edge at least once during the lifetime $T$ of $\mathcal{G}$, where an edge can be covered by one of its endpoints, and only at a time step when it is active. For any $\Delta\in \mathbb{N}$, the aim of the more ``pragmatic'' problem \textsc{$\Delta$-TVC} is to cover every edge at least once at every $\Delta$ consecutive time steps. In both problems, we try to minimize the number of ``vertex appearances'' in the resulting cover, where a vertex appearance is a pair $(v,t)$ for some vertex $v$ and $t\in \{1,2,\ldots,T\}$. \textsc{TVC} and \textsc{$\Delta$-TVC} naturally generalize the applications of the static problem \textsc{Vertex Cover} to more dynamic inputs, especially in the areas of wireless ad hoc networks, as well as network security and scheduling. In the case of a static graph, the vertex cover can contain trusted vertices which have the ability to monitor/surveil all transmissions~\cite{ileri2016vertex,RichterHG07} or all link failures~\cite{KavalciUD14} between any pair of vertices through the edges of the graph. In the temporal setting, it makes sense to monitor the transmissions and to check for link failures within every sliding time window of an appropriate length $\Delta$ (which is exactly modeled by $\Delta$-TVC). It is already known that both \textsc{TVC} and \textsc{$\Delta$-TVC} are NP-hard; for \textsc{$\Delta$-TVC} this is even the case when $\Delta=2$ and the minimum degree of the underlying graph $G$ is just 3~\cite{AkridaMSZ20}. One of the most intriguing questions left open (see Problem 1 in~\cite{AkridaMSZ20}) is whether \textsc{$\Delta$-TVC} (or, more generally, \textsc{Sliding-Window Temporal Vertex Cover}) can be solved in polynomial time \begin{changes} on always degree at most $2$ temporal graphs, that is, on temporal graphs where the maximum degree of the graph at each time step is at most 2. \end{changes} \medskip \noindent\textbf{Our Contribution.} In this paper we initiate the study of the complexity of \textsc{TVC} and \textsc{$\Delta$-TVC} on sparse graphs. Our main result (see~\cref{subsec:2tvc-paths-NP}) is that, for every $\Delta\geq 2$, \textsc{$\Delta$-TVC} is NP-hard even when $G$ is a path or a cycle, while \textsc{TVC} can be solved in polynomial time on paths and cycles. This resolves the first open question (Problem 1) of~\cite{AkridaMSZ20}. In contrast, we show that \textsc{TVC} (see~\cref{subsec:algres}) can be solved in polynomial time on temporal paths and cycles. Moreover, for any $\Delta\geq 2$, we provide a \emph{Polynomial-Time Approximation Scheme (PTAS)} for $\Delta$-TVC on temporal paths and cycles (see~\cref{subsec:algres}), which also complements our hardness result for paths. The \NP-hardness of \Cref{subsec:2tvc-paths-NP} signifies that an optimum solution for \(\Delta\)-TVC is hard to compute, even for $\Delta=2$ and under severe degree restrictions of the input instance. To counter this hardness for more general temporal graphs than those with underlying paths and cycles as in \Cref{paths-cycles-sec}, in \Cref{bounded-degree-sec} we give three algorithms for every $\Delta\geq 2$: First we present an exact algorithm for \(\Delta\)-TVC with \begin{changes} exponential running time dependency on the number of edges in the underlying graph \end{changes} (see \Cref{subsec:exact}). Using this algorithm we are able to devise, for any $d \geq 3$, a polynomial-time \((d-1)\)-approximation (see \Cref{better-d-approx-subsec}), where \(d\) is the maximum vertex degree in any time step, \ie in any part of the temporal graph that is active at the same time. This improves the currently best known \(d\)-approximation algorithm for \textsc{\(\Delta\)-TVC}~\cite{AkridaMSZ20} and thus also answers another open question (Problem 2 in~\cite{AkridaMSZ20}). Finally, we present a simple fixed-parameter tractable algorithm with respect to the size of an optimum solution (see \Cref{cp-alg-subsec}). \section{Preliminaries}\label{prelim-sec} Given a (static) graph $G=(V,E)$ with vertices in $V$ and edges in $E$, an edge between two vertices~$u$ and~$v$ is denoted by $uv$, and in this case~$u$ and~$v$ are said to be \emph{adjacent} in~$G$. For every $i,j\in \mathbb{N}$, where $i\leq j$, we let $[i,j]=\{i,i+1,\ldots ,j\}$ and $[j]=[1,j]$. Throughout the paper we consider temporal graphs whose underlying graphs are finite and whose time-labeling functions only map to finite sets. This implies that there is some \(t \in \mathbb{N}\) such that, for every \(t' > t\), no edge of \(G\) is active at \(t'\) in \((G, \lambda)\). We denote the smallest such \(t\) by $T$, \ie $T = \max\{t \in \lambda(e) \mid e \in E\}$, and call $T$ the \emph{lifetime} of \((G, \lambda)\). Unless otherwise specified, $n$ denotes the number of vertices in the underlying graph $G$, and $T$ denotes the lifetime of the temporal graph $\mathcal{G}$. We refer to each integer $t\in [T]$ as a \emph{time slot} of $(G,\lambda )$. The \emph{instance} (or \emph{snapshot}) of $(G,\lambda )$ \emph{at time}~$t$ is the static graph $G_{t}=(V,E_{t})$, where E_{t}=\{e\in E:t\in \lambda (e)\}$. A \emph{temporal path} of length $k$ is a temporal graph $\mathcal{P}=(P, \lambda)$, where the underlying graph $P$ is the path $(v_0, v_1, v_2, \dots, v_k)$ on $k+1$ vertices, with edges $e_i = v_{i-1}v_i$ for $i = 1, 2, \dots, k$. In many places throughout the paper, we visualize a temporal path as a 2-dimensional array $V(P) \times [T]$, where two vertices $(x,t), (y,t') \in V(P) \times [T]$ are connected in this array if and only if $t = t'\in \lambda(xy)$ and $xy \in E(P)$. For example see \cref{fig:ExampleTemporalPath}. \begin{figure}[h] \centering \includegraphics[width=0.75\linewidth]{PathExample} \caption{An example of visualizing a temporal path graph $\mathcal{G}$ as a $2$-dimensional array, in which every edge corresponds to a time-edge of $\mathcal{G}$.} \label{fig:ExampleTemporalPath} \end{figure} For every $t=1,\ldots,T-\Delta+1$, let $W_t = [t, t+ \Delta -1]$ be the $\Delta$-time window that starts at time $t$. For every $v\in V$ and every time slot $t$, we denote the \emph{appearance of vertex} $v$ \emph{at time} $t$ by the pair $(v,t)$ and the \emph{edge appearance} (or \emph{time-edge}) of $e$ at time $t$ by $(e,t)$. A \emph{temporal vertex subset} of \((G, \lambda)\) is a set of vertex appearances in $(G, \lambda)$, i.e.\ a set of the form \(S \subseteq \{(v, t) \mid v \in V, t \in [T]\}\). For a temporal vertex subset~\(S\) and some \(\Delta\)-time window~\(W_i\) within the lifetime of \((G, \lambda)\), we denote by \(S[W_i] = \{(v, t) \in S \mid t \in W_i\}\) the subset of all vertex appearances in \(S\) in the \(\Delta\)-time window~\(W_i\). For a \(\Delta\)-time window~\(W_i\) within the lifetime of a temporal graph~\((G, \lambda)\), we denote by \(E[W_i] = \{e \in E \mid \lambda(e) \cap W_i \neq \emptyset\}\) the set of all edges which appear at some time slot within \(W_i\). A temporal vertex subset~$\mathcal{C}$ is a \emph{sliding \(\Delta\)-time window temporal vertex cover}, or \(\Delta\)-TVC for short, of a temporal graph \((G, \lambda)\) if, for every \(\Delta\)-time window~\(W_i\) within the lifetime of \((G, \lambda)\) and for every edge in \(E[W_i]\), there is some \((v,t) \in \mathcal{C}[W_i]\) such that \(v \in e\), i.e.\ \(v\) is an endpoint of \(e\), and \(t \in \lambda(e)\). Here we also say \((v,t)\) \emph{covers} \((e,t)\) in time window \(W_i\). \section{Paths and Cycles}\label{paths-cycles-sec} In Section~\ref{subsec:2tvc-paths-NP} we provide our main NP-hardness result for $\Delta$-TVC, for any $\Delta\geq 2$, on instances whose underlying graph is a path or a cycle (see Theorem~\ref{thm:2tvc-paths-NP} and Corollary~\ref{cor:2tvc-cycles-NP}). In Section~\ref{subsec:algres} we prove that TVC on underlying paths and cycles is polynomially solvable, and we also provide our PTAS for $\Delta$-TVC on underlying paths and cycles, for every $\Delta\geq 2$. \subsection{Hardness on Temporal Paths and Cycles}\label{subsec:2tvc-paths-NP} Our NP-hardness reduction of \cref{thm:2tvc-paths-NP} is done from the NP-hard problem \emph{planar monotone rectilinear $3$ satisfiability} (or \emph{planar monotone rectilinear 3SAT}), see \cite{Berg2010Optimal}. This is a specialization of the classical Boolean $3$-satisfiability problem to a planar incidence graph. A Boolean satisfiability formula $\phi$ in conjunctive normal form (CNF) is called \emph{monotone}, if each clause of $\phi$ consists of only positive or only negative literals. We refer to these clauses as \emph{positive} and \emph{negative} clauses, respectively. By possibly repeating literals, we may assume without loss of generality that every clause contains exactly three (not necessarily different) literals. In an instance of planar monotone rectilinear $3$SAT, each variable and each clause is represented with a horizontal line segment, as follows. The line segments of all variables lie on the same horizontal line on the plane, which we call the \emph{variable-axis}. For every clause $C = (x_i \lor x_j \lor x_k)$ (or $C = (\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})$), the line segment of $C$ is connected via straight vertical line segments to the line segments of $x_i, x_j$ and of $x_k$, such that every two (horizontal or vertical) line segments are pairwise non-intersecting. Furthermore, every line segment of a positive (resp.~negative) clause lies above (resp.~below) the variable-axis. Finally, by possibly slightly moving the clause line segments higher or lower, we can assume without loss of generality that every clause line segment lies on a different horizontal line on the plane. \iflong For an example see \cref{fig:rectilinearMax2SAT}. \begin{figure}[h] \centering \includegraphics[width=0.6\linewidth]{rectilinear3SAT} \caption{An example of an instance of a planar monotone rectilinear 3SAT $\phi = (x_2 \lor x_3 \lor x_4) \land (x_1 \lor x_2 \lor x_4) \land (x_1 \lor x_4 \lor x_5) \land (\overline{x_2} \lor \overline{x_3} \lor \overline{x_5}) \land (\overline{x_1} \lor \overline{x_2} \lor \overline{x_5})$. For visual purposes, the line segments for variables and for clauses are illustrated here with boxes.} \label{fig:rectilinearMax2SAT} \end{figure} \fi Let $\phi$ be an arbitrary instance of planar monotone rectilinear $3$SAT, where $X = \{x_1, \dotsc, x_{n}\}$ is its set of Boolean variables and $\phi(X) = \{C_1, \dotsc, C_{m}\}$ is its set of clauses. We construct from $\phi$ a temporal path $\mathcal{G_\phi}$ and prove \iflong (see~\cref{lem:two-directions}) \fi that there exists a truth assignment of $X$ which satisfies $\phi(X)$ if and only if the optimum value of $2$-TVC on $\mathcal{G_\phi}$ is at most $f(\mathcal{G_\phi})$. The exact value of $f(\mathcal{G_\phi})$ will be defined later. \subsubsection{High-Level Description} Given a representation (i.e.~embedding) $R_{\phi}$ of an instance $\phi$ of planar monotone rectilinear $3$SAT, we construct a $2$-dimensional array of the temporal path $\mathcal{G}_{\phi}$, where: \begin{itemize} \item every variable (horizontal) line segment in $R_{\phi}$ is associated with one or more \emph{segment blocks} (to be formally defined below) in $\mathcal{G}_{\phi}$, and \item every clause (horizontal) line segment in $R_{\phi}$, corresponding to the clause $C=(x_i \lor x_j \lor x_k)$ (resp.~$C=(\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})$), is associated with a clause gadget in $\mathcal{G}_{\phi}$, which consists of three edges (one for each of $x_i, x_j, x_k$), each appearing in $4$ consecutive time steps, together with two paths connecting them in the 2-dimensional array for $\mathcal{G}$ (we call these paths the \emph{clause gadget connectors}, for an illustration see~\cref{fig:NP-rectilinearConstruction}), \item every vertical line segment in $R_{\phi}$, connecting variable line segments to clause line segments, is associated with an edge of $\mathcal{G}_{\phi}$ that appears in consecutive time steps. \end{itemize} The exact description of the variables' and clauses' gadgets is given below; first we need to precisely define the segment blocks. \paragraph*{Segment blocks} are used to represent variables. Every segment block consists of a path of length $7$ on vertices $(u_0, u_1, \dots , u_7)$, where the first and last edges (\ie $u_0u_1$ and $u_6 u_7$) appear at $9$ consecutive time steps starting at time $t$ and ending at time $t+8$, with all other edges appearing only two times, \ie at times $t+1$ and $t + 7$. \iflong For an example see \cref{fig:NP-varibleGadgets}. \begin{figure}[h] \centering \includegraphics[width=0.3\linewidth]{NP-variableGadgets} \caption{Example of a segment block construction.} \label{fig:NP-varibleGadgets} \end{figure}\fi Time-edges which correspond to the first and last appearances of $u_0u_1$ and $u_6u_7$ in a segment block are called \emph{dummy time-edges}, all remaining time-edges form two (bottom and top) horizontal paths, and two (left and right) vertical sequences of time-edges (which we call here \emph{vertical paths}), \iflong see \cref{fig:NP-variableGadgets-names}\fi. \iflong \begin{figure}[h] \centering \includegraphics[width=0.3\linewidth]{NP-variableGadgets-names} \caption{An example where dummy time-edges, vertical and horizontal paths are depicted.} \label{fig:NP-variableGadgets-names} \end{figure}\fi Using the next technical lemma will allow us to model the two different truth values of each variable $x_i$ (True, resp.~False) via two different optimum solutions of 2-TVC on a segment block (namely the ``orange and green'', resp.~``orange and red'' temporal vertex covers of the segment block, see Figure~\ref{fig:NP-varibleGadgetsCover}). \begin{lemma}\label{lem:NP-CoverVariableGadgets} There are exactly two different optimum solutions for $2$-TVC of a segment block, both of size $15$. \end{lemma} \begin{proof} Let $\mathcal{C}$ be a $2$-TVC of a segment block on vertices $u_0, \dots, u_7$ that starts at time $t$ and finishes at time $t + 8$. In order to cover the dummy time-edges in time windows $W_{t-1}$ and $W_{t+8}$ one of their endpoints has to be in $\mathcal{C}$. Now let us start with the covering of the first edge ($u_0u_1$) at time $t+1$. Since the dummy time-edges are covered, the edge $u_0u_1$ is covered in the time window $W_t$ but it is not yet covered in the time window $W_{t+1}$. We have two options, either cover it at time $t+1$ or $t+2$. \begin{itemize} \item Suppose that we cover the edge $u_0u_1$ at $t+1$, then the next time step it has to be covered is $t+3$, the next one $t+5$ and the last one $t+7$. Now that the left vertical path is covered we proceed to cover the bottom and top horizontal paths. The middle $5$ edges, from $u_1$ to $u_6$, appear only at time steps $t+1$ and $t + 7$. Since we covered the edge $u_0u_1$ at time $t+1$, we can argue that the optimum solution includes the vertex appearance $(u_1, t+1)$ and therefore the edge $u_1u_2$ is also covered. Extending this covering optimally to the whole path we need to add every second vertex to $\mathcal{C}$, \ie vertex appearances $(u_3,t+1)$ and $(u_5, t+1)$. Similarly it holds for the vertex appearances of vertices $u_1, \dots , u_6$ at time $t + 7$. The last thing we need to cover is the right vertical path. Since the edge $u_6u_7$ is covered at time $t$, the next time step we have to cover it is $t+2$, which forces the next cover to be at $t+4$ and last one at $t+6$. In total $\mathcal{C}$ consists of $4$ endpoints of the dummy time-edges, $4$ vertices of the left and $3$ of the right vertical paths, $2$ vertices of the bottom and $2$ of the top horizontal paths. All together we used $11$ vertices to cover vertical and horizontal paths and $4$ for dummy time-edges. The above described $2$-TVC corresponds to the ``orange and red'' vertex appearances of the odd segment block depicted in the \cref{fig:NP-varibleGadgetsCover}. Let us also emphasize that, with the exception of times $t+1$ and $t + 7$, we do not distinguish between the solutions that uses a different endpoint to cover the first and last edge. For example if a solution covers the edge $u_0 u_1$ at time $t+2$ then we do not care which of $(u_0,t+2)$ or $(u_1,t+2)$ is in the TVC. \item Covering the edge $u_0u_1$ at time $t+2$ produces the $2$-TVC that is a mirror version of the previous one on the vertical and horizontal paths. More precisely, in this case the covering consists of $3$ vertices of the left and $4$ of the right vertical paths and again $2$ vertices of the bottom and $2$ of the top horizontal paths, together with $4$ vertices covering the dummy time-edges. This $2$-TVC corresponds to the ``orange and green'' vertex appearances of the segment block depicted in the \cref{fig:NP-varibleGadgetsCover}. \end{itemize} If we start with vertex appearances from one solution and add vertex appearances from the other solution then we either create a $2$-TVC of bigger size or leave some edges uncovered. Therefore, the optimum temporal vertex cover of any segment block consists of only ``orange and red'' or ``orange and green'' vertex appearances. \end{proof} \begin{figure}[h] \centering \includegraphics[width=0.3\linewidth]{NP-variableGadget2} \caption{An example of two optimum covers of a segment block: (i)~with the ``orange and green''-colored, or (ii)~with the ``orange and red''-colored vertex appearances.} \label{fig:NP-varibleGadgetsCover} \end{figure} For each variable $x_i$ we create multiple copies of segment blocks, and some specific pairs of these segment blocks are connected to each other via the so-called ``horizontal bridges''. Two segment blocks, which are connected via a horizontal bridge, start at the same time $t$ but are built on different sets of vertices (\ie one is to the left of the other in the 2-dimensional array). All the copies have to be created in such a way, that their optimum $2$-TVCs depend on each other. In the following we describe how to connect two different segment blocks (both for the same variable $x_i$). As we prove \iflong below (see~\cref{lem:SizeOfTVCinHorizontalDirection})\fi, there are two ways to optimally cover this construction: one using the ``orange and green'', and one using the ``orange and red'' vertex appearances (thus modeling the truth values True and False of variable $x_i$ in our reduction)\iflong, see~\cref{fig:NP-variableSegments}\fi. \iflong \paragraph{Consistency in the horizontal direction.} Let $\mathcal{H}$ be a temporal path on vertices $(u^1_0, u^1_1, \dots ,$ $u^1_7,w_1,w_2,w_3,w_4 , u^2_0, u^2_1, , \dots , u^2_7)$, with two segment blocks on vertices $(u^1_0, u^1_1, \dots , u^1_7)$ and $(u^2_0, u^2_1, \dots , u^2_7)$, respectively, starting at time $t$ and finishing at time $t+8$, and let $P = (u^1_6, u^1_7, w_1,w_2,w_3,w_4 , u^2_0, u^2_1)$ be a path of length $7$, that appears exactly at times $t + 2$ and $t + 5$. For an example see \cref{fig:NP-variableSegments}. We refer to this temporal path $P$ as a \emph{horizontal bridge} between the two segment blocks. \begin{figure}[h] \centering \includegraphics[width=0.6\linewidth]{NP-variableGadgetHorizontal1} \caption{An example of connecting two segment blocks in horizontal direction. The two different ways to optimally cover this construction is (i)~with the green-colored and the orange-colored, or (ii)~with the red-colored and the orange-colored vertex appearances.} \label{fig:NP-variableSegments} \end{figure} \begin{lemma}\label{lem:SizeOfTVCinHorizontalDirection} The temporal graph $\mathcal{H}$ has exactly two optimum $2$-TVCs, both of size $34$. \end{lemma} \begin{proof} Let $\mathcal{H}$ consist of two segment blocks. Suppose that the first segment block, \ie left one, is covered with the ``orange and green'' $2$-TVC. Then the first edge $u^1_6 u^1_7$ of the path $P$ does not have to be covered at time $t+2$ as it is covered at times $t+1$ and $t+3$. For the other $6$ edges of $P$ there exists a unique optimum $2$-TVC, that uses every second vertex at time $t+2$ and is of size $3$. Therefore we cover the edge $u^2_0u^2_1$ at time $t+2$ which enforces the ``orange and green'' $2$-TVC also on the right segment block. Now, the only remaining uncovered edges are four consecutive edges of $P$, from $w_1$ to $u_0^2$ at time $t+5$, which are optimally covered with two vertex appearances. All together we used $15 + 15$ vertex appearances, to cover both segment blocks and $2 + 2$ to cover $P$ at $t+2, t+5$. \end{proof} \cref{lem:SizeOfTVCinHorizontalDirection} ensures that, in an optimum $2$-TVC of the construction of~\cref{fig:NP-variableSegments}, either both the left and the right segment blocks contain the ``orange and green'' vertex appearances, or they both contain the ``orange and red'' vertex appearances. We can extend the above result to $d$ consecutive copies of the same segment block and get the following result. \begin{corollary}\label{cor:NP-SizeOfTVCinHorizontalDirection} The temporal graph corresponding to $d$ copies of a segment block, where two consecutive are connected via horizontal bridges, has exactly two optimum $2$-TVCs of size $19d -4$. \end{corollary} \begin{proof} The optimum $2$-TVC of each segment block consists of $15$ vertex appearances. A horizontal bridge is optimally covered using $4$ extra vertex appearances. Therefore all together we have $15 d + 4 (d-1) = 19d -4$ vertex appearances in the optimum $2$-TVC. \end{proof} \begin{comment} \paragraph{Consistency in the vertical direction.} Let $\mathcal{H'}$ be a temporal path on vertices $(u_0, u_1, \dots , u_7)$ with two segment blocks. The first (bottom) one starts at time $t$ and finishes at time $t'=t+8$. The second (top) one starts at time $t' + h$ (and finishes at time $t' + h + 8$), where $h \geq 1$ is an \emph{odd} integer. Let the first and the last edge in the segment block (\ie $u_0u_1$ and $u_6u_7$) appear also at $h$ consecutive time steps, from $t'+1$ to $t' + h$. Intuitively, between the end of the bottom segment block and the start of the top one, there are $h$ time steps in which the first and last edges appear. For an example see \cref{fig:NP-variableVertical}. We refer to this sequence of the $h$ time-edges of $u_0u_1$ and the $h$ time-edges of $u_6u_7$ as a \emph{vertical bridge} between the two segment blocks. \begin{figure}[h] \centering \includegraphics[width=0.25\linewidth]{NP-variableGadgetVertical1} \caption{An example of moving a segment block in a vertical direction. The two different ways to optimally cover this construction is (i)~with the green-colored and the orange-colored, or (ii)~with the red-colored and the orange-colored vertex appearances.} \label{fig:NP-variableVertical} \end{figure} \begin{lemma}\label{lem:NP-SizeOfTVCinVerticalDirection} The temporal graph $\mathcal{H'}$ has exactly two optimum $2$-TVCs, both of size $28 + h $, where $h$ is the number of time steps between the end of the bottom segment block and the start of the top one. \end{lemma} \begin{proof} Let the bottom segment block finish at time $t'$. Suppose that this segment block is optimally covered with the green $2$-TVC. Then, the first edge \ie $u_0u_1$ is not covered at time $t'-1$, therefore we have to cover it at time $t'$ and then at $t'+2, t' + 4, \dots$. On the other hand, the last edge \ie $u_6u_7$ is covered at time $t'-1$, therefore the next time step it has to be covered is $t' + 1$ and then $t'+3, t'+5, \dots$. At the time step $t'+h + 2$ the whole path on vertices $(u_0, u_1, \dots , u_7)$ appears. Using the arguing from above, one of the first or last edges is already covered at this time step, therefore there is a unique solution to cover the remaining $6$ edges of the path. This solution now uniquely extends to the whole upper segment block. Similarly it holds if the bottom segment block is covered with the red $2$-TVC. The bottom segment block is covered using $15 -1$ vertex appearances, where $15$ is the size of the optimum $2$-TVC of the bottom segment block and $-1$ comes from the fact that only one of the dummy edges at time $t'$ is covered. Similarly it holds for the upper segment block. We can see that in every time step of the $h$ consecutive appearances of the first and last edges, we always cover exactly one of them. Therefore, this part adds $h$ vertex appearances to each of the two optimum $2$-TVCs. \end{proof} \end{comment} \subsubsection*{Variable Gadget \label{sec:NP-paths-VariableSegments}} From the planar, rectilinear embedding $R_\phi$ of $\phi$ we can easily fix the order of variables. We fix the variables in the order they appear in the variable-axis, starting from the left to the right. Let $d_i$ be the number of appearances of variable $x_i$ as a literal (\ie as $x_i$ and $\overline{x_i}$) in $\phi$. For every variable $x_i$ we create $d_i$ copies of the segment block, which follow each other on a horizontal line and are connected via \emph{horizontal bridges}. Between variable gadgets of two consecutive variables $x_i$ and $x_{i+1}$ we add $4$ vertices (without any additional time-edges). All variable gadgets in $\mathcal{G_\phi}$ start and finish at the same time \ie they lie on the same vertical line. \begin{lemma}\label{lem:NPoddDistance-RightmostEdges} The distance between two rightmost (or two leftmost) edges of any pair of segment blocks in $\mathcal{G_\phi}$ is odd. \end{lemma} \begin{proof} Let $(u_6 u_7, t)$ and $(v_6 v_7,t)$ be the rightmost time-edges of two segment blocks $\mathcal{X}$ and $\mathcal{Y}$ in $\mathcal{G_\phi}$. Without loss of generality we may assume that $\mathcal{X}$ appears before/left of the $\mathcal{Y}$ in $\mathcal{G_\phi}$. If $\mathcal{X}$ and $\mathcal{Y}$ are consecutive (\ie right next to each other) then there are $4$ vertices between them and two blocks are on the distance $5$. Since $(v_6 v_7,t)$ is the last (rightmost) time-edge in $\mathcal{Y}$ it is on the distance $6$ from the beginning of the block and therefore on the distance $11$ from $(u_6 u_7, t)$ . If there are $k$ segment blocks between $\mathcal{X}$ and $\mathcal{Y}$, there are $8 k + 4 (k+1)$ vertices between the end of $\mathcal{X}$ and the beginning of the $\mathcal{Y}$. Since $(v_6 v_7,t)$ is the last (rightmost) time-edge in $\mathcal{Y}$ there are $6$ other vertices before it in the block. Therefore, there are $12k + 10$ vertices between the two edges $(u_6 u_7, t)$ and $(v_6 v_7,t)$, so they are on the distance $2(6k +5) +1$. Similarly holds for the leftmost time-edges $(u_0 u_1, t)$ and $(v_0 v_1,t)$ of two segment blocks $\mathcal{X}$ and $\mathcal{Y}$ in $\mathcal{G_\phi}$. \end{proof} \subsubsection*{Vertical Line Gadget} A vertical line gadget is used to connect a variable gadget to the appropriate clause gadget. It consists of one edge appearing in $2k$ consecutive time steps, where $k$ is a positive integer. The value of $k$ for each clause gadget will be specified later; it depends on the embedding $R_{\phi}$ of the input formula $\phi$. More precisely, let $\mathcal{X}$ be a segment block for the literal $x_i$ (resp.~$\overline{x_i}$) on vertices $(u_0, u_1, \dots , u_7)$, which starts at time $t$ and finishes at time $t' = t+8$. Then the \emph{vertical line gadget} $\mathcal{V}$ of this segment block consists of just the $2k$ appearances of the edge $u_6u_7$ from time $t'$ to time $t' + 2k -1$ (resp.~of the edge $u_0u_1$ from time $t-2k +1$ to time $t$). \begin{lemma}\label{lem:NP-verticalLineGadet} Let $\mathcal{V}$ be any vertical line gadget, whose edge appearances are between time $t_0$ and time $t_0 + 2k -1$. Then a minimum $2$-TVC of $\mathcal{V}$ in the time windows from $W_{t_0}$ to $W_{t_0 + 2k - 2}$ is of size $k$. \end{lemma} \begin{proof} To cover an edge in a specific time step we use just one vertex appearance. Since $\mathcal{V}$ consists of $2k$ consecutive appearances of the same edge $u_xu_{x+1}$, containing in the 2-TVC an appearance of $u_x$ or $u_{x+1}$ at a time $t$ (where $t_0+1 \leq t\leq t_0+2k-2$) temporally covers the edge $u_xu_{x+1}$ in two time windows, namely $W_{t-1}$ and $W_{t}$. Note that there are $2k -1$ time windows between $W_{t_0}$ to $W_{t_{0} + 2k - 2}$. Suppose that there is an optimum $2$-TVC of $\mathcal{V}$ of size at most $k-1$. This $2$-TVC then can cover the edge $u_xu_{x+1}$ in at most $2(k-1)$ time windows, which leaves at least one time window uncovered. Therefore the size of an optimum $2$-TVC is at least $k$. Let us now build two minimum $2$-TVCs of $\mathcal{V}$, both of size $k$. We observe the following two options. \begin{itemize} \item Suppose we cover $u_xu_{x+1}$ at time $t_0$. Then we can cover it also at times $t_0+2, t_0+4, \dots, t_0+2k-2$, and thus $u_xu_{x+1}$ is covered in all time windows between $W_{t_0}$ to $W_{t_{0} + 2k - 2}$ by using exactly $k$ vertex appearances. This $2$-TVC corresponds to the red-colored vertex appearances of the vertical line gadget depicted in the \cref{fig:NP-verticalLineGadgetsCover}. \item Suppose we cover $u_xu_{x+1}$ at time $t_0+1$ (instead of time $t_0$). Then we can cover it also at times $t_0+3, t_0+5, \dots, t_0+2k-1$, and thus $u_xu_{x+1}$ is covered again in all time windows between $W_{t_0}$ to $W_{t_{0} + 2k - 2}$ by using exactly $k$ vertex appearances. This $2$-TVC corresponds to the green-colored vertex appearances of the vertical line gadget depicted in the \cref{fig:NP-verticalLineGadgetsCover}. \end{itemize} \end{proof} \begin{figure}[h] \centering \includegraphics[width=0.22\linewidth]{NP-verticalLineGadget} \caption{An example of two optimum covers of a vertical line gadget: (i)~with the green-colored, or (ii)~with the red-colored vertex appearances.} \label{fig:NP-verticalLineGadgetsCover} \end{figure} \begin{comment} \begin{lemma} Let $\mathcal{X}$ be a segment block and $\mathcal{V}$ be its vertical line gadget. In any minimum 2-TVC of $\mathcal{X} \cup \mathcal{V}$, if $\mathcal{X}$ is covered with the ``orange and green'' (resp.~``orange and red'') vertex appearances, then $\mathcal{V}$ is also covered using the green (resp.~red) vertex appearances. \end{lemma} \begin{proof} Let $\mathcal{X}$ be a segment block on vertices $(u_0, u_1, \dots , u_7)$, starting at time $t$ and finishing at $t' = t+8$. Suppose that $\mathcal{X}$ corresponds to a positive appearance of variable $x_i$. Then the vertical line gadget $\mathcal{V}$ consists of the $2k$ appearances of the edge $(u_6u_7)$ from $t'$ to $t' + 2k -1$. If $\mathcal{X}$ is covered with the ``orange and green'' vertex appearances, then the edge $(u_6u_7)$ is covered at time $t'$, so the next time it has to be covered is at times $t' + 2, t'+4, \dots, t+2k-2$, which corresponds to the $2$-TVC of $\mathcal{V}$ using green vertex appearances. Similarly, if $\mathcal{X}$ is covered with the ``orange and red'' vertex appearances, or if $\mathcal{X}$ is a segment block corresponding to the negative appearance of $x_i$ and $\mathcal{V}$ consists of $2k$ appearances of edge $u_0u_1$ from $t$ to $t - 2k + 1$. \end{proof} \end{comment} \subsubsection*{Clause Gadget} Without loss of the generality we can assume that in every positive clause $(x_i \lor x_j \lor x_k)$ (resp.~negative clause $(\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})$) the literals are ordered such that $i \leq j \leq k$. Every clause gadget corresponding to a positive (resp.~negative) clause consists of: \begin{itemize} \item three edges appearing in $4$ consecutive time steps, these edges correspond to the rightmost (leftmost, in the case of negative clause) edge of a segment block of each variable, \item two paths $P_1$ and $P_2$, each of odd length, such that $P_1$ (resp.~$P_2$) connects the second-to-top (or~second-to-bottom, in the case of a negative clause) newly added edges above (below, in the case of negative clause) the segment blocks of $x_i$ and $x_j$ (resp.~of $x_j$ and $x_k$). We call paths $P_1$ and $P_2$ \emph{clause gadget connectors}. \end{itemize} For an example see \cref{fig:NP-clauseCovering}. \begin{figure}[h] \centering \includegraphics[width=0.5\linewidth]{NP-clauseGadget-vertical} \caption{An example of a positive clause gadget, depicted with vertical line gadgets $\mathcal{X, Y, Z}$ connected to it.} \label{fig:NP-clauseCovering} \end{figure} \begin{lemma}\label{lem:NP-reductionTVCclauseEdge} Let $C$ be a positive clause $(x_i \lor x_j \lor x_k)$ (resp.~negative clause $(\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})$) and let $\mathcal{C}$ be its corresponding clause gadget in $\mathcal{G_\phi}$. Let the clause gadget connectors $P_1$ and $P_2$ have length $p_1$ and $p_2$, respectively. If we temporally cover at least one of the three vertical line gadgets connecting to $\mathcal{C}$ with the green (resp.~red) vertex appearances, then $\mathcal{C}$ can be covered with exactly $7+\frac{p_1+p_2}{2}$ vertex appearances; otherwise we need at least $8+\frac{p_1+p_2}{2}$ vertex appearances to temporally cover $\mathcal{C}$. \end{lemma} \begin{proof} Let $\mathcal{X, Y, Z}$ be the vertical line gadgets connecting the segment blocks of variables $x_i, x_j, x_k$ to the clause gadget, respectively and let $C$ be a positive clause. Suppose that $\mathcal{C}$ starts at time $t$. We denote with $v_x u_x, v_y u_y, v_z u_z$ the underlying edges of $\mathcal{X},\mathcal{Y} ,\mathcal{Z}$ respectively. The clause gadget consists of edges $v_x u_x, v_y u_y, v_z u_z$ appearing in consecutive time steps from $t$ to $t+3$, together with the clause gadget connectors, \ie a path $P_1$ of length $p_1$ from $u_x$ to $v_y$ at time $t+2$ and a path $P_2$ of length $p_2$ from $u_y$ to $v_z$ at time $t+2$. Note $p_1$ and $p_2$ are odd (see \cref{lem:NPoddDistance-RightmostEdges}). A $2$-TVC of $\mathcal{C}$ always covers all three temporal edges at time $t+3$, as the time window $W_{t+3}$ needs to be satisfied. If $\mathcal{X}$ is covered with the red vertex appearances, then we need to cover its underlying edge at time $t$, to satisfy the time window $W_{t-1}$. Besides that we also need one extra vertex appearance for the time window $W_{t+1}$. Without loss of generality we can cover the edge at time $t+2$. If $\mathcal{X}$ is covered with the green vertex appearances, then the edge $v_xu_x$ is already covered in the time window $W_{t-1}$, so we cover it at time $t+1$, which satisfies the remaining time windows $W_t$ and $W_{t+1}$. Similarly it holds for $\mathcal{Y} ,\mathcal{Z}$. We still need to cover the clause gadget connectors $P_1$ and $P_2$. Since $P_1$ and $P_2$ are paths of odd length appearing at only one time step, their optimum $2$-TVC is of size $(p_1 + 1) /2$ and $(p_2 + 1) /2$, respectively. Therefore, if one endpoint of $P_1$ or $P_2$ is in the $2$-TVC, then to cover them optimally the other endpoint cannot be in the cover. If $\mathcal{Y}$ is covered with the red $2$-TVC, then one of the endpoints of the time-edge $(v_y u_y, t + 2)$ has to be in the $2$-TVC, in the other case the time-edge is already covered by a vertex appearance in the previous time step. If $\mathcal{X}$ (resp.~ $\mathcal{Z}$) is covered with the red $2$-TVC, the first (resp.~ last) time-edge of $P_1$ (resp.~$P_2$) has to be covered, thus vertex appearance $(u_x, t + 2)$ (resp.~$(v_z,t+2)$) is in the $2$-TVC. Therefore if all $\mathcal{X,Y,Z}$ are covered with the red $2$-TVC we use $(p_1 + p_2) /2 +2$ vertex appearances to cover $P_1$ and $P_2$. All together we need \begin{itemize} \item one vertex appearance for each edge at time $t+3$, \item one vertex appearance for each edge at time steps $t$ and $t+1$ and \item either $(p_1 + p_2) /2 +1$ or $(p_1 + p_2) /2 +2$ vertex appearances to cover the clause gadget connectors. \end{itemize} We have $8 + \frac{p_1 + p_2}{2}$ vertex appearances to cover $\mathcal{C}$ if all three $\mathcal{X,Y,Z}$ are covered with the ``orange and red'' $2$-TVC and $7 + \frac{p_1 + p_2}{2}$ in any other case. Similarly it holds when $C$ is a negative clause. \end{proof} \fi \begin{figure}[h!] \centering \includegraphics[width=0.8\linewidth]{NP-rectilinearConstruction3SAT} \caption{An example of the construction of temporal graph from a planar rectilinear embedding of monotone 3SAT.} \label{fig:NP-rectilinearConstruction} \end{figure} \iflong \subsubsection*{Creating a Temporal Path $\mathcal{G_\phi}$} Before we start with the detailed construction we need to fix the following notation. \paragraph{Notation.} From the planar, rectilinear embedding $R_\phi$ of $\phi$ we can easily fix the order of clauses. We fix the clauses by first fixing all the positive clauses and then all negative ones using the order they appear in the $R_\phi$. If $C_i, C_j$ are two positive (resp.~negative) clauses and $i < j$, then the clause $C_i$ is above (resp.~below) the clause $C_j$ in the $R_\phi$. For example in \cref{fig:rectilinearMax2SAT} we have $C_1 = (x_1 \lor x_4 \lor x_5), C_2 = (x_1 \lor x_2 \lor x_4), C_3 = (x_2 \lor x_3 \lor x_4), C_4 = (\overline{x_1} \lor \overline{x_2} \lor \overline{x_5}), C_5 = (\overline{x_2} \lor \overline{x_3} \lor \overline{x_5})$. Recall that $d_i$ denotes the number of appearances of the variable $x_i$ as a literal (\ie either $x_i$ or $\overline{x_i}$) in $\phi$. For a clause $C_a=(x_i \lor x_j \lor x_k)$ or $C_a = (\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})$ we denote with $g^a_i, g^a_j$ and $g^a_k$ the appearances of the literals $x_i,x_j$ and $x_k$ (resp.~$\overline{x_i},\overline{x_j}$ and $\overline{x_k}$) in $C_a$, \ie $x_i$ (resp.~$\overline{x_i}$) appears in $C_a$ for the $g^a_j$-th time, $x_j$ (resp.~$\overline{x_j}$) appears $g^a_j$-th time and $x_k$ (resp.~$\overline{x_k}$) appears $g^a_k$-th time. With $m_1$ we denote the number of positive and with $m_2$ the number of negative clauses in $\phi$. For every clause $C_a$ we define also the level $\ell_a$ in the following way. If $C_a$ is a positive clause then $\ell_a$ equals the number of clauses between it and the variable-axis increased by $1$, \ie the positive clause $C_1$, which is furthest away from the variable-axis, is on the level $m_1$, the clause $C_{m_1}$, which is the closest to the variable axis, is on level $1$. Similarly it happens for the negative clauses, where the value of the level is negative, \ie the clause $C_{m_1 + 1}$ is on the level $- m_2$ and the clause $C_{m}$ is on the level $-1$. Now we are ready to combine all the above gadgets and constructions to describe the construction of the temporal path $\mathcal{G_\phi}$. \paragraph{Detailed construction.} For each variable $x_i$ in $\phi$ we construct its corresponding variable gadget in $\mathcal{G_\phi}$. All variable gadgets lie on the same horizontal line. We create the clause gadget of a positive $C_a=(x_i \lor x_j \lor x_k)$ or negative clause $C_a=(\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})$ such that we connect the $g^a_i$-th copy of the segment block of $x_i$ to it, together with the $g^a_j$-th copy of the segment block of $x_j$ and $g^a_k$-th copy of the segment block of $x_k$. We do this using vertical line gadgets, that connect the corresponding segment blocks to the level $\ell_a$ where the clause gadget is starting. Let us now define our temporal graph $\mathcal{G_\phi}=(G,\lambda)$. \begin{itemize} \item The underlying graph $G$ is a path on $12 \sum_{i=1}^{n}d_i - 4$ vertices. \begin{itemize} \item A variable gadget corresponding to the variable $x_i$ consists of $d_i$ copies of the segment block, together with $d_i -1$ horizontal bridges. We need $d_i 8 + (d_i-1) 4 = 12 d_i - 4$ vertices for one variable and $\sum_{i=1}^{n} (12d_i - 4)$ for all of them. \item Between variable gadgets of two consecutive variables $x_i, x_{i+1}$ there are $4$ vertices. Therefore we use extra $4(n-1)$ vertices, for this construction. \end{itemize} \item The lifetime $T$ of $\mathcal{G_\phi}$ is $4(m+4)$. \begin{itemize} \item There are $m$ clauses and each of them lies on its own level. Therefore we need $4m$ time steps for all clause gadgets. \item There is a level $0$ with all the variable gadgets, of height $9$. We add one extra time step before we define the start of levels $1$ and $-1$. This ensures that the vertical line gadget, connecting variable gadget to the corresponding clause gadget, is of even height. \item The first time-edge appears at time $5$ instead of $1$, which adds $4$ extra time steps to the lifetime of $\mathcal{G_\phi}$ and does not interfere with our construction. Similarly, after the appearance of the last time-edge there is one extra time step, where no edge appears. We add these time steps to assure that the dummy time-edges must be covered in the time step they appear and that the lifetime of the graph $\mathcal{G_\phi}$ is divisible by $4$. \item All together we have $4 m + 11 + 4 + 1 $ time steps. \end{itemize} \end{itemize} Therefore $\mathcal{G}_\Phi$ is a temporal graph of lifetime $T = 4(m+4)$ with the underlying path on $12 \sum_{i=1}^{n}d_i -4$ vertices. The appearances of each edge arise from the structure of the planar monotone rectilinear 3SAT. \subsubsection*{\boldmath Size of the Optimum $2$-TVC of $\mathcal{G_\phi}$} Using the notation introduced above we determine the size of the optimum $2$-TVC of $\mathcal{G_\phi}$. We do this in two steps, first determining the size of the optimum $2$-TVC for each variable gadget and then determining the optimum $2$-TVC of all vertical line gadgets together with the clause gadgets. \begin{enumerate} \item Optimum $2$-TVC covering all variable gadgets is of size $19 \sum _{i=1}^n d_i -4n$. \begin{itemize} \item Since a variable $x_i$ appears in $d_i$ clauses as a positive or negative literal, we construct $d_i$ connected copies of the segment block. By \cref{cor:NP-SizeOfTVCinHorizontalDirection} this construction has exactly two optimum $2$-TVCs, each of size $19 d_i - 4$. \item Using one of the four dummy temporal edges of a segment block, denote it $(e,t)$, we connect the corresponding variable gadget to the clause gadget. Therefore we need to cover just $3$ dummy temporal edges. Since there is one extra time step before the first clause gadget level, the edge $e$ appears also at time $t+1$ in the case of a positive clause and $t-1$ in the case of the negative one. To optimally cover it we then use one vertex appearance. \item There are $n$ variables, so all together we need $\sum _{i=1}^n (19d_i -4)$ vertex appearances in $2$-TVC to optimally cover all of them. \end{itemize} \item Optimum $2$-TVC covering all vertical line gadgets and clause gadgets is of size \begin{equation}\label{eq:NP-TVCsizeOfAllClauses} \begin{aligned} & \sum_{\substack{C_a = (x_i \lor x_j \lor x_k) \text{ or}\\ C_a=(\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})}} \Bigg( 6|\ell_a| + 6 \sum_{b=1}^{k-i-1} d_{i + b} + \\ & 6(d_i - g^a_i + g^a_k) + k - i \Bigg) - 2m. \end{aligned} \end{equation} Let $C_a = (x_i \lor x_j \lor x_k)$ (resp~$C_a = (\overline{x_i} \lor \overline{x_j}\lor \overline{x_k})$). \begin{itemize} \item Vertical line gadgets connect variable gadgets of $x_i, x_j$ and $x_k$ with the clause gadget of $C_a$. Since the clause gadget is on level $\ell_a$ the corresponding vertical line gadgets are of height $4(|\ell_a| -1)$. By \cref{lem:NP-verticalLineGadet} and the fact that each clause requires exactly three vertical line gadget, we need $6(|\ell_a| -1)$ vertex appearances to cover them optimally. \item Using \cref{lem:NP-reductionTVCclauseEdge} we know that an optimum $2$-TVC covering the clause gadget corresponding to $C_a$ requires $7 + \frac{p_1 + p_2}{2}$ vertex appearances where $p_1$ and $p_2$ are the lengths of the clause gadget connectors. Let us determine the exact value of $p_1 + p_2$. \begin{itemize} \item There are $k-i-1$ variable gadgets between $x_i$ and $x_k$, namely $x_{i+1}, x_{i+2}, \dots , x_{k-1}$. Variable gadget corresponding to any variable $x_b$ is of length $12 d_b -4$. There are $4$ vertices between two consecutive variable gadgets. Therefore there are $\sum_{d=1}^{k-i-1} (d_{i + d} 12 - 4) + (j-i)4 = 12 \sum_{d=1}^{k-i-1} d_{i + d} -4$ vertices between the last vertex of $x_i$ variable gadget and first vertex of $x_k$ variable gadget. \item From the end of $g^a_i$-th segment block of $x_i$ to the end of the variable gadget there are $d_i - g^a_i $ copies of the segment block together with the $d_i - g^a_i$ horizontal bridges connecting them. Similarly it holds for the case of $x_k$, there are $g^a_k - 1$ segment blocks and horizontal bridges. All together we have $(d_i - g^a_i + g^a_k - 1)8 + (d_i - g^a_i + g^a_k - 1)4 = 12 (d_i - g^a_i + g^a_k - 1)$ vertices. \item Between the end of $g^a_i$-th segment block of $x_i$ and the beginning of the $g^a_k$-th segment block of $x_k$ we have \begin{align*} p_1 + p_2 = & 12 \sum_{d=1}^{k-i-1} d_{i + d} +4(k-i+1)+ \\ & 12 (d_i - g^a_i + g^a_k - 1) \end{align*} vertices. \end{itemize} \end{itemize} All together the optimum $2$-TVC of the clause $C_a$ with the corresponding vertical line gadgets is of size \begin{equation*} 6|\ell_a| + 6 \sum_{b=1}^{k-i-1} d_{i + b} + 6(d_i - g^a_i + g^a_k) + k - i - 1. \end{equation*} Extending the above equation to all clauses and variables we get that the optimum $2$-TVC of $\mathcal{G_\phi}$ is of size \begin{equation} \label{eq:NP-TVCsizeSatisfiable} \begin{aligned} s = & 19 \sum _{i=1}^n d_i + \sum_{\substack{C_a = (x_i \lor x_j \lor x_k) \text{ or}\\ C_a=(\overline{x_i} \lor \overline{x_j} \lor \overline{x_k})}} \Bigg( 6|\ell_a| + 6 \sum_{b=1}^{k-i-1} d_{i + b} + \\ & 6(d_i - g^a_i + g^a_k) + k - i \Bigg) - m - 4n. \end{aligned} \end{equation} \end{enumerate} We are now ready to prove our main technical result of this section. \begin{lemma}\label{lem:two-directions} There exists a truth assignment $\tau$ of the variables in $X$ which satisfies $\phi(X)$ if and only if there exists a feasible solution to $2$-TVC on $\mathcal{G_\phi}$ which is of the size $s$ as in the \cref{eq:NP-TVCsizeSatisfiable}. \end{lemma} \begin{proof} Each segment block corresponding to a variable $x$ has exactly two optimum $2$-TVCs (the ``orange and green'' and ``orange and red'' one, depicted in \cref{fig:NP-varibleGadgetsCover}). We set the ``orange and green'' solution to the \textsc{True} value of $x$ and the ``orange and red'' one to \textsc{False}. ($\Rightarrow$): From $\tau$ we start building a $2$-TVC of $\mathcal{G_\phi}$ by first covering all variable gadgets with a $2$-TVC of ``orange and green'' (resp.~``orange and red'') vertex appearances if the corresponding variable is \textsc{True} (resp.~\textsc{False}). Using \cref{lem:SizeOfTVCinHorizontalDirection} we know that the optimum $2$-TVC of every variable gadget uses either all ``orange and green'' or all ``orange and red'' vertex appearances for every segment block and horizontal bridges connecting them. Next we extend the $2$-TVC from variable gadgets to vertical line gadgets, \ie if the variable gadget is covered with the ``orange and green'' (resp.~``orange and red'') vertex appearances then the vertical line gadget connecting it to the clause gadget uses the green (resp.~red) vertex appearances. At the end we have to cover also clause gadgets. Using \cref{lem:NP-reductionTVCclauseEdge} we know that we can cover each clause gadget optimally if and only if at least one vertical line gadget connecting to it is covered with the green vertex appearances, in the case of a positive clause and red vertex appearances in the case of the negative one. More precisely, a clause gadget $\mathcal{C}$ corresponding to the clause $C$ is covered with the minimum number of vertex appearances whenever $C$ is satisfied. Since $\tau$ is a truth assignment satisfying $\phi$, all clauses are satisfied and hence covered optimally. Therefore the size of the $2$-TVC of $\mathcal{G_\phi}$ is the same as in the \cref{eq:NP-TVCsizeSatisfiable}. ($\Leftarrow$): Suppose now that $\mathcal{C}$ is a minimum $2$-TVC of the temporal graph $\mathcal{G_\phi}$ of size $s$. Using \cref{lem:SizeOfTVCinHorizontalDirection,cor:NP-SizeOfTVCinHorizontalDirection} we know that the optimum $2$-TVC of each variable gadget consists of either all ``orange and green'' or all ``orange and red'' vertex appearances. If this does not hold then $\mathcal{C}$ is not of minimum size on variable gadgets. Similarly, the \cref{lem:NP-reductionTVCclauseEdge} assures that the number of vertex appearances used in the $2$-TVC of any clause gadget is minimum if and only if there is at least one vertical line gadget covered with green vertex appearances in the case of a positive clause and red vertex appearances in the case of a negative clause. If this does not hold then $\mathcal{C}$ is not of minimum size on clause gadgets. Lastly, if a vertical line gadget $\mathcal{V}$ connects a variable gadget covered with ``orange and green'' (resp.~``orange and red'') vertex appearances to a clause gadget using ``orange and red'' (resp.~``orange and green'') vertex appearances, then the $2$-TVC of $\mathcal{V}$ is not minimum (see \cref{lem:NP-verticalLineGadet}) and $\mathcal{C}$ cannot be of size $s$. To obtain a satisfying truth assignment $\tau$ of $\phi$ we check for each variable $x_i$ which vertex appearances are used in the $2$-TVC of its corresponding variable gadget. If $\mathcal{C}$ covers the variable gadget of $x_i$ with all ``orange and green'' vertex appearances we set $x_i$ to \textsc{True} else we set it to \textsc{False}. \end{proof} Our main result of this section follows now directly from Lemma~\ref{lem:two-directions} and the fact that the planar monotone rectilinear 3SAT is NP-hard \cite{Berg2010Optimal}. \fi As, for every $\Delta\geq 2$, there is a known polynomial-time reduction from $\Delta$-TVC to $(\Delta+1)$-TVC~\cite{AkridaMSZ20}, we obtain the following. \begin{theorem}\label{thm:2tvc-paths-NP} For every $\Delta\geq 2$, $\Delta$-TVC on instances on an underlying path is NP-hard. \end{theorem} With a slight modification to the $\mathcal{G_\phi}$ we can create the temporal cycle from $R_\phi$ and therefore the following holds. \begin{corollary}\label{cor:2tvc-cycles-NP} For every $\Delta\geq 2$, $\Delta$-TVC on instances on an underlying cycle is NP-hard. \end{corollary} \begin{proof} We follow the same procedure as above where we add one extra vertex $w$, to the underlying graph $P$ of $\mathcal{G_\phi}$. We add also two time-edges connecting the first and the last vertex of the temporal path graph $\mathcal{G_\phi}$ at time $1$. This increases the size of the $2$-TVC by $1$ (as we need to include the vertex appearance $(w,1)$) and it transforms the underlying path $P$ into a cycle. \end{proof} \subsection{Algorithmic Results} \label{subsec:algres} To complement the hardness presented in \Cref{subsec:2tvc-paths-NP}, we present two polynomial-time algorithms. Firstly, a dynamic program for solving \textsc{TVC} on instances with underlying paths and cycles, which shows that the hardness is inherently linked to the sliding time windows. Secondly, we give a PTAS for \dTVC\ on instances with underlying paths. This approximation scheme can be obtained using a powerful general purpose result commonly used for approximating geometric problems~\cite{mustafa2010hittingset}. \begin{theorem} TVC can be solved in polynomial time on instances with a path/cycle as their underlying graph. \end{theorem} \iflong \begin{proof} Let us start the proof with the case when the underlying graph $G = (v_0, v_1, v_2, \dots, v_n)$ is a path on $n+1$ vertices. Our algorithm mimics the greedy algorithm for computing a minimum vertex cover in a (static) path graph, which just sweeps the path from left to right and takes every second vertex. For every $i=1,2,\ldots, n$ we denote by $e_i$ the edge $v_{i-1}v_i$. To compute the optimum temporal vertex cover $\mathcal{C}$ of $\mathcal{G}$ we need to determine for each edge which vertex appearance covers it. We first consider the edge $v_0 v_1$. Without loss of generality we can cover this edge in $\mathcal{C}$ by a vertex appearance in the set $\{(v_1,t) : v_0 v_1 \in E_t\}$, as no appearance of vertex $v_0$ can cover any other edge apart from $v_0 v_1$. We check whether the set $\{t : v_0 v_1 \in E_t\} \cap \{t' : v_1 v_2 \in E_{t'}\}$ is empty or not; that is, we check whether $v_0 v_1$ appears together with $v_1 v_2$ in any time step. If this set is empty, then we add to $\mathcal{C}$ an arbitrary vertex appearance $(v_1,t)$, where $(e_1,t) \in E_t$. This choice is clearly optimum, as we need to cover $v_0 v_1$ with at least one vertex appearance of $v_1$, while any of the vertex appearances of $v_1$ can not cover any other edge of the graph. Otherwise, let $t\in \{t : v_0 v_1 \in E_t\} \cap \{t' : v_1 v_2 \in E_{t'}\}$ be an arbitrary time step in which both $v_0 v_1$ and $v_1 v_2$ appear. Then we add $(v_1,t)$ to $\mathcal{C}$. This choice is again optimum, as in this case the vertex appearance $(v_1,t)$ covers both edges $v_0 v_1$ and $v_1 v_2$. After adding one vertex appearance to $\mathcal{C}$, we ignore the edges that have been covered so far by $\mathcal{C}$, and we proceed recursively with the remaining part of $\mathcal{G}$, until all edges are covered. Each iteration of the above algorithm can be performed in $\mathcal{O}(T)$ time, and we have at most $\mathcal{O}(n)$ iterations. Therefore the running time of the whole algorithm is $\mathcal{O}(Tn)$. We can similarly deal with the case where the underlying graph $G$ is a cycle on the vertices $v_0, v_1, v_2, \dots, v_n$. Here we just need to observe that, without loss of generality, the optimum solution contains either a vertex appearance of $v_0$ or a vertex appearance of $v_1$ (but noth both). Therefore, to solve TVC on $\mathcal{G}$, we proceed as follows. First we create an auxiliary cycle $G'$ on the vertices $v_0', v_0, v_1, v_2, \ldots, v_n$ (in this order), where $v_0'$ is a new dummy vertex. Then we create the temporal graph $\mathcal{G}'=(G',\lambda')$, where $\lambda'(v_i v_{i+1}) = \lambda(v_i v_{i+1})$ for every $i=1,2,\ldots,n-1$, $\lambda'(v_n v_0') = \lambda(v_n v_0)$, and $\lambda'(v_0' v_0) = \lambda'(v_0 v_1) = \lambda(v_0 v_1)$. Next we compute the temporal subgraphs $\mathcal{G}_1'$ and $\mathcal{G}_2'$ of $\mathcal{G}'$, where the underlying graph of $\mathcal{G}_1'$ (resp.~of $\mathcal{G}_2'$) is the path $(v_0, v_1, \dots, v_n, v_0')$ (resp.~the path $(v_1, v_2, \dots, v_n, v_0', v_0)$). Every edge of $\mathcal{G}_1'$ and of $\mathcal{G}_2'$ has the same time labels as the corresponding edge in $\mathcal{G}$. Now we optimally solve TVC on $\mathcal{G}_1'$ and on $\mathcal{G}_2'$, and we return the smaller of the two solutions, as an optimum solution of TVC on $\mathcal{G}$ (by replacing any vertex appearance $(v_0',t)$ by $(v_0,t)$). The running time is again~$\mathcal{O}(Tn)$. \end{proof} \fi Next we turn to approximating \dTVC\ on underlying paths. The \textsc{Geometric Hitting Set} problem takes as instance a set of geometric objects, e.g.\ shapes in the plane, and a set of points. The task is to find the smallest set of points, that hit all of the objects. In the paper by Mustafa and Ray \cite{mustafa2010hittingset} the authors present a $\PTAS$ for the problem, when the geometrical objects are $r$-admissible set regions. We transform an arbitrary temporal path to the setting of the geometric hitting set. As a result, we obtain a $\PTAS$ for the \dTVC\ problem. \iflong \begin{definition} Let $R = (P,D)$ be a range space that consists of points $P$ in $\mathbb{R}^2$ and a set $D$ of regions containing points of $P$. The \emph{minimum geometric hitting set} problem asks for the smallest set $S \subseteq P$, such that each region in $D$ contains at least one point from $S$. \end{definition} \begin{definition} Let $D$ be the set of regions in the plane, where any region $s \in D$ is bounded by a closed Jordan curve \footnote{A Jordan curve is a non-self-intersecting continuous loop.}. We say, that $D$ is an \emph{$r$-admissible} set of regions, if Jordan curves bounding any two regions $s_1, s_2 \in D$ cross $l \leq r$ times and both $s_1 \setminus s_2$ and $s_2 \setminus s_1$ are connected regions\footnote{The space $X$ is said to be path-connected if there is a path joining any two points in $X$. Every path-connected space is also connected.}. \end{definition} \begin{theorem}[\cite{mustafa2010hittingset}] \label{thm:PTAS} Let $R = (P,D)$ be a range space consisting of a set $P$ of $n$ points in $\mathbb{R}^2$ and a set $D$ of $m$ $r$-admissible regions. There exists a $(1 + \varepsilon)$-approximation algorithm for the minimum geometric hitting set problem that is performed in $\mathcal{O}((mn^{\mathcal{O}(\varepsilon^{-2})})$ time. \end{theorem} \fi \begin{theorem} For every $\varepsilon>0$, there exists an $(1 + \varepsilon)$-approximation algorithm for \dTVC\ on instances with a path/cycle as their underlying graph, which runs in time \begin{align*} & O\left(n (T-\Delta + 1) \cdot (T(n+1))^{\mathcal{O}(\varepsilon^{-2})}\right) = \\ & O\left((T(n+1))^{\mathcal{O}(\varepsilon^{-2})}\right), \end{align*} \ie the problem admits a PTAS. \end{theorem} \begin{proof} Let $\mathcal{G}=(G,\lambda)$ be a temporal path, on vertices $\{v_1, v_2, \dotsc, v_n\}$, with lifetime $T$. We first have to create the range space $R = (P, D)$, where $P \subseteq V \times [T]$ is a set of vertex appearances and $D$ is a set of $2$-admissible regions. Set $P$ of time vertices consist of vertex appearances $(v_i, t)$ for which $t \in \lambda(e_i) \cup \lambda(e_{i+1})$. Intuitively, if edges incident to $v$ do not appear at time $t$, then $(v,t)$ is not in $P$. Set $D$ of $2$-admissible regions consists of rectangles of $2$ different sizes. For every edge $e_i$ that appears in the time window $W_t$ we create one rectangle $R_i^t$, that includes all vertex appearances incident to $e_i$ in $W_t$. For example, if edge $e_i$ appears in the time window $W_t$ at times $t_1$ and $t_2$, then the corresponding rectangle $R_i^t$ contains vertex appearances $(v_{i-1},t_1), (v_{i}, t_1), (v_{i-1},t_2)$ and $(v_{i}, t_2)$. It is not hard to see that $|P| \leq |V| \cdot T = (n+1)T$ and $|D| \leq |E| (T - \Delta + 1) = n (T-\Delta + 1)$. \subsubsection*{Formal Construction.} Since $D$ will be defined to be a set of $2$-admissible regions, the boundary of any two rectangles we construct should intersect at most $2$ times. For this purpose we use rectangles, of two different sizes. Let us denote with $A$ the rectangle of size $a_1 \times a_2$ and with $B$ be the rectangle of size $b_1 \times b_2$, where $a_1 > b_1 > b_2 > a_2$. As we said, for every edge $e_i$ that appears in the time window $W_t$ we construct exactly one rectangle. These are the rules we use to correctly construct them. \begin{enumerate} \item \label{regions:fixedWindow} For a fixed time window $W_t$ we construct the rectangles in such a way, that they intersect only in the case when their corresponding edges $e_i, e_j$ share the same endpoint in the underlying graph $G$. Since $G$ is a path, the intersection happens only in the case when $j = i+1$. We can observe also, that there are no three (or more) edges sharing the same endpoint and therefore no three rectangles intersect. We require also, that the rectangles corresponding to a pair of the adjacent edges are not the same, \ie they alternate between form $A$ and $B$. \iflong For an example see \cref{fig:RegionfixedWindow}. \begin{figure}[h] \includegraphics[width=\linewidth]{regions-fixedWindow} \caption{Regions in a fixed time window.} \label{fig:RegionfixedWindow} \end{figure} \fi \item \label{regions:fixedEdge} For any edge $e_i$, rectangles corresponding to two consecutive time windows $W_t, W_{t+1}$ are not the same, \ie they alternate between the form $A$ and $B$. For an example see \cref{fig:RegionfixedEdge}. \begin{figure}[h] \centering \begin{subfigure}[t]{0.4\textwidth} \centering \includegraphics[width=0.45\linewidth]{regions-fixedEdge2TVC} \caption{Alternating regions for an edge.} \label{fig:RegionfixedEdge} \end{subfigure} \quad \begin{subfigure}[t]{0.4\textwidth} \centering \includegraphics[width=0.7\linewidth]{regions-fixedEdgeDeltaTVC} \caption{Regions for an edge with shift, when $\Delta = 4$. Each region $W_i$ starts at same horizontal position as $W_{i - 4}$.} \label{fig:RegionfixedEdge-delta} \end{subfigure} \caption{Creating regions for one edge.} \end{figure} When the time windows are of size $\Delta$, there are at most $\Delta$ rectangles intersecting at every time step $t$. This holds, because if the edge $e_i$ appears at time $t$ it is a part of the time windows $W_{t_\Delta +1}, W_{t_\Delta +2}, \dots , W_{t}$. Since the constructed rectangles are of two sizes, if $\Delta \geq 3$ we create intersections with infinite number of points between the boundary of some rectangles, if we just ``stack'' the rectangles upon each other. Therefore, we need to shift (in the horizontal direction) rectangles of the same form in one $\Delta$ time window. Since the time window $W_t$ never intersects with $W_{t + \Delta}$, we can shift the time windows $W_{t+1}, \dots , W_{t+ \Delta - 1}$ and fix the $W_{t+ \Delta}$ at the same horizontal position as $W_t$ . For an example see \cref{fig:RegionfixedEdge-delta}. \end{enumerate} Combining both of the above rules we get a grid of rectangles. Moving along the $x$ axis corresponds to moving through the edges of the path and moving along the $y$ axis corresponds to moving through the time steps. \iflong \begin{figure}[h] \centering \includegraphics[width=0.8\textwidth]{regions-allDeltaTVC} \caption{Regions for edges $e_1, \dots, e_8$ in the time windows $W_1, \dots , W_8$, in the case of $4$-TVC.} \label{fig:RegionAll} \end{figure} \fi \iflong By \cref{fig:RegionfixedWindow} and \cref{regions:fixedEdge} of the construction above, rectangles alternate between the form $A$ and $B$ in both dimensions. See figure \cref{fig:RegionAll} for example. \fi \ifshort By construction, rectangles alternate between the form $A$ and $B$ in both dimensions. \fi If an edge $e_i$ does not appear in the time window $W_t$, then we do not construct the corresponding rectangle $R_i^t$. The absence of a rectangle from a grid does not change the pattern of others rectangles. To determine of what form a rectangle corresponding to edge $e_i$ at time-window $W_t$ is, we use the following condition: \begin{equation*} R_i^t = \begin{cases} A & \text{if $i +t \equiv 0 \pmod 2$,} \\ B & \text{else.} \end{cases} \end{equation*} Now we define where the points are placed. We use the following conditions. \begin{enumerate}[a.] \item If an edge $e_i = v_{i-1} v_i$ appears at time $t$ we add vertex appearances $(v_{i-1},t), (v_i, t)$ to all of the rectangles $R_i^{t'}$, where $t-\Delta +1 \leq t' \leq t$, if they exist. Equivalently, we add the vertex appearances $(v_{i-1},t), (v_i, t)$ in the intersection of the rectangles corresponding to the edge $e_i$ in the time windows $W_{t-\Delta +1}, \dots , W_{t}$. For an example see \cref{fig:Vertices-edge}. \item If an edge $e_i$ does not appear at time $t$, then the time vertices $(v_{i-1}, t),(v_i,t)$ are not included in the rectangles $R_i^{t'}$ ($t-\Delta +1 \leq t' \leq t$), if they exist. \item If two adjacent edges $e_i, e_{i+1}$ appear at the same time $t$, we add to the intersection of the rectangles $R_i^{t'}, R_{i+1}^{t'}$ the vertex $(v_i,t)$, where $t-\Delta +1 \leq t' \leq t$. For an example see \cref{fig:Vertices-twoedge}. \end{enumerate} \begin{figure}[htb] \centering \begin{subfigure}[t]{0.4\textwidth} \includegraphics[width=0.8\linewidth]{regionsAndVerticesOneEdge} \caption{Edge $e_i$ appearing at time $5$ and the corresponding placement of vertex appearances to the rectangles, when $\Delta = 4$.} \label{fig:Vertices-edge} \end{subfigure} \quad \begin{subfigure}[t]{0.4\textwidth} \includegraphics[width=\linewidth]{regionsAndVerticesIncidentEdges} \caption{Edges $e_i$ and $e_{i+1}$ appearing at time $5$ and the corresponding vertex appearances placement in the rectangles, when $\Delta= 4$.} \label{fig:Vertices-twoedge} \end{subfigure} \caption{Example of placement of the vertices into the rectangles when $\Delta = 4$.} \end{figure} It is straightforward to verify that finding the minimum hitting set of the range space is equivalent to finding the minimum \dTVC\ for $\mathcal{G}$. On the constructed range space we use the local search algorithm from \cite{mustafa2010hittingset} which proves our result. \begin{changes} Note, we assume that if a region does not admit any points, then it is trivially satisfied. \end{changes} \end{proof} \section{Algorithms for Bounded Degree Temporal Graphs}\label{bounded-degree-sec} In this section we extend our focus from temporal graphs with underlying paths or cycles to instances of \(\Delta\)-TVC with more general degree restrictions. In particular, we present an algorithm that solves \textsc{\(\Delta\)-TVC} exactly, in time that is \begin{changes} exponential in the number of edges of the underlying graph. \end{changes} We then use this algorithm to give a \((d-1)\)-factor approximation algorithm (where \(d\) is the maximum vertex degree in any time step) and finally give an \FPT-algorithm parameterized by the size of a solution. \begin{changes} Before we present our algorithms let us define the generalized notion of (sub)instances of our $\Delta$-TVC problem. We we use this notion in the formulation of the exact exponential time algorithm and in the approximation algorithm. \begin{definition}[\textsc{Partial \(\Delta\)-TVC}] Let \((G, \lambda)\) be a temporal graph. An instance of \textsc{Partial \(\Delta\)-TVC} is given by \((G,\lambda,\ell,h)\), where \(\ell: E(G) \to [T]\) and \(h: E(G) \to [T]\) map each edge to the starting time of its \emph{lowest uncovered time window} and \emph{highest uncovered time window} respectively. The task is to find a temporal vertex subset \(\mathcal{C}\) of minimum size, such that for every edge \(e \) and every time window \(W_i\) with \(\ell(e) \leq i \leq h(e)\) if \(e \in E[W_i]\) then there is some \((v,t) \in \mathcal{C}[W_i]\) where \(v \in e\), \(t \in \lambda(e)\). \end{definition} Intuitively, \textsc{Partial \(\Delta\)-TVC} of $(G,\lambda)$ is a TVC of $(G,\lambda)$, where each edge $e$ has to be covered only in time windows $W_{l(e)}, W_{l(e)+1}, \dots, W_{h(e)}$. Obviously, if \(\ell(e) = 1\) and \(h(e) = T - \Delta + 1\) for all \(e \in E(G)\) then a solution of \textsc{Partial \(\Delta\)-TVC} on \((G,\lambda,\ell,h)\) is also a valid solution of $\Delta$-TVC on $(G, \lambda)$. \end{changes} \subsection{Exact Algorithm} \label{subsec:exact} \newcommand{\unddeg}{{d_G}} \begin{changes} In the following we denote by \(\unddeg\) the degree of the underlying graph of the considered instances of \textsc{Partial \(\Delta\)-TVC}. We provide a dynamic programming algorithm with running time $\mathcal{O}(T \Delta^{\mathcal{O}(|E(G)|)})$ as the next theorem states. \begin{theorem}\label{thm:optPartialTVC} For every \(\Delta\geq 2\), a solution to \textsc{Partial \(\Delta\)-TVC} can be computed in time \(\mathcal{O}(Tc^{\mathcal{O}(|E(G)|)})\), where \(c = \min \{2^\unddeg,\Delta\}\) and \(T\) is the life time of the temporal graph in the instance. \end{theorem} Intuitively, our algorithm scans the temporal graph $\Delta$ time-steps at the time and for each edge $e_i$ calculates the optimal vertex appearance that covers it. Since a time-edge $(e_i, t)$ can appear at each time with a different combination of time-edges incident to it (we call this a \emph{configuration} of edges), it is not always the best to simply cover the last appearance of $e_i$ in the observed time window. To overcome this property we show that it is in fact enough to consider the latest appearance of each configuration of $e_i$, which drastically reduces the search space of our algorithm. Let us now proceed with the detailed proof of \cref{thm:optPartialTVC}. \iflong \begin{proof} Let \((G,\lambda,\ell,h)\) be an instance of \textsc{Partial \(\Delta\)-TVC}. We denote with $m$ the number of edges in the underlying graph $G$ and with $T$ the lifetime of the input instance, more precisely $T \in W_t$, where $t = \max_{e \in E(G)}(h(e))$. For \((G,\lambda,\ell,h)\) we define a dynamic programming table $f$, that is indexed by tuples \((t,x_1,\dotsc, x_{m})\), where \(t \in [T - \Delta + 1]\) and \(x_i \in [0,\Delta - 1]\) for all \(i \in [m]\). We store in \(f(t, x_1, \dotsc, x_{m})\) the size of a minimum \textsc{Partial \(\Delta\)-TVC} of a sub-instance $(G,\lambda,\ell',h)$ with $\ell'(e_i) = t + x_i$, \ie we modify the lowest uncovered time window of each edge. We call such a minimum solution a \emph{witness} for \(f(t,x_1, \dotsc, x_{m})\). Whenever no solution exists we keep \(f(t,x_1, \dotsc, x_{m})\) empty. The following observation is an immediate consequence of the definition and the fact that \(t + x_i = (t + 1) + (x_i - 1)\). \begin{observation}\label{obs-f:increaset} If for all $i$, $x_i \geq 1$ then: $$f(t, x_1, x_2, \dots , x_m) = f(t+1, x_1 - 1, x_2 - 1, \dots , x_m - 1).$$ \end{observation} We introduce the notion of \emph{configurations} of edges, that we use to recursively fill the dynamic programming table. Let $v,w \in V(G)$ be the endpoints of edge $e_i$. An edge configuration of time edge $(e_i,t)$ at endpoint $v$ (resp.~$w$) consist of all time-edges that are incident to $(v,t)$ (resp.~$(w,t)$). Formally, $\gamma(e_i,t)_v = \{e \in E(G) \mid v \in e_i \cap e, t \in \lambda(e)\}$ is a configuration of edges incident to time-edge $(e_i,t) $ at endpoint $v$. With $\gamma (e_i)_v = \{\gamma(e_i,t)_v \mid t \in [T], t \in \lambda(e_i)\}$ we denote the \emph{set of all configurations} of edge $e_i \in (G,\lambda)$ at endpoint $v$. Note, since each vertex in $G$ is of degree at most $d_G$ it follows that $e_i$ is incident to at most $2(d_G -1)$ edges in $G$ ($d_G -1$ at each endpoint) and therefore appears in at most $2^{d_G}$ different edge configurations, i.~e. $|\gamma(e_i)_{v_i}| + |\gamma(e_i)_{w_i}| \leq 2^{d_G}$ for all $v_iw_i=e_i \in E(G)$. Applicability of edge configurations is presented by the following claim. \begin{claim} Suppose that the edge $vw = e_i$ is optimally (temporally) covered in every time window up to $W_t$. Then, to determine an optimum temporal vertex cover in the time window $W_t$, it is enough to check only the last appearance of every edge configuration of $e_i$ in $W_t$. \end{claim} \begin{proof} Suppose that the configuration of $e_i$ at time $t_1$ is the same as the configuration of $e_i$ at time $t_2$ (i.e. $\gamma(e_i,t_1)_v = \gamma(e_i,t_2)_v$ and $\gamma(e_i,t_1)_w = \gamma(e_i,t_2)_w$), where $t \leq t_1 < t_2 \leq t + \Delta -1$. Let $\mathcal{C}$ be an optimum temporal vertex cover of $\mathcal{G}$ that covers edge $e_i$ at time $t_1$ with the vertex appearance $(v,t_1)$. Now let $\mathcal{C}' = \{ \mathcal{C} \setminus (v, t_1)\} \cup (v, t_2)$. Since $\mathcal{C}'$ and $\mathcal{C}$ differ only in the time window $W_t$ all edges in configuration $\gamma(e_i,t_1)_v$ remain optimally (temporally) covered in all time windows up to $W_t$. Since $(v,t_2)$ temporally covers the same edges as $(v,t_1)$ in the time window $W_t$, it follows that $\mathcal{C}'$ is also a $\Delta$-TVC. Clearly $\mathcal{C}'$ is not bigger than $\mathcal{C}$. Therefore, $\mathcal{C}'$ is also an optimum solution. \end{proof} \begin{comment} Let \(\mathcal{C}\) be an optimum solution for \textsc{Partial \(\Delta\)-TVC} for the entire instance and \(\mathcal{C}' \subseteq \mathcal{C}\) be a witness for \(f(t,x_1, \dotsc, x_{|E(G)|})\). Now let \(i\) be such that \(y_i = \min \{y \in [t + x_i,h(e_i)] \mid \exists t'\ (e,t') \text{ is not covered by } \mathcal{C}' \text{ in } W_{y_i}\}\) is minimal. In other words, \(e_i\) is the edge with the earliest appearance that is not covered by \(\mathcal{C}'\) and \(y_i\) is the smallest starting time of a \(\Delta\)-window in which it is not covered. \begin{claim} \label{claim:configrep} There is some \(v \in e_i\), \(\gamma \in \gamma(v)\), and an optimum solution for the entire instance which contains \(\mathcal{C}' \cup \{(v,t)\}\) as subset, where \(t = \max \{t' \in [y_i,y_i + \Delta -1] \cap \lambda(e_i) \cap [\alpha,\beta] \mid \gamma((v,t')) = \gamma\}\). I.e.\ \((v,t)\) is the latest appearance of \(v\) with configuration \(\gamma\) at some time in \([\alpha,\beta]\) which covers all appearances of \(e_i\) in \(W_{y_i}\). \end{claim} \iflong \begin{proof} Let\((v^*,t^*) \in \mathcal{C}\) such that \((v^*,t^*)\) covers all appearances of \(e_i\) in \(W_{y_i}\), and let \(\gamma^* = \gamma((v^*,t^*))\). Consider \((v^*,t)\) where \(t = \max \{t' \in [y_i,y_i + \Delta -1] \cap \lambda(e_i) \cap [\alpha,\beta] \mid \gamma((v,t')) = \gamma^*\}\). It is straightforward to verify that \(\mathcal{C} \setminus \{(v^*,t^*)\} \cup \{(v^*,t)\}\) is a solution for the original \textsc{Partial \(\Delta\)-TVC} instance with the desired properties. Indeed the only non-trivial property to check is that \(\mathcal{C} \setminus \{(v^*,t^*)\} \cup \{(v^*,t)\}\) is a \(\Delta\)-TVC. Assume for contradiction that \((e,s)\) is covered by \((v^*,t^*)\) in \(W_j\) but not by \((v^*,t)\). Because \(\gamma((v^*,t)) = \gamma((v^*,t^*))\) it holds that \(t \in \lambda(e)\). By choice of \(e_i\) and \(y_i\), \(j \geq y_i\). At the same time by choice of \(t\), \(t^* \leq t\) and hence \(t \in W_j\). Hence \((v^*,t)\) covers \((e,s)\) contradicting our assumption. \end{proof} \fi Given \(f(t, x_1, \dotsc, x_{|E(G)|})\), let \(e_i \in E(G)\) be such that \(x_i < \Delta\) and there is an appearance of \(e_i\) at some time step in \(W_{t + x_i} \setminus W_{t + x_i - 1}\). If there is no such edge, then obviously \(f(t, x_1,\dotsc,x_{|E(G)|}) = f(t, x_1 + 1, \dotsc, x_{|E(G)|} + 1)\). Now we consider both options for \(v \in e_i\) and all options for \(\gamma \in \gamma(v)\). Let \(t' \in [x_i,t + \Delta - 1] \cap \lambda(e_i) \cap [\alpha,\beta]\) be maximal with \(\gamma(v,t') = \gamma\). \(\vec{y}\) arises from \(x_1, \dotsc, x_{|E(G)|}\) by replacing \(x_j\) with \(\max\{x_j, t' - t\}\) for all \(j\) for which \(e_j \in \gamma\). Now we set \(f(t,\vec{y})\) to the minimum of \(f(t,x_1, \dotsc, t_{|E(G)|}) + 1\) and its previous value, if it was set. This is correct by \Cref{claim:configrep}. After processing all non-empty entries of \(f\) indexed by tuples starting with \(t\) in this way, we move to \(t + 1\) using \Cref{obs-f:increaset}. \iflong Formally, whenever \(f(t,x_1, \dotsc, x_{|E(G)|})\) with \(x_i > 0\) for all \(i \in [|E(G)|]\), we set \(f(t + 1,x_1 - 1, \dotsc, x_{|E(G)|} -1) = f(t,x_1, \dotsc, x_{|E(G)|})\).\fi The size of an optimum solution for our \textsc{Partial \(\Delta\)-TVC} instance is now given by \(f(T-2\Delta+1,\Delta, \dotsc, \Delta)\). \end{comment} \noindent Using the properties presented above we are ready to describe the procedure that computes the value of $f(t,x_1,x_2, \dots, x_m)$. \begin{itemize} \item[Case 1.] If for all $i$ it holds $x_i > 0$, then $f(t, x_1, x_2, \dots, x_m) = f(t+1, x_1-1, x_2-1, \dots, x_m-1)$. \item[Case 2.] There is at least one $x_i = 0$. Let $i$ be the smallest index for which this holds and let $v_iw_i=e_i$ be its corresponding edge. Now to temporally cover $e_i$ in the time window $W_t$ we check the last appearance of all edge configurations of $e_i$ at $v_i, w_i$ and chose the one that minimizes the solution. Namely, if we cover $e_i$ at time $t_i$ using vertex $v_i$ we add $(v_i,t_i)$ to the solution, set the new value of $x_i$ to $t_i - t$ and also the value $x_j$ of every edge $e_j$ in $\gamma(e_i,t)_{v_i}$ to $t_i - t$. We then recursively continue the calculation of $f$. At the end we select such $t_i$ (such edge configuration) that minimizes the value $f(t,x_1,x_2,\dots,x_m)$. \end{itemize} \paragraph{Running Time.} It is straightforward to see that the number of table entries is bounded by \(T\Delta^{|E(G)|}\) which also bounds the complexity of computing them.\\ A second bound can be established by noticing that each entry of \(f\) that is filled during the dynamic program is uniquely determined by configurations of each edge. Together both bounds yield the desired complexity. \end{proof} \fi \end{changes} In fact the same algorithm and analysis gives a running time bound which is exponential in the \emph{maximum \(\Delta\)-window vertex degree} \(d_\Delta\) which is the maximum vertex degree in any part of \(G\) that appears together in an arbitrary \(\Delta\)-time window. Observe that \(d_\Delta \leq d_G\) but there are also instances in which \(d_G\) is much larger than \(d_\Delta\). \noindent \begin{remark} The above algorithm solves \textsc{Partial \(\Delta\)-TVC} in \(\mathcal{O}(Tc^{\mathcal{O}(|E(G)|)})\) where \(c = \min \{2^{d_\Delta},\Delta\}\). \end{remark} Note, the following parameterized complexity result of \dTVC follows directly from our algorithm above. \begin{corollary} For every $\Delta\geq 2$, \dTVC\ can be solved in time in \(\mathcal{O}(Tc^{|E(G)|})\) where \(c = \min \{2^{\mathcal{O}(|E(G)|)},\Delta\}\), and thus \dTVC\ is in \FPT\ parameterized by \(|E(G)|\). \end{corollary} \subsection{\boldmath Approximation Ratio Better Than \(d\)}\label{better-d-approx-subsec} \begin{changes} In this section we focus on approximation algorithms. In \cite{AkridaMSZ20}, the authors present the \(d\)-factor approximation algorithm (where \(d\) is the maximum vertex degree in any time step), that uses the following idea. First optimally solve the $\Delta$-TVC for each edge separately, which can be done in polynomial time, and then combine all the solutions. In the worst case it may happen that the solution includes all $d$ neighbors of a specific vertex appearance $(v,t)$, instead of just $(v,t)$. Which is how the bound of $d$ is obtained. We try to avoid this situation by iteratively covering paths with two edges (\(P_3\)) instead of single edges. With this approach we force the middle vertex (called \emph{center}) to be in the vertex cover, which gives us an error of at most \(d-1\). Based on this idea we can formulate our \((d-1)\)-approximation algorithm. \end{changes} \subsubsection{Description of the Algorithm} We iteratively extend an initially empty set \(\mathcal{X}\) to a $\Delta$-TVC in the following way. While there is some \(e \in E(G)\) that is not covered in some time window of \(\mathcal{G}\) we have to extend \(\mathcal{X}\); otherwise \(\mathcal{X}\) is a \(\Delta\)-TVC which we can return. We proceed in two phases: \iflong \begin{enumerate} \item {While there is a $P_3$ that is uncovered in some time window $W_i$ (i.~e.~there are two uncovered adjacent edges $e_1,e_2$ in $W_i$), we build an instance of the \textsc{Partial \(\Delta\)-TVC} in the following way. Let \(S\) be the set of all time steps in which $P_3$ is uncovered. We subdivide \(S\) into subsets \(S_1, \dotsc, S_k\) with \(k \leq T\) such that there is a gap of at least $2\Delta - 1$ between the last element of $S_i$ and the first element of $S_{i+1}$ (for all $i \in [k-1]$). Now we consider the subinstances given by \((G[P_3], \lambda'_i(P_3), \ell_i(P_3), h_i(P_3))\) with \(\lambda'_i(P_3)\) defined as the restriction of \(\lambda\) to \(\{P_3\} \cap \lambda^{-1}([\min S_i - \Delta + 1, \max S_i + \Delta - 1])\), \(\ell_i(P_3)\) is the smallest value \(t\) such that \((P_3,\min S_i)\) is not covered in time window \(W_t\), and \(h_i(P_3)\) is the largest value \(t\) such that \((P_3,\max S_i)\) is not covered in time window \(W_t\). We use the algorithm from \Cref{subsec:exact} to solve these subinstances and extend \(\mathcal{X}\) by the union of the solutions.\\ Note that these are the subinstances that bring the crucial advantage compared to the known \(d\)-approximation. To ensure our approximation guarantee, we also need to allow the inclusion of appearances of a single edge of different \(P_3\) subinstances. This is why we restrict the temporal extent of each \(P_3\) subinstance to time steps which are impacted by the actual appearances of the respective \(P_3\). } \item { When there is no such $P_3$ left, we set \(F\) to be the set of edges \(e \in E(G)\) that are not yet covered in some time window of \(\mathcal{G}\). For \(e \in F\), let \(S^e\) be the set of all time steps in which \(e\) appears and is not covered. We subdivide \(S^e\) into subsets \(S^e_1, \dotsc S^e_k\) with \(k \leq T\) such that there is a gap of at least $2\Delta - 1$ between the last element of $S_i$ and the first element of $S_{i+1}$ (for all $i \in [k-1]$). Now we consider the subinstances given by \((G[e], \lambda'_i(e), \ell_i(e), h_i(e))\) with \(\lambda'_i(e)\) defined as the restriction of \(\lambda\) to \(\{e\} \cap \lambda^{-1}([\min S^e_i - \Delta + 1, \max S^e_i + \Delta])\), \(\ell_i(e)\) is the smallest value \(t\) such that \((e,\min S^e_i)\) is not covered in time window \(W_t\), and \(h_i(e)\) is the largest value \(t\) such that \((e,\max S^e_i)\) is not covered in time window \(W_t\). We use the algorithm from \Cref{subsec:exact} to solve these subinstances and extend \(\mathcal{X}\) by the union of the solutions.\\ Intuitively, these subinstances just take care of whatever remains after the first phase. We split them up temporally, just for compatibility with the input for the algorithm from \Cref{subsec:exact}.} \end{enumerate} \fi \ifshort \smallskip \noindent\textbf{Phase 1}: While we find two such edges \(e_1,e_2\) that are adjacent and appear at the same time step and both appearances are not covered in some time window \(W_i\) then we consider the following subinstances of \textsc{Partial \(\Delta\)-TVC}: Let \(S\) be the set of all time steps in which \(e_1\) and \(e_2\) appear together and are both not covered by \(\mathcal{X}\) in some time window \(W_i\) with \(i \in [\min S - \Delta + 1, \max S - \Delta + 1]\). We can subdivide \(S\) into subsets \(S_1, \dotsc S_k\) with \(k \leq T\) such that \(S_1\) contains the smallest elements of \(S\) such that there is no gap of at least \(2\Delta - 1\) between its elements, \(S_2\) contains the smallest elements of \(S\) between the first and second gap of at least \(2\Delta - 1\), and so on. Now we consider the subinstances given by \((G[e_1,e_2], \lambda', \ell, h, \min S_i, \max S_i)\) with \(\lambda'\) defined as the restriction of \(\lambda\) to \(\{e_1,e_2\} \cap \lambda^{-1}([\min S_i - \Delta + 1, \max S_i - \Delta + 1])\), \(\ell(e_1) = \ell(e_2)\) is the smallest time step \(t\) such that \((e_1,\min S_i)\) and \((e_2, \min S_i)\) are not covered in time window \(W_t\) by \(\mathcal{X}\), and \(h(e_1) = h(e_2)\) is the largest time step \(t\) such that \((e_1,\max S_i)\) and \((e_2, \max S_i)\) are not covered in time window \(W_t\) by \(\mathcal{X}\). We use the algorithm from \Cref{subsec:exact} to solve these subinstances and extend \(\mathcal{X}\) by the union of the solutions. \smallskip \noindent\textbf{Phase 2:} If no such edges are adjacent and appear at the same time step and both appearances are not covered in some time window \(W_i\) let \(F\) be the set of edges \(e \in E(G)\) with occurrences which is not covered in some time window in the lifetime of \(\mathcal{G}\) by \(\mathcal{X}\). We consider the following subinstances of \textsc{Partial \(\Delta\)-TVC}: For \(e \in F\), let \(S^e\) be the set of all time steps in which \(e\) appears and is not covered by \(\mathcal{X}\) in some time window \(W_i\) with \(i \in [\min S^e - \Delta + 1, \max S^e - \Delta + 1]\) and \(t \in S^e\). We can subdivide \(S^e\) into subsets \(S^e_1, \dotsc S^e_k\) with \(k \leq T\) such that \(S^e_1\) contains the smallest elements of \(S^e\) such that there is no gap of at least \(2\Delta - 1\) between its elements, \(S^e_2\) contains the smallest elements of \(S^e\) between the first and second gap of at least \(2\Delta -1\), and so on. Now we consider the subinstances given by \((G[e], \lambda', \ell, h, \min S^e_i, \max S^e_i)\) with \(\lambda'\) defined as the restriction of \(\lambda\) to \(\{e\} \cap \lambda^{-1}([\min S^e_i - \Delta + 1, \max S^e_i + \Delta])\), \(\ell(e)\) is the smallest time step \(t\) such that \((e,\min S^e_i)\) is not covered in time window \(W_t\) by \(\mathcal{X}\), and \(h(e)\) is the largest time step \(t\) such that \((e,\max S^e_i)\) is not covered in time window \(W_t\) by \(\mathcal{X}\). We use the algorithm from \Cref{subsec:exact} to solve these subinstances and extend \(\mathcal{X}\) by the union of the solutions. \fi It follows from the above construction that the produced set \(\mathcal{X}\) of vertex appearances is a \(\Delta\)-TVC of $\mathcal{G}$. \ifshort Furthermore, using a double counting argument, we can show that the approximation ratio is at most $d-1$. \fi \subsubsection{Running Time and the Approximation Ratio \boldmath \((d-1)\).} { The number of subinstances considered in Phase 1 is easily bounded by the number of combinations of two edges in \(E(G)\) multiplied by \(T\). Similarly the number of subinstances considered in Phase 2 is bounded by the number of edges in \(E(G)\) multiplied by \(T\). The subinstances require a running time of \(\mathcal{O}(T)\) to solve. Thus the overall running time lies in \(\mathcal{O}(|E(G)|^2T^2)\). For the approximation guarantee we provide only the idea of the proof. Our algorithm brakes down the $\Delta$-TVC of the whole temporal graph $(G,\lambda)$ into smaller subinstances, namely into paths on two edges ($P_3$'s), whenever possible. To cover such a subinstance the solution returned by the algorithm uses appearances of the middle (central) vertex in an optimal way. Therefore these vertex appearances cover at least two edge appearances that cannot be covered by fewer vertices in a solution for the entire temporal graph \((G, \lambda)\). It turns out that, in the worst case, such a selection gives us an error of at most \(d-1\). } \iflong \begin{comment} \subsubsection{Approximation Ratio \boldmath \((d-1)\).} We denote the set of subinstances considered during our algorithm by \(\mathfrak{H}\). Let \(\mathcal{C}\) be a minimum \(\Delta\)-TVC for \(\mathcal{G}\), and \(\mathcal{X}\) be the temporal vertex set computed by our algorithm. To show the desired approximation guarantee, we give a double-counting argument for the cardinality of the following set \(A\): \begin{align*} A = \{(v,t,\mathcal{H}) \mid & (v,t) \in \mathcal{C}, \mathcal{H} \in \mathfrak{H} \, \land\\ & (v,t) \text{ covers an appearance of } e \in E(H)\\ & \text{at some time } t' \in \lambda'(e)\\ & \text{in } W_i \text{ with } \ell(e) \leq i \leq h(e)\}\end{align*} { For this it will be useful to distinguish vertices in \(\mathcal{C}\) based on what kinds of subinstances they cover edge appearances in, as well as subinstances in \(\mathcal{H}\) based on whether the number of vertices in \(\mathcal{C}\) that cover edge appearances in them is more than the optimal solution for the respective subinstance. More formally, after introducing the notation \begin{align*} \mathfrak{H}(v,t) = \{\mathcal{H} \in \mathfrak{H} \mid & (v,t) \text{ covers an appearance}\\ & \text{of } e \in E(H) \text{ at time } t' \in \lambda'(e)\\ &\text{in } W_i \text{ with } \ell(e) \leq i \leq h(e)\} \end{align*} and \begin{align*} \mathcal{C}(\mathcal{H}) = \{(v,t) \in \mathcal{C} \mid & (v,t) \text{ covers an appearance}\\ & \text{of } e \in E(H) \text{ in } W_i \text{ with }\\ & \ell(e) \leq i \leq h(e)\}, \end{align*} it is clear that \begin{align} |A| & = \sum_{(v,t) \in \mathcal{C}} |\mathfrak{H}(v,t)|\\ & \leq (d - 1)|\mathcal{C}| + \sum_{\substack{(v, t) \in \mathcal{C} \\ |\mathfrak{H}(v,t)| > d - 1}} |\mathfrak{H}(v,t)| - (d - 1). \end{align}. Moreover, \begin{align} |A| & = \sum_{\mathcal{H} \in \mathfrak{H}} |\mathcal{C}(\mathcal{H})|\\ & \geq |\mathcal{X}| + \sum_{\{H \in \mathcal{H} \mid |\mathcal{X}(\mathcal{H})| < \mathcal{C}(\mathcal{H})|\}} |\mathcal{C}(\mathcal{H})| - |\mathcal{X}(\mathcal{H})|, \end{align} where \(\mathcal{X}(\mathcal{H})\) denotes the optimal solution for \(\mathcal{H}\) during the calculation of \(\mathcal{X}\). This is because \(|\mathcal{X}| = \sum|\mathcal{X}(\mathcal{H})|\), and as optimal solution for \(\mathcal{H}\), it holds that \(|\mathcal{X}(\mathcal{H})| < |\mathcal{C}(\mathcal{H})|\).} { Now to prove our target, namely that \(|\mathcal{X}| \leq (d-1)|\mathcal{C}|\), it suffices to show that \[\sum_{\substack{(v, t) \in \mathcal{C} \\ |\mathfrak{H}(v,t)| > d - 1}} |\mathfrak{H}(v,t)| - (d - 1) \leq \sum_{\{H \in \mathcal{H} \mid |\mathcal{X}(\mathcal{H})| < |\mathcal{C}(\mathcal{H})|\}} |\mathcal{C}(\mathcal{H})| - |\mathcal{X}(\mathcal{H})|.\] } { Let us start by considering the left-hand side, and in particular when a temporal vertex can cover edge appearances in more than two instances considered by our approximation algorithm. First of all, we observe that almost all edges that are covered in different subinstances by a single temporal vertex \((v,t)\) have to be distinct. \begin{observation} \label{obs:covered-instances} Let \((v,t) \in \mathcal{C}\). There is at most one Phase~2 subinstance \(\mathcal{H}_1 \in \mathfrak{H}(v,t)\). Moreover, for all distinct \(\mathcal{H}_2, \mathcal{H}_3 \in \mathfrak{H} \setminus \{\mathcal{H}_1\}\) for which \((v,t)\) covers an appearance of an edge \(e_2 \in E(H_2)\) in \(\mathcal{H}_2\) and an edge \(e_3 \in E(H_3)\) in \(\mathcal{H}_3\), it holds that \(e_2 \neq e_3\). \end{observation} \begin{proof} Note that the second part of the statement follows easily from the first one and the construction of the Phase~1 subinstances as disjoint and separated by at least \(2\Delta - 1\) time steps. The first part of the statement is true because otherwise the two appearances used to form two separate Phase~2 instances would have already been used in Phase~1 to form an instance together. \end{proof} This means that \(|\mathfrak{H}(v,t)|\) is naturally bounded by the degree of \(v\) in \(G_t\) plus \(1\). This means for all \((v,t)\) with temporal degree at most \(d - 2\) it holds that \(|\mathfrak{H}(v,t)| \leq (d - 2) + 1 = d - 1\). By construction any temporal vertex \((v,t)\) that covers appearances of both underlying edges \(e_1,e_2\) of some \(P_3\) subinstance \(\mathcal{H}\) constructed in Phase~1 of our algorithm, can cover edge appearances in one less subinstance (because two of its incident edge appearances are part of the same subinstance). This means for all \((v,t)\) with temporal degree at most \(d - 1\) that cover appearances of both underlying edges of some \(P_3\) subinstance constructed in Phase~1 of our algorithm, it holds that \(|\mathfrak{H}(v,t)| \leq (d - 1) + 1 - 1 = d - 1\). For all remaining temporal vertices we give subinstances \(\mathcal{H}\) for which the optimal solution \(\mathcal{X}(\mathcal{H})\) is strictly smaller than \(\mathcal{C}(\mathcal{H})\). \begin{lemma} \label{lem:critical-subinstances} For each \((v,t)\) with \(|\mathfrak{H}(v,t)| > d - 1\), there are \(|\mathfrak{H}(v,t)| - (d - 1)\) distinct subinstances \(\mathcal{H} \in \mathfrak{H}\) such that a solution for \(\mathcal{H}\) that is strictly smaller than the one given by \(\mathcal{C}'(\mathcal{H})\) can be found where \(\mathcal{C}'(\mathcal{H})\) is the modification of \(\mathcal{C}(\mathcal{H})\) for all previously considered subinstances and temporal vertices. \end{lemma} \begin{proof} We first show that if there is a Phase~2 subinstance \(\mathcal{H}_1 \in \mathfrak{H}(v,t)\) and a Phase~1 subinstance \(\mathcal{H}_2 \in \mathfrak{H}(v,t)\) that shares an underlying edge with \(\mathcal{H}_1\), then we can modify \(\mathcal{C}'(\mathcal{H}_2)\) to a strictly smaller solution for \(\mathcal{H}_2\). For this note, that the underlying edge \(e\) of \(\mathcal{H}_2\) that is not shared by \(\mathcal{H}_1\) cannot appear in some \(\Delta\)-time window including \(t\), because otherwise by the construction of the subinstances, \(\mathcal{H}_1\) would not include the shared edge between \(H_1\) and \(H_2\) as an underlying edge which contradicts it being covered by \((v,t)\). However \(e\) must be covered by \(\mathcal{C}'(\mathcal{H}_2)\) in all such time windows, and replacing the temporal vertices that cover this by the appearance of the vertex shared by both underlying edges at the respective time step, and removing \((v,t)\) from \(\mathcal{C}'(\mathcal{H}_2)\) results in a strictly smaller solution for \(\mathcal{H}_2\). Next, we show that if there is a Phase~1 subinstance \(\mathcal{H} \in \mathfrak{H}(v,t)\) that shares no underlying edge with any Phase~2 subinstance in \(\mathfrak{H}(v,t)\) (this includes that there is no such Phase~2 subinstance) and \(v\) is not incident to both edges in \(E(H)\), then we can modify \(\mathcal{C}'(\mathcal{H})\) to a strictly smaller solution for \(\mathcal{H}\). To show this we can proceed exactly as above, after observing that one underlying edge in \(\mathcal{H}\) does not appear at \(t\) but needs to be covered in all relevant \(\Delta\)-time windows by temporal vertices other than \((v,t)\). We can replace the temporal vertices that cover these by the appearance of the vertex shared by both underlying edges at the respective time step, and remove \((v,t)\) from \(\mathcal{C}'(\mathcal{H})\), yielding a strictly smaller solution for \(\mathcal{H}\). We now argue that these subinstances are sufficient, in terms of their number. Indeed, for all temporal vertices \((v,t)\) that cover appearances of both underlying edges of some Phase~1 subinstance, if there is no Phase~2 subinstance in \(\mathfrak{H}(v,t)\), then \(|\mathfrak{H}(v,t)| \leq d - 1\) by \Cref{obs:covered-instances}, and the fact that at least one subinstance in \(\mathfrak{H}(v,t)\) includes two incident edge appearances. Otherwise the single subinstance \(\mathcal{H}_2\) for which we modify \(\mathcal{C}'(\mathcal{H}_2)\) in this case suffices. Let us move on to the temporal vertices \((v,t)\) that do not cover appearances of both underlying edges of any Phase~1 subinstance. Because we argued above that we only need to consider \((v,t)\) with \(\operatorname{deg}_{G_t}(v) \geq d - 1 \geq 3 - 1 = 2\) (here it is important that \(d \geq 3\), we know that there must be at least one Phase~1 subinstance \(\mathcal{H} \in \mathfrak{H}(v,t)\) that shares no underlying edge with any Phase~2 subinstance in \(\mathfrak{H}(v,t)\) such that \(v\) is not incident to both edges in \(E(H)\). Otherwise the two edge appearances incident to \((v,t)\) would have been used to form a Phase~1 subinstance contradicting the assumed property of \((v,t)\). If there is no Phase~2 subinstance in \(\mathfrak{H}(v,t)\), then \(|\mathfrak{H}(v,t)| \leq \operatorname{deg}_{G_t}(v)\) by \Cref{obs:covered-instances}, and modifying \(\mathcal{C}'(\mathcal{H})\) suffices. Otherwise we can modify both \(\mathcal{C}'(\mathcal{H})\) and \(\mathcal{C}'(\mathcal{H}_2)\) as described for this case. \end{proof} \Cref{lem:critical-subinstances} implies that \[\sum_{\substack{(v, t) \in \mathcal{C} \\ |\mathfrak{H}(v,t)| > d - 1}} |\mathfrak{H}(v,t)| - (d - 1) \leq \sum_{\{H \in \mathcal{H} \mid |\mathcal{X}(\mathcal{H})| < |\mathcal{C}(\mathcal{H})|\}} |\mathcal{C}(\mathcal{H})| - |\mathcal{X}(\mathcal{H})|,\] which concludes the proof of the desired approximation guarantee. } \end{comment} Overall this shows the desired approximation result. \begin{theorem} For every \(\Delta \geq 2\) and $d\geq 3$, \dTVC\ can be \((d-1)\)-approximated in time \(\mathcal{O}(|E(G)|^2T^2)\). \end{theorem} \subsection{An \FPT\ algorithm with respect to the solution size}\label{cp-alg-subsec} Our final result settles the complexity of \textsc{\(\Delta\)-TVC} from the viewpoint of parameterized complexity theory~\cite{CyganFKLMPPS15,DowneyFellows13,Niedermeier06} with respect to the standard parameterization of the size of an optimum solution. \begin{theorem} For every $\Delta\geq 2$, \dTVC\ can be solved in $\mathcal{O}((2\Delta)^kT n^2)$ time, where \(k\) is the size of an optimum solution. In particular \dTVC\ is in \FPT\ parameterized by \(k\). \end{theorem} \iflong \begin{proof} The algorithm starts by selecting an edge $e \in E(G)$ with an uncovered appearance in an arbitrary \(\Delta\)-time window $W_t$ and selects one of (at most) $\Delta$ vertex appearances of either endpoint to cover it. By covering one edge at some time point, we also cover some other edges in some other time windows, these are also excluded from the subsequent search. This step is repeated until after $k$-steps the algorithm stops and checks if selected vertices form a sliding $\Delta$-time window temporal vertex cover of $\mathcal{G}$. The algorithm builds at most $(2 \Delta)^k$ sets, for each of which checking if it is a temporal vertex cover takes $\mathcal{O}(T n^2)$ time. Therefore the running time of the algorithm is $\mathcal{O}((2 \Delta)^k T n^2)$. \end{proof} \fi
{'timestamp': '2022-04-12T02:30:22', 'yymm': '2204', 'arxiv_id': '2204.04832', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04832'}
arxiv
\section{Introduction} \label{sec:introduction} \IEEEPARstart{S}{ecurity} is an essential component of a dependable system. Since the inception of the Industry 4.0 revolution early last decade, the integration of intelligent Internet of Things (IoT) sensors has become inevitable to keep running the latest enterprise ecosystem smoothly. Thus, the popularity of IoT devices has greatly increased over the last couple of years because of their appealing connectivity, communication, and decision-making features \cite{Eirini-1}. Admittedly, the rise of cyber-attacks has increased in line with the massive online deployments of IoT devices \cite{Da-9}. However, the cyber-physical world is not always predictable \cite{Redowan-73}. Although the interactions within integrated cyber-physical systems are complex, there is no doubt that they must be "dependable" \cite{Bhuiyan-4}. Future heterogeneous IoT applications must close the dependability gap in the face of various challenges and services, such as the ability to overcome data anomalies, avoid catastrophic failures, avoid data corruption, and prevent deliberate privacy intrusions, among others \cite{Bhuiyan-4, 9594795}. As industrial heterogeneous IoT devices have proliferated (25.1 billion by 2025 forecast by the GSM Association). This, has had a direct impact on our socio-economic lives \cite{Alsaedi-39, Manos-6}. So, security and privacy issues relating to industrial heterogeneous IoT devices need to be addressed by ensuring dependability with care and attention. Generally, IoT-based applications consist of lightweight communication protocols with limited computational power and storage capacity \cite{Emiliano-10, hasan-75}. However, traditional security mechanisms require high computational capabilities \cite{Da-9}. As a result of their heterogeneous nature and characteristics, this mechanism cannot be directly deployed for IoT-based applications \cite{Da-9, Emiliano-10}. As IoT applications operate inside the network, this mechanisms seem to be insufficient because of their characteristics, which only identify external attacks \cite{Tianlong-11}. Because of the overwhelming rise of IoT threats and vulnerabilities, they have already shown their inadequate strength to fight against targeted attacks and associated anomalies \cite{Jayavardhana-13}. As a result, the potential threats to the IoT ecosystem are constantly emerging and changing, and the exact nature of these threats or attacks is complex to investigate. Furthermore, traditional machine learning (TML) algorithms have advanced significantly, and some of their variants have been successfully applied to solve classification tasks related to intrusion detection \cite{Nisioti-67, Alsaedi-74}. Also, the progression of deep learning (DL) and its great success in different fields has guided it as a potential solution for network intrusion detection \cite{Nisioti-67}. However, most of proposed IDSs focus on detecting a limited number of cyber-attack types and device profiling and do not consider automatic attack type classification and dependability \cite{Li-32}. Most importantly, these models require a large amount of training data, and the size of training datasets affects the accuracy of the model when the training data is insufficient, as highlighted by the authors in \cite{Anca-8, Shahid-3}. As a result, the TML and DL models need sufficient training data, and it is difficult to train a dependable IDS model only depending on a small-scale of target domain data. With the rapid development of IoT networks and the emergence of new threat types, deep transfer learning (DTL) models, which have effectively solved many nonlinear problems, can be used as a promising solution for building a dependable IDS for the IoT ecosystem \cite{Jun-18}. Specifically, in the Industry 4.0 revolution, heterogeneous IoT applications require a high level of dependable security structure \cite{Bhuiyan-17}. Therefore, there is a need for a dependable intrusion detection system to identify malicious activity within any heterogeneous IoT network. Dependability performance analysis includes availability, efficiency, and scalability features \cite{Bhuiyan-4}. An IDS model's availability is determined by how often it is available, and its efficiency is how well it performs with low computational complexity \cite{Bhuiyan-4}. Also, scalability is the capability to adapt easily to the increased number of data sources from a wider range of IoT sensors \cite{Gregory-4}. To consider all the dependencies, we propose a deep transfer learning-based residual neural network (P-ResNet) IDS that can train efficiently using only a small scale of target domain data and understand its impact by ensuring dependability with low computational capabilities. Figure~\ref{The overall scenario of the proposed IDS applied to the heterogeneous IoT network} shows the motivation on how the proposed IDS can be applied to the IoT network toward effective attack detection. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{Motivation.pdf} \caption{The overall scenario of the proposed IDS applied to the heterogeneous IoT network} \label{The overall scenario of the proposed IDS applied to the heterogeneous IoT network} \end{figure} The proposed method can accurately classify between normal and attack scenarios without any type of failure or undergoing a repair action, which maintains the availability. Moreover, the proposed model increased the scalability properties by including various heterogeneous trusted data sources in the training dataset with maximum consistency that were acquired from a wider range of IoT sensors. Finally, our proposed model improves performance compared to several other existing approaches. The overall accuracy of the proposed detection model is 87\% with low computational complexity. Moreover, the model also greatly improves the precision score of 88\%, the recall score of 86\%, and the f1-score of 86\%, which are higher than the benchmark models. This demonstrates that the proposed detection method is more efficient than others. Extensive analysis and performance evaluation show that the proposed model is robust, more efficient, and has demonstrated better performance, ensuring dependability. The key contributions of this paper are summarized as follows: \begin{itemize} \item In this work, a deep transfer learning-based residual neural network (ResNet) has been proposed for effective intrusion detection. This model effectively detect various cyber threats against heterogeneous IoT networks. Such threats include, denial-of-service (DoS), distributed denial-of-service (DDoS), data injection, man-in-the-middle (MITM), backdoor, password cracking attack (PCA), scanning, cross-site scripting (XSS), and ransomware attack. \item The experiments have been conducted using IoT data generated from heterogeneous sources that include seven IoT sensors. We have observed empirical IoT stream data to identify the best features in the context of supervised learning for speeding up training and improving performance metrics while ensuring its dependability. \item Finally, comprehensive experimental performance analyses have been conducted considering various deep learning and deep transfer learning algorithms. Extensive analysis and performance evaluation show that the proposed model is more dependable and outperforms others. \end{itemize} The rest of this research paper is organized as follows. First, Section \ref{sec: related work} discusses the background and related works. In Section \ref{sec: proposed methodology}, we present the details of our proposed methodology. Section \ref{sec: model implementation and evaluation} presents a detailed description of the dataset and the training process of the selected models. Furthermore, evaluation and experimental results analysis of the methods are discussed in Section \ref{sec: result analysis}. Finally, the summary and possible future research directions are given in Section \ref{sec: conclusion and future work}. \section{Related Work} \label{sec: related work} While investigating the most recent relevant works, we found several works that overlap similar motivations differently. The following discussion illustrates those works before we demonstrate our proposed methodology. Deep transfer learning is a solution that can reuse existing knowledge from the previously trained model and achieve better intrusion detection performance than other models \cite{Li-32}. The transfer learning model proposed by Zadrozny et al. \cite{Zadrozny-34} for intrusion detection, shows more efficient performance in both labeled and unlabeled data. Dai et al. \cite{Dai-35} also proposed a transfer learning model called TrAdaBoost. This model allows knowledge to be efficiently transferred from the old trained data to construct a more efficient classification model for the new validation data. Raina et al. \cite{Raina-36} proposed a transfer learning model that builds an informative model on existing knowledge before validating a particular new task. Gou et al. \cite{Gou-37} proposed a novel transfer learning algorithm to detect different cyber-attacks on large-scale IoT ecosystems. The experimental analysis shows that the detection accuracy of the proposed model for different types of cyber-attacks has been comprehensively improved. Furthermore, Li et al. \cite{Li-32} proposed a transfer learning approach for intrusion detection of different types of attacks on the Internet of Vehicles (IoV). The experimental analysis shows that the model has greatly improved the detection accuracy rate by 23\%. Xu et al. \cite{Xu-38} proposed an intrusion detection approach based on deep learning and transfer learning. Here, transfer learning is initiated to enhance the efficiency and adaptability of the model. The experimental analysis shows that the proposed model is more efficient and robust than other methods and performs better in detecting and classifying new cyber-attacks more effectively. In addition, a real-time, dependable method for human activity classification based on transfer learning has been proposed by Wan et al. \cite{Wan-32}. The experimental analysis shows that the proposed method outperforms others. Recently, Jiang et al. \cite{Jiang-33} proposed a dependable deep learning-based model design for IoT load identification in smart grid. The experimental results demonstrate the good generalization performance and superiority for NILMI in IoT load monitoring systems. However, further analyses are necessary to investigate the performance of new complex types of cyber-attacks in various categories. A summary of all the existing literature that overlap similar motivations differently is given in Table \ref{Table: Overview of recent research on IDSs for IoT applications}. The literature is organized according to \textit{detection\_category}, \textit{model\_accuracy}, \textit{proposed\_methodology}, \textit{validation\_strategy}, and \textit{dependability\_performance\_analysis} of the proposed model. To get the optimal performance of existing transfer-learning models and maintain the knowledge transfer process in realistic models for heterogeneous IoT ecosystems, the deep computational intelligence system has recently been applied in transfer-learning \cite{Lu-33}. So, the existing transfer learning solutions for intrusion detection still require a small amount of labeled data for model updates in heterogeneous IoT applications, ensuring dependability. A new-generation labeled \textit{TON\_IoT\_Telemetry\_Dataset} of IoT devices for data-driven IDS was proposed by Alsaedi et al. \cite{Alsaedi-39}, which is more suitable for applying deep transfer learning models. The deep transfer learning approach shows better performances in time series classification than other models \cite{Xu-38}. Because of the original situation of heterogeneous IoT applications, this paper has comprehensively improved the existing transfer learning model to ensure its dependability for detecting various complex types of cyber-attacks. \begin{table*}[htp] \caption{Overview of recent research on IDSs for IoT applications. "C" indicates that the topic is covered, "N" indicates that the topic is not covered and "P" indicates that the topic is partially covered.} \label{Table: Overview of recent research on IDSs for IoT applications} \centering \begin{tabular}{|c|c|c|c|c|c|} \hline Ref. & Detection Category & Accuracy & Proposed Methodology & Validation Strategy & Dependability\\ \hline \cite{Zadrozny-34} & Learning and Evaluating Classifiers & $>$90\% & Transfer Learning & Analytical and Experimental & N\\ \hline \cite{Dai-35} & Efficiently Transferred Trained-data & $>$85\% & Transfer Learning & Theoretically and Empirically & N\\ \hline \cite{Raina-36} & Intrusion Detection System & $>$85\% & Transfer Learning & Simulation & N\\ \hline \cite{Gou-37} & Intrusion Detection System & $>$90\% & Distributed Transfer Learning & Empirical (6 Devices) 4 Categories & P\\ \hline \cite{Li-32} & Intrusion Detection System & $>$85\% & Transfer Learning & Empirical & N\\ \hline \cite{Xu-38} & Intrusion Detection System & $>$80\% & Deep Transfer Learning & Empirical (4 Devices) 6 Categories & P\\ \hline \cite{Jiang-33} & Device Load Monitoring System & $>$85\% & Transfer Learning & Experimental & N\\ \hline \cite{Bhuiyan-17} & Decision-Making in CPSs & $>$85\% & Model-based In-network & Experimental & C\\ \hline Proposed & Intrusion Detection System & $>$87\%& Deep Transfer Learning & Empirical (7 Devices) 9 Categories & C\\ \hline \end{tabular} \end{table*} \section{Proposed Methodology} \label{sec: proposed methodology} This section presents our proposed dependable IDS model of a deep transfer learning-based residual neural network (P-ResNet). We first introduce the problem statement. Next, we thoroughly explain the structure of the proposed model and how we adapted the model for the DTL process. \subsection{Problem Statement} Six key motivations studied inspired this research paper. First, most proposed IDSs focus on detecting a limited number of cyber-attacks \cite{Eirini-1}. In this case, our proposed model's target is to identify and classify a wide range of cyber-attacks efficiently (e.g., DoS, data injection, MITM, backdoor, PCA, scanning, and ransomware). Such attacks are significantly more challenging to detect at low computational complexity. There is limited device profiling in the existing research\cite{Li-32}. Therefore, this paper considers the behavior of seven different IoT devices (e.g., fridge, GPS tracker, motion light, garage door, modbus, thermostat, and weather sensor) to increase the integrity properties of our proposed DTL-based P-ResNet model. Furthermore, most proposed IDSs did not consider automatic attack type classification and dependability \cite{Alsaedi-39}. However, our proposed DTL-based P-ResNet model can automatically detect different attacks and efficiently classify different attack scenarios while ensuring dependability. Most importantly, the existing TML and DL-based IDSs have apparent advantages in detecting various cyber-attacks \cite{Wang-22}. However, these models require a large amount of training data, and the size of training datasets affects the accuracy of the model when the training data is insufficient, as has been confirmed by the subsequent experiment \cite{Anca-8}. As a result, the TML and DL models need sufficient training data, and it is challenging to train an efficient IDS model only depending on a small-scale of target domain data. Moreover, IoT-based applications typically consist of lightweight communication protocols with limited computational power and storage capacity \cite{Emiliano-10}. However, traditional security mechanisms require high computational capabilities \cite{Anca-8}. As a result, these conventional security mechanisms cannot be directly deployed for IoT-based applications due to their heterogeneous nature and characteristics (e.g., less scalability, inefficiency) \cite{Da-9, Emiliano-10}. Furthermore, as IoT applications operate inside the network, traditional security mechanisms seem to be insufficient because of their features, which only identify external attacks \cite{Tianlong-11}. Because of the overwhelming rise of IoT threats and vulnerabilities, traditional security mechanisms have already shown their inadequate strength to fight against targeted attacks, and associated anomalies \cite{Jayavardhana-13}. As a result, the potential threats to the heterogeneous IoT ecosystem are constantly emerging and changing, and the exact nature of these threats is unknown. To address the last two dependencies of the TML and DL models, we propose a dependable deep transfer learning-based residual neural network (P-ResNet) IDS that can train efficiently using only a small scale of target domain data and understand its impact with low computational capabilities. The proposed P-ResNet model significantly enhances the performance of neural networks with more layers. Generally, our proposed model tries to tackle those dependencies by directly bypassing the input data to the output layer, allowing the output layer to access the raw data. Therefore, we transfer the knowledge in source domain data to the target domain through the proposed P-ResNet model and combine the target domain data with the same model to construct an efficient and dependable IDS for the target domain to improve the detection accuracy for any heterogeneous IoT ecosystem. Finally, most of the previously proposed IDSs didn't consider dependability performance analysis \cite{Bhuiyan-4}. In this case, we have analyzed the dependability performance to ensure the availability, efficiency, and scalability features of our proposed deep transfer learning-based P-ResNet IDS model. \subsection{ResNet with Deep Transfer Learning} Deep neural network (DNN) depth is an essential aspect of model performance\cite{Li-32, Lu-33}. More complex features may be extracted by a DNN algorithm with more layers \cite{Xu-38}. As a result, deeper DNNs may theoretically result in better performance. If the number of DNN layers increases, the degradation problem causes the DNN algorithms' to become more saturated \cite{Alsaedi-39}. The deep residual network (ResNet) tries to tackle this problem by directly bypassing the input data to the output layer, allowing the output layer to access the raw data. Our proposed P-ResNet model consists of multiple residual blocks, each of which may be defined as- $U(x) = V(x) + x$, where x denotes the input data, V(x) denotes the identity residuals mapping function, and U(x) denotes the mapped solution function. Deep transfer learning is a supervised machine learning technique that uses a small-scale dataset to apply a pre-trained model \cite{Xu-38}. The definition of deep transfer learning has been given in terms of source and target domains. A labeled domain IoT dataset $D$ consists of data instances $X$ and a label $Y$. A task $T$ is defined as the connection of label $Y$ with a prediction function $f$ to be learned from the labeled domain data. The source domain and target domain datasets are denoted by $D_s = (X_s, Y_s)$ and $D_t = (X_t, Y_t)$, while the source tasks and target tasks are denoted by $T_s = (Y_s, f_s)$ and $T_t = (Y_t, f_t),$ respectively. We assume that $T_t$ and $D_t$, which represent the ubiquitous computing issue to be solved and the corresponding labeled dataset, are accessible. \textbf{Source Domain:} The domain where the initial model is located. The source domain data ($D_s : (X_s,Y_s)$) is the combination of $ {(X_{s1},Y_{s1}), (X_{s2},Y_{s2}),...,(X_{sn}, Y_{sm})}$, in which the class of the source domain ($Y_s$) is {0, and 1}, where the normal and attack scenarios are represented by 1 and 0, respectively. \textbf{Target Domain:} The domain has a new type of attack. The target domain data ($D_t : (X_t,Y_t)$) is the combination of $ {(X_{t1},Y_{t1}), (X_{t2},Y_{t2}),...,(X_{tn},Y_{tm})}$, in which the class of target domain ($Y_t$) is {0 and 1}, where the normal scenario is represented by 1 and the attack scenario is represented by 0. The number of source and target domain data is represented by n and m, respectively. Furthermore, the source domain label ($ Y_s $) and the target domain label ($ Y_t $) contain only ``normal” and ``attack” data, but attackers in the source domain and target domain may be different. Although the source domain label ($ Y_s $) and the target domain label ($ Y_t $) have the same feature space, their performance in specific features is different. To measure the difference between the source domain and the target domain, we have used the following formula~\eqref{eq1}, which is called Maximum Mean Discrepancy (MMD) \cite{Nisioti-67}. \setlength{\abovedisplayskip}{0pt} \setlength{\belowdisplayskip}{6pt} \begin{align} \label{eq1} Dist (X_s, X_t) = \Bigg\| \frac{1}{n} \sum_{i=0}^{n} \phi (X_{s_i}) - \frac{1}{m} \sum_{i=0}^{m} \phi (X_{t_i}) \Bigg\|^2 \end{align} We propose a deep transfer learning method that transfers DNN weights learned on different attack classification problems on $D_s$ to another DNN trained to solve $T_t$ on $D_t$. Our proposed method in Figure \ref{The structure of the proposed P-ResNet model} belongs to the category of inductive transfers since the source tasks and target tasks are distinct $(T_s \neq T_t)$. The steps are as follows: \begin{itemize} \item \textbf{Definition of source domain $\mathbf{D_s}$ and source task $\mathbf{T_s}$:} $X_s$ is firstly built by considering $M_c$ multiple channel IoT datasets (e.g. $modbus, motion\_light, weather$ sensor etc.). Each $M_c$ sequence in the $n^{th}$ dataset $(1 \leq n \leq M_c)$ is decomposed into single channels, each of which is divided into different segments $S$ of length $L$ using a \textit{sliding\_window\_approach}. All the segments are combined to form the source dataset $X_s$, which is defined by the following formula~\eqref{eq2}: \begin{align} \label{eq2} X_s = \bigcup_{n=1}^{M_c}\left \{ x_{i}^{(n)} \epsilon \mathbb{R^{L}} | \left ( 1 \leq i \leq S_{n}\right ) \right \} \end{align} Here, $x_{i}^{(n)}$ refers to the $i^{th}$ segment of the $n^{th}$ source dataset $X_s$, and $S_n$ refers to the total number of segments obtained from the $n^{th}$ source dataset $X_s$. That is to say, $X_s$ is the union of all segments $S$ extracted from the multiple channel $M_c$ source datasets $X_s$. The source task $T_s$ is defined as the classification of different attacks on the source domain $D_s$. Source labels $Y_s$ are defined by the following formula~\eqref{eq3}: \begin{align} \label{eq3} Y_s = \bigcup_{j=1}^{M_c}\left \{ y_{i}^{(n)} \epsilon \left \{ 1, 2,., C_s \right \} | \left ( 1 \leq i \leq S_{n}\right ) \right \} \end{align} Here, $C_s$ is the number of classes of the source domain (e.g., normal and attack), and $y_{i}^{(n)}$ indicates the label of $x_{i}^{(n)} \epsilon X_s$. Furthermore, $f_s$ is the source prediction function which attributes each $x_{i}^{(n)}$ to its corresponding label $y_{i}^{(n)}$, whether normal or attack. \vspace{2.5pt} \item \textbf{Learning of source prediction function $\mathbf{f_s}$:} A single-channel DNN is used to learn the source prediction function $f_s$. For the single-channel DNN architecture, a batch normalization layer used to perform a regularization on the segments in the source dataset $X_s$ to address the issue of the heterogeneity of the source data. Assuming the single-channel DNN contains $H \epsilon N^{*}$ hidden layers, we denote the weight matrix and bias vector of the $j^{th}$ layer $(1 \leq j \leq H)$ as $W_j$ and $B_j$, respectively. Finally, a softmax layer with $C$ neurons is added, with each neuron of the layer outputting a value that estimates of probability to its corresponding class. This way, the single-channel DNN can classify the segments of source dataset $X_s$ using the source labels $Y_s$. \vspace{2.5pt} \item \textbf{Initialization of a multi-channel DNN}: A multi-channel DNN is defined to learn the target prediction function $f_t$. It is trained using target dataset $X_t$ which contains multi-channel segments $X \epsilon \mathbb{R^{L\times S_n}}$, with $S_n$ being the number of channels of the target dataset $X_t$ and target label $Y_t$ which contains associated labels $Y \epsilon \{1, 2,..., C_t\}$ with $C_t$ being the number of classes of the target problem. For the multi-channel DNN architecture, a batch normalization layer is applied to the segments to perform an operation akin to a standard normalization on the input of the network. The $S_n$ sensor channels are then separated. The $k^{th}$ sensor channel $(1 \leq k \leq S_n)$ is processed by an ensemble of hidden layers of the same number and type as the hidden layers of the single DNN. We refer to this ensemble of layers as a branch of the multi-channel DNN. The output of each branch is then concatenated and connected to fully-connected layers. A softmax layer with the target class $C_t$ neurons is added to output class probabilities for the $C_t$ target classes. \item \textbf{Transfer of weights from single to multi-channel DNN}: The weights $W_j$ and biases $B_j$ of the $H$ hidden layers of the single DNN learned on $\{D_s, T_s\}$ are transferred to the branches of the multi-channel DNN. In other words, the $j^{th}$ layer of the $k^{th}$ branch (for $1 \leq j \leq H$ and $1 \leq k \leq S_n)$ has its weight and bias matrices $W_k^{(s)}$ and $b_k^{(s)}$ initialized as $W_k$ and $b_k$, respectively. \vspace{4pt} \item \textbf{Learning of target prediction function $\mathbf{f_t}$}: The multi-channel DNN is fined-tuned using $(X_t, Y_t)$ to learn $f_t$, which is the predictive function for the target ubiquitous computing problem. \end{itemize} \subsection{Proposed Architecture} Figure \ref{The block diagram of the proposed P-ResNet based IDS model} shows the block diagram of the proposed model for IDS, which predominantly includes two parts: the first is the model training part, and the second is the intrusion detection part. For the training part, after prepossessing the network data, we applied it to our proposed model. \begin{figure}[htp] \centering \includegraphics[width=3.12in]{BlockDiagram.pdf} \caption{The block diagram of the proposed P-ResNet model} \label{The block diagram of the proposed P-ResNet based IDS model} \end{figure} The most significant parameters of this model have been determined through subsequent empirical experiments. The model with the optimal prediction performance on the training set has been selected as the final intrusion detection model for heterogeneous IoT applications. For the intrusion detection part, we have trained the P-ResNet model with a randomly selected training dataset and validated the model with a validation dataset. The detection performance of the models under the discrete types of parameters is compared. We have also analyzed the dependability performance of our proposed model. Finally, the optimal dependable model has been selected as the final detection model in the field of heterogeneous IoT applications. Table \ref{The hyperparameters of the proposed model} shows the hyper-parameters of the proposed model. \begin{table}[htp] \renewcommand{\arraystretch}{1.2} \caption{The hyperparameters of the proposed model} \label{The hyperparameters of the proposed model} \centering \begin{tabular}{|l|c|} \hline Hyper-parameters & Value/Function\\ \hline Number of Hidden Layers & 4\\ \hline Units in hidden layers & 64, 128, 256, 128\\ \hline Batch size & 64\\ \hline Epochs & 200\\ \hline Hidden layer activation function & ReLu\\ \hline Output layer activation function & Softmax\\ \hline Dropout & N/A\\ \hline Optimizer & Ada Delta\\ \hline Loss function & Categorical Crossentropy\\ \hline \end{tabular} \end{table} The network architecture of the proposed P-ResNet model is shown in Figure \ref{The structure of the proposed P-ResNet model}. The input of the network is the same shape. There have been four layers in our proposed model without the input layer. The first layer is the combination of 64 filters of kernel length 8, the second layer is the combination of 128 filters of kernel length 8, the third layer is the combination of 256 filters of kernel length 5, and the last layer is the combination of 128 filters of kernel length 3. Each layer is a one-dimensional convolution layer is followed by a \textit{BatchNormalization()} and \textit{Rectified Linear-Unit (ReLU)} activation function, which is called the feature smoothing layer (FSL). FSL has been used to keep the tensors' shape and smooth the pre-trained tensors to learn features from the new training dataset. After the pre-trained residual blocks (transfer pre-trained knowledge), the FSL has been inserted. The feature extraction layer (FEL) used the first three operations to double the number of channels and fatten the feature map into one dimension. The FEL extracted operation-based features and abstracted important information to describe the previous layer, which improves the final fully-connected layer with these abstracted features. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{ResNetModel.pdf} \caption{The structure of the proposed P-ResNet model} \label{The structure of the proposed P-ResNet model} \end{figure} Each block takes the previous block's outputs as inputs for the current block and performs some non-linearity operations to transform it into a multivariate series whose dimensions are defined by the number of filters in each layer. The fifth layer is the combination of a \textit{GlobalAveragePooling1D()} operation, which takes the input of the previous block and averages each series. This operation drastically reduces the number of parameters in a deep model while enabling the use of a class activation map \cite{Da-9} which allows an interpretation of the learned features. The output of the gap layer is then fed to a \textit{softmax} classification layer whose number of neurons is equal to the number of classes in the dataset. To reduce the overfitting problem of the proposed model, we have considered various strategies, including data augmentation to the training set, adding Gaussian noise during training time, decreasing the network size, and the EarlyStopping method. Skip connections enable feature re-usability and stabilize training and convergence. Finally, we have deployed a skip connections technique of our proposed model by using a vector addition method. Then the gradient would be multiplied by one and its value, which was maintained in the earlier layers. This enabled us to identify the effect of deep transfer learning. \section{Model Implementation and Evaluation} \label{sec: model implementation and evaluation} We have performed all the analyses on a computer with an Intel (R) Core (TM) i7-6800K CPU (3.40GHz) and a GeForce GTX 1080Ti. This section has performed a series of operations on the original combined dataset without changing its properties. Also, we have thoroughly explained the training process and provided an overview of selected models. \subsection{Dataset Description} The dataset has been generated from various heterogeneous sources, including seven IoT sensors, (e.g., \textit{fridge\_sensor}, \textit{GPS\_tracker\_sensor}, \textit{motion\_light\_sensor}, \textit{garage\_door\_sensor}, \textit{modbus\_sensor}, \textit{thermostat\_sensor}, and \textit{weather\_sensors}). The \textit{fridge\_sensor} measures the fridge\_temperature and temperature\_condition, whether it is high or low, based on a preset threshold value. The \textit{GPS\_tracker\_sensor} determines the geographic position, such as latitude and longitude of an object. The \textit{motion\_light\_sensor} includes two characteristics, i. e., motion\_status and light\_status. The light\_status is changed based on the pseudo-random signal generated by the motion\_status. The \textit{garage\_door\_sensor} observed two-states, door\_state and sphone\_signal. The first is observed when the door is open or closed and the second is where the signal is true or false when receiving the door signal on a phone. The \textit{modbus\_sensor} simulates the functionality of the Modbus devices for communication with each other with the help of some register (e.g., input\_register, discrete\_register, holding\_register, and a coil\_over\_register). The \textit{thermostat\_sensor} governs the temperature of a physical system by regulating a heating or cooling system, where current\_temperature and thermostat\_status are the fundamental features. The \textit{weather\_sensors} produce air\_temperature, air\_pressure, and air\_humidity data. \begin{figure}[htp] \centering \includegraphics[width=3.1in]{DataOverview_U1.pdf} \caption{ (a) Statistics of the abnormal dataset with attacks; (b) Class distribution of the combined dataset} \label{Statistics of the combined dataset} \end{figure} Each IoT dataset has been combined into one CSV file by a Python script. The combined dataset has 22 features, including the label feature. The label feature contains two quantitative values, i.e., 0 and 1, which indicate normal and attack scenarios, respectively. Nine types of cyber-attacks (\textit{denial of service (DoS)}, \textit{distributed denial of service (DDoS)}, \textit{data injection}, \textit{man-in-the-middle (MITM)}, \textit{backdoor}, \textit{password cracking attack (PCA)}, \textit{scanning}, \textit{cross-site scripting (XSS)}, and \textit{ransomware}) have been considered against the IoT sensors mentioned above. Figure \ref{Statistics of the combined dataset}(a) shows the statistics of the abnormal dataset with attacks and figure \ref{Statistics of the combined dataset}(b) shows the class distribution of the combined dataset. \subsection{Data Preparation} To achieve optimal performance and improve the learning process, it is necessary to clean and prepare the dataset before applying DTL methods. Data preparation is generally done by removing unnecessary features, checking the variation of independent features, converting non-numerical features, removing outliers, and replacing missing values if they exist. The two fundamental steps apply during the data preparation process. The first is data pre-processing, and the second is data transformation step. \subsubsection{Data Pre-processing} This dataset originates from multiple heterogeneous sources. Due to its vast size, this dataset is highly susceptible to missing and noisy data. This section discusses the essential steps in data pre-processing: data-cleaning and data-integration. \begin{itemize} \item \textbf{Data Cleaning:} First, we have applied various techniques to remove noise and clean inconsistencies in the dataset. For example, \textit{Rosner's Test} for outliers checking, and the \textit{predictive mean matching} method for imputing missing values. Then, to apply DTL models, we have converted the qualitative values into quantitative values. To cite an example, the \textit{door\_state} feature in the dataset, which has qualitative values of ‘open’ and ‘closed’, has been converted into ‘1’ and ‘0’. The conversion to quantitative values was performed using a numerical convolution label-encoding library \textit{numconv} \cite{Geron-56}. Some features, such as - date, time, and timestamp, have been omitted from feature vectors as they may cause them to overfit the training data. Furthermore, the input data shape has been reshaped into three dimensions to feed the models by applying \textit{numpy.reshape} mechanism with \textit{swapaxes} and \textit{concatenate} methods. \item \textbf{Data Integration:} To improve the accuracy and speed of the training and validation processes, the data integration technique helped us reduce and avoid redundancies in the resulting dataset. This dataset originates from multiple heterogeneous sources. So, it is essential to combine all the IoT sensors' data by \textit{redundancy} and \textit{correlation} analysis. This analysis has measured how strongly one feature, i.e., \textit{door\_state} implies the other, i.e., \textit{light\_status}. Figure \ref{Correlation visualization} shows the correlation between different features. For our analysis, we have evaluated the correlation between all the features using the following \textit{Pearson’s product-moment coefficient} equation. \begin{align} C_{orrelation} = \frac{ \sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{ \sqrt{\sum_{i=1}^{n}(x_i-\bar{x})^2}\sqrt{\sum_{i=1}^{n}(y_i-\bar{y})^2}} \end{align} Where \emph{n} is the number of tuples, \emph{x\textsubscript{i}} and \emph{y\textsubscript{i}} are the respective values in tuple \emph{i}, and $\bar{x}$ and $\bar{y}$ are the respective mean values of \emph{x} and \emph{y}. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{Correlation.pdf} \caption{Correlation visualization} \label{Correlation visualization} \end{figure} \end{itemize} \subsubsection{Data Transformation} We applied this processing step to achieve more efficient resulting processes and easily understand the patterns. Some selected features have larger values than others, which leads to incorrect performance, though some models might prefer the large feature values. We have performed these strategies to scale the selected feature values within a range between [0.0, 1.0] without changing the characteristics of the data \cite{Aminanto-58}. As shown in the following equation~\eqref{eq4}, a technique called \textit{minimum-maximum normalization} has been used to scale the selected feature values within the range. \begin{align} \label{eq4} N_{ormalized}V_{alue} = \frac{(X-X_{min})} {(X_{max}- X_{min})} \end{align} Where, X is an original value and X\textsubscript{max} and X\textsubscript{min} are the maximum and minimum values of the feature, respectively. \subsection{Training Process} As discussed in the previous section, all the datasets have been converted into a combined dataset by a Python script containing the training and validation data. First of all, we have divided the combined dataset into the training data set (80\%) and the test data set (20\%) by using the \textit{train\_test\_split} method of the \textit{scikit\_learn} library. The training data set has been used to train the selected models. On the other hand, the test data set has been used to further assess the trained classifier of those models. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{EvaluationProcess_U.pdf} \caption{Overall evaluation process of the selected models} \label{Figure: Evaluation process of our idea} \end{figure} Furthermore, we again split the training data (80\% of the total data) into the new training data (80\%) for training the selected model and validation data (20\%) for hyperparameters’ optimization. Proportions of 80\% for the training dataset and 20\% for the validation dataset have been chosen as suggested in \cite{Geron-56}. To avoid the overfitting problem, this splitting ratio has been considered the best ratio between the training and the validation dataset \cite{Guyon-60}. We want to highlight some DTL models that give better performance than others \cite{Da-9}. We have selected Fully Convolutional Networks (FCN), LeCun Network (LeNet), Inception Network (IncepNet), Multi Channel Deep Convolutional Neural Network (MCDCNN), Convolutional Neural Network (CNN), Long Short-Term Memory (LSTM), Multilayer Perceptron (MLP), and our proposed Residual Neural Network (P-ResNet). We have also considered DL algorithms because some of their variants have been successfully applied to solve classification tasks related to intrusion detection \cite{Nisioti-67, Omar-72}. Therefore, we have considered Long Short-Term Memory (LSTM), Neural Network (NN), Convolutional Neural Network (CNN), and Recurrent Neural Network (RNN) algorithms because of their optimal performance. The overall performance of the selected models has been evaluated with a wide range of tested hyperparameters. Figure \ref{Figure: Evaluation process of our idea} summarizes the steps involved in evaluating the performances of the selected models. \section{Result Analysis} \label{sec: result analysis} This section discusses the overall performance of the selected models. We incorporated a wide range of analysis scenarios with varying measurement indicators, including accuracy, precision, recall, ROC AUC, and f1-score. We also concentrated on the optimization of the hyper-parameters for improved performance. \subsection{DL Metrics Analysis} In recent years, DL algorithms have advanced significantly, and some of the variants of DL algorithms have been successfully applied to solve classification tasks related to intrusion detection \cite{Nisioti-67}. Therefore, we considered DL algorithms in this section because of their optimal performance. In this experiment, we considered LSTM, NN, CNN, and RNN. The LSTM and NN models show the highest accuracy score of 0.82. Dramatically, the other performance metrics of these two models are almost similar. Figure \ref{DL algorithms' performance visualization} shows the performance comparison between selected DL models and the proposed DTL-based P-ResNet model. For the LSTM model, we used three hidden-layers, where the units of hidden layers were 128, 100, and 64, respectively. The \textit{tanh} is the hidden layer activation function, and \textit{Adam} is used as an optimizer. Also, \textit{sigmoid} is used as a network output activation function, and ``categorical\texttt{\_}crossentropy" is used as a loss function. The RNN and CNN models outperform most TML algorithms, with an accuracy score of 0.80 and 0.79, respectively. Furthermore, both the NN and CNN models used the same optimizer and activation function but different types of the hidden layer activation function. Particularly for the RNN model, the \textit{softmax} is used as the network output activation function, and ``categorical\texttt{\_}crossentropy" is used as the loss function. On the other hand, for the CNN model, the number of hidden layers is four and ``binary\texttt{\_}crossentropy" is used as the loss function. Finally, considering all the significant parameters of the DL models, the NN and LSTM models have shown the optimal performance, which indicates that most of the predicted labels are correctly classified. However, when we applied our proposed P-ResNet model to the same dataset, the model performed significantly better in most cases. In such cases, accuracy, precision, f1-score, and ROC AUC are better than in other experimental scenarios. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{DLResult.pdf} \caption{Performance comparison of DL algorithms' with the proposed DTL-based P-ResNet model} \label{DL algorithms' performance visualization} \end{figure} \subsection{DTL Metrics Analysis} In recent years, the progression of deep transfer learning and its great success in different fields mean it has emerged as a potential solution for dependable network intrusion detection \cite{Nisioti-67}. Besides considering the fundamental evaluation criteria, we also incorporated other deep learning evaluation criteria, for example, the numbers of hidden layers, units in the hidden layers, output layer activation functions, loss functions, etc. These criteria helped to calculate and report the classification results effectively. First, we consider the quantitative performance of DTL models. Table \ref{Table: DTL algorithms' performance comparison metrics} shows the quantitative performance summary of the DTL models. \begin{table}[htp] \renewcommand{\arraystretch}{1.3} \caption{DTL algorithms' performance comparison metrics} \label{Table: DTL algorithms' performance comparison metrics} \centering \begin{tabular}{cccccc} \hline Algorithm & Accuracy & Precision & Recall & F1Score & ROC AUC\\ \hline FCN & 0.84 & 0.85 & 0.84 & 0.83 & 0.81\\ \hline LeNet & 0.80 & 0.82 & 0.80 & 0.79 &0.76\\ \hline IncepNet & 0.80 & 0.86 & 0.80 & 0.81 & 0.73\\ \hline MCDCNN & 0.80 & 0.83 & 0.80 & 0.79 & 0.76\\ \hline CNN & 0.81 & 0.83 & 0.81 & 0.80 & 0.76\\ \hline LSTM & 0.85 & 0.84 & 0.77 & 0.77 & 0.83\\ \hline MLP & 0.73 & 0.74 & 0.78 & 0.77 & 0.74\\ \hline P-ResNet & 0.87 & 0.88 & 0.86 & 0.86 & 0.83\\ \hline \end{tabular} \end{table} The proposed P-ResNet model shows optimal performance compared to the others, with an accuracy score of 0.87, precision score of 0.88, recall score of 0.86, f1-score of 0.86, and ROC AUC score of 0.83. We used four hidden-layers in this model, where \textit{ReLu} is the hidden layer activation function. Also, \textit{softmax} is used as a network output activation function, and ``categorical\texttt{\_}crossentropy" is used as a loss function along with the \textit{Adam} optimizer. Figure \ref{DTL algorithms' training and validation accuracy} shows the accuracy score of every single epoch for both the training and validation phases of the selected models. Considering epoch numbers 170 to 200 for both phases, the flattening characteristics of the curve and accuracy are not increasing literally. Therefore, we have considered 200 epochs for our analysis. The proposed model shows the highest accuracy score in both the training and validation phases, whereas, the MLP model shows the lowest accuracy score during any setting of the epoch number within 1 to 200 in both the training and validation phases. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{DTLAllAccuracy.pdf} \caption{DTL algorithms' training and validation accuracy} \label{DTL algorithms' training and validation accuracy} \end{figure} In detail, according to Figure \ref{DTL algorithms' training and validation accuracy}, the accuracy of the MLP model starts around 0.67 for the training phase and 0.63 for the validation phase in epoch number 10. However, it increased dramatically to around 0.78 in epoch number 65 and 0.74 in epoch number 140 for the training and validation phases, respectively. However, for the training phase, the accuracy score (0.78) remains stable in epoch number 66 to 200. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{ResNetAccuracy.pdf} \caption{Training and validation accuracy of proposed model} \label{Training and validation accuracy of proposed P-ResNet model} \end{figure} On the other hand, for the validation phase, the accuracy score (0.74) remains stable between epoch numbers 141 and 200. As shown in Figure \ref{DTL algorithms' training and validation accuracy}, the training and validation accuracy of CNN, IncepNet, LeNet, and MCDCNN models remains steady between epochs 1 and 200. The accuracy of LSTM and FCN models starts with a score of 0.82. However, this score rises gradually with the increase of the epoch number and reaches approximately 0.86 when the epoch number is 160 and then remains stable between epoch numbers 161 and 200 for both phases. The remarkable point is that the behavior of the training phase is almost identical to the validation phase. To better understand our proposed model Figure \ref{Training and validation accuracy of proposed P-ResNet model} shows the trend of the accuracy score of both phases. The proposed model's accuracy increases rapidly at epoch number 60, reaching a peak of close to 0.87 at epoch number 169. However, as shown in Figure \ref{Training and validation accuracy of proposed P-ResNet model}, it remains almost stable up to the early stopping checkpoint. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{DTLAllLoss.pdf} \caption{DTL algorithms' training and validation loss} \label{DTL algorithms' training and validation loss} \end{figure} Next, we analyzed the losses of each model. The training and validation losses of every epoch are shown in Figure \ref{DTL algorithms' training and validation loss}. The MLP model shows the highest losses in the training and validation phases. The highest loss of this model indicates that the model cannot provide a reliable classification between normal and attack scenarios. On the other hand, our proposed model shows the lowest loss for any epoch setting within 1 to 200. In detail, the loss of the proposed model starts around 0.41 for the training phase and 0.42 for the validation phase, as shown in Figure \ref{Training and validation loss of proposed P-ResNet model}. However, it decreases to 0.27 for the epoch number 140 and 0.28 when the number is 145 for the training and validation phases, respectively. The loss score (0.27) remains stable between epoch number 141 and the early stopping checkpoint, which has been indicated by the \textit{red circle} in Figure \ref{Training and validation loss of proposed P-ResNet model}. The losses of the CNN, IncepNet, LeNet, and MCDCNN models remain almost steady during both the training and validation phases, between epochs 1 and 200, which is shown in Figure \ref{DTL algorithms' training and validation loss}. The loss of the LSTM and FCN models is almost 0.42 at the beginning, which declines gradually to approximately 0.31 at epoch number 140 and remains stable for both phases. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{ResNetLoss.pdf} \caption{Training and validation loss of proposed model} \label{Training and validation loss of proposed P-ResNet model} \end{figure} During a concept drift scenario, the learning model drifts, which can be understood as changes in the relationship between the input and target output. In an IDS setup, their are significant challenges arising from the `concept drift', especially in the context of streaming IoT data, where the dataset may not always be static but rather an evolving and moving target for detection. Authors in~\cite{Andresini-68} highlight a set of open challenges faced by the modern ML-based IDS technologies and emphasize adopting concept drift within the solution framework. Gama et al.~\cite{Gama-70} highlight that transfer learning between the different contexts can be a promising solution to deal with the `concept drift' challenges. McKay et al.~\cite{McKay-71} recently implemented an online transfer learning-based solution for concept drifting data streams. Hence, with confidence, we can argue that the proposed transfer learning-based solution has the potential to deal with concept drifting contexts, which we have scoped for future work. \subsection{Performance Analysis on Training and Testing Time} The training time, testing time, and number of parameters were also calculated for each DL and DTL model. Table~\ref{Table: DTL algorithms' testing and training time} compares the total parameters, training time, and testing time for each model. In terms of the DL models, NN requires 2.660 seconds for a total of 50,985 trainable parameters, which is less testing time and a lower number of parameters than other DL models. Moreover, the NN model can be explained as other DL models were lazy learners who used the training phase to store the data and then used the data during the test phase to make a prediction, which makes the testing phase slower, though the number of parameters (trainable) was slightly increasing. \begin{table}[htp] \renewcommand{\arraystretch}{1.3} \caption{Comparison of total parameters, training time, testing time of DL and DTL algorithms} \label{Table: DTL algorithms' testing and training time} \centering \begin{tabular}{ccccc} \hline & Algorithm & Params & Training Time (s) & Testing Time (s)\\ \hline {\multirow{4}{*}{\rotatebox{90}{\textbf{Deep Learn.}}}} & NN & 50,985 & 3242.180 & 2.660 \\ \cline{2-5} & RNN & 59,205 & 3258.245 & 3.105 \\ \cline{2-5} & CNN & 56,086 & 2763.788 & 2.667\\ \cline{2-5} & LSTM & 66,689 & 25921.078 & 5.940\\ \hline {\multirow{8}{*}{\rotatebox{90}{\textbf{Deep Transfer Learning}}}} & FCN & 265,986 & 46756.338 & 7.722 \\ \cline{2-5} & LeNet & 260,052 & 38936.911 & 5.690 \\ \cline{2-5} & IncepNet & 233,074 & 36657.213 & 4.229\\ \cline{2-5} & MCDCNN & 522,998 & 34198.530 & 3.075\\ \cline{2-5} & CNN & 202,686 & 33869.838 & 2.718\\ \cline{2-5} & LSTM & 385,538 & 44859.869 & 5.712\\ \cline{2-5} & MLP & 513,002 & 27065.069 & 3.192 \\ \cline{2-5} & P-ResNet & 506,818 & 24401.586 & 3.014 \\ \hline \end{tabular} \end{table} On the other hand, in terms of the training and testing time, the FCN model requires the longest training and testing time of 46756.338 seconds and 7.722 seconds, respectively, for a total of 265,986 trainable parameters. Surprisingly, the CNN model has the lowest testing time of 2.718 seconds and training time of 33869.838 seconds, the third-lowest among all the DTL models. Furthermore, the LSTM model has a testing time of 5.721 seconds and training time of 44859.869 seconds, the third-longest testing time after the LeNet model, which has a training time of 38936.911 seconds and testing time of 5.690 seconds. One would be concerned that the LSTM and LeNet models have more parameters than the CNN. Both the MLP and MCDCNN models have almost the same testing time and number of parameters. Our proposed P-ResNet model requires a testing time of 3.014 seconds and training time of 24401.586 seconds, for a total of 511,002 trainable parameters, which is less than most of the selected DTL models. This can be explained as our proposed model is a fast learner that uses the training phase to train efficiently, and then uses the data during the test phase to make a prediction, which makes the testing phase faster. Considering all the performance indicators, we think our proposed model can be used for practical applications to protect Industry 4.0 manufacturing and other critical heterogeneous IoT-based infrastructures where dependable IDS system and secure data processing are the main challenges. \subsection{Dependability Performance Analysis} In this section, we explored the dependability performance analysis of our proposed model. Dependability performance analysis includes availability, efficiency, and scalability features~\cite{Bhuiyan-4}. We consider various strategies to select features and then perform our proposed model to accurately classify normal and attack scenarios without any type of failure or undergoing a repair action, which maintains the availability of our proposed model. Moreover, extensive analysis and performance evaluation (e.g., accuracy, precision, ROC AUC, etc.) show that the proposed model is more efficient and demonstrates better performance than several other existing approaches with low computational loss. Figure~\ref{Dependability performance analysis (efficiency) of our proposed P-ResNet model} shows the efficiency and computational loss of the proposed model. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{Dependability.png} \caption{Dependability performance analysis (efficiency) of our proposed P-ResNet model} \label{Dependability performance analysis (efficiency) of our proposed P-ResNet model} \end{figure} Finally, we observed an increase in the scalability properties of our proposed model by including various heterogeneous trusted data sources in the training dataset with maximum consistency that were acquired from a wider range of IoT sensors. As a result, our proposed model's accuracy remained almost the same when we increased the epoch number from 125 to 200, indicating its scalability. Figure~\ref{Dependability performance analysis (scalability) of our proposed P-ResNet model} shows the scalability performance of the proposed model. \begin{figure}[htp] \centering \includegraphics[width=\columnwidth]{Dependability_1.pdf} \caption{Dependability performance analysis (scalability) of our proposed P-ResNet model} \label{Dependability performance analysis (scalability) of our proposed P-ResNet model} \end{figure} \section{Conclusion and Future Work} \label{sec: conclusion and future work} In this paper, we proposed a deep transfer learning-based dependable intrusion detection model along with improved performance in comparison to several other existing approaches. The overall accuracy of the proposed detection model is 87\%, ensuring dependability and low time complexity. Moreover, the model also greatly improves the precision score of 88\%, the recall score of 86\%, and the f1-score of 86\%, which are higher than the benchmark models. This demonstrates that the proposed P-ResNet model can effectively classify attack instances within various heterogeneous IoT networks, ensuring its dependability. Moreover, the proposed model has proven its potential to efficiently exhibit anomalous data identification to protect Industry 4.0 manufacturing and other critical infrastructures where dependable IoT-enabled automation and secure data processing are the main challenges. More precisely, our proposed mechanism provides a guideline for future research of dependable intrusion detection for IoT networks. In the future, we will concentrate on many IoT sensors and optimize the hyper-parameters of the proposed deep transfer learning for improved performance. We will also try to implement this proposed deep learning model based on privacy-preserving decentralized devices or servers. \ifCLASSOPTIONcaptionsoff \newpage \fi
{'timestamp': '2022-04-12T02:30:27', 'yymm': '2204', 'arxiv_id': '2204.04837', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04837'}
arxiv
\section{Introduction} CSIRTs operate passive DNS \cite{draft-dulaunoy-dnsop-passive-dns-cof-07} and passive SSL \cite{dulaunoy_alexandre_passive_2015} databases to support incident response. These historical data foster infrastructure attribution and threat intelligence at large. In this field note, we describe a passive SSH~\cite{pssh} the we developed and discuss how it constitutes a worthy addition to the CSIRTS' toolbox. SSH, and especially OpenSSH implementation, is the main tool for remote management as it offers secure channels for accessing servers' shell, moving data, and tunneling other protocols. As OpenSSH is present on a lot of servers, MacOS and recent Windows computer, as well as IoT devices it makes it very appealing for attackers as vector of attack and means of command and control (see FriztFrog\cite{fritzfrog} for instance). \section{Fingerprinting SSH protocol} The SSH protocol\cite{rfc4253} provides a significant number of fingerprints to track similar infrastructures as it uses public-key cryptography to authenticate clients and server. In the frame of infrastructure fingerprinting, the host-key, that is the key used to authenticate a server to clients is a first data point one can collect. The common use-case is that servers provide a host-key to the clients that is persistent between client connections. This ceremony follows a Trust On First Sight model: the server presents the host-key to the client that, on the first connection, is prompted to decided whether to trust the key or not. Once trusted, host-keys are stored in a cache on the client side against which presented host-keys will be checked on subsequent connections. Server host-keys are therefore persistent, they are usually generated when setting up ssh and left untouched afterwards. Whereas SSH1 only provides algorithm negotiation between the client and the server for bulk encryption, SSH2 introduces the negotiation for the host-key, message authentication, hash function, session key exchange and data compression. These are others data point usable for fingerprinting SSH endpoints. Salesforce also created HASSH, a network fingerprinting standard which can be used to identify specific Client and Server SSH implementations (see \cite{hasshblog} and \cite{hasshcode}). Fingerprinting SSH servers requires to initiate a TCP three-way handshake with the server and read the first SSH protocol message (see Figure~ \ref{sshhandshake}\footnote{This image is a modified version of one found at https://github.com/salesforce/hassh and will be replaced with original content for the final version}). \begin{center} \includegraphics[width=0.8\textwidth]{sshhandshake.png} \captionof{figure}{Fingerprinting SSH first packets} \label{sshhandshake} \end{center} \section{Passive SSH Design and Implementation} We developed a tool to fingerprint SSH servers on the Internet\footnote{Available here \url{https://github.com/D4-project/passive-ssh/blob/main/bin/ssh_scan.py}}. The tool is developed in python and uses paramiko\footnote{\url{https://www.paramiko.org/}} which is an implementation of SSH2 in python to interact with SSH servers. The data points collected for fingerprinting each servers are the following: \begin{itemize} \item the remote server's banner that consists of: \begin{itemize} \item server version / idstring, \item supported key exchange algorithms, \item supported encryption algorithms, \item supported mac algorithms, \item supported compression algorithms, \item server language. \end{itemize} \item the remote server keys MD5 fingerprint, base64 representation, and name; \item the remote server IP; \item eventually we compute the remote server's hassh. \end{itemize} In order to store these SSH servers fingerprints, we developed the tool that is the main focus of this paper: Passive SSH\footnote{Available at\url{https://github.com/D4-project/passive-ssh}}. The tool is written in python 3 (released as open source project), persistence is achieve using a redis-compatible back-end\footnote{Redis is a key/value in-memory back-end that allows for high read/write throughputs, see \url{https://redis.io/}. Redis is used to allow fast-lookup from numerous applications which require low-latency response.}. Passive SSH provides a REST API to push data into the datastore and to retrieve signatures. \section{Statistics} CIRCL operates a passive SSH instance accessible to FIRST, TF-CSIRT, CNW members, and vetted researchers. This instance includes an internet-wide scan of SSH available on IPv4 and TCP port 22. \begin{table}[ht] \caption{IPv4 addresses with SSH enabled} \begin{tabular}{ll} \hline Banners & 99.474 \\ IPv4 addresses & 10.301.105 \\ Tor Onion addresses & 92 \end{tabular} \end{table} \begin{table}[ht] \caption{SSH key types seen on SSH enabled IPv4 addresses } \begin{tabular}{ll} \hline ssh-ed25519 & 5.271.642 \\ ssh-rsa & 7.291.675 \\ ssh-dss & 1.530.867 \\ ecdsa-sha2-nistp256 & 5.078.182 \\ ecdsa-sha2-nistp521 & 42.679 \\ ecdsa-sha2-nistp384 & 5.843 \\ \end{tabular} \end{table} \section{Use-Cases} SSH banners are still very uniform over a large number of scanned IP hosts. This provides a nifty way to cluster groups of hosts depending of their SSH implementation installed especially the outliers. \subsection{Tracking attackers' infrastructure} A Passive SSH service allows to readily answer valuable questions: \begin{itemize} \item Is this host key new to my environment? \item What server presented this key before? \item Did this server already presented this key? \item When was the last time a specific host key was seen in use? \item How many host key were presented by a single IPv4 address? \end{itemize} To make the most of passive SSH, we are currently working on a module for MISP\cite{wagner2016misp} that will allow to automatically enrich MISP events with these new data points. Discovering attack infrastructure, as described in Attribution of Advanced Persistent Treats\cite{steffens2020advanced}, can be performed by using the fingerprints and hassh in Passive SSH. In addition, key renewal in SSH is less frequent than TLS which then allows to keep pivoting information for a longer period. \subsection{Finding vulnerable equipments} In the same manner as Gasser et al.~\cite{gasser_deeper_2014}, a passive SSH database can be used to identify equipments accessible on the Internet running vulnerable software or using weak cryptographic material. The former is readily accessible by interrogating Passive SSH's banner endpoint for vulnerable banners but the latter requires more efforts as some computations may be required to identify weak cryptographic material and leak keys. For this purpose, we plan on interfacing another project of ours, snake-oil-crypto \footnote{https://github.com/D4-project/snake-oil-crypto} to discover weak key materials. \subsection{Uncloacking tor} Deanonymizing tor hidden services through SSH server fingerprinting is a strategy that has two main limitations: (1) each hidden service is usually kept on separate onion addresses. This separation of concern prevent leaking the ties between services, and (2) if a SSH service is also running to administer the machine from the Internet, its access may be controlled by other layers that prevents it to be directly accessible (e.g. the use of a Bastion host, foreign ports, or port-knocking strategies). We scanned SSH service on port 22 and 2222 on 8194 onion addresses known to be alive in our AIL framework~\cite{mokaddem2018ail} onion list and found 92 SSH service. Crossing onion SSH servers with publicly available SSH service on the Internet, we found 9 of those 92 onions have a corresponding SSH fingerprint in our passive SSH database. \section{Future work} Our passive SSH implementation shows a significant source of network fingerprints to discover vulnerable infrastructure, adversary network infrastructure or weak cryptographic materials. We could improve scanning strategies such as BGP networks announces (IPv6 network addresses) or certificate transparency logs\cite{laurie2014certificate} to come across recently exposed network and IoT devices with ephemeral SSH access. SSH banners include various information which could increase the granularity of the fingerprints. Improving high-speed SSH handshake identification by using the Passive SSH database to train a neural network model. \section{Acknowledgments} We would like to thank the anonymous reviewers for their useful comments and suggestions.\\ \includegraphics[width=0.48\textwidth]{inea.png} \bibliographystyle{plain}
{'timestamp': '2022-04-12T02:34:35', 'yymm': '2204', 'arxiv_id': '2204.04922', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04922'}
arxiv
\subsection{Feature engineering} As explained in Section \ref{subsection: indoor scene representation as a graph}, our indoor scene representation is an attributed graph. We now describe these attributes in detail. \begin{itemize} \item \textbf{Room node features $\boldsymbol {X_R}$}, \begin{enumerate} \item \textbf{\textit{Node Type:}} A 4D 1-hot embedding of the node type. The four categories are wall, door, floor, window. \item \textbf{\textit{Room Type:}} A 4D 1-hot embedding of the room type. The four categories are living room, bedroom, dining room, library. \item \textbf{\textit{Location:}} A 6D vector representing the minimum and maximum vertex positions of the 3D bounding box corresponding to the room node. \item \textbf{\textit{Normal:}} A 3D vector representing the direction of the normal vector corresponding to the room node. \end{enumerate} \item \textbf{Furniture node features $\boldsymbol {X_F}$}, \begin{enumerate} \item \textbf{\textit{Super category:}} A 7D 1-hot embedding of the node type. The seven categories are Cabinet/Shelf, Bed, Chair, Table, Sofa, Pier/Stool, Lighting. \item \textbf{\textit{Shape:}} A 1024D embedding of the 3D shape descriptor obtained by processing a 3D point cloud of the furniture item through PointNet. \item \textbf{\textit{Location:}} A 3D vector representing the centroid of the furniture item. \item \textbf{\textit{Orientation:}} A 3D vector representing the direction the ``front" side of the furniture is facing. \item \textbf{\textit{Size:}} A 3D vector representing the dimensions of the furniture along each axis. \end{enumerate} \item \textbf{Furniture-furniture edge features $\boldsymbol {X_{FF}}$}, let us arbitrarily chose a furniture-furniture edge and label its source node as $s$ with receiver node as $r$. We will describe the features for this edge. \begin{enumerate} \item \textbf{\textit{Center-center distance:}} A scalar representing the distance between the centroids of furniture $s$ and $r$. \item \textbf{\textit{Relative orientation:}} A scalar representing the signed dot product between the orientation feature of $s$ and $r$. \item \textbf{\textit{Center-center orientation:}} A 3D vector representing the unit vector connecting the centroids of $r$ and $s$. \item \textbf{\textit{Orientation:}} A 3D vector representing the direction the ``front" side of the furniture is facing. \item \textbf{\textit{Bbox-bbox distance:}} The shortest distance between the corners of the bounding box of $s$ and $r$. \end{enumerate} \item \textbf{Room-furniture edge features $\boldsymbol {X_{RF}}$}, let us arbitrarily chose a room-furniture edge and label its source node as $s$ with receiver node as $r$. We will describe the features for this edge. \begin{enumerate} \item \textbf{\textit{Center-room distance:}} A scalar representing the distance between the centroid of furniture $r$ and room node $s$. This is computed in 2D as a point to line distance. Every wall/window/door can be treated as a line segment in 2D. \item \textbf{\textit{Center-room center:}} A scalar representing the distance between the centroids of $r$ and $s$. \item \textbf{\textit{Bbox-room dist}} A scalar representing the shortest distance between corners of the bounding box of furniture item $r$ to the room node $s$. This is computed in 2D as a point-to-line distance. \item \textbf{\textit{Bbox-room center}} A scalar representing the shortest distance between corners of the bounding box of furniture item $r$ to the centroid of the room node $s$. \item \textbf{\textit{Relative orientation:}} A signed dot product between the normal of $s$ with the orientation attribute of $r$. \end{enumerate} \item \textbf{Room-room edge features $\boldsymbol {X_{RR}}$}, let us arbitrarily chose a room-room edge and label its source node as $s$ with receiver node as $r$. We will describe the features for this edge. \begin{enumerate} \item \textbf{\textit{Center-center distance:}} A scalar representing the distance between the centroids of room nodes $s$ and $r$. \item \textbf{\textit{Relative orientation:}} A scalar representing the signed dot product between the normal vectors of $s$ and $r$. \item \textbf{\textit{Longest distance:}} A scalar representing the longest distance between the corners of the bounding boxes of $r$ and $s$. \item \textbf{\textit{Shortest distance:}} A scalar representing the shortest distance between the corners of the bounding boxes of $r$ and $s$. \end{enumerate} \end{itemize} \subsection{Architecture Details} \subsubsection{Message-Passing Graph Neural Network (MP-GNN)} \label{subsubsection: Message-Passing Graph Neural Network} Here we describe the message-passing mechanism employed in the Graph Neural Networks used in this work. The design of the MP-GNN is inspired by the work of \cite{mavroudi2020representation}, where each layer $l=1,…,L$ of the MP-GNN maps a graph $G^{l-1}$ to another graph $G^l$ by updating the graph’s node and edge features. Specifically, let $h_i^l$ and $h_{ij}^l$ denote the features of node $i$ and edge $(i,j)$ of graph $G^l$, respectively. Let the input to the network be the graph $G^0=G$, so that $h_i^0$ and $h_{ij}^0$ denote the node features and edge features, respectively. At each iteration of node and edge refinement, the MP-GNN: (1) adapts the scalar edge weights by using an attention mechanism; (2) updates the edge attributes depending on the edge type, the attention-based edge weights, the attributes of the connected nodes and the previous edge attribute; and (3) updates the node attribute by aggregating attributes from incoming edges , as described next. \textit{Computing attention coefficients:} At each step $l$ of refinement, we update the scalar edge weights by computing an attention coefficient $a_{ij}^l$ that measures the relevance of node $j$ for node $i$ as follows: \begin{equation} \begin{aligned} \gamma_{ij}^l = \rho(w_a^{\epsilon_{ij}\top} [W_r^{\nu_i} h_i^l ; W_s^{\nu_j} h_j^l ; W_{rs}^{\epsilon_{ij}} h_{ij}^l] \\ a_{ij}^l=\frac{\exp(\gamma_{ij}^l)}{\sum_{k\in N_{\epsilon}(i)}\exp(\gamma_{ik}^l)}, \qquad \forall (i,j) \in E. \end{aligned} \end{equation} In the first equation, each edge $(i,j)$ of $G_l =(V,E,X_l)$ is associated with a score, $\gamma^l_{ij}$, obtained by applying a nonlinearity $\rho$ (e.g., a leaky ReLU) to the dot product between a vector of attention weights $w_a^{\epsilon_{ij}}$ for edge type $\epsilon_{ij} \in \{RR,RF,FF\}$, and the concatenation of five vectors: (1) the receiver node feature $h_i^l \in \mathbb{R}^{d_i}$ weighted by a matrix $W_r^{\nu_i}$ for node type $\nu_i \in \{R, F\}$, (2) the sender node feature $h_j^l$ weighted by a matrix $W_s^{v_j}$ for node type $v_j$, and (3) the receiver-sender edge feature $h_{ij}^l$ weighted by a matrix $W_{rs}^{\epsilon_{ij}}$ for edge type $\epsilon_{ij}$. All weight matrices are also indexed by the GNN layer $l$ which is suppressed to prevent notational clutter. \textit{Updating the node and edge features:} At each step $l$ of refinement, we update the edge and node features as: \begin{equation} \begin{aligned} h_{ij}^{l} &= a_{ij}^l (U_{edge}^{\epsilon_{ij}}W_{s}^{\nu_j} h_j^{l-1}+W_{rs}^{\epsilon_{ij}} h_{ij}^{l-1}), & \forall (i,j)\in E \\ h_i^l &= \rho(h_i^{l-1}+ \sum_{k\in N_{\epsilon_{ij}}(i)} U_{node}^{\epsilon_{ij}} W_sh_{ik}^{l}), & \forall i \in V. \end{aligned} \end{equation} The first equation updates the features of edge $(i,j)$ by taking a weighted combination of the features of node $j$ and the features of edge $(i,j)$ in the previous layer, with weight matrices $W_s^{\nu_j}$ and $W_{rs}^{\epsilon_{ij}}$, respectively. The matrix $U_{edge}^{\epsilon_{ij}}$ is a learnable projection matrix to change the dimensionality of the first term (transformed node feature) with that of the second term (transformed edge feature). The second equation updates the feature of node $i$ as the sum of the feature of node $i$ from the previous layer (a residual connection) and the sum of the features of all edges connected to node $i$ after applying a non-linearity $\rho$, such as a ReLU or leaky-ReLU. Here, $U_{node}^{\epsilon_{ij}}$ denotes a learnable projection matrix for edge type $\epsilon_{ij}$. All weight matrices are also indexed by the GNN layer $l$ which is suppressed to prevent notational clutter. \subsubsection{Encoder, Decoder and Room Aggregator networks} We employ three MP-GNNs in this work. One for the VAE encoder, one for the decoder and one for the Room Aggregator component of the prior network. Each of these MP-GNNs are three layered graph neural networks. In Table \ref{Table: encoder architecture}, \ref{Table: decoder architecture}, \ref{Table: room_agg architecture} we summarize the architecture of the Encoder, Decoder and Room Aggregator networks respectively. \begin{table} \caption{\textit{Encoder architecture. The network parameters are as defined in Section \ref{subsubsection: Message-Passing Graph Neural Network}}} \centering \includegraphics[width=0.9\linewidth]{imgs/encoder_arch.png} \label{Table: encoder architecture} \end{table} \begin{table} \centering \caption{\textit{Decoder architecture. The network parameters are as defined in Section \ref{subsubsection: Message-Passing Graph Neural Network}}} \includegraphics[width=0.9\linewidth]{imgs/decoder_arch.png} \label{Table: decoder architecture} \end{table} \begin{table} \caption{\textit{Room Aggregator architecture. This network only processes the room subgraph $G_R$ and hence all the weight matrices associated with furniture nodes are absent. The network parameters are as defined in Section \ref{subsubsection: Message-Passing Graph Neural Network}}} \centering \includegraphics[width=0.9\linewidth]{imgs/room_agg_arch.png} \label{Table: room_agg architecture} \end{table} The RNN Prior network (second component of our Graph Prior) is implemented by a single layer Gated Recurrent Unit (GRU) with hidden vector of size $64 \times 64$ (the latent space is $64$D). \subsection{The Reconstruction Loss of the ELBO} The reconstruction loss is the first term in the ELBO \eqref{eq: ELBO}. \[\mathbb{E}_{Z \sim q_{\phi}(Z \mid G, T, n_F)} [\log p_{\theta'}(G_F \mid Z, n_F, G_R, T)]\] In subsection \ref{subsection: proposed generative model} we described the distribution $p_{\theta'}(G_F \mid Z, n_F, G_R, T)$ as \begin{equation*} \begin{aligned} &p_{\theta'} (G_F \mid Z, n_F, G_R, T) \\= &\prod_{i=1}^{n_F}p_{\theta'}(shape_i \mid Z, G_R, T) p_{\theta'}(orien_i \mid Z, G_R, T) \\ & p_{\theta'}(loc_i \mid Z, G_R, T)p_{\theta'}(size_i \mid shape_i) p_{\theta'}(cat_i \mid shape_i). \end{aligned} \end{equation*} Here $shape_i, orien_i, loc_i, size_i$ and $cat_i$ refer to the ground truth values of the 3D shape descriptor (PointNet features), orientation, location, size and category respectively for furniture node $i$ in $G_F$. We will now describe each of these distributions in detail along with the corresponding loss term. For the normal and lognormal distributions used we assume the variance parameter is a fixed constant equal to $1$ and do not learn them. \begin{equation*} \begin{aligned} p_{\theta'}(shape_i \mid Z, G_R, T) &= {\mathcal{N}}(\mu^{shape}_{\theta'}(Z, G_R, T), const.) \\ \log p_{\theta'}(shape_i \mid Z, G_R, T) &= -\left(\mu^{shape}_{\theta'}(Z, G_R, T) - shape_i \right)^2 \end{aligned} \end{equation*} \begin{equation*} \begin{aligned} p_{\theta'}(orient_i \mid Z, G_R, T) &= Categorical(\Theta^{orient}_{\theta'}(Z, G_R, T)) \\ \log p_{\theta'}(orient_i \mid Z, G_R, T) &= -H(orient_i, \Theta^{orient}_{\theta'}(Z, G_R, T)) \end{aligned} \end{equation*} $orient_i$ is a $4$D $1$-hot embedding of the ground truth orientation and $\Theta$ is the parameter of the categorical distribution. $H(.,.)$ denotes the cross entropy between two distributions. \begin{equation*} \begin{aligned} p_{\theta'}(loc_i \mid Z, G_R, T) &= {\mathcal{N}}(\mu^{loc}_{\theta'}(Z, G_R, T), const.) \\ \log p_{\theta'}(loc_i \mid Z, G_R, T) &= -\left(\mu^{loc}_{\theta'}(Z, G_R, T) - loc_i \right)^2 \end{aligned} \end{equation*} \begin{equation*} \begin{aligned} &p_{\theta'}(size_i \mid shape_i) = \\& \qquad \qquad LogNormal(\mu^{size}_{\theta'}(\mu^{shape}_{\theta'}(Z, G_R, T)), const.) \\ &\log p_{\theta'}(size_i \mid shape_i) =\\& \qquad \qquad -\left(\mu^{size}_{\theta'}(\mu^{shape}_{\theta'}(Z, G_R, T)) - \ln size_i \right)^2 \end{aligned} \end{equation*} \begin{equation*} \begin{aligned} p_{\theta'}(cat_i \mid shape_i) &= Categorical(\Theta^{cat}_{\theta'}(\mu^{shape}_{\theta'}(Z, G_R, T))) \\ \log p_{\theta'}(cat_i \mid shape_i) &= -H(cat_i, \Theta^{cat}_{\theta'}(\mu^{shape}_{\theta'}(Z, G_R, T))) \end{aligned} \end{equation*} Each furniture node feature in the output of the MP-GNN Decoder is individually processed using a multi-layer Perceptron (MLP). Specifically, let $\hat{h}_i^L$ be the output feature of the decoder for furniture node $i$. In our experiments $\hat{h}_i^L \in \mathbb{R}^{1034}$. \[\mu^{shape}_{\theta'}(Z, G_R, T) = \textrm{Linear}_{\theta'}(1034, 1024)\] \[\Theta^{orient}_{\theta'}(Z, G_R, T)) = \textrm{SoftMax}(\textrm{Linear}_{\theta'}(1034, 4))\] \[\mu^{loc}_{\theta'}(Z, G_R, T) = \textrm{Linear}_{\theta'}(1034, 3)\] \[\mu^{size}_{\theta'} = \textrm{Linear}_{\theta'}(1024, 512) \rightarrow \textrm{ ReLU } \rightarrow \textrm{Linear}_{\theta'}(512, 3)\] This is a three-layer MLP with ReLU activations and $1024$ input neurons since the input is the mean of the shape features $\mu^{shape}_{\theta'}(Z, G_R, T))$. \[\Theta^{cat}_{\theta'}= \textrm{Linear}_{\theta'}(1024, 512) \rightarrow \textrm{ ReLU } \rightarrow \textrm{Linear}_{\theta'}(512, 7)\] The output is $7$D since there are $7$ super-categories in our dataset, Cabinet/Shelf, Bed, Chair, Table, Sofa, Pier/Stool, Lighting. $\textrm{Linear}_{\theta'}(x, y)$ denotes a linear layer with $x$ input neurons and $y$ input neurons. Recall $\theta'$ denotes all the parameters of the Decoder including the GNN and the output MLPs. \subsection{Computing the KL divergence term} \subsubsection{Derivation for \eqref{eq. KL div. analytical form}} Rewriting \eqref{eq: optimal ordering} \begin{equation} \pi^* = \argmin_\pi KL( q_{\phi}(Z \mid G, T, n_F) \mid\mid p_{\theta''}(Z \mid G_R, \pi, n_F, T)) \label{eq: optimal ordering appendix} \end{equation} For simplicity let us denote the two distributions as \begin{equation*} \begin{aligned} q_{\phi}(Z \mid G, T, n_F) &= {\mathcal{N}}(\mu_0, \Sigma_0) \\ p_{\theta''}(Z \mid G_R, \pi, n_F, T) &= {\mathcal{N}}(\tilde{\pi}\mu_1,\tilde{\pi}\Sigma_1\tilde{\pi}^T), \end{aligned} \end{equation*} where $\tilde{\pi} = \pi \otimes I_{d_F \times d_F}$. \\ The KL divergence between two Gaussian distributions is known analytically, \begin{equation} \begin{aligned} & KL( q_{\phi}(Z \mid G, T, n_F) \mid\mid p_{\theta''}(Z \mid G_R, \pi, n_F, T)) \\ &= \frac{1}{2}\left( Tr(\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T \Sigma_0) + (\tilde{\pi}\mu_1 - \mu_0)^T\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T(\tilde{\pi}\mu_1 - \mu_0) \right) \\ &\quad + \frac{1}{2}\left( \ln\left[\frac{det(\tilde{\pi}\Sigma_1\tilde{\pi}^T)}{det(\Sigma_0)}\right] - n_Fd_F \right) \\ &\equiv \left( Tr(\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T \Sigma_0) + (\tilde{\pi}\mu_1 - \mu_0)^T\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T(\tilde{\pi}\mu_1 - \mu_0) \right) \\ &= Tr(\Sigma_1^{-1}\tilde{\pi}^T \Sigma_0\tilde{\pi}) + \mu_1^T \Sigma^{-1}\mu_1 - \mu_1^T \Sigma_1^{-1} \tilde{\pi}^T\mu_0 \\& \quad- \mu_0^T\tilde{\pi}\Sigma_1^{-1}\mu_1 + \mu_0^T\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T\mu_0\\ &\equiv Tr(\Sigma_1^{-1}\tilde{\pi}^T \Sigma_0\tilde{\pi}) - \mu_1^T \Sigma_1^{-1} \tilde{\pi}^T\mu_0 - \mu_0^T\tilde{\pi}\Sigma_1^{-1}\mu_1 \\& \quad+ \mu_0^T\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T\mu_0\\ &\equiv Tr(\Sigma_1^{-1}\tilde{\pi}^T \Sigma_0\tilde{\pi}) - 2\mu_1^T \Sigma_1^{-1} \tilde{\pi}^T\mu_0 + \mu_0^T\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T\mu_0\\ \end{aligned} \label{eq: matching derivation} \end{equation} The third equivalence is obtained by observing that the constant $n_Fd_F$ (which is the dimension of the support of the two Gaussian distributions) does not affect the solution of \eqref{eq: optimal ordering appendix} and that permuting the rows and column of a matrix by the same permutation does not change its determinant and hence the minimizer $\pi^*$ will also not depend on this term. By similar reasoning, we also ignore the factor of $\frac{1}{2}$. In the fifth equivalence we again ignore terms that don't affect $\pi^*$. Using the cyclic property of the $Trace$ operator we can rewrite the last term on the RHS of \eqref{eq: matching derivation} as \[\mu_0^T\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T\mu_0 = Tr\left(\mu_0^T\tilde{\pi}\Sigma_1^{-1}\tilde{\pi}^T\mu_0\right) = Tr\left(\Sigma_1^{-1}\tilde{\pi}^T\mu_0\mu_0^T\tilde{\pi}\right)\] Substituting this results in \eqref{eq: matching derivation} we obtain the desired result. \begin{equation*} \begin{aligned} & KL( q_{\phi}(Z \mid G, T, n_F) \mid\mid p_{\theta''}(Z \mid G_R, \pi, n_F, T)) \\ &\equiv Tr(\Sigma_1^{-1}\tilde{\pi}^T \Sigma_0\tilde{\pi}) - 2\mu_1^T \Sigma_1^{-1} \tilde{\pi}^T\mu_0 + Tr\left(\Sigma_1^{-1}\tilde{\pi}^T\mu_0\mu_0^T\tilde{\pi}\right)\\ &= Tr(\Sigma_1^{-1}\tilde{\pi}^T \left[ \Sigma_0 + \mu_0\mu_0^T \right] \tilde{\pi}) - 2\mu_1^T \Sigma_1^{-1} \tilde{\pi}^T\mu_0 \\ &= Tr(\Sigma_1^{-1}\tilde{\pi}^T \left[ \Sigma_0 + \mu_0\mu_0^T \right] \tilde{\pi}) - 2 Tr\left(\mu_1^T \Sigma_1^{-1} \tilde{\pi}^T\mu_0\right) \\ &= Tr(\Sigma_1^{-1}\tilde{\pi}^T \left[ \Sigma_0 + \mu_0\mu_0^T \right] \tilde{\pi}) - 2 Tr\left(\tilde{\pi}^T\mu_0\mu_1^T \Sigma_1^{-1} \right) \\ \end{aligned} \end{equation*} We again used the cyclic property of the $Trace$ operator for the last equality. This concludes our derivation for \eqref{eq. KL div. analytical form}. \subsubsection{Solving \eqref{eq. KL div. analytical form} using the FAQ approximation}. The FAQ algorithm proceeds as follows, \begin{enumerate} \item \textbf{Choose an initial point:} We choose the uninformative $\pi_0 = \frac{1.1^T}{n_F}$ as the initial estimate for the algorithm. Note, here $\pi^0$ is a doubly stochastic matrix and not a permutation matrix. \item \textbf{Find a local solution:} In each iteration $i$, we linearize the objective at the current iterate $\pi^i$ \[\tilde{f^i}(\pi) := f(\pi^i) + Tr\left[\nabla f(\pi^i)^T(\pi - \pi^i)\right] \] Here, $f(\pi) = Tr\left(\Sigma_1^{-1} \tilde{\pi} \left[ \Sigma_0 + \mu_0\mu_0^T \right]\tilde{\pi}^T\right) - 2Tr\left(\tilde{\pi} \mu_0\mu_1^T\Sigma_1^{-1}\right)$. We then solve the following subproblem \begin{equation} \begin{aligned} \min_{\pi} &Tr(\nabla f(\pi^i)^T(\pi) \\ \textrm{s.t. } & \pi \in D \end{aligned} \label{eq: FW subproblem} \end{equation} Here $D$ is the set of all doubly stochastic matrices. Notice \eqref{eq: FW subproblem} is just a Linear Assignment Problem and can be efficiently solved by the Hungarian Algorithm. Let $q^i$ denote the $\argmin$ of \eqref{eq: FW subproblem}. \item \textbf{Choose the next iterate:} Finally choose $\pi^{i+1} = \alpha \pi^i + (1 - \alpha) q^i$, where $\alpha \in [0,1]$. Here $\alpha$ is chosen by solve the 1D optimization problem analytically. \begin{equation} \min_{\alpha} f(\alpha \pi^i + (1 - \alpha) q^i) \quad \textrm{s.t. } \alpha \in [0, 1] \end{equation} \item \textbf{Repeat steps $2$ and $3$ untill convergence.} Steps 2-3 are repeated iteratively untill some termination criteria is met, say $||\pi^i - \pi^{i-1} ||_F< \epsilon$. In practice, we do not run steps 2-3 untill convergence but terminate after just $1$ iteration of the FAQ algorithm. Running for longer iterations did not result in any significant gains in performance. \item \textbf{Project onto the set of permutation matrices.} Upon termination, the final solution is obtained by projecting $\pi^{final}$ onto the space of permutation matrices by solving $\min_{\pi \in P} -Tr(\pi^{final}\pi^T)$. Here $P$ is the set of all permutation matrices of size $n_F$. This is against solved by the Hungarian Algorithm. \end{enumerate} In step 2, we need to compute the gradient of $f(\pi^i)$. This can be done analytically. We will start our derivation by stating some facts. First, the gradient of the dot product of two matrices $A$ and $X$ with respect to $X$ is, \begin{equation} \frac{d}{dX}\langle A, X \rangle = A \label{eq: derivative of dot product} \end{equation} Second, for every linear operator $M$, its adjoint operator $M^{\dagger}$ is defined such that \begin{equation} \langle A, M(X) \rangle = \langle M^{\dagger}(A), X \rangle \label{eq: definittin of adjojint} \end{equation} Recall, \[f(\pi) = Tr\left(\Sigma_1^{-1} \tilde{\pi} \left[ \Sigma_0 + \mu_0\mu_0^T \right]\tilde{\pi}^T\right) - 2Tr\left(\tilde{\pi} \mu_0\mu_1^T\Sigma_1^{-1}\right)\]. We will fist look at the second term, \begin{equation} \begin{aligned} Tr\left(\tilde{\pi} \mu_0\mu_1^T\Sigma_1^{-1}\right) &= \langle \Sigma_1^{-1} \mu_1 \mu_0^T, M(\pi) \rangle \\ &= \sum_{ij}^{n_F \times n_F} \pi_{ij} Tr\left(\left[\Sigma_1^{-1} \mu_1 \mu_0^T\right]_{ij} \right) \\ &= \langle M^{\dagger}\left(\Sigma_1^{-1} \mu_1 \mu_0^T\right), \pi \rangle \\ \end{aligned} \label{eq. deriving the adjoint} \end{equation} Here, $M(\pi) := \pi \otimes I_{d_F \times d_F}$. Given a matrix $A \in \mathbb{R}^{n_Fd_F \times n_Fd_F}$, we define the operation $\left[A \right]_{ij}$ (used in the second equality) as follows. First divide the matrix $A$ into non-overlapping blocks of size $d_F \times d_F$, there are $n_F \times n_F$ such blocks. Now $\left[A\right]_{ij}$ denotes the $ij^{th}$ block. In the last equality, we defined the adjoint $L^{\dagger}(A)$ as $\hat{A}$. Here $\hat{A}$ is a $n_F \times n_F$ matrix obtained from $A$ whose $ij^{th}$ entry is, \[\hat{A}_{ij} = Tr\left(\left[A \right]_{ij}\right).\]. Combining \eqref{eq. deriving the adjoint} with \eqref{eq: derivative of dot product} we conclude \begin{equation} \frac{d}{d\pi} Tr\left(\tilde{\pi} \mu_0\mu_1^T\Sigma_1^{-1}\right) = M^{\dagger}\left(\Sigma_1^{-1} \mu_1 \mu_0^T\right) \end{equation} The gradient of the first term is calculated similarly, \begin{equation} \begin{aligned} Tr\left(\Sigma_1^{-1} \tilde{\pi} \left[ \Sigma_0 + \mu_0\mu_0^T \right]\tilde{\pi}^T\right) &= \langle \Sigma_1^{-1} \tilde{\pi} \left[ \Sigma_0 + \mu_0\mu_0^T \right],M(\pi) \rangle \\ \frac{d}{d\pi}Tr\left(\Sigma_1^{-1} \tilde{\pi} \left[ \Sigma_0 + \mu_0\mu_0^T \right]\tilde{\pi}^T\right) &= 2 M^{\dagger}(\Sigma_1^{-1} \tilde{\pi} \left[ \Sigma_0 + \mu_0\mu_0^T \right]) \end{aligned} \end{equation} Here $M(\pi)$ is again defined as $ \pi \otimes I_{d_F \times d_F}$. Putting it all together, \begin{equation} \begin{aligned} \nabla f(\pi) = 2M^{\dagger}(\Sigma_1^{-1} \tilde{\pi} \left[ \Sigma_0 + \mu_0\mu_0^T \right]) - 2M^{\dagger}\left(\Sigma_1^{-1} \mu_1 \mu_0^T\right) \end{aligned} \end{equation} \subsection{Learning Under Constraints} \label{appendix: learning under constraints} Let furniture graph $G_F$ be the input to the encoder and $\tilde{G}_F$ be the furniture graph reconstructed by the decoder. Recall, $E_{FF}$ denotes the edges between furniture nodes in $G_F$ (Section \ref{subsection: indoor scene representation as a graph}) and $\tilde{G}_F$ has the same structure as $G_F$. We employ the following constraints, \begin{itemize} \item \textbf{furniture-furniture distance constraint}: For every $(v_i, v_j ) \in E_{FF}$, we define there relative position as $c_{ij} = ||loc(v_i) - loc(v_j)||_2$, where $loc(v_i)$ denotes the $3$D centroid of furniture item $v_i$ from $G_F$. We define $c^{pred}_{ij} = ||loc^{pred}(v_i) - loc^{pred}(v_j)||_2$ as the relative distance computed from the corresponding location mean prediction by the decoder from $\tilde{G}_F$. Finally we define $d^{ij}_{FF} := MSE(c_{ij}, c^{pred}_{ij})$. Here $MSE$ refers to mean squared error. \item \textbf{furniture-room distance constraint}: This constraint restricts the relative position of the predicted furniture items with the room nodes. \begin{itemize} \item For the windows and doors, $d^{ij}_{RF}$ is defined analogously as \\ $d^{ij}_{RF} = MSE(c_{ij}, c^{pred}_{ij})$ where $(v_i, v_j) \in E_{RF}$, with the exception that for computing $c^{pred}_{ij}$ we use the ground truth room node location since they are not predicted by the decoder. \item For walls, $c^{pred}_{ij}$ is computed as the signed distance between the $i^{th}$ wall node and the $j^{th}$ furniture centroid. This ensures the decoder predicts furniture items on the correct side of the wall. \end{itemize} \item \textbf{furniture-furniture relative orientation constraint}: This constraint enforces the relative orientation between two predicted furniture centroid locations to be close to the ground truth. Specifically we define $\forall (v_i, v_j) \in E_{FF}$ $o^{ij}_{FF} = orient(v_i, v_j)^Torient^{pred}(v_i, v_j)$. Here $orient(v_i, v_j)^T$ is the unit vector pointing in the direction $loc(v_i) - loc(v_j)$ computed from $G_F$. Similarly, $orient^{pred}(v_i, v_j)$ is the unit vector pointing in the direction $loc^{pred}(v_i) - loc^{pred}(v_j)$ computed from the reconstruction $\tilde{G}_F$. \end{itemize} We now present the complete optimization objective as \begin{equation} \begin{aligned} &\max_{\theta', \theta'', \phi} {\mathcal{L}}(\theta', \theta'', \phi) \\ & s.t. \qquad \frac{1}{n} \sum_{i=1}^n \left[\sum_{(v_i, v_j) \in E_{FF}} d^{ij}_{FF}\right] \leq \epsilon \\ & s.t. \qquad \frac{1}{n} \sum_{i=1}^n \left[\sum_{(v_i, v_j) \in E_{RF}} d^{ij}_{RF}\right] \leq \epsilon \\ & s.t. \qquad \frac{1}{n} \sum_{i=1}^n \left[\sum_{(v_i, v_j) \in E_{FF}} o^{ij}_{FF}\right] \geq 1 - \epsilon \end{aligned} \label{eq: constraints} \end{equation} Here $\epsilon$ is a user-defined hyperparameter that determines the strictness of enforcing these constraints\footnote{One could also have used a different $\epsilon_i$ per constraint.}. ${\mathcal{L}}(\theta', \theta'', \phi) $ is as defined in \eqref{eq: overall ELBO} and $i$ is in iterator over the scene graphs in the training set. We employ the learning under constraints framework introduced by \cite{chamon2020probably} which results in a primal-dual saddle point optimization problem. For completeness, we will now describe this algorithm in detail. We begin by explicitly writing out the empirical lagrangian $\hat{{\mathcal{L}}}_{\theta', \theta'', \phi, \lambda_1, \lambda_2, \lambda_3}$, \begin{equation} \begin{aligned} g_1(\theta', \theta'', \phi) &:= \frac{1}{n} \sum_{i=1}^n \left[\sum_{(v_i, v_j) \in E_{FF}} d^{ij}_{FF}\right] \\ g_2(\theta', \theta'', \phi) &:= \frac{1}{n} \sum_{i=1}^n \left[\sum_{(v_i, v_j) \in E_{RF}} d^{ij}_{RF}\right]\\ g_3(\theta', \theta'', \phi) &:= \frac{1}{n} \sum_{i=1}^n \left[\sum_{(v_i, v_j) \in E_{FF}} o^{ij}_{FF}\right] \\ \hat{{\mathcal{L}}}_{\theta', \theta'', \phi, \lambda_1, \lambda_2, \lambda_3} &:= {\mathcal{L}}(\theta', \theta'', \phi) + \lambda_3(1 - \epsilon - g_3(\theta', \theta'', \phi)) \\&+ \lambda_1(g_1(\theta', \theta'', \phi) - \epsilon) + \lambda_2(g_2(\theta', \theta'', \phi) - \epsilon) \end{aligned} \label{eq: empirical lagrangian} \end{equation} Here $\lambda_1, \lambda_2, \lambda_3$ are the dual variables. The empirical dual problem is then defined as, \[\hat{D}^* := \max_{\lambda_1, \lambda_2, \lambda_3} \min_{\theta', \theta'', \phi}\hat{{\mathcal{L}}}_{\theta', \theta'', \phi, \lambda_1, \lambda_2, \lambda_3}.\] It was shown in \cite{chamon2020probably} that a saddle-point optimization of this empirical dual will give an approximate solution to \eqref{eq: constraints}. Algorithm \ref{algorithm: constraints} describes the exact steps. At step $5$ we require a $\rho$-optimal minimizer to the empirical Lagrangian, in practice this is done by running the ADAM optimizer for one epoch. After each epoch $t$, the dual variables are updated depending on the slack evaluated with current parameters $(\theta'^{(t-1)}, \theta''^{(t-1)}, \phi^{(t-1)})$. At an intuitive level, the algorithm is similar to regularized optimization with adaptive Lagrange multipliers (the dual variables). In \eqref{eq: empirical lagrangian} each term after ${\mathcal{L}}(\theta' , \theta'', \phi)$ can be thought of a regularizer (one corresponding to each constraint). The Langrange multipliers are updated in each epoch to enforce or relax the regularizer depending on whether the corresponding constraint is violated or satisfied. \begin{algorithm} \caption{Learning under constraints} \begin{algorithmic}[1] \Require \textit{Initializations:} $\theta'^{(0)}, \theta''^{(0)}, \phi^{(0)}$; \textit{Learning rate for dual variables} $\eta$; \textit{Number of steps} $T$ \State $\lambda_1^{(0)} = 0$ \State $\lambda_2^{(0)} = 0$ \State$\lambda_3^{(0)} = 0$ \For {$t = 1, \ldots, T$} \\ \quad Obtain $\theta'^{(t-1)}, \theta''^{(t-1)}, \phi^{(t-1)}$ such that, \[ \hat{{\mathcal{L}}}_{\theta', \theta'', \phi, \lambda_1, \lambda_2, \lambda_3} \leq \min_{\theta', \theta'', \phi} \hat{{\mathcal{L}}}_{\theta', \theta'', \phi, \lambda_1, \lambda_2, \lambda_3} + \rho .\] \\ \quad Update dual variables \[\lambda_1 ^{(t)} = \left[ \lambda_1 ^{(t-1)} + \eta(g_1(\theta'^{(t- 1)}, \theta''^{(t- 1)}, \phi^{(t- 1)}) - \epsilon) \right]_+\] \[\lambda_2 ^{(t)} = \left[ \lambda_2 ^{(t-1)} + \eta(g_2(\theta'^{(t- 1)}, \theta''^{(t- 1)}, \phi^{(t- 1)}) - \epsilon) \right]_+\] \[\lambda_3 ^{(t)} = \left[ \lambda_3 ^{(t-1)} + \eta(1 - \epsilon - g_3(\theta'^{(t- 1)}, \theta''^{(t- 1)}, \phi^{(t- 1)})) \right]_+\] \EndFor \end{algorithmic} \label{algorithm: constraints} \end{algorithm} In Figure \ref{fig: constraints}, we show training curves for ELBO objective \eqref{eq: ELBO} and the ELBO objective with constraints \eqref{eq: constraints} which clearly show the benefit of using constraints. Empirically on the 3D-FRONT dataset, getting good solutions is impossible (even after $900$ epochs ($70$k iterations)) without using constraints. The network performance without any constraints is comparable, to that with constraints, for the furniture category, shape and size loss terms. These are arguably much easier to learn than the orientation and position in $3$D. \begin{figure*}[ht] \centering \includegraphics[width=1.0\linewidth]{imgs/constraints_ablation.png} \setlength{\belowcaptionskip}{-10pt} \caption{\textit{\textbf{Ablation studies showing the effect of constraints on training. The orange curve indicates learning under constraints whereas the blue curve indicates learning without any constraints}(a) Training curves for the terms in the reconstruction loss of the ELBO (first term in \eqref{eq: ELBO}; (b) Objective values of the constraints as training progresses. Note the x-axis is the number of iterations rather than epoch (one iteration is one batch processed).}} \label{fig: constraints} \end{figure*} \subsection{Diverse furniture layout recommendations for the same room layout} More examples for Figure \ref{fig: proposed architecture}b in Figure \ref{fig: more examples for 2a} \begin{figure*}[ht] \centering \includegraphics[width=0.97\linewidth]{imgs/more_generations_2a.png} \setlength{\belowcaptionskip}{-10pt} \caption{\textit{\textbf{Diverse furniture layout recommendations for the same room layout.} Each row depicts a specific room, row 1,2 : living room; row 3,4,5 bedroom. The first column is the ground truth layout from the test set. The remaining columns are recommendations made by our proposed model. All rooms are top-down rendering of the scene except the first row which was generated using blender. The two black boxes marked asterisk in row 4 and 5 are ceiling lights. Notice how sometimes the network proposes a different room type given that is still a reasonable layout. For example, row 4, column 5, the network proposes a living room setup with a sofa instead of a bedroom. Similarly, row 5 column 4, the network proposes the library with a book shelf and a chair instead of a bedroom.}} \label{fig: more examples for 2a} \end{figure*} \subsection{More Examples for Figure \ref{fig: example generationed by autoregressive model}} \subsubsection{Manipulating Latent Space} See Figure \ref{fig: more examples for 2b} \begin{figure*}[ht] \centering \includegraphics[width=0.97\linewidth]{imgs/more_generations_2b.png} \setlength{\belowcaptionskip}{-10pt} \caption{\textit{\textbf{Manipulating the latent space.} We show recommendations made by our model for different rooms using the posterior distribution obtained from the test set furnished room. In all four figures the first image corresponds to the rendering of a test set indoor scene. Notice how the network orients the sofa (in (a) and (b)) and the bed (in (c) and (d)) to account for the room structure.}} \label{fig: more examples for 2b} \end{figure*} \subsubsection{Interpolating along the latent space} See attached videos. ``Interpolation\_3.mp4" contains a finer discretization of the example in Figure \ref{fig: example generationed by autoregressive model}c. Refer to the last paragraph of ``Manipulating the Latent space" in section \ref{subsection: proposed generative model} for details on how these videos were generated. \subsection{Analyzing matched furniture nodes for the trained model} We analyzed the ordering of the matched furniture items for our trained model by carrying out the following steps, \begin{itemize} \item Iterate over the scenes in the test set. \item Ever scene is a tuple consisting of the attributed scene graph, the room type and the number of furniture's in the room $(G, T, n_F)$. For each scene, \begin{itemize} \item Pass it through the trained GNN encoder to obtain the parameters for $q_{\phi}(Z \mid G, T, n_F)$. Here $Z := \{Z^1, Z^2, \ldots Z^{n_F}\}$ is the set of latent variables corresponding to the $n_F$ furniture items to be placed in the room. \item Next solve \eqref{eq: optimal ordering} using the FAQ algorithm and the Graph prior $p_{\theta''}(Z \mid G_R, \pi, T, n_F)$\footnote{Recall, given any ordering of the latent variables, $\pi$, the Graph Prior simulates and auto-regressive model based on $\pi$. See \eqref{eq. graph prior based on ordering}} to find the optimal ordering $\pi^*$. Here $G_R$ refers to the room layout graph derived from the input scene graph. \item This $\pi^*$ is the optimal assignment between $Z_i$'s obtained from the approximate posterior $q_{\phi}(Z \mid G, T, n_F)$ and the sequential latent nodes sampled using the auto-regressive prior (See \eqref{eq: autoregressive model}). \end{itemize} \item Since each $Z_i$ corresponds to a furniture item, we analyze the frequencies (over the test set) with which a certain category is mapped to the first latent sampled by the auto-regressive prior. This can give insights into what the model has learnt and whether the prior's modelling of furniture placement in indoor scenes correlates with how interior designers begin planning room layouts. In Table \ref{Table: matched furniture nodes} we present these results. We found that the first bedroom item matched by our model is a nightstand/bed/light with probability $0.91$ and the first living room item matched is a coffee-table/sofa/light with probability $0.76$. This is interesting since human designers often start planning with these items. \end{itemize} \begin{table} \caption{\textit{Frequency of categories mapped to the first latent sampled by the auto-regressive prior}} \centering \begin{tabular}{l|c|c} \toprule \textbf{Categories} & \textbf{Bedroom} & \textbf{Livingroom} \\ \toprule Bed & 0.30 & 0.0 \\ Light & 0.19 & 0.19 \\ Night-stand & 0.43 & 0.0 \\ Chair & 0.02 & 0.11 \\ Sofa & 0.01 & 0.20 \\ Table & 0.04 & 0.10 \\ Pier & 0.01 & 0.01 \\ Coffee-Table & 0.0 & 0.39 \\ \bottomrule \end{tabular} \label{Table: matched furniture nodes} \end{table} \section{Introduction} \label{sec: Introduction} The last few years have seen significant advances in image generation powered by the emergence of deep generative models such as GANs \cite{NIPS2014_5ca3e9b1} and VAEs \cite{Kingma2014AutoEncodingVB}. State-of-the-art methods are able to generate images of a single object category (e.g., faces) with amazingly realistic quality (e.g., \cite{Karras_2020_CVPR}). However, the problem of generating images of complex scenes composed of multiple objects in diverse arrangements remains a challenge. As an example, images of indoor scenes consist of room elements (floor, walls, etc.) and furniture items (table, chairs, beds, night stands) arranged in different ways depending on the room type (living room, bedroom, etc.) and style (elegant, contemporary, etc.). Moreover, room elements and furniture items should satisfy geometric and stylistic constraints, e.g., each object must lie inside the room and on the floor, two objects cannot occupy the same volume, some objects tend to co-occur in particular orientations relative to the room layout. Recent work on indoor scene image generation \cite{Gadde_2021_ICCV} aims to address the challenge of generating complex indoor scenes by using GANs with multiple discriminators that specialize in localizing different objects within an image. By adding a ``broker'' to mediate among such discriminators, \cite{Gadde_2021_ICCV} achieves state-of-the-art results on synthesizing images of living rooms. However, such state-of-the-art image generation models are far from capturing rich structure in their latent spaces to allow for image generation that is conditioned on rich structures. For example, given an image of a scene with a few objects, how can we generate other images of the same scene, but with additional objects that are consistent with previous objects? We contend that addressing such complex image generation problems requires reasoning about the content of the scene in 3D space. As a stepping stone, this paper focuses on the problem of conditional generation of the scene's 3D layout, rather than a 2D image, though we can synthesize images using a renderer given the layout. Specifically, we assume we are given the room type (e.g., living room or library room) and the room layout (e.g., room elements such as floor and walls), and our goal is to generate a collection of objects (e.g., furniture items such as sofa, coffee table and chairs) that is consistent with the room type and layout. For example, if the input room is larger, we expect the objects to be larger or more spread out. Moreover, we expect the generator to synthesize diverse object arrangements for the same room, and we expect such arrangements to satisfy the aforementioned geometric and stylistic constraints. Recent work on scene graph generation \cite{armeni20193d,wang2018deep,keshavarzi2020scenegen} aims to address these challenges using supervision in the form of scene hierarchies or relational graphs. However, the contextual space of possible arrangements objects in a room is simply too large to be modeled using hand-crafted heuristics or hierarchies. This has led to recent efforts on training networks directly from data, e.g., autoregressive models based on CNNs \cite{Ritchie2019FastAF} or Transformers \cite{wang2020sceneformer,Paschalidou2021NEURIPS}. However, we argue that latent variable models offer several advantages relative to autoregressive models. Firstly, they often lead to a more interpretable latent structure and allow the user to manipulate the generated samples by intervening in the latent space \cite{higgins2016beta,kumar2017variational}. For example, given a room, one could manipulate the latent space to recommend furniture in a ``similar" looking room. Such manipulations are not easy to implement in autoregressive models, which directly learn the conditional distribution of furniture items conditioned on other items. Secondly, the latent space learnt by VAEs is often useful in downstream semi-supervised or supervised classification \cite{kingma2014semi}. For instance one might be interested in classifying interior rooms based on style (modern, contemporary, minimalist, traditional) without access to fine-grained level annotations at scale. In this work, we propose a latent-variable model called Structured Graph Variational Autoencoders for the purpose of generating indoor 3D scenes. In our model, we represent both the room and furniture layouts with an attributed graph whose nodes correspond to room elements or furniture items, node attributes encode object class, position, orientation, etc., and, edges correspond to relationships among nodes captured by edge attributes such as relative orientation. We then propose a scene generative model consisting of a graph encoder that maps the input graph to a latent space, and a graph decoder that generates a furniture graph, given a latent code and the room graph. Specifically, we make the following contributions: \begin{enumerate} \item \emph{A structured auto-regressive prior for graphs}: This is our main contribution. Contemporary graph-VAE architectures typically encode the graph into a single latent vector and then use a multi-layered perceptron (MLP) to decode it back to a graph \cite{simonovsky2018graphvae,Kipf2016VariationalGA}. These architectures are known to be insufficient for learning indoor 3D scenes \cite{para2021generative}. In contrast, we propose to have a separate latent code for each furniture item. This has been previously explored in \cite{luo2020end}. However, in that work the authors assume that each furniture is associated with a latent which is sampled i.i.d from a standard Gaussian distribution. We argue that this assumption is limiting for the purpose of indoor scene synthesis especially when the underlying graph is complete and the decoder is a message passing GNN. To remedy this, we propose a novel autoregressive prior based on linear Gaussian models and propose an efficient way to compute the KL divergence term in the VAE objective. This requires a matching procedure since there is no canonical ordering of graph nodes. \item \emph{Learning graph-VAEs under constraints:} To facilitate learning, we use simple intuitive constraints like limiting the relative distances between furniture items, such as a chair and a table. These can be easily computed from training data. We then train our VAE model end-to-end under these constraints utilizing the recently introduced constrained learning framework by \cite{chamon2020probably}. We not in passing that Para \textit{et al}. \cite{para2021generative} also employ constraints for synthesizing plausible indoor scenes. Their approach however is only limited to linear constraints and training is not end-to-end. \item \emph{Experimental evaluation}: Through extensive experiments we show that our proposed model is competitive with the state of the art at indoor scene synthesis. Moreoever, we leverage the information captured by our latent code to propose furniture layouts to ``similar" looking rooms or interpolate gracefully between two given furnished rooms. We also show, via ablation studies, that our proposed model is better at capturing co-occurence distributions between object categories than baseline graph VAE architectures. \end{enumerate} \section{Related Work} \label{sec:related} \textbf{Graph-based inference:} Graphical representation of scenes and graph-based inference has been extensively studied in the past. Early works \cite{fisher2012example,fisher2011characterizing,yeh2012synthesizing,jiang2018configurable,qi2018human} employed ``shallow" methods like hand-crafted graph kernels or probabilistic graphical models to learn the furniture arrangements. Recent works leverage deep generative models to learn good scene representations directly from spatial data. The community has explored avenus for combining graphs with VAEs to synthesize 3D scenes \cite{10.1145/3303766,zhang2020deep,luo2020end}. However, all these methods rely on external annotations besides just the object labels and their spatial bounding boxes. For instance, \cite{luo2020end} relies on user-defined scene-graphs as input, \cite{10.1145/3303766} requires hand-crafted hierarchies, and \cite{Purkait2020SGVAESG} uses heuristics to extract context-free grammars from data which are then used to train a grammar-VAE \cite{kusner2017grammar}. Our proposed VAE is different from all these methods in that we would like to learn these rules directly from data which requires modelling of a structured prior distribution. On the other hand, Wang \textit{et al}. \cite{wang2019planit} uses graphs for high-level planning of the furniture layout of the room in a 2-stage approach where they train a generator to synthesize scene graphs followed by a CNN to propose consistent furniture poses. Their model has no latent variables and is slower due to the $2$-stage process. \textbf{Autoregressive Scene Generation.} Recent successful models for indoor scene synthesis are all autoregressive in nature \cite{wang2018deep,Ritchie2019FastAF,wang2020sceneformer,Paschalidou2021NEURIPS}. Wang et al. \cite{wang2020sceneformer} introduced an autoregressive scene generation pipeline, Sceneformer, using multiple transformers \cite{NIPS2017_3f5ee243} which predict objects' category, location and size separately. Concurrently, FastSynth \cite{Ritchie2019FastAF} introduced a similar pipeline, where the authors train separate CNNs based on a top-down representation of the scene to sequentially insert objects into the scene. Their method however requires auxilary supervision in the form of depth and semantic segmentation maps. Another recent transformer-based autoregressive approach was proposed in \cite{Paschalidou2021NEURIPS}, which replaces the multiple trained models of past works with a single unified model. Unlike these models, we learn an end-to-end latent variable model to generate 3D indoor scenes trained from spatial data. \textbf{Expressive latent distributions for VAEs.} There has been extensive work into designing expressive distributions for VAEs. For example, \cite{klushyn2019learning} proposes a hierarchial prior, \cite{rezende2015variational} uses normalizing flows to model a more expressive posterior distribution over latents, \cite{chen2016variational} uses an autoregressive prior, and \cite{tomczak2018vae} advocates the use of a mixture distribution for the prior based on the posterior distribution of the encoder. However, learning expressive distributions for latent spaces which are expressed as graphs is challenging due to the absence of any canonical ordering between the different nodes of a graph. This makes computing the required KL divergence term in the ELBO notoriously difficult. In this work we propose to model the latent space as an autoregressive linear Gaussian model which allows us to formulate the ordering as a Quadratic Assignment problem for which we also propose an efficient approximation. \section{Our Approach} \label{sec:method} \begin{figure}[ht] \centering \includegraphics[width=0.9\linewidth]{imgs/proposed_architecture_sample_generations.png} \caption{\textit{\textbf{(a) Overview of the proposed model.} The input scene graph includes the furniture and room sub-graphs and is complete (we omit depicting certain edges to prevent clutter). The Encoder predicts a mean and variance per furniture node, which are then used to sample latents for proposing furniture nodes by the decoder. During inference we use the proposed autoregressive prior to generate the latents, which are then subsequently processed by the decoder for scene synthesis; \textit{\textbf{(b) Generated scenes.} Sample generations for our model for a bedroom (row 1) and a library (row 2). Green rectangles indicate doors while blue rectangles indicate windows}}} \label{fig: proposed architecture} \vspace{-3mm} \end{figure} This section describes the proposed Structure Graph Variational Autoencoder model. First, we describe how we represent the 3D scene layout with an attributed graph. Next, we describe the SG-VAE architecture. The VAE encoder is a GNN that processes the graph and produces latent variables which are then passed to another GNN which serves as the VAE decoder. Then, we describe how we parameterize the prior on the latent space using an autoregressive model which is learnt. Finally, we describe the proposed training methodology, which includes some constraints for faster convergence. A schematic depiction of our approach is given in Figure \ref{fig: proposed architecture}a. We share more architectural and feature engineering details in the Appendix. \subsection{Indoor scene representation as a graph} \label{subsection: indoor scene representation as a graph} We represent an indoor scene as an attributed graph $G=(V, E, X)$. Here the nodes $V$ denote room layout components (floor, wall, windows) and furniture items (sofa, chair, bed), the edges $E \subseteq V \times V$ denote relationships between the nodes (e.g., sofa parallel to wall), and the attributes $X$ denote features associated with the nodes and edges (e.g., location of furniture items or relative orientation between bed and wall). The graph has two node types (room nodes $V_R$, furniture nodes $V_F$), three edge types (room-room edges $E_{RR}$, room-furniture edges $E_{RF}$ and furniture-furniture edges $E_{FF}$), and five attribute types corresponding to these node and edge types ($X_R$, $X_F$, $X_{RR}$, $X_{RF}$ and $X_{FF}$). In this work, we consider the graph as complete, that is, $E_{RF} = V_R \times V_F, E_{FF} = V_F \times V_F$ and $E_{RR} = V_R \times V_R$. We will identify two main subgraphs of $G$. The room layout graph $G_R = (V_R,E_R,{X_R,X_{RR}})$ consists of $n_R := |V_R|$ nodes (or room elements) and $e_R := |E_R|$ edges, where the node attributes $X_R \in {\mathbb{R}}^{n_R \times d_R}$ denote the class, location, orientation and size of the room element, and the edge attributes $X_{RR} \in {\mathbb{R}}^{e_R \times d_{RR}}$ encode geometric or functional relationships between two room elements (relative location, relative orientation etc.). The room type $T$ is also encoded as a categorical feature into $X_R$. Similarly, the furniture layout graph $G_F=(V_F,E_F,{X_F,X_{FF}})$ consists of $n_F := |V_F|$ nodes (or furniture items) and $e_F=|E_F|$ edges, where the node attributes $X_F \in {\mathbb{R}}^{n_F \times d_F}$ denote the class of the furniture item, its location, orientation, size, color, and its 3D shape descriptor, and its edge attributes $X_{FF} \in {\mathbb{R}}^{e_F \times d_{FF}}$ encode geometric or functional relationships between two furniture items. We obtain the shape descriptors of each furniture item by processinga a 3D point cloud of the item through PointNet~\cite{qi2017pointnet} pretrained on the Stanford ShapeNet dataset \cite{shapenet2015}. \subsection{Proposed Generative Model} \label{subsection: proposed generative model} We would like to design and learn a probabilistic model $p(G_F \mid G_R,T,n_F)$ that generates a furniture layout $G_F$ given the room layout $G_R$, type $T$ (say, bedroom or library room) and number of furniture items $n_F$ to place in the room. We assume there exists latent $Z$ such that \begin{equation} \! p(G_F \!\! \mid \!\! G_R, T, n_F) \! = \! \!\! \int \!\! p(G_F \!\! \mid \!\! Z, n_F, G_R, T) p(Z \!\! \mid \!\! n_F, G_R, T)dZ . \label{eq: generative model} \end{equation} Our proposed model consists of three main ingredients: \begin{enumerate}[leftmargin=*,noitemsep] \item An encoder, $q_{\phi}(Z \mid G, T, n_F)$, which maps both room and furniture layouts ($G_R$ and $G_F$ resp.) as well as room type and number of furniture items to a latent variable $Z$, which captures the diversity of room-aware furniture layouts. The parameters of the encoder are denoted as $\phi$. \item A decoder, $p_{\theta'}(G_F \mid Z, n_F, G_R, T)$, which maps the number of furniture items, the latent variable as well as the room layout and type to a furniture layout. The parameters of the encoder are denoted as $\theta'$. \item A prior model $p_{\theta''}(Z \mid n_F, G_R, T)$. The difference between the prior model and the encoder is that the prior model only considers the room layout $G_R$ and not $G$. The parameters of the prior model are denoted as $\theta''$. \end{enumerate} The encoder, decoder and prior model are parameterized with GNNs which we will describe in the next subsection. Given a training set, consisting of indoor scenes in the form of attributed graphs ${\mathcal{G}} = \{G_1, G_2, ..., G_n\}$, we learn the parameters $\{\theta', \theta'', \phi\}$ by optimizing the following empirical average over the training set: \begin{equation} \begin{aligned} {\mathcal{L}}(\theta', \theta'', \phi) = & \frac{1}{n} \sum_{i=1}^n \mathscr{L}(G_i, \theta', \theta'', \phi), \end{aligned} \label{eq: overall ELBO} \vspace{-2mm} \end{equation} where, for any $G \in {\mathcal{G}}$, $L(G, \theta', \theta'', \phi)$ denotes the Evidence Lower Bound (ELBO) defined as: \begin{equation} \begin{aligned} \mathscr{L}(G, \theta', \theta'', \phi) = &\mathbb{E}_{Z \sim q_{\phi}(Z \mid G, T, n_F)} [\log p_{\theta'}(G_F \mid Z, n_F, G_R, T)] \\ &- KL(q_{\phi}(Z \mid G, T, n_F) \mid \mid p_{\theta''}(Z \mid n_F, G_R, T) ). \end{aligned} \label{eq: ELBO} \end{equation} As mentioned in section \ref{sec: Introduction}, we optimize \eqref{eq: overall ELBO} under constraints to speed up convergence, as we will describe in subsection \ref{section: learning under constraints}. \textbf{Graph Encoder.} The encoder models the approximate posterior of a latent variable $Z$ given $(G,T,n_F)$. We assume that the distribution of $Z$, $q_{\phi}(Z \mid G,T,n_F)$, is Gaussian with mean $\mu_{\phi}(G,T,n_F)$ and a diagonal covariance matrix with diagonal entries $\sigma_{\phi}(G,T,n_F)$. The distribution parameters $(\mu_{\phi}, \sigma_{\phi})$ are modeled as the output of an attention-based message passing graph neural network (MP-GNN) with weights $\phi$. The design of the MP-GNN is inspired by \cite{mavroudi2020representation}, where each layer $l=1,…,L$ of the MP-GNN maps a graph $G^{l-1}$ to another graph $G^l$ by updating the graph’s node and edge features. Specifically, let $h_i^l$ and $h_{ij}^l$ denote the features of node $i$ and edge $(i,j)$ of graph $G^l$, respectively. Let the input to the network be the graph $G^0=G$, so that $h_i^0$ and $h_{ij}^0$ denote the node features (rows of $X_R$ and $X_F$) and edge features (rows of $X_{RR}$, $X_{FF}$ and $X_{RF}$), respectively. At each iteration of node and edge refinement, the MP-GNN: (1) adapts the scalar edge weights by using an attention mechanism; (2) updates the edge attributes depending on the edge type, the attention-based edge weights, the attributes of the connected nodes and the previous edge attribute; and (3) updates the node attribute by aggregating attributes from incoming edges. After $L$ layers of refinement, we obtain a graph $G^L$, whose node features are mapped via a linear layer with weights $W_{\mu}, W_{\sigma}$ to obtain the parameters of the Gaussian model as $\mu_\phi^i(G, T) = W_{\mu} h_i^L, \; \sigma^i_\phi(G,T) = \exp(W_{\sigma} h_i^L)$ where $i=1,\dots, n_F$. Note that there is a different Gaussian for each node of the graph. Therefore, the output of the encoder will be two matrices $\mu_\phi(G,T,S) \in\mathbb{R}^{n_F \times d_F}$ and $\sigma_\phi(G,T,S) \in\mathbb{R}^{n_F \times d_F}$ corresponding to the mean and standard deviation vectors of the latent variable matrix $Z\in\mathbb{R}^{n_F \times d_F}$. \textbf{Graph Decoder.} The decoder maps $(n_F, Z)$ and the room layout, type $(G_R, T)$ to a desired furniture layout via the distribution $p_{\theta'}(G_F \mid Z, n_F, G_R, T)$. The generative process proceeds as follows, An initial fully connected furniture graph $G_F^0$ instantiated. Each node of $G_F^0$ is associated with a feature of dimension $d_F$ corresponding to one of the rows of $Z$. Each edge $(i,j)$ of $G_F^0$ of type $\epsilon \in\{RF,FF\}$ is associated with a feature $Z_{ij} = (Z_i,Z_j)$ as the concatenation of the node features. As a result, we obtain an initial graph $G_0$ that includes both the initial furniture graph $G_F^0$ as well as the given room graph $G_R$ as subgraphs. The initial graph $G_0$ is passed to a MP-GNN, which follows the same operations as the encoder MP-GNN. The output of the MP-GNN is the furniture subgraph $G_F^L$ of the final graph $G^L$. Each furniture node of $G^L$ is then individually processed through a MLP to produce parameters for the furniture layout graph distribution $p_{\theta'}(G_F \mid Z, n_F, G_R, T)$, which can be factorized in the following way: \begin{align} p_{\theta'} (G_F \mid Z, n_F, G_R, T) = &\prod_{i=1}^{n_F}p_{\theta'}(shape_i \mid Z, G_R, T) p_{\theta'}(orien_i \mid Z, G_R, T) \\ &p_{\theta'}(loc_i \mid Z, G_R, T)p_{\theta'}(size_i \mid shape_i) p_{\theta'}(cat_i \mid shape_i). \nonumber \end{align} More specifically, we assume that given latent $Z$, room layout $G_R$ and type $T$, the furniture features are independent of each other (a standard assumption in the VAE literature). For a furniture, we further assume that shape, orientation and location features are independent given $Z, G_F$ and $T$. However, since the PointNet shape features implicitly capture the configuration of the furniture item in 3D space we condition the size and category distributions on the shape feature. We parameterize the shape and location features as a normal distribution, the size feature as a lognormal distribution whose support is restricted to be positive valued, category and orientation features as categorical distribtions. Since both the Encoder and Decoder graphs have $n_F$ nodes that are in one-to-one correspondence, we can define our reconstruction loss (first term in \eqref{eq: ELBO}) by simply comparing there node features without the need for an explicit matching procedure. \textbf{Graph Prior.} Recall our latent space $Z$ is modelled such that there is a latent variable corresponding to each furniture node in the graph. Many popular graph VAE models assume an i.i.d. normal prior for each node \cite{kipf2016variational,luo2020end}. However, such a model is restrictive for our purposes. MP-GNNs achieve permutation equivariance by sharing the weight matrices across every node in the graph. When the graph is complete, as is the case here, the marginal distribution of every output node after $L$ GNN layers will be identical if they are initialized as i.i.d. Gaussian at the input layer. Since, the output nodes of the decoder GNN after $L$ layers correspond to different furniture features, having identical marginals is detrimental. We support this claim with ablation studies (Sec. \ref{sec. experiments}) where we show that i.i.d. prior models struggle to learn the dependencies between different furniture categories in a room. To remedy this, we propose to parameterize prior distribution as an autoregressive model based on linear gaussian models \cite{bishop2006pattern}. More specifically, \begin{equation} \begin{aligned} p(Z^0 \mid G_R, T) &= {\mathcal{N}}(\mu_{\theta''}(G_R, T), \sigma^0_{\theta''}(G_R, T)), \\ p(Z^i | Z^{k < i}, G_R, T) &= {\mathcal{N}}(\sum_{k < i}A^k_{\theta''}(G_R, T) Z^k, \sigma^i_{\theta''}(G_R, T)). \end{aligned} \label{eq: autoregressive model} \end{equation} where $Z^i $ refers to the latent corresponding to the $i^{th}$ furniture node. Thus, the $i^{th}$ furniture node latent is given by a Gaussian whose mean is a linear function of all the latents $k < i$. Such a structure ensures that all the latent variables are jointly Gaussian. This allows us to analytically compute the KL divergence term and thus was favoured over more expressive probabilistic models which would introduce more stochasticity in the objective due to the need of estimating the KL divergence term via sampling. We implement \eqref{eq: autoregressive model} (see also Figure 1) with two networks: \begin{itemize}[leftmargin=*] \item \textbf{Room Aggregator for $\boldsymbol {p(Z^0 \mid G_R, T)}$:} The room aggregator is an MP-GNN with the same architecture as the Graph Encoder. except that the input to the network is just $(G_R, T)$ with the node and edge features initialized to $X_R$ and $X_{RF}$, respectively. After $L$ GNN layers, all the room node features are aggregated by a mean pooling operation to obtain a global representation of the room layout plan $X_R^{agg}$. This $X_R^{agg}$ is then passed through an MLP to compute $\mu_{\theta''}(G_R, T)$ and $\sigma^0_{\theta''}(G_R, T)$. \item \textbf{RNN Prior for $\boldsymbol {p(Z^i | Z^{k < i}, G_R, T)}$:} We use a recurrent neural network to predict the matrix $A^k_{\theta''}(G_R, T)$ and the variance $\sigma^i_{\theta''}(G_R, T)$ at each node index. The RNN is initialized with $X_R^{agg}$. We need additional constraints on each $A^k_{\theta''}(G_R, T)$ to prevent the dynamics model in \eqref{eq: autoregressive model} from diverging to infinity. This is typically done by controlling the spectral radius or its proxy, the spectral norm \cite{lacy2003subspace}, of the matrices $\{A^k_{\theta''}(G_R, T): k \in [1, 2, ..., n_F]\}$. Thus, the predicted matrix is taken to be $\frac{A^k_{\theta''}(G_R, T)}{||A^k_{\theta''}(G_R, T)||_{2}}$, where $||A||_2$ is the spectral norm of some matrix $A$. \end{itemize} \subsection{Computing the KL term via matching and constrained learning} \label{section: learning under constraints} Note that the proposed autoregressive prior could in principle be reexpressed as a more traditional i.i.d.~Gaussian prior, which is then passed through an additional non-equivariant transformation layer that can be absorbed into the decoder. But a significant difference emerges in practice when facing the key challenge of incorporating this non-equivariant factor into subsequent model training, given that there is no longer a canonical ordering between the different nodes in a graph. When the proposed autoregressive prior formulation is adopted, such an ordering is only required to evaluate $p_{\theta''}(Z \mid G_R, T, n_F)$ for any $Z$ sampled from the posterior $q_{\phi}(Z \mid G, T, n_F)$ to compute the KL divergence term in the ELBO \eqref{eq: ELBO}. However, by design this term can be expressed analytically, and as we will soon demonstrate, an efficient compensatory permutation can be efficiently computed. In contrast, with an alternative autoregressive decoder formulation, the search for an appropriate ordering is instead needed for computing the VAE reconstruction term (i.e., evaluating the decoder $p_{\theta'} (G_F \mid Z, n_F, G_R, T)$ for any $Z$ sampled from the posterior), and hence becomes entangled with the non-analytic stochastic sampling required for obtaining approximate reconstructions. \textbf{Computing the KL divergence term.} Let $Z = \{Z^1, Z^2, ..., Z^{n_F}\}$ be the set of latent variables correponding to $n_F$ furniture items to be placed in the room. Let $\pi$ denote the ordering among these variables. Given $\pi$, the likelihood of observing $Z$ under our proposed prior is defined as \begin{equation} p_{\theta''}(Z \mid G_R, \pi, n_F, T) = \prod_{i=1}^{n_F} p_{\theta''}(Z^{\pi(i)} \mid Z^{\pi(j < i)}, G_R, T), \label{eq. graph prior based on ordering} \end{equation} However, for $Z \sim q_{\phi}(Z \mid G, T, n_F)$ (the approximate posterior) we do not know this ordering $\pi$. Thus, given $Z$, we define the optimal order $\pi^*$ to be \begin{equation} \pi^* = \argmin_\pi KL( q_{\phi}(Z \mid G, T, n_F) \mid\mid p_{\theta''}(Z \mid G_R, \pi, n_F, T)). \label{eq: optimal ordering} \end{equation} Recall $q_{\phi}(Z \mid G, T, n_F) = \prod_{i=1}^{n_F}{\mathcal{N}}(Z^i; \mu_{\phi}^i(G), \sigma_{\phi}^i(G))$ Since both the prior and posterior are jointly Gaussian, computing \eqref{eq: optimal ordering} reduces to solving a Quadratic Assignment Problem (QAP). For simplicity let us denote the distributions as \begin{equation} \begin{aligned} q_{\phi}(Z \mid G, T, n_F) = {\mathcal{N}}(\mu_0, \Sigma_0); \;\; p_{\theta''}(Z \mid G_R, \pi, n_F, T) = {\mathcal{N}}(\tilde{\pi}\mu_1,\tilde{\pi}\Sigma_1\tilde{\pi}^T), \end{aligned} \end{equation} where $\tilde{\pi} = \pi \otimes I_{d_F \times d_F}$. Note $\pi \in {\mathbb{R}}^{n_F \times n_F}$ and the kronecker product comes from the fact that we are only allowed to permute blocks of $\mu_1$ and $\Sigma_1$, of size $d_F$ and $d_F \times d_F$ respectively, where $d_F$ is the dimension of the latent variable used for each furniture node. In other words, we can only permute latent vectors corresponding to furniture nodes as a whole and not the intra dimensions of $Z$ within any furniture node. Here $\mu_0, \mu_1 \in {\mathbb{R}}^{n_Fd_F}$. Similarly, $\Sigma_0, \Sigma_1 \in {\mathbb{R}}^{n_Fd_F \times n_Fd_F}$. Note that due to the autoregressive structure $\Sigma_1$ will not be a diagonal matrix. We show in the appendix that \eqref{eq: optimal ordering} is equivalent to \begin{equation} \min_{\pi} Tr\left(\Sigma_1^{-1} \tilde{\pi}^T \left[ \Sigma_0 + \mu_0\mu_0^T \right]\tilde{\pi}\right) - 2Tr\left(\tilde{\pi}^T \mu_0\mu_1^T\Sigma_1^{-1}\right). \label{eq. KL div. analytical form} \end{equation} Notice that \eqref{eq. KL div. analytical form} is a Quadratic Assignment Problem (QAP) which is known to be NP-Hard. For this we propose to use a fast approximation algorithm, called FAQ, introduced in \cite{vogelstein2015fast}. FAQ first relaxes the optimization problem from set of permutation matrices to the set of all doubly stochastic matrices. It then iteratively proceeds by solving linearizations of the objective \eqref{eq. KL div. analytical form} using the Franke-Wolfe method. These linearizations reduce the QAP to just a linear assignment problem (LAP), which can be efficiently solved by the Hungarian algorithm. After Franke-Wolfe terminates, we project the doubly stochastic solution back to the set of permutations by solving another LAP. FAQ has a runtime complexity that is cubic in the number of nodes per iteration which is faster than the quartic complexity of the matching procedure used in \cite{simonovsky2018graphvae}. More details in Appendix. We need to compute the optimal $\pi^*$ for each graph in a mini-batch, and then compute the KL divergence term in \eqref{eq: ELBO} analytically given this ordering. We observe no significant gains in performance in running the FAQ algorithm more than $1$ step per graph, which further speeds our method. \textbf{Learning under constraints:} To facilitate faster convergence and also ensure fidelity of the learned solution, we enforce certain constraints on the reconstructed room. These constraints are derived from training data and do not require external annotations. Given input furniture graph $G_F$ to the encoder and the reconstructed graph $\tilde{G}_F$ by the decoder, we enforce the relative positions of predicted furnitures in $\tilde{G}_F$ to be ``close" to the ground truth relative positions in $G_F$. Similarly, we apply constraints on the relative position of the predicted furniture items with the room walls, windows and doors. Finally we apply a constraint penalizing the relative orientations between different furniture items from being too ``far" away from the relative orientations in $G$. We explain these constraints more clearly in the Appendix. Having described all the ingredients in our model, we finally present the complete optimization objective as \begin{equation} \begin{aligned} \max_{\theta', \theta'', \phi} {\mathcal{L}}(\theta', \theta'', \phi) \quad s.t. \qquad \frac{1}{n} \sum_{i=1}^n \textrm{ Constr}(G_i) \leq \epsilon. \\ \end{aligned} \end{equation} Here $\epsilon$ is a user-defined hyperparameter that determines the strictness of enforcing these constraints. ${\mathcal{L}}(\theta', \theta'', \phi) $ is as defined in \eqref{eq: overall ELBO} and $i$ is in iterator over the scene graphs in the training set. We employ the learning under constraints framework introduced by \cite{chamon2020probably} which results in a primal-dual saddle point optimization problem. For completeness, we give exact algorithmic details in the Appendix. \subsection{Inference} For inference, we start with a room layout graph $G_R$ and type $T$ along with the number of furnitures to be placed in the room $n_F$. We then use the learnt autoregressive prior to sample $n_F$ latent variables recursively. This latent $Z$ along with $(n_F, G_R, T)$ is processed by the graph decoder to generate the funiture layout subgraph $G_F$. For scene rendering, we use the predicted shape descriptor for each furniture item and perform a nearest neighbour lookup using the $\ell_2$ distance against a database of 3D furniture mesh objects indexed by there respective PointNet feature. We then use the predicted size and orientation to place furnitures in the scene. Note the inclusion of shape descriptors allows the model to reason about different appearance of furniture items that is more room aware as opposed to retrieval based on just furniture category \& size as in \cite{wang2020sceneformer,Paschalidou2021NEURIPS}. \begin{figure}[ht] \centering \includegraphics[width=0.9\linewidth]{imgs/qualitative_examples.png} \caption{\textit{Qualitative comparison of our method with ATISS and baselines. Windows and doors and indicated by white rectangles}} \label{fig: qualitative comparison} \end{figure} \begin{figure}[ht] \centering \includegraphics[width=1.0\linewidth]{imgs/latent_space_manipulations.png} \caption{\textit{ \textbf{Manipulating the latent space.} (a), (b) recommendations made by our model for different rooms using the posterior distribution obtained from the reference room (first image in both figures); (c) by traversing the latent space one can ``slightly" change the appearance and type of various furniture items}} \label{fig: example generationed by autoregressive model} \end{figure} \section{Experiments} \label{sec:results} \label{sec. experiments} In this section, we evaluate the effectiveness of the proposed approach qualitatively and quantitatively. More details and figures provided in the Appendix. \textbf{Dataset:} We use the 3D-FRONT dataset \cite{fu20213d} for all our experiments. The dataset consists of roughly $14k$ rooms, furnished with $3$D mesh furniture items. We consider four room types, bedroom, living room, library, and dining room. \textbf{Training Protocols:} All models were trained on a $80:20$ train-test split. Since we use PointNet shape descriptors, we only predict 7 ``super-categories" of furniture items\footnote{Cabinet/Shelf, Bed, Chair, Table, Sofa, Pier/Stool, Lighting}. Since furniture is mostly axis-aligned, we discretized the orientation into four categories $[0, 90, 180, 270]$. We also rotate the room by multiples of $\frac{\pi}{2}$ degrees as data augmentations. We train all models using the ADAM optimizer for $1500$ epochs with a batch size of $128$. Each latent furniture is $64$D. \textbf{Baselines:} We compare our VAE model with baselines which have the same Encoder-Decoder architecture but employ the commonly used i.i.d. prior. We compare against two variants (inspired from \cite{luo2020end}), $(i)$ \textbf{Standard Prior (B1):} Each $Z^i \sim {\mathcal{N}}(0, I)$ for $i \in [1, ..., n_F]$, $(ii)$ \textbf{Non-autoregressive Learnt Prior (B2):} Each $Z^i \sim {\mathcal{N}}(\mu(G_R), \sigma(G_R))$. The mean and variance parameters of this distribution are learnt by an MP-GNN which processes just the room subgraph. \textbf{Scene Generation:} In Figure \ref{fig: proposed architecture}b, we illustrate the effectiveness of the proposed method at generating diverse furniture recommendations given a room layout. Notice how our model generates different furniture arrangements as well as diverse 3D appearances. For example, sampled beds, cabinets and ceiling lights look distinct in row 1. For the library example (row 2), our model proposes from a simple study room with a small shelf and seating (columns 2,3) to a lounge with a couch and a chair. In Figure \ref{fig: qualitative comparison} we qualitatively compare our generations for different rooms with the state-of-the-art (ATISS) and our VAE baselines. Note that while both ATISS and our model generate plausible furniture arrangements the baseline VAEs struggle, presumably because of the i.i.d. prior assumption. Moreover, since ATISS does not explicitly model window and doors, often the furniture items occlude them which is undesirable (for example, cabinet partially blocking door in row $3$ col $1$). This is not the case in our method which explicitly accounts for windows and doors as nodes of the room sub-graph. In Table \ref{Table: quantitative metrics}, we provide competitive results compared to existing methods using the same experimental protocols in \cite{Paschalidou2021NEURIPS}. FID score (lower is better), which measures the realism of generated indoor scenes v/s ground truth scenes from the test set. Our method performs the best on this metric for bedrooms and is comparable for living rooms and dining rooms. However, presumably due to fewer training data points, our network struggles on libraries. The Category KL divergence measures how well the model captures the frequency of categories present in an indoor scene compared to the ground truth. On this metric, our method is comparable to existing methods. Moreover, this metric can be misleading since it does not capture the dependencies between different predicted furniture items as we show in ablation studies. Scene classification accuracy (close to $0.5$ is better) tests the ability of a network to distinguish between real and synthetic scenes. On this metric, our method performs better than both FastSynth and Sceneformer in all room types. Note that although ATISS appears quantitatively better at scene generation, it is autoregressive and thus does not share the benefits of latent-variable manipulations which we will discuss next. \begin{table} \caption{\textit{Quantitative comparison of our method with other models and baselines. Scene classification accuracy closer to 0.5 is better}} \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{l|cccc|cccc|cccc} \toprule \multicolumn{1}{c}{\,} & \multicolumn{4}{c}{FID Score ($\downarrow$)}& \multicolumn{4}{c}{Category KL Divergence ($\downarrow$)}& \multicolumn{4}{c}{Scene Classification Accuracy}\\ \toprule \multicolumn{1}{c}{\,} & Bedroom & Living & Dining & Library & Bedroom & Living & Dining & Library & Bedroom & Living & Dining & Library\\ \midrule FastSynth & 40.89 & 61.67 & 55.38 & 37.72 & \textbf{0.01} & 0.02 & 0.05 & 0.04 & 0.883 & 0.945 & 0.935 & 0.815 \\ SceneFormer & 43.17 & 69.54 & 67.04 & 55.45 & \textbf{0.01} & 0.03 & 0.03 & 0.02 & 0.945 & 0.972 & 0.941 & 0.880 \\ ATISS & 38.39 & \textbf{33.14} & \textbf{29.23} & \textbf{35.24} & \textbf{0.01} & \textbf{0.00} & \textbf{0.01} & \textbf{0.01} & \textbf{0.562} & \textbf{0.516} & \textbf{0.477} & \textbf{0.521} \\ Baseline B1 & 56.82 & 39.47 & 63.56 & 76.87 & 0.02 & 0.02 &0.05 & 0.09 & 0.953 & 0.912 & 0.757 & 0.864 \\ Baseline B2 & 47.47 & 39.78 & 42.34 & 67.28 & 0.02 & 0.02 & 0.05 & 0.07 & 0.945 & 0.909 & 0.716 & 0.739 \\ Ours & \textbf{34.86} & 38.19 & 38.03 & 65.05 & \textbf{0.01} & 0.01 & 0.02 & 0.02 & 0.877 & 0.867 & 0.693 & 0.729 \\ \bottomrule \end{tabular}} \label{Table: quantitative metrics} \end{table} \textbf{Manipulating the Latent space.} Suppose we are moving to a new apartment and would like to interior design our new place in the same ``style" as the old apartment. How might we do this? This is a non-trivial problem since one needs to account for differences in room dimensions and size. Answering such questions is easier using latent-variable models where the latent $Z$ is expected to capture the room design and can be easily manipulated. More concretely, given a ``reference" furnished room graph. We can process it using our graph encoder to obtain the posterior distribution $q(Z \mid G, T, n_F)$. We can then use the room layout of our new apartment $\tilde{G}_R$, pass it through the decoder along with the latent $Z \sim q(Z \mid G, T, n_F)$ to recommend furniture items for $\tilde{G}_R$. Figure \ref{fig: example generationed by autoregressive model}a \& b show two such examples. In both figures, the first image is the reference scene $G$. Notice how, according to the room layout, the bed or the sofa changes its orientation while the network tries to keep the overall arrangement the same. This shows that our model does not trivially memorize the furniture layout of the reference room in $Z$ but uses the room structure $\tilde{G}_R$ in making its predictions. \textit{Such latent space manipulations are not possible in our baseline models, where the learnt GNN encoder simply memorizes each furniture pose in its latent and the decoder subsequently ignores the room structure in its generation}. This is validated by experiments in which we keep $Z$ fixed and vary the room layout input to the GNN decoder. For the proposed model, the predicted furniture positions vary on average by $36$ cms because of the room, whereas for our baseline VAEs the furniture predicted positions vary on average by only $10$ cms. \begin{figure} \centering \includegraphics[scale=1]{imgs/coocurrence_heatmaps.png} \caption{\textit{Co-occurence heatmaps show the pairwise distribution of different furniture categories. Rows are arranged according to room type, while columns depict the co-occurrence statistics for scenes synthesized using the indicated method. Cell $ij$ in each heatmap represents the probability that furniture category $i$ and $j$ will co-occur in the same scene}} \label{fig: coocurrence_heatmaps.png} \end{figure} Further, we show in Figure \ref{fig: example generationed by autoregressive model}c that our model learns a smooth latent space which could be exploited to change the ``style" of the recommendations. To do this, we sample two latents $Z_1$ and $Z_2$ from the prior for the same room layout. We then interpolate along a straight line from $Z_1$ to $Z_2$ and visualize the corresponding furniture recommendations made by the GNN decoder, we observe a smooth transition from a room with two cabinets, a chair, and a light (No. I) to a room with a aesthetically different chair, table \& cabinet (No. IV). \textbf{Ablation studies.} We showed that our model performs better than baseline VAEs both qualitatively (Figure \ref{fig: qualitative comparison}) and quantitatively (Table \ref{Table: quantitative metrics}). We now show in Figure \ref{fig: coocurrence_heatmaps.png}, that the proposed autoregressive prior better captures the co-occurrence structure between categories than our baselines. Notice that for both baselines, beds are synthesized in all room types, whereas our model correctly learns that beds must be present only in bedrooms. We also analyzed matched furniture nodes for the trained model, that is, the solution to \eqref{eq: optimal ordering}. We found that the first bedroom item matched by our model is a nightstand/bed/light with probability $0.91$ and the first living room item matched is a coffee-table/sofa/light with probability $0.76$. This is interesting since human designers often start planning with these items. \section{Limitations and Conclusion} We have presented a latent-variable model for generating 3D indoor scenes given the room type and layout. While we show our model's ability to generate diverse scenes, it still lags behind purely autoregressive models in terms of quantitative metrics. It would be interesting to see if this gap can be closed using more expressive non-linear autoregressive priors; however the KL divergence cannot be computed analytically and the subsequent matching will not be quadratic. Moreover, the matching procedure introduced in this paper for training VAEs is novel and can be potentially useful in other permutation-invariant domains like sets. {\small \bibliographystyle{dinat}
{'timestamp': '2022-04-15T02:03:08', 'yymm': '2204', 'arxiv_id': '2204.04867', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04867'}
arxiv
\section{Introduction} Artificial Neural Networks (ANNs or NNs), which are inspired by human brain functionality, are composed of layers of neurons interlinked by synapses and can be used to approximate any computable function. The use of neural networks in safety-critical domains, such as autonomous driving \cite{kaiser2016towards}, healthcare \cite{rahimiazghadi2020hardware}, Internet of Things \cite{whatmough2018dnn} and security \cite{cao2015spiking}, necessitates an examination of their security vulnerabilities and risks. In real-world applications, attacking a neural network can result in undesirable or dangerous inferences (e.g., reduced accuracy or confidence in road sign identification during autonomous driving). These attacks can be launched during the training, manufacturing, or final application stages. Spiking Neural Networks (SNNs) \cite{maass1997networks} are the third generation of neural networks. SNNs are emerging as an alternative to Deep Neural Networks (DNNs) since they are biologically plausible, computationally powerful \cite{heiberg2018firing}, and energy-efficient \cite{merolla2014million}\cite{davies2018loihi}\cite{tavanaei2019deep}. However, very limited research exists on the the security of SNNs against adversarial attacks. Broadly, the attacks could be classified as: White Box attacks where an attacker has complete knowledge of the SNN architecture, and Black Box attacks where the attacker does not know the SNN architecture, network parameters or training data. Multiple prior works \cite{goodfellow2014explaining}\cite{kurakin2016adversarial}\cite{madry2017towards} investigate adversarial attacks on DNN e.g., undetectable modifications to input data, causing a classifier to mispredict with an increased probability and propose countermeasures. The vulnerabilities/attacks of SNNs under a white-box scenario e.g., sensitivity to adversarial examples and a robust training mechanism for defense is proposed \cite{bagheri2018adversarial}. A white-box fault injection attack is proposed \cite{venceslai2020neuroattack} for SNNs by employing adversarial input noise. In \cite{marchisio2020spiking}, a black-box approach is presented to generate adversarial input instances to induce misprediction in SNNs. However, the impact of voltage/power-based fault injection attacks are not studied in these white- and black-box SNN attack scenarios. In prior works, Voltage fault injection (VFI) techniques have been proven to be powerful side channel attacks for disrupting a system's execution flow. In {\cite{barenghi2012fault}}, a fault injection approach is described that underpowers cryptographic devices and introduces bit errors. In {\cite{bozzato2019shaping}}, novel VFI techniques are proposed to inject glitches in popular microcontrollers from manufacturers such as, STMicroelectronics and Texas Instruments. In {\cite{zussa2013power}}, timing constraint violations were introduced in FPGAs by using a negative power supply glitch attack. Laser-based injection has also been proposed for inducing local voltage and clock glitching attacks. However, such studies are not performed for SNN. \begin{figure} [t] \vspace{-3mm} \begin{center} \includegraphics[width=.45\textwidth]{fig/threat_model3.png} \end{center} \vspace{-4mm} \caption{Threat model for power-based attacks on SNN.} \label{threat_model} \vspace{-4mm} \end{figure} \textbf{Proposed Threat Model:} There is limited amount of research on SNN attacks (except adversarial input-based attacks). Similar to classical systems, the adversary can manipulate the supply voltage or inject voltage glitches in the SNN systems. This is likely for, (i) an external adversary who has physical possession of the device or the power port, (ii) an insider adversary with access to power port or laser gun to inject the fault. In this paper, we study a total of five attacks under both black box and white box scenarios. \emph{Black Box Attack: }In this scenario (Attack-5 in Section {\ref{BB}}), the adversary affects the power supply of the entire system to (i) corrupt spiking amplitude of SNN neuron input and, (ii) disrupt SNN neuron's membrane functionality. To launch this attack, the adversary does not need to know the SNN architecture but needs the control of the external power supply ($V_{DD}$). Fig. {\ref{threat_model}} shows a high-level schematic of the proposed threat model against an SNN, where an input image to be classified is converted to spike trains and fed to the neuron layers. The objective is to degrade accuracy of the classified digit. Note that the neuron layers, neurons, and interconnections shown in Fig. {\ref{threat_model}} just illustrate the proposed threat model. The SNN architecture actually implemented in this paper is explained in Section {\ref{exp_setup}}. \begin{figure*} [t] \vspace{-1mm} \begin{center} \includegraphics[width=.92\textwidth]{fig/ind_neurons3.png} \end{center} \vspace{-3mm} \caption{(a) Axon Hillock circuit; (b) Voltage amplifier I\&F circuit; (c) Expected membrane voltage and output voltage of Axon Hillock neuron; (d) Expected membrane voltage voltage of I\&F neuron.} \label{ind_neurons} \vspace{-3mm} \end{figure*} \emph{White Box Attacks:} In this scenario, we consider following cases (details in Sections {\ref{WB-1}} and {\ref{WB-2}}) where the adversary is able to individually attack SNN layers and peripherals through localized laser based power fault injection, (i) Attack 1 where only peripherals e.g., input current drivers are attacked, (ii) Attack 2 and 3 where individual SNN layers attacked partially to fully i.e., 0\%-100\%, and (iii) Attack 4 where all SNN layers affected (no peripherals). \textbf{Contributions}: In summary, we, (a) present detailed analysis of two neuron models namely, Axon Hillock neuron and voltage I\&F amplifier neuron under global, local and fine-grain supply voltage variation; (b) propose five power-based attack models against SNN designs under black box and white box settings; (c) analyze impact of proposed attacks for digit classification tasks; and, (d) propose defenses and a novel detection technique. In the remaining of the paper, Section II presents background on SNNs and neuron design, Section III proposes the attack models, Sections IV and V present the analysis of the attack and countermeasures, respectively and finally, Section VI draws the conclusion. \section{Background} In this section, we present the overview of SNN and neuron designs \cite{indiveri2011neuromorphic} that have been used in this paper. \subsection{Overview of Spiking Neural Network} SNNs are composed of layers of spiking neurons that are interconnected together by synaptic weights (Fig. \ref{threat_model}). The neurons between adjacent layers exchange information in the form of spike trains. The timing of the spikes and the strength of the synaptic weights between neurons are critical parameters in SNN operation. Each neuron includes a membrane, whose potential increases when the neuron receives an input spike. The neuron \emph{fires} an output spike when this membrane potential crosses a pre-determined threshold. Various neuron models such as, I\&F, Hodgkin-Huxley, and spike response exist with different membrane and spike-generation operations. In this work, we have implemented two flavors of I\&F neuron to showcase the power-based attacks. \subsection{Neuron Design and Implementation} \label{SNN} In this work, we implement, simulate, and analyze all neuron models on HSPICE using PTM 65nm technology. \subsubsection{Axon Hillock Spiking Neuron Design} The Axon Hillock circuit \cite{mead2012analog} (Fig. \ref{ind_neurons}a) consists of an amplifier block implemented using two inverters in series (shown in dotted gray box). The input current ($I_{in}$) is integrated at the neuron membrane capacitance ($C_{mem}$), and the analog membrane voltage ($V_{mem}$) rises linearly until it crosses the amplifier's threshold. Once it reaches this point, the output ($V_{out}$) switches from `0' to $V_{DD}$. This $V_{out}$ is fed back into a reset transistor ($M_{N1}$) and activates a positive feedback through the capacitor divider ($C_{fb}$). Another transistor ($M_{N2}$), controlled by $V_{pw}$, determines the reset current. If reset current $>$ $I_{in}$, $C_{mem}$ is discharged until it falls to the amplifier's threshold. This causes $V_{out}$ to switch from $V_{DD}$ to `0'. The output remains `0' until the entire cycle repeats. Fig. \ref{ind_neurons}c depicts the expected results of $V_{mem}$ and $V_{out}$. In this paper, the value of membrane capacitance ($C_{mem}$) and the feedback capacitance ($C_{fb}$) of 1pF are used. For experimental purposes, the input current spikes with an amplitude of 200nA, a spike width of 25ns, and a spike rate of 40MHz are generated through the current source ($I_{in}$). The $V_{DD}$ of the design is set to 1V. Fig. \ref{axon_hillock_sim} shows the simulation results of the input current spikes ($I_{in}$) and the corresponding membrane and the output voltage ($V_{out}$). \begin{figure} [t] \vspace{-1mm} \begin{center} \includegraphics[width=.27\textwidth]{fig/axon_hillock_sim.png} \end{center} \vspace{-3mm} \caption{Simulation result of Axon Hillock spike generation showing input current ($I_{in}$) (top plot), the membrane voltage ($V_{mem}$) and the output voltage ($V_{out}$) (bottom plot).} \label{axon_hillock_sim} \vspace{-3mm} \end{figure} \begin{figure} [t] \vspace{-1mm} \begin{center} \includegraphics[width=.265\textwidth]{fig/IF_sim.png} \end{center} \vspace{-3mm} \caption{Simulation result of voltage amplifier I\&F neuron spike generation showing input current ($I_{in}$) (top plot and zoomed-in), and the membrane voltage ($V_{mem}$) (bottom plot).} \label{IF_sim} \vspace{-5mm} \end{figure} \begin{figure*} [t] \centering (a) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/current_driver2.png} \vspace{-9mm} \caption{} \label{cur_driver} \end{subfigure \hspace{0mm} (b) \hspace{0mm} \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/cur_dri_amp.jpg} \vspace{-11mm} \caption{} \label{cur_driver_amp} \end{subfigure}% \hspace{0mm} (c) \hspace{-2mm} \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/SNN_both_amp.png} \vspace{-11mm} \caption{} \label{snn_both_amp} \end{subfigure \vspace{-0mm} \caption{(a) Current driver circuit of the SNN neurons with design details; (b) Change in current driver output spike ($I_{in}$) amplitude with change in $V_{DD}$; and (C) Effect of input spike amplitude on SNN output time-to-spike for Axon Hillock neuron and voltage amplifier I\&F neuron.} \label{snac1} \vspace{-2mm} \end{figure*} \subsubsection{Voltage Amplifier I\&F Neuron Design} The voltage amplifier I\&F circuit \cite{van2001building} (Fig. \ref{ind_neurons}b) employs a 5-transistor amplifier that offers better control over the threshold voltage of the neuron. This design allows the designer to determine an explicit threshold and an explicit refractory period. The threshold voltage ($V_{thr}$) of the amplifier employed is set to 0.5V and the $V_{DD}$ is set to 1V. The neuron membrane is modeled using a 10pF capacitance ($C_{mem}$) and the membrane leakage is controlled by transistor $M_{N4}$ with a gate ($V_{lk}$) voltage of 0.2V. The excitatory input current spikes ($I_{in}$) integrates charge over $C_{mem}$ and the node voltage at $V_{mem}$ rises linearly. Once $V_{mem}$ crosses $V_{thr}$, the comparator output switches from `0' to $V_{DD}$. This output is fed into 2 inverters in series, where the output of the first inverter is used to pull up $V_{mem}$ to $V_{DD}$ and the output of the second inverter is used to charge a second capacitor ($C_{k}$) of 20pF. The node voltage of $C_{k}$ is fed back to a reset transistor $M_{N1}$. When this node voltage is high enough, $M_{N1}$ is activated and $V_{mem}$ is pulled down to `0' and remains LOW until $C_{k}$ discharges below the activation voltage of $M_{N1}$. For experimental purposes, the input current spikes with an amplitude of 200nA, a spike width of 25ns, and a time interval of 25ns between consecutive spikes are generated through the current source ($I_{in}$). Fig. \ref{ind_neurons}d depicts the expected results of $V_{mem}$. Fig. \ref{IF_sim} shows the simulation results of input current spikes ($I_{in}$) and corresponding membrane voltage ($V_{out}$). \begin{figure*} [t] \centering (a) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/snn_vdd_thresh.png} \vspace{-11mm} \caption{} \label{snn_thresh_vdd} \end{subfigure \hspace{0mm} (b) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/ah_vdd_spike.png} \vspace{-11mm} \caption{} \label{spike_axon_vdd} \end{subfigure}% \hspace{0mm} (c) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/if_vdd_spike.png} \vspace{-11mm} \caption{} \label{spike_IF_vdd} \end{subfigure \vspace{-0mm} \caption{(a) Change in SNN membrane threshold with change in $V_{DD}$; Effect of $V_{DD}$ change on SNN output time-to-spike for (b) Axon Hillock neuron; (c) Voltage amplifier I\&F neuron.} \label{snac2} \vspace{-2mm} \end{figure*} \subsection{SNN Current Driver Design} \label{cur_drive} A current driver provides the input current spikes to the neuron e.g., image input converted to current spike train. We have designed a current source based on a current mirror (Fig. \ref{cur_driver}) where $V_{GS}$ of $M_{N2}$ and $M_{N3}$ are equal causing both transistors to pass the same current. The sizes of the $M_{N2}$ and $M_{N3}$ transistors and the resistor ($R_1$) are chosen to provide a current of amplitude 200 nA. Since the input current of the neuron is modeled as spikes, we have added the $M_{N1}$ transistor to act as a switch that is controlled by incoming voltage spikes ($V_{ctr}$) from other neurons. \section{Neuron Attack Models} \label{attack_models} In this section, we describe the power-based attacks and examine the impact of $V_{DD}$ manipulation on crucial circuit components and parameters of the previously explained SNNs. \subsection{Attack Assumptions} \label{attack_assumptions} We have investigated the power attacks under the following cases: \subsubsection{Case 1: Separate Power Domains} The current drivers and neurons (of the entire SNN) are assumed to be operated on separate $V_{DD}$ domains. This is possible if the neurons, synapses and peripherals have distinct supply voltages e.g., if the neuron and peripherals are CMOS and the synapses are based on memristers. This case enables us to study the effect of $V_{DD}$ modulation on individual components. \subsubsection{Case 2: Single Power Domain} The entire SNN system, including current drivers and neurons share the same $V_{DD}$. This is a likely scenario if the whole circuit is CMOS based. \subsubsection{Case 3: Local Power Glitching} The adversary has fine grain control of the $V_{DD}$ inside a voltage domain for both separate and single power domain cases. For example, adversary can use a focused laser beam to cause localized voltage glitching. \subsection{SNN Input Spike Corruption} \label{snac1_des} The input current spikes of each neuron are fed using a current driver as described in Section \ref{cur_drive}. The driver is designed with $V_{DD}$ = 1V and outputs SNN input current spikes of 200nA amplitude and 25ns spike width. An adversary can attack a normal driver operation by modulating the $V_{DD}$. Fig. \ref{cur_driver_amp} shows the effect of modulating the $V_{DD}$ from 0.8V to 1.2V (corresponding to a -/+ 20\% change). The corresponding output spike amplitude ranges from 136nA for 0.8$V_{DD}$ (-32\% change) to 264nA for 1.2$V_{DD}$ (+32\% change). We subjected our neuron designs under these input spike amplitude modulations while keeping the input spiking rate constant at 40MHz. Fig. \ref{snn_both_amp} shows the effect on output spike rate for the Axon Hillock neuron where the time-to-spike ($V_{out}$) becomes faster by 24.7\% under $V_{DD}$=1.2V and $I_{in}=264nA$ and becomes slower by 53.7\% under $V_{DD}$=0.8V and $I_{in}=136nA$. Similarly, Fig. \ref{snac1}c also shows the effect on output spike rate for the voltage amplifier I\&F neuron where the time-to-spike ($V_{out}$) becomes faster by 6.7\% under $V_{DD}$=1.2V and $I_{in}=264nA$ and becomes slower by 14.5\% under $V_{DD}$=0.8V and $I_{in}=136nA$. \begin{figure*} [t] \centering (a) \begin{subfigure}[b]{0.57\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/Bindsnet_imp3.png} \vspace{-5mm} \caption{} \label{bindsnet_imp} \end{subfigure \hspace{0mm} \hspace{0mm} (b) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/all_drivers_affected2.png} \vspace{-11mm} \caption{} \label{theta_change} \end{subfigure}% \vspace{-0mm} \caption{(a) Implemented 3 layer SNN \cite{diehl2015fast}; (b) Effect of current driver corruption (Attack 1) on MNIST classification accuracy.} \label{binds_theta} \vspace{-2mm} \end{figure*} \subsection{SNN Threshold Manipulation} \label{snac2_des} The adversary can also corrupt normal SNN operation using the externally supplied $V_{DD}$ which can modulate the SNN's membrane threshold voltage. In the ideal condition, the $V_{DD}$ is 1V and the threshold voltage of both the Axon Hillock neuron and the I\&F neuron are designed to be 0.5V. Fig. \ref{snn_thresh_vdd} shows that the membrane threshold voltage changes with $V_{DD}$. In case of the Axon Hillock neuron the change in threshold ranges from -17.91\% for $V_{DD}=0.8V$ to +16.76\% for $V_{DD}=1.2V$. When $V_{DD}$ is modified, the switching threshold of the inverters in the Axon Hillock neuron is also proportionally affected. A lower (higher) $V_{DD}$ lowers (increases) the switching threshold of the inverters and leads to a faster (slower) output spike. Similarly, the change in threshold ranges from -18.01\% to +17.14\% when $V_{DD}$ is swept from 0.8V to 1.2V for the voltage amplifier I\&F neuron. Note that the change in threshold for the I\&F neuron is due to $V_{thr}$ signal (Fig. \ref{snn_thresh_vdd}) which is derived using a simple resistor-based voltage division of $V_{DD}$. Therefore, $V_{thr}$ scales linearly with $V_{DD}$. The change in membrane threshold modulates the output spike rate of the affected SNN neurons. Fig. \ref{spike_axon_vdd} and Fig. \ref{spike_IF_vdd} show the change in time-to-spike under $V_{DD}$ manipulation while the input spikes ($I_{in}$) to the neuron are held at a constant amplitude of 200nA and a rate of 40MHz. The time-to-spike for Axon Hillock ranges from 17.91\% faster to 16.76\% slower. Similarly, the time-to-spike for I\&F neuron ranges from 17.05\% faster to 23.53\% slower. \section{Analysis of Power Attacks on SNN } \label{SNN_model} This section describes the effect of power-oriented attacks on the image classification accuracy under the attack assumptions from Section {\ref{attack_assumptions}}. \subsection{Experimental Setup} \label{exp_setup} We have implemented the Diehl\&Cook SNN \cite{diehl2015fast} using the BindsNET \cite{hazan2018bindsnet} network library with PyTorch Tensor to test the effect of power-based attacks. The SNN is implemented with 3 neuron layers (Fig. \ref{bindsnet_imp}), namely Input layer, Excitatory Layer (EL), and Inhibitory Layer (IL). We employ this SNN for digit classification of the MNIST dataset which consists of digit images of pixel dimension 28$\times$28. Each input image is converted to Poisson-spike trains and fed to the Excitatory neurons in an all-to-all connection, where each input spike is fed to each Excitatory neurons. The Excitatory neurons are 1-to-1 connected with the Inhibitory neurons (Fig. \ref{bindsnet_imp}). Each neuron in the Inhibitory layer is in turn connected to all the neurons in the Excitatory layer, except the one it received a connection from. The architecture performs supervised learning. For our experiments, the EL and IL have 100 neurons each and all experiments are conducted on 1000 Poisson-encoded training images with fixed learning rates of 0.0004 and 0.0002 for pre-synaptic and post-synaptic events, respectively. The batch size is set to 32 and training samples are iterated only once as configured in \cite{hazan2018bindsnet}. Additional details on the neuron layers, learning method, and SNN parameters can be found in {\cite{hazan2018bindsnet}}. The baseline classification accuracy for attack-free SNN is 75.92\% with 1000 training images. \subsection{Input Spike Corruption } \label{WB-1} In Section \ref{snac1_des}, it is shown that the adversary can manipulate the input spike amplitudes for the SNN neurons. This in turn changes the membrane voltage by a different rate for the same number of input spikes. This manipulation of the rate of change of membrane voltage changes the time-to-spike for the neuron (as shown in Fig. \ref{snn_both_amp}). \textbf {Attack 1: }In order to translate this effect to our BindsNET SNN implementation, we have modified the rate of change of the neuron's membrane voltage using variable \emph{theta} which specifies the voltage change in the neuron membrane for each input spike. Fig. \ref{theta_change} shows the corresponding change in MNIST digit classification accuracy. Under the worst case \emph{theta} change of -20\%, classification accuracy decreases by 1.5\%. It is seen that the classification accuracy is not adversely affected by increasing/decreasing \emph{theta} since the accuracy remains within +/-2\% of the baseline accuracy. Note that this is a \emph{white box} attack since the adversary requires the location of the current drivers within the SNN (possible by invasive reverse engineering of a chip) to induce the localized fault. \begin{figure*} [t] \centering (a) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/only_exc_affected2.png} \vspace{-11mm} \caption{} \label{EL_only} \end{subfigure \hspace{0mm} (b) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/only_inh_affected2.png} \vspace{-11mm} \caption{} \label{IH_only} \end{subfigure}% \hspace{0mm} (c) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/all_neurons_affected3.png} \vspace{-11mm} \caption{} \label{EL_IH_both} \end{subfigure \vspace{-0mm} \caption{Classification accuracy trend with SNN membrane threshold for (a) Excitatory Layer only (Attack 2); (b) Inhibitory Layer only (Attack 3); and (c) Both Excitatory Layer and Inhibitory Layer (Attack 4);} \label{snac2_sims} \vspace{-3mm} \end{figure*} \begin{figure*} [t] \centering (a) \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/all_system_affected2.png} \vspace{-11mm} \caption{} \label{all_affected} \end{subfigure \hspace{0mm} (b) \hspace{0mm} \begin{subfigure}[b]{0.24\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/defense_cur_driver2.png} \vspace{-9mm} \caption{} \label{def_cur_driver} \end{subfigure}% \hspace{0mm} (c) \hspace{0mm} \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/thresh_control4.png} \vspace{-11mm} \caption{} \label{axon_fixed} \end{subfigure \vspace{-0mm} \caption{(a) Change in classification accuracy with $V_{DD}$ change for entire system (Neurons and peripherals); (b) Robust SNN current driver (constant output spike amplitude); and (c) Axon Hillock Neuron: Effect of $M_{P1}$'s W/L on threshold voltage change during $V_{DD}$ manipulation. } \label{snapb_defense} \vspace{-3mm} \end{figure*} \begin{figure*} [t] \centering (a) \begin{subfigure}[b]{0.18\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/comparator.png} \vspace{-8mm} \caption{} \label{comparator} \end{subfigure \hspace{0mm} (b) \hspace{0mm} \begin{subfigure}[b]{0.36\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/dummy_neuron.png} \vspace{-5mm} \caption{} \label{dummy_neuron} \end{subfigure}% \hspace{0mm} (c) \hspace{0mm} \begin{subfigure}[b]{0.27\textwidth} \centering \includegraphics[width=0.99\linewidth]{fig/dymmy_neuron_sim2.png} \vspace{-11mm} \caption{} \label{dummy_neuron_sim} \end{subfigure \vspace{-0mm} \caption{(a) Comparator designed and implemented in the Axon Hillock Neuron to mitigate threshold variation.; (b) $V_{DD}$ change detection using dummy neuron; and (c) Effect of $V_{DD}$ on dummy neuron output. } \label{new_defense} \vspace{-5mm} \end{figure*} \subsection{SNN Threshold Manipulation } \label{WB-2} In Section \ref{snac2_des}, it is shown that the adversary can manipulate the membrane threshold voltages of the SNN neurons. This manipulation of the membrane threshold voltage ($V_{thr}$) affects classification accuracy. We have manipulated the threshold values of neurons in each layer from -20\% to +20\% to introduce power attacks in the BindsNET SNN. This range has been selected in line with the threshold variation observed in Fig. \ref{snn_thresh_vdd}. The change in threshold has different effects on neurons from the EL versus IL. Therefore, we analyze individual effect of each neuron layer's on classification accuracy. Finally, we analyze the response for all the layers on the classification accuracy. Note, Attacks 2 to 5 are \emph{white box} attacks since the adversary requires the location of the individual SNN layers (can be obtained from the layout) to induce the localized faults. \textbf{Attack 2:} In this case, we subject only the EL to membrane threshold variation to study its individual effect on classification accuracy. This attack is possible when, (i) each neuron layer has their own voltage domain and the adversary injects a laser-induced fault, (ii) neuron layers share voltage domain but the local fault injection in one layer does not propagate to other layers due to the capacitance of the power rail. Various fraction of neurons in this layer, ranging from 0\% to 100\% are subject to -20\% to +20\% threshold change This analysis is performed to model the situation when adversary has fine grain control of the $V_{DD}$ inside a voltage domain e.g., using local voltage glitching attack that affects only a section of neurons. This is possible in systems which have thousands of neurons per layer that may be physically isolated due to interleaving synapse arrays. Fig. \ref{EL_only} shows the corresponding change in the classification accuracy. It is noted that classification accuracy is equal to or better than the baseline accuracy for threshold changes as long as $\leq$90\% of the layer is affected. For the worst case threshold change of -20\%, the classification accuracy degrades by 7.32\% when 100\% of the EL is affected. In summary, attacking the EL alone has a relatively low impact on the output accuracy. This is intuitive since the effect of any corruption in the EL can be recovered in the following IL. \textbf{Attack 3:} In this attack, we subject only the IL to membrane threshold change. Various fraction of neurons in this layer ranging from 0\% to 100\%, are subject to -20\% to +20\% threshold change. Fig. \ref{IH_only} shows the corresponding change in classification accuracy. It is noted that classification accuracy degrades below the baseline accuracy for 3 out of 4 cases of threshold change and for all fractions of IL affected. A worst case degradation of 84.52\% below the baseline accuracy (observed at -20\% threshold change at 100\% of IL affected) is noted. In summary, attacking the IL has a more significant effect on output accuracy compared to attacking the EL alone. This is understandable since IL is the final layer before the output. Therefore, any loss in learning cannot be recovered. \textbf{Attack 4:} In this attack, we subject 100\% of both the EL and the IL to the same membrane threshold change. Fig. \ref{EL_IH_both} shows the variation in accuracy with the threshold for both the layers of neurons. It is seen that the classification accuracy falls sharply as the membrane threshold of both the layers decreases below the baseline. A worst case accuracy degradation of -85.65\% below baseline accuracy is observed when the membrane threshold is reduced by 20\%. \subsection{Input Spike Corruption and Threshold Manipulation} \label{BB} \textbf{Attack 5: } This is a \emph{black box} attack where the adversary does not need to know the internal architecture of the current driver or the SNN neurons. Here we assume that the power supply is shared among all the components of the SNN system, including the current drivers and all of the neuron layers. Manipulating the $V_{DD}$ changes both membrane voltage per spike (\emph{theta}) and the threshold voltages ($V_{thr}$) of the SNN neurons. Fig. \ref{all_affected} shows that the worst case accuracy degradation is -84.93\%. \subsection{Summary of Power Attack Analysis} From our analysis, we conclude following: \subsubsection{SNN Assets} These include: (a) spike rate and amplitude, (b) neuron membrane threshold, (c) membrane voltage change per spike. Other assets (not studied in this paper) are strength of synaptic weights between neurons and the SNN learning rate. \subsubsection{SNN Vulnerabilities} $V_{DD}$ manipulation, (a) generation of spikes of lower/higher amplitude than nominal value by the neuron's input current driver, (b) lowers/increases neuron's membrane threshold. Both these vulnerabilities cause affected neurons to spike faster/slower. \subsubsection{Attack Models} Manipulation of global and local fine-grained power supply corrupts critical training parameters. Attacks not covered in this paper are, (a) generation of adversarial input samples to cause mis-classification, (b) fault injection into synaptic weights, (c) noise injection in input samples to attack specific neurons. \section{Defenses} \subsection{Robust Current Driver Design} We propose a current driver that produces neuron input spikes of constant amplitude (Fig. {\ref{def_cur_driver}}). Here the negative input terminal of the op-amp is forced to a reference voltage that leads the positive terminal to be virtually connected to the reference voltage ($V_{Ref}$). The current through {$M_{P1}$} transistor is {$V_{Ref}/R_{1}$} and the negative feedback of the amplifier forces the gate voltage of {$M_{P1}$} to satisfy the current equation of the transistor. Since {$V_{GS}$} and {$V_{th}$} of {$M_{P1}$} and {$M_{P2}$} transistors are same, {$M_{P2}$} passes the same current as {$M_{P1}$}. Note, we have used long channel transistors to reduce the effect of channel length modulation. The power overhead incurred for the proposed robust current driver compared to the unsecured version is 3\%. Note that the area overhead of robust driver is negligible compared to the area of unsecured driver since the neuron capacitors occupy the majority of the area. \subsection{Resiliency to Threshold Voltage Variation} \subsubsection{Voltage Amplifier I\&F Neuron} In order to prevent $V_{thr}$ from being corrupted due to $V_{DD}$ change, it can be generated using a bandgap voltage reference that produces a constant voltage irrespective of power and temperature variations. A bandgap circuit is proposed in {\cite{sanborn2007sub}} that generates a constant $V_{ref}$ signal with a output variation of +/-0.56\% for supply voltages ranging from 0.85V to 1V at room temperature. A similar design can be used for our proposed I\&F neuron that require a constant external $V_{thr}$ signal. Since the $V_{thr}$ variation (+/-0.56\%) under $V_{DD}$ manipulation is negligible, the classification accuracy degradation reduces to $\sim$0\%. For our experimental 200-neuron implementation, the area overhead incurred by the bandgap circuit is 65\%. But this can be significantly reduced if the banggap circuit is shared with other components of the chip and if the SNNs are implemented with 10s of thousands of neurons as required by various applications. \subsubsection{Axon Hillock Neuron} We propose following approaches,~\\ \textbf{Neuron transistor sizing: } In case of the Axon Hillock neuron (Fig. \ref{ind_neurons}a), the membrane threshold is determined by the $V_{DD}$ and the design of the first inverter (transistors $M_{P1}$ and $M_{N3}$). Simulations indicate that classification accuracy is affected mostly by lowering the membrane threshold as shown in Fig. \ref{EL_IH_both}. We increased the sizing of the PMOS transistor $M_{P1}$ to limit the threshold change due to $V_{DD}$. Fig. \ref{axon_fixed} shows that increasing the W/L ratio mitigates the reduction in threshold changes under lower $V_{DD}$. At 0.8V, the threshold change observed for W/L ratio of 32:1 is -5.23\% compared to -18.01 \% for the baseline sizing. The corresponding degradation in classification accuracy at $V_{DD}=0.8V$ is only 3.49\% which is a significant improvement compared to the 85.65\% degradation observed previously. At $V_{DD}=1.2V$, the threshold change increases by 3.2\% for W/L ratio of 32:1 and the corresponding accuracy degradation only increases by 1.4\%. For the upsized neuron, the power overhead observed is 25\% while the area overhead is negligible since majority of neuron area is occupied by the two 1pF capacitors that remain unchanged in the new design. \textbf{Comparator implementation:} We replace the first inverter in the Axon Hillock neuron with a comparator that employs $V_{thr}$ generated by a bandgap circuit {\cite{sanborn2007sub}} as the reference voltage to eliminate the effect of $V_{DD}$ variation on inverter switching threshold. The rest of the design remains the same. Fig. {\ref{comparator}} shows the implemented comparator which ensures that the threshold voltage is not determined by the sizing of the inverter transistors or the $V_{DD}$. Instead, it depends on the input biasing of the proposed design. The IN+ and IN- bias is set to 600mV and $V_B$ is set to 400mV. The power overhead incurred is 11\% and the area overhead is negligible since the 1pF capacitors occupy majority of the neuron area. \subsection{Detection of $V_{DD}$ Change} In addition to robust neuron design, we also propose a technique to voltage glitching attack directed at an individual neuron layer. This is done by introducing a dummy neuron within each neuron layer (shown in Fig. {\ref{dummy_neuron}}). In our design, the input of the dummy neuron is connected to a current driver that constantly drives spiking inputs of 200nA amplitude and spike width of 100ns. The spikes repeat every 200ns and does not depend on the spiking of the neurons from the previous layer. Under ideal conditions, the number of output spikes for a fixed sampling period for each dummy neuron should be identical. Fig. {\ref{dummy_neuron_sim}} shows the effect of of $V_{DD}$ change on the dummy neuron's output for both the I\&F and AH neurons over a sampling period of 100ms. It is seen that for both neurons, the number of dummy output spikes differs by $\geq 10\%$ as compared to the baseline. Note that this method is only effective against localized $V_{DD}$ change. For the SNN implemented in Section {\ref{SNN_model}}, the area and power overhead for the proposed dummy neuron detection mechanism is $\sim$ 1\% each. \balance \section{Conclusions} We propose one \emph{black box} and {four} \emph{white box} attacks against commonly implemented SNN neuron circuits by manipulating its external power supply or inducing localized power glitches. We have demonstrated power-oriented corruption of critical SNN training parameters. We introduced the attacks for SNN-based digit classification tasks as test cases and observed significant degradation in classification accuracy. Finally, we proposed defenses against the proposed power-based attacks. \section*{Funding} This work is supported by SRC (2847.001 and 3011.001) and NSF (CNS-1722557, CCF-1718474, DGE-1723687, DGE-1821766, OIA-2040667 and DGE-2113839). \bibliographystyle{ieeetr} \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]{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{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]{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}
{'timestamp': '2022-04-12T02:26:55', 'yymm': '2204', 'arxiv_id': '2204.04768', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04768'}
arxiv
\section{BigScience Pretraining} \label{appendix:bigs-pretraining} The BigScience multilingual autoregressive language model (LM) uses the GPT architecture and the causal language modeling objective. Its tokenizer is the byte-level BPE with a vocab size of 130,001. For pretraining, it uses the Adam optimizer with a batch size 512, a learning rate of 2e-4 with cosine decay over 16,927,083 samples and warmup over 216,320 samples, weight decay of 0.1, and gradient clipping of 1.0. Table~\ref{tab:bigscience-pretraining-oscar} reports the statistics of the deduplicate subcorpora from OSCAR \citep{ortiz:oscar_2019} used for pretraining the BigScience model. \begin{table}[ht] \small \centering \begin{tabular}{lrr} \toprule Language & Number of Words & Sampling Probability \\ \midrule Indonesian & 2,394,957,629 & 0.0554 \\ Basque & 45,359,710 & 0.0184 \\ Vietnamese & 5,577,159,843 & 0.0684 \\ Chinese & 6,350,215,113 & 0.1339 \\ Urdu & 218,030,228 & 0.0267 \\ Spanish & 218,030,228 & 0.1118 \\ Catalan & 729,333,440 & 0.0395 \\ Portuguese & 10,751,156,918 & 0.0867 \\ French & 23,206,776,649 & 0.1110 \\ English & 215,841,256,971 & 0.2107 \\ Hindi & 745,774,934 & 0.0398 \\ Arabic & 3,171,221,354 & 0.0638 \\ Bengali & 363,766,143 & 0.0339 \\ \bottomrule \end{tabular} \caption{Statistics for OSCAR deduplicated subcorpora of 13 languages.} \label{tab:bigscience-pretraining-oscar} \end{table} \section{Language Adaptation Training Details} \label{appendix:language-adaptation-training} For all the language adaptation strategies, we train by using the AdamW optimizer with default parameters, batch size of 8, learning rate of $1e-3$ with linear decay, and maximum sequence length of 1,024. It takes around 30 hours to complete the training on a single V100 GPU machine. \section{Relationship between NLI Task Performance and Adapter Capacity} We convert the reduction factor of language adapters to total adapter capacity and plot the NLI performance against it in Figure~\ref{fig:nli-adpt-capacity}. The figure shows comparable performance across all NLI evaluation settings for both German and Korean languages even with small adapter capacity. \begin{figure}[!ht] \includegraphics[width=8cm]{assets/nli_adpt_capacity.pdf} \caption{Graph of test accuracy for NLI against total adapter capacity (after applying reduction factor) using the Embedding-and-Adapters adaptation.} \label{fig:nli-adpt-capacity} \end{figure} \section{Introduction} Pretrained multilingual language models (LMs) have enabled cross-lingual transfer \cite{artetxe-etal-2020-cross, conneau-etal-2020-emerging, k-etal-2021-analyzing}. While several works suggest that such knowledge transfer goes beyond just vocabulary sharing across languages \cite{artetxe-etal-2020-cross, k-etal-2021-analyzing}, others have shown that the models' performance is sensitive to the quality of the tokenization it relies on \cite{pfeiffer-etal-2021-unks}. Moreover, the quality of knowledge transfer can degrade for unseen languages, especially when the scripts are unknown to the model \cite{muller-etal-2021-unseen}. Data availability, but also the \textit{curse of multilinguality} \cite{conneau-etal-2020-unsupervised} makes training a single model covering all the languages challenging: there is a trade off between the number of languages in pretraining data, model capacity and the downstream performance for each individual language. Finally, it is hard to anticipate any potential usage of pretrained LM in advance, hence it is important to study \textit{a posteoriori} adaptation to new tasks/languages. Recently proposed methods include \textbf{continual pretraining} of the model (restricted to the embedding layer training only in some cases) \cite{artetxe-etal-2020-cross,chau-etal-2020-parsing,muller-etal-2021-unseen,zhang-etal-2020-multi-stage,wang-etal-2020-extending}, or training of \textbf{language-specific adapters} \cite{pfeiffer-etal-2020-mad, pfeiffer-etal-2021-adapterfusion, pfeiffer-etal-2021-unks, philip-etal-2020-monolingual, ustun-etal-2021-multilingual, berard-2021-continual} for the target language. The core motivation behind these methods is to benefit from knowledge transfer encoded in the pretrained LM for the new language processing at a small computational cost (compared to full model retraining) . In this work, we aim at better understanding the trade-offs between the amount of compute and the final downstream task performance. Specifically, we study the impact of the following three factors: original pretraining steps, adaptation strategies, and adapters' capacity on the Natural Language Inference (NLI) task. As part of the initiative of BigScience, we experiment with its multilingual LM, which currently only supports 13 languages. We investigate how researchers could adapt BigScience's full-open-access multilingual models to their languages of interest. Moreover, BigScience open source its intermediate pretraining checkpoints, therefore we also study how does the adaptability to new language changes with the amount of pretraining. Our main findings are: (1) the most promising strategy is training of the embedding layers and adapters simultaneously; (2) position encoding is an important component to adapt; (3) pretraining steps benefit zero-shot performance; (4) adaptation to low-resource languages can be done with low parameter budget. \section{Background and Related Work} Most of the works investigating extension of pretrained models to new languages consider models such as BERT \cite{devlin-etal-2019-bert} and XLM-R \cite{conneau-etal-2020-unsupervised} that were pretrained to 100+ languages with Masked Language Modeling (MLM) objective. \citet{artetxe-etal-2020-cross, pfeiffer-etal-2021-unks} demonstrate that it is possible to add new language to these models by training new embedding layer. \citet{muller-etal-2021-unseen} continues training the pretrained mBERT on the new language data, and finds that transliteration of languages using non-latin script boosts performance on these languages. \citet{berard-2021-continual} adds new languages into pretrained multilingual NMT model by training embedding layer and adapter layers. It shows that higher adaptation cost is required for new target languages (as opposed to new source languages). Closest to our work \cite{ebrahimi-kann-2021-adapt} studies different approaches (i.e., continued pretraining, vocabulary expansion and adapter layers) allowing to extend XLM-R model to 1600 languages. They conclude that continued pretraining is the most promising direction. However, the cost of such pretraining will grow with the size of the pretrained model and can be quite prohibitive for many researchers working with low-resource languages. Our work aims to compare lightweight strategies of adaptation to new language (embedding layer training and adapter layers) across the following previously unstudied dimensions: we consider the (1) adaptation parameter budget and (2) intermediate pretraining checkpoints by analyzing how they impact autoregressive model's adaptability to new languages. \section{Experimental settings} \subsection{BigScience Pretrained Multilingual Language Model} BigScience open-sources one of its pretrained multilingual autoregressive LMs\footnote{https://huggingface.co/bigscience/tr5b-1B3-multilingual-alpha-checkpoints/tree/main} \cite{bigscience_engineering} that relies on transformer architecture with 24 decoder layers, 16 attention heads, embedding dimension of 2048, feed forward layer with dimensionality of 8192, and 1.3B parameters. This model is trained with Next Word Prediction objective (\textit{aka} GPT-style). It is pretrained on OSCAR deduplicated subcorpora \citep{ortiz:oscar_2019} for the following thirteen languages for a total of training 400B tokens: Indonesian, Basque, Vietnamese, Chinese, Urdu, Spanish, Catalan, Portuguese, French, English, Hindi, Arabic, and Bengali. See Appendix~\ref{appendix:bigs-pretraining} for further model pretraining details. In our experiments, we use the model checkpoint saved after 12,000, 100,500, and 118,500 pretraining steps (final checkpoint). \subsection{New Languages and Data} The need for adaptation of pretrained multilingual LM to new languages typically raises for low-resource languages for three reasons: first, the lack of the available data for such languages; second, the lack of the computational resources which people working on low-resource languages may experience; lastly, the lack of the evaluation resources, which makes it hard to assess the quality of the adapted model properly. In this study we simulate low-resource settings by restricting the amount of training samples for high-resource languages. This allows us to benefit from good-quality evaluation datasets available for the high resource languages. We expect that our observations could generalize to real low-resource scenarios. We've chosen two languages for the adaptation of BigScience model: (1) \textit{German} (easy language) that belongs in the same Germanic language family as English and shares the Latin script with several pretraining languages; (2) \textit{Korean} (difficult language) that belongs to Koreanic language family and uses Hangul script system, that none of the languages of pretrained LM cover. We train the pretrained model's byte-level BPE tokenizer with the vocabulary size of 130,000 on German and Korean deduplicated OSCAR subcorpora \citep{ortiz:oscar_2019}, which has 21.5B and 1.1B words respectively. Then, we use 100,000 samples from OSCAR subcorpora of the respective languages for adaptation. \subsection{Language Adaptation Strategies} We experiment with the following three language adaptation strategies that involve finetuning of the embedding layer and adapters layers (see Figure~\ref{fig:language-adaptation}). See Appendix~\ref{appendix:language-adaptation-training} for further training details. \paragraph{Embedding-only.} The embedding layer consists of token embeddings and positional embeddings. We follow \citet{artetxe-etal-2020-cross} by learning new token embeddings and positional embeddings while freezing the rest of the transformer parameters. \vspace{-0.2cm} \paragraph{Embedding-then-Adapters.} Following the Embedding-only approach, we first train the embedding layer on the target language pretraining data for 25,000 steps. Then, we freeze the entire transformer and add MAD-X invertible and language adapters \cite{pfeiffer-etal-2020-mad}. We subsequently finetune the adapters for an additional 25,000 steps. \paragraph{Embedding-and-Adapters.} Instead of training the embedding layer and the adapters separately, we train both of them at the same time for 50,000 steps. We also vary the adapter capacity, which is defined by the reduction factor (also known as compression rate \cite{ruckle-etal-2021-adapterdrop}) in the adapter’s bottleneck layer. A smaller reduction value would lead to a larger amount of adapter parameters and, accordingly, a larger adaptation capacity. We consider the reduction factors of 16 (default), 48, and 384. \subsection{Evaluation} We evaluate our models on the natural language inference (NLI) task, using XNLI dataset \cite{conneau-etal-2018-xnli} for German and KLUE-NLI dataset \cite{park-2021-klue} for Korean\footnote{We evaluate our models on the dev set of KLUE-NLI.}. Table~\ref{tab:nli-task} reports the statistics of the NLI datasets. We adopt the three following evaluation settings with increasing levels of task supervision. \paragraph{Prompt-based Zero-shot} Following \citet{xi-2021-few-shot}, we use the German and Korean cloze-style prompt templates (see Table~\ref{tab:zero-shot-prompt-template}). The zero-shot prediction is the candidate label verbalizer, which replaces the \texttt{[MASK]} token, that maximizes the LM based likelihood of the prompt sentence. \paragraph{Cross-lingual} In this evaluation setting, we follow \citet{pfeiffer-etal-2020-mad} and train task adapters on English task dataset. These adapters are then used on the target language (German or Korean) evaluation set. We adopt adapter size (reduction factor = 16) and run training for 2 epochs with the batch size of 32, learning rate of $5e-5$, and maximum sequence length of 128 input tokens on a single V100 GPU, which takes around 5 hours to complete and produces around 0.65 kg of $\text{CO}_2$. \paragraph{Supervised Finetuning} Our finetuning strategies are identical to the cross-lingual evaluation setting above, except that the classification head and the task adapters are finetuned on the target language dataset. Note that this implies that we train different task adapter for each model. \section{Results and Discussion} Table \ref{tab:nli_result} reports the results on different adaptation strategies. \paragraph{Baselines.} XLM-R and mBERT are pretrained multilingual LMs that were trained on 100+ languages and include both German and Korean languages. Therefore the adaptation of these models can be seen as an upper bound performance one could achieve on classification tasks. XGLM \cite{xi-2021-few-shot} is a multilingual autoregressive LM that was pretrained on 30 languages, including both German and Korean. It serves as the (upper-bound) baseline for the prompt-based evaluation setting due to its zero-shot learning capability through prompts on NLI \cite{xi-2021-few-shot}. \paragraph{Language Adaptation Strategies.} First, original BigScience multilingual model~\modelref{bs} performs poorly on German\footnote{We did not perform evaluation on Korean as the vocabulary used by BigScience model doesn't cover Hangul at all.}. Training adapter layers \modelref{bs_emb_adapt}, \modelref{bs_emb1_adapt2} boosts performance compared to the model updating embedding layers only \modelref{bs_emb}, especially under the cross-lingual setting for both German and Korean languages. Model \modelref{bs_emb1_adapt2} that trains embedding layers and adapters separately seems to perform worse than models training them simultaneously (models~\modelref{bs_emb_adapt} and~\modelref{bs_de_embpe_adapt}). We also observe that it is easier to adapt to German, where adapted models~\modelref{bs_emb}--\modelref{bs100500_emb_adapt} almost close the gap with the upper bound baselines (\modelref{mbert}--\modelref{xglm}), but this is not the case for Korean, where this gap is still important. This is in line with \citeposs{muller-etal-2021-unseen} findings suggesting that knowledge transfer is more efficient between related languages. \paragraph{Original Pretraining Steps.} The models \modelref{bs_emb_adapt}, \modelref{bs100500_emb_adapt} and \modelref{bs12000_emb_adapt} compare the effect of the pretraining steps on the new language adaptability. We observe that, after language adaptation, the early pretraining checkpoint (row \modelref{bs12000_emb_adapt} in Table~\ref{tab:nli_result}) only performs as good as a non-adapted model \modelref{bs} when evaluated with prompts. However, after further finetuning on the downstream task, its performance catches up with later checkpoints. This result suggests that the model is capable to recover a lot of task knowledge during finetuning. Whether the knowledge encoded in the pretrained model was useful needs further investigation. \paragraph{Adapters' Capacity.} The models with different adapters' capacity (models \modelref{bs_emb_adapt}, \modelref{bs_emb_adapt48} and \modelref{bs_emb_adapt384}) achieve comparable downstream performance when adapting to German and Korean languages. The small impact of parameter budget on the final performance could be due to the limited amount of training data. This implies that in the real low-resource settings there is no need for a very large parameter budget. \paragraph{Positional Embeddings.} Our results (models~\modelref{bs_emb_adapt} vs \modelref{bs_de_embpe_adapt}, models~\modelref{bs100500_emb_adapt} vs \modelref{bs_ko_embpe_adapt}) highlight the importance of adapting the positional embedding layer of the LM. For German, the adapted positional embeddings gives 6.5\% accuracy boost for cross-lingual NLI; for Korean, we obtain 4.9\% accuracy improvement for cross-lingual NLI and 12.7\% improvement for the supervised setting\footnote{The training of model \modelref{bs_de_embpe_adapt} diverged on Korean dataset, therefore we used a different original pretraining checkpoint to train \modelref{bs_ko_embpe_adapt}. We would investigate this issue further.}. This is in line with the findings by \citet{ravishankar-sogaard-2021-impact}. \section{Limitations and Future Work} \paragraph{Languages} In our language adaptation setup, we use pseudo-low resource languages by limiting the number of samples for German and Korean, which are classified as high-resource languages by \citet{joshi-etal-2020-state}. In our future work, we plan to explore language adaptation to truly low-resource languages such as Sinhala and Burmese. \paragraph{Evaluation Tasks} We only evaluate our models on the natural language inference task, which is a high-level NLP classification task. We plan to extend our evaluation task suite to include generative tasks such as multilingual abstractive summarization \cite{hasan-etal-2021-xl} and sequence labeling tasks such as named entity recognition \cite{rahimi-etal-2019-massively} We acknowledge that the performances might not generalize to truly low-resource languages because they have exceptionally limited labeled resources. \paragraph{Training Examples} We adapt the model to a new language by training on 100,000 samples of the new language. In reality, many languages may have far more monolingual data available. Our future experiments would include language adaptation with varying number of training samples and evaluate the effect of larger training samples on downstream performance and the use of adapters. \paragraph{Origianl Pretraining Steps} As we observe that the model still performs well on downstream tasks after finetuning despite only 12,000 of original pretraining steps, we plan to evaluate how important it is to start from the pre-trained model by comparing the performance with a randomly initialized pretrained model. \paragraph{Tokenizers} We retrain the BigScience tokenizer with its original vocabulary size of 130,000 on the entire subcorpora of the new language. In our future work, we plan to explore the effect of the vocabulary size of the tokenizers and the number of samples used to train the tokenizers. \section{Conclusion} In this work we've compared different adaptation strategies to add a new language into pretrained BigScience model and identified important components for adaptation. \section*{Acknowledgements} The authors would like to thank anonymous reviewers for their helpful feedback.
{'timestamp': '2022-04-12T02:32:48', 'yymm': '2204', 'arxiv_id': '2204.04873', 'language': 'en', 'url': 'https://arxiv.org/abs/2204.04873'}
arxiv
\section{Introduction}\label{sec:introduction} \IEEEPARstart{V}{ideo} object tracking is one of the fundamental computer vision problems. It finds rich applications in video surveillance \cite{xing2010multiple}, autonomous navigation \cite{janai2020computer}, robotics vision \cite{zhang2015good}, etc. Given a bounding box on the target object at the first frame, a tracker has to predict object box locations and sizes for all remaining frames in online single object tracking (SOT) \cite{yilmaz2006object}. The performance of a tracker is measured by accuracy (higher success rate), robustness (automatic recovery from tracking loss), computational complexity and speed (a higher number of frames per second of FPS). Online trackers can be categorized into supervised and unsupervised ones \cite{fiaz2019handcrafted}. Supervised trackers based on deep learning (DL) dominate the SOT field in recent years. Some of them use a pre-trained network such as AlexNet\cite{krizhevsky2012imagenet} or VGG \cite{chatfield2014return} as the feature extractor and do online tracking with extracted deep{} features \cite{danelljan2017eco, danelljan2016beyond, ma2015hierarchical, qi2016hedged, wang2018multi}. Others adopt an{} end-to-end optimized model which is trained by video datasets in an offline manner \cite{li2018high, li2019siamrpn++} and could be adapted to video frames in an online fashion \cite{lu2018deep, nam2016learning, pu2018deep, song2017crest}. The tracking problem is formulated as a template matching problem in siamese trackers \cite{bertinetto2016fully, li2018high, li2019siamrpn++, tao2016siamese, zhu2018distractor, wang2018learning, he2018twofold}, which is popular because of its simplicity and effectiveness. One recent trend is to apply the Vision Transformer in visual tracking \cite{wang2021transformer, chen2021transformer}. Although DL trackers offer state-of-the-art tracking accuracy, they do have some limitations. First, a large number of annotated tracking video clips are needed in the training, which is a laborious and costly task. Second, they demand large memory space to store the parameters of deep networks due to large model sizes. Third, the high computational power requirement hinders their applications in resource-limited devices such as drones or mobile phones. Fourth, DL trackers need to be trained with video samples of diverse content. Their capability in handling unseen objects appears to be limited, which will be illustrated in the experimental section. In contrast with DL trackers, unsupervised trackers are attractive since they do not need annotated boxes to train trackers. They are favored in real-time tracking on resource-limited devices because of lower power consumption. Advanced unsupervised SOT methods often use discriminative correlation filters (DCFs). They were investigated between 2010 and 2018 \cite{bolme2010visual, henriques2014high, danelljan2015convolutional, danelljan2016discriminative, danelljan2016beyond, bertinetto2016staple, valmadre2017end, li2018learning}. DCF trackers conduct dense sampling around the object box and solve a regression problem to learn a template for similarity matching. Under the periodic sample assumption, matching can be conducted very fast in the Fourier domain. Spatial-temporal regularized correlation filters (STRCF) \cite{li2018learning} adds spatial-temporal regularization to template update and performs favorably against other DCF trackers \cite{danelljan2017eco, danelljan2015learning}. As deep neural networks (DNNs) get popular in recent years, there is an increasing interest in learning DNN-based object tracking models from offline videos without annotations. For example, UDT+ \cite{wang2019unsupervised} and LUDT \cite{wang2021unsupervised} investigated cycle learning in video, in which networks are trained to track forward and backward with consistent object proposals. ResPUL \cite{wu2021progressive} mined positive and negative samples from unlabeled videos and leveraged them for supervised learning in building spatial and temporal correspondence. These unsupervised deep trackers reveal a promising direction in exploiting offline videos without annotations. Yet, they are limited in performance. Furthermore, they need the pre-training effort. In contrast, no pre-training on offline datasets is needed in our unsupervised tracker. Despite the above-mentioned developments in unsupervised trackers, there is a significant performance gap between unsupervised DCF trackers and supervised DL trackers. It is attributed to the limitations of DCF trackers such as failure to recover from tracking loss and inflexibility in object box adaptation. An unsupervised tracker, called UHP-SOT (Unsupervised High-Performance Single Object Tracker), was recently proposed in \cite{zhou2021uhp} to address the issues. UHP-SOT used STRCF as the baseline and incorporated two new modules -- background motion modeling and trajectory-based object box prediction. A simple fusion rule was adopted by UHP-SOT to integrate proposals from three modules into the final one. UHP-SOT has the potential to recover from tracking loss and offer flexibility in object box adaptation. UHP-SOT outperforms all previous unsupervised single object trackers and narrows down the gap between unsupervised and supervised trackers. It achieves comparable performance against DL trackers on small-scale datasets such as TB-50 and TB-100 (or OTB 2015) \cite{7001050}. This work is an extension of UHP-SOT with new contributions. First, the fusion strategies in UHP-SOT and UHP-SOT++ are different. The fusion strategy in UHP-SOT was simple and ad hoc. UHP-SOT++ adopts a fusion strategy that is more systematic and well justified. It is applicable to both small- and large-scale datasets with more robust and accurate performance. Second, this work conducts more extensive experiments on four object tracking benchmarks (i.e., OTB2015, TC128, UAV123 and LaSOT) while only experimental results on OTB2015 were reported for UHP-SOT in \cite{zhou2021uhp}. New experimental evaluations demonstrate that UHP-SOT++ outperforms all previous unsupervised SOT methods (including UHP-SOT) and achieves comparable results with DL methods on large-scale datasets. Since UHP-SOT++ has an extremely small model size, high tracking performance, and low computational complexity (operating at a rate of 20 FPS on an i5 CPU even without code optimization), it is ideal for real-time object tracking on resource-limited platforms. Third, we make thorough discussion on pros and cons of supervised and unsupervised trackers in this work. Besides quantitative evaluations, we provide a few exemplary sequences with qualitative analysis on strengths and weaknesses of UHP-SOT++ and its benchmarking methods. The rest of this paper is organized as follows. Related work is reviewed in Sec. \ref{sec:review}. The UHP-SOT++ method is detailed in Sec. \ref{sec:method}. Experimental results are shown in Sec. \ref{sec:experiments}. Further discussion is provided in Sec. \ref{sec:discussion}. Concluding remarks are given in Sec. \ref{sec:conclusion}. \section{Related Work}\label{sec:review} \begin{figure}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/DCF_SN.png}} \caption{Comparison of the inference structures of a DCF tracker and a siamese network tracker, where the red box denotes the object bounding box, $\phi$ is the feature extraction module and $*$ is the correlation operation.} \label{fig:dcfvssn} \end{figure} \subsection{DCF and Siamese Networks}\label{subsec:review} Two representative single object trackers are reviewed and compared here. They are the DCF tracker and the siamese network tracker as shown in Fig.~\ref{fig:dcfvssn}. The former is an unsupervised one while the latter is a supervised one based on DL. Both of them conduct template matching within a search region to generate the response map for object location. The matched template in the next frame is centered at the location that has the highest response. In the DCF, the template size is the same as that of the search region so that the Fast Fourier Transform (FFT) could be used to speed up the correlation process. To learn the template, a DCF uses the initial object patch to obtain a linear template via regression in the Fourier domain: \begin{equation}\label{eq:regression} \mathrm{arg}\min_{\mathbf{f}} \frac{1}{2}\|\sum_{d=1}^D \mathbf{x}^{d}* \mathbf{f}^{d}-\mathbf{y}\|^2, \end{equation} where $\mathbf{f}$ is the template to be determined, $\mathbf{x} \in \mathbb{R}^{N_x \times N_y \times D}$ is the spatial map of $D$ features extracted from the object patch, $*$ is the feature-wise spatial convolution, and $\mathbf{y} \in \mathbb{R}^{N_x \times N_y}$ is a centered Gaussian-shaped map that serves as the regression label. Templates in DCFs tend to contain some background information. Furthermore, there exists boundary distortion caused by the 2D Fourier transform. To alleviate these side effects, it is often to weigh the template with a window function to suppress background and image discontinuity. In contrast, the template size in a siamese networks is more flexible and significantly smaller than the search region. Usually, the object box of the first frame serves as the template for the search in all later frames. The correlation is typically implemented by the convolution which runs fast on GPU. The shape and size of the predicted object bounding box are determined by the regional proposal network inside the siamese network. \subsection{Spatial-Temporal Regularized Correlation Filters (STRCF)} \label{subsec:STRCF} STRCF is a DCF-based tracker. It has an improved regression objective function using spatial-temporal regularization. The template is initialized at the first frame. Suppose that the object appearance at frame $t$ is modeled by a template, denoted by $\mathbf{f}_t$, which will be used for similarity matching at frame $(t+1)$. By modifying Eq. (\ref{eq:regression}), STRCF updates its template at frame $t$ by solving the following regression equation: \begin{eqnarray} \mathrm{arg}\min_{\mathbf{f}} & \Big\{ & \frac{1}{2}\|\sum_{d=1}^D \mathbf{x}_{t}^{d}* \mathbf{f}^{d}-\mathbf{y}\|^2 + \frac{1}{2}\sum_{d=1}^D \|\mathbf{w}\cdot \mathbf{f}^{d} \|^2 \nonumber \\ && + \frac{\mu}{2}\|\mathbf{f}-\mathbf{f}_{t-1} \|^2, \Big\} \label{eq:strcf} \end{eqnarray} where $\mathbf{w}$ is the spatial weight on the template, $\mathbf{f}_{t-1}$ is the template obtained from time $t-1$, and $\mu$ is a constant regularization coefficient. We can interpret the three terms in Eq. (\ref{eq:strcf}) as follows. The first term is the standard regression objective function of a DCF. The second term imposes the spatial regularization. It gives more weights to features in the center region of a template in the matching process. The third term imposes temporal regularization for smooth appearance change. To search for the box in frame $(t+1)$, STRCF correlates template $\mathbf{f}_t$ with the search region and determines the new box location by finding the location that gives the highest response. Although STRCF can model the appearance change for general sequences, it suffers from overfitting. That is, it is not able to adapt to largely deformed objects quickly. Furthermore, it cannot recover from tracking loss. The template model, $\mathbf{f}$, is updated at every frame with a fixed regularization coefficient, $\mu$, in standard STRCF. Our UHP-SOT++ adopts STRCF as a building module. To address the above-mentioned shortcomings, we have some modification in our implementation. First, we skip updating $\mathbf{f}$ if no obvious motion is observed. Second, a smaller $\mu$ is used when all modules agree with each other in prediction so that $\mathbf{f}$ can adapt to the new appearance of largely deformed objects faster. \section{Proposed UHP-SOT++ Method}\label{sec:method} \begin{figure*}[htbp] \centerline{\includegraphics[width=\textwidth]{./figures/architecture_new.png}} \caption{The system diagram of the proposed UHP-SOT++ method. It shows one example where the object was lost at time $t-1$ but gets retrieved at time $t$ because the proposal from background motion modeling is accepted.} \label{fig:system} \end{figure*} \subsection{System Overview}\label{subsec:overview} There are three main challenges in SOT: \begin{enumerate} \item significant change of object appearance, \item loss of tracking, \item rapid variation of object's location and/or shape. \end{enumerate} We propose a new tracker, UHP-SOT++, to address these challenges, As shown in Fig. \ref{fig:system}, it consists of three modules: \begin{enumerate} \item appearance model update, \item background motion modeling, \item trajectory-based box prediction. \end{enumerate} UHP-SOT++ follows the classic tracking-by-detection paradigm where the object is detected within a region centered at its last predicted location at each frame. The histogram of gradients (HOG) features as well as the color name (CN) \cite{danelljan2014adaptive} features are extracted to yield the feature map. We choose the STRCF tracker \cite{li2018learning} as the baseline because of its efficient and effective appearance modeling and update. Yet, STRCF cannot handle the second and the third challenges well because it only focuses on the modeling of object appearance which could vary a lot across different frames. Generally, the high variety of object appearance is difficult to capture using a single model. Thus, we propose the second and the third modules in UHP-SOT++ to enhance its tracking accuracy. UHP-SOT++ operates in the following fashion. The baseline tracker gets initialized at the first frame. For the following frames, UHP-SOT++ gets proposals from all three modules and merges them into the final prediction based on a fusion strategy. The STRCF tracker was already discussed in Sec. \ref{subsec:STRCF}. For the rest of this section, we will examine the background motion modeling module and the trajectory-based box prediction module in Secs. \ref{subsec:background} and \ref{subsec:trajectory}, respectively. Finally, we will elaborate on the fusion strategy in Sec. \ref{subsec:fusion}. Note that the fusion strategies of UHP-SOT and UHP-SOT++ are completely different. \subsection{Background Motion Modeling}\label{subsec:background} We decompose the pixel displacement between adjacent frames (also called optical flow) into two types: object motion and background motion. Background motion is usually simpler, and it may be fit by a parametric model. Background motion estimation \cite{hariharakrishnan2005fast, aggarwal2006object} finds applications in video stabilization, coding and visual tracking. Here, we propose a 6-parameter model in form of \begin{eqnarray} x_{t+1}& = & \alpha_1 x_t + \alpha_2 y_t + \alpha_0, \\ y_{t+1}& = & \beta_1 x_t + \beta_2 y_t + \beta_0, \end{eqnarray} where $(x_{t+1},y_{t+1})$ and $(x_t,y_t)$ are corresponding background points in frames $(t+1)$ and $t$, respectively, and $\alpha_i$ and $\beta_i$, $i=0,1,2$ are model parameters. With more than three pairs of corresponding points, we can determine the model parameters using the linear least-squares method. Usually, we choose a few salient points (e.g., corners) to build the correspondence. We apply the background model to the grayscale image $I_t(x,y)$ of frame $t$ to find the estimated $\hat{I}_{t+1}(x,y)$ of frame $(t+1)$. Then, we can compute the difference map $\Delta I$: \begin{equation} \Delta I = \hat{I}_{t+1}(x,y) - I_{t+1}(x,y), \end{equation} which is expected to have small and large absolute values in the background and foreground regions, respectively. Thus, we can determine potential object locations. While DCF trackers exploit foreground correlation to locate the object, background modeling uses background correlation to eliminate background influence in object tracking. They complement each other. DCF trackers cannot recover from tracking loss easily since it does not have a global view of the scene. In contrast, our background modeling can find potential object locations by removing the background. \subsection{Trajectory-based Box Prediction}\label{subsec:trajectory} Given predicted box centers of the object of the last $N$ frames, $\{ (x_{t-N},y_{t-N}),\cdots,(x_{t-1},y_{t-1}) \}$, we calculate $N-1$ displacement vectors $\{ (\Delta x_{t-N+1},\Delta y_{t-N+1}),\cdots,(\Delta x_{t-1},\Delta y_{t-1}) \}$ and apply the principal component analysis (PCA) to them. To predict the displacement at frame $t$, we fit the first principal component using a line and set the second principal component to zero to remove noise. Then, the center location of the box at frame $t$ can be written as \begin{equation} (\hat{x}_{t}, \hat{y}_{t}) = (x_{t-1}, y_{t-1}) + (\hat{\Delta x}_{t}, \hat{\Delta y}_{t}). \end{equation} Similarly, we can estimate the width and the height of the box at frame $t$, denoted by $(\hat{w}_t, \hat{h}_t)$. Typically, the physical motion of an object has an inertia in motion trajectory and its size, and the box prediction process attempts to maintain the inertia. It contributes to better tracking performance in two ways. First, it removes small fluctuation of the box in its location and size. Second, when there is a rapid deformation of the target object, the appearance model alone cannot capture the shape change effectively. In contrast, the combination of background motion modeling and the trajectory-based box prediction can offer a more satisfactory solution. For example, Fig. \ref{fig:shape}, shows a frame of the \textit{diving} sequence in the upper-left subfigure, where the green and the magenta boxes are the ground truth and the result of UHP-SOT++, respectively. Although a DCF tracker can detect the size change by comparing correlation scores at five image resolutions, it cannot estimate the aspect ratio change properly. In contrast, as shown in the lower-left subfigure, the residual image after background removal in UHP-SOT++ reveals the object shape. By summing up absolute pixel values of the residual image horizontally and vertically and using a threshold to determine two ends of the box, we have \begin{equation} \hat{w}=x_{\max}-x_{\min}, \mbox{ and } \hat{h}=y_{\max}-y_{\min}. \end{equation} Note that raw estimates may not be stable across different frames. Estimates that deviate much from the trajectory of $(\Delta w_{t},\Delta h_{t})$ are rejected to yield a robust and deformable box proposal. \begin{figure}[!htbp] \centerline{\includegraphics[width=\linewidth]{./figures/scalechange.png}} \caption{Illustration of shape change estimation based on background motion model and trajectory-based box prediction, where the ground truth and our proposal are annotated in green and magenta, respectively.} \label{fig:shape} \end{figure} \begin{figure*}[htbp] \centerline{\includegraphics[width=\textwidth]{./figures/fusion_occ.png}} \caption{Illustration of occlusion detection, where the green box shows the object location. The color information and similarity score could change rapidly if occlusion occurs.} \label{fig:fusion_occ} \end{figure*} \begin{table*}[htbp] \caption{All tracking scenarios are classified into 8 cases in terms of the overall quality of proposals from three modules. The fusion strategy is set up for each scenario. The update rate is related the regularization coefficient, $\mu$, that controls to which extent the appearance model should be updated.}\label{tab3:fusion} \begin{center} \begin{tabular}{ccccc} \hline $isGood_{app}$ & $isGood_{trj}$ & $isGood_{bgd}$ & Proposal to take & Update rate \\ \hline \hline 1 & 1 & 1 & $B_\mathrm{app}$ or union of three & normal \\ 1 & 1 & 0 & $B_\mathrm{app}$ or $B_\mathrm{trj}$ or union of two & normal \\ 1 & 0 & 1 & $B_\mathrm{app}$ or $B_\mathrm{bgd}$ or union of two & normal \\ 0 & 1 & 1 & $B_\mathrm{trj}$ or $B_\mathrm{bgd}$ or union of two & normal or stronger \\ 1 & 0 & 0 & $B_\mathrm{app}$ & normal \\ 0 & 1 & 0 & $B_\mathrm{app}$ or $B_\mathrm{trj}$ & normal or stronger \\ 0 & 0 & 1 & $B_\mathrm{app}$ or $B_\mathrm{bgd}$ & normal or stronger \\ 0 & 0 & 0 & $B_\mathrm{app}$ or last prediction in case of occlusion & normal or weaker \\ \hline \end{tabular} \end{center} \end{table*} \begin{figure*}[htbp] \centerline{\includegraphics[width=\textwidth]{./figures/fusion_showcase.png}} \caption{An example of quality assessment of proposals, where the green box is the ground truth, and yellow, blue and magenta boxes are proposals from $B_\mathrm{app}$, $B_\mathrm{trj}$ and $B_\mathrm{bgd}$, respectively, and the bright yellow text on the top-left corner denotes the quality of three proposals $(isGood_{app},isGood_{trj}, isGood_{bgd})$.} \label{fig:fusion_showcase} \end{figure*} \subsection{Fusion Strategy}\label{subsec:fusion} We have three box proposals for the target object at frame $t$: 1) $B_\mathrm{app}$ from the baseline STRCF tracker to capture appearance change, 2) $B_\mathrm{bgd}$ from the background motion predictor to eliminate unlikely object regions, and 3) $B_\mathrm{trj}$ from the trajectory predictor to maintain the inertia of the box position and size. A fusion strategy is needed to yield the final box location and size. We consider a couple of factors for its design. \subsubsection{Proposal Quality} There are three box proposals. The quality of each box proposal can be measured by: 1) object appearance similarity, and 2) robustness against the trajectory. We use a binary flag to indicate whether the quality of a proposal is good or not. As shown in Table \ref{tab3:fusion}, the flag is set to one if a proposal keeps proper appearance similarity and is robust against trajectory. Otherwise, it is set to zero. For the first measure, we store two appearance models: the latest model, $\mathbf{f}_{t-1}$, and an older model, $\mathbf{f}_{i}$, $i\leq t-1$, where $i$ is the last time instance where all three boxes have the same location. Model $\mathbf{f}_{i}$ is less likely to be contaminated since it needs agreement from all modules. To check the reliability of the three proposals, we compute correlation scores for the following six pairs: ($\mathbf{f}_{t-1}$, $B_\mathrm{app}$), ($\mathbf{f}_{t-1}$, $B_\mathrm{trj}$), ($\mathbf{f}_{t-1}$, $B_\mathrm{bgd}$), ($\mathbf{f}_{i}$, $B_\mathrm{app}$), ($\mathbf{f}_{i}$, $B_\mathrm{trj}$), and ($\mathbf{f}_{i}$, $B_\mathrm{bgd}$). They provide appearance similarity measures of the two previous models against the current three proposals. A proposal has good similarity if one of its correlation scores is higher than a threshold. For the second measure, if $B_\mathrm{app}$ and $B_\mathrm{trj}$ have a small displacement (say, 30 pixels) from the last prediction, the move is robust. As to $B_\mathrm{bgd}$, it often jumps around and, thus, is less reliable. However, if the standard deviations of its historical locations along the $x$-axis and $y$-axis are small enough (e.g., 30 pixels over the past 10 frames), then they are reliable. \subsubsection{Occlusion Detection} We propose an occlusion detection strategy for color images, which is illustrated in Fig.~\ref{fig:fusion_occ}. As occlusion occurs, we often observe a sudden drop in the similarity score and a rapid change on the averaged RGB color values inside the box. A drop is sudden if the mean over the past several frames is high while the current value is significantly lower. If this is detected, we keep the new prediction the same as the last predicted position since the new prediction is unreliable. We do not update the model for this frame either to avoid drifting and/or contamination of the appearance model. \subsubsection{Rule-based Fusion} Since each of the three proposals has a binary flag, all tracking scenarios can be categorized into 8 cases as shown in Fig.~\ref{fig:fusion_showcase}. We propose a fusion scheme for each case below. \begin{itemize} \item When all three proposals are good, their boxes are merged together as a minimum covering rectangle if they overlap with each other with IoU above a threshold. Otherwise, $B_\mathrm{app}$ is adopted. \item When two proposals are good, merge them if they overlap with each other with IoU above a threshold. Otherwise, the one with better robustness is adopted. \item When one proposal is good, adopt that one if it is $B_\mathrm{app}$. Otherwise, that proposal is compared with $B_\mathrm{app}$ to verify its superiority by observing a higher similarity score or better robustness. \item When all proposals have poor quality, the occlusion detection process is conducted. The last prediction is adopted in case of occlusion. Otherwise, $B_\mathrm{app}$ is adopted. \item When other proposals outperform $B_\mathrm{app}$, the regularization coefficient, $\mu$, is adjusted accordingly for stronger update. Because this might reveal that the appearance model needs to be updated more to capture the new appearance. \end{itemize} The fusion rule is summarized in Table \ref{tab3:fusion}. In most cases, $B_\mathrm{app}$ is reliable and it will be chosen or merged with other proposals because the change is smooth between adjacent frames in the great majority of frames in a video clip. \section{Experiments}\label{sec:experiments} \subsection{Experimental Set-up}\label{subsec:setup} To show the performance of UHP-SOT++, we compare it with several state-of-the-art unsupervised and supervised trackers on four single object tracking datasets. They are OTB2015 \cite{7001050}, TC128 \cite{liang2015encoding}, UAV123 \cite{mueller2016benchmark} and LaSOT \cite{fan2019lasot}. OTB2015 (also named OTB in short) and TC128, which contain 100 and 128 color or grayscale video sequences, respectively, are two widely used small-scale datasets. UAV123 is a larger one, which has 123 video sequences with more than 110K frames in total. Videos in UAV123 are captured by low-altitude drones. They are useful in the tracking test of small objects with a rapid change of viewpoints. LaSOT is the largest single object tracking dataset that targets at diversified object classes and flexible motion trajectories in longer sequences. It has one training set with dense annotation for supervised trackers to learn and another test set for performance evaluation. The test set contains 280 videos of around 685K frames. Performance evaluation is conducted using the ``One Pass Evaluation (OPE)" protocol. The metrics include the precision plot (i.e., the distance of the predicted and actual box centers) and the success plot (i.e., overlapping ratios at various thresholds). The distance precision (DP) is measured at the 20-pixel threshold to rank different methods. The overlap precision is measured by the area-under-curve (AUC) score. We use the same hyperparameters as those in STRCF except for regularization coefficient, $\mu$. If the appearance box is not chosen, STRCF sets $\mu=15$ while UHP-SOT++ selects $\mu \in\{15,10,5,0\}$. The smaller $\mu$ is, the stronger the update is. The number of previous frames for trajectory prediction is $N=20$. The cutting threshold along the horizontal or vertical direction is set 0.1. The threshold for good similarity score is 0.08, and a threshold of 0.5 for IoU is adopted. UHP-SOT++ runs at 20 frames per second (FPS) on a PC equipped with an Intel(R) Core(TM) i5-9400F CPU. The speed data of other trackers are either from their original papers or benchmarks. Since no code optimization is conducted, all reported speed data should be viewed as lower bounds for the corresponding trackers. \subsection{Ablation study} We compare different configurations of UHP-SOT++ on the TC128 dataset to investigate contributions from each module in Fig.~\ref{fig:ablation_study}. As compared with UHP-SOT, improvements on both DP and AUC in UHP-SOT++ come from the new fusion strategy. Under this strategy, the background motion modeling plays an more important role and it has comparable performance even without the trajectory prediction. Although the trajectory prediction module is simple, it contributes a lot to higher tracking accuracy and robustness as revealed by the performance improvement over the baseline STRCF. More performance comparison between UHP-SOT++, UHP-SOT and STRCF is presented in Table \ref{tab:sota}. As compared with STRCF, UHP-SOT++ achieves 1.8\%, 6.2\%, 6.7\% and 6.8\% gains in the success rate on OTB, TC128, UAV123 and LaSOT, respectively. As to the mean precision, it has an improvement of 1.2\%, 6.9\%, 7.2\% and 10.4\%, respectively. Except for OTB, UHP-SOT++ outperforms UHP-SOT in both the success rate and the precision. This is especially obvious for large-scale datasets. Generally, UHP-SOT++ has better tracking capability than UHP-SOT. Its performance drop in OTB is due to the tracking loss in three sequences; namely, \textit{Bird2}, \textit{Coupon} and \textit{Freeman4}. They have complicated appearance changes such as severe rotation, background clutter and heavy occlusion. As shown in Fig.~\ref{fig:analysis_error}, errors at some key frames lead to total loss of the object, and the lost object cannot be easily recovered from motion. The trivial fusion strategy based on appearance similarity in UHP-SOT seems to work well on their key frames while the fusion strategy of UHP-SOT++ does not suppress wrong proposals properly since background clutters have stable motion and trajectories as well. \begin{figure}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/ablation_study.png}} \caption{The precision plot and the success plot of our UHP-SOT++ tracker with different configurations on the TC128 dataset, where the numbers inside the parentheses are the DP values and AUC scores, respectively.} \label{fig:ablation_study} \end{figure} \begin{table*}[htbp] \caption{Comparison of state-of-the-art supervised and unsupervised trackers on four datasets, where the performance is measure by the distance precision (DP) and the area-under-curve (AUC) score in percentage. The model size is measured by the memory required to store needed data such as the model parameters of pre-trained networks. The best unsupervised performance is highlighted. Also, S and P indicate \textbf{S}upervised and \textbf{P}re-trained, respectively.}\label{tab:sota} \begin{center} \begin{tabular}{cccc||cc|cc|cc|cc||ccc} \hline Trackers & Year & \textbf{S} & \textbf{P} & \multicolumn{2}{c}{OTB2015} & \multicolumn{2}{c}{TC128} & \multicolumn{2}{c}{UAV123} & \multicolumn{2}{c||}{LaSOT} & FPS & Device & Model size (MB)\\ & & & & DP & AUC & DP & AUC & DP & AUC & DP & AUC & & & \\ \hline SiamRPN++\cite{li2019siamrpn++} & 2019 & \checkmark & \checkmark & 91.0&69.2 & -&- & 84.0&64.2 & 49.3&49.5 & 35 & GPU & 206 \\ ECO\cite{danelljan2017eco} & 2017 & \checkmark & \checkmark & 90.0&68.6 & 80.0&59.7 & 74.1&52.5 & 30.1&32.4 & 10 & GPU & 329 \\ \hline UDT+\cite{wang2019unsupervised} & 2019 & $\times$ & \checkmark & 83.1&63.2 & 71.7&54.1 & -&- & -&- & 55 & GPU & $<1$\\ LUDT\cite{wang2021unsupervised} & 2020 & $\times$ & \checkmark & 76.9&60.2 & 67.1&51.5 & -&- & -&26.2 & 70 & GPU & $<1$\\ ResPUL\cite{wu2021progressive} & 2021 & $\times$ & \checkmark & -&58.4 & -&- & -&- & -&- & - & GPU & $>6$\\ \hline ECO-HC\cite{danelljan2017eco} & 2017 & $\times$ & $\times$ & 85.0&63.8 & 75.3&55.1 & 72.5&50.6 & 27.9&30.4 & 42 & CPU & $<1$\\ STRCF\cite{li2018learning} & 2018 & $\times$ & $\times$ & 86.6&65.8 & 73.5&54.8 & 67.8&47.8 & 29.8&30.8 & 24 & CPU & $<1$\\ UHP-SOT\cite{zhou2021uhp} & 2021 & $\times$ & $\times$ & \textbf{90.9}&\textbf{68.9} & 77.4&57.4 & 71.0&50.1 & 31.1&32.0 & 23 & CPU & $<1$\\ UHP-SOT++ & Ours & $\times$ & $\times$ & 87.6&66.9 & \textbf{78.6}&\textbf{58.2} & \textbf{72.7}&\textbf{51.0} & \textbf{32.9}&\textbf{32.9} & 20 & CPU & $<1$\\ \hline \end{tabular} \end{center} \end{table*} \begin{figure}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/analysis_error.png}} \caption{Failure cases of UHP-SOT++ (in green) as compared to UHP-SOT (in red) on OTB2015.} \label{fig:analysis_error} \end{figure} \begin{figure}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/comp_lasot_un.png}} \caption{The success plot and the precision plot of nine unsupervised tracking methods for the LaSOT dataset, where the numbers inside the parentheses are the overlap precision and the distance precision values, respectively.} \label{fig:comp_benchmark_un} \end{figure} \begin{figure}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/showcase_un.png}} \caption{Qualitative evaluation of three leading unsupervised trackers, where UHP-SOT++ offers a robust and flexible box prediction.} \label{fig:showcase_unsupervised} \end{figure} \begin{figure*}[htbp] \centerline{\includegraphics[width=\textwidth]{./figures/comp_benchmark.png}} \caption{The success plot comparison of UHP-SOT++ with several supervised and unsupervised tracking methods on four datasets, where only trackers with raw results published by authors are listed. For the LaSOT dataset, only supervised trackers are included for performance benchmarking in the plot since the success plot of unsupervised methods is already given in Fig.~\ref{fig:comp_benchmark_un}.} \label{fig:comp_benchmark} \end{figure*} \subsection{Comparison with State-of-the-art Trackers} We compare the performance of UHP-SOT++ and several unsupervised trackers for the LaSOT dataset in Fig. \ref{fig:comp_benchmark_un}. The list of benchmarking methods includes ECO-HC \cite{danelljan2017eco}, STRCF \cite{li2018learning}, CSR-DCF \cite{alan2018discriminative}, SRDCF \cite{danelljan2015learning}, Staple \cite{bertinetto2016staple}, KCF \cite{henriques2014high}, DSST \cite{danelljan2016discriminative}. UHP-SOT++ outperforms other unsupervised methods by a large margin, which is larger than 0.02 in the mean scores of the success rate and the precision. Besides, its running speed is 20 FPS, which is comparable with that of the second runner STRCF (24 FPS) and the third runner (42 FPS) based on experiments in OTB. With a small increase in computational and memory resources, UHP-SOT++ gains in tracking performance by adding object box trajectory and background motion modeling modules. Object boxes of three leading unsupervised trackers are visualized in Fig.~\ref{fig:showcase_unsupervised} for qualitative performance comparison. As compared with other methods, the proposals of UHP-SOT++ offer a robust and flexible box prediction. They follow tightly with the object in both location and shape even under challenging scenarios such as motion blur and rapid shape change. We compare the success rates of UHP-SOT++ and several supervised and unsupervised trackers against all four datasets in Fig. \ref{fig:comp_benchmark}. Note that there are more benchmarking methods for OTB but fewer for TC128, UA123 and LaSOT since OTB is an earlier dataset. The supervised deep trackers under consideration include SiamRPN++ \cite{li2019siamrpn++}, ECO \cite{danelljan2017eco}, C-COT \cite{danelljan2016beyond}, DeepSRDCF \cite{danelljan2015learning}, HDT \cite{fiaz2019handcrafted}, SiamFC\_3s \cite{bertinetto2016fully}, CFNet \cite{valmadre2017end} and LCT \cite{ma2015long}. Other deep trackers that have leading performance but are not likely to be used on resource-limited devices due to their extremely high complexity, such as transformer-based trackers \cite{wang2021transformer, chen2021transformer}, are not included here. Although the performance of a tracker may vary from one dataset to the other due to different video sequences collected by each dataset, UHP-SOT++ is among the top three in all four datasets. This demonstrates the generalization capability of UHP-SOT++. Its better performance than ECO on LaSOT indicates a robust and effective update of the object model. Otherwise, it would degrade quickly with worse performance because of longer LaSOT sequences. Besides, its tracking speed of 20 FPS on CPU is faster than many deep trackers such as ECO (10 FPS), DeepSRDCF (0.2 FPS), C-COT (0.8 FPS) and HDT (2.7 FPS). In Table \ref{tab:sota}, we further compare UHP-SOT++ with state-of-the-art unsupervised deep trackers UDT+ \cite{wang2019unsupervised}, LUDT \cite{wang2021unsupervised} and ResPUL \cite{wu2021progressive} in their AUC and DP values, running speeds and model sizes. Two leading supervised trackers SiamRPN++ and ECO in Fig. \ref{fig:comp_benchmark} are also included. It shows that UHP-SOT++ outperforms recent unsupervised deep trackers by a large margin. We should emphasize that deep trackers demand pre-training on offline datasets while UHP-SOT++ does not. In addition, UHP-SOT++ is attractive because of its lower memory requirement and near real-time running speed on CPUs. Although ECO-HC also provides a light-weight solution, there is a performance gap between UHP-SOT++ and ECO-HC. SiamRPN++ has the best tracking performance among all trackers, due to the merit of end-to-end optimized network with auxiliary modules such as classification head and the region proposal network. Yet, its large model size and GPU hardware requirement limit its applicability in resource-limited devices such as mobile phones or drones. In addition, as an end-to-end optimized deep tracker, SiamRPN++ has the interpretability issue to be discussed later. \subsection{Attribute-based Study} \begin{figure*}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/attcomp_0102.png}} \caption{The area-under-curve (AUC) scores for two datasets, TC128 and LaSOT, under the attribute-based evaluation, where attributes of concern include the aspect ratio change (ARC), background clutter (BC), camera motion (CM), deformation (DEF), fast motion (FM), full occlusion (FOC), in-plane rotation (IPR), illumination variation (IV), low resolution (LR), motion blur (MB), occlusion (OCC), out-of-plane rotation (OPR), out-of-view (OV), partial occlusion (POC), scale variation (SV) and viewpoint change (VC), respectively.}\label{fig:attrs} \end{figure*} To better understand the capability of different trackers, we analyze the performance variation under various challenging tracking conditions. These conditions can be classified into the following attributes: aspect ratio change (ARC), background clutter (BC), camera motion (CM), deformation (DEF), fast motion (FM), full occlusion (FOC), in-plane rotation (IPR), illumination variation (IV), low resolution (LR), motion blur (MB), occlusion (OCC), out-of-plane rotation (OPR), out-of-view (OV), partial occlusion (POC), scale variation (SV) and viewpoint change (VC). We compare the AUC scores of supervised trackers (e.g., SiamRPN++ and ECO) and unsupervised trackers (e.g., UHP-SOT++, ECO-HC, UDT+ and STRCF) under these attributes in Fig. \ref{fig:attrs}. We have the following observations. First, among unsupervised trackers, UHP-SOT++ has leading performance in all attributes, which reveals improved robustness from its basic modules and fusion strategy. Second, although ECO utilizes deep features, it is weak in flexible box regression and, as a result, it is outperformed by UHP-SOT++ in handling such deformation and shape changes against LaSOT. In contrast, SiamRPN++ is better than other trackers especially in DEF (deformation), ROT (rotation)and VC (viewpoint change). The superior performance of SiamRPN++ demonstrates the power of its region proposal network (RPN) in generating tight boxes. The RPN inside SiamRPN++ not only improves IoU score but also has the long-term benefit by excluding noisy information. Fourth, supervised trackers perform better in IV (illumination variation) and LR (low resolution) than unsupervised trackers in general. This can be explained by the fact that unsupervised trackers adopt HOG, CN features or other shallow features which do not work well under these attributes. They focus on local structures of the appearance and tend to fail to capture the object when the local gradient or color information is not stable. Finally, even with the feature limitations, UHP-SOT++ still runs second in many attributes against LaSOT because of the stability offered by trajectory prediction and its capability to recover from tracking loss via background motion modeling. \begin{figure*}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/error_analysis_partial.png}} \caption{Qualitative comparison of top runners against the LaSOT dataset, where tracking boxes of SiamRPN++, UHP-SOT++, ECO and ECO-HC are shown in red, green, blue and yellow, respectively. The first two rows show sequences in which SiamRPN++ outperforms others significantly while the last row offers the sequence in which SiamRPN++ performs poorly.}\label{fig:error_showcase} \end{figure*} \begin{figure*}[htbp] \centerline{\includegraphics[width=\linewidth]{./figures/our_good_case.png}} \caption{Illustration of three sequences in which UHP-SOT++ performs the best. The tracking boxes of SiamRPN++, UHP-SOT++, ECO and ECO-HC are shown in red, green, blue and yellow, respectively.} \label{fig:ourgoodcase} \end{figure*} \section{Exemplary Sequences and Qualitative Analysis}\label{sec:discussion} After providing quantitative results in Sec. \ref{sec:experiments}, we conduct error analysis on a couple of representative sequences to gain more insights in this section. Several exemplary sequences from LaSOT are shown in Fig.~\ref{fig:error_showcase}, in which SiamRPN++ performs either very well or quite poorly. In the first two sequences, we see the power of accurate box regression contributed by the RPN. In this type of sequences, good trackers can follow the object well. Yet, their poor bounding boxes lead to a low success score. Furthermore, the appearance model would be contaminated by the background information as shown in the second cat example. The appearance model of DCF-based methods learns background texture (rather than follows the cat) gradually. When the box only covers part of the object, it might also miss some object features, resulting in a degraded appearance model. In both scenarios, the long-term performance will drop rapidly. Although UHP-SOT++ allows the aspect ratio change to some extent as seen in the first flag example, its residual map obtained by background motion modeling is still not as effective as the RPN due to lack of semantic meaning. Generally speaking, the performance of UHP-SOT++ relies on the quality of the appearance model and the residual map. On the other hand, SiamRPN++ is not robust enough to handle a wide range of sequences well. The third example sequence is from video games. SiamRPN++ somehow includes background objects in its box proposals and drifts away from its targets in the presented frames. Actually, these background objects are different from their corresponding target objects in either semantic meaning or local information such as color or texture. The performance of the other three trackers is not affected. We see that they follow the ground truth without any problem. One explanation is that these video game sequences could be few in the training set and, as a result, SiamRPN++ cannot offer a reliable tracking result for them. Finally, several sequences in which UHP-SOT++ has the top performance are shown in Fig. \ref{fig:ourgoodcase}. In the first cup sequence, all other benchmarking methods lose the target while UHP-SOT++ could go back to the object once the object has obvious motion in the scene. In the second bottle sequence, UHP-SOT++ successfully detects occlusion without making random guesses and the object box trajectory avoids the box to drift away. In contrast, other trackers make ambitious moves without considering the inertia of motion. The third bus sequence is a complicated one that involves several challenges such as full occlusion, scale change and aspect ratio change. UHP-SOT++ is the only one that can recover from tracking loss and provide flexible box predictions. These examples demonstrate the potential of UHP-SOT++ that exploits object and background motion clues across frames effectively. \section{Conclusion and Future Work}\label{sec:conclusion} An unsupervised high-performance tracker, UHP-SOT++, was proposed in this paper. It incorporated two new modules in the STRCF tracker module. They were the background motion modeling module and the object box trajectory modeling module. Furthermore, a novel fusion strategy was adopted to combine proposals from all three modules systematically. It was shown by extensive experimental results on large-scale datasets that UHP-SOT++ can generate robust and flexible object bounding boxes and offer a real-time high-performance tracking solution on resource-limited platforms. The pros and cons of supervised and unsupervised trackers were discussed. Unsupervised trackers such as UHP-SOT and UHP-SOT++ have the potential in delivering an explainable lightweight tracking solution while maintaining good performance in accuracy. Supervised trackers such as SiamRPN++ benefit from offline end-to-end learning and perform well in general. However, they need to run on GPUs, which is too costly for mobile and edge devices. They may encounter problems in rare samples. Extensive supervision with annotated object boxes is costly. Lack of interpretability could be a barrier for further performance boosting. Although UHP-SOT++ offers a state-of-the-art unsupervised tracking solution, there is still a performance gap between UHP-SOT++ and SiamRPN++. It is worthwhile to find innovative ways to narrow down the performance gap while keeping its attractive features such as interpretability, unsupervised real-time tracking capability on small devices, etc. as future extension. One idea is to find salient points in the predicted and reference frames individually, develop a way to build their correspondences, and reconstruct the object box in the predicted frame based on its salient points. \bibliographystyle{IEEEtran}
{'timestamp': '2022-04-08T02:07:17', 'yymm': '2111', 'arxiv_id': '2111.07548', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07548'}
arxiv
\section{Conclusion} We propose a GZSL approach without relying on class attribute vectors. Our novel method can accurately predict Gleason grades from MR images with lower resolution and less information content than histopathology images. This has the potential to improve accuracy of early detection and staging of PCa. A self-supervised component ensures the semantic gap between Seen and Unseen classes is easily covered. The distribution of synthetic features generated by our method are close to the actual distribution, while removing the self-supervised term results in unrealistic distributions. Results show our method's superior performance and synergy between different loss terms leads to improved GZSL classification. We observe failure cases where the acquired MR images are not of sufficiently good resolution to allow accurate registration of histopathology and MRI. Future work will aim to address this issue \section{Experimental Results} \label{sec:expt} \subsubsection{Dataset Details:} We use images from $321$ patients ($48-70$ years; mean: $58.5$ years) undergone prostate surgery with pre-operative T2-w and Apparent Diffusion Coefficient MRI, and post-operative digitized histopathology images. To ensure prostate tissue is sectioned in same plane as T2w MRI custom 3D printed molds were used. Majority votes among three pathologists provided Gleason grades was the consensus annotation. Pre-operative MRI and histopathology images were registered \cite{Bhatta11} to enable accurate mapping of cancer labels. We have the following classes: Class $1: Grade-3, 67$ patients, Class $2:Grades-3+4/4+3, 60$ patients, Class $3:Grade-4, 74$ patients, Class $4:Grades-4+5/5+4, 57$ patients, Class $5:Grade-5, 63$ patients. In the supplementary we show results for the Kaggle DR challenge \cite{Kaggle} and PANDA challenge \cite{Panda}. \textbf{Pre-processing:} Histopathology images were smoothed with a Gaussian filter ($\sigma= 0.25$). They were downsampled to $224 \times 224$ with X-Y resolution $0.25 \times 0.25$ mm$^{2}$. The T2w images, prostate masks, and Gleason labels are projected on the corresponding downsampled histopathology images and resampled to the same X-Y resolution. This ensures corresponding pixels in each modality represents the same physical area. MR images were normalized using histogram alignment \cite{Bhatta12} The training, validation, and test sets had $193/64/64$ patients. We compare results of our method MM$_{GZSL}$ (Multimodal GZSL) with different feature generation based GZSL methods 1) CVAE based feature synthesis method of \cite{HuangCVPR19}; 2) GZSL using over complete distributions \cite{KeshariCvpr20}; 3) self-supervised learning GZSL method of \cite{WuCvpr20}; 4) cycle-GAN GZSL method of \cite{FelixEccv18}; 5) $FSL$- the fully supervised learning method of \cite{BhattaMiccai20} using the same data split, actual labels of `Unseen' class and almost equal representation of all classes. \begin{table}[ht] \begin{center} \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|} \hline {} & {$Acc_S$} & {$Acc_U$} & {H} & {p} & {$Sen_S$} & {$Spe_S$} & {$Sen_U$} & {$Spe_U$} \\ \hline \multicolumn{9}{|c|}{\textbf{Comparison Methods}} \\ \hline {MM$_{GZSL}$} & {83.6(2.4)} & {81.7(3.0)} & {82.6(2.8)} & {-} & {84.1(3.1)} & {82.9(2.6)} & {81.2(3.0)} & {80.1(3.3)}\\ \hline {\cite{HuangCVPR19}} & {80.3(3.5)} & {73.4(3.6)} & {76.7(2.8)} & {0.002} & {81.2(3.6)} & {79.9(3.5)} & {74.1(3.2)} & {72.8(3.4)} \\ \hline \cite{KeshariCvpr20} & {80.6(3.4)} & {72.8(3.0)} & {76.5(3.2)} & {0.001} & {81.1(2.9)} & {80.0(3.2)} & {73.5(3.1)} & {72.1(3.4)} \\ \hline \cite{WuCvpr20} & {81.1(2.9)} & {73.2(3.2)} & {76.9(3.1)} & {0.001} & {81.8(3.5)} & {80.7(3.1)} & {74.0(3.5)} & {72.9(3.7)} \\ \hline \cite{FelixEccv18} & {81.2(3.7)} & {72.8(3.8)} & {76.7(3.8)} & {0.004} & {81.8(3.1)} & {80.7(3.4)} & {73.1(4.0)} & {71.9(4.2)} \\ \hline FSL & {83.9(2.2)} & {83.3(2.5)} & {83.5(2.3)} & {0.01} & {84.9(2.4)} & {83.5(2.6)} & {83.7(2.8)} & {82.5(2.6)} \\ \hline \multicolumn{9}{|c|}{\textbf{Ablation Studies}} \\ \hline {MM$_{wCPC}$} & {79.1(3.1)} & {72.3(3.8)} & {75.5(3.4)} & {0.001} & {79.8(3.4)} & {78.3(3.5)} & {73(3.6)} & {82.5(3.1)}\\ \hline {MM$_{wReg}$} & {80.1(3.7)} & {72.2(3.5)} & {75.9(3.5)} & {0.0001} & {80.5(3.4)} & {78.8(3.5)} & {72.8(3.8)} & {71.3(4.0)} \\ \hline {MM$_{wC}$} & {79.2(3.9)} & {72.9(4.0)} & {75.9(3.9)} & {0.009} & {80.1(3.8)} & {78.6(4.3)} & {73.3(4.1)} & {72.1(4.2)} \\ \hline {MM$_{wE}$} & {80.2(3.7)} & {73.0(3.9)} & {76.4(3.7)} & {0.005} & {80.8(3.3)} & {79.5(3.8)} & {74.1(3.8)} & {72.4(3.4)} \\ \hline {MM$_{MR}$} & {75.6(4.2)} & {71.1(4.5)} & {73.3(4.3)} & {0.007} & {76.3(4.5)} & {75.0(4.3)} & {71.9(4.1)} & {70.4(4.3)}\\ \hline {MM$_{DP}$} & {81.2(3.0)} & {79.1(3.6)} & {80.1(3.4)} & {0.008} & {82.0(3.4)} & {80.6(3.5)} & {79.9(3.9)} & {78.4(4.2)} \\ \hline \end{tabular} \caption{\textbf{GZSL and Ablation Results:} Average classification accuracy ($\%$) and harmonic mean accuracy of generalized zero-shot learning when test samples are from Seen (Setting $A$) or unseen (Setting $B$) classes. Mean and variance are reported when the number of classes in the `Seen' set is $3$. $p$ values are with respect to \textbf{Harmonic Mean of MM$_{GZSL}$}.} \label{tab:GZSL_3class} \end{center} \end{table} \subsection{Generalized Zero Shot Learning Results} Table \ref{tab:GZSL_3class} summarizes the results of our algorithm and other methods when the Seen set has samples from $3$ classes. The numbers are an average of $5$ runs. Samples from $3$ labeled classes presents the optimum scenario balancing high classification accuracy, and generation of representative synthetic samples. Setting $A$ does better than setting $B$. Since GZSL is a very challenging problem, it is expected that classification performance on Unseen classes will not match those of Seen classes. MM$_{GZSL}$'s performance is closest to FSL. Since FSL has been trained with all classes in training and test sets it gives the best results. % We use the McNemar test and determine that the difference in $Acc_S$ of MM$_{GZSL}$ and FSL is not significant ($p=0.062$) although the corresponding values for $Acc_U$ are significant ($p=0.031$) which is not surprising since real Unseen examples have not been encountered in GZSL. Since MM$_{GZSL}$'s performance is closest to FSL for Unseen classes, it demonstrates MM$_{GZSL}$'s effectiveness in generating realistic features of unseen classes. We refer the reader to the supplementary material for additional results (e.g. using different number of classes in the Seen dataset). The individual Per Class mean accuracy and variance are: \textbf{Setting~A:-}Class1=84.1(2.4), Class2=83.8(2.8), Class3=84.1(2.3), Class4=82.9(2.8), Class5=82.9(3.1). \textbf{Setting~B-} Class1=83.1(2.7), Class2=82.9 (2.8), Class3=81.1 (2.9), Class4=79.0(3.2), Class5=78.2(3.9). This shows that our feature generation and classification is not biased to any specific class. \subsubsection{Ablation Studies:} Table~\ref{tab:GZSL_3class} shows ablation results where each row denotes a specific setting without the particular term in the final objective function in Eqn~\ref{eq:lfinal} - e.g., MM$_{wCPC}$ denotes our proposed method MM$_{GZSL}$ without the self-supervised loss $\mathcal{L}_{CPC}$. MM$_{wCPC}$ shows the worst performance indicating $\mathcal{L}_{CPC}$'s correspondingly higher contribution than other terms. The $p-$values indicate each term's contribution is significant for the overall performance of MM$_{GZSL}$ and excluding any one leads to significant performance degradation. We also show in Table~\ref{tab:GZSL_3class} the result of using: 1) only the synthetic MR features (MM$_{MR}$); 2) only digital histopathology features (MM$_{DP}$) obtained by transforming $F_{MRI}$ to get $F_{DP}$. MM$_{DP}$ gives performance metrics closer to MM$_{GZSL}$, which indicates that the digital histopathology images provide highly discriminative information compared to MR images. However, MR images also have a notable contribution, as indicated by the p-values. In another set of experiments we redesign the GZSL experiments to generate synthetic histopathology features $F_{DP}$ instead of $F_{MRI}$ and then transforming them to get MR features. We obtain very similar performance ($Acc_S=83.7, Acc_U=80.8, H=82.2$) to the original MM$_{GZSL}$ setting. This demonstrates that cycle GAN based feature transformation network does a good job of learning accurate histopathology features from the corresponding MR features. {\subsubsection{Visualization of Synthetic Features}:} Figure~\ref{fig:FeatVis} (a) shows t-SNE plot of real data features where the classes are spread over a wide area, with overlap amongst consecutive classes. Figures~\ref{fig:FeatVis} (b,c,d) show, respectively, distribution of synthetic features generated by MM$_{GZSL}$, MM$_{wCPC}$ and \cite{WuCvpr20}. MM$_{GZSL}$ features are the most similar to the original data. MM$_{wCPC}$ and \cite{WuCvpr20} synthesize sub-optimal feature representation of actual features, resulting in poor classification performance on unseen classes. \begin{figure}[t] \centering \begin{tabular}{cccc} \includegraphics[height=2.3cm, width=3cm]{Features_Actual.jpg} & \includegraphics[height=2.3cm, width=3cm]{Features_SSL.jpg} & \includegraphics[height=2.3cm, width=3cm]{Features_NoSSL.jpg} & \includegraphics[height=2.3cm, width=3cm]{Features_ClassLabel.jpg} \\ (a) & (b) & (c) & (d) \\ \end{tabular} \begin{tabular}{c} \includegraphics[height=0.6cm, width=8cm]{Index.png} \\ \end{tabular} \caption{Feature visualizations: (a) Seen+Unseen classes from actual dataset; distribution of synthetic samples generated by b) $MM_{GZSL}$; (c) $MM_{GZSL}$ without self-supervision; (d) for \cite{WuCvpr20}. Different colours represent different classes. (b) is closer to (a), while (c) and (d) are quite different.} \label{fig:FeatVis} \end{figure} \section{Introduction} \label{sec:intro} Early and accurate diagnosis of prostate cancer (PCa) is an important clinical problem. High resolution histopathology images provide the gold standard but involve invasive tissue resection. Non-invasive techniques like magnetic resonance imaging (MRI) are useful for early abnormality detection \cite{Promise12,MonusacTMI,Mahapatra_Thesis,KuanarVC,MahapatraTMI2021,JuJbhi2020,Frontiers2020,Mahapatra_PR2020,ZGe_MTA2019,Behzad_PR2020} and easier to acquire, but their low resolution and noise makes it difficult to detect subtle differences between benign conditions and cancer. A combination of MRI and histopathology features can potentially leverage their respective advantages for improved accuracy in early PCa detection. Accessing annotated multimodal data of same patient from same examination instance is a challenge. % Hence a machine learning model to generate one domain's features from the other is beneficial to combine them for PCa detection. Current supervised learning \cite{BhattaMiccai20,Mahapatra_CVIU2019,Mahapatra_CMIG2019,Mahapatra_LME_PR2017,Zilly_CMIG_2016,Mahapatra_SSLAL_CD_CMPB,Mahapatra_SSLAL_Pro_JMI,Mahapatra_LME_CVIU,LiTMI_2015,MahapatraJDI_Cardiac_FSL,Mahapatra_JSTSP2014,MahapatraTIP_RF2014}, and multiple instance learning \cite{GGL26,MahapatraTBME_Pro2014,MahapatraTMI_CD2013,MahapatraJDICD2013,MahapatraJDIMutCont2013,MahapatraJDIGCSP2013,MahapatraJDIJSGR2013,MahapatraTrack_Book,MahapatraJDISkull2012,MahapatraTIP2012,MahapatraTBME2011,MahapatraEURASIP2010,MahapatraTh2012,MahapatraRegBook} approaches for Gleason grading use all class labels in training. Accessing labeled samples of all Gleason grades is challenging, and we also encounter known and unknown cases at test time, making the problem one of generalized zero-shot learning (GZSL). % We propose to predict Gleason grades for PCa by generating histopathology features from MRI features and combining them for GZSL based disease classification. GZSL classifies natural images from seen and unseen classes \cite{FelixEccv18,Mahapatra_CVAMD2021,PandeyiMIMIC2021,SrivastavaFAIR2021,Mahapatra_DART21b,Mahapatra_DART21a,LieMiccai21,TongDART20,Mahapatra_MICCAI20,Behzad_MICCAI20,Mahapatra_CVPR2020,Kuanar_ICIP19,Bozorgtabar_ICCV19,Xing_MICCAI19} and uses Generative Dual Adversarial Network (GDAN) \cite{HuangCVPR19,Mahapatra_ISBI19,MahapatraAL_MICCAI18,Mahapatra_MLMI18,Sedai_OMIA18,Sedai_MLMI18,MahapatraGAN_ISBI18,Sedai_MICCAI17,Mahapatra_MICCAI17,Roy_ISBI17,Roy_DICTA16,Tennakoon_OMIA16,Sedai_OMIA16}, overcomplete distributions \cite{KeshariCvpr20,Mahapatra_OMIA16,Mahapatra_MLMI16,Sedai_EMBC16,Mahapatra_EMBC16,Mahapatra_MLMI15_Optic,Mahapatra_MLMI15_Prostate,Mahapatra_OMIA15,MahapatraISBI15_Optic,MahapatraISBI15_JSGR,MahapatraISBI15_CD,KuangAMM14,Mahapatra_ABD2014,Schuffler_ABD2014,Schuffler_ABD2014_2,MahapatraISBI_CD2014} and domain aware visual bias elimination \cite{MinCVPR20,MahapatraMICCAI_CD2013,Schuffler_ABD2013,MahapatraProISBI13,MahapatraRVISBI13,MahapatraWssISBI13,MahapatraCDFssISBI13,MahapatraCDSPIE13,MahapatraABD12,MahapatraMLMI12,MahapatraSTACOM12,VosEMBC,MahapatraGRSPIE12,MahapatraMiccaiIAHBD11,MahapatraMiccai11,MahapatraMiccai10}. But it has not been well explored for medical images. One major reason being the availability of class attribute vectors for natural images that describe characteristics of seen and unseen classes, but are challenging to obtain for medical images. Self-supervised learning (SSL) also addresses labeled data shortage and has found wide use in medical image analysis by using innovative pre-text tasks for active learning \cite{MahapatraTMI2021,MahapatraICIP10,MahapatraICDIP10a,MahapatraICDIP10b,MahapatraMiccai08,MahapatraISBI08,MahapatraICME08,MahapatraICBME08_Retrieve,MahapatraICBME08_Sal,MahapatraSPIE08,MahapatraICIT06,Covi19_Ar,DARTSyn_Ar,Kuanar_AR2,TMI2021_Ar,Kuanar_AR1}, anomaly detection \cite{Behzad_MICCAI20,Lie_AR2,Lie_AR,Salad_AR,Stain_AR,DART2020_Ar,CVPR2020_Ar,sZoom_Ar,CVIU_Ar,AMD_OCT,GANReg2_Ar,GANReg1_Ar,PGAN_Ar,Haze_Ar,Xr_Ar,RegGan_Ar}, and data augmentation \cite{Mahapatra_CVPR2020,ISR_Ar,LME_Ar,Misc,Health_p,Pat2,Pat3,Pat4,Pat5,Pat6,Pat7,Pat8,Pat9,Pat10}. SSL has been applied to histopathology images using domain specific pretext tasks \cite{SelfPath,Pat11,Pat12,Pat13,Pat14,Pat15,Pat16,Pat17,Pat18}, semi-supervised histology classification \cite{LuMahmood}, stain normalization \cite{Mahapatra_MICCAI20}, registration \cite{TongDART20} and cancer subtyping using visual dictionaries. Wu et al. \cite{WuCvpr20} combine SSL and GZSL for natural images but rely on class attribute vectors and unlabeled target data for training. Our current work makes the following contributions: 1) We propose a \textbf{multimodal framework for seen and unseen Gleason grade prediction from MR images by combining GZSL and SSL.} 2) Unlike previous methods used for natural images we do not require class attribute vectors nor unlabeled target data during training. 3) We propose a \textbf{self-supervised learning} (SSL) approach for feature synthesis of seen and unseen classes that exploits the ordered relationship between different Gleason grades to generate new features. Although the method by \cite{BhattaMiccai20} uses features from MRI and histopathology images:1) it is a fully supervised method that has no Unseen classes during test time; 2) it also uses MRI and histopathology features from available data while we generate synthetic features to overcome unavailability of one data modality. \section{Method} \label{sec:method} \begin{figure}[t] \centering \begin{tabular}{c} \includegraphics[height=5.5cm, width=10.6cm]{Workflow_MICCAI.png} \\ \end{tabular} \caption{\textbf{Training Workflow:} Feature extraction from MR and digital pathology images generates respective feature vectors $F_{MRI}$ and $F_{DP}$. A $F_{MRI}$ is input to a feature synthesis network to generate new MR features for `Seen' and `Unseen' classes, which are passed through the feature transformation network to obtain corresponding $F_{DP}$. Combined MR and histopathology features are used to train a softmax classifier for identifying `Seen' and `Unseen' test classes. A self-supervised module contributes to the sample generation step through $\mathcal{L}_{CPC}$. } \label{fig:workflow} \end{figure} \subsection{Feature Extraction And Transformation:} \label{met:feat} Figure~\ref{fig:workflow} depicts our overall proposed workflow, which has 3 networks for: feature extraction, feature transformation and self supervised feature synthesis. Let the training set consist of \emph{histopathology and MR images} from PCa cases with known Gleason grades. We train a network that can correctly predict seen and unseen Gleason grades using \emph{MR images only}. % Let the dataset of `Seen' and `Unseen' classes be $S,U$ and their corresponding labels be $\mathcal{Y}_{s},\mathcal{Y}_{u}$. $\mathcal{Y}=\mathcal{Y}_{s} \cup \mathcal{Y}_{u}$, and $\mathcal{Y}_{s} \cap \mathcal{Y}_{u}=\emptyset$. Previous works \cite{FelixEccv18} show that generating feature vectors, instead of images, performs better for GZSL classification since output images of generative models can be blurry, especially with multiple objects (e.g., multiple cells in histopathology images). Additionally, generating high-resolution histopathology images from low resolution and noisy MRI is challenging, while finding a transformation between their feature vectors is much more feasible. We train two separate ResNet-50 networks \cite{ResNet50} as feature extractors for MR and DP images. Histopathology image feature extractor ($FE_{DP}$) is pre-trained on the PANDA dataset \cite{Panda} that has a large number of whole slide images for PCa classification. $FE_{MRI}$ is pre-trained with the PROMISE12 challenge dataset \cite{Promise12} in a self-supervised manner. Since PROMISE12 is for prostate segmentation from MRI and does not have classification labels, we use a pre-text task of predicting if an image slice has the prostate or not. Gleason grades of MRI are the same as corresponding histopathology images. The images are processed through the convolution blocks and the $1000$ dimensional output of the last FC layer is the feature vector for MRI ($F_{MRI}$) and pathology images ($F_{DP}$). \textbf{Feature Transformation} is achieved using CycleGANs \cite{CyclicGANS,MahapatraGAN_ISBI18,Mahapatra_PR2020,Mahapatra_MLMI18,Mahapatra_ISBI19} to learn mapping functions $G : X \rightarrow Y$ and $F : Y \rightarrow X$, between feature vectors $X=F_{MRI}$ and $Y=F_{DP}$. Adversarial discriminator $D_X$ differentiates between real features $F_{DP}$ and generated features $\widehat{F}_{DP}$, and $D_Y$ distinguishes between $F_{MRI}$ and $\widehat{F}_{MRI}$. The adversarial loss (Eqn~\ref{eqn:cyGan1}) and cycle consistency loss (Eqn.~\ref{eqn:cyGan2}) are, \begin{equation} \begin{split} L_{adv}(G,D_Y) = \mathbb{E}_{y} \left[\log D_Y(y)\right] + \mathbb{E}_{x} \left[\log \left(1-D_Y(G(x))\right)\right], \\ L_{adv}(F,D_X) = \mathbb{E}_{x} \left[\log D_X(x)\right] + \mathbb{E}_{y} \left[\log \left(1-D_X(F(y))\right)\right]. \end{split} \label{eqn:cyGan1} \end{equation} \begin{equation} L_{cyc}(G,F)= E_{x} \left\|F(G(x))-x\right\|_1 + E_{y} \left\|G(F(y))-y\right\|_1. \label{eqn:cyGan2} \end{equation} \paragraph{\textbf{Network Training}}: is done using $L_{adv}(G,D_Y)+L_{adv}(F,D_X)+L_{cyc}(G,F)$. Generator $G$ is a multi-layer perceptron (MLP) with a hidden layer of $4096$ nodes having LeakyReLU \cite{Felix34}. The output layer with $2048$ nodes has ReLU activation \cite{Felix35}. $G$'s weights are initialized with a truncated normal of $\mu=0$, $\sigma=0.01$, and biases initialized to $0$. Discriminator $D$ is an MLP with a hidden layer of $2048$ nodes activated by LeakyReLU, and the output layer has no activation. $D$'s initialization is the same as $G$, and we use Adam optimizer \cite{Adam}. \subsection{CVAE Based Feature Generator Using Self Supervision} The conditional variational autoencoder (CVAE) generator synthesizes feature vectors $F_{MRI}^{output}$ of desired class $c_{MRI}^{output}$, given input features $F_{MRI}^{input}$ with known class $c_{MRI}^{input}$. Let $x=F_{MRI}^{input}, z=F_{MRI}^{output}$ and $c=c_{MRI}^{output}$. The CVAE loss is, \begin{equation} \min_{\theta_G,\theta_E} \mathcal{L}_{CVAE} + \lambda_c \cdot \mathcal{L}_c + \lambda_{reg} \cdot \mathcal{L}_{reg} + \lambda_E \cdot \mathcal{L}_E + \lambda_{CPC} \cdot \mathcal{L}_{CPC} \label{eq:lfinal} \end{equation} Denoting CVAE encoder as $p_E(z|x)$ with parameters $\theta_E$, and the regressor output distribution as $p_R(c|x)$, $\mathcal{L}_{CVAE}$ is: \begin{equation} \mathcal{L}_{CVAE}(\theta_E,\theta_G)= -\mathbb{E}_{p_E(z|x),p(c|x)}\left[\log p_G(x|z,c)\right] + KL(p_E(z|x)||p(z)) \label{eq:lcvae} \end{equation} $\mathbb{E}_{p_E(z|x),p(c|x)}(.)$ is the generator’s reconstruction error, and KL divergence, $KL(.)$, encourages CVAE posterior (the encoder) to be close to the prior. Encoder $p_E(z|x)$, conditional decoder/generator $p_G(x|z, c)$, and regressor $p_R(c|x)$ are modeled as Gaussian distributions. The latent code $(z, c)$ is represented by disentangled representations $p_E(z|x)$ and $p_R(c|x)$ to avoid posterior collapse \cite{Verma11} . \subsubsection{Regression/Discriminator Module - $REG_{Synth}$:} \label{syn:reg} % is a feedforward neural network mapping input feature vector $x \in \mathcal{R}^{D}$ to its corresponding class-value $c \in \mathcal{R}^{1}$ . $REG_{Synth}$ is a probabilistic model $p_R(c|x)$ with parameters $\theta_R$ and is trained using supervised ($\mathcal{L}_{Sup}$) and unsupervised ($\mathcal{L}_{Unsup}$) losses \begin{equation} \min_{\theta_R} \mathcal{L}_R = \mathcal{L}_{Sup} + \lambda_R \cdot \mathcal{L}_{Unsup} \label{eq:lreg2} \end{equation} $\lambda_R=0.2$ and $\mathcal{L}_{Sup}(\theta_R)=-\mathbb{E}_{ \{x_n,c_{n} \} }\left[ p_R(c_{n}|x_n) \right]$ is defined on labeled examples $\{x_n,c_{n}\}^{N}_{n=1}$ from the seen class. % % $\mathcal{L}_{Unsup}(\theta_R)=-\mathbb{E}_{p_{\theta_G} (\widehat{x}|z,c)p(z)p(c)} \left[ p_R(c|\widehat{x}) \right]$ is defined on synthesized examples $\widehat{x}$ from the generator. % $\mathcal{L}_{Unsup}$ is obtained by sampling $z$ from $p(z)$, and class-value $c$ sampled from $p(c)$ to generate an exemplar for $p_{\theta_G}(\widehat{x}|z,c))$, and we calculate the expectation w.r.t. these distributions. \subsubsection{Discriminator-Driven Learning:} The error back-propagated from $REG_{Synth}$ improves quality of synthetic samples $\widehat{x}$ making them similar to the desired output class-value $c$. This is achieved using multiple loss functions. The first generates samples whose regressed class value is close to the desired value, \begin{equation} \mathcal{L}_c(\theta_G)=-\mathbb{E}_{p_G(\widehat{x}|z,c)p(z)p(c)}\left[\log p_R(c|\widehat{x}) \right] \end{equation} The second term draws samples from prior $p(z)$ and combines with class-value from $p(c)$, to ensure the synthesized features are similar to the training data, \begin{equation} \mathcal{L}_{Reg}(\theta_G)=-\mathbb{E}_{p(z)p(c)}\left[\log p_G(\widehat{x}|z,c) \right] \label{eq:lreg} \end{equation} The third loss term ensures independence (disentanglement) \cite{Verma11} of $z$ from the class-value $c$. The encoder ensures that the sampling distribution and the one obtained from the generated sample follow the same distribution. \begin{equation} \mathcal{L}_{E}(\theta_G)=-\mathbb{E}_{\widehat{x} \sim p_G (\widehat{x}|z,c)} KL\left[\log p_E(z|\widehat{x})||q(z) \right] \label{eq:le} \end{equation} The distribution $q(z)$ could be the prior $p(z)$ or the posterior from a labeled sample $p(z|x_n)$. \subsubsection{Self Supervised Loss:} Gleason grades have a certain ordering, i.e., grade 3 indicates higher severity than grade $1$, and grade $5$ is higher than grade $3$. Contrastive Predictive Coding (CPC) \cite{Oord} learns self-supervised representations by predicting future observations from past ones and requires that observations be ordered in some dimension. % Inspired by CPC we train our network to predict features of desired Gleason grade from input features of a different grade. From the training data we construct pairs of $\{F_{MRI}^{input},c_{MRI}^{input},F_{MRI}^{output},c_{MRI}^{output}\}$, the input and output features and desired class label value $c_{MRI}^{output}$ of synthesized vector. Since the semantic gap between $F_{MRI}^{input}$ and $F_{MRI}^{output}$ may be too large, we use random transformations to first generate intermediate representation of positive $z^{+}$, anchor $z^{a}$ and negative $z^{-}$ features using the mutual information-based AMDIM approach of \cite{AMDIM}. AMDIM ensures that the mutual information between similar samples $z^{+},z^{a}$ is high while for dissimilar samples $z^{-},z^{a}$ it is low, where $z=F_{MRI}^{output}$. % The CPC objective (Eqn.~\ref{eq:lcpc}) evaluates the quality of the predictions using a contrastive loss where the goal is to correctly recognize the synthetic vector $z$ among a set of randomly sampled feature vectors $z_l=\{z^{+},z^{a},z^{-}\}$ \begin{equation} \mathcal{L}_{CPC} = -\sum \log \frac{\exp^{(F_{MRI}^{input})^{T} F_{MRI}^{output}}} {\exp^{(F_{MRI}^{input})^{T} F_{MRI}^{output}} + \sum \exp^{(F_{MRI}^{input})^{T} F_{MRI}^{output}} } \label{eq:lcpc} \end{equation} This loss is the InfoNCE inspired from Noise-Contrastive Estimation \cite{Gutmann2010,Mnih2013} and maximizes the mutual information between $c$ and $z$ \cite{Oord}. By specifying the desired class label value of synthesized vector and using it to guide feature generation in the CVAE framework we avoid the pitfalls of unconstrained and unrealistic feature generation common in generative model based GZSL (e.g.,\cite{Manc48,Felix8}) \textbf{Training And Implementation:} Our framework was implemented in PyTorch. The CVAE Encoder has two hidden layers of $2000$ and $1000$ units respectively while the CVAE Generator is implemented with one hidden layer of $1000$ hidden units. The Regressor has only one hidden layer of $800$ units. We choose Adam \cite{Adam} as our optimizer, and the momentum is set to ($0.9, 0.999$).The learning rate for CVAE and Regressor is $0.0001$. First the CVAE loss (Eqn.~\ref{eq:lcvae}) is pre-trained followed by joint training of regressor and encoder-generator pair in optimizing Eqn.~\ref{eq:lreg} and Eqn.~\ref{eq:lfinal} till convergence. Hyperparameter values were chosen using a train-validation split with $\lambda_R = 0.1, \lambda_c = 0.1, \lambda_{reg} = 0.1$, $\lambda_E = 0.1$, and $\lambda_{CPC} = 0.2$. Training the feature extractor for $50$ epochs takes 12 hours and the feature synthesis network for $50$ epochs takes 17 hours, all on a single NVIDIA V100 GPU (32 GB RAM). \textbf{ Evaluation Protocol:} The seen class $S$ has samples from $2$ or more Gleason grades, and the unseen class $U$ contains samples from remaining classes. $80-20$ split of $S$ is done into $S_{Train}/S_{Test}$ $F_{MRI}$ is synthesized from $S + U$ using the CVAE and combined with the corresponding synthetic $F_{DP}$ to obtain a single feature vector for training a softmax classifier minimizing the negative log-likelihood loss. Following standard practice for GZSL, average class accuracies are calculated for two settings: 1) $Setting ~\textbf{A}$: training is performed on synthesized samples of $S+U$ classes and test on $S_{Test}$. 2) $Setting ~\textbf{B}$: training is performed on synthesized samples of $S+U$ classes and test on $U$. Following GZSL protocol we report the harmonic mean $H=\frac{2\times Acc_U \times Acc_S}{Acc_U + Acc_S}$; $Acc_S$ and $Acc_U$ are classification accuracy of images from seen (setting $A$) and unseen (setting $B$) classes respectively: \subsection{Pyradiomics Features} The AUC values for the individual categories and combined features for the original image and saliency maps are compared with the baseline features in Figure~\ref{fig:PyRad_RankedFeatures} from which we make the following observations: \begin{enumerate} \item Pyradiomics features from the original images are less informative than the features from saliency maps. This is due to the fact that the original images have a lot of extra features which do not contribute towards sample selection. \item The ``First Order'' features from saliency maps outperforms the `Saliency' features (the IDEAL feature consisting of skewness) in Figure~\ref{fig:PyRad_RankedFeatures} (b). But the corresponding GLCM and Shape features are not very informative because the saliency maps are very sparse and do not have much structure or texture. Hence these two features do not contribute much. \item Combining all features (`PyRad-Combined' in Figure~\ref{fig:PyRad_RankedFeatures} (b) ) degrades the performance w.r.t `PyRad-FirstOrder' since noisy features from GLCM and Shape affect the final performance. This indicates that arbitrary feature combination does not necessarily improve classification performance, \cite{Schuffler}. \end{enumerate} \begin{figure}[t] \begin{tabular}{c} \includegraphics[height=4.2cm, width=7.49cm]{Miccai2020_Latex/Figures/PyRad_Image_rankedFeat.jpg} \\ (a) \\ \includegraphics[height=4.2cm, width=7.49cm]{Miccai2020_Latex/Figures/PyRad_Saliency_rankedFeat.jpg} \\ (b) \\ \end{tabular} \caption{(a) AUC values of \textbf{Ranked} pyrad features calcuated on original image; (b) AUC values for \textbf{Ranked} pyrad features calculated on saliency map } \label{fig:PyRad_RankedFeatures} \end{figure} \subsection{Results of Self Supervised Ordinal Clustering} \label{expt:deep} Figure~\ref{fig:OrdinalClustering} shows the learning curves when using the ordinal clustering approach on deep features (described in Section~\ref{met:ordinal} for saliency maps from the NIH dataset. We plot values for different dimensional feature vectors and the results in Figure~\ref{fig:OrdinalClustering} show that the performance depends upon the feature dimensions. High dimensional features (e.g., $512$) tend to be overfit the training data and do not generalize to the test data, while low dimension features (e.g., $128$,$64$ and $32$) do not provide sufficient discriminative information. A feature vector of $256$ elements gives the best performance on the saliency maps and outperfoms the `PyRad-FirstOrder' and `Saliency' features. This clearly indicates the effectiveness of deep features obtained from auto encoders for identifying informative samples from an image dataset. \begin{figure}[t] \begin{tabular}{c} \includegraphics[height=4.2cm, width=7.49cm]{Miccai2020_Latex/Figures/AUC_Ordinal_New2.jpg} \\ (a) \includegraphics[height=4.2cm, width=7.49cm]{Miccai2020_Latex/Figures/DeepFeatures_Selection.jpg} \\ (b) \end{tabular} \caption{AUC plots of Ordinal clustering of (a) Saliency Maps compared to uncertainty and saliency based plots; (b) after feature selection} \label{fig:OrdinalClustering} \end{figure} \section{Methods} \label{sec:met} \subsection{Intuition behind IDEAL} Figure~\ref{fig:Histograms} shows two example cases of patients with pleural effusion condition, with high and low levels of uncertainty (accumulated pixel-wise uncertainties via MC Dropout). As we compared the corresponding interpretability saliency (derived from Deep Taylor method \cite{alber2019innvestigate}) and uncertainty maps (shown in Fig.~\ref{fig:Histograms}(b) and Fig.~\ref{fig:Histograms}(d), respectively) and their histograms, Fig.~\ref{fig:Histograms}(c) and \ref{fig:Histograms}(e), we observed that the histograms of high and low informative images are quite distinct, thus verifying the fact that high and low informative images have different values for the most salient regions. Comparing between the high informative image histograms of interpretability saliency and uncertainty maps, we observed that the highest peak of the saliency map histogram (i.e. the ``primary'' peak) has a higher count than the corresponding uncertainty map's histogram ``primary peak''. Additionally, the interpretability saliency map histogram ``secondary peaks'' have lower count than those of the uncertainty map histogram. These point to the fact that, compared to the uncertainty method, the interpretability saliency approach identifies salient regions in a more focused manner. This is beneficial when the goal is to identify the most informative saliency maps for improved classification and segmentation. In the following sections we describe the components of the proposed IDEAL approach, including the different investigated information extraction approaches. \begin{figure*}[t] \begin{tabular}{c} \includegraphics[height=6.2cm, width=18cm]{Miccai2020_Latex/Figures/Histogram_Comb1.png} \\ \end{tabular} \caption{Visualization of saliency maps from different methods. Top row shows a high informative image and bottom row shows a low informative image for pleural effusion condition. (a) original image; (b) saliency map from Deep Taylor method; (c) histograms of saliency maps for high and low informative images using Deep Taylor; (d) saliency map obtained using Uncertainy; (e) histograms of saliency maps for high and low informative images using Uncertainty.} \label{fig:Histograms} \end{figure*} \begin{figure*}[htbp] \begin{tabular}{cccccc} \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Batch_Image5_Original.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Batch_Image5_10.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Batch_Image5_20.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Batch_Image5_40.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Batch_Image5_60.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Batch_Image5_90.png} \\ & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Unc_10.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Unc_20.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Unc_40.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Unc_60.png} & \includegraphics[height=2.2cm, width=2.5cm]{Miccai2020_Latex/Figures/Unc_90.png} \\ (a) & (b) & (c) & (d) & (e) & (f)\\ \end{tabular} \caption{Uncertainty maps (top row), and interpretability saliency maps (bottom row) for a given sample input image at different training data levels. (a) Original image (b) $10\%$ of informative samples (c) $20\%$ of informative samples; (d) $40\%$ of informative samples; (e) $60\%$ of informative samples; (f) $90\%$ of informative samples. } \label{fig:BatchSalMaps} \end{figure*} \subsection{Main components of IDEAL} Figure~\ref{fig:IDEALPipeline} depicts a general pipeline of the proposed IDEAL approach. Given unlabeled testing samples (i.e. sample pool), and an associated deep learning classification model (e.g. DenseNet) trained iteratively during active learning, an interpretability saliency map generator is used to produce saliency maps, from which a sample informativeness score (IDEAL Scoring) is calculated to rank pool samples by their informativeness. The IDEAL scoring can be produced in different ways, depending on how the information from the saliency maps is distilled to produce a ranking score for each pool sample. In this study we investigated three different ways of extracting information and scoring samples, which are presented in order of complexity: (i) From our original observation, a single feature extracted from the histogram of saliency maps (Fig.~\ref{fig:Histograms}(c)) is used to derive the IDEAL scoring, (ii) Multivariable radiomics features are extracted and combined into single IDEAL scores, and (iii) Our proposed novel Deep features extracted and used within a self-supervised approach to score informative samples. In the following we describe each component in detail and in relation to the clinical problem of automating lung disease classification and histopathology segmentation, as well as baseline methods used to benchmark the proposed IDEAL approach. \begin{figure*}[t] \includegraphics[height=4.2cm,width=18.0cm]{Miccai2020_Latex/Figures/IDEALPipeline.png} \caption{Proposed IDEAL approach. Given testing samples (i.e. pool samples) and a trained classifier, interpretability saliency maps are generated for each testing sample, and an \textit{IDEAL} score is generated from the saliency maps to characterize sample informativeness. Top-ranked samples are then prioritized for label query and for the next active learning training cycle.} \label{fig:IDEALPipeline} \end{figure*} \subsection{Classification model} The classification model is not per se a component of the IDEAL approach but rather an input its calculations are based on. We present it here to facilitate the presentations and descriptions of the data workflow, as presented in Fig.~\ref{fig:IDEALPipeline}. Any robust classification model can be used as the approach is not restricted to particular architectures. For lung disease classification from X-ray images, we experimented with $3$ different models namely, DenseNet-121 \cite{CheXNet},ResNet-50 \cite{ResNet} and VGG16 \cite{VGG}, and found the DenseNet-121 architecture to perform the best. We denote as $M$, the DenseNet-121 model, and point the reader to section \ref{sec:impldetails}, for further implementation details of the trained model. \snm{For the histopathology image segmentation task we used a DenseNet-121 classifier of the histopathology images (benign vs. malign), as a proxy of informativeness for the main task of image segmentation. This was motivated by multi-task learning where tasks are typically intertwined, and the availability of interpretability approaches for classification tasks. As shown in the results section, we show that this approach is effective in the segmentation task as well.} \subsection{Interpretability Saliency Map Generator} Image-specific saliency maps operate under the the basic principle of highlighting areas of an image that drive the prediction of a model. The importance of these areas can be obtained by investigating the flow of the gradients of a DL model calculated from the model’s output to the input image, or by analyzing the effect of a pixel (or region) to the output when that pixel (or region) is perturbed. This type of visualization facilitates interpretability of a model but also serves as a confirmatory tool to check that machine-based decisions align with common domain knowledge \cite{Reyes2020}. As mentioned, differently from previous works in interpretability, we aim here to employ saliency maps to perform active sample selection. To generate interpretability saliency maps we use the iNNvestigate library \cite{alber2019innvestigate} \footnote{https://github.com/albermax/innvestigate}, which implements several known interpretability approaches. We employ Deep Taylor, a known interpretability approach to generate saliency maps, due to its ability to highlight informative regions while yielding minimal importance to other regions. Deep Taylor operates similarly as other interpretability approaches by decomposing back-propagation gradients, of the studied model, into layer-wise relevance maps of individual cell activations, as a function of a queried input sample and class label (e.g. disease class)\cite{montavon2017explaining}. \subsection{IDEAL Sample Informativeness Score} In this section we formalize the definition of the IDEAL sample scoring. Given a test image $I \in R^{m \times n}$, a prediction model $M$ being updated via active learning, and the corresponding saliency map $S(I,M) \in R^{m \times n}$, we map the saliency map $S(I,M)$ into a sample informativeness score, termed IDEAL score as: \begin{equation} IDEAL_{score}:f(S(I,M))\in R^{m \times n} \rightarrow R. \label{eq:IDEALScore} \end{equation} The function $f$ can have different forms, depending on the way the information is extracted from the saliency map and converted into an informative sample score. We present results investigating three different approaches, described in further detail below. The IDEAL scores obtained for the set of testing samples are sorted in decreasing order and the top-n ranked samples are chosen for expert label querying and added to the next active learning cycle. The complete IDEAL process is summarized in Algorithm~\ref{alg1}. In Algorithm~\ref{alg1} the model $M_0$ can be a pretrained network or, as in our experiments, trained with a small part of the training dataset (e.g. 10\% of training). \begin{algorithm} \caption{Interpretability-Driven Sample Selection - IDEAL}\label{alg1} \begin{algorithmic}[1] \Require Pretrained model $M_0$, \textit{Saliency map operator} $S(\dot)$, $\mathbb{I}_{validation}$, $AUC_{target}$ \State $M \leftarrow M_0$ \Repeat \State $\mathbb{I}_{in} \leftarrow \{I_{in}\}$ \Comment{define set of input testing images} \State $\mathbb{S}_{in} \leftarrow \{S(\mathbb{I}_{in},M)\}$ \Comment{saliency maps given input set and current model} \State $\{ scores \}_{in} \leftarrow IDEAL_{score}(\mathbb{S}_{in}) $ \Comment{calculate informativeness scores} \State $ \mathbb{I}_{sort} \leftarrow sort(\mathbb{I}_{in},\{scores\}_{in})$ \Comment{sort $\mathbb{I}_{in}$ in decreasing order by scores} \State $\mathbb{I}_{train} \leftarrow \mathbb{I}_{sort}\{i=1,...,top\_n\}$ \label{alg1:topn} \Comment{select top-n ranked samples} \State $\mathbb{L}_{train} \leftarrow expert\_query(\mathbb{I}_{train})$ \Comment{label querying of selected samples} \State $M_{new} \leftarrow train(M,\mathbb{I}_{train},\mathbb{L}_{train})$ \Comment{train new model} \Until{$AUC(M_{new},\mathbb{I}_{validation}) \geq AUC_{target}$} \Comment{Repeat until target AUC is attained}\\ \Return $M_{new}$ \end{algorithmic} \end{algorithm} We now describe in detail each of the three studied feature extractor approaches: \vspace{5pt} \subsubsection{\textbf{Single Hand-crafted Feature - Kurtosis}} This first approach is motivated by the observation made from the histograms between high and low uncertainty samples, Figure~\ref{fig:Histograms}. As operator $f$ in Equation~\ref{eq:IDEALScore}, we defined $f=k(H(S(I)))$, with $H$ and $k$ corresponding to the histogram and kurtosis operators, respectively. Consequently, and based on our observations, informative samples are associated to larger kurtosis values and sorted accordingly to select informative ones. In the results section, this approach is referred to as \textit{Kurtosis}. \vspace{5pt} \subsubsection{\textbf{Multivariate Radiomics Features}} As second approach, we used the PyRadiomics package \cite{Pyrad} to extract different radiomics features from the saliency maps. Owing to the large number of potential features we employ a feature selection strategy. \snm{ PyRadiomics has 8 feature categories. We trained random forest (RF) classifiers to predict the image's disease label using each feature category. Based on the in-built information gain of the RF model, we identified the $3$ best performing categories as: ``First Order Statistics'' ($19$ features), ``Gray Level Co-occurrence Matrix (GLCM)'' (24 features), and ``Shape Based (2D)'' ($10$ features). The final features for each category is identified by performing an exhaustive search over all possible feature combinations and using it to predict disease labels with a RF classifier. The final features are summarized in Table~\ref{tab:features}. } In order to combine extracted selected radiomics features for ranking, \snm{we rank different metrics based on the Borda count, which has been used before for ranking informative samples \cite{OzdemirDLMIA2018}. With Borda count samples are ranked for each metric, and samples are selected based on the best combined rank as: \begin{equation} i^{*}=\arg \min_i \left(\sum_{m_k} f_{rank} m_k(I_i) \right) \end{equation} where $m_k$ denotes the $k^{th}$ pyradiomic feature calculated on image $I_i$. } In the results section, this approach is referred to as \textit{PyRad\_category}, with \textit{category} being one of the following \textit{\{1st-order, GLCM, 2DShape\}}. \begin{table}[!htbp] \begin{center} \caption{Description of selected Pyradiomics and Deep Saliency Features.} \begin{tabular}{|l|l|} \hline {\textbf{Feature Type}} & {\textbf{Comments}} \\ \hline {Kurtosis} & {Obtained from histogram of the intensity distribution} \\ \hline {Radiomics-} & {Initial $19$ features. Exhaustive search on $2^{19}-1$} \\ {First Order} & {combinations. $4$ best features - `Kurtosis', `Skewness',} \\ {} & {`Entropy' and `Total Energy'.} \\ \hline % {Radiomics-} & {Initial $24$ features. Exhaustive search on $2^{24}-1$ } \\ {GLCM} & {combinations. $4$ best features -`Sum Entropy',`Inverse } \\ {} & {Difference Normalized',`Difference Entropy' and } \\ {} & { ‘Maximal Correlation Coefficient’.} \\ \hline % {Radiomics-} & {Initial $10$ features. Exhaustive search on $2^{10}-1$ } \\ {Shape} & {combinations. $3$ best features -`Sphericity’, ‘Spherical } \\ {} & {Disproportion’, and‘Elongation’} \\ \hline % {Deep Saliency} & { Ordinal Clustering of latent feature vector} \\ {Features} & { followed by Self-Supervised step. Details in text. } \\ \hline \end{tabular} \label{tab:features} \end{center} \end{table} \vspace{5pt} \subsubsection{\textbf{Deep Saliency Features: Ordinal Clustering And Self Supervised Learning For Informative Sample Selection}} \label{met:ordinal} In this section we present the third and more advanced approach. We propose a novel approach that uses deep features extracted from an autoencoder and self supervised learning based ordinal clustering of informative samples. The goal in self-supervised learning is to identify a suitable self supervision task (or pretext task) that provides additional knowledge (in the form of network weights) to successfully train a model to solve the main task. Some common pretext tasks include for example, estimating relative position of patches \cite{Doersch,Noroozi}, local context \cite{Pathak}, and colour \cite{ZhangECCV2016}. Additionally, exemplar learning has been proposed as a self-supervised learning strategy \cite{Dosovitskiy} where the task is to classify each data instance into a unique class. Given a set of candidate pool samples, saliency maps are generated and, as first step, an auto encoder is trained to reconstruct them. The output of the encoding stage is a $l-$dimensional latent feature vector representation (referred to as \textit{Deep Saliency Features}), which is used as input for the next stage of ranking them. In order to discriminate informative samples from Deep Saliency Features, and in the absence of information to distill which Deep Saliency Features are associated to sample informativeness, we cast the problem as a self supervised learning approach to assign informativeness labels to saliency maps. Figure~\ref{fig:SSOrdinal} depicts the proposed self supervised learning approach, which is also explained in Algorithm~\ref{alg2}. It consists of the following steps: \begin{enumerate} \item Extracted latent feature vector representations are clustered using an ordinal cluster approach into $K(=10)$ clusters. \item Identify most representative sample of each cluster via measuring the closest sample to its centroid using L2 distance between extracted latent feature vectors. \item Query labels of the most representative sample per cluster (e.g. $K=10$ queries) \item Add the corresponding original image to the training set, and determine the change in AUC values ($\Delta AUC$) for a fixed validation set (independent of the training set). Rank samples according to decreasing $\Delta AUC$. \item Identify cluster whose representative image yields maximum positive $\Delta$AUC on validation set. \begin{enumerate} \item Select this cluster as most informative \item Label each cluster as $[1,\cdots,K]$ where $1$ is most informative cluster and $K$ denotes least informative cluster. \item Ranking and queried labels for each representative sample are propagated to all samples within each cluster. \end{enumerate} \item Use labelled samples from the previous step, and their corresponding deep saliency features to train a random forest classifier. \snm{In order to efficiently train the random forest classifier as new samples are selected, we use online random forests \cite{onlineRF}, which performs incremental training of the RF using the previously trained RF as a starting point. The saliency map is classified into one out of $K$ possible levels of informativeness. Use $RF_{final}$ (Algorithm~\ref{alg2}) to rank new (test) samples based on informativeness. } \end{enumerate} \snm{The choice of $K=10$ was to strike a balance between level of granularity and avoid clusters with too few or no samples. If $K$ is too high then we have to increase the batch size (from 32 to higher) to ensure sufficient samples in each cluster for accurately determining a representative vector. However, increased batch size leads to higher computation cost and poses challenges during training. If $K$ is too low then we lose granularity of informativeness rankings. For example, if $K=5$ then samples with different levels of informativeness will be in one cluster and make it difficult to train a reliable classifier to predict informativeness. Thus $K=10$ gives the best tradeoff between these two considerations. } \begin{algorithm} \caption{Self Supervised Deep Features - Training Stage } \label{alg2} \begin{algorithmic}[1] \Require \snm{Random forest $RF_0$, Set of Deep Saliency feature vectors $F$, \textit{Ordinal Clustering operator} $C(\dot)$, number of clusters $K$, $\mathbb{I}_{validation}$, $\mathbb{I}_{train}$} \State \snm{$RF \leftarrow RF_1 , n=1$ } \Repeat \State \snm{$\mathbb{F}_{n} \leftarrow \{F_{n}\}$ \Comment{Feature vectors for iteration $n$} \State $\mathbb{C}_{n} \leftarrow \{C(\mathbb{F}_{n})\}$ \Comment{clustering output given input set and clustering operator}} \State \snm{Identify representative samples of each cluster $\mathbb{F}_{rep}$ \Comment{sample closest to each cluster's centroid}} \State \snm{Identify corresponding original images $\mathbb{I}_{rep}$ \State Query label of most representative sample per cluster \Comment{For all K clusters}} \State \snm{$\mathbb{L}_{rep} \leftarrow expert\_query(\mathbb{I}_{rep})$ \Comment{label querying of representative samples}} \State \snm{$RF_{n} \leftarrow train(RF_{n-1},\mathbb{I}_{rep},\mathbb{L}_{rep})$ \Comment{update pre-trained model using online RF} \State Identify cluster $k$ with highest $+\Delta$AUC \State Label each cluster $[1,\cdots,K]$ \Comment{$1$ is most informative cluster and $K$ is least informative}} \State \snm{$\mathbb{I}_{train}=\mathbb{I}_{train} \setminus \mathbb{I}_{rep}$ \Comment{Update training set} \State $n \leftarrow n+1$ \Comment{Go to next iteration} \Until{$\mathbb{I}_{train}=\emptyset$} \Comment{Repeat until all training samples are used }}\\ \Return \snm{$RF_{final}$ \Comment{Random forest classifier that ranks samples based on informativeness}} \end{algorithmic} \end{algorithm} The proposed ordinal clustering and self supervised learning approach for informative sample selection leverages feature extraction information using modern deep learning technologies. This comes at the cost of a minimal label expert querying of representative samples (i.e. number of cluster $K)$, which based on our experience and the results obtained, yields a good trade-off for clinical utilization. In the results section this approach is referred to as \textit{Deep Features}. In the next section we present results obtained with the proposed and baseline approaches, along with several ablation experiments aiming at leveraging further insights and confirmatory evidence on the benefits of the proposed IDEAL approach. \begin{figure*}[t] \begin{tabular}{c} \includegraphics[height=7.4cm,width=16.0cm]{Miccai2020_Latex/Figures/Workflow1.png} \\ \end{tabular} \caption{Workflow for Ordinal Clustering and Self Supervised learning for informative sample selection. Deep features extracted from an autoencoder are used for ordinal clustering samples into to $K (e.g. K=10)$ clusters. Representative images from each cluster (i.e. samples closest to each cluster's centroid) are queried for labels and added to the training set. Changes in AUC values on a validation set are determined after updating the classification model. Based on $\Delta$AUC of each cluster's representative image, the $K$ clusters are assigned different levels of informativeness in a self supervised manner. Labels and ranking of representative samples are propagated to samples within each cluster, and random forest is trained on to learn to classify each saliency map into each of $K$-level informative levels. } \label{fig:SSOrdinal} \end{figure*} \section{Baseline Methods For Comparison} \label{sec:baselines} In this section we describe the baseline methods used for comparison purposes. \subsection{Standard Active Learning} As first baseline we considered a standard active learning framework where no sample selection is considered. In this setup, given a set of testing samples, a subset of samples are randomly chosen for label querying and active learning training. It is worth noting, that in clinical practice the number of samples reflects the amount of user interaction needed to incorporate new samples into the next cycle of active learning, and hence it needs to be kept as low as possible. In the results section we refer to this approach as \textit{Random}. \subsection{Uncertainty-driven sample selection} This corresponds to our second baseline. As proposed in \cite{MahapatraMICCAI2018, BozorgtabarCVIU2019}, uncertainty estimation can be used as a metric of sample informativeness for active learning. Given the deep learning model $M$ used for disease classification, mapping an input image $I$, to a unary output $\widehat{y}\in R$, the predictive uncertainty for pixel $y$ is approximated using: \begin{equation} Var(y)\approx \frac{1}{T} \sum_{t=1}^{T} \widehat{y}_t^{2} - \left(\frac{1}{T} \sum_{t=1}^{T} \widehat{y}_t \right)^{2} + \frac{1}{T} \sum_{t=1}^{T} \widehat{\sigma}_t^{2} \label{eqn:Uncert} \end{equation} $\widehat{\sigma}^{2}_t$ is the model's output for the predicted variance for pixel $y_t$, and ${\widehat{y}_t,\widehat{\sigma}^{2}_t}^{T}_{t=1}$ being a set of $T$ sampled outputs. Similarly as for the other compared approaches, the obtained uncertainty estimates are sorted from high to low uncertainty, and the \textit{top-n} samples are chosen for label querying, and added to the next active learning cycle. In the results section we refer to this approach as \textit{Uncertainty}. \subsection{Implementation details}\label{sec:impldetails} Our method was implemented in TensorFlow. We trained DenseNet-121 \cite{DenseNet} on \snm{NIH ChestXray14} dataset \cite{NIHXray}, and for the histopathology datasets. We used Adam \cite{Adam} with $\beta_1=0.93$, $\beta_2 = 0.999$, batch normalization, binary cross entropy loss, learning rate $1e-4$, $10^{5}$ update iterations and early stopping based on the validation accuracy. The architecture and trained parameters were kept constant across compared approaches. Training and test was performed on a NVIDIA Titan X GPU having $12$ GB RAM. Images are fed into the network with size $320 \times 320$ pixels. We employed 4-fold data augmentation (i.e. each sample augmented 4 times) using simple random combinations of rotations ($[-25,25]^{\circ}$), translations ($[-10,10]$ pixels in horizontal and vertical directions), and isotropic scaling ($[0.95-1.05]$ scaling factors). For generation of interpretability saliency maps, we used default parameters of the iNNvestigate implementation of Deep Taylor \cite{alber2019innvestigate}. For uncertainty estimation we used a total of $T=20$ dropout samples with dropout distributed across all layers \cite{BDNN}. During active learning the batch size for our experiments was set to $16$. \snm{As shown in Figure~\ref{fig:SSOrdinal} the encoder stage has 3 layers of $256,128,64$ neurons. The output is a $32$ dimensional latent feature vector which is fed to the decoding stage. The output is supposed to reconstruct the original input using the mean square error loss.}
{'timestamp': '2021-11-16T02:30:01', 'yymm': '2111', 'arxiv_id': '2111.07646', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07646'}
arxiv
\section{Introduction} Machine learning (ML) has progressed rapidly during the past decade, and ML models have been adopted in a wide range of applications, such as image recognition~\cite{HZRS16,KSH12}, speech recognition~\cite{GMH13,HDYDMJSVNSK12}, machine translation~\cite{BCB15}, etc. Most of the current ML applications are based on discriminative models, represented by classifiers. Generative models, on the other hand, have attracted an increasing amount of attention recently. The most representative generative model is generative adversarial networks (GANs)~\cite{GPMXWOCB14}. Due to the ability to produce novel samples from high-dimensional data distributions, GANs are finding appealing application scenarios, such as image-to-image translation~\cite{ZPIE17,LBK17,WLZTKC18}, image inpainting~\cite{ISI17}, text generation~\cite{AGLMZ17,VTBE15}, and sound generation~\cite{MKGKJSCB17,ODZSVGKSK16}. ML models have been shown to exhibit severe security and privacy vulnerabilities. Existing attacks including adversarial examples~\cite{SZSBEGF14,EEFLRXPKS18}, membership inference~\cite{SSSS17,SZHBFB19}, and model stealing~\cite{TZJRR16,PMGJCS17,OSF19} mainly focus on discriminative models. Recent research has also demonstrated the security and privacy risks of generative models. In particular, Hayes et al.~\cite{HMDC19} show that an adversary can effectively determine whether a data sample is used to train a target GAN. Chen et al.~\cite{CYZF20} further generalize this attack by proposing a taxonomy of membership inference scenarios against GANs. While most of the attacks against generative models focus on membership inference, other vulnerabilities are left largely unexplored. \subsection{Our Contributions} \mypara{Motivation} In this paper, we perform the first \emph{property inference attack} against GANs: an adversary aims to infer whether a target GAN's underlying training dataset exhibits a certain general property. Here, the general property is related to the macro-level information of the target GAN's training dataset. More importantly, the property is not related to the design purpose of the target GAN. For instance, if a GAN is trained to generate human faces, the property can be the proportion of white people in its training dataset. A successful property inference attack against a target GAN can lead to severe consequences. For instance, learning the property of a GAN's training dataset gains an adversary extra information of the data, which directly violates the intellectual property (IP) of the model owner, as the dataset is often expensive to collect. Also, an effective property inference attack can be used as a fairness auditing tool to make sure a GAN is not trained on biased data~\cite{BG18}. Moreover, this attack can be further leveraged as a stepping stone to perform more advanced attacks, such as membership inference~\cite{SSSS17}. \begin{figure*}[!t] \centering \begin{subfigure}{1.9\columnwidth} \includegraphics[width=\columnwidth]{pic/same_intuition.png} \caption{All white females} \label{figure:intuition_a} \end{subfigure} \begin{subfigure}{1.9\columnwidth} \includegraphics[width=\columnwidth]{pic/multi_intuition.png} \caption{Multiple groups} \label{figure:intuition_b} \end{subfigure} \caption{Samples generated by WGAN trained on (a) 256 images of white females drawn from CelebA dataset (b) 256 images of uniformly distributed demographic background (gender and pale skin) from CelebA dataset. We can see that almost all images in (a) are white females and images in (b) are rather diverse.} \label{figure:intuition} \end{figure*} \mypara{Attack Methodology} Our attack follows the intuition that the generated samples of a GAN can reflect its underlying training dataset's property. For instance, in \autoref{figure:intuition_a}, we can see a WGAN~\cite{ACB17} trained with faces of only white females mainly generates images of white females, while in \autoref{figure:intuition_b}, a WGAN trained with images from people with a diverse demographic background can produce a diverse set of images. We propose two attack scenarios, i.e., full black-box setting and partial black-box setting. For the former, we assume the adversary can just get samples blindly from the target GAN's generator. For the latter, the adversary can decide the input of the target GAN's generator, i.e., the latent code. Note that for both attack scenarios, the adversary does not have access to the target GAN's parameters, which means we focus on the most difficult setting for the adversary~\cite{SSSS17}. Both of our property inference attacks follow a general pipeline. The adversary first queries the target GAN model to obtain a set of generated samples. Then she relies on a property classifier to label these samples with respect to the target property. For instance, if the target property is the gender distribution of the GAN's training dataset, the property classifier is a gender classifier for the generated samples. In the end, she infers the target property by summarizing the results of the property classifier. For the partial black-box setting, since the adversary can choose the input, i.e., the latent code, for the target GAN, we propose a novel optimization framework which allows us to generate a set of latent codes, namely optimized latent code set, to reduce the number of queries to the target model. \mypara{Evaluation} Extensive experiments over four GANs on five different property inference tasks show that our attacks achieve very effective performance. In the gender prediction task on CelebA~\cite{LLWT15}, the average absolute difference between the inferred proportion and the ground truth proportion of males in the target training dataset is 2.4\% in the full black-box setting and 9.8\% in the partial black-box setting. In the age prediction task (proportion of youth) on AFAD~\cite{NZWGH16}, the average absolute difference is 9.7\% and 10.1\% in the full and partial black-box settings respectively. Meanwhile, in the income prediction task on the US Census dataset~\cite{UCIINCOME}, the average absolute difference is 2.9\% and 4.5\% in the full and partial black-box settings respectively. We further compare the two methodologies in detail and conclude that the partial black-box attack behaves better when using a limited number of generated samples (around 100 to 125), while the full black-box attack results in a high accuracy using a large number of random samples. We also observe that our full black-box attack works well even without any knowledge of the target training dataset. Also, our partial black-box attack works robustly with respect to different optimization starting points as well as the number, the structure, and the dataset of the shadow models. \mypara{Enhancing Membership Inference} We further enhance the state-of-the-art membership inference attack against GANs~\cite{CYZF20} leveraging our proposed property inference attacks. In detail, we calibrate a sample's membership prediction result based on its attributes and the property of the target GAN's training dataset obtained by our attack. Experimental result shows that our enhanced methodology increases the membership inference's AUC from 0.52 to 0.61 on the CelebA dataset. This further demonstrates the applicability of our proposed attacks. In summary, we make the following contributions in this paper: \begin{itemize} \item We propose the first property inference attack against generative models. \item We specify two attack scenarios and propose corresponding technical solutions relying on advanced ML techniques. \item We perform extensive experiments and demonstrate the efficacy of our proposed attacks. \item We show that our property inference attacks can serve as a building block to enhance other advanced attacks, in particular, membership inference against GANs. \end{itemize} \subsection{Organization} The rest of the paper is organized as follows. We introduce generative models, property inference attacks, and threat models used in this paper in \autoref{section:preliminaries}. Then, \autoref{section:attack} presents our attack workflow and detailed methodologies. The experiment setup and evaluation results are shown in \autoref{section:evaluation}. We further show how to leverage our attack to enhance membership inference in \autoref{section:MIA}. \autoref{section:related} discusses the related work and \autoref{section:conclusion} concludes this paper. \section{Preliminaries} \label{section:preliminaries} In this section, we first introduce generative models. Then, we present property inference attacks. The threat models considered in this paper are discussed in the end. \subsection{Generative Models} Machine learning models can be categorized into generative models and discriminative models. Discriminative models are mainly designed to solve classification problems, such as image recognition and text sentiment prediction. On the other hand, generative models aim to learn the underlying training data distribution and generate new data based on it. There exist various types of generative models, including Variational AutoEncoders (VAEs) and Generative Adversarial Networks (GANs). In this paper, we focus on GANs as they are the most popular generative models nowadays. A GAN is assembled with two neural networks, i.e., the generator and the discriminator. The generator takes random noise (latent code) as input and generates samples, while the discriminator performs adversarial training to distinguish the real and fake (generated) samples. In the training stage, these two networks are updated in turns: the generator learns to generate samples as realistic as possible while the discriminator learns to better separate real and fake samples. Mathematically, the loss function of a GAN is defined as the following. \[ \mathbb{E}_{x \sim \mathcal{D}_{\it{train}}}[\log \mathsf{D}(x)] + \mathbb{E}_{z \sim \mathcal{Z}}[\log(1-\mathsf{D}(\mathsf{G}(z)))] \] Here, $\mathsf{G}$ and $\mathsf{D}$ represent the generator and the discriminator, respectively. $ z \sim \mathcal{Z} $ denotes the latent code following a prior, normally multivariate Gaussian or uniform distribution. The training dataset of the GAN is represented by $\mathcal{D}_{\it{train}}$. As $\mathsf{G}$ is trained to minimize the loss and $\mathsf{D}$ aims to maximize the loss, the optimization for GAN follows a two-player minimax game. After being first introduced by Goodfellow et al.~\cite{GPMXWOCB14}, GANs have attracted a lot of attention. Over the years, many works have been proposed to enhance the original GANs, such as WGAN~\cite{ACB17}, DCGAN~\cite{RMC15}, WGAPNGP~\cite{GAADC17}, TGAN~\cite{XV18}, PGGAN~\cite{KALL18}, and BigGAN~\cite{BDS19}. In this paper, we focus on WGANGP, PGGAN, DCGAN, and TGAN as they have achieved strong performance in various settings empirically. Note that our method is general and can be applied to other types of GANs as well. \subsection{Property Inference Attacks} Property inference attacks aim to extract some general properties of a target ML model's training dataset, which the target model owner does not intend to share. Also, these general properties are not related to the target GAN's original design purposes. For instance, if the target model is used to generate realistic human profile photos, the property can be the gender distribution of the samples in the training dataset. A successful property inference attack allows an adversary to gain insights on the training data of the target model, which may violate the intellectual property of the model owner as high-quality data is normally expensive to collect. Also, property inference can serve as an important building block for other more advanced attacks, such as membership inference attacks~\cite{CYZF20} (see \autoref{section:MIA}). Moreover, property inference attacks can serve as a fairness auditor for the target model's training dataset, e.g., whether the samples used to train a model are equally distributed among different genders~\cite{BG18}. Recently, Ganju et al.~\cite{GWYGB18} propose the first property inference attack against discriminative models, in particular fully connected neural networks. In this setting, the adversary is assumed to have white-box access to the target model and uses a meta classifier to predict the property of the corresponding training dataset. The features of the meta classifier are summarized over the parameters of the model. The authors propose two approaches for feature summarization, including neuron sorting and DeepSets. To train the meta classifier, the adversary needs to establish multiple shadow models. Different from~\cite{GWYGB18}, our attack is set up in more practical cases, where the victim GAN is completely black-box or only part of the GAN parameters are accessible. So far, property inference attacks concentrate on discriminative models in the white-box setting. In this paper, we propose the first set of property inference attacks against generative models, represented by GANs. More importantly, we focus on the black-box setting which is the most difficult and realistic scenario for the adversary~\cite{SSSS17,SBBFZ20}. \subsection{Threat Models} \label{section:threat_model} Similar to the setting of discriminative models, the goal of the adversary here is to infer whether the target model's training dataset $\mathcal{D}_{\it{target}}$ has a certain property $\mathcal{P}$. We first assume the adversary has an auxiliary dataset $\mathcal{D}_{\it{auxiliary}}$ that comes from the same distribution of $\mathcal{D}_{\it{target}}$. The adversary leverages this auxiliary dataset to build local shadow GANs and classifiers for her attacks, i.e., $\mathcal{D}_{\it{auxiliary}}=\mathcal{D}_{\it{shadow}}\cup \mathcal{D}_{\it{classifier}}$ (see~\autoref{section:attack} for more details). This is also the common assumption used in most of the works in machine learning privacy~\cite{SSSS17,GWYGB18,SZHBFB19,SBBFZ20}. We also assume the adversary only has access to the generator of the target model as the discriminator is normally disregarded after the training phase. For simplicity, we use $\mathsf{G}_{\it{target}}$ to represent the target model in the rest of the paper. We consider two scenarios for the adversary including \emph{full black-box setting} and \emph{partial black-box setting}. \mypara{Full Black-box Setting} This is the least knowledgeable setting for the adversary, where she can just get the generated samples blindly from the target black-box generator $\mathsf{G}_{\it{target}}$. This attack scenario provides a good simulation of the online closed-source API~\cite{CYZF20}. \mypara{Partial Black-box Setting} In this scenario, the adversary also has no knowledge about the parameters of the target GAN but can construct the latent code $z$ to generate the corresponding sample from $\mathsf{G}_{\it{target}}$. In this way, she can feed her chosen latent codes to obtain specific generated samples. Formally, we use the latent code set $\{z_{i}\}_{i=1}^{\vert\mathbf{X}\vert}$ to represent her chosen latent codes in our paper. Moreover, we assume the adversary knows the architecture of the target GAN, as well as the training algorithm. Such information can be directly inferred by performing hyperparameter stealing attacks~\cite{OASF18,WG18}. \section{Attack Methodology} \label{section:attack} In this section, we first introduce our general attack pipeline. Then, we present the details of our attacks under two different scenarios. \subsection{Attack Workflow} Our attacks are designed based on the intuition that the generated samples of a target GAN can reflect the underlying training dataset's property. For instance, if a GAN is mainly trained with images of white males, we expect the generated images are more likely to be white males compared to other demographic backgrounds. \autoref{figure:intuition_a} shows a WGAN trained only on images of white female mainly generates samples that are recognized as white females. Meanwhile, \autoref{figure:intuition_b} shows a WGAN trained with samples from a diverse demographic background generates a diverse set of samples. Therefore, an adversary can estimate a target GAN's underlying property $\mathcal{P}_{\it{infer}}$ by inspecting the corresponding property of its generated samples ($\mathcal{P}_{\it{real}}$). \begin{figure}[!t] \centering \includegraphics[width=0.9\columnwidth]{pic/strategy.pdf} \caption{Workflow of the general property inference attack strategy. With the help of a property classifier $f_{\property}$, the adversary obtains $\mathcal{P}_{\it{infer}}$ to inspect $\mathcal{P}_{\it{real}}$, the target underlying property in the training dataset of $\mathsf{G}_{\it{target}}$.} \label{figure:strategy} \end{figure} \autoref{figure:strategy} depicts the general attack workflow, which can be roughly categorized into three steps. In the first step, the adversary queries the target generator $\mathsf{G}_{\it{target}}$ to produce synthetic samples $\mathbf{X}=\{\mathsf{G}(z_1),\mathsf{G}(z_2),\cdots,\mathsf{G}(z_{\vert\mathbf{X}\vert})\}$. Here, $\mathsf{G}(z_i)$ represents the $i$th generated sample from the target GAN with respect to the corresponding latent code $z_i$. The concrete methods for generating samples, i.e., choosing latent codes, for both full and partial black-box settings, are presented later in \autoref{section:full_black-box} and \autoref{section:partial_black-box}, respectively. Next, the adversary constructs a \emph{property classifier} $f_{\property}$ tailored for classifying the previously generated samples with respect to the target property she is interested in. For instance, if the target property is the gender distribution of the samples (profile images) in the underlying training dataset, the property classifier then predicts the gender of each sample. The property classifier here is trained with part of the auxiliary dataset, i.e., $\mathcal{D}_{\it{classifier}}$ (as described in \autoref{section:preliminaries}) that is disjoint from the underlying training dataset of target GAN. In the end, the adversary predicts $\mathcal{P}_{\it{infer}}$ based on the output of the property classifier. Concretely, she computes a function $\phi$ over the prediction of the property classifier, defined as: \[ \phi\left(\{f_{\property}(\mathsf{G}_{\it{target}}(z_i))\}_{i=1}^{\vert\mathbf{X}\vert}\right) \] In this paper, our attack focuses on inferring a general property as the distribution of a certain attribute, such as the gender distribution of the samples in the target underlying training dataset. Therefore, $\phi$ is realized as a function to summarize the distribution of the target attribute. However, we emphasize that our methodology is general and can be applied to infer other types of property. \begin{figure*}[!t] \centering \includegraphics[width=1.55\columnwidth]{pic/opt_noise.pdf} \caption{Methodology of optimizing input latent codes $(\noise\leftarrow\noise^{*})$ with shadow models.} \label{figure:opt_noise} \end{figure*} \subsection{Full Black-box Adversary} \label{section:full_black-box} For a full black-box adversary, she can only obtain generated samples blindly from the target GAN. These acquired samples $\mathbf{X}$, generated from a random latent code set, are consumed by $f_{\property}$, and then $\phi$ to get the attack result $\mathcal{P}_{\it{infer}}$, just as presented in the basic attack strategy. More formally, the property inference attack through full black-box GANs can be described as the following, where the latent codes are just drawn randomly from a prior. \[ \phi\left(\{f_{\property}\left(\mathsf{G}_{\it{target}}\left(z_{i}^{\circ} \right)\right)\}_{i=1}^{\vert\mathbf{X}\vert}\right) \] Here, each latent code is denoted by $z_{i}^{\circ}$, as a member of the latent code set. \subsection{Partial Black-box Adversary} \label{section:partial_black-box} Different from the full black-box adversary, the partial black-box adversary can choose the latent code to feed into the target GAN. Thus, she can construct/craft a specific latent code set to allow the target GAN to generate corresponding samples that can help her to achieve an effective property inference. Crafting a latent code set is a training process. To this end, the adversary needs to establish a set of shadow models to simulate GANs trained with datasets of different properties. The process to construct the latent code set with the help of shadow models can be divided into three stages. \autoref{figure:opt_noise} provides a schematic overview of it. In the first stage, the adversary generates shadow training datasets for training shadow GANs. More formally, she samples $M$ shadow training datasets $\{\mathcal{D}_1,\mathcal{D}_2,\cdots,\mathcal{D}_M\}$ from $\mathcal{D}_{shadow}$ (obtained from the local auxiliary dataset presented in \autoref{section:preliminaries}) corresponding to $M$ shadow models. Each shadow dataset $\mathcal{D}_{k}$ is sampled to fulfill a certain property denoted by $\mathcal{P}_{k}$, and all the shadow training datasets' properties are uniformly distributed. In the next stage, the adversary trains each local shadow GAN $\mathsf{G}_{k}$ with the corresponding shadow training dataset $\mathcal{D}_{k}$. Note that each $\mathsf{G}_{\it{shadow}}$ has the same architecture with the target GAN $\mathsf{G}_{\it{target}}$ (see \autoref{section:preliminaries}). Finally, the adversary crafts an optimized latent code set, denoted by $\{\noises^{*}_i\}_{i=1}^{\vert\mathbf{X}\vert}$, over the $M$ shadow GANs. Mathematically, the optimization is defined as the following. \[ \argmin_{\{\noises^{*}_i\}_{i=1}^{\vert\mathbf{X}\vert} } \sum_{k=1}^{M} \mathcal{L} \left(\phi\left(\{f_{\property}(\mathsf{G}_k(\noises^{*}_i))\}_{i=1}^{\vert\mathbf{X}\vert}\right), \mathcal{P}_k\right) \] Here, $\mathcal{L}$ represents the adopted loss function, and we utilize the stochastic gradient descent (SGD) method to minimize the loss function. At the beginning of the optimization, we need to set a random starting of the latent code set. Particularly, we present an experiment about how the optimization starting point affects the partial black-box attack in \autoref{section:evaluation_part_black-box}. With the optimized latent code set, the adversary can infer the target property $\mathcal{P}_{\it{infer}}$ similar to the full black-box adversary: \[ \phi\left(\{f_{\property}\left(\mathsf{G}_{\it{target}}\left(z_i^{*}\right)\right)\}_{i=1}^{\vert\mathbf{X}\vert}\right) \] Here, each latent code is denoted by ${z}_i^{*}$, as a member of the optimized latent code set. \section{Evaluation} \label{section:evaluation} In this section, we first describe the datasets used in our experiments, followed by descriptions of the evaluated GAN models and detailed experimental setup. We then present the results of our proposed attacks. \subsection{Dataset} GANs have been demonstrated to be successfully used in the image domain ~\cite{ISI17,LBK17,WLZTKC18}, and current attacks against GANs are also demonstrated with computer vision targets~\cite{CYZF20}. Therefore, we mainly focus on GANs generating image outputs in this paper. We also experiment on tabular data to prove that our attacks are general and can be applied to other domains. \mypara{MNIST} The MNIST database of handwritten digits~\cite{MNIST} is a commonly adopted benchmark repository for computer vision and machine learning projects. It includes 70,000 handwritten digits labeled with corresponding digit numbers. In this paper, we focus on inferring \emph{the proportion of 0s and 1s} used to train target GANs. Concretely, we construct a subset MNIST$_{\rm{01}}$ with over 6.9K 0s and 7.8K 1s and evaluate our inference attack on the proportion of 0s. We also show an extended experiment in \autoref{section:Multi} to evaluate our attack facing the property with multiple classes (digit 0\textasciitilde9) based on the whole MNIST dataset. \mypara{CelebA} CelebA~\cite{LLWT15} is a benchmark dataset for face-related problems. This large-scale face attributes dataset contains more than 200K celebrity images, and each of them has 40 binary attributes. In this paper, we focus on the gender attribute, which not only is easy for a property classifier to discriminate but also has a relatively balanced proportion on females and males (around 4:6). As a result, we intend to infer the \emph{gender distribution} of the samples used to train a target GAN. \begin{table*}[!t] \centering \caption{The settings for each experiment, describing the dataset, the property classifier task, and the target property.} \label{table:experiment_setting} \scriptsize \begin{tabular}{l | c | c | c | c | c | c | c } \toprule Task & Dataset & Property Classifier & Target Property & GAN structure & Size of $\mathcal{D}_{\it{target}}$ & Size of $\mathcal{D}_{k}$ & Size of $\mathcal{D}_{\it{classifier}}$ \\ \midrule $T_1$ & CelebA & Gender Classification & Proportion of Males & WGANGP & 40000 & 40000 & 82K \\ $T_2$ & AFAD$_{\rm{gender}}$ & Gender Classification & Proportion of Males & PGGAN & 10800 & 10800 & 92K \\ $T_3$ & AFAD$_{\rm{age}}$ & Age Classification & Proportion of Youth & PGGAN & 10800 & 10800 & 92K \\ $T_4$ & MNIST$_{\rm{01}}$ & Digit classification & Proportion of 0s & DCGAN & 3000 & 3000 & 8.8K \\ $T_5$ & Census Income & Income classification & Proportion of high-income & TGAN & 4200 & 4200 & 290k \\ \bottomrule \end{tabular} \end{table*} \mypara{AFAD} The Asian Face Age Dataset (AFAD)~\cite{NZWGH16} is a dataset proposed mainly for age estimation tasks. This dataset contains over 160K Asian faces, with the corresponding age and gender attributes. In this paper, we take advantage of both attributes and focus on inferring the \emph{gender distribution} and the \emph{age distribution} of the images used to train target GANs. Concretely, we construct two datasets from AFAD, i.e., AFAD$_{\rm{gender}}$ and AFAD$_{\rm{age}}$. AFAD$_{\rm{gender}}$ contains the same number of images (160K) as the normal AFAD. AFAD$_{\rm{age}}$, on the other hand, contains over 72K samples where $18 \le \rm{age} \le 20$ and $30 \le \rm{age} \le 39$ are chosen from AFAD. In this way, the \emph{age distribution} is described as the proportion of youth ($18 \le \rm{age} \le 20$) in the underlying training dataset. \mypara{US Census Income} The US Census Income Dataset~\cite{UCIINCOME} is used to learn to predict whether a person earns over \$50K a year. It includes 299,285 instances and each of them has 41 demographic and employment related attributes, such as age, gender, education, and citizenship. In this paper, we intend to infer the \emph{high-income distribution} (the proportion of records whose income is over \$50K) of the samples used to train a target GAN. \subsection{Models} \label{section:target_models} We first introduce the four GAN models that we focus on in this paper, i.e., DCGAN~\cite{RMC15}, WGANGP~\cite{GAADC17}, PGGAN~\cite{KALL18}, and TGAN~\cite{XV18}, as they are typical and representative models used in multiple applications like image generation, image-to-image translation, and super-resolution. Then, we describe the property classifier $f_{\property}$ which is used in both attack scenarios. \mypara{DCGAN} DCGAN bridges the gap between convolutional networks (CNNs) and unsupervised learning. Thanks to the combination of CNNs, DCGANs are stable to train in most settings and are proved to learn good representations of images for supervised learning and generative modeling. In this paper, the dimension of the latent code is chosen as 100, and the output size is set as 32$\times$32$\times$1, while our DCGANs are trained on MNIST. The structure we use in this paper is shown in \autoref{table:DCGAN_structure}, and the detailed hyper-parameters are listed below. The number of critic iterations per generator iteration $n_{critic}=1$, the batch size $m=100$, and parameters of the Adam optimizer $\alpha=0.0002$, $\beta_1=0.5$, $\beta_2=0.999$. \mypara{WGANGP} WGANGP is proposed to improve the training process of an ordinary Wasserstein GAN. With the help of an addition called gradient penalty, their proposed method enables stable training of a wide variety of GAN architectures. In this paper, we choose the dimension of each latent code as 100, and the pixel size of output images is 64$\times$64$\times$3. The structure of our WGANGP is shown in \autoref{table:WGANGP_structure}. Moreover, the hyper-parameters in the training process are configured as the following: the gradient penalty coefficient $\lambda=10$, the number of critic iterations per generator iteration $n_{critic}=3$, the batch size $m=100$, and parameters of the Adam optimizer $\alpha=0.0002$, $\beta_1=0.9$, $\beta_2=0.999$. \mypara{PGGAN} The key idea of PGGAN is to grow both generator and discriminator progressively with the resolution becoming higher. This training method has a better performance in training high-quality images. In this paper, we set the image size as 64$\times$64$\times$3, with consideration of the training cost. The remaining settings are the same as those provided in~\cite{KALL18}, including the dimension of input latent code is 512, the usage of WGANGP loss, and leaky ReLU with leakiness 0.2. The structure of PGGAN we use is shown in \autoref{table:PGGAN_structure}, and the detailed hyper-parameters are shown as below: the gradient penalty coefficient $\lambda=10$, the number of critic iterations per generator iteration $n_{critic}=1$, the batch size $m=36$, and parameters of the Adam optimizer $\alpha=0.001$, $\beta_1=0$, $\beta_2=0.99$. \mypara{TGAN} Tabular GAN is designed to generate tabular data like medical or educational records. With the help of mode-specific normalization for numerical variables and smoothing for categorical variables, TGAN can simultaneously generate discrete and continuous variables. In this paper, we set the dimension of the latent code to 200 and the size of the synthetic output to 503 (based on the total size of the one-hot vectors). All of the settings of the TGAN are the same as those provided in~\cite{XV18}, while the output and hidden state size of LSTM are 100, the size of the hidden vector is 100, the batch size is 200, and the parameters of the Adam optimizer are set as $\alpha=0.001$, $\beta_1=0.5$, $\beta_2=0.99$. \mypara{Property Classifier} For each inference task, we construct a property classifier (binary in our case) with the corresponding generated image size. For the gender classifiers, our neural networks start with two convolutional layers and follow with two fully connected layers, both obtaining over 95\% testing accuracy. And the age classifier starts with three convolutional layers followed with three fully connected layers, getting an accuracy of around 80\%. To discriminate the digit 0 and 1, our neural network has the same structure as the age classifier, with a testing accuracy of over 98\%. Additionally, we build up a four-layer fully connected classifier to recognize the high-income census with over 86\% testing accuracy. We also show extended experiments later in \autoref{section:property_classifier} to investigate the influence of the property classifier on the attack performance, i.e., the needlessness of the target model's training dataset and the irrelevance of architecture of the property classifier. For the former, we adopt two off-the-shelf gender classifiers (based on IMDB-WIKI dataset and the Audience dataset) and a locally trained model (based on EMNIST dataset). For the latter, we train five well-behaved classifiers with different architectures. \subsection{Experiment Setup} \begin{figure*}[!t] \centering \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_full_BB/rand1_p1.pdf} \caption{Evaluation on $T_1$} \label{figure:fullBBsight1} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_full_BB/rand1_p2.pdf} \caption{Evaluation on $T_2$} \label{figure:fullBBsight2} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_full_BB/rand1_p3.pdf} \caption{Evaluation on $T_3$} \label{figure:fullBBsight3} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_full_BB/rand1_p4.pdf} \caption{Evaluation on $T_4$} \label{figure:fullBBsight4} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_full_BB/rand1_p7.pdf} \caption{Evaluation on $T_5$} \label{figure:fullBBsight5} \end{subfigure} \caption{Full black-box attack performance. Each point depicts a target model with corresponding underlying property (Ground Truth) and inferred property (Inferred Proportion). The average curve gives an average attack result for target models with the same underlying property. The benchmark line refers to the best attack result, where the inferred proportion is exactly equal to the ground truth. The inferred result for each target model is obtained using 20K randomly generated samples.} \label{figure:fullBBsight} \end{figure*} \begin{figure*}[!t] \centering \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/fullBB_wrt_num_samples/rand2_p1_euc.pdf} \caption{Evaluation on $T_1$} \label{figure:fullBBnumEUC1} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/fullBB_wrt_num_samples/rand2_p2_euc.pdf} \caption{Evaluation on $T_2$} \label{figure:fullBBnumEUC2} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/fullBB_wrt_num_samples/rand2_p3_euc.pdf} \caption{Evaluation on $T_3$} \label{figure:fullBBnumEUC3} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/fullBB_wrt_num_samples/rand2_p4_euc.pdf} \caption{Evaluation on $T_4$} \label{figure:fullBBnumEUC4} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/fullBB_wrt_num_samples/rand2_p7_euc.pdf} \caption{Evaluation on $T_5$} \label{figure:fullBBnumEUC5} \end{subfigure} \caption{Full black-box performance w.r.t.\ number of random samples, evaluated with the absolute difference between the inferred property and the underlying property. Each line presents the average behavior of the target models with the same property, and how the behavior changes using the different number of random samples.} \label{figure:fullBBnum} \end{figure*} We evaluate the performance of our property inference under five different settings, including the proportion of males on CelebA ($T_1$), the proportion of males on AFAD ($T_2$), the proportion of youth on AFAD ($T_3$), the proportion of 0s on MNIST ($T_4$), and the proportion of the high-income on Census Incone dataset ($T_5$). \autoref{table:experiment_setting} lists them in detail. For each task, we firstly split the dataset into three disjoint parts, i.e., a shadow dataset $\mathcal{D}_{\it{shadow}}$ to draw $\mathcal{D}_{k}$, a dataset to draw $\mathcal{D}_{\it{target}}$ with the same size as $\mathcal{D}_{\it{shadow}}$, and a classifier dataset $\mathcal{D}_{\it{classifier}}$ to train $f_{\property}$. We then split $\mathcal{D}_{\it{classifier}}$ with a proportion of 7:3 to train and test the property classifier. Note that, all of the samples are drawn randomly but under a control on the number of images with the target analyzing attribute. For instance, when we focus on inferring the gender distribution of the training dataset, we will control the number of females and males. In this way, these split datasets follow the same distribution as the original datasets except the target attribute. Moreover, the concrete size of the disjoint dataset is also presented in \autoref{table:experiment_setting}. With the aim of inferring the distribution of the target GAN's underlying training dataset, the property of each shadow dataset $\mathcal{P}_{k}$ can be simply set as a range of proportions covering the target property. In our experiments, we assume that $\mathcal{P}_{\it{target}},\mathcal{P}_{k}\in\{30\%,40\%,50\%,60\%,70\%\}$. In this way, we draw $\mathcal{D}_{\it{target}}$ and $\mathcal{D}_{k}$ randomly, while controlling the size and property of each dataset. Note that, we assume the target property $\mathcal{P}_{\it{target}}$ is between 30\% and 70\%, so we simply set the property of each shadow dataset within the same range. Moreover, we also investigate how our partial black-box attack behaves when the property of shadow models do not cover their target property, as shown in \autoref{figure:out_of_range}. \begin{table}[!t] \centering \caption{Average FID for GAN models in each task.} \label{table:FID} \scriptsize \begin{tabular}{l | c | c | c | c } \toprule & WGANGP $T_1$ & PGGAN $T_2$ & PGGAN $T_3$ & DCGAN $T_4$ \\ \midrule Target GANs & 33.62 & 28.79 & 29.48 & 49.07\\ Shaodw GANs & 35.17 & 29.28 & 29.02 & 51.23\\ \bottomrule \end{tabular} \end{table} For each inference task, our experiment basically goes as follows. In the training stage, we have trained eight target models with each $\mathcal{P}_{\it{target}}$, i.e., 40 target models in total, so as to examine the variation in inference accuracy. In the attack stage, we build up 20 shadow models for each $\mathcal{P}_k$, using the same GAN structures and training hyper-parameters with the target models. Consequently, 100 shadow models are involved in the evaluation for the partial black-box attack. The corresponding quantitative evaluation in terms of Fréchet Inception Distance (FID) metric~\cite{HRUNH17} is shown in~\autoref{table:FID} to present the quality of our shadow and target GANs. We can find that our GAN models are in a reasonable range compared with experiments (FID ranging from 14.86 to 53.08) in~\cite{CYZF20}. Note that we will further discuss the influence of shadow models in \autoref{section:Shadow} based on different GAN structures and underlying datasets. \subsection{Attack Evaluation} In this paper, our proposed property inference attack produces a continuous property value, instead of a discrete classification label like~\cite{GWYGB18}. Therefore, we evaluate the effects of the attack based on the \emph{absolute difference} between the real property and the inference property. Formally, as we focus on inferring the proportion of a certain attribute, the absolute difference of our attack can be easily calculated as $\vert\mathcal{P}_{\it{infer}}-\mathcal{P}_{\it{real}}\vert$, where $\mathcal{P}_{\it{infer}}$ and $\mathcal{P}_{\it{real}}$ range from 0\% to 100\%, represented by the percentage. As the definition of the evaluation metric, the attack result is better when the calculated absolute difference is closer to 0\%. \begin{figure*}[!t] \centering \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_part_BB/opt1_p1.pdf} \caption{Evaluation on $T_1$} \label{figure:partBBsight1} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_part_BB/opt1_p2.pdf} \caption{Evaluation on $T_2$} \label{figure:partBBsight2} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_part_BB/opt1_p3.pdf} \caption{Evaluation on $T_3$} \label{figure:partBBsight3} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_part_BB/opt1_p4.pdf} \caption{Evaluation on $T_4$} \label{figure:partBBsight4} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/sight_on_part_BB/opt1_p7.pdf} \caption{Evaluation on $T_5$} \label{figure:partBBsight5} \end{subfigure} \caption{Partial black-box attack performance. Each point depicts a target model with corresponding underlying property (Ground Truth) and inferred property (Inferred Proportion) based on an optimized latent code set. The average curve gives an average result for target models with the same underlying property. The benchmark line refers to the best attack result.} \label{figure:partBBsight} \end{figure*} \begin{figure*}[!t] \centering \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_latent/opt2_p1_euc.pdf} \caption{Evaluation on $T_1$} \label{figure:partBBnumLEUC1} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_latent/opt2_p2_euc.pdf} \caption{Evaluation on $T_2$} \label{figure:partBBnumLEUC2} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_latent/opt2_p3_euc.pdf} \caption{Evaluation on $T_3$} \label{figure:partBBnumLEUC3} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_latent/opt2_p4_euc.pdf} \caption{Evaluation on $T_4$} \label{figure:partBBnumLEUC4} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_latent/opt2_p7_euc.pdf} \caption{Evaluation on $T_5$} \label{figure:partBBnumLEUC5} \end{subfigure} \caption{Partial black-box performance w.r.t.\ number of optimized samples. For each target model, we generate different numbers of optimized samples based on latent code sets and then obtain the inference results using these optimized samples. The red curve represents the average attack performance against all target models based on different numbers of optimized samples. We also provide box plots of our results for statistical analysis.} \label{figure:partBBnumL} \end{figure*} \subsection{Evaluation on Full Black-box Attack} \label{section:evaluation_full_black-box} We first start by evaluating the full black-box method, which is the least knowledgeable setting for the adversary. \autoref{figure:fullBBsight} shows the experimental results of our proposed full black-box attack against all target models. The inferred property of each target model is represented as a single point, which depicts the black-box attack result based on 20K random generated samples against the corresponding underlying property (i.e., the ground truth). We also plot the average inference result for target models sharing the same property, as well as an ideal benchmark line for comparison, on which the inferred property is exactly equal to the underlying property. Overall, our results indicate the effectiveness of the full black-box attack, as we can clearly observe that the average inference curve corresponds closely to the benchmark line. For instance, in \autoref{figure:fullBBsight1} focusing on target models with 30$\%$ males in the training dataset, our attack is well-behaved as the inferred proportion for each target model is very close to 30$\%$. Moreover, we can see that in the tasks $T_1$ and $T_4$, our attack achieves quite a good attack performance, and the variances of inference results on target models are smaller than the other two. Meanwhile, the result in the task $T_3$ is not so good, as the youth is hard to discriminate when using a local property classifier whose testing accuracy is only around 80{\%}. How the $f_{\property}$ affects our attack behavior will be further explored in \autoref{section:property_classifier}. \mypara{Number of Random Samples} Next, we evaluate our full black-box attack performance against an ablation study, i.e., the influence of the number of random generated samples. We repeat our aforementioned full black-box evaluation with various random sample amounts to achieve the attack: $2^i (i = 2, 3, \cdots, 16)$. After obtaining inferred proportions for all the target models, we average the inference results from the same underlying proportion and number of samples respectively for further analysis. \autoref{figure:fullBBnum} plots the average full black-box attack performance against different numbers of random samples. We can see the absolute difference of the inference result is obvious when using a relatively small amount of generated samples (less than 128). And then the inference results become more \emph{accurate and stable} with the increasing number of random generated samples. For instance, the green line in \autoref{figure:fullBBnumEUC2} depicts the average attack performance against target models with half male and half female training data, where the absolute difference is decreasing from 17.8\% to 3.7\% as the amount of samples grows to 1024, indicating the inference result is getting closer to the ground truth. Moreover, focusing on $T_1$ and $T_2$, we can find the inference results on models with 70$\%$ males in the underlying training dataset are always worse than the others. A possible explanation is that $f_{\property}$ has relatively higher accuracy on the female class. In that case, more males are misclassified as females when the proportion of males increases. \subsection{Evaluation on Partial Black-box Attack} \label{section:evaluation_part_black-box} \begin{figure*}[!t] \centering \begin{subfigure}{0.5\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_shadow/opt3_p1_euc.pdf} \caption{Evaluation on $T_1$} \label{figure:partBBnumSEUC1} \end{subfigure} \begin{subfigure}{0.5\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_shadow/opt3_p2_euc.pdf} \caption{Evaluation on $T_2$} \label{figure:partBBnumSEUC2} \end{subfigure} \begin{subfigure}{0.5\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_shadow/opt3_p3_euc.pdf} \caption{Evaluation on $T_3$} \label{figure:partBBnumSEUC3} \end{subfigure} \begin{subfigure}{0.5\columnwidth} \includegraphics[width=\columnwidth]{pic/partBB_wrt_num_shadow/opt3_p4_euc.pdf} \caption{Evaluation on $T_4$} \label{figure:partBBnumSEUC4} \end{subfigure} \caption{Partial black-box performance w.r.t.\ number of shadow models. For each target model, we generate 100 samples from the latent code sets optimized based on different numbers of shadow models and then obtain the inference results using these optimized samples. The red curve shows the average performance of all target models through latent code sets optimized by different numbers of shadow models. We also provide box plots of our results for statistical analysis.} \label{figure:partBBnumS} \end{figure*} We then evaluate the partial black-box method, which relies on locally-trained shadow models. \autoref{figure:partBBsight} shows the partial black-box attack results against all target models. The inferred property of each target model is represented as a single point, which depicts the partial black-box attack result against the corresponding underlying property, using 100 optimized samples generated from an optimized latent code set. Similar to \autoref{figure:fullBBsight}, we further plot a benchmark line as a reference to the best attack result, as well as an average line for target models with the same underlying property. As we can see, the average inference curve lies close to the benchmark line, proving the effectiveness of our partial black-box attack. For instance, we get an average inferred proportion of 48.4$\%$ for the target models with half males and half females in the underlying training dataset as shown in \autoref{figure:partBBsight2} (the ground truth is 50$\%$ males). Note that we use only 100 generated samples to achieve our partial black-box attack in \autoref{figure:partBBsight}, it is reasonable that the inference result of each target GAN has a relatively large deviation. Similar to our results and analysis for the full black-box attack (\autoref{section:evaluation_full_black-box}), our partial black-box attack produces good results when aiming to infer the underlying distribution in tasks $T_1$, $T_2$, $T_4$ and $T_5$, while $T_3$ is the most difficult one to achieve an accurate inference. Moreover, we can find some obvious gaps between the benchmark line and the average curve, such as $\mathcal{P}_{real}=40\%$ in $T_1$ and $\mathcal{P}_{real}=70\%$ in $T_3$. They are possibly caused by a significant dissimilarity between the shadow datasets and the target datasets. In that case, the optimization phase within the partial black-box pipeline fails to construct an effective latent code set for the target models. \mypara{Number of Optimized Samples} In \autoref{section:evaluation_full_black-box}, our one key finding is that the full-black box attack performance is influenced by the number of random samples. Here we also investigate how the number of optimized samples impacts the accuracy of our partial black-box attack, note that the adversary uses an optimized latent code set with the corresponding size to generate these optimized samples. \autoref{figure:partBBnumL} presents the attack performance on each task while using different numbers of optimized samples, in other words, using latent code sets with different sizes. Fixing the number of optimized samples, we can obtain the inference results for all 40 target models. And for each number, we take advantage of box plots to perform all the attack results against the target models. Besides, we also plot a red curve that highlights the average performance against the target models. In general, we can see the partial black-box attack gets more precise when increasing the number of optimized samples. For instance, in \autoref{figure:partBBnumL} when the number of optimized samples grows from 25 to 100, the average absolute difference of all target models changes from 12.5\% to 9.8\% in $T_1$, 8.7\% to 7.2\% in $T_2$, 14.9\% to 10.1\% in $T_3$, 7.7\% to 4.9\% in $T_4$ and 9.8\% to 4.5\% in $T_5$. However, a larger number of optimized samples also tend to cause more serious instability (e.g., the variance of inference results), scaled here by the difference between the lower and upper quartile in the box plot. As shown in \autoref{figure:partBBnumLEUC1}, when choosing the number of optimized samples as 200 in $T_1$, the average performance increases to 12.6\%, and the attack stability increases to around 15\%. In our remaining experiments, after trading off the attack accuracy and the optimization time cost, we set the number of optimized samples as 100, i.e., the size of the optimized latent code set is equal to 100. \begin{figure}[!t] \centering \includegraphics[width=0.67\columnwidth]{pic/partBB_wrt_start_point/opt_4.pdf} \caption{Partial black-box performance w.r.t.\ optimization starting point. Each line plots an average performance of the target models in $T_2$ with the same underlying property, based on 5 latent code sets optimized from different starting points.} \label{figure:start_point} \end{figure} \mypara{Number of Shadow Models} \autoref{figure:partBBnumS} shows the partial black-box attack performance on all target models against the number of local shadow models used to optimize the latent code set. We leverage box plots to present the attack performance for all models' inference results, based on latent code sets optimized with different numbers of shadow models. Moreover, we also plot a curve to present the average inference result against the number of shadow models. As we can see, the average inference behavior changes slightly when using different numbers of shadow models. For example, when increasing the number of shadow models from 50 to 100 in \autoref{figure:partBBnumSEUC3}, the average absolute difference of all target models changes slightly from 10.2\% to 10.8\% in $T_3$. Even though the median and average attack accuracies are slightly higher when optimizing latent code set based on only 25 shadow models for most tasks, the variance of attack results is quite large, even more than 10\% in $T_3$ (scaled by the difference between the lower and upper quartile in a box plot). It means the property inference attack suffers from severer instability when there are only a few shadow models. Finally, considering both the accuracy and stability of the attack performance, we set the number of shadow models as 100 in our other experiments. Moreover, our results indicate that our proposed partial black-box attack is able to achieve high inference accuracy with just a limited amount of shadow models, suggesting it is a practical and realistic threat in the real world. \mypara{Optimization Starting Point} Since we utilize the stochastic gradient descent (SGD) method to optimize a latent code set to implement our partial black-box attack, the optimized results may be affected by the optimization initialization, i.e., the optimization starting point. \autoref{figure:start_point} shows the performance of our partial black-box attack on $T_2$ with five different random starting points. Similar to \autoref{figure:fullBBsight} and \autoref{figure:partBBsight}, we exhibit the average performance for all target models. As we can see, the five curves depicting the average inference results are close to each other. For instance, in \autoref{figure:start_point} considering target models with 70\% males in the underlying training dataset, the average inference results range from 63.2\% to 65.2\% using five latent code sets based on different optimization starting points. It suggests that the optimization starting point would not obviously affect our partial black-box attack performance. \begin{figure}[!t] \centering \includegraphics[width=0.67\columnwidth]{pic/sight_on_part_BB/out_of_range.pdf} \caption{Partial black-box performance w.r.t.\ out-of-range target property. Each bar represents the number of target models with relative partial black-box attack results. All 21 target GANs have 20\% males and 80\% females in the underlying dataset and follow the same setting as $T_4$. The underlying property of the shadow models ranges from 30\% to 70\%.} \label{figure:out_of_range} \end{figure} \mypara{Target Property Out of Range} In the above experiment, we simply set the range of the property of the shadow models to cover the underlying property of the target models. When facing an unknown distribution, the adversary can also expand the covering property range of the shadow models to 0\% to 100\%. In this part, we examine our attack behavior when the target property is out of the range of the shadow models. \autoref{figure:out_of_range} shows the partial black-box attack result of target GANs with 20\% males in the underlying dataset based on shadow models with 30\% to 70\% males. As we can see in \autoref{figure:out_of_range}, there are 38\% (8/21) target GANs whose partial black-box inference error is lower than 2\%. It indicates that our partial black-box attack still works when the target property is out of the range of the property of the shadow models. Compared with the full black-box scenario, our proposed attack methodology on the partial black-box scenario shows more stable performance, as it is loosely related to the choice of several attack hyper-parameters, e.g., the optimization initialization and the number of shadow models. \subsection{Comparison Between Two Attacks} In this paper, we develop two property inference strategies against GANs on two practical attack scenarios: the full black-box setting and the partial black-box setting. The key difference relies on whether the adversary is able to craft latent codes to control the target model’s output. In the former case, we choose a more general and straightforward way by directly sending random generated latent codes to get random samples. As it does not require any internal information of the target model (e.g., parameters, structures), this full black-box methodology is also applicable for the partial black-box adversary. In the latter case, we propose to leverage auxiliary knowledge of the target model to help search for optimized latent codes via SGD, and then send them to the target model. Our aforementioned experimental results show that the partial black-box adversary can achieve an accurate inference with a limited amount of latent codes. In this subsection, we present a more comprehensive comparison between the two attacks based on their attack stability and accuracy. As we can see in \autoref{figure:fullBBnum}, our full black-box attack can achieve a quite good attack performance based on over 256 random generated samples, so our comparison below will focus on using a relatively small amount of samples. \begin{figure}[!t] \centering \includegraphics[width=0.66\columnwidth]{pic/compare/com.pdf} \caption{Ratio of optimized samples behaving better than random ones. For each task, we obtain 80 random inference results and one optimized inference result based on a limited number of generated samples for each target GAN. Then we compare them to get the frequency of optimized samples behaving better than random ones and finally obtain the ratio considering all target models. In this way, we show the ratio of partial black-box attack (optimized) behaving better than the full black-box attack (random) against different numbers of samples.} \label{figure:comp2} \end{figure} \begin{figure*}[!t] \centering \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/classifier/online1.pdf} \caption{Evaluation on $T_1$ with \\ IMDB-WIKI classifier} \label{figure:online1} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/classifier/online2.pdf} \caption{Evaluation on $T_2$ with \\ IMDB-WIKI classifier} \label{figure:online2} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/classifier/online3.pdf} \caption{Evaluation on $T_1$ with \\ Audience classifier} \label{figure:online3} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/classifier/online4.pdf} \caption{Evaluation on $T_2$ with \\ Audience classifier} \label{figure:online4} \end{subfigure} \begin{subfigure}{0.4\columnwidth} \includegraphics[width=\columnwidth]{pic/classifier/online5.pdf} \caption{Evaluation on $T_4$ with \\ EMNIST classifier} \label{figure:online5} \end{subfigure} \caption{Full black-box performance w.r.t.\ unknown training distribution. We adopt two off-the-shelf classifiers (based on IMDB-WIKI and Audience dataset) and a locally trained model (based on EMNIST dataset) to achieve our attacks. Each point depicts the full black-box attack performance with corresponding underlying property and inferred property. The blue curve plots the average performance of the target models with the same underlying property. The orange line marks the ideal attack result. The green line shows the dataset property reported by directly running the off-the-shelf classifier on the underlying training dataset.} \label{figure:online} \end{figure*} We first give a comparison based on the \emph{attack stability} for the proposed two methodologies. Based on the observation in \autoref{figure:fullBBnum}, we can find that the number of samples strongly affects the full black-box attack performance and the inference results are extremely unstable when using less than 256 samples. On the other hand, the partial black-box attack methodology is not affected too much by the number of optimized samples, as the red curves in \autoref{figure:partBBnumL} are much smoother than curves in \autoref{figure:fullBBnum}. For instance, the average absolute difference of our partial black-box attack result decreases from 8.2\% to 3.6\% in $T_4$ when the number of optimized generated samples increases from 25 to 200. In this way, the partial black-box methodology produces a relatively stable performance when using a limited amount of samples (less than around 128 to 256). We follow with a comparison of the \emph{attack accuracy} for the proposed two methodologies, based on the experiment established below. For each target model and specific size of the latent code set, we perform the partial black-box attack once using the corresponding number of optimized samples. In the meanwhile, because the full black-box attack presents a relatively unstable behavior, especially when the number of random samples is small, we repeat our full black-box attack 80 times to reduce observation randomness. Then we compare each full black-box result with the corresponding partial black-box result. Finally, for each tested number of samples, we respectively calculate the ratio of comparisons in which the optimized samples produce a more accurate inference with full consideration of all target models. The statistical result is plotted in \autoref{figure:comp2}. It shows that the partial black-box attack method is more likely to provide more accurate inferences than the full black-box attack when using a small number of samples (less than around 150). For tasks except $T_1$, we can find that inferences with optimized samples are better than those with random samples in most cases (i.e., the ratio is exceeding 0.5). Another observation is that, as the number of samples increases, more full black-box inferences outperform the partial black-box attack results. Overall, we give a conclusion for these two methodologies. \mypara{Partial Black-box Methodology} Our partial black-box attack achieves a better inference performance in both accuracy and stability with a limited number of optimized samples (around 150). Note that obtaining a large number of samples from the target GAN can be possibly detected as an abnormal event, our partial black-box attack is supposed to be a more stealthy one. Moreover, the partial black-box attack helps to reduce query charges when the adversary needs to pay for the generated samples. \mypara{Full Black-box Methodology} When the adversary is allowed to obtain a large number of samples, our full black-box methodology provides a more convenient way to achieve her attack, as it avoids the consumption to optimize the latent code set. Besides, we believe that our full black-box methodology has also presented realistic threats against generative models, as it provides a more generic and easy solution without any extra knowledge of the target model. \subsection{Evaluation on Property Classifier} \label{section:property_classifier} Both of our full and partial black-box attack pipelines include a property classifier $f_{\property}$, which directly impacts the final inference result. In this subsection, we study how the property classifier influences the property inference attack with respect to two factors: the training dataset distribution and the structure of the property classifier. \mypara{Training Dataset from a Different Distribution} We firstly consider a strict situation that the adversary has no knowledge of the target model’s training dataset distribution. In that case, we investigate how the full black-box attack behaves when the property classifier is trained on a different dataset. In our experiment, we adopt three property classifiers, i.e., an off-the-shelf CNN model\footnote{\url{https://data.vision.ee.ethz.ch/cvl/rrothe/imdb-wiki/}} trained on the IMDB-WIKI dataset~\cite{RTG18}, an off-the-shelf CNN model\footnote{\url{https://github.com/dpressel/rude-carnie}} trained on the Audience dataset~\cite{LH15}, and a model locally trained with the EMNIST dataset~\cite{CATS17}. As the former two off-the-shelf models are gender classifications, we directly adopt them to achieve the full black-box attack on $T_1$ and $T_2$. \autoref{figure:online3} and \autoref{figure:online4} shows that the property classifier based on Audience dataset has a good attack performance on both tasks. But as shown in \autoref{figure:online2}, the IMDB-WIKI classifier results in a significant inference accuracy decline in $T_2$. This phenomenon is possibly due to the relatively poor performance of the IMDB-WIKI classifier on the AFAD dataset. In order to verify our guess, we run the off-the-shelf property classifier directly on the target model’s underlying training dataset and then calculate the dataset property. The green curve in \autoref{figure:online2} depicts the result. We can clearly see that the average attack results correspond closely to the dataset property recognized by the property classifier. For instance, when the proportion of male training samples is 30\%, the property classifier reports a male proportion of 56\%, which is close to the average inferred proportion of 59\%. This phenomenon reveals that the property classifier plays a pivotal role in the inference attack. Moreover, we also train a local classifier with the EMNIST dataset~\cite{CATS17} to achieve the full black-box attack on $T_4$. The EMNIST dataset is a variant of the full NIST dataset and shares the same image structure and parameters as the original MNIST dataset, but it is completely disjoint with the MNIST dataset. \autoref{figure:online5} shows that the EMNIST classifier can still help us to accomplish a relatively accurate property inference attack. Our result shows that it is possible to achieve an accurate property inference attack even without the knowledge of the training dataset distribution, as long as the adversary owns a property classifier that has good enough accuracy on the target problem. \begin{figure}[!t] \centering \includegraphics[width=0.6\columnwidth]{pic/classifier/structure.pdf} \caption{Full black-box performance w.r.t.\ property classifier architecture. Each line gives an average performance of target models with the same underlying property. ``c3f2'' means the classifier architecture begins with 3 convolution layers and follows with 2 fully connected layers.} \label{figure:structure} \end{figure} \begin{figure}[!t] \centering \begin{subfigure}{0.49\columnwidth} \includegraphics[width=\columnwidth]{pic/shadow_gan/WGANGP_result_PGGANnoise.pdf} \caption{Evaluate on $T_1$} \label{figure:shadow1} \end{subfigure} \begin{subfigure}{0.49\columnwidth} \includegraphics[width=\columnwidth]{pic/shadow_gan/PGGAN_result_WGANGPnoise.pdf} \caption{Evaluate on $T_2$} \label{figure:shadow2} \end{subfigure} \caption{Partial black-box performance w.r.t.\ unknown training distribution and structure of target GAN. For $T_1$, we optimize the latent code set based on PGGAN with IMDB-WIKI dataset. For $T_2$, we optimize the latent code set based on WGANGP with CelebA dataset. For both tasks, we adopt a downloaded CNN model based on IMDB-WIKI dataset as our property classifier. The blue curve plots the average performance of the target models with the same underlying property. The orange line marks the best attack result. The green line shows the training dataset property directly reported by the off-the-shelf classifier.} \label{figure:shadow} \end{figure} \mypara{Classifier Architecture} We secondly examine the attack behavior based on property classifiers with different architectures. In this paper, our property classifier in $T_1$ is a convolutional neural network with two convolutional layers and two fully connected layers (shortened as c2f2 in this paper). Additionally, we adopt three other structures which have different numbers of convolution layers or fully connected layers (i.e., c2f3, c1f2, and c3f2). As shown in \autoref{figure:structure}, the average full black-box attack results in $T_1$ are very close to each other when using property classifiers with different structures. For instance, the average inference results range from 26\% to 31\% when the underlying training dataset contains 30\% males. As a result, our attack methodologies are only sightly influenced by the classifier architecture. \subsection{Evaluation on Shadow Models with Less Hyper-parameters} \label{section:Shadow} As we assume that the partial black-box adversary can train shadow models with the same structure and training hyper-parameters on the auxiliary dataset of the target GAN. In this subsection, we investigate the behavior of our partial black-box attack based on shadow models with different structure and training dataset. As we still control the input latent code of the target GAN in the partial black-box methodology, we only set the size of the latent code layer in shadow models the same as the target model. For $T_1$, we use the PGGAN trained on the IMDB-WIKI dataset as shadow models, while the target model is WGANGP based on the CelebA dataset. \autoref{figure:shadow1} shows the partial black-box attack result is close to the benchmark line. As a result, the latent code set optimized with shadow models still works well in spite of that the adversary has no knowledge of the main structure and dataset of the target model. For $T_2$, we use the WGANGP trained on the CelebA dataset as shadow models. As shown in \autoref{figure:shadow2}, there is a certain deviation between the partial black-box attack result and the benchmark line. But the inference result corresponds closely to the dataset property recognized by the off-the-shelf property classifier. Moreover, the similarity between \autoref{figure:shadow} and \autoref{figure:online} proves the effectiveness of our partial black-box methodology without knowledge of the structure and underlying dataset of the target model. And this phenomenon further certifies the needless similarity of the generated samples in shadow and target GANs to achieve our partial black-box methodology. \subsection{Evaluation on Multi-class Property} \label{section:Multi} As the five tasks shown above all focus on inferring the distribution of attributes with \emph{binary classes}, we present here an extra experiment to evaluate the performance of our attack on the property with \emph{multiple classes}, i.e., the distribution of 10 digits in the training dataset. Facing a target DCGAN trained on MNIST with a specific distribution (including digits from 0 to 9), \autoref{figure:mnist_ori} shows how our full black-box attack behaves when inferring this multi-class property. We can clearly observe that the inferred distribution follows a close trend with the underlying property. Moreover, the cosine similarity is over 0.99 when considering these two distributions as vectors. As a result, our attack gives a good performance on inferring property with not only binary classes, but also multiple classes. \begin{figure}[!t] \centering \includegraphics[width=0.75\columnwidth]{pic/mnist/mnist_ori.pdf} \caption{Full black-box performance w.r.t.\ multi-class property. The blue bar shows the distribution of each digit in the training dataset, while the orange one depicts the inferred distribution based on our full black-box attack.} \label{figure:mnist_ori} \end{figure} \begin{figure}[!t] \centering \includegraphics[width=0.75\columnwidth]{pic/mnist/mnist_fake.pdf} \caption{Mitigation performance. The blue bar shows the original distribution of each digit in the training dataset, while the orange one depicts the inferred distribution based on our full black-box attack. The green bar shows the fake distribution after rebalancing dataset.} \label{figure:mnist_fake} \end{figure} \subsection{Discussion on Mitigation} \label{section:mitigate} \mypara{Local Property Classifier} One way to mitigate our attack is by introducing a local property classifier to pre-test the property of generated samples. In this way, even though the real generated samples expose the underlying property of the training dataset, we can provide a subset of the generated samples to hide this distribution with the help of the local property classifier. \mypara{Rebalancing the Training Dataset} Another solution would be simply rebalancing the training dataset with respect to the target property by adding extra new samples to the training dataset. \autoref{figure:mnist_fake} shows the full black-box attack performance after filling the training dataset to form a fake distribution. We can find that the inferred property is closer to the fake distribution than the real one, and the cosine similarity reduces from 0.99 to 0.88. This method is useful in most scenarios, but can possibly jeopardize the performance of the target GAN. \section{Enhancing Membership Inference Attack} \label{section:MIA} So far, we have demonstrated the effectiveness of our property inference attacks against GANs. Next, we investigate whether our property inference attacks can be used as a building block to launch other attacks. In particular, we focus on membership inference, one of the most well-established privacy attacks against GANs~\cite{HMDC19,CYZF20}. \mypara{Methodology} In general, the membership inference attack intends to infer whether a target sample belongs to the underlying training dataset of a target GAN. State-of-the-art attacks in this field proposed by Chen et al.~\cite{CYZF20} follow three steps: \begin{itemize} \item Use a distance metric $L(\cdot,\cdot)$ to evaluate the reconstruction error of the target sample $x$ against the target GAN $(\mathsf{G}_v)$. In different scenarios, they deliver different methodologies to obtain the most similar generated sample $\mathcal{R}(x|\mathsf{G}_v)$. \item Build a shadow GAN $(\mathsf{G}_r)$ to repeat the first step and get a reference reconstruction error. In this way, the calibrated reconstruction error $L_{cal}(\cdot,\cdot)$ can be calculated as: \begin{equation} L_{cal}(x,\mathcal{R}(x|\mathsf{G}_v)) = L(x,\mathcal{R}(x|\mathsf{G}_v)) - L(x,\mathcal{R}(x|\mathsf{G}_r)) \end{equation} \item Infer whether the target sample is in the training dataset based on a threshold. Formally, the attack flow works as \begin{equation} \label{equation:MIA} \mathcal{A}(x) = \mathbbm{1}[L_{cal}(x,\mathcal{R}(x|\mathsf{G}_v)) < \epsilon] \end{equation} i.e., when the calibrated reconstruction error is smaller than a threshold, it belongs to the training dataset. \end{itemize} Our enhancement follows the intuition that a sample has a larger possibility to be a member when it shares the same property with the majority of samples in the target GAN's training dataset. For instance, if the target GAN's training dataset contains more males than females (obtained by our property inference attacks), then a target male sample is more likely to be a member than a female sample. Based on this, we add an extra item on the threshold of \autoref{equation:MIA} to enhance membership inference. Formally, the new membership inference attack is modified as the following. \begin{equation} \label{equation:enhanced_MIA} \mathcal{A}(x) = \mathbbm{1}[L_{cal}(x,\mathcal{R}(x|\mathsf{G}_v)) < \epsilon + \lambda_{p}\frac{1}{N}\sum_{i}^N \sl{f}(\mathcal{P}_{\it{i}})] \end{equation} where $\lambda_{p}$ controls the magnitude of our enhancement, $N$ refers to the number of considered attributes of the query sample, $\mathcal{P}_{\it{i}}$ is the proportion of the $i$th attribute in the training dataset, and $\sl{f}({\mathcal{P}_{\it{i}}}) = 2 {\times} {\mathcal{P}_{\it{i}}} - 1$. The term $\lambda_{p}\frac{1}{N}\sum_{i}^N \sl{f}(\mathcal{P}_{\it{i}})$ in \autoref{equation:enhanced_MIA} helps to calibrate a target sample's membership probability with respect to the target model's training dataset's property. When the target sample shares the same attribute as a higher proportion of the underlying training dataset ($\mathcal{P}_{\it{i}}>50\%$), the new threshold rises and leads to a better membership probability. \mypara{Evaluation} We evaluate the performance of the enhanced membership inference attack with the help of the additional knowledge of the gender distribution of samples in the training dataset, which is obtained by our property inference attack. We set up the target GANs using 2,048 CelebA samples with a control of its underlying property (the proportion of males) and the structure is the same as $T_1$ discussed in \ref{section:target_models}. We adopt the same full black-box membership inference attack methodology as Chen et al.~\cite{CYZF20}. We set $\lambda_{p} = 2$ and each evaluation dataset has 2,048 members and 6,144 non-members (8,192 in total). \begin{figure}[!t] \centering \includegraphics[width=0.66\columnwidth]{pic/MIA.pdf} \caption{Enhanced membership inference attack performance.} \label{figure:MIA} \end{figure} As shown in \autoref{figure:MIA}, with the knowledge of the training dataset's underlying property, i.e., 30\% male samples, our enhanced membership inference's AUC (area under the ROC curve) increases from 0.52 to 0.61. Furthermore, when the distribution of gender is more polarized, the enhancement is more pronounced. As a result, the extra item added to the threshold in \autoref{equation:enhanced_MIA} indeed calibrates the membership probability effectively, which further demonstrates the applicability of our property inference attacks. \begin{figure}[!t] \centering \includegraphics[width=0.66\columnwidth]{pic/inaccurate_MIA.pdf} \caption{Enhanced membership inference attack performance w.r.t inferred property with deviations.} \label{figure:inaccurate_MIA} \end{figure} \mypara{Impact of Inferred Properties} As our property inference can not deliver the exact proportion of the considered attribute in the target training dataset, we further evaluate our enhancement algorithm based on inferred proportions with deviations. As we can see in \autoref{figure:inaccurate_MIA}, our enhancement still works on a target GAN with 30\% males when the utilized inference property is less than 50\%. Moreover, the enhanced membership inference's AUC changes slightly when our property inference attack delivers a proportion less than the underlying property, but the AUC decreases significantly to the baseline when the inferred proportion comes closer to 50\%. This further illustrates the applicability of our membership inference attack enhancement algorithm based on the property inference attack. \section{Related Work} \label{section:related} \mypara{Membership Inference Attacks} Membership inference attack tries to infer whether a sample belongs to a specific dataset. Previous studies have demonstrated successful attacks against various targets, such as biomedical data~\cite{HSRDTMPSNC08,BBHM16,HZHBTWB19} and location data~\cite{PTC18}. Shokri et al.~\cite{SSSS17} introduce the first membership inference attack against machine learning models. The key idea is to leverage a set of shadow models to mimic the target model's behavior, and then train an attack model to discriminate member from non-member samples on model outputs. Salem et al.~\cite{SZHBFB19} show that the membership inference attack can attain high accuracy even relaxing the three assumptions in~\cite{SSSS17}. In recent years, membership inference attacks have been investigated on various other scenarios, e.g., white-box models~\cite{NSH19,LF20}, federated learning~\cite{MSCS19}, generative models~\cite{HMDC19,CYZF20}, machine unlearning~\cite{CZWBHZ21}, graph neural networks~\cite{HWWBSZ21,ONK21}, recommender systems~\cite{ZRWRCHZ21}, self-supervised models~\cite{HZ21,LJQG21}, label-only cases~\cite{CTCP21,LZ21}, etc. Despite current research efforts on the membership inference threat for generative models, a wide range of privacy issues of generative models still remain largely unexplored. To fill this gap, we present the first study to specify the property inference attack against GANs. Our results show that even with limited knowledge and access to the target, it is still possible to infer sensitive properties of the training dataset accurately. \mypara{Property Inference Attacks} Property inference attacks aim to infer properties of the target model or the training dataset which are unintended to share by the producer. In fact, sensitive {\it{properties}} cover a wide range of information, which would violate intellectual property if exposed. They can be model-related, such as the model structure and activation functions; as well as data-related, such as where the data are produced or the distribution of the training data. And our work lies in the data-related property inference attacks against GANs. Ganju et al.~\cite{GWYGB18} propose the first property inference attack against discriminative models, which focuses on fully connected neural networks (FCNN), while ours focuses on GANs. As FCNN and GANs have different types of inputs and outputs, the information that our attack exploits is different from \cite{GWYGB18}. As a result, our attack relies on an optimized latent code to the target model in the partial black-box case, while \cite{GWYGB18} uses the weights of FCNN as its property classifier’s input (since it is a white-box attack). Moreover, \cite{GWYGB18} works on the white-box scenario and only treats the inference attack as a binary prediction task, which cannot return a precise prediction of the target property. Different from Ganju et al.~\cite{GWYGB18}, our attacks aim to predict the target property in a far more precise fashion, by modeling the attack task as a regression problem. Furthermore, our proposed attacks work well on two more realistic scenarios: the full black-box and partial black-box setting. Moreover, Carlini et al.~\cite{CLEKS19} demonstrate the secret leakage problem caused by unintended memorization of sequential generative models. It focuses on recovering specific sensitive training records from sequential models, while our work targets at inferring the global data privacy of the training dataset against another important kind of generative model--GANs. Besides the above, there also exists a wide range of study on the security and privacy risks of ML model, such as model stealing~\cite{TZJRR16,OSF19,JCBKP20,YYZTHJ20}, model inversion~\cite{FJR15}, backdoor attack~\cite{WYSLVZZ19,SWBMZ20,LMALZWZ18,CSBMSWZ21} and other attacks under specific background~\cite{SBBFZ20,MSCS19,SS19,HJBGZ21,LWHSZBCFZ22}. \section{Conclusion} \label{section:conclusion} In this paper, we perform the first property inference attack against GANs, the goal of which is to infer the macro-level information of a target GAN's underlying training dataset. We propose a general attack pipeline for two different attack scenarios, following the intuition that the generated samples can reflect the distribution of its underlying training dataset. In the full black-box setting, we rely on random generated samples and a property classifier to realize our attack. In the partial black-box setting, we introduce a novel optimization framework to reduce the number of queries with the help of shadow models. Comprehensive experiments show the effectiveness of both the attack methodologies in a variety of setups including five property inference tasks, four datasets, and four victim GAN models. We also compare our two methodologies to verify the advantage of the partial black-box attack when using a limited number of samples based on two factors, i.e., stability and accuracy. We additionally show the effectiveness of our full black-box attack without \emph{any} knowledge of the target model. Moreover, we present how to leverage our property inference attack to enhance membership inference attacks, which demonstrates the applicability of the proposed property inference method. \section*{Acknowledgement} We thank all the anonymous reviewers for their insightful suggestions and comments to improve the paper. This work is supported by National Key R\&D Program (2020YFB1406900), National Natural Science Foundation of China (U21B2018, 61822309, 61773310, U1736205), Shaanxi Province Key Industry Innovation Program (2021ZDLGY01-02), and the Helmholtz Association within the project ``Trustworthy Federated Data Analytics'' (TFDA) (funding number ZT-I-OO1 4). \bibliographystyle{IEEEtranS}
{'timestamp': '2021-11-16T02:28:32', 'yymm': '2111', 'arxiv_id': '2111.07608', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07608'}
arxiv
\section{Introduction} \label{sec:intro} The complexity of modern software is a source of bugs (leading to program failures), which makes debugging a resource-intensive activity of software development. Automating debugging has thus become a core research field of computer science. Mainly, debugging activities are twofold: fault localization and software repair \cite{lou2020can}. While there is currently excitement in the research around the automation of software repair, fault localization has always been regarded as one of the most tedious and time-consuming activities in debugging~\cite{jones2002visualization}. There is a large amount of literature~\cite{wong2016survey} on advanced fault localization techniques that are developed to aid software engineers to locate program bugs. The granularity and accuracy of such techniques remain however a key bottleneck for their adoption by developers in the industry~\cite{parnin2011automated}. Research has indeed shown that literature approaches to fault localization are limited by a set of strong assumptions on how developers behave when debugging \cite{parnin2011automated}. The researchers revealed that examining a faulty statement is not enough for a developer to understand and fix the corresponding bug. We foresee two different approaches to cope with this limitation: (1) provide a precise characterization of bug alongside coarse-grained localization information (e.g., buffer overflow bug in line~$x$); or (2) provide fine-grained localization of code elements to change alongside the required change operator (e.g., UPDATE boolean value ``true" in line~$x$, column~$y$). Our work focuses on the latter. With the momentum of automated program repair (APR), in particular with the promising generate-and-validate approaches, fault localization techniques are widely leveraged to automate the APR pipeline in terms of identifying code locations that must be involved with code changes to generate patches. Unfortunately, on the one hand, the granularity (e.g., method or line) of fault localization outputs is such that APR tools contribute to exploding the search space in patch generation, leading to an inefficient repair process~\cite{liu2020efficiency}. On the other hand, the inaccuracy of fault localization tools leads APR tools to generate plausible patches (i.e., patches that pass the available test suites without necessarily being correct) that are applied to the non-buggy locations. This is commonly known as the overfitting problem~\cite{wang2020automated,tian2020evaluating,xiong2018identifying,smith2015cure,long2016analysis} (i.e., a plausible patch may still be incorrect), which is now regarded as a key bottleneck for APR adoption in the industry \cite{tao2014automatically}. Finally, a recent study~\cite{liu2019you} has highlighted that the poor performance of state-of-the-art APR tools on benchmark defects can be largely attributed to the under-performance of fault localization: about 1 out of 3 real-world bugs in the Defects4J benchmark~\cite{just2014defects4j} cannot be localized accurately by commonly-used spectrum-based fault localization~\cite{liu2019you}. Overall, fault localization is a critical concern towards facilitating both manual and automatic bug fixing. Consider the example of Defects4J bug Closure-62 as well as its patch shown in Figure~\ref{fig:closure-62}. Although a fault localization tool may localize the buggy {\fontfamily{lmtt}\selectfont if} statement, developers still need to investigate a large number of change trials for addressing the bug. Similarly, a typical search-based generate-and-validate APR tool needs to make various change trials on 12 single code elements (i.e., 12 code tokens: ``{\tt excerpt}'', ``{\tt equals}'', ``{\tt LINE}'', ``{\tt \&\&}'', ``{\tt 0}'', ``{\tt <=}'', ``{\tt charno}'', ``{\tt \&\&}'', ``{\tt charno}'', ``{\tt <}'', ``{\tt sourceExcerpt}'' and ``{\tt length}''). On the one hand, conducting trials on non-buggy code elements will generate and validate a number of nonsensical patches, hence impacting efficiency due to expensive test campaigns~\cite{liu2020efficiency}. On the other hand, modifying the non-buggy code elements increases the likelihood of yielding overfitting patches. For this bug, jKali~\cite{martinez2016astor} removes the whole conditional expression as the faulty element, which is sufficient to pass the weak test suite. \begin{figure}[!t] \centering \lstinputlisting[language=diff, firstnumber=1, numbers = left,xleftmargin=2em, frame=lines,]{listings/Closure-62.txt} \caption{The ground-truth patch and an overfitting patch from jKali for the bug Closure-62.} \label{fig:closure-62} \end{figure} Our work aims to improve fault localization for debugging, with a focus on refining the granularity of code elements to localize, without sacrificing accuracy. We start with the common assumption that underlies most machine learning techniques to defect prediction~\cite{li2019improving}: buggy programs having similar program structures tend to involve the same buggy elements. We, therefore, propose to leverage the concept of abstract syntax tree (AST) path \cite{alon2018general}, which was demonstrated amenable for learning program structure information ~\cite{alon2019code2vec,alon2019code2seq,alon2020structural}. Each code element can thus be accurately identified in the program structure through its AST path. Eventually, we propose a learning approach for fine-grained identification of which code elements must be changed in a buggy program: we refer to this as {\bf fix localization}. Our ambition with fix localization, therefore, goes beyond current fault localization approaches circumscribing the code locations (i.e., at best, the statements) suspected of causing a failure. We develop a new fix localization approach, \textsc{Beep}\xspace (\underline{B}uggy codE \underline{E}lements \underline{P}redictor), which takes as inputs a faulty method and yields a ranked list of code elements that are likely to be the buggy ones. We performed extensive experiments to assess the performance of \textsc{Beep}\xspace. Specifically, we trained \textsc{Beep}\xspace on the dataset used by CoCoNut \cite{lutellier2020coconut} repair tool, and evaluated the prediction results on three defect benchmarks in total: CoCoNut (by using 10-fold cross validation), ManySStuBs4J \cite{karampatsis2020how}, and Defects4J \cite{just2014defects4j}. Since previous studies~\cite{liu2019you} have highlighted that spectrum-based fault localization yields reasonable performance at coarse granularity (e.g., file or method), we consider a fine-grained localization scenario where the buggy method is known. We also perform experiments in a scenario where the faulty line is provided (e.g., by another tool). Overall, the experimental results reveal that the buggy code elements identified by \textsc{Beep}\xspace can significantly reduce the debugging effort. For instance, the median token number for the buggy method in the ManySStuBs4J dataset is 72 while \textsc{Beep}\xspace can predict the buggy token in top-7 on average. Moreover, \textsc{Beep}\xspace is also capable of accurately predicting the code change operator associated to the buggy element. To assess the performance on fixing bugs with the predicted buggy code elements, we design two repair pipelines: in the first (1) we leverage an off-the-shelf code completion tool to predict the correct contents for tokens identified as buggy by \textsc{Beep}\xspace; and in the second (2) we use straightforward heuristics to search for replacements for the localized buggy tokens. Experimental evaluation of the repair pipelines on existing defect benchmarks (Bears, Defects4J, Bugs.jar, and QuixBugs) reveals that these pipelines can fix 27 and 32 bugs respectively, both with a 100\% correctness ratio. Moreover, the efficiency of the pipeline (measured by the Number of Patch Candidates, NPC) significantly outperforms those of the state-of-the-art techniques in the literature (e.g., SimFix~\cite{jiang2018shaping} and TBar~\cite{liu2019tbar}). To sum up, this paper makes the following contributions: \begin{itemize}[leftmargin=*] \item[\ding{172}] [{\bf Fine-grained fix localization with \textsc{Beep}\xspace}]: We develop a new fine-grained fix localization approach, \textsc{Beep}\xspace, which takes advantage of a specialized deep learning architecture that considers abstract syntax tree paths to precisely predict buggy AST nodes. Experimental results with extensive patch datasets (ManySStuBs4J, CoCoNut, and Defects4J) demonstrate the effectiveness of our prediction model which precisely predicts at Top-1 the buggy code elements for up to 45\% bugs. An ablation study further demonstrates the importance of the various components and design decisions in our model. \item[\ding{173}] [{\bf Prediction of code change operators for identified buggy code elements}]: In the implementation of the \textsc{Beep}\xspace fix localization approach, we also learn to predict which operators (i.e., {\tt DELETE}, {\tt UPDATE} and {\tt INSERT}) should be applied to the localized buggy code elements, in order to fix the program. Evaluation results reveal that \textsc{Beep}\xspace can also accurately predict the associated code change operator. \item [\ding{174}] [{\bf Demonstration of \textsc{Beep}\xspace added-value in repair processes}]: Given the output of \textsc{Beep}\xspace (i.e., an identified buggy code element and its associated predicted change operator), we design two repair schemes that leverage either an off-the-shelf code completion tool or a set of straightforward heuristics. We then assess the repair performance of the implemented repair pipelines on four widely-used repair benchmarks. Results reveal that with fine-grained accurate localization, the patch generation performance is characterized by high precision (100\% generated valid patches are also correct) and high efficiency (with an average of only 2 patch candidates to test before finding a valid patch). The pipeline is also complementary to the state-of-the-art since it fixes new bugs that were not yet fixed in the literature. \end{itemize} \section{Background and Definitions} \label{sec:bg} \subsection{Automated Program Repair} APR is a software engineering research field that seeks to automate patch generation towards releasing developers from the heavy burden of manual debugging. APR pipelines start with a fault localization step that enumerates a list of code locations that are suspected as buggy. In widespread generate-and-validate APR tools, spectrum-based fault localization techniques~\cite{pearson2017evaluating} are adopted to produce bug positions at the line~\cite{liu2020efficiency} or method~\cite{wen2018context} granularity. Because the performance of fault localization can severely impact repair performance~\cite{liu2019you}, researchers act on this step to improve the pipeline: e.g., ACS~\cite{xiong2017precise} uses predicate switching~\cite{zhang2006locating} while SimFix~\cite{jiang2018shaping} applies a test case purification approach~\cite{xuan2014test} to refine the fault localization results, respectively. In recent works~\cite{lutellier2020coconut,jiang2021cure}, the assessment of the actual patch generation step of APR has been done by assuming that the fault localization at the line is perfect. Nevertheless, even in such cases, the patch generation is challenged since it often partially touches the relevant code elements~\cite{liu2018closer}. In summary, state-of-the-art APR approaches are still impacted by the presence of non-buggy code elements within the suspected buggy code lines. Our work explores fix localization to achieve finer-grained localization of buggy code elements for program repair. \subsection{Automated Fault localization} Automated fault localization \cite{wong2016survey} aims to precisely diagnose bug positions to facilitate program debugging. The most widely studied {\em spectrum-based fault localization} (SBFL) techniques~\cite{pearson2017evaluating} usually utilize the execution traces of passing and failing tests to identify the suspicious code elements (e.g., lines/methods). The intuition behind this is that if a code element is covered by more failing tests but fewer passing tests, then it is more likely to be the buggy one. Hence, researchers usually apply statistical analysis (e.g., Ochiai~\cite{abreu2007accuracy} and Tarantula~\cite{jones2002visualization}) to calculate the suspiciousness of code elements and rank them in descending order to represent the exposed bug positions. The inherent limitation of SBFL approaches is that a code element executed by a failing test does not necessarily indicate that the element is related to the test failure. To solve this problem, researchers also propose {\em mutation-based fault localization} (MBFL) techniques that mutate code elements and then check their impact on the test outcomes~\cite{papadakis2015metallaxis}. Besides SBFL and MBFL, researchers have explored various fault localization techniques, e.g., slice-based~\cite{zhang2007study}, statistics based~\cite{liblit2005scalable}, program state-based~\cite{zeller2002simplifying}, learning-based~\cite{wong2011effective}, data mining based~\cite{koyuncu2019d}, and model-based techniques~\cite{mayer2008evaluating}. Nevertheless, the state-of-the-art fault localization techniques provide the identified bug positions at best at the granularity of code lines. Our work is the first to target the identification of buggy code elements nested within buggy lines, thus providing a more fine-grained localization for program debugging. \subsection{AST Paths for Code Representation} \label{sec:ast-definition} Recently, a number of works consider the Abstract Syntax Tree (AST) path \cite{alon2018general} for code representation. Code2vec~\cite{alon2019code2vec} and Code2seq~\cite{alon2019code2seq} use all the AST paths within a method with an attention mechanism to represent this method and predict its name as well as generate its natural language description. Brody \emph{et~al.}\xspace \cite{brody2020structural} use this technique to encode the changed code within a file and then predict the following code changes. Alon \emph{et~al.}\xspace \cite{alon2020structural} adopt it to address the {\em any-code completion} task, which is generating a missing piece of source code in a given program. Compton \emph{et~al.}\xspace \cite{compton2020embedding} extend the application scenario of this technique to the whole Java class via variable obfuscation. All the above works demonstrate that the AST path technique is amenable for learning program structure information. We thus build on the concepts of {\em AST path} and {\em operation path} associated to the buggy code elements (see example in Fig.~\ref{fig:ast-path}). Formal definitions for each term in our study are provided as below. \iffalse \begin{figure}[!t] \centering \includegraphics[width=0.9\linewidth]{patches/a.pdf} \caption{Buggy method - with buggy line as identified by spectrum based fault localization} \label{fig:bug} \end{figure} \begin{figure}[!t] \centering \vspace{2mm}\lstinputlisting[language=diff,linewidth={\linewidth},frame=tb,basicstyle=\fontsize{7.5}{8}\selectfont\ttfamily]{listings/patch-bug.diff} \caption{Patch for buggy method in Fig.~\ref{fig:bug}} \label{fig:patch} \end{figure} \fi \begin{figure}[!ht] \centering \vspace{1mm} \includegraphics[width=0.6\linewidth]{figures/AST-path-observation.pdf} \caption{AST \& change operator for the correct patch in Fig.~\ref{fig:closure-62}.} \label{fig:ast-path} \end{figure} \noindent \textbf{Definition 1 - [AST] :} The AST of a code snippet is defined as a tuple: $\langle N, L, T, r, \Delta, \Phi\rangle$, where $N$ is a set of non-leaf nodes, $L$ is a set of leaf nodes, and $T$ is a set of code tokens for $L$. $r \in N$ represents the root node, $\delta\in\Delta : n\rightarrow n^\prime, n \in N, n^\prime \in (N \cup T)$ is a function that reflects the {\em parent-child} relationship between two AST nodes $n$ and $n^\prime$. $\phi\in\Phi : l \rightarrow t, l \in L, t \in T$ maps a leaf node with a corresponding code token. \noindent \textbf{Definition 2 - [AST path] :} An AST path is a path starting from the root node $r$ to a leaf node $l$, that is defined as a quadruple: $p = \langle r, l, N^\prime, \Delta^\prime\rangle, l \in L, N^\prime\subset N, \Delta^\prime\subset\Delta$. \noindent \textbf{Definition 3 - [Operation Path] :} An operation path is an AST path associated with code change operator that works on a leaf node $l$, which is defined as a triple: $op = \langle t, p, o\rangle$, where $t$ is the code token of the leaf node $l$ in the AST path $p$, and $o \in \{\texttt{UPDATE}, \texttt{DELETE}, \texttt{INSERT}\}$ is an atomic code change operator that works on the leaf node. Fig.~\ref{fig:ast-path} provides an illustration of the AST path (with the change operator) for the ground-truth patch illustrated in Fig~\ref{fig:closure-62}. {\tt MethodDeclaration} is the root node of the AST, and other AST nodes with \colorbox{grey}{grey} backgrounds are non-leaf nodes, while all leaf nodes are presented with transparent backgrounds (oval shapes). Each leaf node is attached with its associated code token (in rectangles). The AST path for the buggy operator ``{\tt <}'' is $p$: ``{\tt MethodDeclaration $\rightarrow$ Block $\rightarrow$ IfStatement $\rightarrow$ IfStatement $\rightarrow$ InfixExpression $\rightarrow$ InfixExpression $\rightarrow$ InfixExpression $\rightarrow$ Operator }'', highlighted with a red arrow in Fig.~\ref{fig:ast-path}. For simplification, the other AST nodes irrelevant to the buggy code element are not presented in this figure. The operation path for fixing the buggy operator is $op = \langle$`$<$'$, p, \texttt{UPDATE}\rangle$. As shown in Figure~\ref{fig:ast-path}, the buggy operator `$<$' is replaced (i.e., \texttt{UPDATE}) with the operator `$<=$'. \subsection{Declarations} \label{sec:declaration} In this section, we provide the declarations of code elements and fix localization to clarify their differences between this work and existing studies explored in the literature. \noindent \textbf{[Code Element]:} Generally speaking, all code entities (such as code fragments, statements, expressions, and single code tokens) in the programs can be referred to as code elements for concrete targets. In this work, \textsc{Beep}\xspace is to perform the fine-grained fault localization at code token level for program repair, thus ``{\it code elements}'' studied in this paper denote code tokens in the program. \noindent \textbf{[Fix Localization]:} In the basic pipeline of APR, fault localization aims to pinpoint the statement(s) that can be selected as bug locations for mutation~\cite{le2013current}. The accuracy of fault localization can directly impact the bug-fixing performance of APR tools~\cite{liu2019you}. In the literature, researchers have taken different efforts to improve the fault localization for automated program repair. For example, Tan et al.~\cite{tan2016anti} utilized the anti-patterns to improve fault localization by pinpointing the buggy location at line/function level with higher accuracy. Shariffdeen et al.~\cite{shariffdeen2021automated} leveraged the transformation of existing patches to identify the patch insertion points of bugs at line level. Xin and Reiss~\cite{xin2017leveraging} utilized the stack trace of crashed programs after executing test cases to enhance the fault localization for program repair. Nevertheless, as stated by Le Goues et al.~\cite{le2013current}, the challenge of fault localization for program repair is ``{\it statements that are executed exclusively by the bug-inducing input may not be the best locations for a repair}.'' Our work explores to address this challenge by predicting the fine-grained fault localization (referred to as fix localization in this work) at code element (i.e., code token that need to be fixed within the buggy program) level for program repair, which is different from the existing efforts achieved in the literature on improving fault localization accuracy at line/function level. \section{Proposed Approach} \label{sec:approach} \iffalse We recall that our objective is to design a program repair engine by solving the two key challenges of (1) precisely identifying buggy code elements and (2) accurately replacing them. Figure~\ref{fig:apr} illustrates the overall pipeline: \begin{itemize}[leftmargin=*] \item \textit{Input}: We assume that the faulty method is known. This is a reasonable assumption since, based on data provided in recent studies \cite{lou2020can,benton2020effectiveness}, current techniques are effective in localizing bugs at the method level granularity. \item \textit{Bug prediction}: The first contribution of this work is the \textsc{Beep}\xspace component, which is a learning model aimed at fine-grained localization of buggy code elements and prediction of the change operator. Unlike spectrum-based fault localization (which even provides localization at statement level), \textsc{Beep}\xspace does not require any test execution information. \item \textit{Patch generation}: Buggy code element locations are left as {\em holes} in the program. We build on code completion engines to fill out the holes, thus generating patches for the initial buggy program. \item \textit{Patch validation}: As in classical program repair, each patch candidate is validated against the available test suite. Patch candidates are ordered based on the code completion ranked suggestions. \end{itemize} \fi \textsc{Beep}\xspace is built based on a neural network model trained offline with patches collected in the wild. The model is then used to predict the buggy code element and the associated code change operator. As illustrated in Figure~\ref{fig:model}, the first step in \textsc{Beep}\xspace is a pre-processing step that produces AST differences as representations of patches. \begin{figure}[!ht] \centering \includegraphics[width=0.7\linewidth]{figures/approach.pdf} \caption{Overview of our proposed \textsc{Beep}\xspace.} \label{fig:model} \end{figure} \subsection{\bf Data pre-processing} We consider a collection of historical patches as a training dataset. Then, for each, we use the GumTree~\cite{falleri2014fine} AST differencing algorithm to compute AST diffs, which are the actual input representations for \textsc{Beep}\xspace. These diffs thus allow to readily identify the AST path (from the root towards the modified leaf node) as well as the operation path (i.e., code token + AST path + change operator). This set, which so far includes only true positive samples, is augmented by considering, for every buggy method, all AST paths towards non-buggy leaf nodes and assigning alternatively each of the three change operators. These new operation paths are therefore tagged as true negatives for the training since they represent paths that should not be predicted as buggy. Additionally, during pre-processing, we collect the code token of the leaf node in each AST path to be included in the feature set for learning. Following the insights of a recent study by Lutellier~\emph{et~al.}\xspace~\cite{lutellier2020coconut}, we split code tokens into sub-token sequences in order to significantly reduce the size of the vocabulary. Concretely, as per previous studies~\cite{alon2019code2seq,allamanis2015suggesting}, code tokens are broken into sub-token sequences ``\{$t_0, t_i,\ldots,t_n$\}'' based on camel case and underscore naming conventions, and the obtained sub-tokens are converted to their lowercase form. \subsection{\bf Training the \textsc{Beep}\xspace model} \label{sec:training} \textsc{Beep}\xspace is mainly composed of an {\em encoder-decoder} network and a {\em pointer network} to generate the output. Our prediction approach is based on the intuition of software naturalness~\cite{hindle2012naturalness}: the buggy part should be detectable via learning as encoder-decoders have already done for natural language typographical/grammatical mistakes. A pointer network \cite{vinyals2015pointer} is a simple modification of the {\em attention} model which learns the conditional probability of an output sequence with elements that are discrete tokens corresponding to positions in an input sequence. As several recent studies~\cite{brody2020structural,li2020survey} have further demonstrated, pointer networks are indeed particularly effective when the output is simply picked among elements from inputs. Since in our problem case, the predicted results (i.e., buggy code elements and change operators) are discrete elements, \textsc{Beep}\xspace leverages the pointer network to predict the buggy code elements along with the associated change operators. Figure~\ref{fig:model2} illustrates the overview of the model architecture. \begin{figure}[!ht] \centering \includegraphics[width=0.9\linewidth]{figures/architecture.pdf} \caption{Architecture of the Prediction Model.} \label{fig:model2} \end{figure} Given an operation path, \textsc{Beep}\xspace first respectively encodes code sub-tokens, AST path, and operator with three models\footnote{Encoding each of the sub-tokens, AST path, and operations is followed with the encoding method of code2seq~\cite{alon2018code2seq}.}, and concatenates the vectors for path representation. Then, the path vectors are passed through a fully-connected layer and the Long Short-Term Memory (LSTM) based encoder-decoder consecutively. Finally, the pointer network learns to predict the most probable path. \paragraph{Embedding Operation Paths} Given a set of $k$ operation paths \{$op_1$,\ldots,$op_k$\}, \textsc{Beep}\xspace embeds a vector representation $v_i$ for each path $op_i$ = $\langle$ $t_i$, $p_i$, $o_i$ $\rangle$ where $p_i$ = \{$n_1^i,n_2^i$,\ldots,$n_{l_i}^i$\} is the corresponding AST path, $t_i$ is the code token and $o_i$ is the change operator. To that end, \textsc{Beep}\xspace first leverages a learned embedding matrix to embed each sub-token (after splitting $t_i$) and sum the sub-token vectors to represent the full token. The change operator of each operation path is embedded with another embedding matrix. The embedding process is formulated as below: \begin{equation} \label{eqa:encode-token} \begin{aligned} & \mbox{V}_{t} = \sum_{t_s \in T_{s}} E_{t}(t_s) \\ & \mbox{V}_{o} = E_{o}(o) \end{aligned} \end{equation} where $E_{t}(*)$ and $E_{o}(*)$ are learned embedding matrix. $T_{s}$ is the sub-token sequence of code token $t$ and $V_t$ represents the vector representation for token $t$, while $V_o$ is the vector representation for the change operator $o$. The AST path of each operation path is composed of several AST nodes. \textsc{Beep}\xspace also represents each node $n_i$ using a learned embedding matrix $E_{p}(*)$ and encode the entire sequence with the final state of the bi-directional LSTM neural networks: \begin{equation} \mbox{V}_{p} = LSTM(E_{p}(n_1),E_{p}(n_2),\ldots,E_{p}(n_l)) \label{eqa:encode-path} \end{equation} where $V_p$ represents the vector representation of an AST path. $LSTM$ denotes the bi-directional LSTM neural networks. \paragraph{Extracting Features with Encoder-Decoder Networks} To represent the operation path, we jointly concatenate the vector representations of code token, the AST path, and the change operator, and then pass them through a fully-connected layer, of which results are further fed into the LSTM-based encoder-decoder networks to better capture the features, which is formulated as below: \begin{equation} \begin{aligned} & z_i = tanh(W_{in}[V_t; V_p; V_o]) \\ & (e_1,\ldots,e_k) = LSTM_{encoder}(z_1,\ldots,z_k) \\ & (b_1,\ldots,b_k) = LSTM_{decoder}(e_1,\ldots,e_k) \end{aligned} \end{equation} where $W_{in}$ is the weight matrix with the size of ($d_{t}$ + $2d_{p}$ + $d_{o}$) $\times$ $d_{hidden}$, $(e_1,\ldots,e_k)$ and $(b_1,\ldots,b_k)$ are hidden states of the encoder and decoder, respectively. \paragraph{Generating Results with Pointer Networks} Given the encoder and decoder hidden states $(e_1,\ldots,e_k)$ and $(b_1,\ldots,b_k)$, we calculate the attention vector as follows: \begin{equation} u_j = v^T tanh(W_1e_j + W_2b_j) \end{equation} \noindent where $v$, $W_1$, and $W_2$ are learnable parameters of the model and j $\in$ (1,\ldots,k). The value of $u_j$ is used as attention weight to the $j_{th}$ input: \begin{equation} p(op_j|op_1,\ldots,op_k) = softmax(u_j) \end{equation} \noindent where softmax normalizes the vector $u = [u_1,\ldots,u_k]$ to be an output distribution over the inputs. At last, the output is a list of operation paths ranked by their distribution weights. It should be noted that our {\em pointer network} is a variant of the original model: we only point to a single path from the inputs rather than generating a sequence of outputs. \paragraph{Parameter training} We use cross-entropy loss \cite{rubinstein1999the} to train the parameters in our model: \begin{equation} \label{eqa:loss} Loss = \sum_{y_i \in Y} - \sum_{op \in y_i} [Y_{op} \cdot log(P_{op}) + (1-Y_{op}) \cdot log(1-P_{op})] \end{equation} $Y_{op}$=\{1, 0\} indicates whether the operation path is an oracle path, $P_{op}$ is the outputted weight of the operation path. We use the Adam approach \cite{kingma2014adam} in the learning process to reduce the $Loss$. \subsection{\bf Buggy position prediction} Once the \textsc{Beep}\xspace model is trained, we can use it to predict the operation path (i.e, buggy token value + bug position + change operator) for an unseen buggy method. We first extract AST paths towards all leaf nodes within the buggy method and assign alternatively each of the three change operators, which generates all operation paths for this method. We then embed all these operation paths and send them into the trained model. \textsc{Beep}\xspace will then return the prediction result (i.e., a list where the operation paths are ranked by their output weights). \iffalse \subsection{Generating Patches via Code Completion} As indicated in the design of our approach (cf. Figure~\ref{fig:apr}), \texttt{PEARL}\xspace exploits a code completion engine to predict a replacement token for the predicted buggy one. For our prototype, we build on top of a pre-trained Structural Language Model\footnote{\texttt{AnyCodeGen}\xspace provides APIs for querying a hosted SLM-based code completion engine.} provided by Alon~\emph{et~al.}\xspace~\cite{alon2020structural} referred to as \texttt{AnyCodeGen}\xspace (cf. Section~\ref{sec:slm}). Once \textsc{Beep}\xspace yields the predicted operation path, we parse the change operator and the token (buggy element). If the operator is {\tt DELETE}, then we simply generate a patch that removes this token from the method at the position identified by the predicted AST path. If the operator is {\tt UPDATE}, however, we create a hole (represented by the ``??'' notation\footnote{This notation is recognized by \texttt{AnyCodeGen}\xspace as a program hole to be completed.}) within the buggy method at the position of the identified token for the predicted AST path. The holed code thus constitutes an input for querying the \texttt{AnyCodeGen}\xspace structural language model-based engine. Finally, if the change operator is {\tt INSERT}, we simply add a placeholder (still represented by the ``??'' notation) to the method, again forming a query to the code completion engine. \subsection{Patch Validation} The code completion engine returns a ranked list of predicted tokens. We iteratively use each to generate a patch (depending on the operator type). Each generated patch is then applied to the program, on which the test suite is executed. A valid patch must make the program pass all the test cases. When such a patch is found, the search stops (and the remaining code completion suggestions are discarded). Nevertheless, we manually (but systematically) check that the generated plausible patch is indeed correct. Correctness is assessed in comparison with the ground truth patch. We adopt the rules that were presented by Liu~\emph{et~al.}\xspace~\cite{liu2020efficiency} to ensure that our assessment is replicable. \fi \section{Study Design} \label{sec:exp} \iffalse Our assessment experiments give importance to single-token bugs due to several reasons: First, note that to build a dataset for \textsc{Beep}\xspace training, we need to extract the oracle operation paths associated to bug fixes. When the bug fix affects a single token change, this extraction can be readily done automatically with AST differencing tools such as GumTree~\cite{falleri2014fine}. If the bug fix affects multiple tokens, the matching relations generated by GumTree are often imprecise~\cite{torre2018imprecisions}, the extracted oracle operation paths are noisy and lead to poor training. Second, the \textsc{Beep}\xspace deep learning architecture requires a large dataset of bug fix patches for training. Such datasets in the literature mostly include single-token or single-statement bugs. Finally, our trials with the \texttt{AnyCodeGen}\xspace code completion engine revealed that it is mostly effective when it is fed with a single missing token. In the following sub-section~\ref{sec:stb} we discuss the prevalence of single-token bugs in the wild and show that, despite being seemingly simple, they remain unaddressed by current program repair tools. Sub-section~\ref{sec:rqs} then enumerates the research questions before the experimental setup. \subsection{Single-Token Bugs} \label{sec:stb} A single-token bug is defined as a bug whose fix requires the change (insertion, deletion, or update) of a single token within the program. While fixing such bugs may involve randomly mutating operators ({\tt ==}~$\rightarrow$~{\tt !=}) or heuristically changing some values ({\tt true}~$\rightarrow$~{\tt false}), in many cases it may require an analysis of the code context. Consider the example patch for a benchmark bug (Bears-87) presented in Fig.~\ref{fig:bears-87}. In this case, the patch generation has led to the insertion of a third argument to the function call, a transformation that all state of the art APR tools have failed to achieve so far. Our proposed \texttt{PEARL}\xspace approach, however, has been able to successfully generate this patch automatically just based on the surrounding context of the method code. \begin{figure}[!t] \centering \vspace{2mm}\lstinputlisting[language=diff,linewidth={\linewidth},frame=tb,basicstyle=\fontsize{7.5}{8}\selectfont\ttfamily]{listings/Bears-87.diff} \caption{Ground-truth Patch of the Bug Bears-87.} \label{fig:bears-87} \end{figure} Table~\ref{tab:single-token-bug performance} reports the proportion of single-token bugs in well-established Java APR benchmarks. We also indicate (in the last two columns) the corresponding numbers of single-token bugs that have been plausibly/correctly fixed by 30 Java APR tools from the literature. The data reveal that single-token bugs constitute between 2\% and 22\% of bugs in the considered benchmarks. In the case of the widely-used Defects4J benchmark, 10\% of its bugs are single-token bugs, and to date, more than 20\% of these single-token bugs have not been successfully fixed by many APR tools available in the literature. We also note that for some single-token bugs, only a plausible patch has been found. \input{tables/single-token-bug-performance.tex} \intuition{In Java APR benchmarks (Bears + Bugs.jar + Defects4J + Quixbugs), about \textbf{63\%} (i.e., 1- 33/88) single-token bugs have \underline{\bf\em not yet} been reported as correctly fixed by any APR tool in the literature.} We have also investigated two large scale defects datasets, namely the dataset used in the CoCoNut~\cite{lutellier2020coconut} deep learning based repair approach and the ManySStubs4J~\cite{karampatsis2020how} dataset of single-statement bugs. The statistics in Table~\ref{tab:extra-single-token} confirm that single-token bugs are indeed highly prevalent in real-world codebases. \input{tables/extra-single-token-bug} \intuition{Single-token bugs are widespread in computer programs.} \fi \subsection{Research Questions} \label{sec:rqs} \begin{itemize}[leftmargin=*] \item {\bf [RQ-1] }{\em Is \textsc{Beep}\xspace effective for identifying buggy code elements in real-world programs?} We attempt the fix localization on thousands of bugs to assess the performance of \textsc{Beep}\xspace. Thus, we focus on the predicted results about the buggy token without considering the associated change operator. \item {\bf [RQ-2] }{\em Does \textsc{Beep}\xspace accurately predict the change operator that must be applied to fix a bug?} Given that predicting the operator alone is irrelevant, we investigate the prediction performance of \textsc{Beep}\xspace for the pair of ingredients constituted by the buggy code element and the change operator. The prediction of these ingredients is essential for accelerating both manual and automated program repair~\cite{liu2019tbar, liu2019avatar}. \item {\bf [RQ-3] }{\em To what extent have our design choices influenced the performance of the neural network?} We assess the impact of splitting the tokens, encoding nodes of the AST paths, and using a fully connected layer in improving the predictive power of \textsc{Beep}\xspace. \item {\bf [RQ-4]} {\em Can fine-grained fix localization help improve the precision and efficiency of patch generation?} In particular, we investigate a case study of program repair, how token-level fault localization impacts (1) patch overfitting in APR, as well as (2) the number of patch candidates that are tried before a plausible patch can be identified. \end{itemize} \subsection{Subject Selection} {\bf Patch datasets.} For training the proposed \textsc{Beep}\xspace neural network-based model, we collect patches from the training dataset used by the CoCoNut~\cite{lutellier2020coconut} repair tool. To evaluate the performance of \textsc{Beep}\xspace, we collect bugs from ManySStuBs4J~\cite{karampatsis2020how} and Defects4J~\cite{just2014defects4j} datasets. We choose these datasets because (1) CoCoNut and ManySStuBs4J are large-scale patch benchmarks which are suitable for assessing the generalization ability of our approach and (2) Defects4J is the most widely used benchmark in the software testing literature. We deduplicate the samples and remove samples related to test code, since we focus on fix localization in source code. Overall, the final datasets include 436\,676, 26\,406, and 393 bugs from CoCoNut Dataset, ManySStuBs4J, and Defects4J, respectively. {\bf Repair benchmarks.} To answer RQ4 (on the added-value of \textsc{Beep}\xspace for APR patch generation performance), we consider bugs within four widely-used Java defect benchmarks: Defects4J (V1.4)~\cite{just2014defects4j}, Bears~\cite{madeiral2019bears}, QuixBugs~\cite{lin2017quixbugs} and Bugs.jar~\cite{saha2018bugs}. We choose these benchmarks because they have been widely used for evaluating the state of the art APR tools whose assessment reports are available for comparison. \subsection{Experiment Settings} \subsubsection{\bf Implementation} We implemented \textsc{Beep}\xspace by integrating the Pytorch implementation of PointerNet\footnote{\url{https://github.com/shirgur/PointerNet}} with the framework provided for code2seq~\cite{alon2019code2seq}. The \textsc{Beep}\xspace model is trained on two servers with NVIDIA TITAN V, Xp, and 1080 Ti GPUs. \subsubsection{\bf Parameter configuration} Following the insights of previous studies~\cite{alon2019code2vec, alon2019code2seq}, we set a limit for the maximum \textit{length} of the AST path, as well as for the maximum number of operation paths that we feed to the neural network. These limits are respectively noted as $max_l$ and $max_k$ and are determined empirically as hyper-parameters of our model. For tuning, we randomly sample 43\,000 patches among the considered CoCoNut patches as our validation dataset, while the remaining are used for training and testing. In the tuning process, we mainly focus on the key hyper-parameters: the vector length of encoded tokens (64, 128, 256), learning rate (0.001, 0.002, 0.005), epoch size (20, 40, 50), batch size (64, 128, 256), $max_l$ (10, 15, 20), and $max_k$ (100, 120, 150, 180, 200). Default values of other parameters are taken from the implementation of code2seq. The final values of hyper-parameters of our model are displayed in Table~\ref{tab:parameter-value}. \input{tables/parameter_value} \iffalse \subsubsection{\bf Parameter training} We use cross-entropy loss \cite{rubinstein1999the} to train the parameters in our model: \begin{equation} \label{eqa:loss} Loss = \sum_{y_i \in Y} - \sum_{op \in y_i} [Y_{op} \cdot log(P_{op}) + (1-Y_{op}) \cdot log(1-P_{op})] \end{equation} $Y_{op}$=\{1, 0\} indicates whether the operation path is the oracle one, $P_{op}$ is the outputted weight of the operation path. We use the Adam approach \cite{kingma2014adam} in the learning process to reduce the $Loss$. \fi \subsubsection{\bf Evaluation setting} To answer the first three research questions (c.f., Section~\ref{sec:rqs}) on the performance of the \textsc{Beep}\xspace neural network-based model, we also perform 10-fold cross validation~\cite{wang2020automated,10_fold} on CoCoNut dataset to avoid bias and ensure the generalization of the model. Each training epoch takes about 8~minutes on our computing power, summing up to a total of about 5-hour execution time for each validation fold. \subsubsection{\bf Metrics} To answer research questions RQ-1 to RQ-3, we use the following widely-used metrics \cite{zou2019empirical,li2019deepfl,lou2020can}: {\bf Recall@Top-n:} Following the existing works~\cite{li2019deepfl,zou2019empirical,zhang2017boosting} for the fault localization, we selected the Recall at Top-N as the metric. Specifically, given a descending-order ranked list of predicted suspicious code elements $E^{sus}=\{e^{sus}_1, e^{sus}_2,...,e^{sus}_n\}$, if the buggy code element $e_i$ is within $E^{sus}$, it is localized. A smaller $n$ value indicates the more accuracy of fault localization for automated program repair. It is equivalent to the spectrum-based fault localization methods~\cite{parnin2011automated,lou2020can,li2019deepfl} that locate the bug position at the line level with a ranked list of suspicious statements. In this work, we select $n$ as 1, 3, 5, 10, and 20. A higher {\bf Recall@Top-n} value indicates the better precision of fault localization. Note that in our evaluation datasets, a bug may possess more than one buggy code element (e.g., a patch changes two or more code tokens). Following the validation procedure of spectrum-based fault localization~\cite{parnin2011automated,lou2020can}, we consider that a bug is localized at top-$n$ when one of its buggy code elements is ranked among the top-$n$ predictions of \textsc{Beep}\xspace. {\bf Mean First Rank (MFR):} It computes the mean rank value for the first localized buggy code element in the ranked list of predicted suspicious code elements. For example, given a bug, the list predicted by \textsc{Beep}\xspace contains $n$ suspicious code elements, and the buggy code element is ranked at the $k$ ($k \in [1, n]$) position in the list. A lower {\bf MFR} value indicates the better precision of fault localization. The last research question RQ-4 is assessed with the following two metrics \cite{liu2020efficiency,xiong2017precise}: {\bf Correctness Ratio (CR):} In the literature, to assess the bug fixing performance of APR tools, researchers mainly focus on the number of bugs that can be fixed by APR tools with generated plausible patches (i.e., the patches can make the patched program pass all test suites) \cite{le2012genprog,kim2013automatic}. Due to the overfitting challenge \cite{qi2015analysis,wang2020automated,tan2016anti}, the capability of generating correct patches (i.e., the patches can really fix the buggy program but not just make the patched program pass all test suites) \cite{liu2020efficiency,xiong2017precise,wen2018context} is proposed to evaluate the bug fixing performance of APR tools in the community. Suppose that, an APR tool can generate plausible patches for $x$ bugs, and the generated patches of $y$ bugs are correct, then $CR = y/x * 100\%$. To assess the correctness of APR-generated patches, we adopt the open patch correctness assessment rules provided by Liu \emph{et~al.}\xspace \cite{liu2020efficiency}, where 15 rules are explicitly defined to illustrate how to identify an APR-generated patch as correct when comparing it with the ground-truth develop-written patch provided in benchmark datasets. Such rules are publicly available at \url{https://github.com/TruX-DTF/APR-Efficiency} and are widely used in the patch correctness validation of APR works \cite{wang2020automated,tian2020evaluating,ye2019automated,lutellier2020coconut,jiang2021cure}. {\bf Number of Patch Candidates (NPC):} Repair efficiency is the other metric that is used to assess the bug fixing performance of APR tools. The time cost of generating patches has been proposed in the literature \cite{le2012systematic,ghanbari2019practical} to assess the repair efficiency. However, time cost could be biased by differences among buggy programs, experimental setup and platforms~\cite{liu2020efficiency}. In this study, we leverage the NPC score, the number of patch candidates generated by an APR tool when the first plausible patch is produced~\cite{liu2020efficiency}, to assess the repair efficiency of APR tools. \section{Study Results} \label{sec:eval} We now report on the experimental results and conclude on the research questions. \subsection{Fix Localization Performance} To the best of our knowledge, \textsc{Beep}\xspace is the first approach that targets the fix localization of buggy code elements (cf. Section~\ref{sec:declaration}) that must be changed. Nevertheless, we propose to build two baseline localizers for comparison with \textsc{Beep}\xspace. {\bf Baseline\#1 -- statistics based}: in the study on patch granularity by Liu~\emph{et~al.}\xspace~\cite{liu2018closer}, a reported finding suggests that some specific code elements are more prone to be buggy than others. We leverage their data to build a simple predictor as a baseline: ranking the elements based on their probabilities of being buggy. When two or more tokens present the same probability, their rankings are further determined by their appearance orders in the token sequence of the buggy method. {\bf Baseline\#2 -- machine learning-based}: we also propose to train a Random Forest model \cite{random_forest} for predicting buggy tokens. For a specific token, we consider four kinds of features: $\langle${\em token rank}, {\em statement type}, {\em token length}, and {\em number of sub-tokens}$\rangle$, where {\em token rank} denotes the ranking of this token in the token sequence of the buggy method, {\em statement type} denotes the type of the statement to which this token belongs (e.g., {\fontfamily{lmtt}\selectfont ReturnStatement} or {\fontfamily{lmtt}\selectfont IfStatement}), {\em token length} denotes its number of characters. The {\em number of sub-tokens} of each code token is the sum of sub-tokens that each code token has, after each code token is split into sub-tokens based on the camel case and underscore naming conventions. Our experiments consider two scenarios where \textsc{Beep}\xspace is provided with the full buggy method or the specific line: both inputs can indeed be provided by current spectrum-based fault localization methods. Performance results are provided in Tables~\ref{tab:rq1-line} and~\ref{tab:rq1-method} in terms of the percentages of bug cases for which the tools managed to place the buggy code element among the Top-$k$ of its ranked suspicion list. The {\em Mean First Rank (MFR)} computes the mean rank value for the correct buggy code element: the closer to 1, the better. \input{tables/RQ1-line} \input{tables/RQ1-method} The performance of Baseline\#1 is consistent with the observations in the study of Liu~\emph{et~al.}\xspace~\cite{liu2018closer}. Baseline\#2 also appears to provide a bit better performance than Baseline\#1. Overall, \textsc{Beep}\xspace outperforms these baselines on all datasets and with respect to all metrics. When the input for fix localization is a buggy method, \textsc{Beep}\xspace can precisely rank the buggy code elements at the top-1 position for 46.9\% of bugs in the {\em CoCoNut} dataset, 30.7\% of bugs in the {\em ManySStuBs4J} dataset, and 34.9\% of bugs in the {\em Defects4J} dataset. In contrast, both baselines perform poorly: Baseline\#1 can localize at Top-1 only 3.7\%, 0.7\%, and 1.3\% of bugs, respectively in CoCoNut, ManySStuBs4J, and Defects4J, while Baseline\#2 localizes respectively 14.0\%, 8.1\%, 3.0\% of bugs in these datasets. Finally, we note that \textsc{Beep}\xspace can achieve a recall of around 90\% in localizing the right buggy code element within its Top 20 suggestions for each bug. \notez{{\bf [RQ-1]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \ding{172} \textsc{Beep}\xspace is largely more effective than both a statistical baseline approach and a machine learning-based baseline approach in performing fine-grained localization of buggy code elements (i.e., fix localization). } \begin{figure*}[!ht] \centering \begin{subfigure}{.495\linewidth} \includegraphics[width=0.98\linewidth]{figures/box_plot_method.png} \caption{Buggy method} \end{subfigure} \begin{subfigure}{.495\linewidth} \includegraphics[width=0.98\linewidth]{figures/box_plot_line.png} \caption{Buggy line} \end{subfigure} \caption{Number of tokens in each buggy method and buggy line.} \label{fig:number_of_tokens} \end{figure*} We further investigate how much manual debugging effort can be saved when using \textsc{Beep}\xspace to localize the tokens that must be changed in a method. To that end, we count the number of code tokens in each buggy method and buggy line identified from the three defects benchmarks used in this study. We exclude the Java keywords (e.g., {\em if}, {\em int}, etc.) when calculating the results since it is unlikely that these tokens are buggy. This configuration, however, may under-estimate the effectiveness of \textsc{Beep}\xspace since there indeed exists bugs whose fixes require the changes of such keywords (e.g., Math-57 from Defects4J benchmark is patched by changing {\fontfamily{lmtt}\selectfont int} into {\fontfamily{lmtt}\selectfont float}). Results are shown in Fig.~\ref{fig:number_of_tokens}. We note that the medium values of the number of tokens in each buggy method are 38, 72, and 67 for the CoCoNut, ManySStuBs4J, and Defects4J benchmarks, respectively. Recall that the Mean First Rank (MFR) values for \textsc{Beep}\xspace on these three benchmarks are 3.9, 6.7, and 6.5 respectively (cf. Table~\ref{tab:rq1-method}). Such results indicate that \textsc{Beep}\xspace can rank the buggy elements at a rather high position (i.e., usually in the top 10\% among all the method code elements). When it comes to the number of tokens in each buggy line, the medium values become 5, 3, and 5 for the three benchmarks. From Table~\ref{tab:rq1-line}, the MFR values for \textsc{Beep}\xspace are 2.3, 1.3, and 1.4 respectively, which means \textsc{Beep}\xspace can generally rank the buggy elements within the first half. \notez{{\bf [RQ-1]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \ding{173} When provided with a buggy method, \textsc{Beep}\xspace can drastically reduce debugging effort needed by developers to pinpoint the buggy tokens: on average, \textsc{Beep}\xspace filters out about 90\% of non-buggy code tokens. Even in such a case where the buggy line is known (e.g., with spectrum-based fault localization), \textsc{Beep}\xspace can still halve the number of tokens to manually check. } \iffalse \subsubsection*{\bf Generalization of \textsc{Beep}\xspace beyond single-token bugs} Our \textsc{Beep}\xspace model in this evaluation was trained on single-token bugs (cf. Section~\ref{sec:exp} for justifications). Nevertheless, given that it outputs a ranked list of operation paths (i.e., a buggy code element and its operation), it's use is not limited to single-token bugs. Given a multiple-token bug\footnote{A bug that is not a single-token bug, but also whose fix does not require adding or deleting the whole statement.}, we expect its different buggy code elements to be ranked in the output of \textsc{Beep}\xspace. We perform an experiment using the Defects4J dataset. We discard in this study all bug cases where the fix consists in adding or deleting whole statements. The localization of such bugs is a good target for spectrum-based fault localization. Overall, we apply \textsc{Beep}\xspace on 77 relevant bugs from Defects4J (v1.4) that are exclusively not single-token bugs. Just like in the validation of spectrum-based fault localization~\cite{lou2020can,li2019deepfl}, we will consider that a fault is localized at top-$k$ as long as any of its buggy code element is ranked among \textsc{Beep}\xspace's top-$k$ predictions. This verification is done manually and thus incurs a high workload\footnote{This workload constrained our effort on Defects4J. In future work, other APR datasets can be investigated.}. We then compute the recall@k for all bugs in the set. The recall@1 reaches 10\%, while recall@5, recall@10 and recall@20 are respectively estimated at 43\%, 73\% and 87\%. Unfortunately, our results are not comparable to any work in the literature. Nevertheless, we postulate that \textsc{Beep}\xspace (which does fine-grained localization) can be used in conjunction with spectrum-based fault localization (which provides coarse-grained localization) to achieve a highly-sought precision in bug localization for program repair~\cite{liu2019you}. \fi \noindent \subsection{Joint Prediction of Bug and Change Operator} Aside from the question of accurate fine-grained bug localization, manual repair as well as APR are challenged in the selection of adequate repair operators. Classically, several approaches in the APR literature rely on heuristics to try-and-err with different operators~\cite{jiang2018shaping,liu2019tbar,wen2018context}. \textsc{Beep}\xspace performs the selection of the change operators for the identified buggy code elements by learning a model from the operation paths (i.e., AST path + operator) of existing patches. The prediction performance of \textsc{Beep}\xspace (given a buggy method as input) is detailed in Table~\ref{table:RQ2-result}. \input{tables/RQ2-result} We note that the performance of joint prediction is decreased only slightly when compared against the prediction of buggy code elements alone (cf. Table~\ref{tab:rq1-method}). This suggests that the \textsc{Beep}\xspace model is able to predict the change operator when it precisely locates the buggy element. \notez{{\bf [RQ-2]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} We confirm that \textsc{Beep}\xspace can not only localize the buggy code element (RQ1) but also accurately predict the code change operator associated to it.} \iffalse \update{ \subsection{Efforts Saved for Manual Debugging} We have gained the performances of \textsc{Beep}\xspace on three defect benchmarks so far. To investigate how many manual debugging (i.e., localizing the tokens that to be changed) efforts will be saved when using \textsc{Beep}\xspace, we calculate the number of code tokens in each buggy method and buggy line for patches within the three benchmarks. We exclude the Java keywords (e.g., {\em if} and {\em for}) when calculating the results since it is unlikely that these tokens are buggy. This configuration, however, may under-estimate the effectiveness of \textsc{Beep}\xspace since there indeed exists bugs that require to change the keywords for fixing in our evaluation datasets (e.g., Math-57 which changes {\fontfamily{lmtt}\selectfont int} to {\fontfamily{lmtt}\selectfont float} for fixing). Results are shown in Fig.~\ref{fig:number_of_tokens}. } \begin{figure*}[!ht] \centering \begin{subfigure}{.495\linewidth} \includegraphics[width=0.98\linewidth]{figures/box_plot_method.png} \caption{Buggy method} \end{subfigure} \begin{subfigure}{.495\linewidth} \includegraphics[width=0.98\linewidth]{figures/box_plot_line.png} \caption{Buggy line} \end{subfigure} \caption{Number of tokens in each buggy method and buggy line.} \label{fig:number_of_tokens} \end{figure*} \update{ We can observe that the medium values with respect to the number of tokens in each buggy method are 38, 72, and 67 for the CoCoNut, ManySStuBs4J, and Defects4J benchmarks, respectively. Recall that the MFR values of \textsc{Beep}\xspace on these three benchmarks are 3.9, 6.7, and 6.5 respectively (cf. Table~\ref{tab:rq1-method}). Such results indicate that \textsc{Beep}\xspace can rank the buggy elements at a rather high position (i.e., usually at top 10\%). When it comes to the number of tokens in each buggy line, the medium values become 5, 3, and 5 for the three benchmarks. From Table~\ref{tab:rq1-line}, the MFR values of \textsc{Beep}\xspace are 2.3, 1.3, and 1.4 respectively, which means \textsc{Beep}\xspace can generally rank the buggy elements at the first half. } \notez{{\bf [RQ-3]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \update{ When the input is a buggy method, \textsc{Beep}\xspace can save great efforts for the developers for finding the buggy tokens with filtering around 90\% code tokens on average. Even if the buggy line is identified, \textsc{Beep}\xspace can still reduce more than half of the burden. } } \fi \subsection{Ablation Study} We assess the contributions of some components and design choices in the performance of our core prediction model, \textsc{Beep}\xspace. Our analysis focuses on three key aspects: (1) the impact of our sub-token splitting; (2) the impact of our node-based AST path encoder; and (3) the impact of fully-connected layer for feature extraction. In the first experiment assessing the impact of sub-token splitting, we directly feed each token in our dataset to $E_t(*)$. In the second experiment assessing the design choice of considering each node, we do not represent each node in the AST path $p$. Instead, we learn an embedding matrix $E_{paths}$ for representing the whole AST path. In the third experiment, we drop the fully-connected layer: we directly use the concatenated operation path representation as the input of the LSTM encoder layer. The results are summarized in Table~\ref{tab:ablation_onlyMFR} w.r.t. the performance of the bug prediction model. Due to space constraints, we only provide MFR metric values which are indicative of the overall performance. We note that under each experimental setting, the MFR value when {\em no token splitting} is applied is always the highest. On CoCoNut dataset, while the performance of model variants can be on par with that of the full \textsc{Beep}\xspace, the MFR value is always lowest with \textsc{Beep}\xspace, indicating that our design choices globally lead to the best predictive model. On ManySStuBs4J and Defects4J datasets, the results of \textsc{Beep}\xspace are systematically better than those yielded by its variants. Note that the different models are trained on the CoCoNut dataset, which, for applied on ManySStuBs4J and Defects4J bugs, leave room to improve the neural network design choices for \textsc{Beep}\xspace. \input{tables/ablation_onlyMFR} \notez{{\bf [RQ-3]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} Various design choices have together contributed to the performance of \textsc{Beep}\xspace. Splitting the tokens before embedding appear to be the most rewarding design choice.} \subsection{Repair Performance on Real Bugs} In this RQ, we seek to investigate if narrowing the mutation space of APR tools by leading them to change the predicted buggy tokens can enhance the precision (i.e., avoiding generating overfitting patches) and the efficiency (i.e., reducing the number of patch candidates that are tried before the first plausible patch). After a review of literature artifacts, we found that state-of-the-art APR tools are implemented such that the patch generation process is entangled with current fault localization settings. We thus propose to experiment with implementations of two straightforward repair pipelines based on code completion and on heuristics. The basic workflow for these two pipelines is as follows: \noindent {\bf Input:} We assume that the faulty method is known. This is a reasonable assumption since, based on data provided in recent studies \cite{lou2020can,benton2020effectiveness}, existing techniques are effective in localizing bugs at the method level granularity. Some APR tools~\cite{liu2019you,le2016history} in the literature are even assessed based on the assumption. \noindent {\bf Bug prediction:} We use \textsc{Beep}\xspace to predict the buggy tokens. After this step, we obtain a ranked list of operation paths. \noindent {\bf Operation path selection:} We consider the first 20 operation paths since our evaluation results (cf. Table~\ref{table:RQ2-result}) have shown that \textsc{Beep}\xspace has a very high recall within its top-20 results (i.e., the searched operation path is in among those). We then use a simple try-and-err heuristic: we iterate over each path following the ranking order and input it to the patch generation process. If all paths have been tried but no test-adequate patch is generated, we re-iterate over pairwise combinations of operation paths, and so on. This process comes to an end when a patch that passes all the tests is generated. \noindent {\bf Patch generation:} In this step, patches are generated by using either a code completion technique or straightforward heuristics. We will introduce the details of these two methods later in this section (after the general workflow). \noindent {\bf Patch validation:} Each generated patch is then applied to the program, on which the test suite is executed. A valid patch must make the program pass all the test cases. When such a patch is found, the search stops. We then manually (but systematically) check whether the generated plausible patch is indeed correct. Correctness is assessed in comparison with the ground truth patch. We adopt the rules that were presented by Liu \emph{et~al.}\xspace \cite{liu2020efficiency} to ensure that our assessment is replicable. \subsubsection{Code completion for patch generation} Given the naturalness of software~\cite{hindle2012naturalness}, we postulate that it should be possible to statically predict missing elements just like one predicts missing words in natural language text. Fortunately, such an idea has been very recently explored by Alon \emph{et~al.}\xspace with their approach for code generation with structural language modeling (SLM)~\cite{alon2020structural}. While other state of the art such as seq2seq~\cite{sutskever2014sequence}, code2seq~\cite{alon2019code2seq} and structured prediction~\cite{brockschmidt2018generative} are valid alternatives for our code completion task, we build in this work on SLM: its {\em AnyCodeGen} trained model was experimentally shown to significantly outperform a variety of strong baselines on Java and C\# languages for the task of code completion~\cite{alon2020structural}. Once \textsc{Beep}\xspace yields the predicted operation path, we parse the change operator and the token (buggy element). If the operator is {\tt DELETE}, then we simply generate a patch that removes this token from the method at the position identified by the predicted AST path. If the operator is {\tt UPDATE}, however, we create a hole (represented by the ``??'' notation\footnote{This notation is recognized by \texttt{AnyCodeGen}\xspace as a program hole to be completed.}) within the buggy method at the position of the identified token for the predicted AST path. The holed code thus constitutes an input for querying the \texttt{AnyCodeGen}\xspace structural language model-based engine. Finally, if the change operator is {\tt INSERT}, we simply add a placeholder (still represented by the ``??'' notation) to the method, again forming a query to the code completion engine. \subsubsection{Heuristics-based repair pipeline} In this implementation, we generate patches via using the following heuristics: \begin{itemize}[leftmargin=*] \item If the predicted operation is {\tt DELETE}, we directly remove this token. \item If the predicted operation is {\tt INSERT} or {\tt UPDATE}, we transform the program using the following rules: \begin{itemize}[leftmargin=*] \item if the token is an operator, we change it to another one in the operator set (e.g., == $\rightarrow$ != and $>=$ $\rightarrow$ $>$); \item if the token is a boolean value, we change it to its reverse (e.g., false $\rightarrow$ true); \item if the token is a data type, we change it to another type (e.g., int $\rightarrow$ float); \item if the token is an identifier, we replace it or pad the location with its 5-nearest\footnote{Distance is computed within the token sequence of the buggy method.} identifiers with the same type. We consider generating only 5 candidates to remain comparable to \texttt{AnyCodeGen}\xspace code completion engine which only returns 5 code completion results. \end{itemize} \end{itemize} \noindent {\bf Analysis of repairability.} We provide in Table~\ref{tab:repair-result-simple} the performance of our repair pipelines on the four defect benchmarks. We also compare their performance against the results of 26 APR techniques reported in recent literature~\cite{jiang2021cure}. Due to space limitation, we only include in this table the most representative tools w.r.t. yielding highest precision (i.e., high correctness ratio - CR - above part of the table) and w.r.t. repairability (i.e., the highest number of bugs fixed - below part of the table). Overall, we find that our pipelines can both achieve 100\% precision: all generated patches that passed the test suite were found to be correct. Actually, during the manual check, we found that they were all identical to the ground-truth patches. In comparison, the APR tool with the highest precision in the literature, i.e., CapGen, has a correctness ratio of 84\%. We also note that our pipeline provides comparable performance with respect to the number of correctly fixed bugs when compared with the first four tools. For instance, ACS can only correctly fix 18 bugs while \textsc{Beep}\xspace (with heuristics-based patch generation) can correctly fix 21 bugs. On the other hand, although tools with high repairability metrics outperform our pipelines in terms of the number of correctly fixed bugs, their overall precision is low. For example, DLFix plausible patches even include more incorrect ones than correct ones. Since in practice developers should check that the correctness of generated patches before integrating them, it may be detrimental to use APR if the correctness ratio is low. We also note that when using simple heuristics for patch generation, we can fix more bugs (32 vs. 27) than when relying on a carefully-designed and fully-trained sophisticated Deep Learning model for code completion (i.e., \texttt{AnyCodeGen}\xspace). Our results suggest that, for program repair, finding donor code within the same method may be more effective than predicting missing tokens using big data. Moreover, we found that our pipelines are able to fix bugs which were never yet reported to be fixed by the considered 26 APR tools. 2 of such bugs can be found in the Defects4J dataset. \textsc{Beep}\xspace + code completion also led to fixing 2 bugs from Bears as well as 4 bugs from Bugs.jar which were not fixed by the state-of-the-art tools (such as ARJA~\cite{yuan2018arja}) which were applied on these benchmark. These results further demonstrate token-level-based program repair is a sweet spot for developing further directions in generate-and-validate APR. \input{tables/repair_result_simple} \notez{{\bf [RQ-4]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \ding{172} Automated program repair built on the top of \textsc{Beep}\xspace localization results can produce patches with high correctness ratio, hence providing a novel perspective to address patch overfitting in program repair. } \noindent {\bf Analysis of patch generation efficiency.} In this section, we consider only the \textsc{Beep}\xspace plus heuristics repair pipeline since it is more effective. Repair efficiency assessment considers the number of patch candidates (NPC) that are generated and tested before a plausible patch is hit. NPC score was recently proposed by Liu~\emph{et~al.}\xspace~\cite{liu2020efficiency} to enable fair comparison across computing environments. They provide the NPC score of several state-of-the-art tools for the Defects4J bugs with the assumption that each APR is provided with the buggy line. We also place the proposed pipeline under this setting. Fig.~\ref{fig:efficiency} compares the distribution of NPC of the pipeline vs. 16 APR tools considered by Liu~\emph{et~al.}\xspace~\cite{liu2020efficiency} on Defects4J bugs. \begin{figure}[!ht] \centering \includegraphics[width=0.7\linewidth]{figures/NPC1_updated.pdf} \caption{Comparison of efficiency.} \label{fig:efficiency} \end{figure} With a median NPC score of 2, our pipeline is more efficient than pattern-based APR techniques (e.g., TBar and kPAR) and even more recent state of the art heuristic-based APR techniques (e.g., SimFix). Nevertheless, six tools significantly outperform this pipeline in terms of efficiency: three (i.e., DynaMoth, Nopol, ACS) actually use constraint-solving and synthesis strategies, which indeed make them efficient (see ~\cite{liu2020efficiency}); the other three (i.e., jKali, Kali-A, and jMutRepair) apply naive repair strategies that limit their search spaces -- jKali and Kali-A change conditional statements into {\em true} or {\em false} and jMutRepair only mutate operators. \notez{{\bf [RQ-4]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \ding{173} Successful prediction of the buggy code element and adequate change operator by \textsc{Beep}\xspace limits the number of patch candidates, hence improving the efficiency of patch generation.} \iffalse We compare our \textsc{Beep}\xspace-based prototype repair tool (i.e., \texttt{PEARL}\xspace) against 31 APR techniques from the literature\footnote{We consider tools targeting Java programs and where execution results on the available benchmarks can be found in repositories or are available in replication studies.} on single-token bugs in the relevant benchmarks. Although these tools have been executed with different fault localization assumptions, we can perform this comparison after checking that all 111 considered single-token bugs are actually localizable at the method level by the typical spectrum-based fault localization pipeline (GZoltar~\cite{campos2012gzoltar} + Ochiai~\cite{abreu2007accuracy}) used by the APR tools in the literature. 110 (i.e., except a single bug\footnote{This bug (related to a method modifier) is not fixed by any APR tool, including ours.}) bugs can further be localized at the line level. No tool is thus advantaged over the others in our comparison. \input{tables/repair_result} \subsubsection{\bf Analysis of repairability} \label{subsub:analysis} Table~\ref{tab:repair-result} details the performance comparison data. Overall, \texttt{PEARL}\xspace successfully fixes 30 out of 111 single-token bugs. We successfully fixed 2 bugs from {Bears} benchmark which were never yet reported as fixed by previous APR tools. We achieve this also for 4 bugs in {Bugs.jar}. We are also able to fix 3 single-token bugs among the additional bugs that were integrated with v2.0 of Defects4J. Finally, we note that \texttt{PEARL}\xspace is capable of partially fixing a multi-location bug (Mockito-16), which no previous tool could address (even partially). \begin{figure}[!ht] \begin{center} \includegraphics[width=0.18\textwidth]{figures/Venn-blackwhite.pdf} \end{center} \caption{Overlaps in fixed Defects4J single-token bugs for deep-learning based APR tools.} \label{fig:venn} \end{figure} Since \texttt{PEARL}\xspace builds on \textsc{Beep}\xspace (which is based on neural networks), we propose to compare its repairability against deep learning (DL)-based repair tools (DLFix~\cite{li2020dlfix}, SequenceR~\cite{chen2019sequencer} and CoCoNut~\cite{lutellier2020coconut}). The Venn diagram of Fig.~\ref{fig:venn} illustrates the complementarity of \texttt{PEARL}\xspace with other DL-based approaches on fixing different bugs in the Defects4J dataset (v1.4, where \texttt{PEARL}\xspace fixed 16 bugs). In particular, comparing with the CoCoNut, whose training dataset is used for training \textsc{Beep}\xspace, we note only a small overlap. {\bf Contribution of AnyCodeGen.} To dissect the contribution of \texttt{AnyCodeGen}\xspace on the overall performance of \texttt{PEARL}\xspace, we implement another repair pipeline where we replace \texttt{AnyCodeGen}\xspace by a heuristic replacement operator. If the predicted operation is {\bf ADD} or {\bf UPDATE}, we transform the program using the following rules: (1) if the token is an operator, we change it to another one (e.g., == $\rightarrow$ != and >= $\rightarrow$ >); (2) if the token is a boolean value, we change it to its reverse (e.g., false $\rightarrow$ true); (3) if the token is a data type, we change it to another type (e.g., int $\rightarrow$ float); (4) if the token is an identifier, we replace it or pad the location with its 5-nearest\footnote{Distance is computed within the token sequence of the buggy method.} identifiers (to be comparable with \texttt{AnyCodeGen}\xspace which only returns 5 candidates). Repair performance results using this replacement heuristic on \textsc{Beep}\xspace predicted buggy elements are provided in the top of the last three rows of Table~\ref{tab:repair-result}. It is noteworthy that this heuristic-supported pipeline produces comparable performance with \texttt{PEARL}\xspace, by correctly fixing in total 29 bugs (only one fewer than \texttt{PEARL}\xspace). It can even fix more bugs than \texttt{PEARL}\xspace on specific benchmarks such as {\em QuixBugs} and {\em Bugs.jar}. These results suggest that although \texttt{AnyCodeGen}\xspace is advanced, it is not the main contributor to the effectiveness of \texttt{PEARL}\xspace. The key insight is thus program repair could be highly effective when fix localization (i.e., fine-grained identification of code elements to change) is accurate. {\bf Contribution of \textsc{Beep}\xspace.} We perform another experiment to dissect the contribution from \textsc{Beep}\xspace where we assume a perfect line-level fault localization and let \texttt{AnyCodeGen}\xspace synthesize the correct statement. The performance results (cf. second of last three rows in Table~\ref{tab:repair-result}) record that such a pipeline can only fix in total 2 bugs. This confirms that (1) without fine-grained fix localization, program repair as a code completion task is infeasible; and (2) \texttt{AnyCodeGen}\xspace does not perform well on completion of programs that are missing whole statements. \notez{{\bf [RQ-4]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \ding{172} \texttt{PEARL}\xspace offers comparable performance to the state of the art in addressing single-token bugs. It is even complementary to existing tools, being able to fix new bugs. More in-depth analyses reveal that \textsc{Beep}\xspace predictive power is the main contribution for this performance.} \subsubsection{\bf Analysis of patch correctness} All plausible patches generated by \texttt{PEARL}\xspace are correct (i.e., the correctness ratio (CR) is 100\%). While constraint-based program repair tools {JAID} and {ACS} achieve a CR score of 100\%, they can only fix 8 and 3 single-token bugs, respectively. Note, APR tools (CapGen, ConFix, FixMiner, and TBar) which outperform \texttt{PEARL}\xspace on Defects4J in generating plausible patches, produce overfitting patches (with a CR as low as 64\% for ConFix). We analyse cases where other tools generate overfitting patches to comprehend the success of \texttt{PEARL}\xspace: on Closure-62, jKali (which implements too coarse-grained operations) simply deletes an entire conditional block to make the program pass all test cases, while \texttt{PEARL}\xspace is forced to address a specific buggy code element, leading to the generation of a correct patch. We also investigate the 81 single-token bugs in the benchmarks that \texttt{PEARL}\xspace fails to fix. There are mainly three reasons for the failures of our tool: \begin{itemize}[leftmargin=*] \item \texttt{PEARL}\xspace is challenged when the fix is about changing a method name of a defective method invocation due to the formatting of the code completion query. More details with a case study are provided with the replication package. \item \texttt{AnyCodeGen}\xspace fails in many cases to generate the appropriate replacement. In future work, we will consider specific heuristics to boost code completion for targeting program repair scenarios. \item \texttt{AnyCodeGen}\xspace only returns 5 candidate results for each code completion query, potentially leading \texttt{PEARL}\xspace to miss the opportunity to hit a valid patch with more repair attempts. \end{itemize} \notez{{\bf [RQ-4]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \ding{173} Precise fine-grained localization of repair targets leads \texttt{PEARL}\xspace to generate plausible patches with a high probability of correctness.} \subsubsection{\bf Analysis of patch generation efficiency} Repair efficiency assessment considers the number of patch candidates (NPC) that are generated and tested before a plausible patch is hit. NPC score was recently proposed by Liu~\emph{et~al.}\xspace~\cite{liu2020efficiency} to enable fair comparison across computing environments. They provide the NPC score of several state of the art tools for the Defects4J bugs with the assumption that each APR is provided with the buggy line. We also place \texttt{PEARL}\xspace under this setting. Fig.~\ref{fig:efficiency} compares the distribution of NPC of \texttt{PEARL}\xspace vs 16 APR tools considered by Liu~\emph{et~al.}\xspace~\cite{liu2020efficiency}. Note that, for fairness, we consider only the NPC scores for single-token bugs. \begin{figure}[!h] \centering \includegraphics[width=0.7\linewidth]{figures/NPC1.pdf} \caption{Comparison of efficiency - {\footnotesize numbers between parentheses (\#) represent the number of bugs for which the tool eventually generated a plausible patch - after trying several patch candidates (NPC)}.} \label{fig:efficiency} \end{figure} With a median NPC score of 2, \texttt{PEARL}\xspace is more efficient than pattern-based APR techniques (e.g., TBar and kPAR) and even more recent state of the art heuristic-based APR techniques (e.g., SimFix). Nevertheless, six tools significantly outperform \texttt{PEARL}\xspace in terms of efficiency: three (i.e., DynaMoth, Nopol, ACS) actually use constraint-solving and synthesis strategies, which indeed make them efficient (see ~\cite{liu2020efficiency}); the other three (i.e., jKali, Kali-A, and jMutRepair) apply naive repair strategies that limit their search spaces -- jKali and Kali-A change conditional statements into {\em true} or {\em false} and jMutRepair only mutate operators. \notez{{\bf [RQ-4]} \hspace{2mm}\begin{rotate}{90}\ding{242}\end{rotate} \ding{174} Successful prediction of the buggy code element and adequate change operator by \textsc{Beep}\xspace limits the number of patch candidates, hence improving the efficiency of patch generation.} \fi \section{Discussion} \label{sec:dis} \noindent{\bf Influence of bug occurrence:} \textsc{Beep}\xspace, as similar data-driven approaches~\cite{li2020dlfix}, performs poorly on infrequent bugs that are not common in programs or their similar bugs are very rarely occurred. Indeed, features of such bugs are generally not well captured in model training. \noindent{\bf Declaration vs body of methods:} Buggy method declarations are challenging for \textsc{Beep}\xspace. For example, in Defects4J bug {\em Lang-29}, the return type of the method should be {\em float} instead of {\em int}. Given that such bugs have short AST paths (2 nodes), the model fails to learn any relevant features for predicting the buggy elements. \noindent{\bf The ability to fix multi-location bugs:} Despite that, the majority of bugs which can be fixed by \textsc{Beep}\xspace with the heuristics are about the modification of a single code token, we did note that this pipeline can fix multi-location bugs. Totally, our pipeline fix two multi-location bugs from Defects4J dataset. A case is illustrated in Figure~\ref{fig:math-79}. Fixing this bug requires to change the data type {\tt int} into {\tt double} in two locations. After \textsc{Beep}\xspace accurately predicts the two buggy elements (and the operators) within its Top 2, our heuristics successfully generate the correct patch since it allows to change the data type. Another instance is Time-4 where our pipeline precisely predicts the deletion of a token with an insertion in another location. \begin{figure}[!ht] \centering \vspace{3mm} \lstinputlisting[language=diff, firstnumber=1, numbers = left,xleftmargin=2em, frame=lines,]{listings/Math-79.diff} \caption{The ground-truth patch for the bug Math-79.} \label{fig:math-79} \end{figure} \noindent{\bf Threats to Validity:} Our experimental results carry some threats to validity, notably \ding{182} its generalization beyond the Java programming language. Although the theoretical design of \textsc{Beep}\xspace is valid for any language whose AST can be readily generated (e.g., C/C++), we selected Java due to the availability of large-scale off-the-shelf datasets and benchmarks, and the possibility to compare against some open released state of the art tools. As a second threat, we note that \ding{183} \textsc{Beep}\xspace was trained and evaluated with two recent large-scale datasets with a significant proportion of single-statement patches. Such a dataset may be biased or non-representative. We plan to extend the evaluations to more kinds of bugs by collecting more diverse datasets. As a third threat, \ding{184} Defects4J contains bug cases where the fix consists in adding or deleting whole statements. The localization of such bugs is a good target for spectrum-based fault localization, but not of \textsc{Beep}\xspace because we did not consider such cases in our training set (borrowed from CoCoNut). As a forth threat, \ding{185} \textsc{Beep}\xspace is built on an assumption of the available information of fault methods/statements, that is not practical. \textsc{Beep}\xspace is a token-level fault localization built on top of the statement-level/method-level fault localization tools. The assumption is mainly used to evaluate the possibility of predicting the exact buggy code elements for program repair within a limited search space of suspicious bug locations. As a fifth threat, \ding{186} the AST/Operation paths created by \textsc{Beep}\xspace do not have long length, which arises a threat for \textsc{Beep}\xspace that the impact from the long path on the learning model cannot be assessed. We list it as a part of future work for improving \textsc{Beep}\xspace. Finally, \ding{187} different embeddings of the sub-tokens, AST path, and operations can impact the performance of the deep learning models, which could further influence the performance of \textsc{Beep}\xspace, nonetheless, this work mainly focuses on exploring the possibility of fine-grained fix localization for program repair. The influence of the different embeddings will be investigated in future work. \section{Related Work} \label{sec:relatedWork} \noindent{\bf Developers' Opinion on Fault Localization.} A number of studies investigate developers' perspectives on current FL techniques. Parnin and Orso~\cite{parnin2011automated} find that several assumptions made by automated debugging techniques do not hold in practice for developers (e.g., ``examining a faulty statement in isolation is enough for a developer''). Xie~\emph{et~al.}\xspace~\cite{xie2016revisit} find that simply providing the ranked suspicious code lines for developers actually reduces their debugging efficiency. Kochhar \emph{et~al.}\xspace~\cite{kochhar2016practitioners} find that the most popular FL granularity so far (i.e., method level) only gains preferences from around half of the investigated practitioners. Our work provides developers with a finer-grained FL results by targeting the buggy code tokens as well as the required change operator. We expect \textsc{Beep}\xspace research direction to contribute to reducing the burden of manual debugging in practice. \vspace{1mm} \noindent{\bf Learning-Based Fault Localization.} With the power of advanced neural networks, a number of works have been proposed for performing fault localization based on machine/deep learning. Wong and Qi \cite{wong2009bp} propose a fault localization approach based on the back-propagation (BP) neural network. MULTRIC~\cite{xuan2014learning} is the first learning-to-rank fault localization technique that can integrate the suspiciousness values calculated with spectrum-based fault localization techniques (SBFL) to improve the accuracy of SBFL~\cite{zou2019empirical}. Since then, program invariant~\cite{b2016learning} and source code complexity information~\cite{sohn2017fluccs} have been explored to combine the SBFL suspiciousness values for more effective learning-to-rank fault localization. These learning-to-rank fault localization techniques aim to rank faulty statements higher than correct ones, while other learning based fault localization techniques focus on the test coverage information~\cite{briand2007using,zhang2017deep,zheng2016fault, wong2009bp} that cannot distinguish elements accidentally executed by failed tests and the actual faulty elements~\cite{li2017transforming}. Zhang \emph{et~al.}\xspace \cite{zhang2019cnn} construct a convolutional neural network customized for fault localization. Li \emph{et~al.}\xspace \cite{li2019deepfl} propose to leverage the traditional MLP and RNN networks to learn the effective existing/latent features (collected from the various suspiciousness-value-based, fault-proneness-based and textual-similarity-based features from the fault localization, defect prediction and information retrieval areas) for precise fault localization. Li \emph{et~al.}\xspace \cite{li2021fault} treat FL as an image pattern recognition problem and achieve so via novel code coverage representation learning (RL) and data dependencies RL for program statements. These works all locate the buggy code at the statement and method levels which is still coarse-grained, our work explores to leverage the deep learning techniques to predict the buggy code elements in buggy statements for program repair. \vspace{1mm} \noindent{\bf Fault Localization for APR.} An essential step in APR is identifying the locations of buggy code within the program to be repaired~\cite{bohme2017where}. These locations are the target for selecting code entities that must be transformed to generate patches. As reported in recent work~\cite{liu2019you}, the commonly-adopted FL configuration (with GZoltar and Ochiai) still provides too inaccurate bug localization information for automated program repair. Therefore, researchers try to enhance FL for APR with predicate switching~\cite{xiong2017precise,zhang2006locating}, test case purification~\cite{jiang2018shaping}, deep learning~\cite{li2019deepfl} and other information~\cite{zhang2017boosting,wen2019historical}. Most APR tools leverage localization information at the granularity of code lines. To the best of our knowledge, our work is the first to target the identification of buggy code elements nested within buggy lines, thus providing a more fine-grained localization for APR. As reported by previous works \cite{liu2020efficiency, liu2019you}, the accuracy of FL results can cause significant differences in repair performances. In detail, accurate FL can enhance the efficiency as well as the precision of APR tools. Our evaluation with a fine-grained token-level FL also demonstrates this point. \vspace{1mm} \noindent{\bf APR for Fault Localization.} Previously, the connection between the two key points in software debugging (i.e., fault localization and program repair) is that program repair techniques usually use off-the-shelf fault localization techniques to identify potential buggy locations for patching \cite{wen2018context,jiang2018shaping}. Recently, however, Lou \emph{et~al.}\xspace \cite{lou2020can} propose to utilize the patch execution information during program repair for providing fault localization with useful feedback. A follow-up work~\cite{benton2020effectiveness} further demonstrated that the effectiveness of this approach can be enhanced when integrating patch generation information from diverse APR systems. Nevertheless, these works target accurate localization at the method level. They can therefore be complemented by \textsc{Beep}\xspace to achieve fine-grained FL (i.e., fix localization). \vspace{1mm} \noindent{\bf State-of-the-art APR.} The APR community has explored various APR techniques to address the bugs in different language-written programs. One of the commonly studied approaches is generate-and-validate program repair. Since GenProg~\cite{weimer2009automatically} created the milestone of program repair, which was proposed to solve C program bugs with a generic method, various APR techniques have been proposed in the literature that can be categorized into four main categories: heuristic-based, constraint-based, and template-based and learning based repair approaches~\cite{le2019automated}. Heuristic-based repair approaches construct and iterate over a search space of syntactic program modifications, e.g., SimFix~\cite{jiang2018shaping}. Constraint-based repair approaches generally leverage the specific technique (e.g., constraint solving) to infer the constraints of the given buggy program, which are further used to guide the generation and validation of patches, e.g., SemFix~\cite{nguyen2013semfix}. Template-based repair approaches utilize the fix patterns identified from the real-world patches, that can provide the dedicated code change behaviors for bug fixing, e.g., TBar~\cite{liu2019tbar}. Learning-based repair approaches rely on machine learning or deep learning techniques to learn correct fix ingredients for patch generation, e.g., Prophet~\cite{long2016automatic}. To date, the state-of-the-art APR research work mainly focuses on the bugs in C/C++ programs~\cite{nguyen2013semfix, mechtaev2016angelix, tan2015relifix, long2015staged, long2016automatic, gao2019crash} and Java programs~\cite{kim2013automatic}. This work is to provide the fine-grained fault localization for APR to reduce the possibility of generating plausible but incorrect patches because of the coarse fault localization. \vspace{1mm} \noindent{\bf Deep Learning for APR.} A considerable number of studies have utilized deep learning techniques for program repair.\\ \noindent \ding{228} SequenceR~\cite{chen2019sequencer}, DLFix~\cite{li2020dlfix}, CoCoNut~\cite{lutellier2020coconut}, and CURE~\cite{jiang2021cure} work at the line level, thus requiring as input the exact buggy statement, an information granularity that current fault localization inaccurately provides. In contrast, our repair pipeline only targets buggy methods, a granularity that is more accessible to off-the-shelf fault localization tools~\cite{lou2020can,benton2020effectiveness}. \\ \noindent \ding{228} Although the approach of Tufano~\emph{et~al.}\xspace~\cite{tufano2019empirical} works with methods, they have to disregard methods with more than 50 tokens due to the performance limitation of their seq2seq translation. In contrast, we accept any-size methods.\\ \noindent \ding{228} Allamanis~\emph{et~al.}\xspace~\cite{allamanis2018learning} use graph-based deep learning while Vasic~\emph{et~al.}\xspace~\cite{vasic2019neural} adopt multi-headed pointer networks for repairing bugs. Hellendoorn~\emph{et~al.}\xspace~\cite{hellendoorn2020global} further propose a hybrid model by analyzing the weakness of the previous two works. The limitation of these works is that they only focus on variable-misuse bugs. While they propose to localize variable tokens, our work targets any buggy token (and its associated change operator) within a method.\\ \noindent \ding{228} Some other approaches~\cite{gupta2017deepfix,mesbah2019deepdelta,santos2017finding,santos2018syntax,bhatia2018neurosymbolic} focus on learning to fix defects related to the programming language syntax, some of which only apply to small-scale student programs \cite{santos2018syntax,bhatia2018neurosymbolic}. In contrast, our work targets semantic defects in large-scale real-world programs.\\ \noindent \ding{228} Phoenix~\cite{bavishi2019phoenix} also synthesizes repairs for bugs. However, it uses static analysis as an oracle while we rely on test cases. \iffalse \vspace{1mm} \noindent{\bf Generate-and-Validate APR.} Traditional G\&V APR can be divided into search-based techniques and semantic-based techniques~\cite{le2019automated}. Semantic-based techniques synthesize a patch directly using semantic information via symbolic execution and constraint solving~\cite{xiong2017precise,xuan2017nopol,durieux2016dynamoth}. Search-based techniques are however more widespread: they search for candidate patches within a predefined space using techniques with randomness such as genetic programming \cite{le2012genprog} and random search~\cite{qi2014strength} or using patterns ~\cite{liu2019tbar,wen2018context}. Our work falls under the latter scheme where we build on code completion as well as some straightforward heuristics to identify donor code for generating patches. \vspace{1mm} \noindent{\bf Code Completion based APR.} Our pipeline (i.e., \textsc{Beep}\xspace + code completion) is aligned with recent research directions in the literature that reduce the program repair problem to a sub-problem of program synthesis~\cite{gulwani2017program}. SketchFix~\cite{hua2018towards} is a representative example of such approaches: it translates faulty programs into {\em sketches}, i.e., programs with ``holes'' to substantially reduce the space of patch candidates that must be tested, thus improving efficiency. We differ from SketchFix in terms of objective: SketchFix aims at reducing the test effort while we seek a very precise fix localization to improve effectiveness of repair. Another difference is that SketchFix relies on spectrum-based fault localization and then uses pre-defined templates to create holes in programs, while our approach consists in predicting which fine-grained buggy elements to modify in order to create the holes. Finally, SketchFix relies on SMT solvers to drive the synthesis while we postulate that machine learning can be leveraged towards synthesizing parts of programs. \fi \section{Conclusion} \label{sec:conc} We tackle the ambition of implementing fix localization as the fine-grained identification of buggy code elements. Our \textsc{Beep}\xspace neural network-based architecture can accurately predict buggy tokens and the required change operator. It can thus save great efforts for manual debugging. We also assessed two intuitive repair pipelines with \textsc{Beep}\xspace, where the identified buggy code elements are considered as missing and, thus, must be replaced via using either a code completion engine or a set of code search heuristics. We explore the bug fixing performance of the proposed pipelines on bugs across several benchmarks. Results reveal that all patches generated by the two pipelines are found to be correct. Hence, program repair built on top of fine-grained fix localization offers a promising perspective to address the long-standing challenge of overfitting in automated program repair. \noindent {\bf Artefacts:} All data and source code in the study are publicly available at: \begin{center} {\bf \url{http://doi.org/10.5281/zenodo.4717352}}. \end{center} \section*{Acknowledgements}{ \bibliographystyle{ACM-Reference-Format}
{'timestamp': '2021-11-16T02:33:51', 'yymm': '2111', 'arxiv_id': '2111.07739', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07739'}
arxiv
\section{Introduction} \label{sec:intro} \begin{figure*} \centering \includegraphics[width=\textwidth]{fig1.png} \caption{Architecture of the proposed Spectral Window Unit. (a) The input raw data is processed by a spectral attention module that extracts stable principal patterns of the feature dimension while encodes long-range time-dependency. (b) Local \textsc{UFGConv} embeds topological information of sliced subgraphs to node representations, which are sent to predictors for forecasting tasks.} \label{fig:architecture} \end{figure*} Dynamic graphs appear in many scenarios, such as transportation \cite{li2018diffusion}, pandemic spread \cite{panagopoulos2020transfer}, climate change \cite{cachay2021graph}, social network \cite{rossi2020temporal}, complex physics system \cite{sanchezgonzalez2020learning}, biology \cite{Gainza606202}. Learning dynamic graphs, however, is a challenging task where node features and graph structures evolve over time. The graph property requires being dynamically predicted, which needs a model to capture both time-dependent features and time-varying structures of a graph. There are a few pioneering works on dynamic graph representation learning \citep{rossi2020temporal,xu2020inductive,kumar2019predicting}. Existing models usually embed sequential graph topology then feed into recurrent networks, similar to predicting on conventional time-series data. While the idea is intuitive and easy to follow, such a design can hardly generalize to continuous graphs. The embedding step happens on graph slices at each point of timer shift, where node-by-node long-short term memory is impossible to preserve. Instead, the temporal graph network (\textsc{TGN}) \cite{rossi2020temporal} proposes to leverage a memory module that encodes previous records to the latest events. The event states are concatenated for describing node dynamics within a small time window. Nevertheless, this module has trouble in viewing the holistic graph evolving. The memory unit, e.g., gated recurrent unit (GRU), that the model relies on allows long-term interaction in a most implicitly way. Within the black box, there is no way to control or investigate the preserved message. Alternatively, self-attention \citep{vaswani2017attention} is a classic tool that improves the long-range memory for sequential data. In particular, it learns pair-wise similarity scores of the entire range of interest. This method preserves maximum dependency within a large window so that the memory is no longer a problem. However, for the cost of comprehensiveness, its complexity easily explodes when the timestamp grows rapidly. This work proposes an effortless mechanism, where we show randomized SVD plus MLP play a similar role as a transformer \cite{dosovitskiy2020vit,vaswani2017attention} for dynamic data. SVD finds the pivotal parts of the temporal node information by multiplying a higher-order power of the feature matrix, which is analogous to the classical attention where the principal feature is learned by a linear neural layer. In correspondence, SVD scales temporal features by weighting different components in its decomposition. The main patterns of transformed features are highlighted with a similarity measure from both the time dimension and node feature dimension. We thus call this procedure a \emph{spectral attention} mechanism. Moreover, the framelet graph convolution \citep{zheng2021framelets} provides sufficient scalability via its multilevel representation of the structured data and characterizes the non-Euclidean geometry of the graph data in evolutionary learning. Both the spectral attention and framelet convolution are implemented in the fast algorithms with a much-reduced number of model parameters as compared to the classical schemes. The spectral attention and framelet convolution define a new computational unit for distilling information from dynamic graph data, which we call \emph{Spectral Window Unit}. It takes account of the three dimensions of time, node and structure features simultaneously, and it exploits the long-term evolution behavior of time-varying data. The fusion effect of three distinct dimensions that enables the effective extraction of temporal information is stimulated in the spectral domain under the transforms of SVD and framelets. The rest of the paper is arranged as follows. Section~\ref{sec:relatedWork} reviews previous works that are closely related to our work. Section~\ref{sec:attnSVD} and Section~\ref{sec:GNN} presents the key components for temporal feature and structure embedding. In particular, we revisit the inefficient attention mechanism and identify an alternative spectral transform based on randomized SVD for potential improvement. Section~\ref{sec:model} details our proposed framework for dynamic graph processing. The model's empirical performance is reported in Section~\ref{sec:experiment} on inductive and transductive link prediction tasks, following extensive ablation study and computational efficiency analysis. \section{Related work} \label{sec:relatedWork} This section reviews previous research that is mostly relevant to our work, which are graph representation learning and dynamic inference of sequential data. \subsection{Graph Structure Embedding} GNNs have seen a surge in interest and popularity recently. It has also shown great success in dealing with irregular graph-structured data that traditional deep learning methods such as CNNs fail to manage. The main factor that contributes to its success is that GNNs learn the structure pattern of graphs while CNNs can only handle regular grid-like inputs. Common to most GNNs and their variants is the graph embedding through the aggregation of neighbor nodes (no matter in vertex domain or spectral domain after a certain transform) in a way of message passing \citep{gilmer2017neural,bronstein2017geometric,wu2020comprehensive}. Graph convolution is a key ingredient for graph embedding for node aggregation as similar to the convolution of pixels in CNNs. Convolution operating on vertex or nodes \citep{hamilton2017inductive, xu2018powerful} and convolutions on the pseudo-coordinate system that are mapped from nodes through a transformation (typically Fourier) \citep{bruna2013spectral}, correspond to spatial-based methods and spectral-based methods, respectively. Due to its intuitive characteristics of spatial-based methods which can directly generalize the CNNs to graph data with convolution on neighbors, most GNNs fall into the category of spatial-based methods \citep{atwood2016diffusion,velivckovic2017graph,monti2017geometric,huang2018adaptive,zhang2018end,li2018deeper,ying2018hierarchical,liu2019geniepath,xu2018powerful}. Many other spatial methods broadly follow the message passing scheme with different neighborhood aggregation strategies, but they are developed empirically being limiting theoretical understanding. In contrast, spectral-based graph convolutions \citep{bruna2013spectral,henaff2015deep,defferrard2016convolutional,levie2018cayleynets,zhao2021wgcn,xu2018graph,li2020fast,zheng2020decimated,zheng2020mathnet,zheng2021framelets} convert the raw signal or features in the vertex domain into the frequency domain. Spectral-based methods have already been proved to have a solid mathematical foundation in graph signal processing \citep{shuman2013emerging}, and the vastly equipped multi-scale or multi-resolution views push them to a more scalable solution of graph embedding. Versatile Fourier\citep{defferrard2016convolutional,kipf2016semi,henaff2015deep}, wavelet transforms\citep{zhao2021wgcn} and framelets\citep{zheng2021framelets} have also shown their capabilities in graph representation learning. Of these transforms, Fourier transforms is particularly one of the most popular ones and the work in \citep{lee2021fnet} gave a detailed review of how Fourier Transform enhances neural networks. In addition, with fast transforms being available in computing strategy, a big concern related to efficiency is well resolved. \subsection{Temporal Encoding of Dynamic Graphs} Recurrent neural networks (RNNs) are considered exceptionally successful for sequential data modelling, such as text, video, and speech \citep{graves2012sequence,graves2013speech,shahroudnejad2021survey}. In particular, Long Short Term Memory (LSTM) \citep{hochreiter1997long} and Gated Recurrent Unit (GRU) \cite{cho2014properties} gains great popularity in application. Compared to Vanilla RNN, they leverage a gate system to extract memory information, so that memorizing long-range dependency of sequential data becomes possible. Though, it is difficult to interpret their internal behaviors due to the complex network architecture \citep{chung2014empirical}. Also, the sequential data encoding prevents recurrent networks from efficiently capturing temporal dependencies. Instead, the Transformer network \citep{vaswani2017attention} designs an encoder-decoder architecture with the self-attention mechanism, so as to allow parallel processing on sequential tokens. The self-attention mechanism have achieved state-of-the-art performance across all NLP tasks \citep{vaswani2017attention,kumar2016ask} and even some image tasks \citep{dosovitskiy2020vit,yang2016stacked}. For dynamic GNNs, it is critical to consolidate the features along the temporal dimension. Dynamic graphs consist of discrete and continuous two types according to whether they have the exact temporal information \citep{skardinga2021foundations}. Recent advances and success in static graphs encourage researchers and enable further exploration in the direction of dynamic graphs. Nevertheless, it is still not recently until several approaches \citep{nguyen2018continuous,li2018deep,goyal2018dyngem,trivedi2018representation} were proposed due to the challenges of modeling the temporal dynamics. In general, a dynamic graph neural network could be thought of as a combination of static GNNs and time series models which typically come in the form of an RNN \citep{seo2018structured,manessi2020dynamic,narayan2018learning}. The first DGNN was introduced by Seo et al. \citep{seo2018structured} as a discrete DGNN and Know-Evolve \citep{trivedi2017know} was the first continuous model. JODIE \citep{kumar2019predicting} employed a coupled RNN model to learn the embeddings of the user/item. The work in \citep{sankar2020dysat} learns the node representations through two joint self-attention along both dimensions of graph neighborhood and temporal dynamics. The work in \citep{pareja2020evolvegcn} was the first to use RNN to regulate the GCN model, which means to adapt the GCN model along the temporal dimension at every time step rather than feeding the node embeddings learned from GCNs into an RNN. TGAT \citep{xu2020inductive} is notable as the first to consider time-feature interactions. Then Rossi et al. \cite{rossi2020temporal} presented a more generic framework for any dynamic graphs represented as a sequence of time events with a memory module added in comparison to \citep{xu2020inductive} to enable the short-term memory enhancement. \section{Temporal Message Encoding} \label{sec:attnSVD} This section discusses the efficiency issue of scalable sequential feature embedding. The self-attention mechanism is first analyzed with its inevitable cost, following the power method-based randomized SVD that compacts an efficient version of the transformer. \subsection{Linear Self-Attention and its Inefficiency} We start from a simple linear attention without softmax activation \cite{cao2021transformer}. The attention for a given signal ${\bm{X}}\in\mathbb{R}^{n\times d}$ reads \begin{align} \label{func:attn} &{\rm attn}({\bm{X}}) := ({\bm{Q}}{\bm{K}}^{\top}{\bm{V}})/n, \\ \text{where } &{\bm{Q}}:={\bm{X}}{\bm{W}}_Q, {\bm{K}}:={\bm{X}}{\bm{W}}_K,{\bm{V}}:={\bm{X}}{\bm{W}}_V. \notag \end{align} The three square matrices ${\bm{Q}}$ (query), ${\bm{K}}$ (key) and ${\bm{V}}$ (value) contain learned basis functions, and they have an identical size of $d\times d$. As $d$ is typically smaller than the sample size $n$, this helps save the learning cost of algorithms, i.e., the number of parameters to approximate. The local attention applies trainable non-batch-based normalization on them. Alternatively, efficient attention \citep{shen2021efficient} leverages layer normalization out of the attention function. For now, we neglect this normalization operator as well as the scaler $n$ for simplicity, but the same intrinsic idea holds for both scenarios. Rewrite (\ref{func:attn}) with respect to ${\bm{X}}$, we have \begin{align} \label{func:attn2} {\rm attn}({\bm{X}}) = {\bm{X}}{\bm{W}}_Q{\bm{W}}_K^{\top}{\bm{X}}^{\top}{\bm{X}}{\bm{W}}_V. \end{align} This simple powerful module facilitates many applications in complicated data processing and analysis domains. Though, the compromised computational efficiency remains unsolved. The propagation of ${\bm{Q}}{\bm{K}}^{\top}$ ${\bm{X}}{\bm{W}}_Q{\bm{W}}_K^{\top}{\bm{X}}^{\top}$ requires an expensive matrix multiplication at $n\times n$. The computational cost explodes easily when the sample size grows drastically. To tackle this issue, we first revisit (\ref{func:attn2}) from the view of matrix decomposition and approximation. \subsection{Randomized Power scheme of SVD} Singular value decomposition (SVD) forms a unitary transform on the raw data signal \citep{bertero2020introduction}. A matrix ${\bm{X}}\in\mathbb{R}^{n\times d}$ ($n>d$) is factorized into ${\bm{U}}\Sigma{\bm{V}}^{\top}$, where ${\bm{U}}\in\mathbb{R}^{n\times n}$ and ${\bm{V}}\in\mathbb{R}^{d\times d}$ are two orthonormal bases that span the row and column space of ${\bm{X}}$. The raw matrix ${\bm{X}}$ can be projected to some spectral domain by ${\bm{U}}$ or ${\bm{V}}$. For example, ${\bm{X}}{\bm{V}}$ denotes the spectral coefficients of ${\bm{X}}$ where the projected space takes feature aggregation into account. As ${\bm{X}}{\bm{V}}={\bm{U}}\Sigma$, and ${\bm{U}}\Sigma$ is a scaled row-space orthonormal basis, ${\bm{X}}{\bm{V}}$ can also be interpreted as an orthonormal basis of the raw matrix ${\bm{X}}$. Alternatively, \emph{truncated SVD} \citep{hansen1987truncatedsvd} cuts off small singular value and their corresponding singular vectors so that ${\bm{U}}\in\mathbb{R}^{n\times d'}$ and ${\bm{V}}\in\mathbb{R}^{d\times d'}$ ($d'<d$) with the $d-d'$ most sensitive parts to small changes being removed. The randomized power scheme \citep{halko2011finding} improves the efficiency of SVD. The orthonormal basis of ${\bm{X}}$ is approximated efficiently by the randomized power method with an iterative QR decomposition via the Gram-Schmidt algorithm. Formally, the basis \begin{align} \label{func:QRsvd} {\bm{Q}} = {\bm{A}}{\bm{R}}^{-1} = {\bm{X}}({\bm{X}}^{\top}{\bm{X}})^q{\bm{R}}^{-1}, \end{align} where ${\bm{A}}$ denotes the power-$q$ approximation of ${\bm{X}}$. The ${\bm{R}}$ is an upper triangular matrix determined by column elements of ${\bm{X}}$ and ${\bm{Q}}$. For illustration purposes, we eliminate the random factor $\Omega$ that usually produces dimensionality reduction on ${\bm{Y}}$. Compared to vanilla SVD, $({\bm{X}}^{\top}{\bm{X}})^q{\bm{R}}^{-1}$ serves as an approximator of the column singular vectors ${\bm{V}}$. The closeness of the approximation to the exact solution is controlled by iteration $q$. The more iterations applied, the larger gaps are discovered between different basis vectors, and the smaller the approximation error is involved. \subsection{Linear Attention versus Randomized SVD} We now connect linear attention with randomized SVD. The current SVD approximation in (\ref{func:QRsvd}) involves no learnable scheme, thus it is impossible to adapt the importance of orthonormal basis (or spectral coefficient) with respect to the input data. One simple solution is endowing a linear transformation \begin{align} \label{func:QRsvd2} \widetilde{{\bm{Q}}} = {\bm{Q}}{\bm{W}} = {\bm{X}}({\bm{X}}^{\top}{\bm{X}})^q{\bm{W}}. \end{align} We unite ${\bm{R}}^{-1}$ with the learnable parameter ${\bm{W}}$ to abbreviate the representation. An intuitive explanation of this linear transformation is to rearrange and summarize the principal factors (singular vectors) to the importance of describing entity features. While the QR decomposition ranks the orthonormal basis according to their energy decreasing, this measure of importance might be less practical for many prediction tasks. Thus it is preferred to allow data-driven adjustments on principal components. If we rewrite ${\bm{W}}_Q{\bm{W}}_K^{\top}={\bm{W}}_1$ and ${\bm{W}}_V={\bm{W}}_2$ of (\ref{func:attn2}): \begin{align} \label{func:attn3} {\rm attn}({\bm{X}}) = {\bm{X}}{\bm{W}}_1{\bm{X}}^{\top}{\bm{X}}{\bm{W}}_2. \end{align} Both (\ref{func:QRsvd2}) and (\ref{func:attn3}) share a similar format except for the number of learnable parameter sets and the power scheme. In fact, the linear self-attention in (\ref{func:attn3}) can be considered as a special case of (\ref{func:QRsvd2}) in the sense that the attention mechanism implicitly calculates a $1$-iteration QR approximation of SVD basis. While the power-$1$ approximation is of limited accuracy, attention makes linear adjustments by learnable parameter that approximates ${\bm{W}}_1{\bm{X}}^{\top}{\bm{X}}{\bm{W}}_2 \approx {\bm{X}}({\bm{X}}^{\top}{\bm{X}})^q{\bm{R}}^{-1}{\bm{W}}$. In fact, both ${\bm{W}}_1{\bm{X}}^{\top}{\bm{X}}{\bm{W}}_2$ (or ${\bm{K}}^{\top}{\bm{V}}$) and ${\bm{X}}({\bm{X}}^{\top}{\bm{X}})^q{\bm{R}}^{-1}{\bm{W}}$ serve the same role as a similarity metric of ${\bm{X}}$'s row space. The ${\bm{X}}^{\top}{\bm{X}}$ in a one-step approximation of QR iteration aggregates row-wise variation and summarize a low-rank covariance matrix of the feature space. The subsequent power iterations and adjustments on ${\bm{R}}$ only widen the gap between different modes so that more resources can be focused on large modes, and the smallest modes (which are usually considered as noise or disturbance of truth) are eventually removed. The same procedure on attention, in contrast, is highly dependent on the input value. The learning process is indeed a black-box learning module. While the algorithm is considerably flexible and adaptive to a broad range of scenarios, such advantages are traded with precision and controlling power. The other pain point of the attention mechanism in (\ref{func:attn3}) is the computational expense on large datasets. Consider an extremely long sequence of input ${\bm{X}}_{N}\in\mathbb{R}^{N\times d}$ where $N \gg d$. The attention method have to calculate ${\bm{X}}{\bm{W}}_1{\bm{X}}^{\top} \in \mathbb{R}^{N\times N}$ following another $N\times d$ matrix multiplication. This huge square matrix could result in a great burden on both calculation speed and storage. In comparison, (\ref{func:QRsvd2}) starts from ${\bm{X}}^{\top}{\bm{X}}\in\mathbb{R}^{d\times d}$ that controls the main calculation within an acceptable dimension. While the length of sequential data, such as time-series data, can easily be expanded, this `dimension reduction' trick is important for scalable learning tasks. \section{Graph Topology Embedding} \label{sec:GNN} We now present the two modules with respect to sub-graph topology embedding. The first module is called a memory window that batchrizes the event flow with fixed batch size. The construction of the adjacency matrix relies on the events that happened within this batch, and the features constitute both present and (recent) previous information of the nodes. The second is a graph convolution for topology representation learning. We use a spectral-based method in consideration of scalability. \subsection{Memory Window} \label{sec:tgnWindow} A continuous-time dynamic graph records the temporal evolution by a sequence of events. Instead of treating graph intervals as discrete slices, Temporal Graph Networks (\textsc{TGN}) \cite{rossi2020temporal} practices node embedding by a message-memory encoder. Given an event $e_{i}[t]$ at time $t$ with respect to node $n_i$, we name it a \emph{message} of $n_i$ at time $t$, denoted as ${\rm \mathbf{\mathbf{msg}}}(e_{i}[t])$. In addition, if the node was previously recorded active, we use ${\rm \mathbf{mem}}(e_{i}[:t])$ to represent the past information, or \emph{memory}, of $n_i$ prior to time $t$. The memory module ${\rm \mathbf{mem}}()$ refreshes constantly with the latest messages to capture the dynamic nature of graph interactions. When a new event $e_i[t]$ is recorded, the updated memory at time $t$ is \begin{equation*} {\rm \mathbf{mem}}(e_{i}[t])=f({\rm \mathbf{mem}}(e_{i}[:t]), {\rm \mathbf{msg}}(e_{i}[t])) \end{equation*} with a trainable function $f()$. Depending on when the node $i$ was previously recorded, the last memory can be found before $t-1$. Also it is possible to recall memory from more than one step away. We thus describe $n_i[t]$'s state by its hidden memory $h_i[t]$ at time $t$, which concatenates ${\rm \mathbf{msg}}(e_{i}[t])$ and ${\rm \mathbf{mem}}(e_{i}[:t])$, i.e., \begin{equation} \label{func:msg_mem_encoder_node} h_i(t) = {\rm \mathbf{concat}}({\rm \mathbf{msg}}(e_{i}[t])) \| {\rm \mathbf{mem}}(e_{i}[:t]))). \end{equation} The embedding for an interactive event $e_{ij}(t)$ between two nodes $n_i$ and $n_j$ is similar, which reads \begin{equation}\label{func:msg_mem_encoder_edge} h_i(t) = {\rm \mathbf{concat}}({\rm \mathbf{msg}}(e_{ij}[t]) \| {\rm \mathbf{mem}}(e_{i}[:t]) \| {\rm \mathbf{mem}}(e_{j}[:t])). \end{equation} \subsection{Framelet Graph Transforms} \label{sec:UFGconv} Graph convolution is a key ingredient for graph representation learning. Given an undirected graph ${\mathcal{G}}=({\mathbb{V}},\mathbb{E},{\bm{X}})$ with $N=|{\mathbb{V}}|$ nodes, its edge connection is described by an adjacency matrix ${\bm{A}}\in \mathbb{R}^{N\times N}$ and the $d$-dimensional node feature is stored in ${\bm{X}}\in\mathbb{R}^{N\times d}$. Graph convolution aims at encoding ${\bm{A}},{\bm{X}}$ to a hidden representation ${\bm{H}}$ for prediction tasks. Depending on whether the convolution is conducted on the vertex domain or a transformed domain, typical methods are classified into either spatial or spectral methods. Here we are interested in spectral methods, or more specifically, Frame wavelet (Framelet) methods, where multilevel or multiscale feature allows scalable graph representation learning. We now brief the undecimated Framelet graph convolution (\textsc{UFGConv}) method proposed by \cite{zheng2021framelets}, which leverages fast Framelet decomposition and reconstruction for graph topology embedding. The Framelet convolution defines in a similar manner to any typical spectral graph convolution layer that \begin{equation} {\bm{\theta}}\star {\bm{X}} = {\mathcal{V}} {\rm diag}({\bm{\theta}}) {\mathcal{W}} {\bm{X}}', \end{equation} where ${\bm{X}}'$ is transformed (hidden) feature embedding and ${\bm{\theta}}$ denotes learnable parameters. The ${\mathcal{W}}$ and ${\mathcal{V}}$ denotes the decomposition and reconstruction operators that transform the graph signal between the vertex domain and the Framelet domain. The fast approximation of Framelet coefficients is crucial for an efficient \textsc{UFGConv} algorithm, and we now brief the graph Framelet transforms \citep{dong2017sparse,zheng2021framelets}. Framelet transform divides an input signal to multiple channels by a set of low-pass and high-passes \emph{Framelet bases}. For a specific nodes $p$, its bases at \emph{scale level} $l=1,\ldots,L$ reads \begin{align*} \boldsymbol{\varphi}_{l,p}(v) &= \sum_{\ell=1}^{N} \hat{\alpha}\left(\frac{\lambda_{\ell}}{2^{l}}\right) \overline{{\bm{u}}_{\ell}(p)}{\bm{u}}_{\ell}(v)\\ \boldsymbol{\psi}_{l,p}^k(v) &= \sum_{\ell=1}^{N} \widehat{b^{(k)}}\left(\frac{\lambda_{\ell}}{2^{l}}\right)\overline{{\bm{u}}_{\ell}(p)}{\bm{u}}_{\ell}(v). \end{align*} We call $\Psi=\{\alpha;\beta^{(1)},\dots,\beta^{(K)}\}$ a set of \emph{scaling functions}, and it is determined by a filter bank $\mathbf{\eta}:=\{a;b^{(1)},\dots,b^{(K)}\}$. The other component is the eigen-pairs $\{(\lambda,{\bm{u}})\}_{j=1}^{N}$ of the graph Laplacian ${\mathcal{L}}$, which plays a key role for embedding graph topology. The Framelet basis projects input signals to a transformed domain as \emph{Framelet coefficients}. Given a signal ${\bm{x}}$, $\langle\boldsymbol{\varphi}_{l,p},{\bm{x}}\rangle$ and $\langle\boldsymbol{\psi}_{l,p}^k,{\bm{x}}\rangle$ are the corresponding Framelet coefficients for node $p$ at scale $l$. To allow fast approximation of the filter spectral functions, $m$-order Chebyshev polynomials is considered. We denote $m$-order approximation of $\alpha$ and $\{\beta^{(1)},\dots,\beta^{(K)}\}$ by ${\mathcal{T}}^m_0$ and $\{{\mathcal{T}}^m_{k}\}_{k=1}^{K}$. At a given level $L$, the full set of Framelet coefficients ${\mathcal{W}}_{k,1}{\bm{x}}$ reads $$ \begin{cases} {\mathcal{T}}^m_k(2^{-H}{\mathcal{L}}){\bm{x}}, & l=1 \\ {{\mathcal{T}}^m_k}(2^{-H -l}{\mathcal{L}}){{\mathcal{T}}^m_0}(2^{-H-l+1}{\mathcal{L}}){\cdots{\mathcal{T}}^m_0}(2^{-H}{\mathcal{L}}){\bm{x}}, & \text{otherwise}, \end{cases} $$ where the dilation scale $H$ satisfies $\lambda_{\max} \leq 2^H\pi$. \section{Spectral Window Unit} \label{sec:model} This section presents the proposed Spectral Window Unit (\textsc{SWINIT}) model for dynamic graph representation learning. We divide the learning task into two steps. First, a \emph{spectral attention} module is leveraged for efficient temporal feature encoding. The new representations are then batchrized and sent to \textsc{UFGConv} for topological encoding. The particular designs are detailed below. Algorithm~\ref{alg:SWINIT} summarizes the complete training process with the model complexity analysis be provided. The model architecture is briefed in Figure~\ref{fig:architecture}. In addition, Figure~\ref{fig:SVD} and Figure~\ref{fig:UFG} give detailed demonstrations for each portion of the proposed model for better understanding. \subsection{Temporal Feature Encoding} \label{sec:svdEmbedding} \begin{figure} \centering \input{tikz_SVD} \caption{A dissection of Randomized SVD-oriented spectral message encoder on ${\bm{X}}$. Section~\ref{sec:svdEmbedding} discusses the two interpretations of this embedding in detail.} \label{fig:SVD} \end{figure} Our method embeds long-range time-dependency by a randomized SVD-based spectral attention mechanism, which implements a similar function to the classic attention design but provides additional scalability and reliability, as analyzed in Section~\ref{sec:attnSVD}. This section gives an intuitive justification for the feasibility of dynamic events processing by spectral attention. Consider a raw matrix ${\bm{X}}\in\mathbb{R}^{N\times d}$ that records sequential events of a period. Rather than directly training prediction models on ${\bm{X}}$, it is desired to first find a low-dimension projection $\widetilde{{\bm{X}}}$ to some spectral domain that. The $\widetilde{{\bm{X}}}$ is believed better summarize the principal patterns of the input space and is immune to a minor disturbance. Consequently, they are easier to train with small chunks later on. To this end, we propose to encode the raw input with a randomized power scheme of truncated SVD. Similar to the self-attention mechanism, our spectral encoder reweights the input with their similarity score. Moreover, the similarity matrix is updated with explicit rules, so that the learning process is more manageable in comparison to a data-driven black-box approximation. We provide two interpretations to help understand how exactly this spectral attention method summarizes main patterns from both directions of feature and time. \paragraph{Interpretation 1} \textbf{The spectral attention extracts information of feature dimension by $\widetilde{{\bm{X}}} \approx {\bm{X}}{\bm{V}}$}: We know from definition ${\bm{X}}:={\bm{U}}\Sigma{\bm{V}}^{\top}$ that SVD stores factorized features (columns) in ${\bm{V}}$, and the factorized timestamps (rows) in ${\bm{U}}$. The truncated SVD is design especially when the input is of low-rank, or full-rank but with noise. A purified input is transformed by $\widetilde{{\bm{X}}}\approx {\bm{X}}{\bm{V}}\in\mathbb{R}^{N\times d'} (d>d')$. Consequently, the projected samples of $\widetilde{{\bm{X}}}$ from ${\bm{V}}$ finds a new representation by referring most effective feature dimension representations. For example, the $j$th feature of the $i$th transformed sample $\widetilde{{\bm{X}}}_{ij}={\bm{X}}_i{\bm{V}}_j$. The raw ${\bm{X}}_i$ is concreted to a point following the projection rule of the $j$th factorized feature. Similar mappings by the $1, 2, \dots, d'$th factorization of ${\bm{V}}$ converts the raw ${\bm{X}}_i$ to a new space that is mostly representative from the perspective of features. \paragraph{Interpretation 2} \textbf{The spectral attention aggregates information of time dimension by $\tilde{{\bm{X}}} \approx {\bm{X}}({\bm{X}}^{\top}{\bm{X}}){\bm{R}}^{-1}$}: To get the full picture of the information aggregation, let's focus on the simplest case of iteration $q=1$. We already know from Section~\ref{sec:attnSVD} that the ${\bm{X}}^{\top}{\bm{X}}{\bm{R}}^{-1}$ (in green box) is a one-step approximation of ${\bm{V}}$. Here we show how this approximation embeds the long-range time-dependency of the input data. Figure~\ref{fig:SVD} show how the $j$th element of the $j$th row in ${\bm{X}}^{\top}{\bm{X}}$ is calculated by the inner product of the $j$th column vector of ${\bm{X}}$. The calculated $d\times d$ matrix is indeed a covariance matrix that summarizes the column-wise linear relationship of ${\bm{X}}$. In our case, the $j$th column of ${\bm{X}}$ describes the evolution of the $j$th feature over the entire timeline, and the covariance matrix gives a linear similarity measure of all features based on their temporal trace. If we project the raw matrix ${\bm{X}}$ by this similarity matrix, the new representation will include the temporal correlation of all time. The same interpretation holds after $q$ iterations. While the algorithm concentrates high energies on more expressive modes and takes some linear adjustments (via ${\bm{R}}^{-1}$), the fundamental format of the covariance matrix ${\bm{X}}^{\top}{\bm{X}}$ is never changed. \subsection{Structured Node Embedding} \begin{figure} \centering \input{tikz_UFG} \caption{Inheritance and renewal of the global spectral coefficient $\Theta$. The first row indicates the alternation of the global $\Theta$ from $t-1$ to $t+1$. The second row showcases the local $\theta$ updates by \textsc{UFGConv} of a graph at step $t$ and $t+1$.} \label{fig:UFG} \end{figure} So far the event-based data have been projected to a spectral domain of the feature dimension. While the long-term dependencies are well-encoded during this process, the short-term memory requires further enhancement. In addition, the intrinsic structural information is waiting for embedding. To this end, a memory window gets involved to divide multiple batches of subgraphs. This operation allows zooming into a small window of events and extracting critical messages. The current state of an underlying node is also closely connected to recent messages of the same entity (node) from previous states. To include this part of the information, which we call memories, an aggregation is employed for assembling. The importance of short-term memorization has been verified by \cite{rossi2020temporal}. We adopt a similar idea for this slicing and aggregation by following the procedures introduced in Section~\ref{sec:tgnWindow}. Now that the graph sequence is prepared, the next step is graph convolution for structure embedding. We employ \textsc{UFGConv}, a special type of spectral-based graph convolution, that allows potential scalability over multi-level graph signal processing. In classic graph-level representation learning tasks, \textsc{UFGConv} can easily parallel to multiple graphs that are independent of each other. For sequential graphs, the time-dependency is required to be implanted by a properly designed intra-connection on transform parameters $\theta$s. Inspired by the fact that the parameters are stored on a diagonal line and they scale the node-wise Framelet coefficients, we link the initialization of current Framelet coefficients with their best estimation of the last record, i.e., \begin{align*} \theta_i[t]^{(0)} = \theta_i[:t]^{(n)} \end{align*} for the $i$th $\theta$ value with respect to node $i$ at time $t$. Here $0$ denotes the first iteration (or initial value) of $\theta$ and $n$ is the estimated $\theta$ after $n$ propagation. The full set of $\theta$ is stored in a global $\Theta$, so that every time when step into a new \textsc{UFGConv}, the algorithm extracts previous $\theta$s from $\Theta$. The updated parameters of the training procedure, while being used for prediction, are also restored to $\Theta$ for next calling. Figure~\ref{fig:UFG} gives a simple demonstration. Consider a small graph with $5$ nodes. The global $\Theta$ has $5$ parameters to tune. The subgraph at batch $t$ contains the first $3$ of the $5$ nodes. When training the \textsc{UFGConv} layer, the model inherits the best estimation of $\{\theta_1,\theta_2,\theta_3\}$ before $t$ as initialization. The optimized model is deployed for further prediction tasks. Meanwhile, $\Theta$ replaces $\{\theta_1,\theta_2,\theta_3\}$ by the three updated parameters. This process is conducted repetitively along with the training procedure until all subgraphs are trained and evaluated. \begin{algorithm}[t] \hsize=\textwidth \SetKwData{step}{Step} \SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output} \BlankLine \Input{raw sequential data ${\bm{X}}$} \Output{label prediction ${\bm{Y}}$} Initialization: global $\Theta$\\ \textcolor{RoyalBlue}{\bf Randomized SVD ${\bm{X}}{\bm{V}}\leftarrow{\bm{X}}({\bm{X}}^{\top}{\bm{X}})^q{\bm{R}}^{-1}$};\\ \For{batch $i \leftarrow 1$ \KwTo $N-2$}{ \bf $h_i[t]\leftarrow {\rm \textbf{msg}}(e_{i}[t])\|{\rm \textbf{mem}}(e_{i}[:t])$;\\ \textcolor{RoyalBlue}{${\mathcal{G}}_i\leftarrow({\bm{A}}_i,{\bm{X}}_i\leftarrow\text{\textbf{FC}}(h_i[t])$)};\\ \textcolor{RoyalBlue}{$H_i\leftarrow\textsc{\textbf{ UFGConv}}({\bm{A}}_i,{\bm{X}}_i,\theta_i)$};\\ ${\bm{Y}}_i\leftarrow\text{Predictor}(H_i)$;\\ $\Theta_i\leftarrow\theta_i$;\\ ${\bm{Y}}_{\text{i,val}}\leftarrow\text{Predictor}(H_{i+1})$;\\ ${\bm{Y}}_{\text{i,test}}\leftarrow\text{Predictor}(H_{i+2})$;\\ Update: score(${\bm{Y}}_{\text{val}}$), score(${\bm{Y}}_{\text{test}}$). } \caption{\textcolor{RoyalBlue}{\bf \textsc{SWINIT}: Spectral Window Unit}} \label{alg:SWINIT} \end{algorithm} \subsection{Complexity Analysis} As mentioned in Section~\ref{sec:attnSVD}, our design of spectral attention is efficient with a small time and space complexity, as we analyze as follows. We analyze the computational complexity for the SWINIT in Algorithm~\ref{alg:SWINIT} by estimating the cost for the three main computational units: randomized SVD for the entire training data, and MLP and UFGConv (framelet convolution) for batched graphs. \paragraph{Time complexity} For a dynamic graph with $N$ events (edges) and $d$ edge features, the computational cost for randomized SVD is ${\mathcal{O}}(Nd\log(d))$ \cite{halko2011finding}. The MLP has cost ${\mathcal{O}}(N)$ in total. For all $m$ batches, the framelet convolution (UFGConv) has the complexity of ${\mathcal{O}}(\sum_{i=1}^m N_i S_i \log_2(\lambda_i/\pi) F)$ where $N_i, S_i$ are the number of edges and sparsity of the $i$th batched graph, $\lambda_i$ is the largest eigenvalue of the corresponding graph Laplacian \cite{zheng2021framelets}, and $F$ is the number of the node features. In practice, the $N_i$ for each batched graph can be set as $N/m$, and we suppose $S_i$ and $\lambda_i$ are bounded by constants. The total computational cost of \textsc{SWINIT} is ${\mathcal{O}}\left(N(d\log(d)+F)\right)$. \paragraph{Space complexity} For the randomized SVD, the memory cost is ${\mathcal{O}}(Nd)$. The MLP with $l+1$ fully connected layers needs memory ${\mathcal{O}}(n_1\sqrt{N/m}+n_1\times m_1+\cdots+n_l\times m_{l})$. Suppose each layer has the same number of hidden neurons $n$, then MLP has the space complexity ${\mathcal{O}}(n\sqrt{N/m}+n^2l)$. The memory cost of framelet convolution is ${\mathcal{O}}(NF)$. Then, the total space complexity of \textsc{SWINIT} is ${\mathcal{O}}\left(N(d+F)+n\sqrt{N/m}+n^2l\right)$. \paragraph{Parameter number} The trainable network parameters appear mainly in MLP and UFGConv. As similar to space complexity analysis, \textsc{SWINIT} has the ${\mathcal{O}}\left(n\sqrt{N/m}+n^2l+NF\right)$ parameters in total. \section{Numerical Examples} \label{sec:experiment} \begin{table*}[t] \caption{Performance of link prediction over 10 repetitions} \label{tab:linkPrediction} \begin{center} \resizebox{0.9\linewidth}{!}{ \begin{tabular}{llrrrrrrr} \toprule && & \multicolumn{2}{c}{\textbf{Wikipedia}} & \multicolumn{2}{c}{\textbf{Reddit}} & \multicolumn{2}{c}{\textbf{MOOC}}\\ \cmidrule(lr){4-5}\cmidrule(lr){6-7}\cmidrule(lr){8-9} &\textbf{Model} & \# parameters & precision & ROC-AUC & precision & ROC-AUC & precision & ROC-AUC \\ \midrule \multirow{5}{*}{\rotatebox[origin=c]{90}{transductive}} \hspace{2mm} &\textsc{DyRep}\citep{trivedi2019dyrep} & $920\times 10^{3}$ & $94.67${\scriptsize $\pm0.25$} & $94.26${\scriptsize $\pm0.24$} & $96.51${\scriptsize $\pm0.59$} & $96.64${\scriptsize $\pm0.48$} & $79.84${\scriptsize $\pm0.38$}& $81.92${\scriptsize $\pm0.21$} \\ &\textsc{JODIE-rnn}\citep{kumar2019predicting} & \textcolor{violet}{\bm{$209\times 10^{3}$}} & $93.94${\scriptsize $\pm2.50$} & $94.44${\scriptsize $\pm1.42$} & $97.12${\scriptsize $\pm0.57$} & $97.59${\scriptsize $\pm0.27$} & $76.68${\scriptsize $\pm0.02$}&$81.40${\scriptsize $\pm0.02$} \\ &\textsc{JODIE-gru}\citep{kumar2019predicting} & \bm{$324 \times 10^{3}$} & $96.38${\scriptsize $\pm0.50$} & \textcolor{violet}{\bm{$96.75${\scriptsize $\pm0.19$}}} & $96.84${\scriptsize $\pm0.39$} & $97.33${\scriptsize $\pm0.25$} &$80.29${\scriptsize $\pm0.09$} & \bm{$84.88${\scriptsize $\pm0.30$}} \\ &\textsc{TGN-gru}\citep{rossi2020temporal} & $1,217\times 10^{3}$ & \bm{$96.73${\scriptsize $\pm0.09$}} & $96.45${\scriptsize $\pm0.11$} & \textcolor{violet}{\bm{$98.63${\scriptsize $\pm0.06$}}} & \textcolor{violet}{\bm{$98.61${\scriptsize $\pm0.03$}}} & \textcolor{violet}{\bm{$83.18${\scriptsize $\pm0.10$}}} & $83.20${\scriptsize $\pm0.35$}\\ &\textsc{SWINIT-mlp} (ours) & \textcolor{red}{\bm{$170\times 10^{3}$}} & \textcolor{violet}{\bm{$97.02${\scriptsize $\pm0.06$}}} & \bm{$96.51${\scriptsize $\pm0.08$}} & \bm{$98.19${\scriptsize $\pm0.05$}} & \bm{$98.15${\scriptsize $\pm0.06$}} & \bm{$82.40${\scriptsize $\pm0.24$}} &\textcolor{violet}{\bm{$85.55${\scriptsize $\pm0.17$}}} \\ &\textsc{SWINIT-gru} (ours) &$376\times 10^{3}$&\textcolor{red}{\bm{$97.44${\scriptsize $\pm0.05$}}} & \textcolor{red}{\bm{$97.15${\scriptsize $\pm0.06$}}}& \textcolor{red}{\bm{$98.69${\scriptsize $\pm0.09$}}} & \textcolor{red}{\bm{$98.66${\scriptsize $\pm0.12$}}}&\textcolor{red}{\bm{$84.50${\scriptsize $\pm0.10$}}} &\textcolor{red}{\bm{$86.88${\scriptsize $\pm0.09$}}}\\ \midrule \multirow{5}{*}{\rotatebox[origin=c]{90}{inductive}} \hspace{2mm} &\textsc{DyRep}\citep{trivedi2019dyrep} & $920\times 10^{3}$ & $92.09${\scriptsize $\pm0.28$} & $91.22${\scriptsize $\pm0.26$} & $96.07${\scriptsize $\pm0.34$} & $96.03${\scriptsize $\pm0.28$} & $79.64${\scriptsize $\pm0.12$}& $82.34${\scriptsize $\pm0.32$} \\ &\textsc{JODIE-rnn}\citep{kumar2019predicting} & \textcolor{violet}{\bm{$209\times 10^{3}$}}& $92.92${\scriptsize $\pm1.07$} & $92.56${\scriptsize $\pm0.87$} & $93.94${\scriptsize $\pm1.53$} & $95.08${\scriptsize $\pm0.70$} & $77.17${\scriptsize $\pm0.02$}&$81.77${\scriptsize $\pm0.01$} \\ &\textsc{JODIE-gru}\citep{kumar2019predicting} & $324 \times 10^{3}$& \textcolor{violet}{\bm{$94.93${\scriptsize $\pm0.15$}}} & \textcolor{violet}{\bm{$95.08${\scriptsize $\pm0.70$}}} & $92.90${\scriptsize $\pm0.03$} &$95.14${\scriptsize $\pm0.07$}&$77.82${\scriptsize $\pm0.17$} & \bm{$82.90${\scriptsize $\pm0.60$}} \\ &\textsc{TGN-gru}\citep{rossi2020temporal} & $1,217\times 10^{3}$& \bm{$94.37${\scriptsize $\pm0.23$}} & \bm{$93.83${\scriptsize $\pm0.27$}} & \textcolor{violet}{\bm{$97.38${\scriptsize $\pm0.07$}}} & \textcolor{violet}{\bm{$97.33${\scriptsize $\pm0.11$}}} & \bm{$81.75${\scriptsize $\pm0.24$}}& $82.83${\scriptsize $\pm0.18$}\\ &\textsc{SWINIT-mlp} (ours) & \textcolor{red}{\bm{$170\times 10^{3}$}} & $94.27${\scriptsize $\pm0.05$} & $93.28${\scriptsize $\pm0.05$} & \textcolor{red}{\bm{$97.49${\scriptsize $\pm0.01$}}} & \textcolor{red}{\bm{$97.34${\scriptsize $\pm0.02$}}} & \textcolor{red}{\bm{$82.54${\scriptsize $\pm0.08$}}}& \textcolor{red}{\bm{$85.23${\scriptsize $\pm0.09$}}}\\ &\textsc{SWINIT-gru} (ours) & \bm{$376\times 10^{3}$} &\textcolor{red}{\bm{$96.60${\scriptsize $\pm0.01$}}} & \textcolor{red}{\bm{$95.70${\scriptsize $\pm0.02$}}}& \bm{$97.47${\scriptsize $\pm0.05$}}& \bm{$97.10${\scriptsize $\pm0.09$}}& \textcolor{violet}{\bm{$82.35${\scriptsize $\pm0.06$}}} & \textcolor{violet}{\bm{$83.67${\scriptsize $\pm0.06$}}}\\ \bottomrule\\[-2.5mm] \multicolumn{9}{l}{$\dagger$ The top three are highlighted by \textbf{\textcolor{red}{First}}, \textbf{\textcolor{violet}{Second}}, \textbf{Third}.} \end{tabular} } \end{center} \end{table*} \begin{table}[t] \caption{Comparison of computational complexity and training speed.} \label{tab:complexity} \begin{center} \resizebox{\linewidth}{!}{ \begin{tabular}{lrrr} \toprule \textbf{Model} & \textbf{Wikipedia} & \textbf{Reddit} & \textbf{MOOC}\\ \midrule \textsc{DyRep}\citep{trivedi2019dyrep} & $20.1$s {\scriptsize $\pm0.6$s} & $139.3$s {\scriptsize $\pm0.1$s} & $78.34$s {\scriptsize $\pm0.6$s} \\ \textsc{JODIE-rnn}\citep{kumar2019predicting} & $17.4$s {\scriptsize $\pm2.0$s} & \bm{$121.8$}s{\scriptsize $\pm0.3$s} & $62.64$s {\scriptsize $\pm0.1$s} \\ \textsc{JODIE-gru}\citep{kumar2019predicting} & \bm{$16.9$}s {\scriptsize $\pm1.1$s} & $131.6$s {\scriptsize $\pm 1.5$s} & \bm{$58.82$}s {\scriptsize $\pm 2.2$s} \\ \textsc{TGN-gru} \citep{rossi2020temporal} & $24.9$s {\scriptsize $\pm 0.3$s} & $128.1$s {\scriptsize $\pm2.2$s} & $78.11$s {\scriptsize $\pm 0.7$s} \\ \textsc{SWINIT-mlp} (ours) & \textcolor{red}{\bm{$9.87$}s {\scriptsize $\pm0.1$s}} & \textcolor{red}{\bm{$63.3$}s {\scriptsize $\pm1.1$s}} & \textcolor{red}{\bm{$38.41$}s {\scriptsize $\pm0.5$s}} \\ \textsc{SWINIT-gru} (ours) &\textcolor{violet}{\bm{$12.5$}s {\scriptsize $\pm0.3$s}} & \textcolor{violet}{\bm{$83.6$}s {\scriptsize $\pm0.1$s}} & \textcolor{violet}{\bm{$49.20$}s {\scriptsize $\pm0.1$s}} \\ \bottomrule\\[-2.5mm] \end{tabular} } \end{center} \end{table} \begin{table}[t] \caption{ROC-AUC of node classification over 10 repetitions.} \label{tab:nodeClassification} \begin{center} \resizebox{0.95\linewidth}{!}{ \begin{tabular}{lrrr} \toprule \textbf{Model} & \textbf{Wikipedia} & \textbf{Reddit} & \textbf{MOOC} \\ \midrule \textsc{DyRep}\citep{trivedi2019dyrep} & $84.59${\scriptsize $\pm2.21$}&$62.91${\scriptsize $\pm2.40$} & $69.86${\scriptsize $\pm0.02$} \\ \textsc{JODIE-rnn}\citep{kumar2019predicting} & $85.38${\scriptsize $\pm0.08$}&$61.68${\scriptsize $\pm0.01$} &$66.82${\scriptsize $\pm0.05$} \\ \textsc{JODIE-gru}\citep{kumar2019predicting} &$87.90${\scriptsize $\pm0.09$} & \bm{$64.30${\scriptsize $\pm0.21$}}& \bm{$70.23${\scriptsize $\pm0.09$}}\\ \textsc{TGN-gru} \citep{rossi2020temporal} &\textcolor{violet}{\bm{$88.95${\scriptsize $\pm0.07$}}}& $61.49${\scriptsize $\pm0.01$} & \textcolor{violet}{\bm{$70.32${\scriptsize $\pm0.13$}}} \\ \textsc{SWINIT-mlp} (ours) &\bm{$88.37${\scriptsize $\pm0.03$}} &\textcolor{violet}{\bm{$64.94${\scriptsize $\pm0.07$}}} & $69.52${\scriptsize $\pm0.08$} \\ \textsc{SWINIT-gru} (ours) &\textcolor{red}{\bm{$90.32${\scriptsize $\pm0.05$}}} & \textcolor{red}{\bm{$65.28${\scriptsize $\pm0.05$}}}& \textcolor{red}{\bm{$71.08${\scriptsize $\pm0.02$}}}\\ \bottomrule\\[-2.5mm] \end{tabular} } \end{center} \end{table} This section reports the performance of \textsc{SWINIT} in comparison to three baseline models and five ablation studies. The main experiment tests on two link prediction tasks with both inductive and transductive learning tasks. The best reported performance are tuned with PyTorch on NVIDIA\textsuperscript{\textregistered} Tesla V100 GPU with 5,120 CUDA cores and 16GB HBM2 mounted on an HPC cluster. Experimental code in PyTorch can be found at \url{https://github.com/bzho3923/GNN\_SWINIT}. \subsection{Experimental Protocol} \subsubsection{Dataset} Our experiments are conducted on three bipartite graph datasets: \textbf{Wikipedia}, \textbf{Reddit} and \textbf{MOOC} \citep{kumar2019predicting,liyanagunawardena2013moocs}. \begin{itemize} \item \textbf{Wikipedia} has users and Wikipedia page as the two sets of nodes. An edge is recorded when a user edits a page. The dataset selects the $1,000$ most edited pages and frequent editing users who made at least $5$ edits. The dataset contains $9,227$ nodes and $157,474$ edges in total, and each event is described by $172$ features. \item \textbf{Reddit} divides two sets of nodes as users and subreddits (communities). An interaction occurs when a user posts a message to a subreddit. The datasets samples $1,000$ most active subreddits as nodes along with the $10,000$ most active users. In total, the dataset contains $11,000$ nodes and $672,447$ edges. All events are recorded as $172$ edge features by the LIWC categories \citep{pennebaker2001linguistic} by the text of each post. \item \textbf{MOOC} records students and courses of the ``Massive Open Online Course" learning platform. An interaction occurs when a student enrolls in the course. The dataset consists of $7,047$ students, $97$ courses and $411,749$ interactions. Specifically, $4,066$ state changes are recorded implying action that a student drops out of a course. \end{itemize} \subsubsection{Learning Tasks} We conduct prediction tasks of the three datasets on link prediction and node classification. In the link prediction tasks, the goal is to predict the probability of an edge occurring between two nodes at a given time. To conduct the prediction, a simple MLP decoder is concatenated after the node embedding module, mapping from the concatenation of the node pair's embeddings to the probability of the edge. Unlike tabular data where entities are independent of each other, graph nodes are inter-connected. Different graph data splitting strategies can affect the performance of prediction tasks. Depending on the degree of information accessed in the test set, we split our dynamic predicting tasks into inductive and transductive settings. \textbf{Transductive} setting refers to the reasoning from the observed graph to specific nodes or edges \citep{joachims2003transductive}. It assumes that the entire input graph can be observed across the training, validation, and test sets. Our predictions for the future edges are based on the observed input graph. \textbf{Inductive} setting refers to the reasoning from observed graph information to general rules (or unseen graphs, in our case) \citep{hamilton2017inductive}. We break edges to get independent training, validation, and test graphs. The task is to predict future links of unseen nodes. In node classification, the target is to predict whether the linkage between users and items will lead to a state change in users \cite{kumar2016ask}. In particular, a trained model tries to predict if a user will be banned (Wikipedia, Reddit) or if a student will drop out from the course (MOOC). Note that the three datasets are highly-imbalanced and the positive rate is at most $1\%$, since the chances a user will be banned or a student' drop-out should be small. In this task, a trained model from the link prediction task serves as the encoder. A trainable MLP decoder mapping from the node embedding to the probability of state change. \subsubsection{Evaluation Metrics} We follow the design of prediction task by PyTorch on interactions happening in time $t+1$ and $t+2$ of a bipartite graph given information until time $t$. The evaluation of our model is based on two specific metrics: \textbf{precision} and \textbf{ROC-AUC}. \begin{itemize} \item \textbf{Precision} refers to the number of true positives (TP) divided by the total number of positive observations, i.e., the sum of true positive and false positive (TP$+$FP) instances. The information retrieval theory \citep{baeza1999modern} suggests the best model has its precision at $1$, which implies that labels of all the positive samples are correctly predicted. In our cases, we use precision to measure the proportion of predicted interactions that indeed exists in the ground truth dataset. \item \textbf{ROC-AUC}, or `The Area under the ROC Curve' where ROC stands for receiver operating characteristic curve is a standard performance measure for classification tasks \citep{bradley1997use}. ROC-AUC calculates the 2D area underneath the ROC curve. It measures models' capability of distinguishing labels among classes. Here we use ROC-AUC to measure the probability that the model ranks a random true interaction that is higher than a random false interaction. \end{itemize} \subsubsection{Comparison Baselines} \textsc{SWINIT} is compared with three dynamic graph models for continuous-time inputs. \textsc{JODIE} \citep{kumar2019predicting} \footnote{\url{https://github.com/srijankr/jodie}} employs two recurrent neural network models and introduces an innovative projection function that learns the future embeddings of any user. \textsc{DyRep} \citep{trivedi2019dyrep} \footnote{implemented by \url{https://github.com/twitter-research/tgn}} designs a latent mediation process to capture the topological evolution and node-level interactions. The node neighbours are aggregated by \textsc{GAT} \citep{velivckovic2017graph}. \textsc{TGN} \citep{rossi2020temporal} \footnote{\url{https://github.com/twitter-research/tgn}} develops a novel memory module to consider the long-term dependencies in dynamic graphs and employs temporal graph attention to learn the temporal embeddings. \subsubsection{Training Setup} We follow the pseudo-code of Algorithm~\ref{alg:SWINIT} and design \textsc{SWINIT} accordingly. In the spectral attention module, we approximate truncated SVD with some largest modes with $q$-iteration. The specific number of node is selected as the smallest number between $50$ and $100$ such that the spectral norm error is less than $0.1$. The batch memory window is processed by fully connected layers, and the prepared subgraphs are then processed by \textsc{UFGConv} with Haar-type filters at dilation factor $2^l$ to allow efficient transforms. To train a generalized model that is robust to small disturbance, in the validation set we randomly add 50\% negative samples at each epoch. The same negative sampling procedure is conducted in the test set, except that all the samples are deterministic. This design is universally used in literature so that the prediction tasks become non-trivial. The hyper-parameters of baseline models, unless specified, are fixed to the best choice provided by their authors. For all the models, we fix the batch size at $1,000$ with a maximum of $200$ epochs for both datasets. Any employed neural network overlays either $2$ or $3$ layers, and the memory dimension, node embedding dimension, time embedding dimension are selected from $\{100,150,200\}$ respectively. To make the comparison as fair as possible, the number of parameters of each model corresponding the fine tuned hyperparameters are reflected in Table \ref{tab:linkPrediction}. The optimal learning rate is tuned from the range of $\{1\mathrm{e}-4,5\mathrm{e}-5\}$, and the weight decay is fixed at $1\mathrm{e}-2$. The training process is optimized by \textsc{AdamW} \citep{loshchilov2018decoupled}. All the datasets follow the standard split and processing rules as in \citep{kumar2019predicting,rossi2020temporal}. The average test accuracy and its standard deviation come from $10$ runs. \begin{table}[t] \caption{Average performance for ABLATION study on Wikipedia.} \label{tab:ablation_wiki} \begin{center} \resizebox{\linewidth}{!}{ \begin{tabular}{lrrr} \toprule & \multicolumn{2}{c}{\textbf{link prediction}} & \textbf{node classification} \\ \cmidrule(lr){2-3}\cmidrule(lr){4-4} \textbf{Module} & precision & ROC-AUC & ROC-AUC \\ \midrule \textsc{raw+mlp} & $96.71${\scriptsize $\pm0.10$} & $96.20${\scriptsize $\pm0.20$} & $88.33${\scriptsize $\pm0.18$} \\ \textsc{raw+trSVD+mlp} & $96.82${\scriptsize $\pm0.13$} & $96.23${\scriptsize $\pm0.12$} & \bm{$88.47${\scriptsize $\pm0.22$}} \\ \textsc{trSVD+mlp} & \bm{$97.02${\scriptsize $\pm0.06$}} & \bm{$96.51${\scriptsize $\pm0.08$}} & $88.37${\scriptsize $\pm0.03$} \\ \midrule \textsc{raw+gru} & $97.18${\scriptsize $\pm0.03$} & $96.84${\scriptsize $\pm0.04$} & $88.66${\scriptsize $\pm0.27$} \\ \textsc{raw+trSVD+gru} & $97.23${\scriptsize $\pm0.04$} & $96.90${\scriptsize $\pm0.05$} & $87.56${\scriptsize $\pm0.09$} \\ \textsc{trSVD+gru} & \bm{$97.44${\scriptsize $\pm0.05$}} & \bm{$97.15${\scriptsize $\pm0.06$}} & \bm{$90.32${\scriptsize $\pm0.05$}} \\ \bottomrule\\[-2.5mm] \end{tabular} } \end{center} \end{table} \subsection{Result Analysis with Baseline Comparison} \subsubsection{Prediction Performance} We report the performance of transductive and inductive link prediction tasks in Table~\ref{tab:linkPrediction}. In addition, we provide the average computation speed per epoch and the number of parameters to be estimated in Table~\ref{tab:complexity}. Of all four scenarios (two tasks on two settings), \textsc{SWINIT} outperforms \textsc{JODIE} and \textsc{DyRep}, and achieves at least comparable performance to \textsc{TGN} for both precision and ROC-AUC metric. The standard deviation is also controlled at a low level, which reflects our model has consistent performance over time. It is worth noticing that \textsc{JODIE-gru} outperforms the original \textsc{JODIE-rnn} adopted by the authors of \cite{kumar2019predicting}. The performance gain of GRU over RNN explains to some extent the outperformance of \textsc{TGN} over \textsc{SWINIT-mlp} in some cases. We would like to stress here that our memory unit is propagated by MLP, which is an even simpler design compared to any recurrent unit. While the disadvantage is considerably small (or even twisted), it stresses the effectiveness of the spectral modules we rely on. This observation can easily be verified by the results of \textsc{SWINIT-gru} where the memory layer adopts the GRU module. It outperforms all other baselines significantly, including \textsc{TGN}, over different datasets, learning tasks, and evaluation metrics. The average AOC-ROC score for node classification tasks on the three datasets are reported in Table~\ref{tab:nodeClassification}. As mentioned in experimental setup, the extremely imbalanced nature of node classes results in lower performance of all the models on average. Still, \textsc{SWINIT} outperforms the baselines, where the advantage is greater when equipping GRU module. In particular, GRU-enhanced models achieve the highest ROC-AUC scores of all time. \subsubsection{Computational Complexity} In supplement to the performance of prediction tasks, we provide the average computation speed per epoch and the number of parameters to be estimated in Table~\ref{tab:complexity}. In general, the computational complexity, \textsc{SWINIT} requires \textbf{SEVEN} times smaller than \textsc{TGN-gru} the amount of parameters to approximate, in comparison to \textsc{TGN-gru}. The computational speed of \textsc{SWINIT} is mainly influenced by the frequent operation of pushing and pulling $\theta$s from the global $\Theta$. This issue becomes obvious when the total number of edges in the dataset grows to a considerably large mass. With further optimization on a practice level, we believe the speed issue can be well-resolved or at least lessen to an acceptable level. We leave the improvements for future work. Despite the cost of \textsc{UFGConv}, \textsc{SWINIT} propagates faster than all other baselines. Particularly on the Reddit dataset, which has more than $4$ times of events compared to Wikipedia, \textsc{SWINIT} boost at least $50\%$ speed while maintaining top performance. This result is consistent with the analysis in Section~\ref{sec:attnSVD} and Section~\ref{sec:model}, where the computational cost of \textsc{SWINIT} is significantly reduced through calculating ${\bm{X}}^{\top}{\bm{X}}$ in priority. \begin{remark} The performance of \textsc{TGN} in both transductive and inductive settings are lower than scores reported in \cite{rossi2020temporal}. The difference lies in the access of previous interactions. In particular, the task we (also in PYG) design is constrained on a more realistic scenario that no ground truth after $t$ can be accessed when we validate and test at time $t$ and $t+1$. The prediction is thus made in parallel. In contrast, \textsc{TGN} has access to all previous data when sampling node neighborhoods for interactions later in the batch. \end{remark} \subsection{Ablation Study} In addition to the comparison against baseline methods, we also justify the choice of the temporal encoder, including the spectral attention and sequential network. For the spectral attention module, we set up three different data encoders, the input of which is the raw data, and the output is a transformed data matrix that is used for batch training (graph slicing). The three encoders differ in the proportion of used column basis from SVD: no SVD transform (\textsc{raw}), truncated SVD transform that concatenates raw input (\textsc{raw + trSVD}), and truncated SVD transform (\textsc{trSVD}). The last model, i.e., \textsc{trSVD}, is used as our final model. For the sequential temporal information encoder, we consider MLP and GRU modules, which are also the two choices we evaluated in the last two experiments. A total number of six models are thus to be validated. Note that when comparing different choices of attention, we exclude the vanilla transformer encoder, as its speed is too slow to provide the average score within a limited computing resource. As a matter of fact, an epoch of the self-attention encoder requires more than $30$ minutes to run. In contrast, it only takes \textsc{trSVD} less than $1.5$ minutes to finish an epoch on a model of the same setting. The models are validated on Wikipedia of both link prediction and node classification tasks. We follow the same setups aligned with Table~\ref{tab:linkPrediction}. The hyper-parameters are fixed to the optimal results from the best performed \textsc{SWINIT} in the earlier baseline comparison experiment. As the prediction performance reported in Table~\ref{tab:ablation_wiki}, all the three variants of \textsc{SWINIT} achieve a similar level of outstanding scores, which is due to the main architectural design. Still, \textsc{trSVD} outperforms \textsc{raw + trSVD} with a noticeable differences, and achieves a slightly better performance than \textsc{raw}. The outperformance is much more significant with GRU than MLP network, where the former contains more complicated architectures for local temporal information aggregation. To understand such observation, a possible interpretation is that the importance of feature abbreviation and pattern extraction gains increasing importance when the feature-to-sample ratio increases. The smaller the sample size is, the more harmful a redundant data input becomes. The observations demonstrate the effectiveness of our design regarding encoding principal patterns of both dimensions. \section{Discussion} \label{sec:conclusion} The paper proposed a new graph neural network framework for the prediction tasks of temporal data. The operations in the computational unit are fully defined by a trainable spectral transform, where the trainable neural unit is implemented by fully connected layers, i.e., MLP. It connects the two spectral-based modules. The first module uses the randomized SVD for all the event edges of the dynamic graph. It extracts the key temporal node features. By transforming features to the spectral domain, the node dimension and time dimension are fused properly. With SVD, the conventional multi-layer perception becomes as powerful as complex recurrent memory modules, such as GRU and LSTM, in dynamic graph prediction tasks. MLP takes the feature batches of subgraphs from SVD and outputs the trained features to the framelet convolution (\textsc{UFGConv}). The latter has been proved able to capture the graph structure information in a multi-level and multi-scale learning presentation \cite{zheng2021framelets}. The graph structure is mainly embedded in the framelet basis of the framelet convolution. The experiments show that the framelet system constructed by the original data has a strong transferrability in the dynamic evolution of graph data. Thus, the three units, SVD, MLP, and \textsc{UFGConv}, altogether serve as a powerful network engine for Dynamic GNNs to learn time-dependent structured data. Both theoretical and empirical evidence demonstrates that the learnable SVD equipped with randomized SVD and MLP plays an equal role as a transformer. Inherited from the scalability of the SVD and especially the framelet transforms-based \textsc{UFGConv}, \textsc{SWINIT} then achieves better scalability than traditional transformer encoders. \bibliographystyle{ACM-Reference-Format}
{'timestamp': '2021-11-16T02:28:18', 'yymm': '2111', 'arxiv_id': '2111.07602', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07602'}
arxiv
\section{Introduction} The propositional logic has long been recognized as one of the corner stones of reasoning in philosophy and mathematics \cite{biere2009handbook}. The satisfiability problem of propositional logic formulas (SAT) has significant impact on many areas of computer science and artificial intelligence. SAT is the first problem proved to be NP-complete \cite{cook1971complexity}, requiring the worst-case exponential time to be solved unless P=NP. The Maximum Satisfiability problem (MaxSAT) is a generalization of SAT, which aims to optimize the number of satisfied clauses, and it is also an NP-hard problem with a wide range of applications \cite{carlos2013maxsat}. There have been tremendous efforts in solving SAT and MaxSAT efficiently, and numerous solvers have been developed in the last few decades such as \cite{cai2021sat}. Nevertheless, these off-the-shelf solvers are mainly based on search algorithms with elaborate hand-crafted strategies. Thanks to recent advances in deep representation learning, particularly for non-euclidean structure, there have been initial efforts to represent and solve combinatorial problems such as SAT through data-driven approaches. It relies on the fact that the distribution of problem instances in practice is generally domain-specific, which means that we can solely replace the training data to obtain efficient implicit heuristics instead of carefully modifying the strategies for certain domain. The current application of deep learning to SAT problem can be grouped into two categories. One is to build an end-to-end model that inputs a problem instance and directly predicts the satisfiability or solution, as demonstrated in Figure \ref{fig1}. A pioneering work is NeuroSAT \cite{selsam2018learning}, which shows that graph neural networks (GNNs) have capability to learn the satisfiability of SAT instances in specific domain (i.e., whether a group of assignments to the variables exists such that all the clauses are satisfied). \cite{chris2020predicting} further explores the performance of GNN models on predicting the satisfiability of random 3SAT problems which are still challenging for the state-of-the-art solvers. The other category combines neural networks with the traditional search frameworks, trying to improve the effects of some key heuristics. For example, GNNs are used to replace the variable selection function in the WalkSAT solver \cite{nips2019learning}, produce the initialization assignment of local search \cite{zhang2020nlocalsat}, or guide the search by predicting the variables in the unsat core \cite{selsam2019neurocore}. These efforts indicate that GNN models are believed to have a certain degree of capability for learning from SAT problem instances, and also the potential to help improve SAT solving techniques in the future. Nevertheless, the current research barely discusses the quality of solution predicted by the models, which should be an important indicator to check what GNNs learn from SAT problems. The end-to-end models mentioned above mainly focus on the prediction of satisfiability. For a satisfiable instance, the predicted solution given by models is infeasible most of the time, and we also have no idea how far it is from a feasible solution. In order to better understand the capability of GNN models, we target the subject as learning the solution of MaxSAT problem, an optimization version of SAT which aims at finding a solution that maximizes the number of satisfied clauses. The advantage is that as an optimization problem, we can analyze the quality of solution in more detail, such as the number of satisfied clauses and the approximation ratio, while a solution of SAT provides little information that it is valid or not. It is worth mentioning that although the 2SAT problem (i.e., each clause contains two literals) is in the complexity class P, the Max2SAT problem is still NP-hard \cite{garey1976max2sat}, so even generating near-optimal solution for Max2SAT is not trivial. Moreover, despite GNNs have shown their effectiveness on SAT problem through experiments, the theoretical analysis about why they can work is still absent so far. Recently, there have been some theoretical research about learning to solve combinatorial problems with GNNs. \cite{xu2019gin} proves that the discriminative power of many popular GNN variants, such as Graph Convolutional Networks (GCN) and GraphSAGE, is not sufficient for the graph isomorphism problem. \cite{xu2020algoalign} proposes the algorithmic alignment theory to explain what reasoning tasks GNNs can learn well, and shows GNNs can align with dynamic programming algorithms. So, many classical reasoning tasks could be solved relatively well with a GNN model, such as visual question answering and shortest paths. However, it also raises an issue: as a polynomial-time procedure, any GNN model cannot align with an exact algorithm for NP-hard problems unless P=NP, whereas some approximation algorithms may be used to analyze the capability of GNNs to solve such problems. \cite{sato2019approximation} has employed a class of distributed local algorithms to prove that GNNs can learn to solve some combinatorial optimization problems, such as minimum dominating set and minimum vertex cover, with some approximation ratios. These theoretical contributions provide a basis for us to further study the capability of GNNs on the MaxSAT problem. In this paper, we investigate the capability of GNNs in learning to solve MaxSAT problem both from theoretical and practical perspectives. Inspired from the algorithmic alignment theory, we design a distributed local algorithm for MaxSAT, which is guaranteed to have an approximation ratio of $1/2$. As the algorithm aligns well with a single-layer GNN, it can provide a theoretical explanation of the effect that a simple GNN can learn to solve MaxSAT problem to some extent. More importantly, for the first time, this work leverages GNNs to learn the solution of MaxSAT problem. Specifically, we build two typical GNN models, MS-NSFG and MS-ESFG, based on summarizing the common forms proposed for SAT, to investigate the capability of GNNs from the practical perspective. We have trained and tested both models on several random MaxSAT datasets in different settings. The experimental results demonstrate that both models have achieved pretty high accuracy on the testing sets, as well as the satisfactory generalization to larger and more difficult problems. This implies that GNNs are expected to be promising alternatives to improve the state-of-the-art solvers. We are hopeful that the results in this paper can provide preliminary knowledge about the capability of GNNs to solve MaxSAT problem, and become a basis for more theoretical and practical research in the future. The contributions can be summarized as follows: \begin{itemize} \item We build two typical GNN models to solve MaxSAT problem, which is the first work to predict the solution of MaxSAT problem with GNNs in an end-to-end fashion. \item We analyze the capability of GNNs to solve MaxSAT problem theoretically, and prove that even a single-layer GNN can achieve the approximation ratio of $1/2$. \item We evaluate the GNN models on several datasets of random MaxSAT instances with different distributions, and show that GNNs can achieve good performance and generalization on this task. \end{itemize} \begin{figure}[t] \centering \includegraphics[width=0.9\columnwidth]{framework} \caption{The general framework of applying GNNs to solve SAT and MaxSAT problems. The CNF formula is firstly transformed to a bipartite factor graph, then each node is assigned an initial embedding. The embeddings are updated iteratively through the message passing process. Finally, a classifier decodes the assignment of each variable from its embedding.} \label{fig1} \end{figure} \section{Preliminaries} In this section, we firstly give the definition of SAT and MaxSAT problems, and then give an introduction to graph neural networks. \subsection{SAT and MaxSAT} Given a set of Boolean variables $\{x_1, x_2, \dots, x_n\}$, a \emph{literal} is either a variable $x_i$ or its negation $\neg x_i$. A \emph{clause} is a disjunction of literals, such as $C_1:=x_1 \vee \neg x_2 \vee x_3$. A propositional logic formula in \emph{conjunctive normal form (CNF)} is a conjunction of clauses, such as $F:=C_1 \wedge C_2 \wedge C_3$. For a CNF formula $F$, the Boolean Satisfiability (SAT) problem is to find a truth assignment for each variable, such that all the clauses are satisfied (i.e., at least one literal in each clause is True). And the Maximum Satisfiability (MaxSAT) problem is to find a truth assignment for each variable, such that the number of satisfied clauses is maximized. SAT and MaxSAT have long been proved to be NP-hard, which means there is no polynomial-time algorithm to solve them unless P=NP. Specifically, if every clause in $F$ contains exactly $k$ literals, the problem is called `$k$SAT' or `Max$k$SAT'. There is a close relationship between MaxSAT and SAT. Firstly, MaxSAT can be seen as an optimization version of SAT, which can provide more information when handling over-constrained problems. Besides, many solving techniques that are effective in SAT have also been adapted to MaxSAT, such as lazy data structures and variable selection heuristics. Accordingly, SAT can also benefit from the progress of MaxSAT. \subsection{Graph Neural Networks} Graph neural networks (GNNs) are a family of neural network architectures that operate on graphs, which have shown great power on many tasks across domains, such as protein interface prediction, recommendation systems and traffic prediction \cite{zhou2020gnnreview}. For a graph $G=\langle V,E \rangle$ where $V$ is a set of nodes and $E \subseteq V \times V$ is a set of edges, GNN models accept $G$ as input, and represent each node $v$ as an embedding vector $h_v^{(0)}$. Most popular GNN models follow the message passing process that updates the embedding of a node by aggregating the information of its neighbors iteratively. The operation of the $k$-th iteration (layer) of GNNs can be formalized as \begin{equation} \begin{array}{l} s_v^{(k)}={\rm AGG}^{(k)}(\{h_u^{(k-1)}|u \in \mathcal{N}(v)\}), \\ h_v^{(k)}={\rm UPD}^{(k)}(h_v^{(k-1)}, s_v^{(k)}), \end{array} \label{equ1} \end{equation} where $h_v^{(k)}$ is the embedding vector of node $v$ after the $k$-th iteration. In the aggregating (messaging) step, a message $s_v^{(k)}$ is generated for each node $v$ by collecting the embeddings from its neighbors $\mathcal{N}(v)$. Next, in the updating (combining) step, the embedding of each node is updated combined with the message generated above. After $T$ iterations, the final embedding $h_v^{(T)}$ for each node $v$ is obtained. If the task GNNs need to handle is at the graph level such as graph classification, an embedding vector of the entire graph should be generated from that of all the nodes: \begin{equation} h_G={\rm READOUT}(\{h_u^{(T)}|u \in V\}). \label{equ2} \end{equation} The final embeddings can be decoded into the outputs by a learnable function such as multi-layer perceptron (MLP), whether for node-level or graph-level tasks. The modern GNN variants have made different choices of aggregating, updating and readout functions, such as concatenation, summation, max-pooling and mean-pooling. A more comprehensive review of GNNs can be found in \cite{wuzh2021gnnreview}. \begin{figure}[b] \centering \includegraphics[width=0.9\columnwidth]{factorgraph_new} \caption{Two kinds of factor graphs to represent the CNF formula $(x_1 \vee x_2 \vee x_3) \wedge (x_1 \vee \neg x_3) \wedge (\neg x_1 \vee \neg x_2 \vee \neg x_3)$ with 3 variables and 3 clauses.} \label{fig2} \end{figure} \section{GNN Models for MaxSAT} As described in Section 1, there have been several attempts that learn to solve SAT problem with GNNs in recent years. The pipeline of such work generally consists of three parts. Firstly, a CNF formula is transformed to a graph through some rules. Next, a GNN variant is employed that maps the graph representation to the labels, e.g., the satisfiability of a problem or the assignment of a variable. Finally, the prediction results are further analyzed and utilized after the training converges. Intuitively, they can almost be transfered to work on MaxSAT problem without much modification, since these two problems have the same form of input. Factor graph is a common representation for CNF formulas, which is a bipartite structure to represent the relationship between literals and clauses. There are mainly two kinds of factor graphs that have appeared in the previous work. The first one is node-splitting factor graph (NSFG), which splits the two literals ($x_i, \neg x_i$) corresponding to a variable $x_i$ into two nodes. NSFG is used by many work such as \cite{selsam2018learning} and \cite{zhang2020nlocalsat}. The other one is edge-splitting factor graph (ESFG), which establishes two types of edges, connected the clauses with positive and negative literals separately. \cite{nips2019learning} uses ESFG with a pair of biadjacency matrices. An example that represents a CNF formula with these two kinds of factor graphs is illustrated in Figure \ref{fig2}. The models generally follow the message passing process of GNNs. Considering the bipartite structure of graph, in each layer the process is divided in two directions executed in sequence. For NSFG, the operation of the $k$-th layer of GNNs can be formalized as \begin{equation} \begin{split} &C_j^{(k)}={\rm UPD_C}(C_j^{(k-1)}, {\rm AGG_L}(L_i^{(k-1)}|(i,j) \in E)), \\ &(L_i^{(k)}, \widetilde{L}_i^{(k)})={\rm UPD_L}(L_i^{(k-1)}, \widetilde{L}_i^{(k-1)}, \\ &\mathrel{\phantom{(L_i^{(k)}, \widetilde{L}_i^{(k)})={\rm UPD_L}}}{\rm AGG_C}(C_j^{(k-1)}|(i,j) \in E)), \end{split} \label{equ3} \end{equation} where $L_i^{(k)}, C_j^{(k)}$ is the embedding of literal $i$ and clause $j$ in the $k$-th layer. The message is firstly collected from the literals in clause $j$, and the embedding of $j$ is updated by that of the last layer and the message. Next, the embedding of literal $i$ is updated in almost the same way, except that the embedding of literal $i$ is updated with that of its negation together (denoted by $\widetilde{L}_i^{(k)}$). This operation maintains the consistency of positive and negative literals of the same variable. For ESFG, there are two types of edges, which can be denoted as $E^+$ and $E^-$. If a positive literal $i_1$ appears in clause $j$, we have $(i_1, j)\in E^+$, and similarly have $(i_2, j)\in E^-$ if $i_2$ is a negative literal. The operation of the $k$-th layer of GNNs can be formalized as \begin{equation} \begin{split} &C_j^{(k)}={\rm UPD_C}(C_j^{(k-1)}, {\rm AGG_L^+}(L_i^{(k-1)}|(i,j) \in E^+), \\ &\mathrel{\phantom{C_j^{(k)}={\rm UPD_C}}}{\rm AGG_L^-}(L_i^{(k-1)}|(i,j) \in E^-)), \\ &L_i^{(k)}={\rm UPD_L}(L_i^{(k-1)}, {\rm AGG_C^+}(C_j^{(k-1)}|(i,j) \in E^+), \\ &\mathrel{\phantom{C_j^{(k)}={\rm UPD_C}}}{\rm AGG_C^-}(C_j^{(k-1)}|(i,j) \in E^-)). \end{split} \label{equ4} \end{equation} Finally, for both NSFG and ESFG, a binary classifier is applied to map the embedding of each variable to its assignment. We use the binary cross entropy (BCE) as loss function, which can be written as \begin{equation} BCE(y, p) = -(y\log(p)+(1-y)\log(1-p)), \label{equ5} \end{equation} where $p\in[0,1]$ is the predicted probability of a variable being assigned True, and $y$ is the binary label from an optimal solution. By averaging the loss of each variable, we obtain the loss of a problem instance, which should be minimized. We will investigate the performance of these two models through experiments in Section 5. \section{Theoretical Analysis} With the results and prospects revealed in practice, GNNs are considered to be a suitable choice in learning to solve SAT problem from benchmarks. However, the knowledge about why these models would work from a theoretical perspective is still limited so far. In this section, we are committed to explaining the possible mechanism of GNNs to solve MaxSAT problem. More specifically, we prove that a single-layer GNN can achieve an approximation ratio of $1/2$ with the help of a distributed local algorithm. \subsection{Algorithmic Alignment} Our theoretical analysis framework is inspired by the algorithmic alignment theory proposed by \cite{xu2020algoalign}, which provides a new point of view to understand the reasoning capability of neural networks. Formally, suppose a neural network $\mathcal{N}$ with $n$ modules $\mathcal{N}_i$, if by replacing each $\mathcal{N}_i$ with a function $f_i$ it can simulate, and $f_1,\dots,f_n$ generate a reasoning function $g$, we say $\mathcal{N}$ aligns with $g$. As shown in that paper, even if different models such as MLPs, deep sets and GNNs have the same expressive power theoretically, GNNs tend to achieve better performance and generalization stably in the experiments. This can be explained by the fact that the computational structure of GNNs aligns well with the dynamic programming (DP) algorithms. Therefore, compared with other models, each component of GNNs only needs to approximate a simpler function, which means the algorithmic alignment can improve the sample complexity. \subsection{Distributed Local Algorithm} According to the algorithmic alignment theory, it is possible to reasonably infer the capability that a GNN model can achieve with the help of an algorithm aligned with its computational structure. However, this also raises an issue: as a polynomial-time procedure, any GNN model cannot align with an exact algorithm for NP-hard problems such as MaxSAT, under the assumption that P$\neq$NP. In this case, we turn to employ a weaker approximation algorithm to analyze the capability of GNNs. Although there has been a lot of research on the approximation algorithms of MaxSAT \cite{vijay2001approxbook}, it is regrettable that most of them cannot align with the structure of GNNs in an intuitive way. In fact, there is a class of algorithms called distributed local algorithm (DLA) \cite{elkin2004distributed}, which have been found to be a good choice to align with GNNs for combinatorial problems. DLA assumes a distributed computing system that there are a set of nodes in a graph, where any two nodes do not know the existence of each other at first. The algorithm then runs in a constant number of synchronous communication rounds. In each round, a node performs local computation, and sends one message to its neighboring nodes, while receiving one from each of them. Finally, each node computes the output in terms of the information it holds. DLAs have been widely used in many applications, such as designing sublinear-time algorithms \cite{parnas2007sublinear} and controlling wireless sensor networks \cite{kubisch2003wireless}. \subsection{Analyzing GNNs for MaxSAT} Most DLAs are designed for solving combinatorial problems in graph theory. \cite{sato2019approximation} has employed DLAs to clarify the approximation ratios of GNNs for several NP-hard problems on graphs such as minimum dominating set and minimum vertex cover. This also encourages us to analyze the capability of GNNs to solve MaxSAT problem with the help of a DLA. As the DLA for MaxSAT has not been studied in the literature, we design an algorithm that aligns well with the message passing process described in Section 3, and the pseudo code is shown in Algorithm \ref{alg1}. This algorithm accepts the description of a MaxSAT problem instance as input, and returns the assignment of literals, while the value of objective (i.e., the number of satisfied clauses) is easy to compute from it. Following the rules of DLA, the literals and clauses do not have any information about the problem initially. $W$ and $S$ correspond to the states of literals and clauses, respectively. In line 4, the message is passed from \emph{literals} to \emph{clauses}, so that each clause is aware of the literals it contains, and stores the information into $S$. Next, in lines 5-8, the message is generated by \emph{clauses} and sent to \emph{literals}. Finally, the assignment of each literal is decoded from $W$ by a greedy-like method. It can be seen that the algorithm only carries out one round of communication. It is interesting to know whether a single-layer GNN may also have some capabilities to solve the MaxSAT problem theoretically. This can be analyzed by aligning it with the algorithm. \begin{algorithm}[tb] \caption{A distributed local algorithm for MaxSAT} \label{alg1} \textbf{Input}: The set of literals $L$, the set of clauses $C$ \\ \textbf{Output}: The assignments of literals $\Phi$ \begin{algorithmic}[1] \STATE Set up a factor graph such as NSFG for $L$ and $C$. \STATE $W(L_i)\leftarrow 0$ for each $L_i \in L$. \STATE $S(C_j)\leftarrow \{\}$ for each $C_j \in C$. \STATE $S(C_j)\leftarrow S(C_j) \cup \{L_i\}$ for each edge $(L_i,C_j)$ in the factor graph. \FOR {each $C_j \in C$} \STATE $L^* \leftarrow$ Pick a literal from $S(C_j)$. \STATE $W(L^*)\leftarrow W(L^*)+1$. \ENDFOR \FOR {each $L_i \in L$} \IF {$W(L_i) >= W(\widetilde{L}_i)$} \STATE $\Phi(L_i)\leftarrow {\rm True}$. \ELSE \STATE $\Phi(L_i)\leftarrow {\rm False}$. \ENDIF \ENDFOR \STATE \textbf{return} $\Phi$ \end{algorithmic} \end{algorithm} \begin{theorem} \label{theo1} There exists a single-layer GNN to solve the MaxSAT problem, which is guaranteed to have an approximation ratio of\, $1/2$. \end{theorem} \begin{proof} We give a proof sketch here because of the space limitation, and the full proof is available in Appendix. Firstly, we show that there exists a single-layer GNN model that can align with the proposed distributed local algorithm (Algorithm \ref{alg1}), so that every part of the algorithm can be effectively approximated by a component of GNN. This implies that the GNN model can achieve the same performance with the algorithm when solving MaxSAT problem. Next, we prove that it is a $1/2$-approximation algorithm. The picking operation of literal (line 6) is equivalent to transforming the original problem into another, where each clause only contains one literal. Given a solution, the number of satisfied clauses of the original problem is at least as large as that of the new one, so we get the approximation ratio by analyzing the new Max1SAT problem. It is not hard to find that the algorithm has a guarantee that at least half of the clauses are satisfied for any Max1SAT instance. \end{proof} The proposed DLA can be considered as a candidate explanation for why a single-layer GNN model works and generalizes on the MaxSAT instances. The methodologies and results may also serve as a basis for future work to make theoretical progress on this task, such as explaining the improvement of capability as the number of GNN layers increases in the experiments and finding a tighter bound. \section{Experimental Evaluation} Although the GNN models have shown their capability on many reasoning tasks such as SAT problem, the experimental evidence of whether GNNs can learn to solve MaxSAT problem is still under exploration. In order to demonstrate the capability of GNNs on this task, we firstly build two models, using NSFG and ESFG separately. After constructing the datasets with a commonly used generator for random MaxSAT instances, the GNN models are trained and tested in different settings, so that we can obtain a comprehensive understanding of their capabilities. The experimental results show that GNNs have attractive potential in learning to solve MaxSAT problem with good performance and generalization. \subsection{Building the Models} In Section 3, we have described the general GNN frameworks that can learn to solve MaxSAT problem. Based on the successful early attempts, we build two GNN models that accept a CNF formula as input, and output the assignment of literals. We abbreviate them to MS-NSFG and MS-ESFG, because they use NSFG and ESFG as the graph representation, respectively. The structures of models follow those in Eq. (\ref{equ3}) and (\ref{equ4}). Here we only describe the implementation of some key components, and the complete frameworks are shown in Appendix. \noindent \textbf{Aggregating functions.} The implementation of aggregating functions: ${\rm AGG_L}$, ${\rm AGG_C}$ in MS-NSFG, and ${\rm AGG_L^+}$, ${\rm AGG_L^-}$, ${\rm AGG_C^+}$, ${\rm AGG_C^-}$ in MS-ESFG, consists of two steps. First, an MLP module maps the embedding of each node to a message vector. After that, the messages from relevant nodes are summed up to get the final output. For example, the function ${\rm AGG_L}$ in MS-NSFG which generates the message from literals and sends it to clause $j$, can be formalized as $\sum_{(i, j)\in E}{{\rm MLP}(L_i)}$, where $L_i$ is the embedding of literal $i$. \noindent \textbf{Updating functions.} The updating functions: ${\rm UPD_L}$ and ${\rm UPD_C}$ in both MS-NSFG and MS-ESFG can be implemented by the LSTM module \cite{hochreiter1997lstm}. For example, to implement the function ${\rm UPD_C}$, the embedding of clause $j$ (denoted as $C_j$) is taken as the hidden state, and the message generated from aggregation is taken as the input of LSTM. \subsection{Data Generation} For data-driven approaches, a large number of labeled instances are necessary. So, the dataset should be easy to solve by off-the-shelf MaxSAT solvers to ensure the size of dataset, meanwhile it should also have the ability to produce larger instances in the same distribution to test the generalization. As a result, we construct the datasets of random MaxSAT instances by running a generator proposed by \cite{mitchell1992generator}, which is also used to provide benchmarks for the random track of MaxSAT competitions\footnote{https://maxsat-evaluations.github.io/}. The generator can produce CNF formulas with three parameters: the number of literals in each clause $k$, the number of variables $n$, and the number of clauses $m$. In order to better observe the performance of GNN models, we generate multiple datasets with different distributions, which are listed in Table \ref{tab1}. For \texttt{R2(60,600)}, \texttt{R2(60,800)} and \texttt{R3(30,300)}, we generate 20K instances, and divide them into training set, validation set and testing set according to the ratio of 8:1:1. For \texttt{R2(80,800)} and \texttt{R3(50,500)}, we only generate 2K instances as testing sets. Then we call MaxHS \cite{bacchus2020maxhs}, a state-of-the-art MaxSAT solver, to find an optimal solution for each instance as the labels of variables. The average time MaxHS spends to solve the instances in each dataset is also presented, so that we can know about their difficulty. \begin{table}[h] \def1.1{1.1} \centering \begin{tabular}{ccccc} \hlineB{3} Dataset & $k$ & $n$ & $m$ & Time(s) \\ \hline \texttt{R2(60,600)} & 2 & 60 & 600 & 4.01 \\ \texttt{R2(60,800)} & 2 & 60 & 800 & 18.21 \\ \texttt{R2(80,800)} & 2 & 80 & 800 & 105.19 \\ \texttt{R3(30,300)} & 3 & 30 & 300 & 1.92 \\ \texttt{R3(50,500)} & 3 & 50 & 500 & 216.26 \\ \hlineB{3} \end{tabular} \caption{The parameters and difficulty of the datasets.} \label{tab1} \end{table} \subsection{Implementation Details} We implement the models MS-NSFG and MS-ESFG in Python, and examine their practical performance to solve MaxSAT problem\footnote{The source code is available at https://url-is-hidden.}. The models are trained by the Adam optimizer \cite{kingma2015adam}. All the experiments are running on a machine with Intel Core i7-8700 CPU (3.20GHz) and NVIDIA Tesla V100 GPU. For reproducibility, we also summarize the setting of hyper-parameters as follows. In our configuration, the dimension of embeddings and messages $d=128$, and the learning rate is $2 \times 10^{-5}$ with a weight decay of $10^{-10}$. Unless otherwise specified, the number of GNN layers $T=20$. The instances are fed into models in batches, with each batch containing 20K nodes. \subsection{Accuracy of Models} We firstly evaluate the performance of both GNN models, including their convergence and the quality of predicted solution. The accuracy of prediction is reported with two values in the following paragraphs. The first one is \textbf{the gap to optimal objective}, which is the distance between the predicted objective and the corresponding optimal value. The predicted objective can be computed by counting the satisfied clauses given the predict solution. The other is \textbf{the accuracy of assignments}, which is the percentage of correctly classified variables, i.e., the assignment of a variable from the predicted solution is the same as its label. Generally, the gap to optimal objective could be a better indicator, because the optimal solution of a MaxSAT problem may not be unique. We have trained MS-NSFG and MS-ESFG separately on three different datasets: \texttt{R2(60,600)}, \texttt{R2(60,800)} and \texttt{R3(30,300)}, and illustrate the evolution curves of accuracy throughout training on \texttt{R2(60,600)} in Figure \ref{fig3} as an example. All the models can converge within 150 epochs, and achieve pretty good performance. The average gaps to optimal objectives are less than 2 clauses for all the models, with the approximation ratio $>$99.5\%. Besides, the accuracy of assignments is around 92\% (Max2SAT) and 83\% (Max3SAT). There is no significant difference between the two models, while MS-ESFG performs slightly better than MS-NSFG. The experimental results show that both GNN models can be used in learning to solve MaxSAT problem. \begin{figure}[htbp] \centering \includegraphics[width=0.98\columnwidth]{train_curve_new} \caption{The evolution of accuracy of MS-NSFG and MS-ESFG during a training process of 150 epochs on the dataset \texttt{R2(60,600)}.} \label{fig3} \end{figure} \subsection{Influence of GNN Layers} According to the theoretical analysis, the number of GNN layers determines the information that each node can receive from its neighborhood, thereby affecting the accuracy of prediction. We examine this phenomenon from the experimental perspective by training MS-NSFG and MS-ESFG on the three datasets separately, with different hyper-parameter $T$ from 1 to 30. The changes of accuracy on testing sets are illustrated in Figure \ref{fig4}. It can be seen that when $T=1$, the capabilities of both models are weak, where the predicted objective is far from the optimal value, and the accuracy of assignments is not ideal. However, the effectiveness of both models has been significantly improved when $T=5$. If we increase $T$ to 20, the number of clauses satisfied by the predicted solution is only one less than the optimal value on average. We have continued to increase $T$ to 60, but no obvious improvement occurred. This indicates that increasing the number of layers -- within an appropriate range -- will improve the capability of GNN models. \begin{figure}[htbp] \centering \includegraphics[width=0.98\columnwidth]{change_nr_new} \caption{The accuracy of MS-NSFG and MS-ESFG trained with different number of GNN layers.} \label{fig4} \end{figure} \subsection{Generalizing to Other Distributions} Generalization is an important factor in evaluating the possibility to apply GNN models to solve those harder problems. We make the predictions by MS-NSFG and MS-ESFG on the testing sets with different distributions from the training sets, and the results are shown in Table \ref{tab1} and \ref{tab2}, respectively. The first column is the dataset used for training the model, and the first row is the testing set. For each pair of training and testing datasets, we report the gap to optimal objective together with the approximation ratio in the brackets above, and the accuracy of assignments below. Here, the approximation ratio is defined as the ratio of predicted and optimal objectives. Here we mainly focus on three kinds of generalization. The first is generalizing to the datasets with \textbf{different clause-variable proportion}. From the results, both models trained on \texttt{R2(60,600)} and tested on \texttt{R2(60,800)} (or vice versa) can maintain almost the same prediction accuracy. The second is generalizing to \textbf{larger and more difficult problems}. We use two testing sets, \texttt{R2(80,800)} and \texttt{R3(50,500)}, where the number of variables is larger than those appeared in the training sets, as well as more difficult to solve by MaxHS. It can be found that both models trained on Max2SAT datasets can generalize to work on \texttt{R2(80,800)} with a satisfactory accuracy. This also holds when the training set is \texttt{R3(30,300)} and the testing set is \texttt{R3(50,500)}, which implies that GNN models are expected to be promising alternatives to help solve those difficult MaxSAT problems. The last is generalizing to \textbf{other datasets with different parameter $k$}. For example, the model is trained on Max2SAT but tested on Max3SAT problems. The results show that both models have limitations under this condition, since they cannot achieve an accuracy of assignments $>$80\% on every pair of training and testing sets, and the gap to optimal objective is not close enough, especially when trained on \texttt{R3(30,300)} and tested on Max2SAT datasets. \begin{table}[t] \centering \def1.1{1.1} \resizebox{.95\columnwidth}{!}{ \begin{tabular}{c|ccc|cc} \hlineB{3} \rule{0pt}{10pt} Train $\backslash$ Test & \texttt{R2(60,600)} & \texttt{R2(60,800)} & \texttt{R3(30,300)} & \texttt{R2(80,800)} & \texttt{R3(50,500)} \\ \hlineB{2} \multirow{2}{*}{\texttt{R2(60,600)}} & \textbf{0.86 (99.8\%)} & 1.42 (99.7\%) & 3.86 (98.6\%) & \textbf{1.15 (99.8\%)} & 6.77 (98.5\%) \\ & \textbf{91.9\%} & 91.9\% & 76.1\% & \textbf{92.0\%} & 75.4\% \\ \hline \multirow{2}{*}{\texttt{R2(60,800)}} & 1.19 (99.7\%) & \textbf{1.17 (99.8\%)} & 4.59 (98.4\%) & 1.50 (99.7\%) & 7.96 (98.3\%) \\ & 91.7\% & \textbf{92.4\%} & 75.8\% & 91.6\% & 75.1\% \\ \hline \multirow{2}{*}{\texttt{R3(30,300)}} & 20.58 (96.0\%) & 29.10 (95.7\%) & \textbf{1.37 (99.5\%)} & 27.92 (95.9\%) & \textbf{2.16 (99.5\%)} \\ & 78.1\% & 76.0\% & \textbf{83.3\%} & 78.0\% & \textbf{82.2\%} \\ \hlineB{3} \end{tabular}} \caption{The accuracy of MS-NSFG on different combinations of training and testing sets.} \label{tab2} \end{table} \begin{table}[t] \centering \def1.1{1.1} \resizebox{.95\columnwidth}{!}{ \begin{tabular}{c|ccc|cc} \hlineB{3} \rule{0pt}{10pt} Train $\backslash$ Test & \texttt{R2(60,600)} & \texttt{R2(60,800)} & \texttt{R3(30,300)} & \texttt{R2(80,800)} & \texttt{R3(50,500)} \\ \hlineB{2} \multirow{2}{*}{\texttt{R2(60,600)}} & 0.54 (99.8\%) & 1.12 (99.8\%) & 5.98 (97.9\%) & 0.69 (99.9\%) & 9.92 (97.9\%) \\ & 92.3\% & 92.2\% & 74.5\% & 92.2\% & 73.9\% \\ \hline \multirow{2}{*}{\texttt{R2(60,800)}} & \textbf{0.48 (99.9\%)} & \textbf{0.78 (99.8\%)} & 6.13 (97.8\%) & \textbf{0.62 (99.9\%)} & 10.24 (97.8\%) \\ & \textbf{92.3\%} & \textbf{92.8\%} & 74.7\% & \textbf{92.2\%} & 74.2\% \\ \hline \multirow{2}{*}{\texttt{R3(30,300)}} & 14.83 (97.1\%) & 16.44 (97.5\%) & \textbf{1.32 (99.5\%)} & 20.22 (97.0\%) & \textbf{1.98 (99.5\%)} \\ & 78.8\% & 79.5\% & \textbf{83.5\%} & 78.6\% & \textbf{82.5\%} \\ \hlineB{3} \end{tabular}} \caption{The accuracy of MS-ESFG on different combinations of training and testing sets.} \label{tab3} \end{table} \section{Related Work} Although the mainstream approaches for solving combinatorial problems, not limited to SAT or MaxSAT, are based on the search algorithms from symbolism, there have always been attempts trying to tackle these problems through data-driven techniques. A class of research is to integrate machine learning model in the traditional search framework, which has made progress on a number of problems such as mixed integer programming (MIP) \cite{khalil2016mip}, satisfiability modulo theories (SMT) \cite{balunovic2018smt} and quantified boolean formulas (QBF) \cite{lederman2020qbflearning}. Here, we work on building end-to-end models which do not need the aid of search algorithm. The earliest research work can be traced back to the Hopfield network \cite{hopfield1985neural} to solve TSP problem. Recently, many variants of neural networks have been proposed, which directly learn to solve combinatorial problems. \cite{vinyals2015pointer} introduces Pointer Net, a sequential model that performs well on solving TSP and convex hull problems. \cite{khalil2017learning} uses the combination of reinforcement learning and graph embedding, and learns greedy-like strategies for minimum vertex cover, maximum cut and TSP problems. With the development of graph neural networks, there have been a series of work that uses GNN models to solve combinatorial problems. An important reason is that many of such problems are directly defined on graph, and in general the relation between variables and constraints can be naturally represented as a bipartite graph. Except for the mentioned NeuroSAT \cite{selsam2018learning} and its improvement, there have been some efforts learning to solve TSP \cite{prates2019tsp}, pseudo-Boolean \cite{liu2020pseudo} and graph coloring \cite{lemos2019graphcolor} problems with GNN-based models. The results indicate that GNNs have become increasingly appealing alternatives in solving combinatorial problems. Moreover, there are also some well-organized literature reviews on this subject, such as \cite{bengio2021ml4co}, \cite{cappart2021corgnn} and \cite{lamb2020gnn4ns}. \section{Conclusion and Future Work} Graph neural networks (GNNs) have been considered as a promising technique that can learn to solve combinatorial problems in the data-driven fashion, especially for the Boolean Satisfiability (SAT) problem. In this paper, we further study the quality of solution predicted by GNNs in learning to solve Maximum Satisfiability (MaxSAT) problem, both from theoretical and practical perspectives. Based on the graph construction methods in the previous work, we build two kinds of GNN models, MS-NSFG and MS-ESFG, which can predict the solution of MaxSAT problem. The models are trained and tested on randomly generated benchmarks with different distributions. The experimental results show that both models have achieved pretty high accuracy, and also satisfactory generalization to larger and more difficult instances. In addition, this paper is the first that attempts to present an explanation of the capability of GNNs to solve MaxSAT problem from a theoretical point of view. On the basis of algorithmic alignment theory, we prove that even a single-layer GNN model can solve the MaxSAT problem with an approximation ratio of $1/2$. We hope the results in this paper can inspire future work from multiple perspectives. A promising direction is to integrate the GNN models into a powerful search framework to handle more difficult problems in the specific domain, such as weighted and partial MaxSAT problems. It is also interesting to further analyze the theoretical capability of multi-layer GNNs to achieve better approximation.
{'timestamp': '2021-11-16T02:27:17', 'yymm': '2111', 'arxiv_id': '2111.07568', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07568'}
arxiv
\section{Introduction} The dimensional down-scaling of CMOS technology has been continuously focused on increasing hardware efficiency of digital circuits \cite{yeap2013smart}. However, the performance improvement from the recent down-scaling is now expected to meet the potential limitation especially caused by the increased interconnecting/routing overheads \cite{magen2004interconnect}. Among the different solutions to address this limitation, the multi-valued logic (MVL) circuits have been recently gaining great popularity due to their attractive potential for reducing the circuit-level complexity as well as the routing burden even at the aggressive down-scaling technology \cite{gaudet2016survey}. For the practical implementation of the ternary-based system, which is a starting point of MVL solutions, numerous technologies have been proposed to solve the stability issue of each voltage/current level with emerging devices including carbon nanotube FETs (CNTFETs) \cite{lin2009novel}, graphene barristors \cite{yang2012graphene}, and CMOS-based ternary transistors \cite{shin2015compact}. In general, the prior studies on ternary circuits mainly present the potential expectations of gate-level performances \cite{kim2018optimal,kim2020logic}. For circuit-level studies, some digital building blocks such as adder, multiplier, and flip-flop have been also investigated to extend the concept of gate-level evaluation in ternary domains \cite{heo2018ternary,kang2017novel,choi2021design}. Due to the lack of systematic design-level strategies, on the other hand, the system- or processor-level explorations for ternary-based digital solutions are rarely reported in the open literature with few details \cite{PyconTernary}. In this work, we introduce advanced design and evaluation frameworks to realizing ternary processors, measuring actual performances with the practical benchmark programs. In contrast that the previous studies only present limited concepts to only test processing blocks in ternary number systems \cite{DouglasW,narkhede2013design}, we develop a 9-trit advanced RISC-based ternary (ART-9) core by adopting the proposed frameworks, presenting the fully-functional top-level ternary microprocessor. Based on the 9-trit instruction-set architecture (ISA) with 24 custom ternary instructions, more precisely, the proposed software-level framework provides an efficient way to convert the existing binary programs to the ternary codes, even reducing the program size compared to the baseline codes with RV-32I ISA \cite{RISC-V}. The hardware-level framework offers the cycle-accurate simulator and the technology mapper, providing the quantitative evaluations of the pipelined ART-9 architecture for arbitrary design technology. Targeting the specialized 5-stage pipelined architecture, as a case study, the proposed ART-9 core achieves the processing efficiency of 57.8 DMIPs/W and $3.06 \times 10^6$ DMIPs/W when we use the FPGA-level ternary-logic emulations and the emerging CNTFET-based ternary gates \cite{kim2020logic,kim2018optimal}, respectively, reporting the first full-level evaluations of ternary processors. \section{Background} \subsection{Ternary Number Systems} Based on the integrated ternary gates using three voltage levels such as GND, VDD/2 and VDD, the ternary circuits are dedicated to the arithmetic operations in a ternary number system. Like the binary case, there are in general two types of ternary fixed-point number systems: unsigned and signed systems. For an $n$-trit number $X = (x_{n-1},x_{n-2},...,x_0)_3$, where $x_i \in \{ 0, 1, 2 \}$, the unsigned ternary number only represents positive integers from 0 to $3^{n}-1$ by interpreting an $n$-trit sequence into a decimal value $Y_{\text{unsigned}}$ as follows. \begin{equation} Y_{\text{unsigned}} = \sum^{n-1}_{k=0} x_k3^k. \end{equation} Although the unsigned number system is useful for denoting indices of general-purposed ternary registers (GPTR) and addresses of ternary instruction/data memories (TIM/TDM), it is obviously required to support the signed arithmetic operations for performing the general data processing. Therefore, the singed ternary number system is considered to interpret the given $n$-trit sequence into the negative value. Among different ways to develop the ternary signed numbers \cite{DouglasW}, in this work, we adopt the balanced signed number system, where each trit is now an element from the balanced set, i.e, $x_i \in \{ -1, 0, 1 \}$ \cite{DouglasW}. Then, a numerical value $Y_{\text{signed}}$ of $n$-trit ternary number $X$ is still calculated in the same way as the unsigned representation shown in (1). Compared to the unbalanced approaches in \cite{DouglasW}, it is reported that the arithmetic operations in balanced ternary numbers can be simplified according to the conversion-based negation property \cite{kim2020logic,narkhede2013design}. To develop the proposed frameworks for general-purposed ternary processors, therefore, the balanced representation is definitely suitable by requiring fewer ternary gates for the practical realization \cite{kim2020logic}. \begin{figure} [!t] \centering \includegraphics[scale=1.0]{fig1.eps} \caption{Truth tables of ternary logic operations.} \label{fig.fig1} \end{figure} \subsection{Ternary-based Arithmetic and Logical Operations} Similar to basic operations of RISC-based binary processors \cite{RISC-V}, the ternary processor should support logic and arithmetic operations to perform the general user-level programs. As reported in \cite{DouglasW}, the balanced ternary logic operations include AND, OR, XOR, standard ternary inverting (STI), negative ternary inverting (NTI) and positive ternary inverting (PTI), where the detailed truth tables are exemplified in Fig. 1. Compared to the familiar two-input logic gates such as AND, OR, and XOR, note that the inverting operation consists of three fundamental functions (denoted as STI, NTI, PTI in Fig. 1), considering as the most important processing in the balanced ternary number system \cite{DouglasW}. It is also possible to define the proper two-input arithmetic operations, which are comparable to the well-established functions in the binary processor \cite{RISC-V}. For example, the fundamental functions including ternary addition, comparison, multiplication, and division, have been extensively studied for the next-generation computer arithmetic \cite{parhami2013arithmetic,heo2018ternary,kang2017novel }. Utilizing the negation operations in Fig. 1, it is also possible to simply utilize the ternary subtraction based on the pre-designed ternary adder \cite{parhami2013arithmetic}. \begin{figure} [!t] \centering \includegraphics[scale=1.0]{fig5_temp.eps} \caption{The proposed software-level compiling framework.} \label{fig.fig2} \end{figure} \section{Proposed Frameworks for Ternary Processors} \subsection{Software-Level Compiling Framework} For the full-level ternary processor implementation, based on a given ternary ISA, it is important to prepare ternary-based assembly (or executable) programs in an easy way. With the assistance of the existing RISC-V tool chains in open-source domains \cite{8714897}, in this work, we first develop a software-level compiling framework supporting instruction mapping, operand conversion, and redundancy checking, which can efficiently generate the ternary assembly benchmarks for arbitrary C-based source codes. Fig. 2 conceptually illustrates the processing steps of the proposed software-level framework. Note that the input C-level program is firstly handled by an open-source compiler for RV-32I ISA, obtaining an assembly sequence of 32-bit instructions. Then, the instruction mapping step is activated to translate the 32-bit instructions into pre-defined ternary instructions. For a binary instruction that cannot be directly converted with a ternary version, we utilize several primitive sequences of ternary instructions, still offering valid mapping results by allowing a few more instructions. After mapping ternary instructions, the operand conversion step is followed to find the ternary representations of immediate values in the baseline binary instructions. Depending on the definition of ternary instructions, it might be required to add more instructions to construct the large-sized operands in ternary number systems. Note that the operand conversion step also supports the register renaming when the given ternary ISA uses fewer general-purposed registers than the baseline binary processor. As the mapping and conversion steps may utilize additional instructions, the final redundancy checking phase finds the meaningless instructions by investigating the duplicated operations, removing them to minimize the overall code size. During the elimination of redundant instructions, the proposed framework also re-calculates the branch target addresses to ensure the correct results. As the proposed software-level framework is based on the well-established compiling environments for binary processors, we can purely focus on increasing the mapping quality in the ternary domain by deeply considering the characteristics of ternary instructions, relaxing the development efforts of ISA-dependent processor-design frameworks. Targeting the proposed ART-9 ISA, as a case study, the proposed software-level framework easily generates various ternary codes with reduced memory requirements, even saving the program size of dhrystone benchmark by 54\% compared to the baseline processor of RV-32I ISA \cite{RISC-V}. \begin{figure} [!t] \centering \includegraphics[scale=1.0]{fig6_temp.eps} \caption{The proposed hardware-level evaluation frameworks.} \label{fig.fig3} \end{figure} \subsection{Hardware-Level Evaluation Framework} Using ternary assembly codes, which can be obtained by the proposed software-level compiling framework, we develop the hardware-level evaluation framework allowing an efficient way to develop the prototype of ternary processor. As illustrated in Fig. 3, the hardware-level framework includes a cycle-accurate simulator, a gate-level analyzer, and a performance estimator. The cycle-accurate simulator accepts the high-level description of the pipelined ternary processor, and provides the required processing cycles for performing the input ternary assembly codes. With the synthesizable RTL design corresponding to the high-level architecture description, the proposed gate-level analyzer can estimate the critical delay as well as the power consumption of ternary processor. Note that we define the property description of the design technology as another input of gate-level analyzer, which includes delay and power characteristics of primitive building blocks, enabling more accurate analysis results depending on the target technology. As depicted in Fig. 3, the performance estimator gathers all the outputs from prior steps, and finally generates the overall evaluation information of the ternary processor implemented in certain design technology. By utilizing multiple evaluation steps and even considering the technology-oriented information, before starting the actual implementation phase with pre-designed peripherals, we can remarkably reduce the design efforts of the custom ternary processor with the proposed hardware-level evaluation framework. \begin{figure*}[ht] \centering \includegraphics[scale = 1.0]{fig2.eps} \caption{5-stage pipelined architecture of the proposed ART-9 processor.} \label{fig:fig4} \end{figure*} \begin{table}[!t] \centering \renewcommand{\arraystretch}{1.3} \renewcommand{\tabcolsep}{1.1mm} \caption{Summary of ART-9 Ternary Instructions} \input{table2_date.tex} \end{table} \section{ART-9 Core Design for Proposed Frameworks} \subsection{ART-9 Instruction Set Architecture} Based on the balanced ternary number systems, the proposed ART-9 processor defines 9-trit-length ISA following the properties of contemporary RISC-type binary processors \cite{RISC-V}. Table I summarizes 24 ART-9 ternary instructions processing 9-trit data values, which are the essential inputs at the proposed software-level compiling framework. By matching the word length of both instruction and data, we can allow the regular structure for realizing TIM and TDM. To fetch an instruction by accessing the TIM, we use a special-purposed 9-trit register, i.e., the program counter (PC) register containing the instruction address. In order to store the intermediate data, like the modern processor architectures \cite{RISC-V,yiu2015definitive}, the ART-9 core also includes a ternary registerfile (TRF) including nine general-purposed registers, each of which is accessed by using a 2-trit value. Utilizing the load-store architecture used for typical RISC processors \cite{schuiki2020stream}, there are four instruction categories in ART-9 ISA; R-type, I-type, B-type, and M-type. For the R-type instructions, considering the recent studies \cite{li2019reduce}, we select essential 12 logical/arithmetic functions as depicted in Table I. In fact, most R-type instructions are typical two-address instructions, which fetch two 9-trit operands in TRF, whose 2-trit indices are denoted as Ta and Tb, and then overwrite a 9-trit result to the register TRF[Ta]. Note that some R-type instructions specialized for inversion and data-movement operations use only one source operand from Tb, where the destination operand is still Ta to have the regular encoding patterns, relaxing the complexity to decode the fetched instruction. In addition, we also realize an R-type comparison instruction (COMP), where the least significant trit (LST) of the destination register TRF[Ta] denotes the comparison result of two input operands with the dedicated function $compare()$ in Table I. More specifically, the LST of TRF[Ta] is set to be zero when the two inputs are the same, otherwise it becomes $+1$ (or $-1$) if TRF[Ta] $>$ TRF[Tb] (or TRF[Ta] $<$ TRF[Tb]). This COMP instruction plays an important role to improve the code density by allowing the conditional execution of the following branch instructions. In order to reduce the generation complexity of constant values, the technique to encode immediate values into the instruction is generally used for reducing the size of user-level programs \cite{RISC-V,yiu2015definitive}. The proposed ART-9 processor also supports immediate-based processing with I-type instructions. As described in Table I, unlike the R-type instructions offering various functions, we only allow immediate values at addition, AND logic, and shift functions, which are known to be the most common operations in practice \cite{li2019reduce}. Due to the limited trit-width for denoting an embedded immediate, there could be extra overheads to realizing full-length (9-trit) constant values. Instead of utilizing a series of the shift-and-addition process to store a 5-trit immediate value initialized by a \emph{load immediate} (LI) instruction, we adopt a special I-type instruction named \emph{load upper immediate} (LUI), which is introduced at the RISC-type processors for making a large-sized constant value \cite{RISC-V, yiu2015definitive}. As a result, the ART-9 ISA offers an acceptable flexibility to use wide ranges of immediate values, suitable for the resource-limited processing environments. Besides the logical/arithmetic instructions, it is also required to define the branch-related instructions changing the PC value, which is denoted as B-type instructions in Table I. In the proposed ART-9 cores, we introduce four B-type instructions including two conditional branch operations associated with the PC-relative addressing, which are referred to as BEQ and BNE as shown in Table I. To utilize these conditional operations, as described earlier, we preset the LST of TRF[Tb] in BEQ or BNE by using a COMP instruction, so that a 1-trit B value in BEQ or BNE is compared to check the branch-taken condition. In addition, we define two unconditional jump-and-link instructions (JAL and JALR), which are mainly used for the subroutine calls. Adopting the PC-relative addressing, similar to the conditional branches, the JAL instruction uses the PC value as a base address added by a 5-trit immediate. On the other hand, by using the JALR instruction, we can use the stored 9-trit value in TRF to set the base address with a small-sized 3-trit immediate, allowing more long-range jumps. As depicted in Table I, note that this base-register addressing is also used to access TDM with M-type load/store instructions, reducing the hardware complexity with the shared datapath. \subsection{5-stage Pipelined ART-9 Architecture} To support the proposed ART-9 ISA efficiently, we develop in this work a simple but efficient pipelined architecture, which is used for input descriptions of the proposed hardware-level evaluation framework. As shown in Fig. 4, similar to the lightweight RISC-type designs \cite{schuiki2020stream}, there are five stages for fetching the instruction from TIM (IF), decoding the fetched instruction (ID), executing the arithmetic/logical operations (EX), accessing the TDM (MEM), and updating the result to TRF (WB). The ternary pipelined registers are newly developed to keep the results from each stage, making a balanced pipelined processing. We also introduce the synchronous single-port TIM and TDM designs for reducing the memory-accessing latency, where the TRF in this work supports two asynchronous read ports and one synchronous write port. The ternary arithmetic logic unit (TALU) in EX stage is specialized to perform various operations depending on the control signals from main decoder in ID stage. In the pipelined ART-9 core, the hazard detection unit (HDU) in ID stage compares the adjacent instructions to determine the generation of hardware-level stall controls at the run time. For reducing the number of unwanted stalls as many as possible, we actively apply the forwarding multiplexers to get the correct 9-trit inputs at TALU, solving ALU-use data hazards. To minimize the number of stalls from B-type instructions causing control hazards, the pipelined ART-9 processor utilizes the dedicated branch-target calculator as well as the condition checker in ID stage, directly forwarding the calculated address to update the PC register. For checking the branch-taken conditions, in addition, forwarding one-trit values successfully mitigates the long and complex datapath starting from TRF, still allowing one-cycle stall after B-type instructions without increasing the overall critical delay. As a result, we only observe the hardware-inserted stall cycles when there exist load-use data hazards and taken branches. After detecting the stall insertion case, the main decoder at ID stage generates a stall control signal, which will be used for selecting the no-operation (NOP) at the next ID stage as shown in Fig. 4. Without introducing a dedicated NOP encoding, note that the proposed ART-9 ISA uses an ADDI instruction to denote the NOP operation with a zero-valued immediate. \begin{figure} [!t] \centering \includegraphics[scale=1.0]{fig3.eps} \caption{The number of memory cells for storing benchmark programs.} \label{fig.fig5} \end{figure} \section{Evaluation and Implementation Results} \subsection{Benchmark Evaluations} By using the proposed compiling framework, targeting the ART-9 ISA shown in Table I, we designed several ternary benchmark programs including the general computing algorithms; bubble sort, general matrix multiplication (GEMM), and sobel filter \cite{wang2012compression,zulehner2019matrix}. In addition, for the first time, a dhrystone benchmark is also described with the ternary instructions by converting the existing dhrystone code of the RV-32I ISA, which is popularly used for evaluating the computing performance of general-purposed CPU cores \cite{york2002benchmarking}. Fig. 5 depicts the effectiveness of the proposed ART-9 ISA by evaluating the required memory size for storing each benchmark program, showing that the proposed software-level framework offers acceptable assembly codes compared to the binary versions. Note that we counted the number of memory cells for this comparison, as the ternary instructions necessitate the dedicated ternary memory where a storing cell can keep up to three different charge distributions \cite{choi2021design}. Although we developed a simple 9-trit ISA including only 24 instructions, it is clear that the proposed ART-9 processor requires a much smaller memory size when compared to the binary counterparts; RV-32I using 32-bit instructions \cite{RISC-V} and ARMv6M with 16-bit instructions \cite{yiu2015definitive}. If we consider implementation results of dhrystone codes, due to the short-length ternary instructions associated with the efficient software-level framework, for example, our ART-9 core reduces the number of required memory cells by 54\% and 17\% when compared to the RV-32I \cite{RISC-V} and ARMv6M \cite{yiu2015definitive} processors, respectively. In other words, there exist reasonable benefits of exploiting the ternary number systems, which can reduce the memory overheads while providing a similar amount of flexibility to binary ISAs with long-length instructions. \begin{table}[!t] \renewcommand{\arraystretch}{1.3} \renewcommand{\tabcolsep}{1.1mm} \centering \caption{Simulation Results of Dhrystone Benchmark} \label{table:functions} \input{table3.tex} \end{table} \begin{table}[!t] \renewcommand{\arraystretch}{1.3} \renewcommand{\tabcolsep}{1.1mm} \centering \caption{Processing Cycles for Different Test Programs} \label{table:functions3} \input{temp5.tex} \end{table} \subsection{Hardware-level Evaluation Results} Table II precisely shows evaluation results of the cycle-accurate simulator of different RISC-based processors running the dhrystone benchmark. Note that our ART-9 core achieves 0.42 DMIPS/MHz by utilizing only 24 instructions, whereas the fully-optimized VexRiscv \cite{VexRiscv} and PicoRV32 \cite{PicoRV32} processor provides 0.65 and 0.31 DMIPS/MHz with more instructions and the dedicated multiplier, respectively. Utilizing the optimized codes from the proposed compiling frameworks, the prototype ART-9 core can be designed with the comparable processing speed and much smaller size of memory cells. In addition, Table III also shows that the proposed compiling framework efficiently optimizes the number of instructions for the other benchmarks. As it is considered that the memory in general dominates the overall system complexity, the prototype ART-9 core offers the low-complexity computing platform even compared to the recent lightweight PicoRV32 processor with non-pipelined architecture. In other words, the optimized ART-9 ISA and processor, which utilize the proposed frameworks, successfully offer a reasonable solution achieving both the fast computing and the low hardware-cost, presenting the fully-functional processor design in the ternary domain. Using the proposed gate-level analyzer, we finally present implementation results of ART-9 prototypes. For the simplified 32nm CNTFET ternary models without considering the parasitic capacitance \cite{kim2020logic}, we first estimated the gate-level costs of the 5-stage pipelined core as shown in Table IV. The datapath of ART-9 core only required 652 standard ternary gates, consuming 42.7 $\mu$W when the operating voltage is set to 0.9 V. According to the dhrystone result shown in Table II, the CNTFET-based ART-9 core achieves $3.06 \times 10^6$ DMIPS/W, showing that the emerging ternary device leads to the low-power microprocessor, even superior to the near-threshold ARM Cortex-M3 design requiring $3.9 \times 10^3$ DMIPS/W \cite{dreslinski2013centip3de}. \begin{table}[!t] \renewcommand{\arraystretch}{1.3} \renewcommand{\tabcolsep}{2mm} \centering \caption{Implementation Results using CNTFET Ternary Gates} \label{table:functions4} \input{table6.tex} \end{table} \begin{table}[!t] \renewcommand{\arraystretch}{1.3} \renewcommand{\tabcolsep}{2mm} \centering \caption{Implementation Results using FPGA-based Ternary Logics} \label{table:functions5} \input{table4.tex} \end{table} In order to validate the proposed ternary processor, we also implemented the ART-9 core in the FPGA-based verification platform. For the practical implementation, all the ternary-based building blocks are emulated with the binary modules, adopting the binary-encoded ternary number system\cite{frieder1975algorithms}. Table V summarizes the implementation results of the binary-encoded ART-9 core, which utilizes only few hardware resources of Intel Stratix-V FPGA at the operating frequency of 150 MHz. Targeting the dhrystone benchmark, the FPGA-based ART-9 core achieves 57.8 DMIPS/W by consuming 1.09W including two binary-encoded ternary memories. As a result, the proposed frameworks successfully opens the preliminary results for realizing the ternary-based processor, which can be easily mapped to the future emerging ternary devices for allowing the extreme-low-power computing. \section{Conclusion} In this paper, we have proposed several designs and evaluation frameworks for developing ternary microprocessors, which are verified by the lightweight RISC-based ternary processor with 9-trit datapath. Based on the balanced ternary number system, the proposed software-level framework efficiently supports a systematic way to construct assembly codes for the given ternary ISA. Accepting the architecture-aware descriptions as well as the target technology information, the hardware-level framework is then followed to estimate several implementation-aware metrics, reducing the overall design overheads in the ternary number system. Based on the proposed frameworks, the fully-functional ART-9 microprocessor is developed and verified at different emerging technologies, offering attractive design methods for ternary processors. \bibliographystyle{IEEEtran}
{'timestamp': '2021-11-16T02:27:35', 'yymm': '2111', 'arxiv_id': '2111.07584', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07584'}
arxiv
\section{Introduction} In recent years, with the increasing use of mobile payment, online banking, and other applications, a large number of smart devices are growing exponentially \cite{chugh2018fingerprint,liu2021one,maltoni2009handbook,marcel2014handbook}. Due to the security requirements, more and more smart devices tend to use Automated Fingerprint Recognition Systems for personal authentication \cite{liu2021one}. However, AFRSs are vulnerable to malicious attacks, such as 2D or 3D artificial fingerprints made of gelatin, silicone, etc. \cite{liu2019high,liu2021one,chugh2017fingerprint,arora2016design,arora2017gold,engelsma2018universal}. To ensure that the user has a secure environment against presentation attacks (PA), lots of PAD methods have been proposed to solve this problem \cite{goicoechea2016evaluation,chugh2019oct}. Meanwhile, to deal with the threat and promote anti-spoofing techniques, a series of fingerprint LivDet competitions have been held since 2009 \cite{ghiani2017review}. Many public datasets e.g. LivDet 2011, LivDet 2013, LivDet 2015, LivDet 2017 et.al are available to evaluate the performance of fingerprint PAD \cite{ghiani2017review,7358776,mura2018livdet}. Generally, PAD methods can often be divided into two categories, i.e. hardware and software based approaches \cite{chugh2019oct,marasco2014survey}. For hardware approaches, special sensors such as imaging technologies based on multispectral, short-wave infrared and, optical coherent tomography (OCT), have been developed to extract live features like odor, blood flow and, heartbeat to discriminate the live samples from spoof samples \cite{robison2019system,tolosana2018towards,tolosana2019biometric,moolla2019optical,baldisserra2006fake,nixon2004novel,reddy2008new,liu2019high,agassy2019liveness,liu2021one,liu2020flexible,engelsma2018raspireader}. For instance, a spectroscopy-based device proposed by Nixon et al. \cite{nixon2004novel} can obtain the spectral features of the fingertip, which has been proven to effectively distinguish between spoof and live fingertip. Reddy et al. \cite{reddy2008new} used a pulse-oximetry-based device to capture the percentage of oxygen in the blood and the heart pulse rate for live detection. OCT devices were applied by Liu et al. \cite{liu2019high} to collect depth-double-peak features and sub-single-peak features of fingerprint, which achieved 100$\%$ accuracy over four types of artificial fingerprints. Ultrasonic fingerprint sensors were used by Agassy et al. \cite{agassy2019liveness} to determine whether the finger is a spoof fingertip or not. Liu et al. \cite{liu2021one} proposed a One-Class framework for PAD using OCT. As only bonafide is required for training, this method not only has better generalization ability but also alleviates the data dependence problem. However, the aforementioned methods are sensor-dependent and they require additional hardware devices such as OCT-based devices and Raspireader \cite{liu2020flexible,engelsma2018raspireader}. The expensive hardware costs limit the widespread usage of these approaches. In contrast, software-based methods work without extra hardware devices. They can also be divided into two categories: the traditional PAD methods and the CNN-based PAD methods. Traditional methods distinguish spoof from live fingerprints by extracting hand-crafted features such as anatomical features (e.g. the locations and distribution of core), physiological features (e.g. perspiration and ridge distortion), and texture based features, from the fingerprint images \cite{schuckers2017fingerprint,jia2007new,antonelli2006fake,xia2018novel}. For example, encoding skin distortion information, Fractional Fourier transforms and curvelet transform-based method are all effective methods adopted to extract hand-crafted features to discriminate live and spoof fingerprints \cite{antonelli2006fake,lee2009fake,nikam2008fingerprint}. However, these methods are sensitive to "noise", so they have a poor generalization performance \cite{liu2021fingerprint}. In addition, feature generators need to be manually designed for different tasks \cite{nogueira2016fingerprint}. \begin{figure}[!] \centering \includegraphics[scale=0.49]{img/liveAndSpoof.pdf} \caption{The samples of live features and spoof features on fingerprint images. The images in the first row represent the spoof fingerprint and the corresponding live and spoof features. The images in the second row represent the spoof fingerprint and the corresponding live and spoof features. The second column represents the original image. The patches in the green box represent the live features of the original image and the patches in the red box represent the spoof features of the original image.} \label{fig:liveAndSpoof} \end{figure} With the development of computer vision, CNN has begun to be widely used in fingerprint PAD. CNN-based methods are learning-based and the convolutional layer with pooling layer in CNN can automatically extract features of different scales. Compared with traditional methods, CNN-based methods reduce human intervention and make feature extraction simple because there is no need to manually design feature generators for specific tasks \cite{nogueira2016fingerprint}. CNN-based methods outperform the solutions using hand-crafted features by a wide margin \cite{menotti2015deep,nogueira2016fingerprint,chugh2018fingerprint,7358776}. Typically, Nogueira et al. \cite{nogueira2016fingerprint} pre-train deep CNNs for the task of object recognition and then fine-tune the CNN for fingerprint PAD. This is a global based method and the input of the network is the whole image. VGG and AlexNet have been successfully applied for fingerprint PAD via transfer learning, which achieved better results than randomly initialized weights in LivDet 2015 \cite{7358776}. Chugh et al. \cite{chugh2018fingerprint} proposed a deep convolutional neural network based method. In their method, they utilized fingerprint prior knowledge by extracting local patches centered and aligned using minutiae to train the MobileNet-v1 CNN model. The above-mentioned methods improved the performance of fingerprint PAD, but they also raise new problems. One of the major limitations of the above two methods is their poor generalization performance against sensors that are unknown during training. Both of the two methods achieved good accuracy when the sensors of the training set and the testing set are the same. However, they did not get a good performance when the sensors in the training set and testing set are different. In the method proposed by Nogueira et al. \cite{nogueira2016fingerprint}, the Average Classification Error (ACE) is as high as 25.28\% when the type of sensor used for testing is different from the one used in training. Similarly, in the method proposed by Chugh et al. \cite{chugh2018fingerprint}, the ACE is higher than 25\% when the training set is Biometrika 2011 and the testing set is ItalData 2011 or vice versa. In order to improve the poor generalization performance against different sensors. Chugh et al. \cite{chugh2020fingerprint} proposed a novel style-transfer based method to improve both the cross-material and cross-sensor generalization performance of fingerprint PAD. They transferred the style characteristics between fingerprint images of known materials with the goal of synthesizing fingerprint images corresponding to unknown materials. In this method, they leveraged centered and aligned minutiae-based prior knowledge to propose a style-transfer-based wrapper, which is used to transfer the style characteristics of known fingerprint materials. And then the CNN was supervised to learn generative-noise invariant features to improve the generalization performance. This method based on data augmentation, which increased the ACE of Slim-ResCNN and FSB from 94.01\%, 95.44\% to 95.37\%, 95.88\%, respectively \cite{zhang2019slim,chugh2018fingerprint,chugh2020fingerprint}. Although this method had improved the average cross-sensor spoof detection performance, it needs images from the target material or target sensor to synthesize new images, which may not be accessible \cite{liu2021fingerprint}. Meanwhile, they used patches as input to synthesis style-transferred data. Using patches as input not only leads to the information loss of other regions but also the relative spatial position. Subsequently, Liu et al. \cite{liu2021fingerprint} proposed a global-local model based PAD method to overcome the above-mentioned limitations to some extent. In this method, no images of target material or target sensor appear in the training set, and they proposed a rethinking module to connect a global and a local module. The final spoof score is calculated by averaging the global and local spoof scores. This method achieved an average classification error of 2.28\% in cross-sensor settings. However, this method is based on ensemble learning, which uses two models for training and finally combines the two models by calculating the average score. This multi-model method requires the integration of multiple models and makes training complicated and time-consuming at the same time. Algorithms achieving good performance using global-local features may not be suitable for deployment conditions where the decision needs to be made quickly. Meanwhile, this method also used the heat maps in the local module and found that there exist some discriminative regions for PAD, but they did not explore further about this phenomenon. \begin{figure*}[!] \centering \includegraphics[scale=0.60]{img/pipeline.pdf} \caption{An overview of the proposed fingerprint PAD method(CFD-PAD) based on channel-wise denoising.} \label{fig:pipeline} \end{figure*} Based on the above considerations, we further analyzed the essence of the deep learning based method for fingerprint PAD and found an interesting phenomenon. Regardless of whether the input fingerprint images are live or spoof, they contain both live and spoof features when the network makes predictions for fingerprint PAD. Grad-CAM \cite{selvaraju2017grad} is used to locate the regions of interest and visualize the heat map in a fingerprint image. The features which can activate the heat map in a fingerprint image can be called live features. And then we reverse the heat map and now we call those features which can activate the reversed heat map spoof features. Correspondingly, we deem the patches which have the same labels with original images as discriminative regions while the patches that have different labels with original images can be regarded as "noise" regions. As shown in Fig \ref{fig:liveAndSpoof}, whether the original image is a live sample or spoof sample, it contains abundant live and spoof features. The patches framed by the green line are live features and the patches framed by the red line are spoof features. If the input sample is a live image, the discriminative regions contain a lot of live features while the “noise” regions contain a lot of spoof features. In contrast, the discriminative regions contain a lot of spoof features while the "noise" regions contain a lot of live features if the input sample is a spoof fingerprint image. Whether it is a live image or a spoof image, the discriminative regions and "noise" regions exist in one fingerprint image simultaneously, which proves that there exists a lot of "noise" in a fingerprint image. For one original image, when the network utilizes some features to make predictions, there exist some "noises" that may interfere with the network. The same situation appears in the channels of a feature map. The feature map contains a large number of feature channels and also contains a large number of "noise" channels. Thus, we propose a novel fingerprint PAD method based on channel-wise feature denoising in this paper. Feature denoising is a common method in computer vision. Traditional denoising methods often denoise through image analysis and modeling \cite{brooks2019unprocessing}. Many classic methods such as anisotropic diffusion, total variation denoising et.al, use hand-engineered algorithms to recover a clean signal from noise input under the assumption that both signal and noise exhibit particular statistical regularities \cite{perona1990scale,rudin1992nonlinear,brooks2019unprocessing,zhang2017beyond}. The traditional denoising method is simple and effective but the parametric models limited their capacity and expressiveness \cite{brooks2019unprocessing}. However, the essence of the current feature denoising in the deep learning based method is to suppress the "noise" in the feature map to make the responses focus on visually meaningful regions \cite{xie2019feature}. For instance, in the field of adversarial attack, Xie et al. \cite{xie2019feature} found that adversarial perturbations on images lead to "noise" in the features constructed by convolutional networks. Thus, they developed new network architectures that increase adversarial robustness by performing feature denoising. Specifically, the networks contain blocks that denoise the features using non-local means or other filters. The feature denoising networks substantially improve the adversarial robustness in both white-box and black-box attack settings. Similar to feature denoising, attention is another field in computer vision \cite{vaswani2017attention,hu2018squeeze,fu2019dual,chaudhari2019attentive,xu2015show}. The attention model tends to focus selectively on some important parts of the image while ignoring other irrelevant parts\cite{chaudhari2019attentive,xu2015show}. Fu et al. \cite{fu2019dual} proposed a novel Dual Attention Network (DANet) with a self-attention mechanism to enhance the discriminant ability of feature representations for scene segmentation. The aforementioned studies show that the denoising strategy is crucial for computer vision and has already been applied in different tasks successfully. However, the utilization of denoising strategy in the classification task, especially in PAD has rarely been discussed. In this paper, for the time first, we to employ the denoising strategy to improve the generalization ability of fingerprint PAD. Fig. \ref{fig:pipeline} shows the flowchart of the proposed method. The training stage contains three parts: a) extracting "noise" channels from feature maps, b) suppressing those selected "noise" channels in the feature maps to avoid interference, c) designing PA-Adaption loss to align the feature domain of fingerprint. Given an input image, the model firstly evaluates the importance of each channel in the feature map to find those "noise" channels. Those "noise" channels correspond to "noise" regions with abundant "noise" features. And then we minimize the interference of "noise" regions by suppressing the "noise" channels. Finally, to alter the feature distribution of different sensors of different materials, we design a PA-Adaption loss to align the feature domain of fingerprint by pulling all the live fingerprints close but pushing the spoof ones of different materials or sensors apart. In this paper, we propose a novel fingerprint PAD method based on channel-wise feature denoising. Unlike other methods, we are the first to propose the "noise" regions in fingerprint PAD. We successfully found those channels that correspond to "noise" regions and remove the interference of these "noise" completely. Experimental results show that the proposed method is efficient and time-saving, which can significantly improve the performance of PAD, and outperform the state-of-the-art methods in cross-sensor and cross-material settings. The main contributions of this paper are summarized as follows. \begin{itemize} \item[$\bullet$] A channel-wise feature denoising model is first proposed for fingerprint PAD in this paper. By filtering the redundant information or “noise” regions on the feature map, the fingerprint PAD performance can be significantly improved. \item[$\bullet$] An effective method to evaluate each channel and suppress the propagation of “noise” channels is proposed. By weighting the importance of each channel, “noise” channels can be suppressed. \item[$\bullet$] A new loss function that alters the feature distribution of different sensors or different materials is designed. A PA-Adaption loss is designed to align the feature domain of fingerprint by pulling all the live fingerprints close while pushing the spoof ones of different materials or sensors apart. \item[$\bullet$] Experimental results carried on LivDet 2017 show that the proposed CFD-PAD can achieve an Average Classification Error (ACE) of 2.53\% and a True Detection Rate (TDR) of 93.83\% when the False Detection Rate (FDR) equals to 1.0\% in the case of cross-material. In the case of cross-sensor, our proposed method achieves 19.80\% ACE and 32.32\% True Detection Rate when the False Detection Rate equals to 1.0\%. Meanwhile, our method is based on a single lightweight model, which is time-saving and suitable for deployment conditions. \end{itemize} \section{PROPOSED APPROACH} As the overview shown in Fig. \ref{fig:pipeline}, our method, denoted as CFD-PAD, applies a channel-wise denoising model for PAD. The proposed method includes three stages in the training process, i.e., evaluating the importance of each channel, suppressing the propagation of "noise" channels, and aligning channel-wise domains. In the first stage, a channel distance array is generated to measure the importance of each channel in the feature map. In the second stage, we use the channel distance array to suppress the propagation of the "noise" channels. In the last stage, PA-Adaption loss is employed to push the samples apart from all samples of different materials or sensors. In this section, we first gave the system framework of the proposed method and then detailly introduced these three stages one by one. \begin{algorithm}[!] \caption{Channel-wise Feature Denoising PAD Method (CFD-PAD)} \label{alg::cfd_pad} \begin{algorithmic} \Require \\ Training Set of Images:$X_{train}$=\{$x_{1}$,$\cdots$,$x_{i}$,$\cdots$,$x_{n}$\}; \\ Groundtruth of $X_{train}$:$Y_{train}$=\{$y_1$,$\cdots$,$y_i$,$\cdots$,$y_n$\}; \\ Attack type of $X_{train}$:$A_{train}$=\{$a_1$,$\cdots$,$a_i$,$\cdots$,$a_n$\}; \\ Feature Generator: G(·) with learning parameters $\theta_g$; \\ Feature Embedding: E(·) with learning parameters $\theta_e$; \\ Classifier: C(·) with learning parameters $\theta_c$; \\ Loss Function: Cross-entropy Loss function $\mathcal{L}_{c}$(·,·) and PA-Adaption Loss function $\mathcal{L}_{t}$(·,·); \\ Training Epoch Number: $e$; \\ Learning Rate: $\alpha$; \\ Channel's number of $g_t$: $c$ \\ channel distance array: $dis$ \Ensure \end{algorithmic} \begin{algorithmic}[1] \State Initialize $\theta_g$, $\theta_e$, $\theta_c$ from the model pretrained on ImageNet. \State Set all the values in array $dis$ to 0 \For {$j=1$ to $e$} \For{ $x \in X_{train}$ } \State $f \gets$ $G(x)$; \State $e \gets$ $E(f)$; \State $o \gets$ $C(e)$; \State $r \gets$ $softmax(o)$; \State // Evaluate the importance of each channel \For {$i=1$ to $c$} \State $f_{i}^{'} \gets$ Suppress the $i$-th channel of $f$; \State $e_{i}^{'} \gets$ $E(f_{i}^{'})$; \State $o_{i}^{'} \gets$ $C(e_{i}^{'})$; \State $r_{i}^{'} \gets$ $softmax(o_{i}^{'})$; \State $dis[i] \gets$ $dis[i]$ + $abs(a$-$a_i)$; \EndFor \State // Suppress the propagation of "noise" channels \For {$i=1$ to $c$} \If{$dis[i]$ is in $maxk(dis)$} \State $f^{''}[i] \gets$ $f^{'}[i]$ \Else \State $f^{''}[i] \gets$ 0 \EndIf \EndFor \State $e^{''} \gets$ $E(f^{''})$; \State $o^{''} \gets$ $C(e^{''})$; \State $Gradient_{c1} \gets \bigtriangledown_{\theta_g,\theta_c} \mathcal{L}_{c}(o,y)$ \State // using PA-Adaption loss \State $Gradient_{t} \gets \bigtriangledown_{\theta_g,\theta_c} \mathcal{L}_{t}(e^{''},a)$ \State $Gradient_{c2} \gets \bigtriangledown_{\theta_g,\theta_c} \mathcal{L}_{c}(o^{''},y)$ \State $Gradient \gets \lambda_1 Gradient_{t} + \lambda_2 Gradient_{c1} + \lambda_3 Gradient_{c2}$ \State Update $\theta_g \gets$ $\theta_g-$ $\alpha * Gradient$ \State Update $\theta_e \gets$ $\theta_e-$ $\alpha * Gradient$ \State Update $\theta_c \gets$ $\theta_c-$ $\alpha * Gradient$ \EndFor \EndFor \end{algorithmic} \end{algorithm} \begin{figure*}[!] \centering \includegraphics[scale=0.60]{img/weightChannel.pdf} \caption{Illustration of weighting the importance of each channel in the feature map $f$. The feature maps $f^{'}$ of the gray background is derived from suppressing each channel in the feature map $f$. And the importance of each channel can be obtained by calculating the distance between $r$ and each element in $r_{i}^{'}$ ($i$ is range from $1$ to $c$). The output $r^{'}_{i}$ is derived after $f^{'}_{i}$ passes through the $E(\cdot)$ and $C(\cdot)$.} \label{fig:weightChannel} \end{figure*} \subsection{System Framework} To better describe our method, we first set up the basic notations used in this paper: ($x$, $y$) denotes a data sample, $x$ is an input image and the corresponding label is $y$. $G(\cdot)$ denotes the feature generator module, $E(\cdot)$ denotes the feature embedding module, $C(\cdot)$ denotes the classifier and $\theta_g$, $\theta_e$, $\theta_c$ are their parameters respectively. We use $f$ to denote the feature map output by $G(\cdot)$ and $e$ denotes the feature map output by $E(\cdot)$. So we have the follow equations: \begin{equation} g = G(x) \label{eq.g} \end{equation} \begin{equation} e = E(g) \label{eq.e} \end{equation} \begin{equation} o = C(e) \label{eq.o} \end{equation} where $o$ denotes the prediction result of the network and we can get $r$ when using the softmax function to normalize $o$, as formulated in Eq.(\ref{eq.r}). \begin{equation} r = softmax(o) \label{eq.r} \end{equation} The system mainly consists of three steps during training, as shown in Fig.\ref{fig:pipeline}, i.e., importance evaluation of each channel, propagation suppression of "noise" channels in the feature map, and domain alignment in channel-wise. As detailed in the Algorithm. \ref{alg::cfd_pad}, input an image $x$, we get a feature map $f$ from $G(\cdot)$ by Eq.(\ref{eq.g}) in the first step. And then a channel distance array $dis$ is generated according to the importance of each channel in the feature map $f$. In the second step, according to $dis$, we can divide channels into important channels and "noise" channels. And then we can get $f^{''}$ after suppressing those "noise" channels in $f$ in the channel suppression module by: \begin{equation} f^{''}[i] = \begin{cases} f[i], & dis[i] \in maxk(dis) \\ 0, & dis[i] \notin maxk(dis) \\ \end{cases} \label{eq.dn} \end{equation} where $i$ denotes the i-th channel in the feature map and $maxk(\cdot)$ denotes the top k values in an array. In the channel-wise domain alignment step, $e^{''}$ which derived by Eq.(\ref{eq.e}) is put to the PA-Adpation loss for gradient updation. \subsection{Importance Calculation For Each Channel} The process of calculating the importance of each channel can guide the network to distinguish between important channels and "noise" channels in $f$. The detailed description of this process is shown in Figure \ref{fig:weightChannel}. Given an input image $x$, we first pass it into the feature generator $G(\cdot)$ to gain a feature map $f$. The derived feature map $f$ has $c$ channels and then we successively zero the value of channel $i$ (range from $1$ to $c$) in the feature map $f$ but remain unchanged of other channels. So we obtain $c$ new feature maps $\{ f^{'}_{1}$, $f^{'}_{2}$, ... ,$f^{'}_{c}$ \}. Next, we feed the original feature map $f$ and all $c$ new feature maps $\{ f^{'}_{1}$, $f^{'}_{2}$, ... ,$f^{'}_{c}$ \} into the feature embedding layer $E(\cdot)$, the classification layer $C(\cdot)$ and the softmax layer, and thus get corresponding representation $r$, $\{r^{'}_{1}$, $r^{'}_{2}$, ..., $r^{'}_{c}\}$. Finally, we can get the channel distance array $dis$ by calculating the distance of representation $r$ and $r^{'}_i$ ($i$ is range from $1$ to $c$), where $r$ is a two-tuple matrix and $r$ = \{$a$, $b$\}. Since PAD is a binary classification task such as live and spoof, $a$ and $b$ in $r$ denote the probability of live and spoof fingerprints respectively. The value of $a$ and $b$ are all range from 0 to 1, and the sum of $a$ and $b$ are 1. Therefore, the distance array $dis$ can be calculated by: \begin{equation} dis^{b}[i] = dis^{b-1}[i] + abs(a - a_i) \end{equation} where $ dis^{b}[i] $ indicates the importance of the i-th channel in $f$ and $b$ denotes the batch number. Since the calculation of $dis$ is a cumulative process, $dis^{b-1}[i]$ denotes the calculation result of the top $(b-1)$ batch. When training starts, that is, $b=1$, and the value of $dis^{b-1}[i]$ is 0. The value $abs(a - a_i)$ describes the change of the network's output caused by suppressing the i-th channel of $f$. If the channel $i$ is indeed important, the corresponding representation $r^{'}_{i}$ derived from $E(\cdot)$ and $C(\cdot)$ will change a lot compare with $r$. The distance $abs(a - a_i)$ between representation $r$ and $r^{'}_{i}$ is a dynamic value. The larger the value of $abs(a - a_i)$, the suppression of the i-th channel has a more significant influence on the result, which also indicates that this channel belongs to important channels. Inversely, the small value of $abs(a - a_i)$ means that the network output is not sensitive to suppressing the i-th channel, which illustrates that the i-th channel is a "noise" channel. Since evaluating the importance of each channel is a dynamic accumulation process, the importance of each channel in the e-th batch is jointly determined by the current batch and the previous $(b-1)$ batch together. We calculate the importance of each channel in $f$ to get $c$ values $ dis = \{ dis[1], dis[2], ……, dis[k], ……, dis[c] \} $ and we sort $dis$ by their value. More formally, $maxk(\cdot)$ function means the top $k$ values in an array and we select the top $k$ channels as important channels. Correspondingly, the rest $(c-k)$ channels belong to "noise" channels. In addition, $dis$ is a dynamically accumulated channel distance array, we accumulate the distance between $r$ and $r^{'}_{i}$ ( $i$ is range from $0$ to $c$) in every batch. \subsection{Channels Suppression} Since all the channels in $f$ are divided into important channels and "noise" channels according to $dis$, the process of channels suppression is to suppress the propagation of "noise" channels and keep important channels unchanged. After suppressing those "noise" channels in $f$ we can get $f^{''}$. The channel distance array $dis$ indicates the importance of each channel in the feature map $f$. $dis$ is an array containing $c$ elements, each element in $dis$ represents the importance of the corresponding channel in $f$. Using $maxk()$ to select the top-k value in $dis$ and the index of the k values is the number id of important channels in $f$. While the remaining belong to "noise" channels. There exist abundant discriminative features in important channels and "noise" features in "noise" channels. To eliminate the reflection of "noise" features, we set 0 to those "noise" channels in $f$, while remain unchanged of other important channels, as list in Eq(\ref{eq.dn}). Since the corresponding gradient will disappear after setting 0 to those "noise" channels, which achieve the goal of denoising. We get $f^{''}$ after denoising the feature map $f$ and the denoised feature map $f^{''}$ will replace $f$ to propagate in the network. When $f^{''}$ passing through $E(\cdot)$ and $C(\cdot)$, we can get $e^{''}$ and $o^{''}$ by Eq.(\ref{eq.e}) and Eq.(\ref{eq.o}). \begin{table*}[] \centering \caption{SPECIFICATION FOR BACKBONE: MOBILENET V2 ARCHITECTURE \cite{2018MobileNetV2}} \label{fig.mobilenetv2} \setlength\tabcolsep{30pt} \large \resizebox{.98\textwidth}{!}{% \begin{tabular}{c|c|c|c|c|c} \hline Input & Operator & Expansion factor & Output-Channel & Repeated times & Stride \\ \hline 224 × 224 × 3 & conv2d & - & 32 & 1 & 2 \\ 112 × 112 × 32 & bottleneck & 1 & 16 & 1 & 1 \\ 112 × 112 × 16 & bottleneck & 6 & 24 & 2 & 2 \\ 56 × 56 × 24 & bottleneck & 6 & 32 & 3 & 2 \\ 28 × 28 × 32 & bottleneck & 6 & 64 & 4 & 2 \\ 14 × 14 × 64 & bottleneck & 6 & 96 & 3 & 1 \\ 14 × 14 × 96$ ^*$ & bottleneck & 6 & 160 & 3 & 2 \\ 7 × 7 × 160 & bottleneck & 6 & 320 & 1 & 1 \\ 7 × 7 × 320 & conv2d 1×1 & - & 1280 & 1 & 1 \\ 7 × 7 × 1280 & avgpool & - & - & 1 & - \\ 1 × 1 × 1280 & conv2d 1×1 & - & 2 & - & \\ \hline \end{tabular}% } \begin{tablenotes} \footnotesize \item[*] \setlength{\parindent}{10em} * The derive feature map $z_t$. \end{tablenotes} \end{table*} \begin{figure*}[!] \centering \includegraphics[scale=0.60]{img/distribution.pdf} \caption{Description of the PA-Adaption loss. The points in different colors represent the feature distribution of live or fake fingerprints of different attack materials or sensors. Left: Different types of fingerprints are distributed in the feature domain randomly and their distribution is irregular before PA-Adaption loss. Right: After PA-Adaption loss, the domains of different spoof fingerprints are separated while the domains of live fingerprints are aggregated. Meanwhile, the live fingerprints are also pulled apart away from all the spoof fingerprints.} \label{fig:distribution} \end{figure*} \subsection{Design of PA-Adaption Loss} Due to the diversity of attack materials and sensors, the distribution discrepancies are much larger among spoof than live fingerprints. Therefore, seeking a generalized feature domain for the spoof fingerprints is difficult and may also affect the classification accuracy for the target domain. In consideration of this, we proposed to align the feature domain of fingerprints by pulling all the live fingerprints close while pushing the spoof ones of different materials or sensors apart. As shown in Fig.\ref{fig:distribution}, the feature domains of live fingerprints and spoof fingerprints of different attack materials or sensors are randomly distributed. Spoof fingerprints of different materials of sensors belong to different classes here. To aggregate the feature domains of different classes of fingerprints respectively, PA-Adaption loss is conducted on the live and spoof fingerprints to achieve the following optimization goals: Firstly, we separate the spoof fingerprints of different feature domains apart; Secondly, we pull apart the spoof fingerprints away from the live fingerprints. The constrain of PA-Adaption loss is given by: \begin{equation} \mathcal{L}_{padp}=max ( || E(f^a) - E(f^p) ||_2^2 - || E(f^a) - E(f^n) ||_2^2 + \alpha, 0 ) \label{eq:triplet} \end{equation} where the anchor $f^a$ and the positive example $f^p$ are all feature maps with the same label, while $f^n$ is the feature map of a negative sample, which has a different label with $f^a$. The $\alpha$ is a margin that is enforced between positive and the negative pairs. $E(\cdot)$ denotes the feature embedding layer, and $f$ denotes a feature map generator by the feature generator $G(\cdot)$. So, equation(\ref{eq:triplet}) can also be written as: \begin{equation} \mathcal{L}_{padp}=max ( || e^a - e^p ||_2^2 - || e^a - e^n ||_2^2 + \alpha, 0 ) \label{eq:triplet2} \end{equation} where $||e^a-e^p||_2^2$ denotes the distance between anchor and positive sample, and $||e^a-e^n||_2^2$ denotes the distance between anchor and negative sample. We minimize this loss to push $||e^a-e^p||_2^2$ to 0 and $||e^a-e^n||_2^2$ to be greater than $||e^a-e^p||_2^2+ \alpha $. As soon as $||e^a-e^p||_2^2+ \alpha < ||e^a-e^n||_2^2$, the loss becomes zero. After PA-Adaption loss, the extracted features of spoof fingerprints are more dispersed than before in the feature domain but the feature domain of live fingerprints is getting aggregated, which achieves good performance for unknown attack materials or sensors. Furthermore, in order to pull all the live fingerprints close but push the spoof ones of different materials or sensors apart, we use $\mathcal{L}_{padp}(e^{''}, a)$ to calculate their PA-Adaption loss for the gradient update. And $a$ is a more fine-grained label compared with $y$. The fine-grained label $a$ not only contains the live or false label of the input sample $x$ but also contains the types of attack sensor or material if $x$ is a spoof sample. $e^{''}$ is a denoised feature map, which is calculated by Eq(\ref{eq.g}), Eq (\ref{eq.e}) and Eq (\ref{eq.dn}). Using the denoised feature map for PA-Adaption loss can force the network less interfered by "noise" channels, which promotes the network to learn a better feature domain for unknown attack materials or sensors. Integrating all things mentioned above together, the objective of the proposed channel-wise feature denoising method for fingerprint PAD is: \begin{equation} \mathcal{L}_{cfd} = \lambda_1 \mathcal{L}_{c}(o, y) + \lambda_2 \mathcal{L}_{padp}(e^{''}, a) + \lambda_3 \mathcal{L}_{c}(o^{''}, y) \end{equation} where $\lambda1$, $\lambda2$ and $\lambda3$ are the balanced parameters and $\mathcal{L}_{c}$ is the cross-entropy loss. \section{EXPERIMENTS AND RESULTS} To evaluate the performance of the proposed method, several experiments were carried on LivDet 2017 \cite{mura2018livdet} in this section, which is one of the most commonly used public datasets for fingerprint PAD. We first introduce the dataset and implementation details in subsection A. And then we show the evaluation metrics and other methods compared with us in subsection B. Subsequently, we prove the effectiveness of the proposed CFD-PAD method in subsection C. Finally, subsection D shows the comparison between our method and other current methods on LivDet 2017. \subsection{Dataset and Implementation Details} Table \ref{tab.livdet2017} presents a summary of the LivDet 2017 dataset. LivDet 2017 dataset is one of the most recent publicly available LivDet datasets, containing over 17,500 fingerprint images captured from three different scanners, namely Green Bit, Orcanthus, and Digital Persona. Unlike other LivDet datasets, the spoof materials in the training set and testing set are completely different. In the training set, the spoof materials are Wood Glud, Ecoflex and, Body Double. In the testing set, the spoof materials are Latex, Gelatine and, Liquid Ecoflex. As shown in Table \ref{tab.livdet2017}, there are about 2200 images for training and 3740 images for testing for each sensor. In the training set and testing set, the number of each attack material is about 400 and 680, respectively. LivDet 2017 is a suitable cross-dataset to evaluate the generalization performance of PAD methods. \begin{table*}[] \centering \caption{SUMMARY OF THE LIVDET 2017 DATASETS \cite{mura2018livdet} } \label{tab.livdet2017} \setlength\tabcolsep{10pt} \huge \resizebox{.98\textwidth}{!}{% \begin{tabular}{c|cc|cc|c|c|c|c|c|c} \hline \multirow{2}{*}{Sensor} & \multicolumn{4}{c|}{Images} & \multirow{2}{*}{Model} & \multirow{2}{*}{Type} & \multirow{2}{*}{Resolution(dpi)} & \multirow{2}{*}{Image Size} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Spoof Material\\ for Training\end{tabular}} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Spoof Material\\ for Testing\end{tabular}} \\ \cline{2-5} & \multicolumn{2}{c|}{Train(Live/Spoof)} & \multicolumn{2}{c|}{Test(Live/Spoof)} & & & & & & \\ \hline GreenBit & 1000 & 1200 & 1700 & 2040 & DactyScan84c & Optical & 500 & 500 × 500 & \multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Wood Glue,\\ Exoflex,\\ Body Double\end{tabular}} & \multirow{3}{*}{\begin{tabular}[c]{@{}c@{}}Gelatine,\\ Liquid Ecoflex,\\ Latex\end{tabular}} \\ \cline{1-9} DigitalPersona & 999 & 1199 & 1700 & 2028 & U.are.U 5160 & Optical & 500 & 252 × 324 & & \\ \cline{1-9} Orcanthus & 1000 & 1200 & 1700 & 2018 & Certis2 Imag & Thermal swipe & 500 & 300 × n & & \\ \hline \end{tabular}% } \end{table*} To promote network to learn non-local features, we use the cut-out module to perform the data pre-processing. Inspired by \cite{devries2017improved}, we randomly select a pixel coordinate within the image as a center point and then place the zero-mask around that location in the training stage. The size of the zero-mask is set to 96×96 and the number of zero-masks is 10. Besides, data augmentation techniques, including horizontal flipping, vertical flipping, and random rotation are adopted to ensure that the trained model is robust to the possible variations in fingerprint images. MobileNet v2 \cite{2018MobileNetV2} pretrained on ImageNet \cite{russakovsky2015imagenet} is used as backbone for the proposed CFD-PAD method. For feature generator $G(\cdot)$, feature embedding $E(\cdot)$, and classifier $C(\cdot)$, they are all substructures of MobileNet v2. As shown in Table \ref{fig.mobilenetv2}, the feature embedding $E(\cdot)$ contains a bottleneck layer and a conv2d 1$\times$1 layer. Compared with the other popular deep networks, MobileNet v2 is particularly suitable for mobile applications. It allows very memory-efficient inference and relies on utilizing standard operations present in all neural frameworks, which is proved to be useful for fingerprint PAD in \cite{8987320}. On the basis of network architecture search (NAS), MobileNet v2 uses a combination of depth-wise separable convolutions \cite{zhang2018shufflenet,howard2017mobilenets,chollet2017xception}, linear bottlenecks, inverted residuals, and information flow interpretation as building blocks. The architecture of linear bottleneck captures the low-dimensional manifold of interest by inserting linear bottleneck layers into the convolutional blocks and uses linear layers to prevent non-linearities from destroying too much information. In the inverted residual, denotes as the bottleneck, Sandler \cite{2018MobileNetV2} et al. use shortcuts directly between the bottlenecks because the bottlenecks contain all the necessary information, while an expansion layer acts merely as an implementation detail that accompanies a non-linear transformation of the tensor. As the specification listed in TABLE \ref{fig.mobilenetv2}, the backbone used in this paper is called MobileNet v2, which consists of 17 bottlenecks, 2 convolutional layers and, 1 average pooling layer. Since the sizes of fingerprint images derived from the various sensors are different, the average pooling layer( i.e. avgpool in TABLE \ref{fig.mobilenetv2} ) is used to handle arbitrary sizes of input fingerprints images. Besides, the last layer of the original architecture, a convolutional layer with 1000-unit output, is replaced by the convolutional layer with a 2-unit output of fingerprint PAD, i.e. live fingerprint and spoof fingerprint. Our implementation is based on the public platform Pytorch \cite{paszke2017automatic}. We use the Adam optimizer for training and the learning rate of the Adam is set to 0.0001. The feature map $f$ that derived after the feature generator is shown in Table \ref{fig.mobilenetv2} marked by $^*$, the shape of $f$ is $(7 \times 7 \times 160)$ if the input $x$ is $(224 \times 224 \times 3)$. The feature map $f$ has a total of 160 channels, and the number of important channels $k$ is set to 30. Our workstation's CPU is 2.8GHz, RAM is 32GB and GPU is NVIDIA TITAN RTX. \subsection{Evaluation Metrics and Comparison Method} To evaluate the performance of the methods, two popular metrics like Average Classification Error (ACE) and True Detection Rate (TDR) @ False Detection Rate (FDR) = 1$\%$ are used. Among them, ACE reflects the classification performance of the method. The smaller the value of ACE, the better the performance of the evaluation method. While TDR@FDR=1$\%$ represents the percentage of PAs able to breach the biometric system security when the reject rate of legitimate users $\le$ 1\%. The larger the value of TDR@FDR=1\%, the better performance the evaluated method achieves. To further demonstrate the performance of our method, we compare it with single model based methods and multiple model based methods. The single model based methods include the winner in LivDet 2017 \cite{mura2018livdet}, and FSB \cite{chugh2018fingerprint}. Similar, we compared our method with multiple model based methods, i.e., FSB + UMG Wrapper \cite{chugh2020fingerprint} and RTK-PAD \cite{liu2021fingerprint}. \begin{table*}[] \caption{Performances of CFD-PAD with or without Each Proposed Module In Terms of ACE and TDR@FDR=1.0\%} \label{tab.ablation} \setlength\tabcolsep{15pt} \huge \resizebox{.98\textwidth}{!}{ \begin{tabular}{cccc|cc|cc|cc|cc} \hline & & & & \multicolumn{8}{c}{LivDet 2017} \\ \cline{5-12} & & & & \multicolumn{2}{c|}{GreenBit} & \multicolumn{2}{c|}{Orcanthus} & \multicolumn{2}{c|}{DigitalPersona} & \multicolumn{2}{c}{Mean} \\ \cline{5-12} \multirow{-3}{*}{Baseline} & \multirow{-3}{*}{\begin{tabular}[c]{@{}c@{}}PA-Adaption\\ Loss\end{tabular}} & \multirow{-3}{*}{\begin{tabular}[c]{@{}c@{}}Channel-wise \\ Feature \\ Denoising\end{tabular}} & \multirow{-3}{*}{\begin{tabular}[c]{@{}c@{}}Channel-wise \\ Feature \\ Regularization\end{tabular}} & ACE(\%) & TDR(\%) & ACE(\%) & TDR(\%) & ACE(\%) & TDR(\%) & ACE(\%) & TDR(\%) \\ \hline $\checkmark$ & $\times$ & $\times$ & $\times$ & 3.54 & 81.67 & 2.94 & 71.46 & 4.83 & 68.64 & 3.77 ± 0.97 & 73.92 ± 6.86 \\ $\checkmark$ & $\checkmark$ & $\times$ & $\times$ & 2.93 & 88.08 & 2.67 & 82.61 & 4.72 & 76.53 & 3.44 ± 1.12 & 82.41 ± 5.78 \\ $\checkmark$ & $\times$ & $\checkmark$ & $\times$ & 3.36 & 86.72 & 2.27 & 84.59 & 4.61 & 71.80 & 3.41 ± 1.17 & 81.04 ± 8.07 \\ $\checkmark$ & $\checkmark$ & $\times$ & $\checkmark$ & 3.00 & 90.81 & 2.60 & 86.67 & 4.79 & 76.33 & 3.46 ± 1.16 & 84.60 ± 7.46 \\ \hline \rowcolor[HTML]{C0C0C0} $\checkmark$ & $\checkmark$ & $\checkmark$ & $\times$ & \textbf{2.59} & \textbf{93.43} & \textbf{1.68} & \textbf{97.32} & \textbf{3.33} & \textbf{90.73} & \textbf{2.53 ± 0.82} & \textbf{93.83 ± 3.31} \\ \hline \end{tabular} } \end{table*} \begin{table*}[] \centering \caption{Performance Comparison between the proposed method and state-of-the-art results reported on LivDet2017 dataset for cross material experiments In Terms of ACE and TDR@FDR=1.0\%} \label{tab.crossmaterial} \setlength\tabcolsep{11pt} \huge \resizebox{.98\textwidth}{!}{% \begin{tabular}{c|clcccc|cccc} \hline & \multicolumn{6}{c|}{Single Model} & \multicolumn{4}{c}{Multiple Model} \\ \cline{2-11} & \multicolumn{2}{c|}{LivDet 2017 Winner \cite{mura2018livdet} } & \multicolumn{2}{c|}{FSB \cite{chugh2018fingerprint}} & \multicolumn{2}{c|}{\cellcolor[HTML]{C0C0C0}CFD-PAD (Ours)} & \multicolumn{2}{c|}{FSB + UMG \cite{chugh2020fingerprint}} & \multicolumn{2}{c}{RTK-PAD \cite{liu2021fingerprint}} \\ \cline{2-11} \multirow{-3}{*}{LivDet 2017} & \multicolumn{2}{c|}{ACE(\%)} & \multicolumn{1}{c|}{ACE(\%)} & \multicolumn{1}{c|}{TDR(\%)} & \cellcolor[HTML]{C0C0C0}ACE(\%) & \cellcolor[HTML]{C0C0C0}TDR(\%) & ACE(\%) & \multicolumn{1}{c|}{TDR(\%)} & ACE(\%) & TDR(\%) \\ \hline GreenBit & \multicolumn{2}{c|}{3.56} & \multicolumn{1}{c|}{3.32} & \multicolumn{1}{c|}{91.07} & \cellcolor[HTML]{C0C0C0}\textbf{2.59} & \cellcolor[HTML]{C0C0C0}\textbf{93.43} & 2.58 & \multicolumn{1}{c|}{92.29} & 1.92 & 96.82 \\ Digital Persona & \multicolumn{2}{c|}{6.29} & \multicolumn{1}{c|}{4.88} & \multicolumn{1}{c|}{62.29} & \cellcolor[HTML]{C0C0C0}\textbf{3.33} & \cellcolor[HTML]{C0C0C0}\textbf{90.73} & 4.80 & \multicolumn{1}{c|}{75.47} & 3.25 & 80.57 \\ Orcanthus & \multicolumn{2}{c|}{4.41} & \multicolumn{1}{c|}{5.49} & \multicolumn{1}{c|}{66.59} & \cellcolor[HTML]{C0C0C0}\textbf{1.68} & \cellcolor[HTML]{C0C0C0}\textbf{97.32} & 4.99 & \multicolumn{1}{c|}{74.45} & 1.67 & 96.18 \\ \hline Mean ± s.d. & \multicolumn{2}{c|}{4.75 ± 1.40} & \multicolumn{1}{c|}{4.56 ± 1.12} & \multicolumn{1}{c|}{73.32 ± 15.52} & \cellcolor[HTML]{C0C0C0}\textbf{2.53 ± 0.82} & \cellcolor[HTML]{C0C0C0}\textbf{93.83 ± 3.31} & 4.12 ± 1.34 & \multicolumn{1}{c|}{80.74 ± 10.02} & 2.28 ± 0.69 & 91.19 ± 7.51 \\ \hline \end{tabular}% } \end{table*} \begin{table*}[] \centering \caption{Performance Comparison between the proposed method and state-of-the-art results reported on LivDet2017 dataset for cross-sensor experiments In Terms of ACE and TDR@FDR=1.0\%} \label{tab.crosssensor} \setlength\tabcolsep{30pt} \huge \resizebox{\textwidth}{!}{% \begin{tabular}{cc|cccccc} \hline \multicolumn{2}{c|}{} & \multicolumn{4}{c|}{Single Model} & \multicolumn{2}{c}{Multiple Model} \\ \cline{3-8} \multicolumn{2}{c|}{\multirow{-2}{*}{LivDet 2017}} & \multicolumn{2}{c|}{FSB \cite{chugh2018fingerprint}} & \multicolumn{2}{c|}{\cellcolor[HTML]{C0C0C0}CFD-PAD(Ours)} & \multicolumn{2}{c}{RPK-PAD \cite{liu2021fingerprint}} \\ \hline Training Sensor & Testing Sensor & ACE(\%) & \multicolumn{1}{c|}{TDR(\%)} & \cellcolor[HTML]{C0C0C0}ACE(\%) & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}TDR(\%)} & ACE(\%) & TDR(\%) \\ \hline GreenBit & Orcanthus & 50.57 & \multicolumn{1}{c|}{0.00} & \cellcolor[HTML]{C0C0C0}\textbf{22.34} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{21.56}} & 30.49 & 20.61 \\ GreenBit & DigitalPersona & 10.63 & \multicolumn{1}{c|}{57.48} & \cellcolor[HTML]{C0C0C0}\textbf{7.03} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{75.05}} & 7.41 & 70.41 \\ Orcanthus & GreenBit & \textbf{30.07} & \multicolumn{1}{c|}{\textbf{8.02}} & \cellcolor[HTML]{C0C0C0}30.92 & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}2.87} & 28.81 & 15.00 \\ Orcanthus & DigitalPersona & 42.01 & \multicolumn{1}{c|}{\textbf{4.97}} & \cellcolor[HTML]{C0C0C0}\textbf{27.44} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}4.78} & 29.19 & 13.26 \\ DigitalPersona & GreenBit & 10.46 & \multicolumn{1}{c|}{57.06} & \cellcolor[HTML]{C0C0C0}\textbf{6.23} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{66.57}} & 6.74 & 70.25 \\ DigitalPersona & Orcanthus & 50.68 & \multicolumn{1}{c|}{0.00} & \cellcolor[HTML]{C0C0C0}\textbf{24.83} & \multicolumn{1}{c|}{\cellcolor[HTML]{C0C0C0}\textbf{23.09}} & 28.55 & 18.68 \\ \hline \multicolumn{2}{c|}{Mean ± s.d.} & 32.40 ± 18.53 & \multicolumn{1}{c|}{21.26 ± 28.06} & \cellcolor[HTML]{C0C0C0}\textbf{19.80 ± 10.59} & \cellcolor[HTML]{C0C0C0}\textbf{32.32 ± 31.07} & 21.87 ± 10.48 & 34.70 ± 25.30 \\ \hline \end{tabular}% } \end{table*} \begin{figure}[!] \centering \includegraphics[scale=0.6]{img/FigAcc.pdf} \caption{Accuracy after removing different channels. The black line in the figure shows the accuracy after removing "noise" features among channels. The red line in the figure shows the accuracy after removing important features among channels.} \label{fig:FigAcc} \end{figure} \subsection{Effectiveness Validation of the Proposed CFD-PAD Method} To verify the effectiveness of our method, we trained a CNN for PAD and derived a feature map at the middle layer of the trained CNN. The derived feature map has a total of 160 channels, and a large number of features extracted from discriminative regions and noise regions are preserved in the feature map. As shown in Fig. \ref{fig:FigAcc}, when some important features or "noise" feature among channels are removed respectively, the accuracy of PAD has become different. The red line in the figure shows the accuracy after removing important features among channels and the black line shows the accuracy after removing "noise" features among channels. When about 20 important features among channels are removed, the accuracy of PAD has dropped from over 90 to less than 80, which decline significantly. After removing nearly 40 important channels, the network can hardly be classified correctly. In contrast, the changes in accuracy for removing "noise" features among channels are quite different. As shown in the black line, the accuracy of removing the first 150 "noise" features among channels does not change significantly. The classification accuracy starts to drop until more than 150 "noise" features among channels are removed. The above experimental results illustrate that there exist "noise" and important features in the feature map simultaneously, which is similar to the "noise" and discriminative regions. The channels in the feature map that contains abundant features can be deemed as important channels, while the remaining are "noise" channels. The discriminative regions correspond to those important channels between points A and B on the red line in Fig \ref{fig:FigAcc}. The important channels are discriminative, they contain abundant features of the fingerprints and have a positive effect on the prediction results of the module. On the contrary, the "noise" channels in Fig \ref{fig:FigAcc}, which corresponds to point A to D on the black line, are similar to the "noise" regions. "Noise" channels contain a lot of invalid and redundant "noise" features which will greatly interfere with the prediction results of the network. Successfully removing the influence of "noise" features may perfectly improve the performance of the model on PAD. \begin{figure*}[!] \centering \includegraphics[scale=0.40]{img/roc.pdf} \caption{ROC curves for the ablation study on fingerprint PAD. PA Loss denotes the PA-Adaption loss, CFD denotes the channel-wise feature denoising and CFR denotes the channel-wise feature regularization.} \label{fig:roc} \end{figure*} We also perform the ablation study to evaluate the cross-material performance gained by each module for different network architectures, i.e., PA-Adaption loss and channel-wise feature denoising on the LivDet 2017. Table \ref{tab.ablation} and Fig. \ref{fig:roc} present the generalization performance of the proposed method when all the training and testing images are captured using the same sensor but the spoof materials in the training and testing set are completely different. Table \ref{tab.ablation} is the ablation study result of our method, it can be seen that the PA-Adaption loss module and channel-wise feature denoising module can improve the performance effectively. To visualize the ablation study, we plot the ROC curves for GreenBit, DigitalPersona, and Orcathus respectively. As shown in Fig. \ref{fig:roc}, the "PA Loss + CFD(Ours)" line achieved the best results in all three cases, which indicates the effectiveness of our proposed method. To quantify the contribution of PA-Adaption loss, we compare the baseline with the results by adding PA-Adaption loss to the baseline. Table \ref{tab.ablation} shows the result after adding the PA-Adaption loss to baseline, ACE decrease from 3.77\% to 3.44\%, and TDR@FDR=1.0\% improve from 73.92\% to 82.41\%. On the contrary, after removing PA-Adaption loss on "Channel-wise Feature Denoising + PA-Adaption Loss", ACE increase from 2.53\% to 3.41\%, and TDR@FDR=1.0\% decline from 91.68\% to 81.04\%. The results indicate that PA-Adaption loss has successfully modified the feature distribution of live and spoof fingerprints by pulling all the live fingerprints aggregated while pushing the spoof ones of different materials apart. This proves that PA-Adaption loss can improve the performance of the baseline effectively. Since the channel-wise feature denoising module is an important part of the method, we also test the contribution of the channel-wise feature denoising module and the result is listed in Table \ref{tab.ablation}. Compared with baseline, the method using channel-wise feature denoising has better performance, ACE is decreased from 3.77\% to 3.41\% and TDR@FDR=1.0\% is improved from 73.92\% to 81.04\%. However, when the channel-wise feature denoising module is removed from the final experiment, it is observed that the ACE is increased from 2.53\% to 3.44\%, and TDR@FDR=1.0\% is declined from 93.83\% to 82.41\%. This result demonstrates that the channel-wise feature denoising module can remove redundant "noise" features in the fingerprint, which shows the effectiveness of the channel-wise feature denoising. To further verify the effectiveness of the channel-wise feature denoising module, we compared it with the channel-wise feature regularization module. Channel-wise feature denoising and channel-wise feature regularization are similar in the process of evaluating the importance of each channel. $dis$ is calculated which can reflect the importance of each channel in the module of channel-wise feature regularization and channel-wise feature denoising. But the difference is that channel-wise feature regularization chooses the down $k$ channels in $dis$ as important channels and the rest are "noise" channels, while channel-wise feature denoising chooses the top $k$ channels in $dis$ as important channels and the rest are "noise" channels. The result in Table \ref{tab.ablation} shows that channel-wise feature regularization achieves the ACE of 3.46\% and TDR@FDR=1.0\% of 84.60\%, which did not get a good performance compared with channel-wise feature denoising. This result demonstrates that compared with channel-wise feature regularization, channel-wise feature denoising is more useful and can improve the performance effectively. \begin{figure}[!] \centering \includegraphics[scale=0.60]{img/viscam.pdf} \caption{Grad-CAM visualizations on LivDet2017 under Digital Persona. The first two row shows the live sample and the last two row presents the spoof sample. The first column is the original image, the second column is the visualization results after using the denoising method, and the last column is the visualization result without using the undenoising method.} \label{fig:viscam} \end{figure} In order to investigate the advance of the proposed method, we adopt the Grad-CAM to provide the class activation map(CAM) visualizations of our method and baseline, which has the same architecture as our method but without denoising module. As shown in Fig. \ref{fig:viscam}, the first two row shows the live sample, and the last two row presents the spoof sample. The first column is the original image, the second column is the visualization results after using the denoising method, and the last column is the visualization result without using the denoising method (undenoising method). We can see that CFD-PAD always focuses on the adequate region of interest(ROI) for both live and spoof fingerprints to seek discriminative cues instead of domain-specific backgrounds, which is more likely to generalize well to unseen domains. However, when compared with the pre-trained model from the denoising method, the undenoising method localize some background region, which indicates the effectiveness of the proposed denoising method. \subsection{Comparison With Existing Methods} To demonstrate the performance of our CFD-PAD method, we compare it with other single and multiple model based PAD methods, i.e., the winner in LivDet 2017 \cite{mura2018livdet}, a minutiae-centered patches based method \cite{chugh2018fingerprint}, a style-transfer based method \cite{chugh2020fingerprint}, the state-of-the-art PAD method \cite{liu2021fingerprint} et al. Table \ref{tab.crossmaterial} and Table \ref{tab.crosssensor} present the performance of some fingerprint PAD methods on LivDet 2017. The performance of our proposed CFD-PAD method achieves 2.53\% ACE and 93.83\% TDR@FDR=1\% in the cross-material setting and achieves 19.80\% ACE and 32.32\% TDR@FDR=1\% in the cross-material setting. In this paper, two different experimental settings are considered, including cross-material and cross-sensor. In the case of cross-material, the spoof materials used in the training set and testing set are different, as shown in Table \ref{tab.livdet2017}. The spoof materials in the training set are Wood Glue, Ecoflex, Body Double but Gelatine, Latex, Liquid Ecoflex in the testing set. Therefore, the data partition of LivDet 2017 can be directly used as the cross-material setting. In the case of cross-sensor, the fingerprint images in the training set and testing set use different sensors. \subsubsection{In The Case of Cross-Material} \ \\ \indent Table \ref{tab.crossmaterial} presents the generalization performance of the proposed method on the LivDet2017 dataset in the case of cross-material. A significant reduction in the mean of ACE is achieved by the proposed method. In the case of cross-material, compared with the best single model based method Fingerprint Spoof Buster (FSB) \cite{chugh2018fingerprint}, the mean ACE is reduced from 4.56\% to 2.53\% and the mean TDR@FDR=1\% is improved from 73.32\% to 93.83\% by our method. A 44.52\% reduction in the mean of ACE and a 27.97\% rise in the mean of TDR@FDR=1\% are achieved by our method compared with FSB. Compared with the best multiple model based model RTK-PAD \cite{liu2021fingerprint}, the mean of TDR@FDR=1\% is improved from 91.19\% to 93.83\% and our method has achieved the state-of-the-art method performance in TDR@FDR=1\%. In the case of Orcanthus, the proposed method outperforms the combination of Fingerprint Spoof Buster and UMG wrapper by a wide margin. When using Orcanthus as the training and testing sensor, our proposed method can achieve 1.68\% ACE, which improves obviously compared with the previous method \cite{mura2018livdet,chugh2018fingerprint,chugh2020fingerprint}. When Orcanthus is used as the sensor, our method decreases 2.73\% in the ACE compared to LivDet 2017 Winner \cite{mura2018livdet} which is the best single model based method in the case of Orcanthus before. Given Digital Persona as the sensor, the ACE of our method is 3.33\%, which is also better than the best single model based method before \cite{chugh2020fingerprint}. Compared with the single model based methods, we can see that the proposed method outperforms all the single model based methods by a wide margin in the evaluation metrics of both ACE and TDR@FDR=1\%. Compared with multiple model based methods, we can still get a good performance at the same time. Even if we use a single model, we can fully beyond the combination of Fingerprint Spoof Buster and the style-transfer based wrapper (FSB + UMG) \cite{chugh2020fingerprint} in both ACE and TDR@FDR=1\%. In the evaluation metric of TDR@FDR=1\%, our method has improved from 91.19\% to 93.83\% compared with the state-of-the-art method RTK-PAD \cite{liu2021fingerprint}. Experimental results indicate that the proposed CFD-PAD method has better performance and generalization ability in PAD, and has achieved the state-of-the-art performance on LivDet 2017 in TDR@FDR=1\%. \subsubsection{In The Case of Cross-Sensor} \ \\ \indent We compare the performance of the proposed method with Fingerprint Spoof Buster \cite{chugh2018fingerprint} and RTK-PAD method \cite{liu2021fingerprint} under cross-sensor setting to further verify the robustness of the proposed method. In the case of cross-sensor, the sensors used in the training set and testing set are completely different. Since there are three types of sensors, we conducted 6 sets of experiments in order to cover all of their combinations. As the results show in Table \ref{tab.crosssensor}, the proposed method achieves the best performance in the mean of ACE. More specifically, compared with the best single model based method \cite{chugh2018fingerprint}, we achieve better performance in both ACE and TDR@FDR. While compared with the current best multiple model based method, i.e. RTK-PAD \cite{liu2021fingerprint}, we still get a better performance in terms of ACE (19.80\% vs. 21.87\%) . It should be noted that FSB+UMG \cite{chugh2020fingerprint} is a style transfer based method, which also tests in cross-sensor setting. This method uses the UMG framework to augment CNN-based spoof detector(FSB), which significantly improves the performance of FSB against novel materials while retaining its performance on known materials \cite{chugh2018fingerprint,chugh2020fingerprint}. However, their method uses the data in the target sensor to synthesize extra data \cite{chugh2020fingerprint} while we do not use the data in the target sensor, it is unfair to compare our method with FSB + UMG \cite{chugh2020fingerprint}. FSB + UMG wrapper can achieve 19.37\% in ACE and 43.23\% in TDR@FDR=1\%in the case of cross-sensor setting. But our method reaches to an accuracy close to FSB + UMG wrapper (e.g. 19.80\% vs. 19.37\% \cite{chugh2020fingerprint} in terms of ACE) but without using any image from target sensor. Thus we conclude that even without using the data derived from target sensors, our method can also improve the cross-sensor performance effectively. \begin{table}[h] \centering \caption{computational complexity in terms of params and time cost.} \label{tab:time} \setlength\tabcolsep{12pt} \huge \resizebox{.49\textwidth}{!}{% \begin{tabular}{c|c|c|c} \hline & Input Size & FLOPs (GMACs) & Time Cost (ms) \\ \hline FSB \cite{chugh2018fingerprint} & $\sim$48×224×224×3 & $\sim$27.84 & 268.2 \\ RTK-PAD \cite{liu2021fingerprint} & 1×224×224×3 & 0.69 & 237.3 \\ \rowcolor[HTML]{C0C0C0} CFD-PAD (Ours) & 1×224×224×3 & \textbf{0.31} & \textbf{59.9} \\ \hline \end{tabular}% } \end{table} \subsection{Computational Complexity Analysis} To investigate the computational complexity of the proposed method, we calculate the FLOPs (floating point operations) and time cost as the evaluation metrics. As list in Table \ref{tab:time}, both Time Cost and FLOPs of the proposed method are less than FSB \cite{chugh2018fingerprint} and the state-of-the-art method, RTK-PAD \cite{liu2021fingerprint}. FSB \cite{chugh2018fingerprint} is a single model based method, which needs to calculate the spoof score of 48 minutiae-centered patches and fusion their scores, no such operations are needed by our method. Hence, a 208.3 ms reduction in terms of time cost can be saved by our method. RTK-PAD \cite{liu2021fingerprint} is a multiple model based method, which uses a global PAD module, a local PAD module, and a rethinking module, but our method only uses a single model. Hence, our method spends less time than RTK-PAD. When input size is 1×224×224×3, our method takes 59.9ms to distinguish spoof from live fingerprints, which is faster than RTK-PAD markedly. Our method is based on a single lightweight model, which is time-saving and suitable for deployment conditions. Compared with RTK-PAD, a 74.76\% reduction in time-consuming is achieved by our method. Hence, whether compared with other single model or multiple model based method, far less time is required by our method. \section{CONCLUSION} Improving the robustness and generalization ability of PAD methods is critical to ensure the security of a fingerprint recognition system. This paper thus proposes a channel-wise feature denoising method and a PA-Adaption loss. The method contains three key steps during training, including each channel's importance evaluation, "noise" channels' suppression and, channel-wise domain alignment. In the stage of channels evaluation, the importance of each channel is quantified according to the change of the results after the channel is suppressed. And then all the channels in the feature map can be divided into important channels and "noise" channels. The influence of "noise" features among channels will be greatly reduced due to the suppression of the propagation of "noise" channels. Finally, a PA-Adaption loss is designed to constrain the feature distribution. The effectiveness of the proposed method was proved by experiments on LivDet 2017, which is one of the most recent publicly available LivDet datasets. Our experimental results have shown that compared with baseline, PA-Adaption loss has reduced the evaluation metric of ACE from 3.77\% to 3.44\% and increased TDR@FDR=1\% from 73.92\% to 82.41\%. Similarly, the channel-wise feature denoising module has reduced ACE from 3.77\% to 3.41\% and increased TDR@FDR=1\% from 73.92\% to 81.04\%. The combination of channel-wise feature denoising and PA-Adaption loss can achieve 2.53\% ACE and 93.83\% TDR@FDR=1\%, which get a better result compared with adding PA-Adaption loss module and channel-wise feature denoising module respectively. The effectiveness of the propose method is further proved by comparing with the state-of-the-art PAD methods under cross material and cross sensor settings. \section{Acknowledgment} This work is supported in part by National Natural Science Foundation of China under Grant 62076163 and Grant 91959108; In part by the Shenzhen Fundamental Research Fund under Grant JCYJ20190808163401646 and Grant JCYJ20180305125822769; And in part by the Tencent Rhinoceros Birds-Scientific Research Foundation for Young Teachers of Shenzhen University. {\small \bibliographystyle{IEEEtran}
{'timestamp': '2021-11-16T02:29:05', 'yymm': '2111', 'arxiv_id': '2111.07620', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07620'}
arxiv
\section{Introduction} \label{sec: intro} The rate at which new manufacturing technologies are being developed and the range of components that can now be produced pose a challenge to formal standardisation, which has traditionally formed the basis for engineering design and assessment. An important motivation for new technologies is to trade the quality of the component with the speed and cost at which it can be manufactured. This trade-off results in the introduction of imperfections or defects, in a manner that is intrinsically unpredictable and could therefore be described as statistical. As such, there is a need to develop principled and general statistical methods that can be readily adapted to new technologies, in order to obtain reliable models as the basis for formal standards in the engineering context. The recent emergence of additive manufacture technologies for stainless steel promises to disrupt traditional approaches based on standardised components and to enable design of steel components of almost arbitrary size and complexity \citep{Buchanan2019}. This \textit{directed energy deposition} technology arises from the combination of two separate technologies; traditional welding modalities and industrial robotic equipment \citep{ASTM}. In brief, material is produced in an additive manner by applying a layer of steel onto the surface of the material in the form of a continuous weld. To ensure that this process is precisely controlled, the manufacture is performed by a robot on which the weld head is mounted. The complexity of this process is such that the geometric (e.g. thickness and volume) and mechanical (e.g. stiffness and strength) properties of additively manufactured (henceforth ``3D-printed'') steel are not yet well-understood. Indeed, conventional models for welding focus on the situation of a localised weld that is typically intended to bind two standard components together. The material properties of elementary welds, as a function of the construction protocol and ambient environment, have been modelled in considerable detail \citep{Kou2003}. In contrast, 3D-printed steel is a single global weld whose construction protocol is highly non-standard. Furthermore, the limited precision of the equipment results in imperfections in the material geometry, which can range in severity from aesthetic roughness of the surface of the material through to macroscale defects, such as holes in the printed component. These imperfections occur in a manner that is best considered as random, since they cannot be easily predicted or controlled. The variation in the manufactured components precludes the efficient use of raw material, as large factors of safety are necessarily employed. An important task is therefore to gain a refined understanding of the statistical nature of 3D-printed steel, enabling appropriate factors of safety to be provided for engineering design and assessment \citep{Buchanan2017}. It is anticipated that geometric variation, as opposed to mechanical variation, is the dominant source of variation in the behaviour of a 3D-printed thin-walled steel component under loading. The focus of this work is therefore to take a statistical approach to surface metrology, with the aim to develop a generative model for geometric variation in 3D-printed steel. Specifically, the following problem is considered: \begin{problem} Given the notional and actual geometries of a small number of 3D printed steel components, construct a generative statistical model for the actual geometry of a 3D-printed steel component whose notional geometry (only) is provided. \end{problem} \noindent For example, in \Cref{subsec: predict cylinder 1} of this paper a statistical model is used to generate realistic simulations of geometric variation that might be encountered on a 3D-printed steel cylinder, based only on a training dataset of notionally flat panels of 3D-printed steel; see \Cref{fig: explain}. \begin{figure}[t!] \centering \newcolumntype{C}{ >{\centering\arraybackslash} m{2cm} } \begin{tabular}{CCC|CCC} \multicolumn{3}{c}{\underline{Training Dataset}} & \multicolumn{3}{c}{\underline{Generative Model}} \\ Notional & & Actual & Notional & & Actual \\ \begin{tikzpicture} \draw [] (0,0) -- ++(1.5cm,0) -- ++ (0cm,1.5cm) -- ++ (-1.5cm,0) -- ++ (0cm,-1.5cm); \draw [] (0.05,1.5) -- (0.05,1.55) -- (1.55,1.55) -- (1.55,0.05) -- (1.5,0.05); \draw [densely dashed] (0.05,0.05) -- (0.05,1.5); \draw [densely dashed] (0.05,0.05) -- (1.5,0.05); \draw [densely dashed] (0,0) -- (0.05,0.05); \draw [] (0,1.5) -- (0.05,1.55); \draw [] (1.5,1.5) -- (1.55,1.55); \draw [] (1.5,0) -- (1.55,0.05); \end{tikzpicture} & $\xrightarrow{\hspace*{2cm}}$ & \includegraphics[height = 0.07\textheight,clip,trim = 2cm 1.5cm 2cm 1cm]{figures/thin_panel} \includegraphics[height = 0.07\textheight,clip,trim = 2cm 1.5cm 2cm 1cm]{figures/thick_panel} & \begin{tikzpicture} \draw [fill=gray, fill opacity=0, dashed] (180:7mm) coordinate (a) -- ++(0,-12.5mm) coordinate (b) arc (180:360:7mm and 1.85mm) coordinate (d) -- (a -| d) coordinate (c) arc (0:180:7mm and 1.85mm); \draw [fill=gray, fill opacity=0] (0,0) coordinate (t) circle (7mm and 1.85mm); \draw [densely dashed] (d) arc (0:180:7mm and 1.85mm); \draw [] (180:7.5mm) coordinate (A) -- ++(0,-12.5mm) coordinate (B) node [midway, right, inner sep=1pt] {} arc (180:360:7.5mm and 2.625mm) coordinate (D) -- (A -| D) coordinate (C) arc (0:180:7.5mm and 2.625mm); \draw [] (0,0) coordinate (T) circle (7.5mm and 2.625mm); \end{tikzpicture} & $\xrightarrow{\hspace*{2cm}}$ & $?$ \end{tabular} \caption{Illustration of the problem statement. Here the actual geometries of a small number of 3D printed steel components, each notionally a flat panel, are provided and the aim is to construct a generative statistical model for the actual geometry of a 3D-printed steel component whose notional geometry is cylindrical. } \label{fig: explain} \end{figure} \subsection{A Brief Review of Surface Metrology} Surface metrology concerns small-scale features on surfaces and their measurement \citep{Jiang2007a,Jiang2007}. The principal aim is to accurately characterise the nature of the surface of a given type of material, in order that such material can be recreated in simulations or otherwise analysed. Typical applications of surface metrology are at the nanometer-to-millimeter scale, but the principles and methods apply equally to the millimeter-to-centimeter scale variation present in 3D-printed stainless steel. The first quantitative studies of surfaces can be traced back to the pioneering work of \cite{Abbot1933}, and concern measurement techniques to produce one-dimensional surface cross-sections (or ``profiles''), denoted $z : [0,L] \rightarrow \mathbb{R}$, and the subsequent description of profiles in terms of a small number of summary statistics, such as amplitude and texture statistics \citep{thomas1999rough}. Typical examples of traditional summary statistics are presented in Table \ref{tab: features from literature}. The use of summary statistics for surface profiles continues in modern surface metrology \citep[e.g. as codified in standard][]{ISO213}. These include linear filters, for example based on splines and wavelets \citep{Krystek_1996}, and segmentation filters that aim to partition the profile into qualitatively distinct sections \citep{Scott_2004}. See \cite{Jiang2007}. \begin{table}[] \centering \footnotesize \begin{tabular}{ | l | l | p{5cm} | p{5cm} |} \hline \textbf{Parameter} & \textbf{Parameter} & & \\ \textbf{Name} & \textbf{Type} & \textbf{Description} & \textbf{Mathematical Definition} \\ \hline \hline Rq & Amplitude & Root mean square roughness & Rq $:= \sqrt{\frac{1}{L} \int_0^L [z(x) - \mu]^2 \mathrm{d}x}$ \\ \hline Ra & Amplitude & Average roughness & Ra $:= \frac{1}{L} \int_0^L |z(x) - \mu| \mathrm{d}x$ \\ \hline HSC & Texture & Number of local peaks per unit length & (NA - this depends on definition of a peak) \\ \hline $\text{R}_L$ & Texture & Ratio of developed length of a profile compared to nominal length & $\text{R}_L := \frac{1}{L} \int_0^L \sqrt{1 + z'(x)^2} \mathrm{d}x$ \\ \hline \end{tabular} \caption{Summary statistics traditionally used in surface metrology; here $z : [0,L] \rightarrow \mathbb{R}$ is the profile through the surface of the material and $\mu$ is its average or intercept as per \eqref{eq: ARMA}. Adapted from Chapters 7 and 8 of \cite{thomas1999rough}. } \label{tab: features from literature} \end{table} Although useful for the purposes of classifying materials according to their surface characteristics, these descriptive approaches do not constitute a generative model for the geometric variation in the material. Subsequent literature in surface metrology recognised that surfaces contain inherently random features that can be characterised using a stochastic model \citep{PATIR1978263,DeVOR}. In particular, it has been noted that many types of rough surface are well-modelled using a non-stationary stochastic model \citep[see e.g.][]{MAJUMDAR1990313}. Traditional stochastic models for surface profiles fall into two main categories: The first seeks to model the surface profiles as time-series, typified by the autoregressive moving average (ARMA) model introduced in this context in \cite{DeVOR} and extended to surfaces with a non-Gaussian height distribution by \cite{WATSON1982215}. An ARMA$(p,q)$ model combines a $p$th order autoregressive model and a $q$th order moving average \begin{align} \label{eq: ARMA} z_i = \mu + \epsilon_i + \sum_{k=1}^p \phi_k z_{i-k} + \sum_{l=1}^q \theta_l \epsilon_{i-l} \end{align} where $z_i = z(t_i)$ represents a discretisation of the surface profile and the $\epsilon_i$ are residuals to be modelled. These techniques have been applied to isotropic surfaces. \cite{PATIR1978263} have noted that the theory is less well-understood regarding anisotropy and pointed out that observations of surface profiles in differing directions may be used to establish anisotropic models. This represents a significant weakness where simulation of rough surfaces are concerned, as it becomes unwieldly and complex to simulate materials with a layered surface such as 3D-printed steel. \cite{PATIR1978263} introduced a second class of methods, wherein a two-dimensional surface is represented as a $N \times M$ matrix of heights $(z_{i,j})$, assumed to have arisen as a linear transform of a $(N+n) \times (M+m)$ random matrix $(\eta_{i,j})$ according to $$ z_{i,j} = \mu + \epsilon_i + \sum_{k=1}^{n} \sum_{l=1}^{m} \alpha_{k,l} \eta_{i+k,j+l} , $$ where the coefficients $(\alpha_{k,l})$ are selected in order to approximate the measured autocorrelation function for the $z_{i,j}$. The surface heights are often assumed to be Gaussian as the theory in this setting is well-understood. A number of authors have developed this method: A fractal characterisation was explored in \cite{MAJUMDAR1990313}, recognising that the randomness of some rough surfaces is multiscale and exhibits geometric self-similarity. \cite{HU199283} proposed the use of the fast Fourier transform on the autocorrelation function to facilitate rapid surface simulation; see also \cite{newland1980introduction} and \cite{WU200047}. A possible drawback with this second class of approaches, compared to the former, is that it can be more difficult to account for non-stationarity compared to e.g. the ARMA model. The use of wavelets to model non-stationary and multi-scale features has received more recent attention, see \cite{Jiang2007a}. Recent research in surface metrology concerns the simulation of rough surfaces for applications in other fields, including tribology \citep{10.1115/1.4029644}, electronics \citep{7819933} and wave scattering \citep{CHOI201827}. Typically the approaches above are used directly, but alternative methods are sometimes advanced. For instance, \cite{10.1115/1.4029644} proposed an approach utilising random switching to generate Gaussian surfaces with prescribed statistical moments and autocorrelations. Clearly it is necessary to specialise any statistical model to the specific material under study. For example, in the case of 3D-printed steel an approach ought to be taken which is able to natively account for anisotropy due to layering of the steel. More crucially in the present context, existing methods pre-suppose that surface profiles $(z_i)$ or height matrices $(z_{i,j})$ are pre-defined with respect to some regular Cartesian grid on a Euclidean manifold. In applications to 3D-printed steel, where components have possibly complex macroscale geometries, the training and test data can belong to different manifolds and it is far from clear how an existing model, once fitted to training data from one manifold, could be used to simulate realistic instances of geometric variation on a different manifold. An important application of surface metrology is \textit{surface quality monitoring}; a classification task where one seeks to determine, typically from a limited number of measurements and in an online environment, whether the quality of a manufactured component exceeds a predefined minimum level \citep{zang2018phase,zang2018phaseb,jin2019scale,zhao2020intrinsic}. Existing research into quality monitoring has exploited Gaussian process models to reconstruct component geometries from a small number of measurements \citep{xia2008gaussian,colosimo2014profile,del2015geodesic}, possibly at different fidelities \citep{colosimo2015multisensor,ding2020multisensor}. Going further, performance metrics arising from surface metrology have been used as criteria against which the parameters of a manufacturing protocol can be optimised \citep{yan2019structured}. \subsection{Outline of the Contribution} The aim of this paper is to explore whether modern techniques from spatial statistics can be used to provide a useful characterisation of geometric variation in 3D-printed stainless steel. \begin{figure}[t!] \centering \begin{subfigure}[b]{0.29\textwidth} \vspace{-20pt} \includegraphics[width = \textwidth]{figures/scanning.jpg} \vspace{15pt} \caption{} \end{subfigure} \begin{subfigure}[b]{0.6\textwidth} \scalebox{.5}{ \includegraphics[clip,trim = 8cm 13cm 9.3cm 0cm]{figures/35_panel_side.pdf} \includegraphics[clip,trim = 4cm 13cm 3cm 0cm]{figures/35_panel_front.pdf} } \vspace{-30pt} \scalebox{.5}{ \phantom{\includegraphics[clip,trim = 8cm 30cm 9.3cm 0cm]{figures/35_panel_side.pdf}} \includegraphics[clip,trim = 4cm 21cm 3cm 7cm]{figures/35_panel_bottom.pdf} } \caption{} \label{fig: example panel} \end{subfigure} \caption{Laser scan of 3D-printed steel sheet. (a) Photograph of the handheld scanning equipment. (b) Orthographic projection of (a portion of) the scanned sheet, which will be called a \emph{panel}. The notional thickness of the panel is 3.5mm. [Observe the residual stress induces a slight curvature in the notionally flat panel.] } \label{fig: protocol} \end{figure} To provide a training dataset, a high-resolution laser was used to scan 3D-printed stainless steel panels, on whose surfaces the geometric variation of interest is exhibited. A typical panel is displayed in Figure \ref{fig: protocol}. To characterise geometric variation in the panel dataset, in Section \ref{sec: methods} a library of candidate models is constructed, rooted in Gaussian stochastic processes, and in Section \ref{sec: results} formal parameter inference and model selection are performed to identify a most suitable candidate model. Although quite natural from a statistical perspective, this systematic approach to parameter inference and model selection appears to be novel in the surface metrology context. The high-dimensional nature of the dataset introduces computational challenges that are familiar in spatial statistics and the stochastic partial differential equation (SPDE) techniques described in \cite{Lindgren2011} are leveraged to make the computation practical. The aim is to characterise geometric variation not just on panels but on components whose notional geometry, represented abstractly by a two-dimensional manifold $\mathcal{M}$ embedded in $\mathbb{R}^3$, may be complicated. (The case study in \Cref{subsec: predict cylinder 1} considers the case where $\mathcal{M}$ is cylindrical which, whilst not complicated, differs from a flat panel in a fundamental topological way.) This variation, present in the actual geometry of a 3D-printed component, is described by a two-dimensional vector field $u : \mathcal{M} \rightarrow \mathbb{R}^2$. As illustrated in Figure \ref{fig: notation illustration}, the value of the first coordinate $u^{(1)}(x)$ of the vector field represents the Euclidean distance of the upper surface of the component from the manifold and similarly the value of $u^{(2)}(x)$ represents the distance of the lower surface of the component from the manifold. The absence of geometric variation corresponds to the functions $u^{(1)}(x)$ and $u^{(2)}(x)$ being constant, but actual 3D-printed steel components exhibit geometric variation that can be statistically modelled. The need to consider diverse notional geometries, represented by different manifolds, precludes conventional parametric \citep{Rasmussen2006}, compositional \citep{Duvenaud2014} and nonparametric \citep{Bazavan2012,Oliva2016,Moeller2016} approaches that aim to infer an appropriate covariance function defined only on the manifold of the training dataset. Indeed, it is well-known that a radial covariance function $\varphi(d_{\mathcal{M}_1}(x,y))$ defined on one manifold $x,y \in \mathcal{M}_1$ with geodesic distance $d_{\mathcal{M}_1}$ can fail to be a valid covariance function when applied as $\varphi(d_{\mathcal{M}_2}(x,y))$ in the context of a different manifold $x,y \in \mathcal{M}_2$ with geodesic distance $d_{\mathcal{M}_2}$. This occurs because positive-definiteness can fail; see Section 4.5 of \cite{Gneiting_2013}. The key insight used in this paper to generalise across manifolds is that the Laplacian $\Delta_{\mathcal{M}_1}$ on $\mathcal{M}_1$ can be associated with the Laplacian $\Delta_{\mathcal{M}_2}$ on $\mathcal{M}_2$. In doing so a suitable differential operator on $\mathcal{M}_1$, describing the statistical character of the vector field $u$ via an SPDE, can be inferred and then used to instantiate an equivalent differential operator on $\mathcal{M}_2$, defining a Gaussian random field on $\mathcal{M}_2$ via an SPDE. This allows, for instance, the simulation of high-resolution random surfaces on a cylinder whose local characteristics are related to the panel training dataset. (Note that this paper does not consider the question of when the covariance differential operator / SPDE approach defines a true random field rather than a generalised random field. The practical consequences of this are minimal, however, since the random field will be discretised by projection onto a finite element basis whose coefficients are well-defined linear functionals of the random field.) In Sections \ref{subsec: predict cylinder 1} and \ref{subsec: predict cylinder 2} it is demonstrated, using a held out test dataset consisting of a 3D-printed steel cylinder, that random surfaces generated in this way can capture some salient aspects of geometric variation in the material. However, the conclusions of this paper are tempered by the substantial computational challenges associated with the fitting of model parameters in this context. The paper concludes with a brief discussion in Section \ref{sec: conclusion}. \begin{figure}[t!] \centering \includegraphics[width = 0.9\textwidth,clip,trim = 2cm 3cm 0cm 1cm]{figures/manifold} \caption{Data are conceptualised as a two-dimensional vector field $u$ on an oriented manifold $\mathcal{M}$. The value $u^{(1)}(x)$ represents the height of the upper surface of the material above $x \in \mathcal{M}$, while the value $u^{(2)}(x)$ represents the height of the lower surface below $x \in \mathcal{M}$. } \label{fig: notation illustration} \end{figure} This research forms part of a wider effort to develop realistic computer modelling tools for applications involving 3D-printed steel; these must also account also for other factors such as mechanical variation and aspects of the printing protocol \citep{Dodwell2021}. Specifically, other controllable factors that affect the quality of the manufactured component include the angle of the weld head, the speed of printing and the order in which the steel layers are printed. It is possible that an improved understanding of the nature of geometric variation can inform the improvement of manufacturing techniques and their protocols \citep{Barclift2012,Franco2017}, but these directions are beyond the scope of the present paper, which aims only to characterise the geometric variation in the material. \section{Statistical Models for Geometric Variation in 3D-Printed Steel} \label{sec: methods} This section proceeds as follows: Section \ref{subsec: insight} contains the main conceptual contribution, that identification of Laplacians can be used to generalise from the training manifold to a test manifold. Section \ref{subsec: maths} presents the mathematical setting of a two-dimensional Gaussian random field characterised by a differential operator and Section \ref{subsec: candidates} presents the resulting collection of candidate models. \subsection{Gaussian Models and Generalisation via the Laplacian} \label{subsec: insight} In this paper, geometric variation for a 3D-printed component with notional geometry $\mathcal{M}$ is modelled using a Gaussian stochastic process. Letting $\mathbb{E}$ and $\mathbb{C}$ denote expectation and covariance operators, set \begin{align*} \mathbb{E}[u^{(r)}(x)] & = 0 \\ \mathbb{C}( u^{(r)}(x) , u^{(s)}(y) ) & = k_{\mathcal{M}}((x,r),(y,s)) , \end{align*} where the covariance function $k_{\mathcal{M}}((x,r),(y,s))$ describes the statistical relationship between the upper and lower surfaces ($r,s \in \{1,2\}$) at different spatial locations ($x,y \in \mathcal{M}$). To describe geometric variation in the panel datasets, whose notional flat geometry is denoted $\mathcal{M}_1$, any existing method for estimating a suitable covariance function $k_{\mathcal{M}_1}$ from the dataset could be employed. Such methods are well-developed and examples include maximum likelihood estimation over a parametrised class of covariance functions \citep{Rasmussen2006}, inference based on cross-validation with arbitrarily complicated compositions of simple kernels \citep{Duvenaud2014} and even fully nonparametric inference of a covariance function \citep{Bazavan2012,Oliva2016,Moeller2016}. However, in doing so one would be learning a covariance function that is defined on the manifold $\mathcal{M}_1$ of the training dataset, being the Green's function of a stochastic differential equation defined on $\mathcal{M}_1$ \citep[see e.g.][]{Fasshauer2013}. As a consequence, one cannot expect a covariance function learned from the training dataset to carry the same meaning when applied on the manifold $\mathcal{M}_2$ of the test dataset. Indeed, it is a classic result that the Mat\'{e}rn kernel $\varphi$ on $\mathbb{R}^3$ with $d_{\mathbb{R}^3}(x,y) = \|x-y\|$ can fail to be positive definite when applied as $\varphi(d_{\mathbb{S}^2}(x,y))$ on the sphere $x,y \in \mathbb{S}^2 \subset \mathbb{R}^3$ with $d_{\mathbb{S}^2}$ the geodesic distance on $\mathbb{S}^2$ \citep[see e.g. Section 4.5 of][]{Gneiting_2013}. Thus inferential approaches based on the covariance function are unsuitable in this context, since a description is required of geometric variation on a range of manifolds that includes potentially complicated manufacturing geometries. The key insight in this paper is that, whilst covariance functions do not generalise across manifolds, their associated differential operators are only locally defined. In particular, a wide range of models for stochastic vector fields $u$ can be cast as the solutions of a coupled system of SPDEs based on a Laplacian-type differential operator. The specific form of the differential operator, together with suitable boundary conditions, determine the statistical properties of the associated random field. The Laplacian $\Delta_{\mathcal{M}_1}$ on the manifold $\mathcal{M}_1$ of the training dataset can be associated with the Laplacian $\Delta_{\mathcal{M}_2}$ on the manifold $\mathcal{M}_2$ where generative models are to be tested. This provides a natural way in which to decouple the statistical properties of the random vector field $u$ from the manifold on which it is defined. To sound a cautionary note, this assumption is likely to break down in situations where one of the manifolds is highly curved. For example, it is conceivable that the protocols used to control weld head movement may be less effective when the required trajectories are highly curved, leading to higher levels of geometric variation in corresponding regions of the component. As a more extreme example, if two distinct regions of the manifold come within millimetres due to the manifold curving back on itself when embedded in 3D, then through stochastic fluctuation there is a potential for the two corresponding regions of the printed component to become physically fused. The first of these phenomena could be handled by considering Gaussian models that allow covariances to be both position- and curvature-dependent, while an entirely different approach would be needed to model accidental fusing of distinct regions of a component. Neither of these extensions are pursued in the present work. The SPDE formulation of Gaussian random fields has received considerable attention in the spatial statistics literature following the seminal work of \cite{Lindgren2011}, generating an efficient computational toolkit which has been widely used \citep[e.g.][]{coveney2019probabilistic}. Interestingly, the present account appears to describe the first instance of \emph{transfer learning} using the SPDE framework, where observations made on one manifold are used to provide information on the equivalent stochastic process defined on a different manifold. As noted earlier, no attempt is made to address the technical issue of whether the covariance operator corresponds to a true random field rather than a generalised random field. \subsection{Mathematical Set-Up} \label{subsec: maths} The purpose of this section is to rigorously set up a coupled SPDE model for a random vector field $u$ on a manifold $\mathcal{M}$. For completeness, the required regularity assumptions are stated in Section \ref{subsubsec: reg}; these are essentially identical to the presentation in \cite{Lindgren2011} and may be safely skipped if desired. The coupled SPDE model is introduced in Section \ref{subsubsec: TDGRF}, following a similar presentation to that of \cite{Hu2013a,Hu2013}. \subsubsection{Regularity Assumptions} \label{subsubsec: reg} The domain of the printing process is $\mathbb{R}^3$ and throughout the paper the convention is used that the printing occurs in the direction of the $z$-axis of $\mathbb{R}^3$. That is, each layer of steel is notionally perpendicular to the $z$-axis according to the printing protocol. The notional geometry of a component is described by a manifold $\mathcal{M}$ embedded in $\mathbb{R}^3$. Below are listed some strong regularity conditions on $\mathcal{M}$ that ensure the coupled SPDE model in Section \ref{subsubsec: TDGRF} is well-defined. Let $\mathcal{M}$ be a 2-dimensional manifold embedded in $\mathbb{R}^3$, so that the Hausdorff measure on $\mathcal{M}$, denoted $\mu_\mathcal{M}$, can be defined, and thus an inner product \begin{align*} \langle \phi , \psi \rangle_\mathcal{M} & := \int_\mathcal{M} \phi(x) \psi(x) \mathrm{d} \mu_\mathcal{M}(x) \end{align*} and an associated space $L^2(\mathcal{M})$ of functions $\phi : \mathcal{M} \rightarrow \mathbb{R}$ for which $\langle \phi , \phi \rangle_\mathcal{M} < \infty$. It is assumed that $\mathcal{M}$ is endowed with a Riemannian structure, induced by the embedding in $\mathbb{R}^3$, which implies that one can define differential operators including the gradient $\nabla_{\mathcal{M}}$, the Laplacian $\Delta_{\mathcal{M}}$ and the normal derivative $\partial_{\mathcal{M},\mathrm{n}}$ on $\mathcal{M}$. It is assumed that $\mathcal{M}$ is compact (with respect to the topology induced by $\mathbb{R}^3$), which implies the existence of a countable subset $\{E_k : k = 0,1,\dots\}$ of eigenfunctions of the negative Laplacian, $- \Delta_{\mathcal{M}} E_k = \lambda_k E_k$, which can be taken as a basis for $L^2(\mathcal{M})$. From compactness it follows that $\mathcal{M}$ is bounded and it is further assumed that $\mathcal{M}$ has a boundary $\partial \mathcal{M}$ that is a piecewise smooth 1-dimensional manifold. (From a practical perspective, the assumption that the manifold has a boundary is not restrictive, since manifolds without boundary, such as the sphere, are likely to be challenging to realise as 3D-printed components.) The induced measure on $\partial \mathcal{M}$ is denoted $\mu_{\partial \mathcal{M}}$. In the sequel the manifold $\mathcal{M}$ is fixed and the shorthand $\Delta = \Delta_{\mathcal{M}}$ is used, leaving the dependence of the Laplacian on $\mathcal{M}$ implicit. \subsubsection{Two-Dimensional Gaussian Random Fields} \label{subsubsec: TDGRF} \cite{Hu2013a,Hu2013} considered using coupled systems of SPDEs to model random vector fields, building on the constructions in \cite{Lindgren2011}. In this work a similar coupled SPDE construction is used, defined next. Let $\Omega$ be an underlying probability space, on which all random variables in this paper are defined, and let $\omega \mapsto Z^{(r)}(x; \omega)$, $r \in \{1,2\}$ be independent, centred, real-valued (true or generalised) random fields, whose distribution is to be specified. Following standard convention, the argument $\omega \in \Omega$ is left implicit throughout. Let $\mathcal{L}^{(rs)}$, $r,s \in \{1,2\}$, be differential operators on $\mathcal{M}$, to be specified, and consider then the coupled system of SPDEs \begin{align} \left[ \begin{array}{cc} \mathcal{L}^{(11)} & \mathcal{L}^{(12)} \\ \mathcal{L}^{(21)} & \mathcal{L}^{(22)} \end{array} \right] \left[ \begin{array}{c} u^{(1)}(x) \\ u^{(2)}(x) \end{array} \right] = \left[ \begin{array}{c} Z^{(1)}(x) \\ Z^{(2)}(x) \end{array} \right] , \qquad x \in \mathcal{M} , \label{eq: SPDE1} \end{align} whose specification is completed with Neumann boundary conditions on $\partial \mathcal{M}$. The system in \eqref{eq: SPDE1} is compactly represented in matrix form as $\mathcal{L} \mathbf{u} = \mathbf{Z}$. The distribution of $u$, the vector field solution of \eqref{eq: SPDE1}, is therefore fully determined by the specification of the matrix differential operator $\mathcal{L}$ and the distribution of the random field $\mathbf{Z}$. In particular, the components $u^{(r)}$, $r \in \{1,2\}$ are independent if $\mathcal{L}^{(12)} = \mathcal{L}^{(21)} = 0$ and if $Z^{(1)}$ and $Z^{(2)}$ are independent. Suitable choices for $\mathcal{L}$ and $\mathbf{Z}$ are discussed next. \subsection{Candidate Models} \label{subsec: candidates} A complete statistical description for the random vector field $u$ follows from specification of both the differential operator $\mathcal{L}$ and the noise process $\mathbf{Z}$. Sections \ref{subsubsec: iso model}-\ref{subsubsec: ani nonstat} present four candidate parametric models for $\mathcal{L}$, then Sections \ref{subsubsec: white}-\ref{subsubsec: smo osc noise} present three candidate parametric models for $\mathbf{Z}$. Thus a total of 12 candidate parametric models are considered for the random vector field $u$ of interest. It is important to acknowledge that the SPDE framework does not currently enjoy the same level of flexibility for modelling of complex structural features as the covariance function framework. This is for two reasons; first, the indirect relationship between an SPDE and its associated random field presents a barrier to the identification of a suitable differential operator to represent a particular feature of interest and, second, each SPDE model requires the identification or development of a suitable numerical (e.g. finite element) method in order to facilitate computations based on the model. A discussion of the numerical methods used to discretise the SPDEs in this work is reserved for Appendix A.1, with model-specific details contained in Appendix A.2. For these two reasons, the aim in the sequel is not to arrive at a generative model whose realisations are indistinguishable from the real samples of the material. Rather, the aim is to arrive at a generative model whose realisations are somewhat realistic in terms of the salient statistical properties that determine performance in the engineering context. The models were therefore selected to exhibit a selection of physically relevant features, including anisotropy, oscillatory behaviour, degrees of smoothness and non-stationarity of the random field. It is hoped that this paper will help to catalyse collaborations with the surface metrology community that will lead in the future to richer and more flexible SPDE models for geometric variation in material. The candidate models presented next are similar to those considered in \cite{Lindgren2011}, but generalised to coupled systems of SPDEs in a similar manner to \cite{Hu2013,Hu2013a}. Note that formal model selection was not considered in \cite{Lindgren2011} or \cite{Hu2013a,Hu2013}. \subsubsection{Isotropic Stationary} \label{subsubsec: iso model} For the differential operators $\mathcal{L}^{(rs)}$, $r,s \in \{1,2\}$, the simplest candidate model that considered is \begin{align} \mathcal{L}^{(rs)} u(x) := (\eta^{(rs)} - \Delta) ( \tau^{(rs)} u(x) ) , \qquad x \in \mathcal{M} , \label{eq: iso stat L} \end{align} where $\eta^{(rs)}, \tau^{(rs)} > 0$ are constants to be specified. This model is stationary, meaning that the differential operator $\mathcal{L}^{(rs)}$ does not depend on $x$, and isotropic, meaning that it is invariant to rotation of the coordinate system on $\mathbb{R}^3$. The differential order of the differential operator in \eqref{eq: iso stat L} is fixed, which can be contrasted with \cite{Lindgren2011} where powers $(\eta - \Delta)^{\alpha/2}$, $\alpha \in \mathbb{N}$, of the pseudo-differential operator were considered. The decision to fix $\alpha = 2$ was taken because (a) the roughest setting of $\alpha = 1$ was deemed not to be realistic for 3D-printed steel, since the solutions $u$ to the SPDE are then not well-defined, and (b) over-parametrisation will be avoided by controlling smoothness of the vector field $u$ through the smoothness of the driving noise process $\mathbf{Z}$, rather than through the differential order of $\mathcal{L}$. The model parameters in this case are therefore $\theta = \{\tau^{(rs)},\eta^{(rs)}\}_{r,s \in \{1,2\}}$. To reduce the degrees of freedom, it was assumed that $\eta^{(12)} = \eta^{(21)}$, $\eta^{(11)} = \eta^{(22)}$, $\tau^{(12)} = \tau^{(21)}$ and $\tau^{(11)} = \tau^{(22)}$. This encodes an exchangeability assumption on the statistical properties of the upper and lower surfaces of the material. Such an assumption seems reasonable since the distinction between upper and lower surface was introduced only to improve the pedagogy; in reality such a distinction is arbitrary. \subsubsection{Anisotropic Stationary} \label{subsubsec: aniso model} The visible banding structure in Figure \ref{fig: example panel}, formed by the sequential deposition of steel as the material is printed, suggests that an isotropic model is not well-suited to describe the dataset. To allow for the possibility that profiles parallel and perpendicular to the weld bands admit different statistical descriptions, the following anisotropic stationary model was considered: \begin{align} \mathcal{L}^{(rs)}u(x) := (\eta^{(rs)} - \nabla \cdot \mathbf{H}^{(rs)} \nabla)(\tau^{(rs)} u(x)), \qquad x \in \mathcal{M} . \label{eq: aniso stat pde} \end{align} Here \eqref{eq: aniso stat pde} differs from \eqref{eq: iso stat L} through the inclusion of a diffusion tensor $\mathbf{H}^{(rs)}$, $r,s \in \{1,2\}$, a positive definite $3 \times 3$ matrix whose elements determine the nature and extent of the anisotropy being modelled. The model parameters in this case are $\theta = \{\eta^{(rs)},\tau^{(rs)}, \mathbf{H}^{(rs)} \}_{r,s \in \{1,2\}}$. To reduce the number of parameters, it was assumed that $\mathbf{H}^{(rs)} \equiv \mathbf{H}$ where $\mathbf{H}$ is a $3 \times 3$ diagonal matrix, so that the nature of the anisotropy is the same for each of the four differential operators being modelled. Moreover, anisotropy was entertained only in the direction of printing (the $z$-axis of $\mathbb{R}^3$) relative to the non-printing directions, meaning that the model is in fact \emph{orthotropic} with $\mathbf{H} = \text{diag}(h_1,h_1,h_2)$ for as yet unspecified $h_1,h_2 > 0$. As before, an exchangeability assumption on the upper and lower surfaces of the material was enforced, so that $\eta^{(12)} = \eta^{(21)}$, $\eta^{(11)} = \eta^{(22)}$, $\tau^{(12)} = \tau^{(21)}$ and $\tau^{(11)} = \tau^{(22)}$. \subsubsection{Isotropic Non-Stationary} \label{subsubsec: nonstat model} A more detailed inspection of the material in Figure \ref{fig: example panel} reveals that (at least on the visible surface) the vertical centre of the panel exhibits greater variability in terms of surface height compared to the other portions of the panel. It can therefore be conjectured that the printing process is non-stationary with respect to the direction of the $z$-axis, in which case this non-stationarity should be encoded into the stochastic model. To entertain this possibility, a differential operator of the form \begin{align*} \mathcal{L}^{(rs)} u(x) & := (\eta^{(rs)}(x_3) - \Delta) (\tau^{(rs)}(x_3) u(x) ), \qquad x \in \mathcal{M} , \end{align*} was considered, which generalises \eqref{eq: iso stat L} by allowing the coefficients $\eta^{(rs)}$ and $\tau^{(rs)}$ to depend on the $z$-coordinate $x_3$ of the current location $x$ on the manifold. Here it was assumed that $\tau^{(rs)}(x_3) = c_\tau^{(rs)} \tau(x_3)$ and $\eta^{(rs)}(x_3) = c_\eta^{(rs)} \eta(x_3)$ for some unspecified $c_\tau^{(rs)}$, $c_\eta^{(rs)}$ and some functions $\tau$, $\eta$, to be specified, whose scale is fixed. The nature of the non-stationarity, as characterised by $\tau$ and $\eta$, will differ from printed component to printed component and this higher order variation could be captured by a hierarchical model that can be considered to have given rise to each specific instance of the $\tau,\eta$. Recent work due to \cite{Roininen2016} considered the construction of non-stationary random fields that amounted to using a nonparametric Gaussian random field for both $\tau$ and $\eta$. However, this is associated with a high computational overhead that prevents one from deploying such an approach at scale in the model selection context. Therefore the functions $\tau$ and $\eta$ were instead parametrised using a low order Fourier basis, for $\tau$ taking \begin{equation} \tau(x) = 1 + \sum_{i=1}^4 \sum_{j=0}^1 \gamma_\tau^{(ij)} \sin \left( \frac{ 2 \pi i } {100} x_3 + \frac{j \pi}{4} \right) \label{eq: nonatationary param} \end{equation} where the $\gamma_\tau^{(\cdot)}$ are parameters to be specified. The units of $x_3$ are millimeters, so \eqref{eq: nonatationary param} represents low frequency non-stationarity in the differential operator. For $\eta$ an identical construction was used, with coefficients denoted $\gamma_\eta^{(\cdot)}$. The model parameters in this case are $\theta = \{c_\tau^{(rs)}, c_\eta^{(rs)}, \gamma_\tau^{(ij)}, \gamma_\eta^{(ij)} \}$. To reduce the number of parameters an exchangeability assumption was again used, setting $c_\tau^{(11)} = c_\tau^{(22)}$, $c_\tau^{(12)} = c_\tau^{(21)}$, $c_\eta^{(11)} = c_\eta^{(22)}$ and $c_\eta^{(12)} = c_\eta^{(21)}$. To circumvent the prohibitive computational cost of fitting a hierarchical model for the Fourier coefficients $\gamma_\tau^{(\cdot)}$ and $\gamma_\eta^{(\cdot)}$, joint learning of these parameters across the panel datasets was not attempted. This can be justified by the fact that we have only 6 independent samples, drastically limiting the information available for any attempt to learn a hierarchical model from the dataset. \subsubsection{Anisotropic Non-stationary} \label{subsubsec: ani nonstat} The final model considered for the differential operator is the natural combination of the anisotropic model of Section \ref{subsubsec: aniso model} and the non-stationary model of Section \ref{subsubsec: nonstat model}. Specifically, the differential operator \begin{align*} \mathcal{L}^{(rs)} u(x) := (\eta^{(rs)}(x_3) - \nabla \cdot \mathbf{H}^{(rs)} \nabla)(\tau^{(rs)}(x_3) u(x) ) , \qquad x \in \mathcal{M} \end{align*} was considered, where the $3 \times 3$ matrices $\mathbf{H}^{(rs)}$ and the functions $\tau^{(rs)}$, $\eta^{(rs)}$ are parametrised in the same manner, with the same exchangeability assumptions, as earlier described. Note that the matrices $\mathbf{H}^{(rs)}$ are not considered to be spatially dependent in this model. \subsubsection{White Noise} \label{subsubsec: white} Next, attention turns to the specification of a generative model for the noise process $\mathbf{Z}$. In what follows three candidate models are considered, each arising in some way from the standard white noise model. The simplest of these models is just the white noise model itself, described first. Let $Z^{(j)} := W^{(r)}$ be a spatial random white noise process on $\mathcal{M}$, defined as an $L^2(\mathcal{M})$-bounded generalised Gaussian field such that, for any test functions $\{\varphi_i \in L^2(\mathcal{M}) : i = 1,\dots,n\}$, the integrals $\langle \varphi_i , W^{(j)} \rangle_\mathcal{M}$, $i = 1, \dots, n$, are jointly Gaussian with \begin{align} \mathbb{E} \langle \varphi_i , W^{(j)} \rangle_\mathcal{M} & = 0 \nonumber \\ \mathbb{C}( \langle \varphi_i , W^{(j)} \rangle_\mathcal{M} , \langle \varphi_j , W^{(j)} \rangle_\mathcal{M} ) & = \langle \varphi_i , \varphi_j \rangle_\mathcal{M} . \label{eq: White def 2} \end{align} It is not necessary to introduce a scale parameter for the noise process since the $\tau^{(rs)}$ parameters perform this role in the SPDE. For this choice of noise model the random field $u$ of interest is typically continuous but not mean-square differentiable, which may or (more likely) may not be an appropriate mathematical description of the material. \subsubsection{Smoother Noise} \label{subsubsec: smoother noise} It is difficult to determine an appropriate level of smoothness for the random field $u$ based on visual inspection, except to rule out models that cannot be physically realised (c.f. Section \ref{subsubsec: iso model}). For this reason, a smoother model for the noise process $\mathbf{Z}$ was also considered. In this case the noise process is itself the solution of an SPDE \begin{align} (\eta^{(r)} - \nabla \cdot \mathbf{H} \nabla) Z^{(r)}(x) & = W^{(r)}(x) & x \in \mathcal{M} \label{eq: smooth noise pde} \\ \partial_{\mathrm{n}} Z^{(r)}(x) & = 0 & x \in \partial\mathcal{M} \nonumber \end{align} where $W^{(r)}$ is the white noise process defined in Section \ref{subsubsec: white}. To limit scope, it was assumed that the matrix $\mathbf{H}$ is the same as the matrix used (if indeed one is used) in the construction of the differential operator in Sections \ref{subsubsec: aniso model} and \ref{subsubsec: ani nonstat}. The only free parameters are therefore $\eta^{(1)}, \eta^{(2)} > 0$ and the further exchangeability assumption was made that these two parameters are equal. For this choice of noise model the random field $u$ of interest is typically twice differentable in the mean square sense, which may or may not be more realistic than the white noise model. \subsubsection{Smooth Oscillatory Noise} \label{subsubsec: smo osc noise} The final noise model allows for the possibility of oscillations in the realisations of $\mathbf{Z}$. As explained in Appendix C4 of \cite{Lindgren2011}, such noise can be formulated as arising from the complex SPDE \begin{align*} (\eta e^{i \pi \theta} - \nabla \cdot \mathbf{H} \nabla ) [ Z^{(1)}(x) + i Z^{(2)}(x) ] & = W^{(1)}(x) + i W^{(2)}(x) & x \in \mathcal{M} \\ \partial_n [Z ^{(1)}(x) + i Z^{(2)}(x) ] & = 0 & x \in \partial\mathcal{M} . \end{align*} Here $\eta > 0$ and $0 \leq \theta < 1$ are to be specified, with $\theta = 0$ corresponding to the smoother noise model of \Cref{subsubsec: smoother noise}. The matrix $\mathbf{H}$ is again assumed to be equal to the corresponding matrix used (if indeed one is used) in the construction of the differential operator in Sections \ref{subsubsec: aniso model} and \ref{subsubsec: ani nonstat}, and $W^{(1)}$ and $W^{(2)}$ are independent white noise processes as defined in Section \ref{subsubsec: white}. This completes the specification of candidate models for $\mathcal{L}$ and $\mathbf{Z}$, constituting 12 different models for the random vector field $u$ in total. These will be denoted $M_i$, $i = 1,\dots,12$ in the sequel. Section \ref{sec: results} seeks to identify which of these models represents the best description of the panel training dataset. \section{Data Pre-Processing and Model Selection} \label{sec: results} This section proceeds as follows: In Section \ref{subsec: set up} the training dataset is described and Section \ref{subsec: preprocess} explains how it was pre-processed. Section \ref{subsec: model select} describes how formal statistical model selection was performed to identify a ``best'' model from the collection of 12 models just described. The fitting of model parameters raises substantial computational challenges, which this paper does not fully solve but discusses in detail. \subsection{Experimental Set-Up} \label{subsec: set up} The data were obtained from large sheets of notional 3.5mm thickness manufactured by the Dutch company MX3D (\url{https://mx3d.com}) using their proprietary printing protocol. The dataset consisted of 6 panels of approximate dimensions 300mm $\times$ 300mm, cut from a large sheet. These panels were digitised using a laser scanner to form a data point cloud; the experimental set-up and a typical dataset are displayed in Figure \ref{fig: protocol}. The measuring process itself can be considered to be noiseless, due to the relatively high (0.1mm) resolution of the scanning equipment. For each panel a dense data point cloud was obtained, capturing the geometry of both sides of the panel. \subsection{Data Pre-Processing} \label{subsec: preprocess} Before data were analysed they were pre-processed and the steps taken are now briefly described. \subsubsection{Cropping of the Boundary} First, as is clear from Figure \ref{fig: example panel}, part of the boundary of the panel demonstrates a high level of variation. This variation is not of particular interest, since in applications the edges of a component can easily be smoothed. Each panel in the dataset was therefore digitally cropped using a regular square window to ensure that boundary variation was removed. Note that no reference coordinate system was available and therefore the orientation of the square window needed to be determined (i.e. a \textit{registration} task needed to be solved). To identify the direction perpendicular to the plane of the panel a principal component analysis of the data point cloud was used to determine the direction of least variation; this was taken to be the direction perpendicular to the plane of the panel. To orient the square window in the plane a coordinate system was chosen to maximise alignment with the direction of the weld bands. The weld bands are clearly visible (see Figure \ref{fig: example panel}) and the average intensity of a Gabor filter was used to determine when maximal agreement had been reached \citep[see e.g.][]{Weldon1996}. \subsubsection{Global De-Trending} As a weld cools, a contraction in volume of the material introduces \emph{residual stress} in the large sheet \citep{Radaj2012}. As a consequence, when panels are cut from the large sheet these stresses are no longer contained, resulting in a global curvature in each panel as internal forces are re-equilibrated. This phenomenon manifests as a slight curvature in the orthographic projections of the panel shown in Figure \ref{fig: example panel}. The limited size of the dataset, in terms of the number of panels cut from the large sheet, precludes a detailed study of geometric variation due to residual stress in this work. Therefore residual stresses were removed from each panel dataset by subtracting a quadratic trend, fitted using a least-squares objective in the direction perpendicular to the plane of the panel. This narrows focus to the variation that is associated with imprecision in the motion of the print head as steel is deposited. The data at this stage constitute a point cloud in $\mathbb{R}^3$ that is centred around a two-dimensional, approximately square manifold $\mathcal{M}$, aligned to the $x$ and $y$ axes in $\mathbb{R}^3$. \subsubsection{High-Frequency Filter} Closer inspection of Figure \ref{fig: example panel} reveals small bumps on the surface of the panel. These are referred to as ``splatter'' and result from small amounts of molten steel being sprayed from the weld head as subsequent layers of the sheet are printed. Splatter is not expected to contribute much to the performance of the material and therefore is of little interest. To circumvent the need to build a statistical model for splatter, a pre-processing step was used in order to remove such instances from the dataset. For this purpose a two-dimensional Fourier transform was applied independently to each surface of each panel and the high frequencies corresponding to the splatter were removed. Since data take the form of a point cloud, the data were first projected onto a regular Cartesian grid, with grid points denoted $x_i \in \mathcal{M}$, in order that a fast Fourier transform could be performed. The frequencies for removal were manually selected so as to compromise between removal of splatter and avoidance of smoothing of the relevant variation in the dataset. The resolution of the grid was taken to be 300$\times$300 (i.e. millimeter scale), which was fine enough to capture relevant variation whilst also enabling the computational analyses described in the sequel. \subsubsection{Pre-Processed Dataset} \label{subsubsec: preproc dataset} The result of pre-processing a panel dataset is a collection of triples $$ (x_i,u_i^{(1)},u_i^{(2)}) $$ where $x_i \in \mathcal{M}_1$ represents a location in the manifold representation $\mathcal{M}_1$ of the panel, $u_i^{(1)} = u^{(1)}(x_i) \in \mathbb{R}$ represents the measured Euclidean distance of the upper surface of the panel from $x_i \in \mathcal{M}_1$ and $u_i^{(2)} = u^{(2)}(x_i) \in \mathbb{R}$ represents the measured Euclidean distance of the lower surface of the panel from $x_i \in \mathcal{M}_1$. The subscript on $\mathcal{M}_1$ indicates that the training data are associated to this manifold; a test manifold $\mathcal{M}_2$ will be introduced in Section \ref{subsec: predict cylinder 1}. The latent two-dimensional vector field $u$ describes the continuous geometry of the specific panel and it is the statistical nature of these vector fields which will be modelled. In the sequel a collection of candidate models for $u$ are considered, each based on a Gaussian stochastic process. The pre-processed data for a panel are collectively denoted $\mathcal{D}^{(j)}$, where $j \in \{1,\dots,6\}$ is the index of the panel. The collection of all 6 of these panel datasets is denoted $\mathcal{D}_1$, the subscript indicating that these constitute the training dataset. \subsection{Model Selection} \label{subsec: model select} To perform formal model selection among the candidate models an information criterion was used, specifically the Akaike information criterion (AIC) \begin{align} \text{AIC}(M) = 2 \text{dim}(\hat{\theta}_M) - 2 \log p(\mathcal{D}_1 | \hat{\theta}_M , M) , \label{eq: AIC} \end{align} where $p(\mathcal{D}_1 | \theta_M , M)$ denotes the likelihood associated with the training dataset $\mathcal{D}_1$ under the SPDE model $M$, whose parameters are $\theta_M$, and $\hat{\theta}_M$ denotes a value of the parameter $\theta_M$ for which the likelihood is maximised. Small values of AIC are preferred. The parameter vector $\theta_M$ can be decomposed into parameters that are identical for each panel dataset $\mathcal{D}^{(j)}$, denoted $\theta_M^\text{id}$, and those that are specific to a panel dataset $\mathcal{D}^{(j)}$, denoted $\theta_M^{(j)}$. The latter are essentially random effects and consist of the Fourier coefficients $\gamma_\tau^{(\cdot)}$ and $\gamma_\eta^{(\cdot)}$ in the case where $M$ is a non-stationary model (Sections \ref{subsubsec: nonstat model} and \ref{subsubsec: ani nonstat}), otherwise $\theta_M^{(j)}$ is empty and no random effects are present. The panel datasets $\mathcal{D}^{(j)}$ that together comprise the training dataset $\mathcal{D}_1$ are considered to be independent given $\theta_M$ and $M$, so that \begin{align} p(\mathcal{D}_1 | \theta_M, M) = \prod_{j=1}^6 p(\mathcal{D}^{(j)} | \theta_M^{\text{id}}, \theta_M^{(j)}, M) . \label{eq: likelihood} \end{align} The maximisation of \eqref{eq: likelihood} to obtain $\hat{\theta}_M$ requires a global optimisation routine and this will in general preclude the exact evaluation of the AIC for the statistical models considered. Following standard practice, $\hat{\theta}_M$ was therefore set to be the output of a numerical optimisation procedure applied to maximisation of \eqref{eq: likelihood}. A drawback of the SPDE approach is that implementation of an effective numerical optimisation procedure is difficult due to the considerable computational cost involved in differentiating the likelihood. To obtain numerical results, this work arrived, by trial-and-error, at a procedure that contains the following ingredients: \vspace{5pt} \noindent \textbf{Gradient ascent:} In the case where $M$ is a stationary model, so the $\theta_M^{(j)}$ are empty, the maximum likelihood parameters $\hat{\theta}_M^{\text{id}}$ were approximated using the natural gradient ascent method. This extracts first order gradient information from \eqref{eq: likelihood} and uses the Fisher information matrix as a surrogate for second order gradient information, running a quasi-Newton method that returns a local maxima of the likelihood. Full details are provided in Appendix A.4. \vspace{5pt} \noindent \textbf{Surrogate likelihood:} The use of gradient information constitutes a computational bottleneck, due to the large dense matrices involved, which motivates the use of a surrogate likelihood within the gradient ascent procedure whose Fisher information is more easily computed \citep{Tajbakhsh2014}. For this paper a surrogate likelihood was constructed based on a subset of the dataset, reduced from the 300 $\times$ 300 grid to a 50 $\times$ 50 grid in the central portion of the panel. Natural gradient ascent was feasible for the surrogate likelihood. It is hoped that minimisation of this surrogate likelihood leads to a suitable value $\hat{\theta}_M$ with respect to maximising the exact likelihood, and indeed the values that reported in the main text are evaluations of the exact likelihood at $\hat{\theta}_M$. \vspace{5pt} \noindent \textbf{Two-stage procedure for random effects:} The case where $M$ is non-stationary is challenging for the natural gradient ascent method, even with the surrogate likelihood, due to the much larger dimension of the parameter vector when the random effects $\theta_M^{(j)}$ are included. In this case a two-stage optimisation approach was used, wherein the common parameters $\theta_M^{\text{id}}$ were initially fixed equal to their values under the corresponding stationary model and then optimised over the random effects $\theta_M^{(j)}$ using natural gradient ascent, which can be executed in parallel. \vspace{5pt} These approximation techniques combined to produce the most robust and reproducible parameter estimates that the authors were able to achieve, but it is acknowledged that they do not guarantee finding a local maximum of the likelihood and this analytic/numerical distinction can lead to pathologies that are discussed next. The computations that we report were performed in Matlab R2019b and required approximately one month of CPU time on a Windows 10 laptop with an Intel$^\text{\textregistered}$ Core\texttrademark i7-6600U CPU and 16GB RAM. The number of iterations of natural gradient ascent required to achieve convergence ranged from 10 to 80 and was model-dependent. Models with $\geq 100$ parameters required several days of computation, while the simpler models with $<10$ parameters typically required less than one day of computation in total. \begin{table}[t] \footnotesize \centering \begin{tabular}{|>{\centering\arraybackslash}p{1cm}>{\centering\arraybackslash}p{1cm}>{\centering\arraybackslash}p{1.7cm}cccc|} \hline \multirow{2}{*}{\rotatebox{20}{Isotropic}} & \multirow{2}{*}{\rotatebox{20}{Stationary}} & \multirow{2}{*}{\rotatebox{20}{Noise}} & & \multicolumn{2}{c}{\textbf{Log-likelihood}} & \\ & & & \textbf{\# Parameters} & surrogate & exact & \textbf{AIC} \\ \hline \ding{51} & \ding{51} & white & 4 & 21,187 & 1,041,766 & -2,083,524 \\ \ding{51} & \ding{51} & smoother & 5 & 21,775 & 1,154,950 & -2,309,890 \\ \ding{51} & \ding{51} & sm. oscil. & 6 & 22,752 & 1,208,810 & -2,417,608 \\ \ding{51} & \ding{55} & white & 100 & 24,404 & 774,539 & -1,548,878 \\ \ding{51} & \ding{55} & smoother &101 & 25,900 & 1,023,561 & -2,046,920 \\ \ding{51} & \ding{55} & sm. oscil. & 102 & 29,118 & 1,042,737 & -2,085,270 \\ \ding{55} & \ding{51} & white & 6 & 22,005 & 1,100,358 & -2,200,704 \\ \ding{55} & \ding{51} & smoother & 7 & 23,166 & 1,164,952 & -2,329,890 \\ \ding{55} & \ding{51} & sm. oscil. & 8 & 25,151 & 1,233,936 & -2,467,856 \\ \ding{55} & \ding{55} & white & 102 & 25,385 & 914,913 & -1,829,622 \\ \ding{55} & \ding{55} & smoother & 103 & 26,336 & 1,056,735 & -2,113,264 \\ \ding{55} & \ding{55} & sm. oscil. & 104 & 28,150 & 1,111,449 & -2,222,690 \\ \hline \end{tabular} \caption{Model selection based on the training dataset $\mathcal{D}_1$. The first three columns indicate whether the differential operator $\mathcal{L}$ was isotropic and stationary and the driving noise process $\mathbf{Z}$ that was used. The remaining columns indicate the number of free parameters in each model, the approximately maximised values of the surrogate and exact log-likelihood and the Akaike information criterion (AIC). [The log-likelihood and AIC values are rounded to the nearest integer.] } \label{tab: AIC} \end{table} The twelve candidate models are presented in the first three columns of Table \ref{tab: AIC}, together with the dimension $\text{dim}(\theta_M)$ of their parameter vector, the (approximately) maximised value of the surrogate and exact log-likelihood and the AIC. The main conclusions to be drawn are as follows: \vspace{5pt} \noindent \textbf{Isotropy:} In all cases the anisotropic models for $\mathcal{L}$ out-performed the corresponding isotropic models according to both the (approximately) maximised exact log-likelihood and the AIC. (The same conclusion held for 5 of 6 comparisons based on the surrogate likelihood.) Since the anisotropic model includes the isotropic model as a special case, these higher values of the likelihood are to be expected, but the AIC conclusion is non-trivial. (Inspection of the log-likelihood does, however, provide a useful validation of the optimisation procedure that was used.) \vspace{5pt} \noindent \textbf{Stationarity:} In all cases the non-stationary models for $\mathcal{L}$ out-performed the corresponding stationary models according to the (approximately) maximised surrogate log-likelihood, which is to be expected since these models are nested. However, the conclusion was \emph{reversed} when the parameters $\hat{\theta}_M$, estimated using the surrogate likelihood, were used to evaluate the exact likelihood. These results suggest that the two-stage numerical optimisation procedure for estimation of random effects was robust but that the surrogate likelihood was lossy in respect of information in the dataset that would be needed to properly constrain parameters corresponding to non-stationarity in the model. \vspace{5pt} \noindent \textbf{Noise model:} In all cases the smooth oscillatory noise models for $\mathbf{Z}$ led to substantially lower values of the surrogate and the exact log-likelihood compared to the white noise and smooth noise models. This is to be expected since these models are nested, but the fact that this ordering was recovered in both the values of the surrogate and exact log-likelihood indicates that the numerical procedure worked well in respect of fitting parameters pertinent to the noise model. \vspace{5pt} \noindent \textbf{Best model:} The best-performing model, denoted $M^*$ in the sequel, was defined as the model that provided the smallest value of AIC, computed using the (approximately) maximised exact likelihood. This was the anisotropic stationary model $\mathcal{L}$ with smooth oscillatory noise $\mathbf{Z}$, which had 8 parameters and achieved a substantially lower value of AIC compared to each of the 11 candidate models considered. Although the use of AIC in this context is somewhat arbitrary and other information criteria could also have been used, the substantially larger value of the log-likelihood for the best-performing model suggests that use of an alternative information criterion is unlikely to affect the definition of the best-performing model. If instead the surrogate likelihood had been used to produce values for AIC, it would have declared that the best-performing model also includes non-stationary behaviour. This suggests that the aforementioned ``best'' model is more accurately described as the ``best model that could be fitted'' and that, were the computational challenges associated with parameter estimation in the SPDE framework surmounted, a model that involves non-stationarity may have been selected. This suggests that additional models of further complexity may provide better descriptions of the data, at least according to AIC, but that fitting of model parameters presents a practical barrier to the set of candidate models that can be considered. The remainder investigates whether predictions made using the simple model $M^*$ may still be useful. \section{Transfer Learning} This section aims to assess the capacity of our selected statistical model $M^*$ to perform transfer learning, and proceeds as follows: Section \ref{subsec: predict cylinder 1} assesses the performance of the statistical model in the context of a 3D-printed cylinder, which constitutes a held-out test dataset. Then, Section \ref{subsec: predict cylinder 2} implements finite element simulations of compressive testing based on the fitted model and compares these against the results of a real compressive experiment. \subsection{Predictive Performance Assessment} \label{subsec: predict cylinder 1} To investigate the generalisation performance of the model $M^*$ identified in Section \ref{subsec: model select}, a test dataset, denoted $\mathcal{D}_2$ and displayed in Figure \ref{subfig: real cylinder}, was obtained as a laser scan of a 3D-printed cylinder of diameter $\approx$170mm and length $\approx$581mm. The notional thickness of the cylinder was 3.5mm, in agreement with the training dataset. The manifold representation of the panel is denoted $\mathcal{M}_1$ and the manifold representation of the cylinder is denoted $\mathcal{M}_2$. The fitted model $M^*$ induces a bivariate Gaussian field on any suitably regular manifold, in particular $\mathcal{M}_2$. A sample from this model is displayed in Figure \ref{subfig: cylinder sample}. At a visual level, the ``extent'' of the variability is similar between Figure \ref{subfig: real cylinder} and Figure \ref{subfig: cylinder sample}, but the experimentally produced cylinder contains more prominent banding structure compared to the cylinder simulated from $M^*$. The thickness of the cylinder wall is relevant to its mechanical performance when under load. Recall that $M^*$ was not explicitly trained as a predictive model for thickness; rather, thickness is a derived quantity of interest. It is therefore interesting to investigate whether the distribution of material thickness, accouring to $M^*$ instantiated on $\mathcal{M}_2$, agrees with the experimentally obtained test dataset. Results in Figure \ref{subfig: thickness} indicate that the fitted model agrees with the true distribution of material thickness in as far as the modal value and the right tail are well-approximated. However, the true distribution is positively skewed and the model $M^*$, under which thickness is necessarily distributed as a Gaussian random field, is not capable of simultaneously approximating also the left tail. From an engineering perspective, the model $M^*$ is conservative in the sense that it tends to under-predict wall thickness, in a similar manner to how factors of safety might be employed. The predictive likelihood of a held-out test dataset is often used to assess the predictive performance of a statistical model. However, there are two reasons why such assessment is unsuitable in the present context: First, the pre-processing of the training dataset, described in Section \ref{subsec: preprocess}, was adapted to the manifold $\mathcal{M}_1$ of the training dataset and cannot be directly applied to the manifold $\mathcal{M}_2$ of the test dataset. This precludes a fair comparison, since the fitted statistical model is not able to explain the high-frequency detail (such as weld splatter, visible in Figure \ref{subfig: real cylinder}) that are present in the test dataset $\mathcal{D}_2$ but were not included in the training dataset. Second, recall that the purpose of the statistical model is limited to capturing aspects of geometric variation that are consequential in engineering. The predictive likelihood is not well-equipped to determine if the statistical model is suitable for use in the engineering context. For a more detailed assessment of the statistical model and its predictive performance in the engineering context, finite element simulations of cylinders under load were performed, described next. \begin{figure}[t!] \centering \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width = \textwidth,clip,trim = 0cm -4cm 0cm 0cm]{figures/test_dataset_brighter} \caption{} \label{subfig: real cylinder} \end{subfigure} \begin{subfigure}[b]{0.3\textwidth} \includegraphics[width = \textwidth,clip,trim = 0cm -4cm 0cm 0cm]{figures/simulated_dataset_brighter} \caption{} \label{subfig: cylinder sample} \end{subfigure} \begin{subfigure}[b]{0.33\textwidth} \includegraphics[width = \textwidth,clip,trim = 7cm 11.7cm 7cm 12cm]{figures/thickness} \caption{} \label{subfig: thickness} \end{subfigure} \caption{(a) Laser scan of a section from a real 3D-printed cylinder. (b) Sample from the fitted model $M^*$ generated based on a cylindrical manifold. (c) The distribution over the thickness of the wall of the real (blue, shaded) and the simulated (red, solid) 3D-printed cylinder.} \label{fig: cylinder samples} \end{figure} \subsection{Application to Compressive Testing} \label{subsec: predict cylinder 2} As discussed in Section \ref{subsec: candidates}, the aim of this work is to model those aspects of variability that are salient to the performance of components manufactured from 3D-printed steel. To this end, predictions were generated for the outcome of a compressive test of a cylinder. This test, which was also experimentally performed, involved a cylinder of the same dimensions described in Section \ref{subsec: predict cylinder 1}, which was machined to ensure that its ends are parallel to fit the testing rig. The test rig consisted of a pair of end plates which compress the column ends axially. The cylinder was placed under load until a set amount of displacement has been reached. Both strain gauge and digital image correlation measurements of displacement under a given load were taken; further details may be found in \cite{Buchanan2018TESTINGOW}. \begin{figure}[t!] \centering \begin{subfigure}[b]{0.19\textwidth} \centering \includegraphics[height = 0.3\textheight,clip,trim = 25cm 2cm 25cm 2cm]{figures/rendered1} \caption{} \end{subfigure} \begin{subfigure}[b]{0.19\textwidth} \centering \includegraphics[height = 0.3\textheight,clip,trim = 25cm 2cm 25cm 2cm]{figures/rendered2} \caption{} \end{subfigure} \begin{subfigure}[b]{0.19\textwidth} \centering \includegraphics[height = 0.3\textheight,clip,trim = 25cm 2cm 25cm 2cm]{figures/rendered3} \caption{} \end{subfigure} \begin{subfigure}[b]{0.19\textwidth} \centering \includegraphics[height = 0.3\textheight,clip,trim = 0cm 0cm 3.2cm 0cm]{figures/real_buckle} \caption{} \end{subfigure} \begin{subfigure}[b]{0.19\textwidth} \centering \includegraphics[height = 0.3\textheight,clip,trim = 3cm 0cm 0cm 0cm]{figures/real_buckle} \caption{} \end{subfigure} \caption{Predicting the outcome of a compressive test on a 3D-printed cylinder, using the fitted generative model $M^*$ for the geometry of the cylinder and a finite element simulation of the experiment. (a-c) Samples from the generative model for the geometry of the cylinder after the simulated compressive test. (d-e) Buckled cylinders, experimentally produced. \citep[Reproduced with permission from][]{Buchanan2018TESTINGOW}. } \label{fig: FEM results} \end{figure} To produce a predictive distribution over possible outcomes of the test, three geometries were simulated for the cylinder using $M^*$ and finite element simulations of the compressive test were performed, using these geometries in the construction of the finite element model. To facilitate these simulations a simple homogeneous model for the mechanical properties of the material was used, whose values were informed by the coupon testing undertaken in \cite{Buchanan2018TESTINGOW}. This is not intended as a realistic model for the mechanical properties of 3D-printed steel. Indeed, as discussed in Section \ref{sec: intro}, it is expected that 3D-printed steel exhibits local variation in mechanical properties such as stiffness; the focus of this paper is surface metrology (only) and joint modelling of geometric and mechanical variation for 3D-printed steel will be addressed in future work. Three typical end points from the finite element simulation are displayed in Figure \ref{fig: FEM results}, panels (a)-(c). Notice that local variation in geometry leads to non-trivial global variation in the location of the buckling point. Panel (d) in Figure \ref{fig: FEM results} displays the buckled states of two real 3D-printed steel cylinders, experimentally obtained. At a visual level there is some qualitative agreement in the appearence of these failure modes. The approach taken in this paper can be contrasted with approaches in the engineering literature that do not generalise across manifolds and do not report full probability distributions \citep{wagner2020probabilistic}. However, an important caveat is that the precise quantitative relationship between load and displacement in these simulations is not yet meaningful due to the simplistic model used for material properties. Further research will be required to incorporate these aspects into a complete statistical model for 3D-printed steel. \section{Discussion} \label{sec: conclusion} This paper identified surface metrology as a promising new application area for recent advances in spatial statistics. Though attention was focussed on 3D-printed stainless steel, the techniques and methods have the potential for application to a wide variety of problems in this engineering sub-field. Our approach sought to decouple the local statistical properties of the geometric variation from the global shape of the component, which offered the potential for transfer learning; i.e. conclusions drawn from one component to be carried across to a possibly different component. This assumption is intuitively reasonable for components that do not involve high levels of curvature, but its appropriateness for general components remains to be tested. To achieve this we exploited the SPDE framework. However, these was a practical limitation on the complexity of SPDE that could be reliably fit, since gradients of the likelihood required large dense matrices to be computed. As a result, it is possible that models that are too simple but whose parameters can be successfully optimised may be prefered to more parsimonious models whose parameters cannot easily be optimised. In other applications of surface metrology where generalisation across manifolds is not required, model fitting and model selection could be more easily achieved using the traditional covariance function framework \citep[e.g.][]{Rasmussen2006,Duvenaud2014,Bazavan2012,Oliva2016,Moeller2016}. The principal mathematical assumption that made transfer learning possible in this work was the identification of Laplacians across different manifolds, corresponding to the different components that can in principle be manufactured. This assumption (together with knowledge of the printing direction) enabled the meaning of a statistical model to be unambiguously interpreted across different manifolds, despite the fact that in general there are an infinitude of different geometries with which a given manifold can be equipped. Gaussian process models arise naturally in this context, since in specific cases they can be conveniently expressed in terms of the Laplacian via the SPDE framework. Alternative statistical models could also be considered: For example, the eigenfunctions $\{E_k : k = 0,1,\dots\}$ of the negative Laplacian $-\Delta_{\mathcal{M}}$ form a basis for $L^2(\mathcal{M})$, and one can consider more general generative models for the random fields $u_1,u_2 \in L^2(\mathcal{M})$ based on linear combinations of the $E_k$ with non-Gaussian coefficients \citep[see e.g.][]{hosseini2017well,sullivan2017well}. However, computational methods for non-Gaussian models remain relatively under-developed at present. The scope of this investigation was limited to describing the geometric variation of 3D-printed steel and there are many interesting questions still to be addressed. These include statistical modelling of the mechanical properties of the material, optimisation of the printing protocol to maximise the performance of (or reduce the variability in performance of) a given component, and adaptive monitoring and control of the manufacturing process to improve the quality of the printed component. These important problems will need to be collaboratively addressed; see \citet{Dodwell2021}. The same printing protocol that we studied was recently used to construct an entire pedestrian bridge using 3D-printed steel \citep{Zastrow2020}. To ensure the safety of the bridge for pedestrians, extensive engineering assessment and testing were required. A long-term goal of this research is to enable such assessment to be partly automated {\it in silico} before the component is printed. This would in turn reduce the design and testing costs associated with components manufactured with 3D-printed steel. \paragraph*{Supplementary Materials} The electronic supplement contains a detailed description of how computation was performed, together with the Matlab R2019b code that was used. \paragraph*{Acknowledgements} The authors wish to thank the Editor, Associate Editor, and two Reviewers for their valuable comments on the manuscript. This research was supported by the Lloyd's Register Foundation programme on data-centric engineering and the Alan Turing Institute (under the EPSRC grant EP/N510129/1). WSK gratefully acknowledges support from the UK EPSRC (grant EP/K031066/1). The authors are grateful to Craig Buchanan, Pinelopi Kyvelou and Leroy Gardner for providing the laser-scan datasets and to MX3D, from whom the material samples were provided. In addition, the authors are grateful for discussions with Alessandro Barp, Tim Dodwell, Mark Girolami, Peter Gosling and Rob Scheichl. } \fi \newpage \if1\supplement {
{'timestamp': '2022-10-04T02:23:10', 'yymm': '2111', 'arxiv_id': '2111.07745', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07745'}
arxiv
\section{Introduction} Many stochastic problems in finance and risk management are high-dimensional with a univariate quantity of interest, say $\mu=\mathbb{E}(\Psi(\bm{X}))$ for some integrable function $\Psi:\mathbb{R}^d\rightarrow\mathbb{R}$ and random vector $\bm{X}\sim F_{\bm{X}}$ for some $d$-dimensional distribution function $F_{\bm{X}}$. Because $\mu$ rarely allows for an analytical expression, the plain Monte Carlo (MC) estimator $\hat{\mu}^\text{\tiny{MC}}_n=(1/n)\sum_{i=1}^n\Psi(\bm{X}_i)$ where $\bm{X}_1,\dots,\bm{X}_n\omu{\text{\tiny{ind.}}}{\sim}{} F_{\bm{X}}$ is a popular choice for finding approximate solutions to such problems. It is unbiased and has an estimation error converging to zero at a rate independent of the dimension of the problem is often popular for finding approximate solutions to such problems. The drawback of plain MC is the high computational cost it requires to obtain an estimate with a sufficiently small error. This issue is particularly severe for rare-event simulation, i.e., when $\P(|\Psi(\bm{X})|>0)$ is small, as then a typically very large number of samples is required to obtain non-zero observations and therefore an estimator with small variance. As such, plain MC is often combined with variance reduction techniques (VRTs), such as control variates (see, e.g., \cite{lavenbergwelch1981}) or stratified sampling (SS) (see, e.g., \cite{cochran2005}) to make the variance and thus the width of the estimate's confidence interval small. Importance sampling (IS) is a VRT frequently applied to rare-event analysis in order to improve the reliability of MC estimators; see, e.g., \cite{kahnmarshall1953} and \cite{asmussenglynn2007}. The main idea of IS is to draw samples from a proposal distribution that puts more mass on the rare-event region of the sample space than the original distribution. As the efficiency of IS depends heavily on the choice of the proposal distribution, finding a good proposal distribution is a crucial step in applying IS. Unfortunately, there is no single best strategy known for finding a good proposal distribution that works in every situation since the nature of the rare event and what constitutes a good proposal distribution depends on the problem at hand; that is, on $\Psi$ and $F_{\bm{X}}$. As such, much of the existing work on IS in computational finance finds effective proposal distributions by exploiting the structure of specific problems: \cite{glassermanheidelbergershahabuddin1999} develop IS methods to price path-dependent options under multivariate normal models; \cite{glassermanheidelbergershahabuddin2000, glassermanheidelbergershahabuddin2002} estimate the Value-at-Risk of a portfolio consisting of stocks and options under a normal and $t$-distribution; \cite{sakhormannleydold2010} estimate tail probabilities of equity portfolios under generalized hyperbolic marginals with a $t$-copula assumption; \cite{glassermanli2005} estimate tail probabilities of credit portfolios under the Gaussian copula, \cite{bassamboojunejazeevi2008, chankroese2010} consider $t$-copula models. As all these IS techniques are exploiting specific properties of the problem at hand, they can achieve substantial variance reduction but are typically specific techniques not applicable to other problems without major modifications. The contribution of this work is the development of theory and algorithms to apply IS for a wide range of problems by introducing a conditioning sampling step and optimally twisting the distribution of the conditioning variable. Let $T=T(\bm{X})$ be some univariate random variable, such as $\bm{\beta}^{\top}\bm{X}$ for some (well chosen) $\bm{\beta}\in\mathbb{R}^d$, and assume sampling from $\bm{X} \mid T$ is feasible. If $T$ has density $f$ (resp., $g$) under the original (resp., proposal) distribution (both distributions assumed to have the same support $\Omega_T$ for now), let $$\hat{\mu}^{\text{\tiny{IS}}}_n = (1/n) \sum_{i=1}^n \Psi(\bm{X}_i) f(T_i)/g(T_i),\quad T_i\omu{\text{\tiny{ind.}}}{\sim}{} g,\quad \bm{X}_i \omu{\text{\tiny{ind.}}}{\sim}{} F_{\bm{X}\mid T}(\cdot \mid T = T_i),\quad i=1,\dots,n.$$ If $T$ explains much of the variability of the output, so if $R^2 := \operatorname{Var}( \mathbb{E}(\Psi(\bm{X}) \mid T) ) / \operatorname{Var}(\Psi(\bm{X}))$ is large, we can choose $g$ optimally and make the rare event more likely by changing the distribution of $\bm{X}$ through changing the distribution of the univariate $T$. Many high dimensional financial problems are of this nature; see, e.g., \cite{caflischrusselmorokoffowen1997, wangfang2003, wangsloan2005, wang2006}. In order to analyze our estimator, we work with the semi-parametric model $$\Psi(\bm{X})=m(T)+\varepsilon_{\bm{X},T}$$ for some (unknown) transformation $T:\mathbb{R}^d\rightarrow\mathbb{R}$, where $m^{(k)}(t)=\mathbb{E}(\Psi(\bm{X})^k\mid T)$ for $k\in\mathbb{N}$ and $\varepsilon_{\bm{X},T}$ is a random error so that $\varepsilon_{\bm{X},T}\mid T$ has mean 0 and variance $v^2(t)=\operatorname{Var}(\Psi(\bm{X})\mid T=t)$. We say that $\Psi(\bm{X})$ has a strong single index structure if $R^2$ is large (say, $R^2>0.9$), and the resulting estimator is referred to as Single Index IS (SIS) estimator. We will show that the optimal proposal distribution for $g$ under SIS is proportional to $(m^{(2)})^{1/2}(t)f(t)$ resulting in an estimator with variance no larger than the plain MC estimator. If the proposal distribution $g$ allows for a simple way to evaluate the quantile function $G_T^{-1}$ of $g$, we can further reduce the variance by applying equal stratification to the support of $T$, i.e., instead of sampling $T_1,\dots,T_n\omu{\text{\tiny{ind.}}}{\sim}{} g$, we can set $T_i = G_T^{-1}(U_i)$ where $U_k\omu{\text{\tiny{ind.}}}{\sim}{} \operatorname{U}( k/n, (k+1)/n)$ for $k = 0,\dots,n-1$ and $G_T^\i(u)=\inf\{t\in\mathbb{R}: G_T(t)\geq u\}$ is the quantile function of $T$ under $g$. The resulting method is referred to as stratified SIS (SSIS). We also derive optimal variance expressions in this case and show that (S)SIS gives zero variance when $R^2=1$. The derivation of these results along with some more notation and the connection between our methods and the IS and stratification techniques from \cite{arbenzcambouhofertlemieuxtaniguchi2018, glassermanheidelbergershahabuddin1999, neddermeyer2011} can be found in Section~\ref{sec:SIS:var:opt}. There, we also briefly explain how our conditional sampling step reduces the effective dimension of the problem and therefore makes quasi-Monte Carlo (QMC) particularly attractive in our setting; in QMC, pseudo-random numbers (PRNs) are replaced by more homogeneously distributed quasi-random numbers (see, e.g., see \cite{niederreiter1978, lemieux2009, dickpillichshammer2010}). Besides the choice of $g$, the performance of our procedure heavily depends on the choice of the transformation $T$, which must be chosen such that i) sampling from $\bm{X}\mid T$ is feasible and ii) $T$ explains a lot of the variability of $\Psi(\bm{X})$, i.e., $R^2$ is as close to 1 as possible. The choice of the transformation is clearly not unique. In our numerical examples, we typically assume that $T$ is a linear function of $\bm{X}$, whose coefficients can be estimated via the average derivative method of \cite{stoker1986}, the sliced inverse regression of \cite{li1991} or the semiparametric least-squares estimator of \cite{ichimura1993}. We remark that these methods do not require the form of the function $m(t)$ to be known. As seen earlier, the optimal proposal densities involve a conditional moment function that is not known in practice. We propose to estimate this function using pilot-runs. The resulting point-wise approximation to the optimal density function can then be integrated and inverted numerically using the NINIGL algorithm developed in \cite{hormannleydold2003}. When this is too time-consuming, we suggest finding an approximately optimal $g$ in the same parametric family as $f$ (e.g., a location-scale transform of the original density). We detail this calibration stage, i.e., the process of estimating $T$, the optimal density and a way to sample from it, in Section~\ref{sec:calibration}. In the numerical examples in Section~\ref{sec:numexp}, we demonstrate that our methods are applicable to a wide range of problems and achieve substantial variance reduction. After investigating a simple linear model example, we consider the problem of tail probability estimation in Gaussian and $t$-copula credit portfolio problems and show that our methods outperform those of \cite{glassermanli2005} and \cite{chankroese2010}. As our formulation of (S)SIS does not assume a specific $\Psi$ or $F_{\bm{X}}$, it is applicable to a wide range of problems and is efficient as long as the problem of interest has a strong enough single-index structure. It also adapts to the problem through the design of the one-dimensional transformation revealing the single-index structure and through the choice of the proposal distribution. Besides its applicability to a wide range of problems, our proposed method has the following advantages. First, as it applies IS only to the univariate transformation variable, SIS is less susceptible to the dimensionality problem of IS, which is discussed in \cite{aubeck2003, katafygiotiszuev2008, schuelleretal2004}. This also simplifies the task of finding an optimal proposal distribution. Second, SIS has a dimension reduction feature, so it enhances the effectiveness of QMC sampling methods. Third, by applying IS to a transformation of the input random vector $\bm{X}$, our proposal distribution amounts to changing the dependence structure of the problem under study, which can have a significant advantage over methods that only change the marginal distributions. We conclude this paper in Section~\ref{sec:conclusion}. \section{Variance analysis and optimal calibration for SIS and SSIS} \label{sec:SIS:var:opt} \subsection{Notations and definitions} To fix notation, recall we estimate $\mu = \mathbb{E}(\Psi(\bm{X}))$ via \begin{align*} \hat{\mu}^{\text{\tiny{SIS}}}_n = (1/n) \sum_{i=1}^n \Psi(\bm{X}_i) w(T_i),\quad T_i\omu{\text{\tiny{ind.}}}{\sim}{} g_T,\quad \bm{X}_i \omu{\text{\tiny{ind.}}}{\sim}{} F_{\bm{X}\mid T}(\cdot \mid T=T_i),\quad i=1,\dots,n, \end{align*} where $f_T$ and $g_T$ denote the original and proposal densities for $T$ with supports $\Omega_f=(t_{\inf},t_{\sup})$ (with possibly $t_{\inf},t_{\sup}\in\{\pm\infty\}$) and $\Omega_g$ and $w(t)=g_T(t)/f_T(t)$ is the IS weight function. Furthermore, we model the output $\Psi(\bm{X})$ as $\Psi(\bm{X})=m(T)+\varepsilon_{\bm{X},T}$, where \begin{align*} m^{(k)}(t)=\mathbb{E}(\Psi(\bm{X})^{k}\mid T),\quad \mathbb{E}(\varepsilon_{\bm{X},T}\mid T)=0,\quad \operatorname{Var}(\varepsilon_{\bm{X},T}\mid T)=v^2(t)=\operatorname{Var}(\Psi(\bm{X})\mid T). \end{align*} We already introduced the coefficient of determination $R^2 = \operatorname{Var}(m(T))/\operatorname{Var}(\Psi(\bm{X}))$ (see, e.g., \cite{kvaalseth1985}) and said that $\Psi(\bm{X})$ is a strong single-index model if $R^2$ is large. This can be true for any model $\Psi(\bm{X})$, as we allow $\varepsilon_{\bm{X},T}$ to depend on $\bm{X}$. However, a pure single index model is a situation where $\varepsilon_{\bm{X},T}=\varepsilon_T$ only depends on $\bm{X}$ through $T$. In that case, it is easy to see that $\mathbb{E}(\Psi(\bm{X})\mid T)=m(T)$, so that overall the random variable $\Psi(\bm{X})$ depends on $\bm{X}$ only through $T$. However, we do not impose the assumption of a pure single index model. Readers are referred to \cite{powellstockstoker1989}, \cite{hardlehallichimura1993} and \cite{ichimura1993} for more information on single-index models. Based on the representation of $\Psi(\bm{X})$ and using the law of total variance, we can write \begin{align}\label{eq:SIS:vardecomp} \operatorname{Var}(\Psi(\bm{X}))= \operatorname{Var}(m(T)) + \mathbb{E}(v^2(T)) = \operatorname{Var}(m(T)) + \operatorname{Var}(\varepsilon_{\bm{X},T}), \end{align} since $\mathbb{E}(v^2(T))=\operatorname{Var}(\varepsilon_{\bm{X},T})-\operatorname{Var}(\mathbb{E}(\varepsilon_{\bm{X},T}\mid T)) = \operatorname{Var}(\varepsilon_{\bm{X},T})$. We see that~\eqref{eq:SIS:vardecomp} decomposes the variance of $\Psi(\bm{X})$ into two pieces: the one of the (random) systematic part, $m(T)$ and the unsystematic error $\varepsilon_{\bm{X},T}$ of the model. Note that~\eqref{eq:SIS:vardecomp} holds irrespective of wether we have a pure single index model or not. In addition to applying IS on $T$, we also propose to use stratification on $T$ to further reduce the variance; it will turn out that this essentially ``stratifies away'' $\operatorname{Var}(m(T))$, the variance of the systematic part of the model. More precisely, let $\Omega_{f}=(t_{\inf},t_{\sup})$ where possibly $t_{\inf}=-\infty$ and $t_{\sup}=\infty$. The SSIS scheme splits $\Omega_{f}$ into $n$ strata of equal probability under $g$ and draws one sample of $T$ from each stratum. Our estimator becomes \begin{align*} \hat{\mu}^{\text{\tiny{SSIS}}}_n = (1/n) \sum_{i=1}^n \Psi(\bm{X}_i) w(T_i),\quad T_i=G_T^\i(U_i),\quad U_i\sim \operatorname{U}( (i-1)/n, i/n), \end{align*} and, as before, $\bm{X}_i \omu{\text{\tiny{ind.}}}{\sim}{} F_{\bm{X}\mid T}(\cdot \mid T=T_i)$ for $i=1,\dots,n$. For our variance analysis below, it is useful to find an expression for $\operatorname{Var}(\hat{\mu}^\text{\tiny{MC}}_n)$. Note that the conditional moment functions $m^{(k)}$ do not depend on wether we sample from $f_T$ or $g_T$. From~\eqref{eq:SIS:vardecomp} and the fact that $\operatorname{Var}(m(T))=\mathbb{E}(m(T))^2- \mu^2$ as well as $\mathbb{E}(v^2(T)) = \mathbb{E}(m^{(2)}(T))-\mathbb{E}(m(T))^2$, we find \begin{align}\label{eq:var:mu:MC} n \operatorname{Var}(\hat{\mu}^\text{\tiny{MC}}_n) = \operatorname{Var}(m(T))+\mathbb{E}(v^2(T)) = \mathbb{E}(m^{(2)}(T))-\mu^2. \end{align} As should be clear from the form of our estimators, their bias depends on the support $\Omega_{g}$ of $g_T$. We define \begin{align*}% \mu_{\text{\tiny{SIS}}} = \int_{\Omega_g} m(t)f_T(t)\;\mathrm{d} t, \quad \sigma_{\text{\tiny{SIS}}}^2=\int_{\Omega_g} m^{(2)}(t) \frac{f_T^2(t)}{g_T(t)}\;\mathrm{d} t - \mu_{\text{\tiny{SIS}}}^2, \quad \sigma_{\text{\tiny{SSIS}}}^2=\int_{\Omega_g} v^{2}(t) \frac{f_T^2(t)}{g_T(t)}\; \mathrm{d} t. \end{align*} Notice that $\mu_{\text{\tiny{SIS}}}$ depends on $g_T$ through the region $\Omega_{g}$. The SIS and SSIS estimators are unbiased only if $g_T$ is such that $g_T(t)>0$ whenever $m(t)f_T(t)>0$, but we do not impose this unbiasedness assumption on $g_T$. \subsection{Optimal densities} We are now able to derive properties of the (S)SIS estimators and derive the optimal (variance-minimizing) proposal distribution of $g_T$; see the appendix for the proofs. As the objective of our IS techniques is variance reduction, we call the practice of setting $g_T$ to its optimal density or their approximation as \emph{optimal calibration}, and the resulting methods $\operatorname{SIS}^*$ and $\operatorname{SSIS}^*$. \begin{proposition}[Variance-optimal SIS]\label{prop:IS} We have $\mathbb{E}(\hat{\mu}^{\text{\tiny{SIS}}}_n)=\mu_{\text{\tiny{SIS}}}$ and $\operatorname{Var}(\hat{\mu}^{\text{\tiny{SIS}}}_n)=\sigma_{\text{\tiny{SIS}}}^2/n$. If $\mathbb{E}_g(m^2(T)w^2(T)) < \infty$, then $\sqrt{n} (\hat{\mu}^{\text{\tiny{SIS}}}_n-\mu_{\text{\tiny{SIS}}}) \omu{\text{\tiny{d}}}{\rightarrow}{} \operatorname{N}(0,\sigma_{\text{\tiny{SIS}}}^2)$ as $n\rightarrow\infty$. Suppose that $\Psi(\bm{x}) \geq 0$ or $\Psi(\bm{x}) \leq 0 $ for all $\bm{x} \in \Omega_{\bm{X}}$. The density $g_T$ that gives an unbiased SIS estimator with the smallest variance is \begin{align}\label{eq:IS:gopt} g_T^{\text{\tiny{opt}}}(t)= c^{-1} \sqrt{m^{(2)}(t)} f_{T}(t), \quad t \in (t_{\inf},t_{\sup}),\quad c = \int_{t_{\inf}}^{t_{\sup}} \sqrt{m^{(2)}(t)} f_{T}(t)\; \mathrm{d} t. \end{align} The variance of the optimal SIS estimator, denoted by $\hat{\mu}^\text{\tiny{SIS,opt}}_n$, is $\operatorname{Var}(\hat{\mu}^\text{\tiny{SIS,opt}}_n)=(c^2 - \mu^2)/n$. \end{proposition} \begin{remark}\label{rem:optIS} \begin{enumerate} \item Proposition~\ref{prop:IS} implies that using optimal SIS gives variance no larger than MC. Indeed, by Jensen's inequality, $n\operatorname{Var}(\hat{\mu}^\text{\tiny{SIS,opt}}_n) \leq \mathbb{E}(m^{(2)}(T))-\mu^2$, which is equal to $\operatorname{Var}(\hat{\mu}^\text{\tiny{MC}}_n)$ using~\eqref{eq:var:mu:MC}. This inequality holds as an equality only when $m^{(2)}(t)$ is constant for all $t \in \Omega_{T}$. \item If $R^2 = 1$ (corresponding to the strongest possible single index structure), then $\operatorname{Var}(\hat{\mu}^\text{\tiny{SIS,opt}}_n)=0$: SIS provides a zero-variance estimator if $m^{(2)}(t)=(m(t))^2$ for all $t$, which is equivalent to having $v^2(t)=0$ for all $t$, or equivalently, to having $\mathbb{E}(v^2(T))=0$ since $v^2(t) \ge 0$ for all $t$. This is the same as asking $\operatorname{Var}(m(T))/\operatorname{Var}(\Psi(\bm{X}))=R^2=1$. This is why choosing a function $T$ such that the model is an as good fit as possible is important for the SIS method to achieve significant variance reduction. \end{enumerate} \end{remark} The following proposition gives the properties of the SSIS estimator and the optimal (variance-minimizing) proposal distribution of $g_T$. Its proof is in the appendix. \begin{proposition}[Variance-optimal SSIS]\label{prop:SIS} It holds that $\mathbb{E}(\hat{\mu}^{\text{\tiny{SSIS}}}_n)=\mu_{\text{\tiny{SIS}}}$ and, for large enough $n$, $\operatorname{Var}(\hat{\mu}^{\text{\tiny{SSIS}}}_n)=\sigma_{\text{\tiny{SIS}}}^2/n + o(1/n)$. If $\mathbb{E}_g \left(\left|m(T)w(T)\right|^{2+\delta}\right) < \infty$ for some $\delta>0$, $\hat{\mu}^{\text{\tiny{SSIS}}}_n$ is asymptotically normal as $\sqrt{n} (\hat{\mu}^{\text{\tiny{SSIS}}}_n-\mu_{\text{\tiny{SIS}}}) \omu{\text{\tiny{d}}}{\rightarrow}{} \operatorname{N}(0, \sigma_{\text{\tiny{SIS}}}^2)$ for $n\rightarrow\infty$. Suppose that $\Psi(\bm{x}) \geq 0$ or $\Psi(\bm{x}) \leq 0$ for all $\bm{x} \in \Omega_{\bm{X}}$ and that $\P_f(v^2(T)=0, \; m(T) \neq 0)=0$. The density $g_T$ that gives an unbiased SSIS estimator with the smallest variance is \begin{align}\label{eq:SIS:gopt} g_T^{\text{\tiny{opt,s}}}(t)=c^{-1}v(t) f_{T}(t), \quad t \in (t_{\inf},t_{\sup}), \quad c=\int_{t_{\inf}}^{t_{\sup}} v(t) f_{T}(t) \;\mathrm{d} t. \end{align} The variance of the optimal SSIS estimator $\hat{\mu}^\text{\tiny{SSIS,opt}}_n$ is $\operatorname{Var}(\hat{\mu}^\text{\tiny{SSIS,opt}}_n)=c^2/n+o(1/n)$. If $\P_f(v^2(T)=0, \; m(T) \neq 0)>0$, then $\hat{\mu}^\text{\tiny{SSIS,opt}}_n$ is biased. \end{proposition} \begin{remark} \begin{enumerate} \item Proposition~\ref{prop:SIS} implies that using optimal SSIS gives asymptotically a variance no larger than MC. Indeed, Jensen's inequality implies that we have $\operatorname{Var}(\hat{\mu}^\text{\tiny{SSIS,opt}}_n) \leq (1/n) \mathbb{E}(v^2(T)) + o(1/n)$ with equality only if $v(t)$ is constant for all $t \in \Omega_T$. From~\eqref{eq:var:mu:MC} (and ignoring the $o(1/n)$ term), this means $\operatorname{Var}(\hat{\mu}^\text{\tiny{SSIS,opt}}_n) \le \operatorname{Var}(\hat{\mu}^\text{\tiny{MC}}_n)$, with equality only if $v(t)$ is constant for all $t \in \Omega_T$ and $\operatorname{Var}(m(T))=0$, which is unlikely to be the case since $m(T)$ has been chosen specifically such that $R^2\approx 1$. \item If $R^2 = 1$ (strongest possible single index structure), then $\operatorname{Var}(\hat{\mu}^\text{\tiny{SSIS,opt}}_n) =0$, since $\operatorname{Var}(\hat{\mu}^{\text{\tiny{SSIS}}}_n)=0$ iff $m^{(2)}(t)=(m(t))^2$ for all $t$, or equivalently $v^2(t)=0$ for all $t$ and thus $\mathbb{E}(v^2(T))=0$, which means $R^2=1$. \item Unless $m(t)=0$, SSIS achieves variance reduction compared to SIS, as $\operatorname{Var}(\hat{\mu}^{\text{\tiny{SSIS}}}_n) \leq \operatorname{Var}(\hat{\mu}^{\text{\tiny{SIS}}}_n)$ for the same choice of $g_T$. This in turn implies that $\operatorname{Var}(\hat{\mu}^\text{\tiny{SSIS,opt}}_n) \leq \operatorname{Var}(\hat{\mu}^\text{\tiny{SSIS,opt}}_n)$.\label{eq:SISbetterIS} The proposal densities $g_T^{\text{\tiny{opt}}}$ and $g_T^{\text{\tiny{opt,s}}}$ defined in~\eqref{eq:IS:gopt} and~\eqref{eq:SIS:gopt} give estimators with smallest variance if $\Psi(\bm{x}) \lesseqgtr 0$ for all $\bm{x} \in \Omega$, which holds for many applications in finance (e.g., when $\Psi$ is an indicator and thus $\mu$ a probability or when $\Psi$ is the payoff of an option). If $\Psi$ takes both positive and negative values, $m(t)$ could be 0 for some values of $t$. We can then improve the optimal calibration by setting $g_T(t)=0$ whenever $m(t)=0$. Since it is generally unknown and hard to estimate which values of $t$ give $m(t)=0$, this improvement may not be implementable. \item The expression for $\operatorname{Var}(\hat{\mu}^\text{\tiny{SSIS,opt}}_n)$ implies that $\operatorname{SSIS}^*$ ``stratifies away'' the variance captured by the systematic part $m(T)$ of the single-index model, so the variance of the $\operatorname{SSIS}^*$ estimator comes only from the error term $\varepsilon_{\bm{X},T}$ via $v(t)$. If $g_T$ is not chosen optimally, then $\operatorname{Var}(\hat{\mu}^{\text{\tiny{SSIS}}}_n) = \sigma_{\text{\tiny{SIS}}}^2/n + o(1/n)$ shows that we still make $\operatorname{Var}(m(T))$ vanish by using stratification, but the contribution from $v^2(T)$ might be amplified (compared to how it contributes to the MC estimator's variance) if we do not choose a good proposal density. Irrespective of the choice of $g_T$ it is true that the stronger the fit of the single index model, the better (S)SIS works. \item These results show that as long as the problem at hand has a strong single-index structure and sampling from $T$ and $\bm{X}\mid T$ is feasible, SIS and SSIS can be applied and should give large variance reduction. As those conditions do not assume a specific form for $\Psi$ or for the distribution of $\bm{X}$, SIS and SSIS are applicable to a wide range of problems. \end{enumerate} \end{remark} Proposition~\ref{prop:SIS} asserts the asymptotic normality of the SSIS estimator. In order to construct a confidence interval from this estimator, we must estimate $\sigma_{\text{\tiny{SSIS}}}^2$. We take an approach similar to the one by \cite{wangbrowncailevine2008} where the first-order difference of samples are taken to remove the effect of the mean function. Its proof is in the appendix. \begin{proposition}[Estimation of $\sigma_{\text{\tiny{SSIS}}}^2$]\label{prop:SISvar:est} Let $G_T$ be the distribution function corresponding to $g_T$. If $G^{-1}_T$, $m$ and $v^2$ are continuously differentiable over the domain of $T$ under the proposal distribution, then \begin{align*} \hat{\sigma}_{\text{\tiny{SSIS}}}^2 = \frac{1}{2(n-1)}\sum\limits_{i=1}^{n-1} r_i^2 w^2(T_i) \end{align*} is a consistent estimator of $\sigma_{\text{\tiny{SSIS}}}^2$, where $r_i= \Psi(\bm{X}_{i+1}) - \Psi(\bm{X}_i)$ for $i=1,\ldots,n-1$. \end{proposition} Proposition~\ref{prop:SISvar:est} assumes that $G^{-1}_T$ is continuously differentiable which requires that $g_T(t)>0$ on the support of $T$ under the proposal distribution. This does not hold if there exist intervals where $g_T(t)=0$. In such a situation, we propose to divide the support of $T$ into disjoint intervals with $g_T(t)>0$ then apply Proposition~\ref{prop:SISvar:est} separately to each interval and combine them to obtain $\hat{\sigma}_{\text{\tiny{SSIS}}}^2$. \subsection{Connection to other IS and SS techniques} In this subsection, we explain some connections of our proposed methods to other IS and SS techniques. Suppose that $\bm{X} \sim \operatorname{N}_d(\bm{0}, I_d)$. A popular strategy for constructing a proposal distribution under the multivariate normal (MVN) model is to shift its mean vector of $\bm{X}$, that is, letting $\bm{X} \sim \operatorname{N}_d(\bm{\eta}, I_d)$ under the IS distribution for some $\bm{0} \neq \bm{\eta} \in \mathbb{R}^d$. The following proposition states that this type of IS can be achieved within our SIS framework by using $T(\bm{X})= \bm{\theta}^{\top}\bm{X}$ where $\bm{\theta}$ is the normalized version of $\bm{\eta}$. Based on Proposition~\ref{prop:IS} and Remark~\ref{rem:optIS}, this result thus implies that this popular mean-shifting strategy for MVN models works well if the problem has a strong linear single-index structure based on the specific choice of shift vector $\bm{\eta}$. \begin{proposition}[SIS in MVN models]\label{prop:meanshift} Let $\bm{X} \sim \operatorname{N}_d(\bm{0}, I_d)$ under the original distribution. Fix $\bm{0} \neq \bm{\beta} \in \mathbb{R}^d$ with $\bm{\beta}^{\top}\bm{\beta}=1$. Consider SIS with $T(\bm{X})= \bm{\beta}^{\top}\bm{X}$. If $g_T$ is the density of $\operatorname{N}(c,\sigma^2)$, then $\bm{X} \sim \operatorname{N}_d(c\bm{\beta}, I_d + (\sigma^2-1)\bm{\beta}\bbeta^{\top})$ in the IS scheme. \end{proposition} Proposition~\ref{prop:meanshift} implies that $\bm{X} \sim \operatorname{N}_d(c\bm{\beta}, I_d)$ if $g_T$ is chosen as the $\operatorname{N}(c, 1)$ density (where we recall that the original distribution $f_T$ is $\operatorname{N}(0,1)$), so that the previously mentioned mean-shifting strategy is a special case of IS (namely, by merely shifting the mean of $T$ instead of applying $\operatorname{SIS}^*$). If $\operatorname{Var}(T)\ne 1$ under $g$, the dependence structure of the components in $\bm{X}$ does change in the IS scheme. The stratification technique proposed in \cite{glassermanheidelbergershahabuddin1999} is applied by using the normalized shift vector as the stratification direction and can also be achieved within our SIS framework using the same function $T$ and proposal distribution as in Proposition~\ref{prop:meanshift}. The combination of IS and SS is not motivated as in \cite{glassermanheidelbergershahabuddin1999}. In the latter reference, IS and SS are used to remove the variability due to the linear and the quadratic part, respectively, of $\Psi(\bm{X})$. In SSIS, SS is used to eliminate $\operatorname{Var}(m(T))$, the variance captured by the systematic part of the single-index model, and then IS is used to minimize the variance contribution from $\varepsilon_{\bm{X},T}$. It is easy to see that the NPIS method proposed by \cite{neddermeyer2011} with $u=1$ (where $u$ is defined as in \cite{neddermeyer2011}) is closely connected to SIS with $T(\bm{X})=X_1$. It is proposed to choose $g_T(t)= m(t)f_T(t)/\mu$ in \cite{neddermeyer2011}, but by Proposition~\ref{prop:IS}, choosing $g_T^{\text{\tiny{opt}}}$ defined in \eqref{eq:IS:gopt} gives an IS estimator with a smaller variance. SIS also generalizes the IS method in \cite{arbenzcambouhofertlemieuxtaniguchi2018} in two ways. First, SIS generalizes the form of the transformation function $T$, that is, it does not assume any specific form of $T$, while the IS method in \cite{arbenzcambouhofertlemieuxtaniguchi2018} assumes that $T(\bm{X}) = \max \{F_1(X_1),\dots,F_d(X_d)\}$, where $F_1,\dots,F_d$ are the marginal distribution functions of $\bm{X}$. Secondly, SIS generalizes the form of the proposed density of the transformed variable, whereas the proposal density $g_T$ for the IS method in \cite{arbenzcambouhofertlemieuxtaniguchi2018} has the form \begin{align*} g_{T}(t) = \sum_{k=1}^{M} q_k f_{T}(t \mid T>\lambda_k) =\sum_{k=1}^{M} q_k \frac{f_{T}(t)I_{\{t>\lambda_k\}}}{1-F_T(\lambda_k)}, \end{align*} for some $M \geq 1$, $t_{\inf}=\lambda_1 < \cdots < \lambda_{M}$, and $q_1,\ldots,q_M \geq 0$ such that $\sum_{k=1}^{M} q_k=1$. The single-index structure we exploit to design our SIS and SSIS schemes is strongly related to the idea of conditional MC. In both cases, the goal is to identify a function $T$ of $\bm{X}$ that explains much of the variability of $\Psi(\bm{X})$. However, with conditional MC one typically also chooses $T$ so that $m(t)=\mathbb{E}(\Psi(\bm{X})\mid T(\bm{X})=t)$ is known, and then estimates $\mu$ by the sample mean of the $m(T_i)$, $i=1,\ldots,n$. In our case, we do not assume or need this conditional expectation to be known in closed-form. This means we typically do not completely get rid of the $\operatorname{Var}(m(T))$ term in~\eqref{eq:SIS:vardecomp}, but we aim to reduce it via IS; if SSIS is applied optimally, we actually do make $\operatorname{Var}(m(T))$ vanish. \subsection{Single-Index Importance Sampling and QMC}\label{sec:qmc:IS} As mentioned in the introduction, further variance reduction can be achieved by performing the simulation based on quasi-random numbers (QRNs) instead of PRNs. Suppose we are given a sampling algorithm $\phi : [0,1)^{d+k} \rightarrow \mathbb{R}^d$ for some $k \geq 0$ such that $\phi(\bm{U}) \sim f_{\bm{X}}$ for $\bm{U} \sim \operatorname{U}[0,1)^{d+k}$. For instance, when $\bm{X}\sim \operatorname{N}_d(\bm{\mu}, \Sigma)$, then $k=0$ and $\phi(\bm{u})=\bm{\mu}+C (\Phi^{-1}(u_1),\ldots,\Phi^{-1}(u_d))^{\top}$, where the matrix $C$ is such that $CC^{\top} = \Sigma$ and $\Phi(x)=\int_{\infty}^x (2\pi)^{-0.5} \exp(-t^2/2)\;\mathrm{d} t$ is the distribution function of the standard normal distribution. For a discussion of what the function $\phi$ is in a more general context, where $\bm{X}$ has a dependence structure modelled by a copula other than the Gaussian copula, we refer to \cite{cambouhofertlemieux2016}. With $\phi$ at hand, we can write $\hat{\mu}^\text{\tiny{MC}}_n=(1/n)\sum_{i=1}^n \Psi(\phi(\bm{U}_i))$ where $\bm{U}_i\omu{\text{\tiny{ind.}}}{\sim}{}\operatorname{U}(0,1)^{d+k}$. With QMC, we replace the $\bm{U}_i$ with deterministic vectors $\bm{v}_i\in[0,1)^{d+k}$ that fill the unit hypercube more evenly. A number of constructions for such points have been proposed (see e.g., \cite[Ch.~5]{lemieux2009}); we use the Sobol' sequence of \cite{sobol1967} for our numerical examples later on. In order to obtain an easy-to-compute error bound, we apply a random digital shift to the $\bm{v}_i$ to obtain multiple independent and identically distributed realizations of the randomized QMC (RQMC) estimator. Based on the digitally-shifted RQMC estimates, we can compute a probabilistic error bound in the form of a confidence interval. It is widely accepted that the performance of QMC is largely influenced by the effective dimension of the problem, a concept first introduced in \cite{caflischrusselmorokoffowen1997}. More precisely, QMC works significantly better than plain MC if the problem has a low effective dimension; see also \cite{wangfang2003, wangsloan2005, wang2006}. One notion of effective dimension is the truncation dimension; see \cite{wangsloan2005}. Essentially, a problem has a low truncation dimension when only a small number of leading input variables are important. Recall that $\bm{X}$ is sampled indirectly in SIS, that is, $T$ is generated first then $\bm{X}$ is drawn from $F_{\bm{X} | T}$. Assuming $T$ is generated using the inversion method and via the first coordinate $u_1$ of $\bm{u} \in [0,1)^{k+d}$, the indirect sampling step of SIS transforms the problem in such a way that the first input variable accounts for $R^2\cdot100\%$ of the variance of $\Psi(\bm{X})$, where $R^2=\operatorname{Var}(m(T))/\operatorname{Var}(\Psi(\bm{X}))$. That is, the problem has a truncation dimension of 1 in proportion $R^2$ under SIS. Therefore, if the fit of the single-index model is good, say $R^2>0.9$, the indirect sampling step via $T$ serves as a dimension reduction technique and enhances the efficiency of QMC. \section{Calibration stage in practice}\label{sec:calibration} As mentioned in the introduction, we must estimate the optimal transformation function $T=T(\bm{X})$ and construct an approximation $\hat{g}_T^{\text{\tiny{opt}}}$ for the optimal density $g_T^{\text{\tiny{opt}}}$ before applying (S)SIS. We call the stage in which these two tasks are performed the \emph{calibration stage}. Furthermore, the calibrations in \eqref{eq:IS:gopt} and~\eqref{eq:SIS:gopt} require the knowledge of the conditional mean function and variance function, respectively. As these are rarely known in practice, they must be estimated in the calibration stage as well. \subsection{Estimating the optimal transformation $T$} In what follows, we assume that $T$ is a linear function of the components in $\bm{X}$, i.e., $T=\bm{\beta}^{\top}\bm{X}$ for some $\bm{\beta}\in\mathbb{R}^d$; note that if $\bm{X}$ is multivariate normal, then $T$ is univariate normal and sampling from $\bm{X}\mid T$ is straightforward. To find $\bm{\beta}$ that maximizes $R^2$, we use the average derivative method of \cite{stoker1986}, which essentially allows us to estimate $\bm{\beta}$ as if we met the assumptions of a linear regression. That is, we sample independent realizations $\Psi(\bm{X}_i)=:\Psi_i$ for $i=1,\dots,n_1$ (say, $n_1=1000$) and compute the sample covariance matrix $\Sigma_{\bm{X},\bm{X}}$ as well as the sample cross covariance of $\bm{X}_1,\dots,\bm{X}_{n_1}$ and $(\Psi_1,\dots,\Psi_{n_1})$, say $\Sigma_{\bm{X},\Psi}$ to obtain $$\hat{\bm{\beta}} = \Sigma_{\bm{X},\bm{X}}^{-1} \Sigma_{\bm{X},\Psi}.$$ In some applications, we may use only a subset of the components in $\bm{X}$; in later examples, for instance, we only use the systematic risk factors in a credit model to build our transformation $T$. Sometimes one may even not need to estimate $\bm{\beta}$, for instance, if it is clear that the $d$ components in $\bm{X}$ are equally important, one can simply set $\bm{\beta} = (1/\sqrt{d},\dots,1/\sqrt{d})$; see Section~\ref{section:credit:gauss} for an example. \subsection{Finding the optimal density} The calibration in~\eqref{eq:IS:gopt} requires the knowledge of the conditional second moment function $m^{(2)}(t) = \mathbb{E}(\Psi^2(\bm{X}) \mid T=t)$ for all $t\in \Omega_T$, which, of course, is not known; similarly, the conditional variance function $v^2$ required for the calibration in~\eqref{eq:SIS:gopt} is not known either. We now describe how to calibrate~\eqref{eq:IS:gopt} in practice; the calibration of~\eqref{eq:SIS:gopt} can be done similarly. Our first ingredient is the construction of an estimate of $m^{(2)}(t) = \mathbb{E}(\Psi^2(\bm{X}) \mid T=t)$ for all $t\in \Omega_T$; we suggest using plain MC for this purpose. To this end, let $t_1<\dots<t_M$ be knots at which the function $m^{(2)}$ is to be estimated (e.g., $M=20$ equally spaced points in the relevant range). Choose some small pilot sample size $n_{\text{\tiny{pilot}}}$ (for example, 5\% of the total sample size $n$). For each $t_j$, sample $n_{\text{\tiny{pilot}}}$-many realizations from $\bm{X} \mid T=t_j$ and estimate $m^{(2)}(t_j)$ by its empirical equivalent for $j=1,\dots,M$. Then utilize smoothing splines (see, for example, \cite{reinsch1967}) and only those $t_j$ associated with a positive estimate to construct an estimate $\hat{m}^{(2)}$ for all $t\in \Omega_T$; for those $t$ where $\hat{m}^{(2)}(t)\leq 0$, one can either leave them as $\hat{m}^{(2)}(t)=0$ (which may lead to bias as discussed below) or set $\hat{m}^{(2)}$ to be some positive function (e.g., the error function) that resembles the lower tail of $\varepsilon$. Having constructed an estimate for $m^{(2)}$, we can set $\hat{g}_T^{\text{\tiny{opt}}}\propto \sqrt{\hat{m}^{(2)}(t)}f(t)$ for $t\in\mathbb{R}$. However, $\hat{g}_T^{\text{\tiny{opt}}}$ rarely belongs to known parametric families of distributions that are easily sampled from. One can use numerical techniques such as the NINIGL algorithm to approximate the quantile function of a distribution given its unnormalized density; see \cite{hormannleydold2003}. This approach, however, has three drawbacks: i) sampling from a numerically constructed density is time-consuming and can be prone to numerical problems; ii) the normalizing constant needs to be estimated, and iii) bias can occur when $\hat{g}_T^{\text{\tiny{opt,s}}}$ does not have the same support as $g_T^{\text{\tiny{opt,s}}}$, which in turn happens when $\hat{m}^{(2)}(t)=0$ even though $m^{(2)}(t)\not=0$ for some set $D$ with $\int_D f(t)\;\mathrm{d} t>0$. The third drawback can be alleviated if we can define $\hat{m}^{(2)}(t)$ to be positive whenever $m^{(2)}(t)$ is (for example, by assuming some lower and upper tail behaviour). Furthermore, recall from Proposition~\ref{prop:SIS} that \eqref{eq:SIS:gopt} gives a biased estimator if $\P_f(v^2(T)=0, \; m(T) \neq 0)>0$ which in some cases can be debiased. For instance, if $v(t)>0$ for all $t\in\Omega_t$, but the estimated $\hat{v}(t)=0$ for $t\geq t_{\max}$ for some $t_{\max}\in\mathbb{R}$ and $m(t)=c$ for some constant $c$ for $t\geq t_{\max}$ (for instance, if $\mu$ is a probability, then typically $m(t)=c=1$ for $t\geq t_{\max}$). If $\hat{\mu}^{\text{\tiny{SSIS}}}_n$ is constructed using $\hat{v}$, we find \begin{align*} \mathbb{E}(\hat{\mu}^{\text{\tiny{SSIS}}}_n) &= \int_{-\infty}^{t_{\max}} m(t)f_T(t)\;\mathrm{d} t = \mu - \int_{t_{\max}}^{\infty} m(t)f_T(t)\;\mathrm{d} t \approx \mu - c\P_f(T>t_{\max}); \end{align*} $\hat{\mu}^{\text{\tiny{SSIS}}}_n$ can therefore be debiased by adding $c\P_f(T>t_{\max})$. The second drawback can be addressed by using weighted IS (so that the normalizing constant cancels out); see \cite[Section~4.5]{lemieux2009}. Alternatively, the normalizing constant can be estimated as follows: Let $\hat{g}_{T,u}^{\text{\tiny{opt}}}(t)= \sqrt{\hat{m}^{(2)}}g(t)$ denote the unnormalized density, and $T_1,\dots,T_n\omu{\text{\tiny{ind.}}}{\sim}{} \hat{g}_T^{\text{\tiny{opt}}}$ (obtained, for instance, using the NINIGL algorithm). Now construct an estimate of the density of $T_1,\dots,T_n$, such as the kernel density estimator, and denote this estimated density by $\hat{h}$; note that $\hat{h}$ is normalized and that each of $\hat{h}(T_i)/\hat{g}_{T,u}^{\text{\tiny{opt}}}(T_i)$ for $i=1,\dots,n$ is an estimator for the normalizing constant. As such, we suggest using the sample median of $\{\hat{h}(T_1)/\hat{g}_{T,u}^{\text{\tiny{opt}}}(T_1),\dots,\hat{h}(T_n)/\hat{g}_{T,u}^{\text{\tiny{opt}}}(T_n) \}$ as an estimator for the normalizing constant. The first drawback, that is, the construction of an approximation to the quantile function of $\hat{g}_T^{\text{\tiny{opt}}}$ being both slow and potentially prone to numerical problems, is most severe. Below, we propose an alternative method, namely by setting $\hat{g}_T^{\text{\tiny{opt}}}(t) = 1/\sigma f( (t-k)/\sigma)$ for carefully chosen $k\in\mathbb{R}$ and $\sigma>0$. In other words, we suggest using a location-scale transform of the original density as proposal density and will therefore call this method $\operatorname{SIS}^{c,\sigma}$. While this procedure does require estimation of $k$ and $\sigma$, it does not suffer from any of the three aforementioned problems: i) if we can sample from $f$, we can also sample from $f( (t-k)/\sigma)/\sigma$; ii) there is no normalizing constant or density to be estimated; iii) $f$ and $f( (t-k)/\sigma)/\sigma$ have the same support, so that the resulting estimator is unbiased. The idea behind using a location-scale transform arises from the observation that in many practical examples (as will be seen later) the optimal density has roughly the same shape as the original density. As such, we try to find $k$ and $\sigma$ so that $1/\sigma f( (t-k)/\sigma)$ is approximately $g_T^{\text{\tiny{opt}}}(t)$. Denote again by $\hat{g}_{T,u}^{\text{\tiny{opt}}}(t)= \sqrt{\hat{m}^{(2)}(t)}f(t)$ the unnormalized, estimated optimal density and assume that the mode of $f_T$ is at zero (otherwise, shift accordingly). Now find $k^* = \operatorname*{argmax}_t \hat{g}_{T,u}^{\text{\tiny{opt}}}(t)$ numerically; this makes sure that the theoretical and approximated densities have (roughly) the same mode, thereby both sample from the ``important region''. Having estimated $k^*$, the next step is to compute $\sigma$ such that it minimizes the variance of the resulting estimator. More precisely, given a sample $T_1,\dots,T_{n_{\text{\tiny{pilot}}}}$ from $f$, we can estimate the variance of the estimator for a given $\sigma$ as follows: Set $\tilde{T}_i=k^* + \sigma T_i$ and $w_i =\frac{f(\tilde{T}_i)}{f( (\tilde{T}_i-k^*)/\sigma)/\sigma}$ and sample $\bm{X}_i \mid \tilde{T}_i$ for $i=1,\dots,n_{\text{\tiny{pilot}}}$. The second moment of the IS estimator (written as a function of the scale $\sigma$) is then \begin{align}\label{eq:Vsigma} V(\sigma) = \sum_{i=1}^{n_{\text{\tiny{pilot}}}} \Psi(\bm{X}_i) w_i^2, \quad \sigma>0. \end{align} We can now solve $\sigma^* = \operatorname*{argmin}_{\sigma>0} V(\sigma)$ numerically. Note that due to the nature of a location-scale transform, we only need to sample $T_1,\dots,T_{n_{\text{\tiny{pilot}}}}$ once. Intuitively, $k^*$ shifts the density to the important region, while $\sigma^*$ scales it appropriately. If computing $V(\sigma)$ is very time consuming (for example, when the sampling of $\bm{X} \mid T$ is complicated), one can set $\sigma^*=1$; the resulting method is then called $\operatorname{SIS}^{\mu}$ instead of $\operatorname{SIS}^{\mu,\sigma}$. \begin{algorithm}[Calibration and estimation stage for estimating $\mu$ via $\operatorname{SIS}^{\mu,\sigma}$]\label{alg:SIS:full} Given knots $t_1,\dots,t_{n_{\text{\tiny{pilot}}}}$, a total pilot budget $n_{\text{\tiny{tot}}}$ and knot-sample size $n_{\text{\tiny{knot}}}$, target sample size $n$, estimate $\mu$ via: \begin{enumerate} \item \emph{Estimation of the direction vector.} \begin{enumerate} \item Sample $\bm{X}_i\omu{\text{\tiny{ind.}}}{\sim}{} f_{\bm{X}}$ for $i=1,\dots,n_{\text{\tiny{pilot}}}$ and compute $\Psi(\bm{X}_i)=:\Psi_i$, $i=1,\dots,n_{\text{\tiny{pilot}}}$. \item Compute $\Sigma_{\bm{X},\bm{X}}$ and $\Sigma_{\bm{X},\mathbf{\Psi}}$and set $\hat{\bm{\beta}} = \Sigma_{\bm{X},\bm{X}}^{-1} \Sigma_{\bm{X},\Psi}$. \end{enumerate} \item \emph{Estimation of $c^*$ and $\sigma^*$.} \begin{enumerate} \item\label{step:condsampling1} For each $k=1,\dots,n_{\text{\tiny{pilot}}}$, sample $\bm{X}_{j,k}\omu{\text{\tiny{ind.}}}{\sim}{} f_{\bm{X}\mid T}(\cdot \mid t_k)$ for $j=1,\dots,n_{\text{\tiny{knot}}}$. \item Utilize smoothing splines\footnote{In the case when $\Psi$ is an indicator, use a logistic regression (available, for instance, via the \textsf{R}\ function \texttt{glm())} with $n_{\text{\tiny{knot}}} = 1$ instead.} through $(t_k, (1/n_{\text{\tiny{knot}}})\sum_{j=1}^{n_{\text{\tiny{knot}}}} \Psi(\bm{X}_{j,k})^2)$, $k=1,\dots,n_{\text{\tiny{pilot}}}$, to construct an estimate for $\hat{m}^{(2)}(t)$ for $t\in\mathbb{R}$. \item Find $c^* = \operatorname*{argmax}_t \sqrt{\hat{m}^{(2)}(t)} f(t)$ numerically. \item\label{step:condsampling2} Sample $T_1,\dots,T_{n_{\text{\tiny{pilot}}}}\omu{\text{\tiny{ind.}}}{\sim}{} f$ and find $\sigma^* = \operatorname*{argmin}_{\sigma>0} V(\sigma)$ with the function $V$ from~\eqref{eq:Vsigma} numerically. \end{enumerate} \item \emph{Estimation of $\mu$.} \begin{enumerate} \item Sample $T_1',\dots,T_n'\omu{\text{\tiny{ind.}}}{\sim}{} f$, set $T_i = c^* + \sigma^* T_i$ and compute $w_i =\frac{f(T_i)}{ f( (T_i-c^*)/\sigma^*)/\sigma^*}$ for $i=1,\dots,n$. \item\label{step:condsampling3} Sample $\bm{X}_i\omu{\text{\tiny{ind.}}}{\sim}{} f_{\bm{X}\mid T}(\cdot \mid T_i)$ for $i=1,\dots,n$. \item Return $\hat{\mu}^{\text{\tiny{SIS}}}_n = (1/n) \sum_{i=1}^n \Psi(\bm{X}_i)w_i$. \end{enumerate} \end{enumerate} \end{algorithm} \begin{remark} \begin{enumerate} \item Algorithm~\ref{alg:SIS:full} can be easily adapted to accommodate quasi-random numbers and stratification, as will be discussed in the next section. \item The effort for the conditional sampling needed in Steps~\ref{step:condsampling1}, \ref{step:condsampling2} and~\ref{step:condsampling3} is problem specific -- for some problems, samples of $\bm{X} \mid T=t_1$ can be easily transformed to samples from $\bm{X} \mid T=t_2$ for $t_1\not=t_2$, making these steps very fast; in some other problems, the conditional sampling is more involved. \item Our proposed SIS method can also be combined with other VRTs. For instance, in Section~\ref{section:credit:t}, we combine conditional MC (CMC) and SIS to estimate loss probabilities of a credit portfolio whose dependence is governed by a $t$-copula. \end{enumerate} \end{remark} \section{Numerical Experiments} \label{sec:numexp} In this section, we perform an extensive numerical study to demonstrate the effectiveness of our proposed methods. We start with a simplistic linear model example, in which case calibration of the optimal densities can be done easily. This allows us to investigate the effect of replacing $g_T^{\text{\tiny{opt}}}$ by $\hat{g}_T^{\text{\tiny{opt}}}$. In Section~\ref{section:credit:gauss}, we apply our SIS and SSIS schemes to a credit portfolio problem under the Gaussian copula model studied by \cite{glassermanli2005}. The same financial problem but this time using a more complicated $t$-copula model is studied in Section~\ref{section:credit:t}. All computations were carried out in \textsf{R}; see \cite{Rsystem}. \subsection{Linear Model Example}\label{section:linearmodel} Let $L = \alpha T + \varepsilon_T$ where $T\sim \operatorname{N}(0,1)$, $\varepsilon_T \mid T \sim \operatorname{N}(0, s^2)$ and $\alpha^2+s^2 = 1$. $L$ has a single index structure when $\alpha^2\approx 1$ since $R^2 = \operatorname{Var}(m(T))/\operatorname{Var}(L)=\operatorname{Var}(\alpha T)=\alpha^2$. Assume interest lies in estimating the probability $p_l=\P(L>l)=\bar{\Phi}(l)=\mathbb{E}(\mathbbm{1}_{\{L>l\}})$ for some large $l$; note that we can approximate the true value of $p_l$ efficiently with high precision since $L\sim\operatorname{N}(0,1)$. Furthermore it is easily seen that $p_l(t) = \P(L>l \mid T = t) = \bar{\Phi}\left( (l-\alpha t) /s\right)$ for $l,t\in\mathbb{R}$. Since the integrand $\Psi$ in this setting is an indicator, we find from Proposition~\ref{prop:IS} that $g_T^{\text{\tiny{opt}}}(t) \propto \sqrt{p_l(t)}f_T(t)$. Unlike in this simplistic setting, $p_l(t)$ for $t\in\mathbb{R}$ is unknown in practice as discussed in Section~\ref{sec:calibration}; thus, this setting serves as an excellent example to also compare whether approximating $g_T^{\text{\tiny{opt}}}$ by $\hat{g}_T^{\text{\tiny{opt}}}$ has a significant effect on the accuracy of the estimators. Sampling from the true optimal densities is performed using the \textsf{R}\ package \texttt{Runuran} of \cite{leydoldhoermann2020}. We consider the methods $\operatorname{SIS}^{**}$ (constructed using known $p_l(t)$), $\operatorname{SIS}^{*}$ (approximated $p_l(t)$ and NINGL), $\operatorname{SIS}^{\mu}$ and $\operatorname{SIS}^{\mu,\sigma}$ For the two settings of $\alpha^2 \in\{0.7, 0.99\}$ (corresponding to a weaker and stronger single index structure), we estimate $p_l$ for $l\in\{3,4,\dots,7\}$ using the five aforementioned methods. For each value of $l$, the optimal density is calibrated separately. In all examples, we use a sample size of $n=10^6$ and a pilot sample size of $5\times 10^4$. We repeat the experiment 200 times. Figure~\ref{fig:lm:densdur} displays on the left the optimally calibrated and approximated IS densities. The true optimal density is bell shaped, so it is well approximated by a normal density. It can be confirmed from the plot that in this case, all IS densities seem to cover the important range. The right of Figure~\ref{fig:lm:densdur} displays a boxplot of run-times needed to estimate $p_l$; note that the run-time does not depend on $\alpha$ or $l$. This plot, however, should be interpreted with caution as it highly depends on how the pilot runs are implemented. \begin{figure} \centering \includegraphics[width=0.48\textwidth]{fig_linmod_densities.pdf} \includegraphics[width=0.48\textwidth]{fig_linmod_durs.pdf} \caption{Left: Calibrated densities for $\alpha=0.99$, $l=5$. Right: Run-times for each method including pilot runs.} \label{fig:lm:densdur} \end{figure} Figure~\ref{fig:lm:results:pl} displays mean relative errors; recall that we know $p_l$ here. The relative errors for the different methods are similar, though $\operatorname{SIS}^{\mu,\sigma}$ seems to give smallest errors. A possible explanation might be that the simplicity of that method (e.g., in terms of the support) relative to numerically constructing the optimal density via NINGL might outweigh the benefit of the latter having slightly more theoretical support. Furthermore, note that the IS methods perform much better when $R^2=\alpha^2$ is larger, i.e., when the single index structure is strong, as expected. \begin{figure} \centering \includegraphics[width=0.48\textwidth]{fig_linmod_pl_mre_MC_0.7.pdf} \includegraphics[width=0.48\textwidth]{fig_linmod_pl_mre_RQMC_0.7.pdf} \includegraphics[width=0.48\textwidth]{fig_linmod_pl_mre_MC_0.99.pdf} \includegraphics[width=0.48\textwidth]{fig_linmod_pl_mre_RQMC_0.99.pdf} \caption{Mean relative errors when using pseudo-random numbers (left) and quasi-random numbers (right) for $\alpha^2=0.7$ (top) and $\alpha^2=0.99$ (bottom).} \label{fig:lm:results:pl} \end{figure} \begin{figure} \centering \includegraphics[width=0.48\textwidth]{fig_linmod_pl_var_MC_0.7.pdf} \includegraphics[width=0.48\textwidth]{fig_linmod_pl_var_RQMC_0.7.pdf} \includegraphics[width=0.48\textwidth]{fig_linmod_pl_var_MC_0.99.pdf} \includegraphics[width=0.48\textwidth]{fig_linmod_pl_var_RQMC_0.99.pdf} \caption{Mean estimated variance when using pseudo-random numbers (left) and quasi-random numbers (right) for $\alpha^2=0.7$ (top) and $\alpha^2=0.99$ (bottom).} \label{fig:lm:results:pl} \end{figure} \subsection{Loss Distribution of a Credit Portfolio}\label{section:credit:gauss} In this section, we study the effectiveness of the proposed methods for a credit portfolio problem studied in \cite{glassermanli2005}, where the goal is to estimate the probability of large portfolio losses under a normal copula model. We compare our proposed methods to the IS technique of Glasserman and Li, to which we refer to as G$\&$L IS. \subsubsection{Problem Formulation}\label{section:credit:gauss:pars} Suppose that $Y_k$ denotes the default indicator of the $k$th obligor with exposure $c_k$ and a default probability of $p_k$ for $k=1,\ldots,h$. The incurred loss is then $L = \sum_{k=1}^h c_k Y_k$. Let $$Y_k = \mathbbm{1}_{\{X_k > \Phi^{-1}(1-p_k)\}},\quad X_k = a_{k1} Z_1 + \cdots + a_{kd} Z_d + b_k \varepsilon_k \sim \operatorname{N}(0,1),\quad k=1,\dots,h,$$ where $$ (Z_1,\ldots,Z_d) \sim \operatorname{N}_d(\bm{0},I_d), \quad\varepsilon_1,\dots,\varepsilon_h\omu{\text{\tiny{ind.}}}{\sim}{}\operatorname{N}(0,1), \quad \sum_{j=1}^h a^2_{kj} \leq 1,\quad b_k = \sqrt{1- \sum_{j=1}^h a^2_{kj} }.$$ The $a_{kj}$ represent the $k$th obligor's factor loadings for the $d$ risky systematic factors; the choice of $b_k$ ensures $X_k\sim\operatorname{N}(0,1)$. Our goal is to estimate $P(L>l)$ for small $l>0$. As in \cite{glassermanli2005}, we consider a portfolio with $h=1\ 000$ obligors in a 10-factor model (i.e. $d=10$). The marginal default probabilities and exposures are $p_k = 0.01 \cdot (1+\sin(16 \pi k /h))$ and $c_k = (\left \lceil{{5k/h}}\right \rceil)^2$ for $k=1,\ldots, h$, respectively. The marginal default probabilities vary between $0 \%$ and $2\%$ and the possible exposures are 1, 4, 9, 16 and 25, with 200 obligors at each level. The factor loadings $a_{kj}$'s are independently generated from a $\operatorname{U}(0,1/\sqrt{d})$. Letting $\bm{Z}=(Z_1,\ldots,Z_d)^{\top}$ and $\bm{\varepsilon}=(\varepsilon_1,\ldots,\varepsilon_h)^{\top}$, we write $L=L(\bm{Z},\bm{\varepsilon})$, i.e., the vector $\bm{X}$ to which we have referred throughout this paper is given by $\bm{X}=(\bm{Z},\bm{\varepsilon})$ for this example. We investigate whether or not $L$ has a single-index structure. Let $T= \bm{\theta}^{\top} \bm{Z}$ where $\bm{\theta} \in \mathbb{R}^d$ such that $\bm{\theta}^{\top} \bm{\theta}=1$, so $T \sim \operatorname{N}(0,1)$. We estimate $\bm{\theta}$ that maximize the fit by using the average derivative method of \cite{stoker1986}. The estimated $\bm{\theta}$ has almost equal entries close to $\sqrt{1/d}$. This makes intuitive sense, as each component of $\bm{Z}$ is likely to be equally important because the factor loadings are generated randomly. The left side of Figure~\ref{fig:scatter:optdens:gcop} shows the scatter plot of $(T,L)$. The figure reveals the single-index model fits $L$ well even in the extreme tail, implying SIS based on this choice of $T$ will give substantial variance reduction. The right side of Figure~\ref{fig:scatter:optdens:gcop} displays the original density of $T$, the optimally calibrated $\operatorname{SIS}^*$ density as well as the estimated function $p_l(t)$. Note that the optimally calibrated density's mode substantially differs from the original one. \begin{figure}[h] \centering \includegraphics[width = 0.48\textwidth]{fig_gcop_TvsL_normal.pdf} \includegraphics[width = 0.48\textwidth]{fig_gcop_optdens.pdf} \caption{Plot of Transformed variable ($T$) vs Portfolio Loss ($L$) based on 10\ 000 observations (left) and OCIS density calibrated to $l=3000$ (right).} \label{fig:scatter:optdens:gcop} \end{figure} \subsubsection{Proposed estimators} The method of \cite{glassermanli2005} consists of a two-step procedure. In a calibration stage, an optimal mean vector $\bm{\mu}\in\mathbb{R}^d$ is found by solving an optimization problem minimizing the variance of the resulting IS estimator. Next, one samples $\bm{Z}\sim\operatorname{N}_d(\bm{\mu}, I_d)$ and computes the conditional default probabilities $p_k(\bm{Z})=\P(Y_k=1\mid \bm{Z})=\Phi( (\bm{a}_k^{\top}\bm{Z} - x_k)/b_k)$, which enter another optimization problem used to find a number $\theta\in\mathbb{R}$ so that $q_k(\theta, \bm{Z})$ are variance minimizing default probabilities. Given $\bm{Z}$, we know that $Y_1,\dots,Y_h$ are independent and can therefore easily sample the loss via $L=\sum_{k=1}^h c_k \mathbbm{1}_{\{U_k \leq q_k(\theta(\bm{Z})\}}$ where $(U_1,\dots,U_h)\sim \operatorname{U}(0,1)^h$. Finally, the estimator $\mathbbm{1}_{\{L>l\}}\cdot w(\bm{Z}, L)$ where $w$ denotes the IS weight function is an unbiased estimator. Our method $\operatorname{SIS}^{\mu,\sigma}$ proceeds as described in \ref{alg:SIS:full}; $\operatorname{SIS}^{\mu}$ omits sets the scale to unity while the $\operatorname{SSIS}$ methods also stratify. Once $\bm{Z}\mid T$ is sampled, we sample $Y_k$ from $p_k(Z)$ independently. We also include $\operatorname{SIS}^*$ and $\operatorname{SSIS}^*$, where the function $p_l(t)$ is estimated as before and the quantile function of the optimal distribution is estimated via the NINiGL algorithm, in our experiments; see also Figure~\ref{fig:scatter:optdens:gcop}. \subsubsection{Comparison} We compare SIS and SSIS to G\&L IS by computing estimates, standard errors and computation times for $l \in \{100, 1000, 2000, 3000, 4000\}$. All methods require a calibration stage. For this comparison, we optimize the proposal distributions at each loss level of $l$ separately and estimate the corresponding loss probability. Table~\ref{table:res:gausscredit} shows the estimated probabilities along with half-widths of estimated confidence intervals (CI) in brackets. The last column shows the average computational time of each method over all loss levels $l$. All examples used $n=5000$ samples and $1000$ samples for the calibration. We see that all our methods lead standard errors smaller than G\&L IS, while the estimated CIs for both methods are typically overlapping, supporting the correctness of both approaches. Given the small run-time, unbiasedness and small estimated errors, we can conclude that $\operatorname{SSIS}^{\mu,\sigma}$ is the best estimator for this problem. This supports our claim that the optimal density of $T$ can be quickly and accurately approximated by a location scale transform of $f_T$. Note that $\operatorname{SIS}^*$ and $\operatorname{SSIS}^*$ are particularly slow, as it involves numerically approximation the quantile function corresponding to the optimal $g_T$. \begin{table}[ht] \centering \begin{tabular}{c|cccccc} \toprule l & 100 & 1000 & 2000 &3000 &4000 & Avg run-time (sec)\\ \midrule G\&L IS & 0.28 &0.0079 &0.00077&9.2e-05&1.1e-05&2.45\\ & (0.0078) & (0.00036) & (4.1e-05) & (6.3e-06) & (8.8e-07) & \\ $\operatorname{SIS}^*$ &0.28& 0.0081&0.00076&9.2e-05&1.1e-05&6.62\\ & (0.0068)& (0.00021)& (2.1e-05) & (2.4e-06) & (3.5e-07)& \\ $\operatorname{SSIS}^*$ &0.28& 0.0082&0.00077&9.5e-05&1.1e-05&12.56\\ & (0.0046) & (0.00014) & (1.4e-05) & (1.7e-06) & (2.5e-07) & \\ $\operatorname{SIS}^{\mu}$ &0.28& 0.0077&0.00074&8.6e-05&1e-05 &1.41\\ & (0.0086) & (0.00039) & (4.2e-05) &(5.5e-06) & (6.8e-07) & \\ $\operatorname{SSIS}^{\mu}$ &0.28& 0.008& 0.00075&9.1e-05&1.1e-05&1.45\\ & (0.0062) & (0.00028) & (2.9e-05) &(4e-06)&(5.1e-07) & \\ $\operatorname{SIS}^{\mu,\sigma}$ &0.28& 0.0082&0.00077&9.4e-05&1.1e-05&2.45\\ &(0.0077)&(0.00034) & (3.3e-05) & (5.2e-06) &(4.6e-07) & \\ $\operatorname{SSIS}^{\mu,\sigma}$ &0.28& 0.0081& 0.00075&8.9e-05&1.1e-05& 2.2\\ &(0.0059) &(2e-04) & (1.9e-05)& (2.3e-06) & (3e-07) & \\ \bottomrule \end{tabular} \caption{Estimates and CI halfwidths when estimating $p_l$ in the Gaussian Credit Portfolio problem with $h=1000$ obligors and $d=10$ factors for various $l$ and methods. The last column displays average run-times. } \label{table:res:gausscredit} \end{table} \begin{table}[ht] \centering \begin{tabular}{c|cccccc} \toprule l & 100 & 1000 & 2000 &3000 &4000 \\ \midrule G\&L IS & 1.5 & 1.5 & 1.5 & 1.5 & 1.6 \\ $\operatorname{SIS}^*$ & 1.3 & 1.3 & 1.2 & 1.7 & 1.5 \\ $\operatorname{SIS}^{\mu,\sigma}$ & 1.6 & 1.5 & 1.9 & 1.7 & 1.6 \\ $\operatorname{SSIS}^{\mu,\sigma}$ & 1 & 1.1 & 1 & 1.1 & 0.9 \\ \bottomrule \end{tabular} \caption{Relative error reduction factors RE(MC)/RE(RQMC) for the Gaussian credit portfolio with $h=1000$ obligors and $d=10$ factors for various $l$ and methods. } \label{table:vrf:gausscredit} \end{table} \subsection{Tail probabilities of a $t$-Copula Credit Portfolio}\label{section:credit:t} In this section, we apply SIS to a credit portfolio problem under a $t$-copula model, which is the model studied in Section~\ref{section:credit:gauss} with a multiplicative shock variable included. This $t$-copula model is a special case of the models with extremal dependence studied in \cite{bassamboojunejazeevi2008}. Unlike the Gaussian copula, the $t$-copula is able to model tail dependence of latent variables, so simultaneous defaults of many obligors are more likely under the $t$-copula model than under its Gaussian copula counterpart. \subsubsection{Problem Formulation} In the $t$-copula model, the latent variables $\bm{X}=(X_1,\ldots,X_d)$ are multivariate-$t$ distributed, that is, \begin{align*} X_k = \sqrt{W} (a_{k1} Z_1 + \cdots + a_{kd} Z_d + b_k \varepsilon_k),\quad k=1,\dots,h, \end{align*} where $W \sim\operatorname{IG}(\nu/2,\nu/2)$ is independent of $Z_1,\dots,Z_d, \varepsilon_k\omu{\text{\tiny{ind.}}}{\sim}{}\operatorname{N}(0,1)$. Accordingly, we define $Y_k = \mathbbm{1}_{\{X_k > t^{-1}_{\nu}(1-p_k)\}}$. We assume the same parameters as in Section~\eqref{section:credit:gauss:pars}, except that now we have $h=50$ obligors, and the two settings for the degrees-of freedom $\nu\in\{5, 12\}$. Let $\bm{Z}=(Z_1,\ldots,Z_d)^{\top}$ and $\bm{\varepsilon}=(\varepsilon_1,\ldots,\varepsilon_h)$. We consider two transformations. For the first transformation, let $Z_W= \Phi^{-1}(F_W(W))$ and $$T_1(W, \bm{Z}, \bm{\epsilon})=\beta_W Z_W + \bm{\beta}_{L}^{\top} \bm{Z},$$ where $\beta_W\in\mathbb{R}$ and $\bm{\beta}_{L}\in\mathbb{R}^d$ are such that $\beta^1_W+\bm{\beta}_{L}^{\top}\bm{\beta}_{L}=1$. Then, $T_1 \sim \operatorname{N}(0,1)$ since $Z_W\sim\operatorname{N}(0,1)$ is independent of $\bm{Z}$. Our second transformation relies on the random variable $S_l(\bm{Z},\bm{\varepsilon})=\P(L>l \mid \bm{Z},\bm{\varepsilon})$ and note that $\P(L>l)=\mathbb{E}(S_l(\bm{Z},\bm{\varepsilon}))$. Based on this and the fact that, given a sample $\bm{Z}, \bm{eps}$, the function $S_l$ can be computed analytically, \cite{chankroese2010} propose to use CMC, i.e., estimating $\P(L>l)$ by the sample mean of $S_l(\bm{Z}_i,\bm{\varepsilon}_i)$ for independent $\bm{Z}_i,\bm{\varepsilon}_i$ for $i=1,\dots,n$. We propose to use this CMC idea combined with SIS by using the transformation $$T_2=\bm{\beta}_S^{\top}\bm{Z}$$ with $\bm{\beta}_S$ such that $\bm{\beta}_S^{\top}\bm{\beta}_S=1$, which implies $T_2\sim\operatorname{N}(0,1)$. The second method based on CMC, is very effective as the variable $W$ which accounts for a large portion of the variance of $L$, is integrated out. Furthermore, \cite{chankroese2010} additionally employ IS on $(\bm{Z},\bm{\varepsilon})$ to make the event $\{L>l\}$ more frequent using the cross-entropy method; see \cite{deboerkroesemannorrubinstein2005, rubinstein1997,rubinsteinkroese2013}. We refer to Chan and Kroese's method as C\&K CMC+IS. The numerical study in~\cite{chankroese2010} demonstrates that C\&K CMC+IS achieves substantial variance reduction. We will show in our numerical examples below that combining their CMC idea with our proposed single index IS method gives even greater variance reduction. \subsubsection{Fit of Single-Index models with and without conditional Monte Carlo} We first investigate whether or not $L$ and $S_l$ have single-index structures. As before, the coefficients $\bm{\beta}$ that maximize the fit of the single-index model are estimated using the average derivative method of Stoker \cite{stoker1986}. \begin{figure}[htbp] \centering \includegraphics[width = 0.48\textwidth]{fig_condsample_t_df5trafo1.pdf} \includegraphics[width = 0.48\textwidth]{fig_condsample_t_df5trafo2.pdf} \includegraphics[width = 0.48\textwidth]{fig_condsample_t_df12trafo1.pdf} \includegraphics[width = 0.48\textwidth]{fig_condsample_t_df12trafo2.pdf} \caption{Scatter plots of $L$ vs $T_1$ (left) and $S_l$ vs $T_2$ (right) where $l=500$ and $\nu = 5$ (top) and $\nu = 12$ (bottom). } \label{fig:T_vs_L_tcredit} \end{figure} Figure~\ref{fig:T_vs_L_tcredit} shows scatter plots of $(T_1,L)$ and $(T_2, S_l)$ for $\nu=12$ and $\nu=5$. The figures show that there is a strong association between $T_1$ and $L$ but the dependence is stronger when $\nu=12$ than when $\nu=4$. When $\nu=4$, there is a significant variation of $L$ that cannot be captured by the single-index model based on $T_1$ in the right-tail. This observation holds more generally; the smaller $\nu$ (i.e., the stronger the dependence between the $\bm{X}_i$), the worse the fit of the single-index model becomes in the right-tail. When investigating the fit of $(T_2, S_l)$, recall that the main advantage of CMC is that $W$ is integrated out; the resulting estimators should be less sensitive to the degrees-of-freedom $\nu$, which is the case in the plot. We can see that the fit of $T_2$ is excellent even in the outer right-tail for all settings of $\nu$ and $l$. \subsubsection{Estimates and estimated variances} \begin{figure} \includegraphics[width = 0.48\textwidth]{fig_tcredit_dens_df2trafo1.pdf} \includegraphics[width = 0.48\textwidth]{fig_tcredit_dens_df2trafo2.pdf} \caption{Optimally calibrated densities for $l=100$ and the transformations $T_j$ for $j=1,2$. } \end{figure} \begin{figure} \centering \includegraphics[width = 0.45\textwidth]{fig_tcop_ests_trafo1df_1.pdf} \includegraphics[width = 0.45\textwidth]{fig_tcop_vars_trafo1df_1.pdf} \includegraphics[width = 0.45\textwidth]{fig_tcop_ests_trafo2df_1.pdf} \includegraphics[width = 0.45\textwidth]{fig_tcop_vars_trafo2df_1.pdf} \caption{Estimates (left) and estimated variances (right) as a function of $n$ for $\nu=5$. } \label{fig:tcop:estvars:1} \end{figure} \begin{figure} \centering \includegraphics[width = 0.45\textwidth]{fig_tcop_ests_trafo1df_2.pdf} \includegraphics[width = 0.45\textwidth]{fig_tcop_vars_trafo1df_2.pdf} \includegraphics[width = 0.45\textwidth]{fig_tcop_ests_trafo2df_2.pdf} \includegraphics[width = 0.45\textwidth]{fig_tcop_vars_trafo2df_2.pdf} \caption{Estimates (left) and estimated variances (right) as a function of $n$ for $\nu=12$. } \label{fig:tcop:estvars:2} \end{figure} We compare the original C\&K CMC+IS from \cite{chankroese2010} with SIS with and without CMC. We additionally investigate whether employing RQMC yields a variance reduction. To this end, we estimate $p_l$ for $l=100$ for various $n$ and methods; see Figures~\ref{fig:tcop:estvars:1} and \ref{fig:tcop:estvars:2}. Variances are estimated as the sample variance of $B=20$ repetitions; this ensures that the same variance estimator (namely, the sample variance) is used for both methods, rather than using the estimator from Proposition~\ref{prop:SISvar:est} for MC and the sample variance for RQMC. Note that for fixed $\nu$, the data for C\&K CMC+IS are identical independent of which transformation is used, so these lines can be used as reference. As expected, variances with the CMC idea are smaller than without the CMC idea. Note further that all our (S)SIS methods combined with $T_1$ (which does not integrate out $W$) give smaller variances than C\&K CMC+IS, which does integrate out $W$. \section{Concluding Remarks} \label{sec:conclusion} In this paper, we developed importance sampling and stratification techniques that are designed to work well for problems with a single-index structure, i.e., where the response variable depends on input variables mostly through some one-dimensional transformation. The main theme of our approach is to exploit the low-dimensional structure of a given problem in rare-event simulation by introducing a conditional sampling step on this important transformed random variable and using optimal IS. We derived expressions for optimal densities of said one-dimensional transformation which achieve minimum variance and discussed boundary cases with zero variance. Furthermore, we demonstrated that our framework includes and generalizes existing mean-shifting techniques. Our theoretical framework and numerical examples suggest substantial variance reduction for problems having strong single-index structures. As the optimal density rarely belongs to a known parametric family, we also give explicit steps to calibrate the proposal distribution. Our numerical experiments revealed that the proposed methods outperform existing methods that were specifically tailored to the Gaussian and $t$-copula credit portfolio problem. The success of our method in this framework highlights the flexibility and wide applicability of our approach. By combining our single-index framework with RQMC methods, we achieve even more precise estimation results, thanks to the dimension reduction feature of our conditional sampling step. Note that there exist many other low-dimensional structures studied in the literature and they may provide a better fit than single-index models do. For instance, the structure assumed by the sufficient dimension reduction can be seen as a multi-index extension of the linear single-index model; see \cite{cook1998, cookforzani2009, adrangicook2009}. We would like to develop importance sampling techniques for problems based on other low-dimensional structures in future research.
{'timestamp': '2021-11-16T02:26:35', 'yymm': '2111', 'arxiv_id': '2111.07542', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07542'}
arxiv
\section{CC Delivery Phase} After the users reveal their requests, the server first performs a CC delivery phase where it uses coded caching techniques to build a set of codewords and transmit them to eligible users. Assume the number of users associated with profile $p$ and making requests at the considered time instant (i.e., the length of profile $p$) is $\eta_p$. The server then chooses a common parameter $\hat{\eta}$ to indicate the number of users participating in the CC delivery phase. The system level impact of choosing $\hat{\eta}$ is clarified later in this section. Then, for every profile $p$: \begin{enumerate} \item if $\eta_p > \hat{\eta}$, then $\hat{\eta} - \eta_p$ users associated with profile $p$ are selected randomly and excluded from the CC phase; \item if $\eta_p \le \hat{\eta}$, then $\hat{\eta} - \eta_p$ \textit{phantom} users are assigned with the profile $p$. \end{enumerate} Phantom users are non-existing users that appear when codewords are built and are excluded from the actual delivery~\cite{salehi2020lowcomplexity}. Although phantom users incur some \ac{DoF} loss, they enable a larger beamforming gain that can actually improve the achievable rate, compared with schemes with a larger DoF, at the finite-SNR regime (cf.~\cite{salehi2020lowcomplexity,tolli2017multi}). After the above-mentioned process, all profiles will have the same length of $\hat{\eta}$. Then, we consider a \emph{virtual} network with $P$ users, coded caching gain $\Brt = P\gamma$, and spatial DoF of $\Bar{\alpha} = \lceil \frac{\alpha}{\hat{\eta}} \rceil$, where the virtual user $\Brk \in [P]$ has the cache content corresponding to the profile $p = \Brk$ in the original network. For this virtual network, we build the transmission vectors using the RED scheme in~\cite{salehi2020lowcomplexity},\footnote{The RED scheme requires the spatial DoF to be larger than or equal to the caching gain. So, here we assume $\Bar{\alpha} \ge \Brt$. Relaxing this condition is left for the extended version of the paper.} resulting in a total number of $P(P-\Brt)$ transmission vectors $\Bar{\Bx}_{j}^{r}$, where $j \in [P-\Brt]$ and $r \in [P]$. In fact, the virtual network would require $P$ transmission \emph{rounds}, where at each round, $P-\Brt$ individual transmissions are done. The transmission vector $\Bar{\Bx}_{j}^{r}$ is explicitly built as \begin{equation} \label{eq:trans_general_virt_net} \Bar{\Bx}_{j}^{r} = \sum_{\Brn \in [\Brt+\Bar{\alpha}]} \BrW_{\Bar{\Bp}_{j}^{r}[\Brn]}^{\Brq}(\Bar{\Bk}_{j}^{r}[\Brn]) \Bar{\Bw}_{\Bar{\CR}_{j}^{r}(\Brn)} \; , \end{equation} where $\Bar{\Bp}_j^r$ and $\Bar{\Bk}_j^r$ are the packet and user index vectors, and $\Bar{\CR}_j^r(\Brn)$ is the interference indicator set used for the $\Brn$-th data term, in the $j$-th transmission of round $r$. Also, $\Bar{\Bw}_{\Bar{\CR}_{j}^{r}(\Brn)}$ is the optimized beamforming vector suppressing data at every user in $\Bar{\CR}_j^r(\Brn)$, $\BrW(\Brk)$ denotes the file requested by the virtual user $\Brk$, and $\Brq$ is the subpacket index which is initialized to one and increased every time a packet appears in a transmission vector. All these parameters are exactly defined in~\cite{salehi2020lowcomplexity}. Specifically, $\Bar{\Bp}_j^r$ and $\Bar{\Bk}_j^r$ are built such that the graphical representation of the transmission vectors follows two perpendicular circular shift operations over a grid. The following example clarifies how the transmission vectors are built for the virtual network. \begin{exmp} \label{exmp:virt_network} Consider the network in Example~\ref{exmp:base_network}, and assume the spatial DoF is $\alpha = 4$. Also, assume $\eta_1 = \eta_2 = 2$ and $\eta_3 = \eta_4 =3$. If we choose either $\hat{\eta} = 2$ or $\hat{\eta} = 3$, the virtual network will have $P = 4$ users, coded caching gain $\Brt = 1$ and spatial DoF $\Bar{\alpha} = 2$. Then, the data delivery will require four rounds, with three transmissions at each round. According to~\cite{salehi2020lowcomplexity}, user and packet index vectors for the first round ar \begin{equation*} \begin{aligned} &\Bar{\Bk}_1^1 = [\Bar{1}, \Bar{2}, \Bar{3}], \quad \Bar{\Bk}_2^1 = [\Bar{1}, \Bar{3}, \Bar{4}], \quad \Bar{\Bk}_3^1 = [\Bar{1}, \Bar{4}, \Bar{2}] \; , \\ &\Bar{\Bp}_1^1 = [\Bar{2}, \Bar{1}, \Bar{1}], \quad \Bar{\Bp}_2^1 = [\Bar{3}, \Bar{1}, \Bar{1}], \quad \Bar{\Bp}_3^1 = [\Bar{4}, \Bar{1}, \Bar{1}] \; , \end{aligned} \end{equation*} resulting in the transmission vectors \begin{equation*} \label{eq:virt_trans_vectors} \begin{aligned} \Bar{\Bx}_1^1 &= \BrW_{\Bar{2}}^{\Bar{1}}(\Bar{1}) \Bar{\Bw}_{\Bar{3}} + \BrW_{\Bar{1}}^{\Bar{1}}(\Bar{2}) \Bar{\Bw}_{\Bar{3}} + \BrW_{\Bar{1}}^{\Bar{1}}(\Bar{3}) \Bar{\Bw}_{\Bar{2}} \; , \\ \Bar{\Bx}_2^1 &= \BrW_{\Bar{3}}^{\Bar{1}}(\Bar{1}) \Bar{\Bw}_{\Bar{4}} + \BrW_{\Bar{1}}^{\Bar{2}}(\Bar{3}) \Bar{\Bw}_{\Bar{4}} + \BrW_{\Bar{1}}^{\Bar{1}}(\Bar{4}) \Bar{\Bw}_{\Bar{3}} \; , \\ \Bar{\Bx}_3^1 &= \BrW_{\Bar{4}}^{\Bar{1}}(\Bar{1}) \Bar{\Bw}_{\Bar{2}} + \BrW_{\Bar{1}}^{\Bar{2}}(\Bar{4}) \Bar{\Bw}_{\Bar{2}} + \BrW_{\Bar{1}}^{\Bar{2}}(\Bar{2}) \Bar{\Bw}_{\Bar{4}} \; , \\ \end{aligned} \end{equation*} where brackets for interference indicator sets are dropped for notational simplicity. For clarification, we use a tabular view, borrowed from~\cite{salehi2020lowcomplexity}, to graphically represent the transmission vectors in Figure~\ref{fig:subhatnoxor}. In this representation, columns and rows denote user and packet indices, respectively. A darkly shaded cell means the packet index is cached at the user, while a lightly shaded cell indicates that (part of) the packet index is transmitted to the user. As can be seen in Figure~\ref{fig:subhatnoxor}, the transmission vectors in a single round are built using circular shift operations of the lightly shaded cells over non-colored cells of the table, in two perpendicular directions. \input{Figs/Trans_virt} \end{exmp} After the transmission vectors are built for the virtual network, we need to \emph{elevate} them to be applicable to the original network. We first need to define a few new parameters; $b$ is the remainder of the division of $\alpha$ by $\hat{\eta}$, i.e., $b = \alpha - \hat{\eta} \lfloor \frac{\alpha}{\hat{\eta}} \rfloor$, and the set $\CD_{\Brk}$ consists of the set of user indices in the real network that are associated with the profile $p = \Brk$. Then, we have two elevation mechanisms, depending on the value of $b$. \noindent \textbf{1)} If $b = 0$, i.e., if $\frac{\alpha}{\hat{\eta}}$ is an integer, every vector $\Bar{\Bx}_j^r$ is elevated into one transmission vector $\Bx_j^r$ for the original network. To do so, each term inside the summation in~\eqref{eq:trans_general_virt_net} is replaced by \begin{equation*} \label{eq:elevation_b0} \BrW_{\Bar{\Bp}_{j}^{r}[\Brn]}^{\Brq}(\Bar{\Bk}_{j}^{r}[\Brn]) \Bar{\Bw}_{\Bar{\CR}_{j}^{r}(\Brn)} \rightarrow \sum_{m \in [\hat{\eta}]} W_{\Bar{\Bp}_{j}^{r}[\Brn]}^{q}(\CD_{\Bar{\Bk}_{j}^{r}[\Brn]}[m]) \Bw_{\CR_j^r(\Brn,m)} \; , \end{equation*} where \begin{equation} \label{eq:int_set_elevation} \CR_j^r(\Brn,m) = \bigcup_{\Brk \in \Bar{\CR}_j^r(\Brn)} \!\! \CD_{\Brk} \;\; \cup \;\; \CD_{\Bar{\Bk}_{j}^{r}[\Brn]} \;\; \backslash \;\; \{ \CD_{\Bar{\Bk}_{j}^{r}[\Brn]}[m] \} \; . \end{equation} In other words, every data term intended for some user $\Brk$ in the virtual network is replaced by $\hat{\eta}$ data terms intended for all users associated with profile $p = \Brk$ in the real network, and the inter-stream interference between these terms is suppressed by beamforming vectors. Note that each interference indicator set $\Bar{\CR}_{j}^{r}(\Brn)$ in the virtual network consists of $\Bar{\alpha} - 1$ virtual users, and hence, using~\eqref{eq:int_set_elevation}, every interference indicator set in the real network will have $(\Bar{\alpha}-1)\hat{\eta} + (\hat{\eta}-1) = \Bar{\alpha}\hat{\eta} - 1 = \alpha - 1$ users. So, suppressing the interference with the beamformers is possible as the spatial DoF for the original network is $\alpha$. Summarizing the discussions, if $b=0$, the transmission vectors for the original network are built as \begin{equation} \Bx_j^r = \sum_{\Brn \in [\Brt+\Bar{\alpha}]} \sum_{m \in [\hat{\eta}]} W_{\Bar{\Bp}_{j}^{r}[\Brn]}^{q}(\CD_{\Bar{\Bk}_{j}^{r}[\Brn]}[m]) \Bw_{\CR_j^r(\Brn,m)} \; . \end{equation} \noindent \textbf{2)} If $b \neq 0$, i.e., when $\alpha$ is \emph{not} divisible by $\hat{\eta}$, every transmission vector $\Bar{\Bx}_j^r$ is elevated into $\hat{\eta}$ transmission vectors $\Bx_{j,s}^r$, $s \in [\hat{\eta}]$, for the original network. For elevation, we first define the \emph{base} and \emph{extended} interference indicator sets as \begin{equation*} \CB_{j,s}^{r,b}(\Brn,m) = \bigcup_{\Brk \in \Bar{\CR}_j^r[\Brn]} \!\! \CD_{\Brk} \;\; \bigcup_{i \in \CE_s^b(\hat{\eta})} \{ \CD_{\Bar{\Bk}_{j}^{r}[\Brt + \Bar{\alpha}]}[i] \} \end{equation*} and \begin{equation*} \CR_{j,s}^{r,b}(\Brn,m) \! = \! \begin{cases} & \!\!\!\!\!\! \CB_{j,s}^{r,b}(\Brn,m) \cup \CD_{\Bar{\Bk}_{j}^{r}[\Brn]} \backslash \{ \CD_{\Bar{\Bk}_{j}^{r}[\Brn]}[m] \} \quad \! \Brn < \Brt+\Bar{\alpha}\\ & \!\!\!\!\!\! \CB_{j,s}^{r,b}(\Brn,m) \backslash \{\CD_{\Bar{\Bk}_{j}^{r}[\Brn]}[m]\} \quad \quad \quad \quad \;\; \Brn = \Brt+\Bar{\alpha} \end{cases} \end{equation*} respectively, where $\CE_s^b(\hat{\eta})$ denotes the first $b$ elements of $[\hat{\eta}]$, after they are circularly shifted to the left by $s$ units (recall that the order of members in a set is preserved). In other words, \begin{equation} \CE_s^b(\hat{\eta}) = \big( ([b] + s - 2) \mod \hat{\eta} \big) + 1 \; . \end{equation} Then, the elevated transmission vectors are built as \begin{equation} \Bx_{j,s}^r = \sum_{\Brn \in [\Brt+\Bar{\alpha}]} \sum_{m \in [\hat{\eta}]} W_{\Bar{\Bp}_{j}^{r}[\Brn]}^{q}(\CD_{\Bar{\Bk}_{j}^{r}[\Brn]}[m]) \Bw_{\CR_{j,s}^{r,b}(\Brn,m)} \; . \end{equation} As an explanation, from the $\Brt + \Bar{\alpha}$ total data terms within the transmission vector $\Bar{\Bx}_j^r$, we substitute each of the first $\Brt + \Bar{\alpha}-1$ terms with $\hat{\eta}$ terms for the real network (as we did for the case $b=0$). However, the last data term is only replaced by $b$ terms, out of the $\hat{\eta}$ options, chosen through a circular shift operation (implemented using $\CE_s^b(\hat{\eta})$ in the equations). The following example clarifies the elevation process for both cases of $b = 0$ and $b \neq 0$, and enlightens the effect of phantom users. \begin{exmp} \label{exmp:base_net_cc_perfect} Consider the same network in Example~\ref{exmp:base_network}, with the profile lengths mentioned in Example~\ref{exmp:virt_network}. Let us assume $\CD_{\Bar{1}} = [1,2]$, $\CD_{\Bar{2}} = [3,4]$, $\CD_{\Bar{3}} = [5,6,7]$, and $\CD_{\Bar{4}} = [8,9,10]$. For this network, we find transmission vectors resulting from the elevation of the vectors in~\eqref{eq:virt_trans_vectors}, for both cases of $\hat{\eta} = 2,3$. If $\hat{\eta} = 2$, no phantom users are needed. However, we should exclude two users, associated with profiles $p=3,4$, from the CC delivery phase. Assume users 7 and 10 are excluded. As $b=0$, transmission vectors $\Bar{\Bx}_1^1$ and $\Bar{\Bx}_1^2$ in~\eqref{eq:virt_trans_vectors} are elevated as \begin{equation*} \begin{aligned} \Bx_1^1 =& W_2^1(1) \Bw_{5,6,2} + W_2^1(2) \Bw_{5,6,1} + W_1^1(3) \Bw_{5,6,4} \\ &+ W_1^1(4) \Bw_{5,6,3} + W_1^1(5) \Bw_{3,4,6} + W_1^1(6) \Bw_{3,4,5} \; , \\ \Bx_2^1 =& W_3^1(1) \Bw_{8,9,2} + W_3^1(2) \Bw_{8,9,1} + W_1^2(5) \Bw_{8,9,6} \\ &+ W_1^2(6) \Bw_{8,9,5} + W_1^1(8) \Bw_{5,6,9} + W_1^1(9) \Bw_{5,6,8} \; , \\ \end{aligned} \end{equation*} and their graphical representation will be as shown in Figure~\ref{fig:elevated_b0}. Comparing Figures~\ref{fig:subhatnoxor} and~\ref{fig:elevated_b0}, we can see that the elevation mechanism stretches the transmission vectors horizontally. \input{Figs/elevate_b0} Now, let us assume $\hat{\eta} = 3$. In this case, no user is excluded from the CC delivery phase, but two phantom users $\Check{1}$ and $\Check{2}$ are associated with profiles $p=1$ and $p=2$, respectively. As $b=1$, each transmission vector for the virtual network is elevated into $\hat{\eta} = 3$ vectors for the real network. Here we only mention the vectors resulting from $\Bar{\Bx}_1^1$, which are built as \begin{equation} \label{eq:trans_vect_b_neq_0_phantom} \begin{aligned} &\Bx_{1,1}^1 \! = \! W_2^1(1) \Bw_{2,\Check{1},5} \! + \! W_2^1(2) \Bw_{1,\Check{1},5} \! + \! W_2^1(\Check{1}) \Bw_{1,2,5} + \\ & \; \; \; W_1^1(3) \Bw_{4,\Check{2},5} \! + \! W_1^1(4) \Bw_{3,\Check{2},5} \! + \! W_1^1(\Check{2}) \Bw_{3,4,5} \! + \! W_1^1(5) \Bw_{3,4,\Check{2}} , \\ &\Bx_{1,2}^1 \! = \! W_2^2(1) \Bw_{2,\Check{1},6} \! + \! W_2^2(2) \Bw_{1,\Check{1},6} \! + \! W_2^2(\Check{1}) \Bw_{1,2,6} + \\ & \; \; \; W_1^2(3) \Bw_{4,\Check{2},6} \! + \! W_1^2(4) \Bw_{3,\Check{2},6} \! + \! W_1^2(\Check{2}) \Bw_{3,4,6} \! + \! W_1^1(6) \Bw_{3,4,\Check{2}} , \\ &\Bx_{1,3}^1 \! = \! W_2^3(1) \Bw_{2,\Check{1},7} \! + \! W_2^3(2) \Bw_{1,\Check{1},7} \! + \! W_2^3(\Check{1}) \Bw_{1,2,7} + \\ & \; \; \; W_1^3(3) \Bw_{4,\Check{2},7} \! + \! W_1^3(4) \Bw_{3,\Check{2},7} \! + \! W_1^3(\Check{2}) \Bw_{3,4,7} \! + \! W_1^1(7) \Bw_{3,4,\Check{2}} . \\ \end{aligned} \end{equation} The graphical representation of this elevation mechanism is shown in Figure~\ref{fig:elevated_b1}, where the columns representing phantom users are hatched for better clarification. Comparing with the base transmission vectors for the virtual network in Figure~\ref{fig:subhatnoxor}, the elevation mechanism works through horizontal stretching followed by an extra circular shift operation over a block of user indices (users 5,6,7 in this example). Finally, we should note that the effect of phantom users should be removed before the real transmission. To do so, we simply remove phantom indices from the transmission vectors. So, for example, instead of $\Bx_{1,1}^1$ in~\eqref{eq:trans_vect_b_neq_0_phantom}, we transmit \begin{equation*} \begin{aligned} \Bx_{1,1}^1 =& W_2^1(1) \Bw_{2,5} + W_2^1(2) \Bw_{1,5} + W_1^1(3) \Bw_{4,5} \\ & + W_1^1(4) \Bw_{3,5} + W_1^1(5) \Bw_{3,4} \; . \\ \end{aligned} \end{equation*} \input{Figs/elevate_b1} \end{exmp} As can be seen in Example~\ref{exmp:base_net_cc_perfect}, the choice of $\hat{\eta}$ can heavily affect both performance and complexity metrics such as the required subpacketization and number of transmissions. A smaller $\hat{\eta}$ reduces the chance of requiring phantom users, but more real users are excluded from the CC delivery phase, and hence, the achievable coded caching gain is reduced. On the other hand, while with a larger $\hat{\eta}$ we can include more users in the CC delivery phase, in specific transmissions, the achievable \ac{DoF} can become too small after the effect of phantom users is removed (in Example~\ref{exmp:base_net_cc_perfect}, $\Bx_1^1$ has a DoF of six, but for $\Bx_{1,s}^1$, $s\in[3]$ the DoF is reduced to five). In fact, if the distribution of profile lengths $\eta_p$ and the choice of $\hat{\eta}$ are such that we need many phantom users, the achievable DoF in some transmissions may fall below the spatial \ac{DoF} $\alpha$ (i.e., we lose \ac{DoF} by using coded caching techniques). One solution to this issue is to check the achievable \ac{DoF} at every transmission vector after removing the effect of phantom users, and avoid the transmission if the \ac{DoF} falls below $\alpha$. The data terms intended to be sent with such transmission vectors are then transmitted during the subsequent unicast delivery phase. \section{Unicast Delivery Phase} During the unicast delivery phase, we fulfill the request of users excluded from the CC delivery phase. Meantime, we also transmit any other data term not sent during the CC delivery phase. This includes, for example, data terms in transmission vectors with a \ac{DoF} value smaller than $\alpha$ (due to the presence of phantom users), or data terms re-transmitted because of channel errors. We use a greedy mechanism (which is not necessarily optimal) to achieve an appropriate spatial \ac{DoF} for every transmission vector in this phase. To do so, we first split the files requested by users excluded from the CC delivery phase into the same number of subpackets we needed in the CC delivery phase (this subpacketization value is discussed shortly after). Then, for every user $k$, we define $u(k)$ to be the number of subpackets that should be delivered to user $k$, and sort users by their $u(k)$ values in the descending order. Now, we select $\max\{\alpha,U\}$ first users, where $U$ is the total number of users for which $u(k) > 0$, and deliver one subpacket to each selected user, with a single transmission vector. The inter-stream interference in the transmission vector is suppressed by beamforming vectors (which is possible as the spatial \ac{DoF} is $\alpha$). Finally, we update $u(k)$ values and repeat the same procedure, until all the remaining data terms are transmitted. \begin{exmp} Consider the network in Example~\ref{exmp:base_net_cc_perfect}, and assume $\hat{\eta} = 2$. In this case, we don't need any phantom users, but the users 7 and 10 are excluded from the CC delivery phase (as also shown in Figure~\ref{fig:elevated_b0}). As will be shown later, the total subpacketization in this case is $P(\Brt + \Bar{\alpha}) = 12$. However, in the placement phase, each file is already split into $P=4$ packets, and one packet is cached at each user. So, during the delivery, we need to further split each packet into $\frac{12}{4} = 3$ subpackets and deliver nine subpackets to each of these users. So, $u(k)=9$ for $k=7,10$ and zero otherwise, and $U=2$. Then, we need nine transmission vectors, where each vector delivers one subpacket to each of the users 7 and 10. For example, the first and second vectors are built as $W_1^1(7)\Bw_{10} + W_1^1(10) \Bw_7$ and $W_1^2(7)\Bw_{10} + W_1^2(10) \Bw_7$, respectively. \end{exmp} \subsection{Complexity Analysis} As stated earlier, the goal of this paper is \emph{not} to provide a theoretically optimal scheme. Instead, we aim at proposing a practical coded caching solution for dynamic networks where the users are allowed to join and leave the network. In this regard, our scheme has a small subpacketization requirement and enables a very simple optimized beamformer design using uplink-downlink duality~\cite{salehi2020lowcomplexity}, and hence, can be applied to networks with a large ($O(10^2)$) number of users. Also, as we will verify through simulations, it is able to provide a comparable performance with the non-dynamic scenario. The subpacketization requirement of our scheme depends on the value of $b$. If $b=0$ (i.e., if $\alpha$ is divisible by $\hat{\eta}$), the total subpacketization is $P(\Brt + \Bar{\alpha})$. This simply follows the fact that in this case, every transmission vector for the virtual network is elevated into exactly one vector for the original network, and no extra splitting is required. However, if $b \neq 0$, the scheme needs a larger subpacketization of $P(\hat{\eta} \Brt+\alpha)$. Analyzing the required subpacketization in this case is lengthy due to the extra circular shift operation in the scheme and removed here due to the lack of space. It can be seen that in both cases, the required subpacketization is pretty small and grows linearly with the total number of users in the CC delivery phase. Simulation results for the proposed scheme are provided in Figures~\ref{fig:L12-ScenarioB} and~\ref{fig:L12-ScenarioBCD}. We have done simulations for a \ac{MISO} network with 50 single-antenna users, where the cache ratio at each user is $\gamma = 0.1$ (i.e., $P=10$), and the spatial \ac{DoF} is set to $\alpha = 10$. The number of transmitting antennas at the server can be any number larger than $\alpha$; it is assumed to be 12 here. For the distribution of $\eta_p$, we consider uniform distribution (i.e., $\eta_p = 5$ for $p \in [10]$) as well as three other scenarios, where the non-uniformity of $\eta_p$ values increase from scenario 1 to 3. The exact values of $\eta_p$ for these scenarios are shown in Table~\ref{tab:sim_scenarios}. In all simulations, optimized beamformers are used and both CC and unicast delivery phases are implemented. For a better comparison, in the figures we have also included the rate curve for the case all the required data is delivered through the unicast delivery phase (i.e., there is no coded caching gain). \input{Figs/L12-ScenarioB} \begin{table}[t] \centering \begin{tabular}{|c||c|c|} \hline Scenario & $\eta_p$ values & Standard deviation \\ \hline \hline 1 & 5,4,5,5,4,3,6,6,5,7 & 1.15 \\ \hline 2 & 9,3,1,4,5,7,2,6,5,8 & 2.58 \\ \hline 3 & 8,3,8,0,4,10,7,4,0,6 & 3.40 \\ \hline \end{tabular} \caption{Simulation scenarios with non-uniform profile lengths} \label{tab:sim_scenarios} \end{table} \input{Figs/L12-ScenarioBCD} In Figure~\ref{fig:L12-ScenarioB}, the effect of the $\hat{\eta}$ parameter on the performance in scenarios 1, 3 is shown. In general, choosing a larger $\hat{\eta}$ value (up to $\max \eta_p$) improves the performance. This is because with increased $\hat{\eta}$, a better coded caching gain, strong enough to cover for the \ac{DoF} loss of phantom users, is achieved. Of course, it should be noted that in scenario 3, the case $\hat{\eta} = 9$ provides slightly (about one percent) better rate compared with $\hat{\eta} = 10$. This is because as $\eta_p$ distribution becomes more non-uniform, by choosing $\hat{\eta} = \max \eta_p$ we need to add too many phantom users, increasing the chance of \ac{DoF} loss. Nevertheless, even for the very non-uniform case of scenario 3, this performance loss is negligible, and one can safely consider $\hat{\eta} = \max \eta_p$ in all cases. Of course, a more theoretical analysis, due for the extended version of this paper, would better clarify the probable performance loss of selecting $\hat{\eta} = \max \eta_p$. Finally, in Figure~\ref{fig:L12-ScenarioBCD}, we compare the performance of the proposed scheme with the case of uniform $\eta_p$ distribution (i.e., the maximum possible coded caching gain), for scenarios 1, 2, and 3, when $\hat{\eta} = \max \eta_p$. As can be seen, the proposed scheme performs very well, with loss of less than ten percent for the considered network setup, compared with the uniform case. This is because with $\hat{\eta} = \max \eta_p$, we try to maximize the achievable global caching gain. Also, when \ac{DoF} falls due to phantom users, optimized beamformers enable a larger beamforming gain (as the size of the interference indicator set becomes smaller than $\alpha-1$), thus compensating for the minor performance loss. Interestingly, in the low-SNR regime and for scenario 1, the proposed scheme even outperforms the uniform case by a small margin. This is because the beamforming gain is more effective in this regime, as discussed in~\cite{tolli2017multi}. \section{3pt}{6pt plus 4pt minus 2pt}{6pt plus 2pt minus 2pt} \titlespacing\subsection{3pt}{4pt plus 4pt minus 2pt}{4pt plus 2pt minus 2pt} \titlespacing\subsubsection{3pt}{3pt plus 4pt minus 2pt}{0pt plus 2pt minus 3pt} \setlength{\textfloatsep}{2pt plus 3pt minus 2pt} \setlength{\abovecaptionskip}{3pt plus 3pt minus 2pt} \setlength{\belowcaptionskip}{3pt plus 3pt minus 2pt} \setlength{\belowdisplayskip}{3pt} \setlength{\belowdisplayshortskip}{5pt} \setlength{\abovedisplayskip}{3pt} \setlength{\abovedisplayshortskip}{5pt} \title{Low-Subpacketization Multi-Antenna\\Coded Caching for Dynamic Networks} \begin{document} \author{\IEEEauthorblockN{MohammadJavad Salehi\IEEEauthorrefmark{1}, Emanuele Parinello\IEEEauthorrefmark{2}, Hamidreza Bakhshzad Mahmoodi\IEEEauthorrefmark{1}, and Antti T\"olli\IEEEauthorrefmark{1}} \\ \IEEEauthorblockA{ \IEEEauthorrefmark{1}Centre for Wireless Communications, University of Oulu, 90570 Oulu, Finland \\ \IEEEauthorrefmark{2}Communication Systems Department, Eurecom, Sophia Antipolis, 06410 Biot, France\\ \textrm{E-mail: \{firstname.lastname\}@oulu.fi, \{firstname.lastname\}@eurecom.fr} } \thanks{ This work is supported by the Academy of Finland under grant no. 318927 (6Genesis Flagship), and by Vaikuttavuuss\"a\"ati\"o under the project Directional Data Delivery for Wireless Immersive Digital Environments (3D-WIDE).}\vspace{-10pt} } \maketitle \begin{abstract} Multi-antenna coded caching combines a global caching gain, proportional to the total cache size in the network, with an additional spatial multiplexing gain that stems from multiple transmitting antennas. However, classic centralized coded caching schemes are not suitable for dynamic networks as they require prior knowledge of the number of users to indicate what data should be cached at each user during the placement phase. On the other hand, fully decentralized schemes provide comparable gains to their centralized counterparts only when the number of users is very large. In this paper, we propose a novel multi-antenna coded caching scheme for dynamic networks, where instead of defining individual cache contents, we associate users with a limited set of predefined caching profiles. Then, during the delivery phase, we aim at achieving a combined caching and spatial multiplexing gain, comparable to a large extent with the ideal case of fully centralized schemes. The resulting scheme imposes small subpacketization and beamforming overheads, is robust under dynamic network conditions, and incurs small finite-SNR performance loss compared with centralized schemes. \end{abstract} \begin{IEEEkeywords} coded caching, MIMO communications, low-subpacketization, dynamic networks \end{IEEEkeywords} \section{Introduction} \input{Intro} \section{System Model} \input{SysMoodel} \input{HybridCC} \section{Performance Analysis} \input{SimResults} \section{Conclusion and Future Work} We introduced a new multi-antenna coded caching scheme for dynamic networks where the users are allowed to join and leave the network freely. Instead of dictating individual caching profiles for users, we associated them with a set of predefined caching profiles. Data delivery is then performed in two consecutive phases, with the goal of maximizing the achievable performance. The proposed scheme requires a small subpacketization, enables easy implementation of optimized beamformers, and its performance and robustness under dynamic conditions is shown through simulations. The current paper provides a proof-of-concept, with many theoretical analyses and optimizations due for future work. \bibliographystyle{IEEEtran}
{'timestamp': '2021-11-16T02:29:14', 'yymm': '2111', 'arxiv_id': '2111.07626', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07626'}
arxiv
\section{Introduction} A deep feedforward network observes an entire scene to achieve state-of-the-art performance. However, observing an entire scene may not be necessary as many times the task-relevant information lies only in a few parts of the scene. A visual hard attention technique allows a recognition system to attend to only the most informative subregions called \textit{glimpses} \cite{mnih2014recurrent,xu2015show}. A hard attention model builds a representation of a scene by sequentially acquiring useful glimpses and fusing the collected information. The representation guides recognition and future glimpse acquisition. Hard attention is useful to reduce data acquisition cost \cite{uzkent2020learning}, to develop interpretable \cite{elsayed2019saccader}, computationally efficient \cite{katharopoulos2019processing} and scalable \cite{papadopoulos2021hard} models. The majority of hard attention models first analyze a complete image, occasionally at low resolution, to locate the task-relevant subregions \cite{ ba2014multiple, elsayed2019saccader}. However, in practice, we often do not have access to the entire scene. Instead, we only observe parts of the scene as we attend to them. We decide the next attention-worthy location at each step in the process based on the partial observations collected so far. Examples include a self-driving car navigating in unknown territory, time-sensitive aerial imagery for a rescue operation, etc. Here, we develop a hard-attention model for such a scenario. While the majority of existing hard attention models pose glimpse acquisition as a reinforcement learning task to optimize a non-differentiable model \cite{mnih2014recurrent, xu2015show}, we use a fully differentiable model and training objective. We train the model using a combination of discriminative and generative objectives. The former is used for class-label prediction, and the latter is used for the content prediction for unobserved regions. We use the predicted content to find an optimal attention-worthy location as described next. A hard attention model predicts the class label of an image by attending various informative glimpses in an image. We formulate the problem of finding optimal glimpse-locations as Bayesian Optimal Experiment Design (BOED). Starting from a random location, a sequential model uses BOED to determine the next optimal location. To do so, it estimates the expected information gain (EIG) obtained from observing glimpses at yet unobserved regions of the scene and selects a location with maximum EIG. As the computation of EIG requires the content of regions, the model \textit{synthesizes} the unknown content conditioned on the content of the observed regions. For efficiency reasons, the model predicts the content in the feature space instead of the pixel space. Our model consists of three modules, a recurrent feature aggregator, a linear classifier, and a Partial VAE \cite{ma2018eddi}. Partial VAE synthesizes features of various glimpses in the scene based on partial observations. There may exist multiple possibilities for the content of the unobserved regions, given the content of the observed regions. Hence, we use normalizing flows in Partial VAE to capture the multi-modality in the posterior. Our main contributions are as follows. \begin{itemize}[noitemsep,topsep=0pt,leftmargin=*] \item We develop a hard attention model to classify images using a series of partial observations. The model estimates EIG of the yet unobserved locations and attends a location with maximum EIG. \item To estimate EIG of unobserved regions, we synthesize the content of these regions. Furthermore, to improve the efficiency of a model, we synthesize the content in the feature space and use normalizing flows to capture the multi-modality in the problem. \item We support our approach with a principled mathematical framework. We implement the model using a compact network and perform experiments on five datasets. Our model achieves 2-10\% higher accuracy compared to the baseline methods when both have seen only a couple of glimpses. \end{itemize} \section{Related Works} \minisection{Hard Attention.} A hard attention model prioritizes task-relevant regions to extract meaningful features from an input. Early attempts to model attention employed image saliency as a priority map. High priority regions were selected using methods such as winner-take-all \cite{koch1987shifts,itti1998model, itti2000saliency}, searching by throwing out all features but the one with minimal activity \cite{ahmad1992visit}, and dynamic routing of information \cite{olshausen1993neurobiological}. Few used graphical models to model visual attention. \citet{rimey1991controlling} used augmented hidden Markov models to model attention policy. \citet{larochelle2010learning} used a Restricted Boltzmann Machine (RBM) with third-order connections between attention location, glimpse, and the representation of a scene. Motivated by this, \citet{zheng2015neural} proposed an autoregressive model to compute exact gradients, unlike in an RBM. \citet{tang2014learning} used an RBM as a generative model and searched for informative locations using the Hamiltonian Monte Carlo algorithm. Many used reinforcement learning to train attention models. \citet{paletta2005q} used Q-learning with the reward that measures the objectness of the attended region. \citet{denil2012learning} estimated rewards using particle filters and employed a policy based on the Gaussian Process and the upper confidence bound. \citet{butko2008pomdp} modeled attention as a partially observable Markov decision process and used a policy gradient algorithm for learning. Later, \citet{butko2009optimal} extended this approach to multiple objects. Recently, the machine learning community uses the REINFORCE policy gradient algorithm to train non-differentiable hard attention models \cite{mnih2014recurrent, ba2014multiple, xu2015show, elsayed2019saccader, papadopoulos2021hard}. Other recent works use EM-style learning procedure \cite{ranzato2014learning}, wake-sleep algorithm \cite{ba2015learning}, a voting based region selection \cite{alexe2012searching}, and spatial transformer \cite{jaderberg2015spatial, gregor2015draw, eslami2016attend}. Among the recent methods, \cite{ba2014multiple, ranzato2014learning,ba2015learning} look at the low-resolution gist of an input at the beginning, and \cite{xu2015show, elsayed2019saccader, eslami2016attend, gregor2015draw} consume the whole image to predict the locations to attend. In contrast, our model does not look at the entire image at low resolution or otherwise. Moreover, our model is fully differentiable. \minisection{Image Completion.} Image completion methods aim at synthesizing unobserved or missing image pixels conditioned on the observed pixels \cite{yu2018generative,pathak2016context,iizuka2017globally,wang2014biggerpicture,yang2019very,wang2019wide}. Image completion is an ill-posed problem with multiple possible solutions for the missing image regions. While early methods use deterministic models, \cite{zhang2020multimodal,cai2020piigan,zhao2020uctgan} used stochastic models to predict multiple instances of a complete image. Many used probabilistic models to ensure that the completions are generated according to their actual probability \cite{zheng2019pluralistic, sohn2015learning, ma2018eddi, garnelo2018neural, garnelo2018conditional}. We use Partial VAE \cite{ma2018eddi} -- a probabilistic model -- to predict the content of the complete image given only a few glimpses. However, unlike other approaches that infer image content in the pixel space, we predict content in the feature space. \minisection{Patch Selection.} Many computer vision methods select attention-worthy regions from an image, e.g., region proposal network \cite{ren2015faster}, multi-instance learning \cite{ilse2018attention}, top-$K$ patch selection \cite{angles2018mist, cordonnier2021differentiable}, attention sampling \cite{katharopoulos2019processing}. These approaches observe an entire image and find all attention-worthy patches simultaneously. Our model observes an image only partially and sequentially. Furthermore, it selects a single optimal patch to attend at a given time. \vspace{-0.2cm} \section{Model} \label{sec:model} In this paper, we consider a recurrent attention model that sequentially captures glimpses from an image $x$ and predicts a label $y$. The model runs for time $t=0$ to $T-1$. It uses a recurrent net to maintain a hidden state $h_{t-1}$ that summarizes glimpses observed until time $t-1$. At time $t$, it predicts coordinates $l_t$ based on the hidden state $h_{t-1}$ and captures a square glimpse $g_t$ centered at $l_t$ in an image $x$, i.e. $g_t = g(x,l_t)$. It uses $g_t$ and $l_t$ to update the hidden state to $h_t$ and predicts the label $y$ based on the updated state $h_t$. \vspace{-0.2cm} \subsection{Building Blocks} \label{sec:architecture} \begin{figure} \centering \includegraphics[width=0.8\textwidth]{figures/f_graph.pdf} \caption{A recurrent attention model sequentially observes glimpses from an image and predicts a class label. At time $t$, the model actively observes a glimpse $g_t$ and its coordinates $l_t$. Given $g_t$ and $l_t$, the feed-forward module $F$ extracts features $f_t$, and the recurrent module $R$ updates a hidden state to $h_t$. Using an updated hidden state $h_t$, the linear classifier $C$ predicts the class distribution $p(y|h_t)$. At time $t+1$, the model assesses various candidate locations $l$ before attending an optimal one. It predicts $p(y|g,l,h_t)$ ahead of time and selects the candidate $l$ that maximizes $D_{\mathrm{KL}}[p(y|g,l,h_t)||p(y|h_t)]$. The model synthesizes the features of $g$ using a Partial VAE to approximate $p(y|g,l,h_t)$ without attending to the glimpse $g$. The normalizing flow-based encoder $S$ predicts the approximate posterior $q(z|h_t)$. The decoder $D$ uses a sample $z\sim q(z|h_t)$ to synthesize a feature map $\Tilde{f}$ containing features of all glimpses. The model uses $\Tilde{f}(l)$ as features of a glimpse at location $l$ and evaluates $p(y|g,l,h_t)\approx p(y|\Tilde{f}(l),h_t)$. Dashed arrows show a path to compute the lookahead class distribution $p(y|\Tilde{f}(l),h_t)$.} \label{fig:model} \vspace{-0.2cm} \end{figure} As shown in Figure \ref{fig:model}, the proposed model comprises the following three building blocks. A recurrent feature aggregator ($F$ and $R$) maintains a hidden state $h_t$. A classifier ($C$) predicts the class probabilities $p(y|h_t)$. A normalizing flow-based variational autoencoder ($S$ and $D$) synthesizes a feature map of a complete image given the hidden state $h_t$. Specifically, a flow-based encoder $S$ predicts the posterior of a latent variable $z$ from $h_t$, and a decoder $D$ uses $z$ to synthesize a feature map of a complete image. A feature map of a complete image can also be seen as a map containing features of all glimpses. The BOED, as discussed in section \ref{sec:boed}, uses the synthesized feature map to find an optimal location to attend at the next time step. To distinguish the synthesized feature map from an actual one, let us call the former $\Tilde{f}$ and the latter $f$. Henceforth, we crown any quantity derived from the synthesized feature map with a ( $\Tilde{}$ ). Next, we provide details about the three building blocks of the model, followed by a discussion of the BOED in the context of hard attention.\\ \minisection{Recurrent Feature Aggregator.} Given a glimpse $g_t$ and its location $l_t$, a feed-forward module extracts features $f_t = F(g_t, l_t)$, and a recurrent network updates a hidden state to $h_t = R(h_{t-1}, f_t)$. We define $F(g,l)=\mathcal{F}_g(g) + \mathcal{F}_l(l)$ and $R(h,f) = LeakyReLU(\mathcal{F}_h(h) + \mathcal{F}_f(f))$. $\mathcal{F}_g$ is a small CNN with receptive-field equal to size of $g$. $\mathcal{F}_l, \mathcal{F}_h, \mathcal{F}_f$ are shallow networks with one linear layer.\\ \minisection{Classifier.} At each time step $t$, a linear classifier predicts the distribution $p(y|h_t) = C(h_t)$ from a hidden state $h_t$. As the goal of the model is to predict a label $y$ for an image $x$, we learn a distribution $p(y|h_t)$ by minimizing $D_{\mathrm{KL}}[p(y|x)||p(y|h_t)]$. Optimization of this KL divergence is equivalent to the minimization of the following cross-entropy loss. \begin{align} \mathcal{L}_{\text{CE}}(t) = - p(y|x) \log(p(y|h_t)) \label{eq:ce} \end{align} \minisection{Partial Variational Autoencoder.} \label{sec:pvae} We adapt a variational autoencoder (VAE) to synthesize the feature map of a complete image from the hidden state $h_t$. A VAE learns a joint distribution between the feature map $f$ and the latent variable $z$ given $h_t$, $p(f,z|h_t)=p(f|z)p(z|h_t)$. An encoder approximates the posterior $q(z|f,h_t)$, and a decoder infers the likelihood $p(f|z)$. The optimization of VAE requires calculation of $D_{\mathrm{KL}}[q(z|f,h_t)||p(z|h_t)]$ \cite{kingma2013auto}. As the hard attention model does not observe the complete image, it cannot estimate $q(z|f,h_t)$. Hence, we cannot incorporate the standard VAE directly into a hard attention framework and use the following approach. At the time $t$, let's separate an image $x$ into two parts, $o_t$ --- the set of regions observed up to $t$, and $u_t$ --- the set of regions as yet unobserved. \citet{ma2018eddi} observed that in a VAE, $o_t$ and $u_t$ are conditionally independent given $z$, i.e. $p(x|z)=p(u_t|z) p(o_t|z)$. They synthesize $u_t$ independently from the sample $z\sim q(z|o_t)$, while learning the posterior $q(z|o_t)$ by optimizing ELBO on $\log(p(o_t))$. They refer to the resultant VAE as a Partial VAE. The BOED, as discussed in section \ref{sec:boed}, requires features of $o_t$ and $u_t$. \citet{ma2018eddi} consider $o_t$ and $u_t$ in pixel space. Without the loss of generality, we consider $o_t$ and $u_t$ in the feature space. Synthesizing $o_t$ and $u_t$ in the feature space serves two purposes. First, the model does not have to extract features of $o_t$ and $u_t$ for the BOED as they are readily available. Second, Partial VAE does not have to produce unnecessary details that may later be thrown away by the feature extractor, such as the exact color of a pixel. Recall that the features $f_{1:t}$ and the hidden state $h_t$ calculated by our attention model correspond to the glimpses observed up to $t$, which is equivalent to $o_t$, the set of observed regions. Hence, we write $q(z|o_t)$ as $q(z|h_t)$ and $p(o_t|z)$ as $p(f_{1:t}|z)$ in the ELBO of Partial VAE. \begin{align} \mathcal{L}_{\text{PVAE}}(t) = -ELBO &= -\Big\{ \mathbb{E}_{q(z|o_t)} \log(p(o_t|z)) - D_{\mathrm{KL}}[q(z|o_t)||p(z)]\Big\} \nonumber \\ &= -\Big\{\mathbb{E}_{q(z|h_t)} \log(p(f_{1:t}|z)) - D_{\mathrm{KL}}[q(z|h_t)||p(z)]\Big\} \label{eq:pvae} \end{align} In \eqref{eq:pvae}, the prior $p(z)$ is a Gaussian distribution with zero mean and unit variance. To obtain expressive posterior $q(z|h_t)$, we use normalizing flows in Partial VAE \cite{kingma2016improved}. Specifically, we use auto-regressive Neural Spline Flows (NSF) \cite{durkan2019neural}. Between the two flow layers, we flip the input \cite{dinh2016density} and normalize it using ActNorm \cite{kingma2018glow}. Refer to supp. material for brief overview of NSF. In Figure \ref{fig:model}, the flow-based encoder $S$ infers the posterior $q(z|h_t) = S(h_t)$. In a Partial VAE, $p(f|z) = p(f_{1:t}|z) p(f^c_{1:t}|z)$; where $f^c_{1:t}$ are the features of the glimpses other than the ones observed up to $t$ and $f=f_{1:t} \cup f^c_{1:t}$. We implement a decoder $D$ that synthesizes a feature map containing features of all glimpses in an image given the sample $z\sim q(z|h_t)$, i.e. $\Tilde{f} = D(z)$. Let $m_t$ be a binary mask with value \textbf{1} for the glimpses observed by the model up to $t$ and \textbf{0} otherwise; hence, $f_{1:t} = m_t \odot f$, where $\odot$ is an element-wise multiplication. We assume a Gaussian likelihood and evaluate the log-likelihood in \eqref{eq:pvae} using the mask $m_t$ as follows. \begin{align} - \log(p(f_{1:t}|z)) \propto \frac{1}{2}\sum \frac{|m_t\odot \Tilde{f} - m_t\odot f|^2}{\sigma^2} + \log(\sigma^2) \label{eq:xliklihood} \end{align} Where $\sigma$ is a model parameter. The BOED uses $\Tilde{f}$ to find an optimal location to attend. \subsection{Bayesian Optimal Experiment Design (BOED)} \label{sec:boed} The BOED evaluates the optimality of a set of experiments by measuring information gain in the interest parameter due to the experimental outcome \cite{chaloner1995bayesian}. In the context of hard attention, an experiment is to attend a location $l$ and observe a corresponding glimpse $g=g(x,l)$. An experiment of attending a location $l$ is optimal if it gains maximum information about the class label $y$. We can evaluate optimality of attending a specific location by measuring several metrics such as feature variance \cite{huang2018active}, uncertainty in the prediction \cite{melville2004active}, expected Shannon information \cite{lindley1956measure}. For a sequential model, information gain $ D_{\mathrm{KL}}[p(y|g, l, h_{t-1})||p(y|h_{t-1})]$ is an ideal metric. It measures the change in the entropy of the class distribution from one time step to the next due to observation of a glimpse $g$ at location $l$ \cite{bernardo1979expected,ma2018eddi}. The model has to find an optimal location to attend at time $t$ before observing the corresponding glimpse. Hence, we consider an expected information gain (EIG) over the generating distribution of $g$. An EIG is also a measure of Bayesian surprise \cite{itti2006bayesian,schwartenbeck2013exploration}. \begin{align} EIG(l) &= \mathbb{E}_{p(g|l, h_{t-1})} D_{\mathrm{KL}}\big[p(y|g, l, h_{t-1})||p(y|h_{t-1})\big] \\ &= \mathbb{E}_{p(f(l)| h_{t-1})} D_{\mathrm{KL}}\big[p(y|f(l), h_{t-1})||p(y|h_{t-1})\big] \label{eq:EIG} \end{align} Where $f(l)$ are features of a glimpse located at $l$, i.e. $f(l)=F(g,l)$. Inspired by \cite{harvey2019near}, we define $p(f(l)| h_{t-1})$ as follows. \begin{align} p(f(l)| h_{t-1}) &= \mathbb{E}_{q(z|h_{t-1})} p(f(l)|z) = \mathbb{E}_{q(z|h_{t-1})} \delta(D(z)(l)) = \mathbb{E}_{q(z|h_{t-1})} \delta(\Tilde{f}(l)) \label{eq:p_of_gt} \end{align} Here, $\delta(\cdot)$ is a delta distribution. As discussed in the section \ref{sec:pvae}, the flow-based encoder $S$ predicts the posterior $q(z|h_{t-1})$ and the decoder $D$ predicts the feature map containing features of all glimpses in an image, $\Tilde{f}=D(z)$. Combining \eqref{eq:EIG} and \eqref{eq:p_of_gt} yields, \begin{align} EIG(l) &= \mathbb{E}_{q(z|h_{t-1})} D_{\mathrm{KL}}\big[p(y|\Tilde{f}(l), h_{t-1})||p(y|h_{t-1})\big] \label{eq:EIG_x} \end{align} To find an optimal location to attend at time $t$, the model compares various candidates for $l_t$. It predicts $EIG(l)$ for each candidate $l$ and selects an optimal candidate as $l_t$, i.e. $l_t = \argmax_l EIG(l)$. When the model is considering a candidate $l$, it uses $\Tilde{f}(l)$ to calculate $\Tilde{h}_t = R(h_{t-1}, \Tilde{f}(l))$ and $p(y|\Tilde{h}_{t}) = C(\Tilde{h}_t)$. It uses the distribution $p(y|\Tilde{h}_{t}) = p(y|\Tilde{f}(l), h_{t-1})$ to calculate $EIG$ in \eqref{eq:EIG_x}. We refer to $p(y|\Tilde{h}_{t})$ as the \textit{lookahead} class distribution computed by anticipating the content at the location $l$ ahead of time. In Figure \ref{fig:model}, the dashed arrows show a lookahead step. Furthermore, to compute $EIG$ for all locations simultaneously, we implement all modules of our model with convolution layers. The model computes $EIG$ for all locations as a single activation map in a single forward pass. An optimal location is equal to the coordinates of the pixel with maximum value in the $EIG$ map. \section{Experiments} \minisection{Datasets.} We evaluate our model on SVHN \cite{netzer2011reading}, CINIC-10 \cite{darlow2018cinic}, CIFAR-10 \cite{krizhevsky2009learning}, CIFAR-100 \cite{krizhevsky2009learning}, and TinyImageNet \cite{tinyimagenet} datasets. These datasets consist of real-world images categorized into 10, 10, 10, 100 and 200 classes respectively. Images in TinyImageNet are of size $64\times64$ and images in the remaining dataset are of size $32\times32$. \minisection{Training and Testing.} We train our model in three phases. In the first phase, we pre-train modules $F$, $R$, and $C$ with a random sequence of $T$ glimpses using $\sum_{t=0}^{T-1} \mathcal{L}_{CE}(t)$ as a training objective. In the second phase, we introduce $S$ and $D$. We pre-train $S$ and $D$ while keeping $F$, $R$, $C$ frozen. Again, we use a random sequence of $T$ glimpses and train $S$ and $D$ using $\sum_{t=0}^{T-1} \mathcal{L}_{\text{PVAE}}(t)$ training criterion. To produce the target $f$ used in equation \ref{eq:xliklihood}, we feed a complete image and a grid of all locations to the pretrained $F$, which computes features of all glimpses as a single feature map. Pre-training $(F, R, C)$ and $(S,D)$ separately ensures that the Partial VAE receives a stable target feature map $f$ in equation \ref{eq:xliklihood}. Finally, in the third phase, we fine-tune all modules end-to-end using the training objective $\mathcal{L} = \sum_{t=0}^{T-1} \alpha \mathcal{L}_{\text{PVAE}}(t) + \beta \mathcal{L}_{CE}(t)$, where $\alpha$ and $\beta$ are hyperparameters. In the finetuning stage, we sample an optimal sequence of glimpses using the BOED framework. We use only one sample $z\sim q(z|h_t)$ to estimate the $EIG$ map during the training, which leads to exploration. In the test phase, we achieve exploitation by using $P$ samples of $z$ to estimate the $EIG$ accurately. The test procedure is shown in Algorithm \ref{algo:pred_all}. Refer to supp. material (SM) for more details. \setlength{\textfloatsep}{5pt} \begin{algorithm}[t] \caption{Test procedure for the model shown in Figure \ref{fig:model}} \begin{algorithmic}[1] \State Randomly sample $l_0$; Capture $g_0$ at $l_0$, compute $f_0$, $h_0$ and $p(y|h_0)$ \For{$t \in \{1,\dots,T-1\}$}\Comment{T is the time budget} \State Sample $z_i \sim q(z|h_{t-1})$ and predict $\Tilde{f}^{i}; i \in \{0,\dots,P-1\}$\Comment{P is the sample budget} \State Compute $\Tilde{h}_{t}^{i}$, $p(y|\Tilde{h}_t^i)$ and $EIG = \frac{1}{P} \sum_i D_{\mathrm{KL}}[p(y|\Tilde{h}_t^i)||p(y|h_{t-1})]$ \Comment{\eqref{eq:EIG_x}} \State $l_{t} = \argmax \{EIG\}$ \State Capture $g_t$ at $l_t$; Compute $f_t$, $h_t$ and $p(y|h_t)$ \EndFor \end{algorithmic} \label{algo:pred_all} \end{algorithm} \minisection{Hyperparameters.} We implement our model with a small number of parameters, and it runs for $T=7$ time steps. It senses glimpses of size $16\times16$ overlapping with stride $n=8$ for TinyImageNet and senses glimpses of size $8\times8$ overlapping with stride $n=4$ for the remaining datasets. The Partial VAE predicts $\Tilde{f}$ and $EIG$ for a set of glimpses separated with stride equal to $n$. We do not allow our model to revisit glimpses attended in the past. We choose the hyperparameters $\alpha$ and $\beta$ such that the two loss-terms contribute equally. The sample budget $P$ is 20 for all experiments. Refer to SM for more details. \subsection{Baseline Comparison} We compare our model with four baselines in Figure \ref{fig:compare}(a-e). RAM is a state-of-the-art hard attention model that observes images partially and sequentially to predict the class labels \cite{mnih2014recurrent}. We implement RAM using the same structure as our model. Instead of the Partial VAE, RAM has a controller that learns a Gaussian attention policy. \citet{mnih2014recurrent} minimize $\mathcal{L}_{CE}$ at the end of $T$ steps. Following \cite{li2017dynamic}, we improve RAM by minimizing $\mathcal{L}_{CE}$ at all $T$ steps. We refer to this baseline as RAM+. We also consider a baseline model that attends glimpses on random locations. The Random baseline does not have a controller or a Partial VAE. Our model and the three baselines described so far observe the image only partially through a series of glimpses. Additionally, we train a feed-forward CNN that observes the entire image to predict the class label. For the SVHN dataset, the Random baseline outperforms RAM for initial time steps. However, with time, RAM outperforms the Random baseline by attending more useful glimpses. RAM+ outperforms RAM and the Random baselines at all time steps. We observe a different trend for non-digit datasets. RAM+ consistently outperforms RAM on non-digit datasets; however, RAM+ falls behind the Random baseline. In RAM and RAM+, the classifier shares latent space $h_t$ with the controller, while the Random baseline dedicates an entire latent space to the classifier. We speculate that the dedicated latent space in the Random baseline is one of the reasons for its superior performance on complex datasets. \begin{figure}[!t] \centering \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/svhn_sota.pdf} \centering{(a)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/cifar10_sota.pdf} \centering{(b)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/cinic10_sota.pdf} \centering{(c)} \end{minipage} \hfill \vfill \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/cifar100_sota.pdf} \centering{(d)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/tinyimagenet_sota.pdf} \centering{(e)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/tinyimagenet_noflow.pdf} \centering{(f)} \end{minipage} \hfill \caption{\textit{Baseline Comparison on (a) SVHN (b) CIFAR-10 (c) CINIC-10 (d) CIFAR-100 (e) TinyImageNet. Ablation study on normalizing flows on (f) TinyImageNet.} (a-e) We compare various methods for $t=0$ to $6$. All results are averaged over ten different runs. Accuracy of a CNN and chance accuracy, displayed on top of each plot, serve as upper and lower bounds for the accuracy of glimpse-based methods. A CNN observes an entire image, whereas glimpse-based methods observe $<43.75\%$ area of the image by $t=6$. When compared with baseline methods, our method achieves the highest accuracy. (f) The use of normalizing flows improves accuracy.} \label{fig:compare} \vspace{-0.45cm} \end{figure} \begin{figure}[h!] \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/cnn_observe_diagram.png} \centering{(a)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/svhn_cnnobserve.pdf} \centering{(b)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/cifar10_cnnobserve.pdf} \centering{(c)} \end{minipage} \hfill \vfill \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/cinic10_cnnobserve.pdf} \centering{(d)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/cifar100_cnnobserve.pdf} \centering{(e)} \end{minipage} \hfill \begin{minipage}[c]{0.32\linewidth} \includegraphics[width = \textwidth]{figures/tinyimagenet_cnnobserve.pdf} \centering{(f)} \end{minipage} \hfill \caption{\textit{Accuracy of a CNN when only the attended glimpses are observed}. (a) Experiment setup: we train a CNN using complete images and test it on masked images with only the glimpses attended by various methods made visible. Results on (b) SVHN (c) CIFAR-10 (d) CINIC-10 (e) CIFAR-100 (f) TinyImageNet. All results are averaged over three runs.} \label{fig:cnnobserved} \end{figure} \begin{figure}[!t] \hfill \begin{minipage}[c]{0.48\linewidth} \includegraphics[width = \textwidth]{figures/visualization_epoch450_seed0_im6_of_batch1_labelis_Bird_predis_Bird.pdf} \centering{(a)} \end{minipage} \hfill \begin{minipage}[c]{0.48\linewidth} \includegraphics[width = \textwidth]{figures/visualization_epoch450_seed0_im2_of_batch1_labelis_Automobile_predis_Automobile.pdf} \centering{(b)} \end{minipage} \hfill \vfill \hfill \begin{minipage}[c]{0.48\linewidth} \includegraphics[width = \textwidth]{figures/visualization_epoch450_seed0_im22_of_batch1_labelis_Bird_predis_Bird.pdf} \centering{(c)} \end{minipage} \hfill \begin{minipage}[c]{0.48\linewidth} \includegraphics[width = \textwidth]{figures/visualization_epoch450_seed0_im8_of_batch3_labelis_Dog_predis_Cat.pdf} \centering{(d)} \end{minipage} \hfill \caption{\textit{Visualization of the $EIG$ maps and the glimpses observed by our model on CIFAR-10 images.} The top rows in each plot show the entire image and the $EIG$ maps for $t=1$ to 6. The bottom rows in each plot show glimpses attended by our model. The model observes the first glimpse at a random location. Our model observes a glimpse of size $8\times 8$. The glimpses overlap with the stride of 4, resulting in a $7\times 7$ grid of glimpses. The EIG maps are of size $7 \times 7$ and are upsampled for the display. We display the entire image for reference; our model never observes the whole image. (a-c) success cases (d) failure case.} \label{fig:visual} \end{figure} Our model consistently outperforms all attention baselines on all datasets. The performance gap between the highest performing baseline and our model reduces with many glimpses, as one can expect. Predicting an optimal glimpse-location is difficult for early time-steps as the models have access to minimal information about the scene so far. Compared to the highest performing baseline at $t=1$, our model achieves around 10\% higher accuracy on SVHN, around 5-6\% higher accuracy on CIFAR-10 and CINIC-10, and around 2-3\% higher accuracy on CIFAR-100 and TinyImageNet. Note that CIFAR-100 and TinyImageNet are more challenging datasets compared to SVHN, CINIC-10, and CIFAR-10. Similar to RAM and RAM+, the classifier and the Partial VAE share a common latent space in our model. Hence, our model achieves a lower gain over the Random baseline for complex datasets. We attribute the small but definite gain in the accuracy of our model to a better selection of glimpses. The CNN has the highest accuracy as it observes a complete image. The accuracy of the CNN serves as the upper bound for the hard attention methods. Unlike CNN, the hard attention methods observe less than half of the image through small glimpses, each uncovering only 6.25\% area of an image. On the CIFAR-10 dataset, the CNN predicts correct class labels for approximately 9 out of 10 images after observing each image completely. Remarkably, our model predicts correct class labels for 8 out of 10 images after observing less than half of the total area in each image. \vspace{-0.25cm} \subsubsection{Comparison of Attention Policies using a common CNN} \label{sec:cnn_acc} Above, we compared the attention policies of various methods using their respective classifiers. However, each model attains different discriminative power due to different training objectives. While RAM, RAM+, and our model are trained jointly for two different tasks, i.e., classification and glimpse-location prediction or feature-synthesis, the Random baseline is trained for only one task, i.e., classification. Consequently, the Random baseline attains higher discriminative power than others and achieves high accuracy despite using a sub-optimal attention policy. To make a fair comparison of the attention policies irrespective of the discriminative power of the models, we perform the following experiment. We mask all image regions except for the ones observed by the attention model so far and let the baseline CNN predict a class label from this masked image (see Figure \ref{fig:cnnobserved}). RAM+ consistently outperforms RAM, suggesting that the former has learned a better attention policy than the latter. As RAM+ is trained using $\mathcal{L}_{CE}$ at all time-steps, it achieves higher accuracy, and ultimately, higher reward during training with REINFORCE \cite{mnih2014recurrent}. RAM and RAM+ outperform the Random baseline for the SVHN dataset. However, they fall short on natural image datasets. In contrast, our method outperforms all baselines with a significant margin on all datasets, suggesting that the glimpses selected by our model are more informative about the image class than the ones chosen by the baselines. RAM and RAM+ struggle on images with many objects and repeated structure \cite{sermanet2014attention}, as often the case with natural image datasets. For example, TinyImageNet includes many images with multiple objects (e.g. beer bottle), repeated patterns (e.g. spider web), and dispersed items (e.g. altar). Note that a random policy can perform competitively in such scenarios, especially when the location of various objects in an image is unknown due to partial observability. Yet, our method can learn policies that are superior to the Random baseline. Refer to SM for additional analyses. \vspace{-0.06cm} \subsection{Ablation study on Normalizing Flows} We inspect the necessity of a flexible distribution for the posterior $q(z|h_t)$ and, therefore, the necessity of normalizing flows in the encoder $S$. To this end, we model the posterior with a unimodal Gaussian distribution and let $S$ output mean and diagonal covariance of a Gaussian. We do not use flow layers in this case. Figure \ref{fig:compare}(f) shows the result for TinyImageNet dataset. We observe that modeling a complex posterior using normalizing flows improves accuracy. Ideally, the Partial VAE should predict all possibilities of $\Tilde{f}$ consistent with the observed region $o_t$. When the model observes a small region, a complex posterior helps determine multiple plausible feature maps. A unimodal posterior fails to cover all possibilities. Hence, the EIG estimated with the former is more accurate, leading to higher performance. Refer to SM for visualization of $q(z|h_t)$ estimated with and without normalizing flows. \vspace{-0.06cm} \subsection{Visualization} We visualize a few interesting examples of sequential recognition from the CIFAR-10 dataset in Figure \ref{fig:visual}. Refer to SM for additional examples. In Figure \ref{fig:visual}(a), activity in the $EIG$ map reduces as the model settles on a class `Bird'. In Figure \ref{fig:visual}(b), the model takes a long time to decide the true class of the image. Though incorrect, it predicts classes that are types of vehicles. After discovering parts like headlight and rear-view mirror, it predicts the true class `Automobile' at $t=6$. Figure \ref{fig:visual}(c) shows a difficult example. The model decides the true class `Bird' after covering parts of the bird at $t=5$. Notice a high amount of activity in the $EIG$ maps up to $t=5$ and reduced activity at $t=6$. Figure \ref{fig:visual}(d) shows a failure case with enduring activity in $EIG$ maps. Finally, observe that the $EIG$ maps are often multimodal. \vspace{-0.06cm} \section{Conclusions} We presented a hard attention model that uses BOED to find the optimal locations to attend when the image is observed only partially. To find an optimal location without observing the corresponding glimpse, the model uses Partial VAE to synthesize the content of the glimpse in the feature space. Synthesizing features of unobserved regions is an ill-posed problem with multiple solutions. We use normalizing flows in Partial VAE to capture a complex distribution of unobserved glimpse features, which leads to improved performance. The synthesized features enable the model to evaluate and compare the expected information gain (EIG) of various candidate locations, from which the model selects a candidate with optimal EIG. The predicted EIG maps are often multimodal. Consequentially, the attention policy used by our model is multimodal. Our model achieves superior performance compared to the baseline methods that use unimodal attention policy, proving the effectiveness of multimodal policies in hard attention. When all models have seen only a couple of glimpses, our model achieves 2-10\% higher accuracy than the baselines. \newpage
{'timestamp': '2021-11-16T02:26:27', 'yymm': '2111', 'arxiv_id': '2111.07534', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07534'}
arxiv
\section{Introduction} \label{section:intro} The purpose of anomaly detection and localization in computer vision field is to identify abnormal images and locate abnormal areas, which is widely used in industrial defect detection (Bergmann et al. 2019, 2020), medical image inspection (Philipp Seeböck et al. 2017), security check (Akcay, Atapour-Abarghouei, and Breckon 2018) and other fields. However, due to the low probability density of anomalies, the normal and abnormal data usually show a serious long-tail distribution, and even in some cases, no abnormal samples are available. The drawback of this reality makes it difficult to collect and annotate a large amount of abnormal data for supervised learning in practice. Unsupervised anomaly detection has been proposed to address this problem, which is also denoted as \textit{one-class classification} or \textit{out-of-distribution detection}. That is, we can only use normal samples during training process but need to identify and locate anomalies in testing. \begin{figure}[t] \centering \includegraphics[width=0.97\columnwidth]{ figure1.pdf} \caption{An example of the proposed FastFlow. FastFlow transforms features of the input image from the original distribution to the standard normal distribution. The features of the normal area in the input image fall in the center of the distribution, while the abnormal features are far away from the center of the distribution.} \label{fig:story} \end{figure} One promising method in unsupervised anomaly detection is using deep neural networks to obtain the features of normal images and model the distribution with some statistical methods, then detect the abnormal samples that have different distributions~\cite{bergman2020classification,rippel2021modeling,yi2020patch,cohen2020sub,defard2020padim}. Following this methodology, there are two main components: the feature extraction module and the distribution estimation module. To the \textit{distribution estimation module}, previous approaches used the non-parametric method to model the distribution of features for normal images. For example, they estimated the multidimensional Gaussian distribution~\cite{li2021cutpaste,defard2020padim} by calculating the mean and variance for features, or used a clustering algorithm to estimate these normal features by normal clustering~\cite{reiss2021panda,roth2021towards}. Recently, some works~\cite{rudolph2021same,gudovskiy2021cflow} began to use normalizing flow~\cite{kingma2018glow} to estimate distribution. Through a trainable process that maximizes the log-likelihood of normal image features, they embed normal image features into standard normal distribution and use the probability to identify and locate anomalies. However, original one-dimensional normalizing flow model need to flatten the two-dimensional input feature into a one-dimensional vector to estimate the distribution, which destroys the inherent spatial positional relationship of the two-dimensional image and limits the ability of flow model. In addition, these methods need to extract the features for a large number of patches in images through the sliding window method, and detect anomalies for each patch, so as to obtain anomaly location results, which leads to high complexity in inference and limits the practical value of these methods. To address above problems, we propose the FastFlow which extend the original normalizing flow to two-dimensional space. We use fully convolutional network as the subnet in our flow model and it can maintain the relative position of the space to improve the performance of anomaly detection. At the same time, it supports the end-to-end inference of the whole image and directly outputs the anomaly detection and location results at once to improve the inference efficiency. To the \textit{feature extraction module} in anomaly detection, besides using CNN backbone network such as ResNet~\cite{he2016deep} to obtain discriminant features, most of the existing work~\cite{defard2020padim,reiss2021panda,rudolph2021same,gudovskiy2021cflow} focuses on how to reasonably use multi-scale features to identify anomalies at different scales and semantic levels, and achieve pixel-level anomaly localization through sliding window method. The importance of the correlation between global information and local anomalies~\cite{yan2021learning,wang2021glancing} can not be fully utilized, and the sliding window method needs to test a large number of image patches with high computational complexity. To address the problems, we use FastFlow to obtain learnable modeling of global and local feature distributions through an end-to-end testing phase, instead of designing complicated multi-scale strategy and using sliding window method. We conducted experiments on two types of backbone networks: vision transformers and CNN. Compared with CNN, vision transformers can provide a global receptive field and make better use of global and local information while maintaining semantic information in different depths. Therefore, we only use the feature of one certain layer in vision transform. Replacing CNN with vision transformer seems trivial, but we found that performing this simple replacement in other methods actually degrade the performance, but our 2D flow achieve competitive results when using CNN. Our FastFlow has stronger global and local modeling capabilities, so it can better play the effectiveness of the transformer. As shown in Figure~\ref{fig:story}, in our approach, we first extract visual features by the feature extractor and then input them into the FastFlow to estimate the probability density. In training stage, our FastFlow is trained with normal images to transform the original distribution to a standard normal distribution in a 2D manner. In inference, we use the probability value of each location on the two-dimensional feature as the anomaly score. To summarize, the main contributions of this paper are: \begin{itemize} \item We propose a 2D normalizing flow denoted as FastFlow for anomaly detection and localization with fully convolutional networks and two-dimensional loss function to effectively model global and local distribution. \item We design a lightweight network structure for FastFlow with the alternate stacking of large and small convolution kernels for all steps. It adopts an end-to-end inference phase and has high efficiency. \item The proposed FastFlow model can be used as a plug-in model with various different feature extractors. The experimental results in MVTec anomaly detection dataset~\cite{bergmann2019mvtec} show that our method outperforms the previous state-of-the-art anomaly detection methods in both accuracy and reasoning efficiency. \end{itemize} \section{Related Work} \subsection{Anomaly Detection Methods} Existing anomaly detection methods can be summarized as reconstruction-based and representation-based methods. Reconstruction-based methods~\cite{bergmann2019mvtec,gong2019memorizing,perera2019ocgan} typically utilize generative models like auto-encoders or generative adversarial networks to encode and reconstruct the normal data. These methods hold the insights that the anomalies can not be reconstructed since they do not exist at the training samples. Representation-based methods extract discriminative features for normal images~\cite{ruff2018deep,bergman2020classification,rippel2021modeling,rudolph2021same} or normal image patches~\cite{yi2020patch,cohen2020sub,reiss2021panda,gudovskiy2021cflow} with deep convolutional neural network, and establish distribution of these normal features. Then these methods obtain the anomaly score by calculating the distance between the feature of a test image and the distribution of normal features. The distribution is typically established by modeling the Gaussian distribution with mean and variance of normal features~\cite{defard2020padim,li2021cutpaste}, or the kNN for the entire normal image embedding~\cite{reiss2021panda,roth2021towards}. We follow the methodology in representation-based method which extract the visual feature from vision transformer or ResNet and establish the distribution through FastFlow model. \begin{figure*}[t] \centering \includegraphics[width=0.99\linewidth]{ figure2.pdf} \caption{(a) the whole pipeline for unsupervised anomaly detection and localization in our method, which consists of a feature extractor and our FastFlow model. We can use an arbitrary network as the feature extractor such as CNN or vision transformer. FastFlow is alternatly stacked by the ``$3\times3$" and ``$1\times1$" flow. (b) one flow step for our FastFlow, the ``Conv 2d" can be $3\times3$ or $1\times1$ convolution layer for $3\times3$ or $1\times1$ flow, respectively.} \label{fig:pipeline} \end{figure*} \subsection{Feature extractors for Anomaly Detection} With the development of deep learning, recent unsupervised anomaly detection methods use deep neural networks as feature extractors, and produce more promising anomaly results. Most of them~\cite{cohen2020sub, defard2020padim,roth2021towards} use ResNet~\cite{he2016deep} to extract distinguish visual features. Some work has also begun to introduce ViT~\cite{dosovitskiy2020image} into unsupervised anomaly detection fields, such as VT-ADL~\cite{mishra2021vt} uses vision transformer as backbone in a generated-based way. ViT has a global receptive field and can learn the relationship between global and local better. DeiT~\cite{touvron2021training} and CaiT~\cite{touvron2021going} are two typical models for ViT. DeiT introduces a teacher-student strategy specific to transformers, which makes image transformers learn more efficiently and got a new state-of-the-art performance. CaiT proposes a simple yet effective architecture designed in the spirit of encoder/decoder architecture and demonstrates that transformer models offer a competitive alternative to the best convolutional neural networks. In this paper, we use various networks belonging to CNN and ViT to prove the universality of our method. \subsection{Normalizing Flow} Normalizing Flows (NF)~\cite{rezende2015variational} are used to learn transformations between data distributions with special property that their transform process is bijective and the flow model can be used in both directions. Real-NVP~\cite{dinh2016density} and Glow~\cite{kingma2018glow} are two typical methods for NF, in which both forward and reverse processes can be processed quickly. NF is generally used to generate data from variables sampled in a specific probability distribution, such as images or audios. Recently, some work~\cite{rudolph2021same,gudovskiy2021cflow} began to use it for unsupervised anomaly detection and localization. DifferNet~\cite{rudolph2021same} achieved good image level anomaly detection performance by using NF to estimate the precise likelihood of test images. Unfortunately, this work failed to obtain the exact anomaly localization results since they flattened the outputs of feature extractor. CFLOW-AD~\cite{gudovskiy2021cflow} proposes to use hard code position embedding to leverage the distribution learned by NF, which probably underperforms at more complicated datasets. \section{Methodology} In this section, we introduce the pipeline of our method and the architecture of the FastFlow, as shown in Figure~\ref{fig:pipeline}. We first set up the problem definition of unsupervised anomaly detection, and introduce the basic methodology that uses a learnable probability density estimation model in the representation-based method. Then we describe the details of feature extractor and FastFlow models, respectively. \subsection{Problem Definition and Basic Methodology} Unsupervised anomaly detection is also denoted as one-class classification or out-of-distribution detection which requires the model to determines whether the test image is normal or abnormal. Anomaly localization requires a more fine-grained result that gives the anomalies label for each pixel. During the training stage, only normal images were observed, but the normal images and abnormal images simultaneously appear in inference. One of the mainstream methods is representation-based method which extracts discriminative feature vectors from normal images or normal image patches to construct the distribution and calculate anomaly score by the distance between the embedding of a test image and the distribution. The distribution is typically characterized by the center of an n-sphere for the normal image, the Gaussian distribution of normal images, or the normal embedding cluster stored in the memory bank obtained from KNN. After extract the features of the training dataset $D = \{x_1, x_2, \cdots, x_N\}$ where $x_i, i = 1, 2, \cdots, N$ are samples from the distribution $p_{X}(x)$, a representation-based anomaly detection model $\mathcal{P} = \{P_{\theta}:\theta \in \Theta\}$ aims to learn the parameter $\theta$ in the parameter space $\Theta$ to map all $x_{i}$ from the raw distribution $p_{X}(x)$ into the same distribution $p_{Z}(z)$, with anomalous pixels or instances mapped out of the distribution. In our method, we follow this methodology and propose FastFlow $P_{\theta}$ to project the high-dimensional visual features of normal images extracted from typical backbone networks into the standard normal distribution. \subsection{Feature Extractor} In the whole pipeline of our method, we first extract the representative feature from the input image through ResNet or vision transformers. As mentioned in the Sec~\ref{section:intro}, one of significant challenges in the anomaly detection task is the global relation grasped to distinguish those abnormal regions from other local parts. Therefore, when using vision transformer (ViT)~\cite{dosovitskiy2020image} as the feature extractor, we only use the feature of one certain layer because ViT has stronger ability to capture the relationship between local patches and the global feature. For ResNet, we directly use the features of the last layer in the first three blocks, and put these features into three corresponding FastFlow model. \subsection{2D Flow Model} As shown in Figure~\ref{fig:pipeline}, our 2D flow $f: X \rightarrow Z$ is used to project the image features $x \in p_{X}(x)$ into the hidden variable $z \in p_{Z}(z)$ with a bijective invertible mapping. For this bijection function, the change of the variable formula defines the model distribution on $X$ by: \begin{equation} \begin{aligned} {p}_{X}(x) ={p}_{Z}(z) \left\vert \mathbf{det}(\frac{\partial z}{\partial x})\right\vert \end{aligned} \end{equation} We can estimate the log likelihoods for image features from $p_{Z}(z)$ by: \begin{equation} \begin{aligned} \log {p}_{X}(x) &= \log p_{Z}(z) + \log \left\vert \mathbf{det}(\frac{\partial z}{\partial x}) \right\vert \\ & = \log p_{Z}(f_{\theta}(x)) + \log \left\vert \mathbf{det}(\frac{\partial f_{\theta}(x)}{\partial x}) \right\vert , \end{aligned} \end{equation} where $z \sim \mathcal{N}(o, I)$ and the $\mathbf{\frac{\partial f_{\theta}(x)}{\partial x}}$ is the Jacobian of a bijective invertible flow model that $z = f_{\theta}(x)$ and $x = f^{-1}_{\theta}(z)$, $\theta$ is parameters of the 2D flow model. In inference, the features of anomalous images should be out of distribution and hence have lower likelihoods than normal images and the likelihood can be used as the anomaly score. Specifically, we sum the two-dimensional probabilities of each channel to get the final probability map and upsample it to the input image resolution using bilinear interpolation. In actual implementation, our flow model $f_{2d}$ is constructed by stacking multiple invertible transformations blocks $f_{i}$ in a sequence that: $$ X \xrightarrow{f_{1}} H_{1} \xrightarrow{f_{2}} H_{2} \xrightarrow{f_{3}} \cdots \xrightarrow{f_{K}} Z, $$ and $$ X \xleftarrow{f^{-1}_{1}} H_{1} \xleftarrow{f^{-1}_{2}} H_{2} \xleftarrow{f^{-1}_{3}} \cdots \xleftarrow{f^{-1}_{K}} Z, $$ where the 2D flow model is $f_{2d}=f_{1}\circ f_{2}\circ f_{3}\circ \cdots \circ f_{K}$ with $K$ transformation blocks. Each transformation block $f_{i}$ consists of multiple steps. Following~\cite{dinh2014nice}, we employ affine coupling layers in each block, and each step is formulated as follow: \begin{equation} \begin{aligned} y_{a}, y_{b} &= \text{split}(y) \\ y'_{a} &= y_{a} \\ y'_{b} &= s(y_{a}) \odot y_{b} + b(y_{a}) \\ y' &= \text{concat}(y'_{a}, y'_{b}), \end{aligned} \end{equation} where $s(y_a)$ and $b(y_a)$ are outputs of two neural networks. The split($\cdot$) and concat($\cdot$) functions perform splitting and concatenation operations along the channel dimension. The two subnets s($\cdot$) and b($\cdot$) are usually implemented as fully connected networks in original normalizing flow model and need to flatten and squeeze the input visual features from 2D to 1D which destroy the spatial position relationship in the feature map. To convert the original normalizing flow to 2D manner, we adopt two-dimensional convolution layer in the default subnet to reserve spatial information in the flow model and adjust the loss function accordingly. In particular, we adopt a fully convolutional network in which 3$\times$3 convolution and 1$\times$1 convolution appear alternately, which reserves spatial information in the flow model. \begin{table*}[tbp] \centering \begin{tabular}{c|ccccc} \hline Model & FPS & A.d. Time (ms) & A.d. Params (M) & Image-level AUC & Pixel-level AUC \\ \hline CaiT-M48-distilled & & & & \\ + Patch Core & 2.39 & 107 & 0 & 97.9 & 96.5 \\ + CFlow & 2.76 & 42 & 10.5 & 97.7& 96.2\\ + FastFlow & \textbf{3.08} & \textbf{9} & 14.8 & \textbf{99.4} & \textbf{98.5}\\ \hline DeiT-base-distilled & & & & \\ + Patch Core & 15.45 & 39 & 0 & 96.5 & 97.9\\ + CFlow & 16.91 & 34 & 10.5 & 95.6 & 97.9\\ + FastFlow & \textbf{30.14} & \textbf{8} & 14.8 & \textbf{98.7} & \textbf{98.1}\\ \hline ResNet18 & & & & & \\ + SPADE & 3.92 & 250 & 0 & - & -\\ + CFlow & 20.3& 44 & 5.5 & 96.8 & \textbf{98.1} \\ + FastFlow & \textbf{30.8} & \textbf{27} & 4.9 & \textbf{97.9} & 97.2 \\ \hline Wide-ResNet50-2 & & & & \\ + SPADE & 0.67 & 1481& 0 & 96.2 & 96.5 \\ + Patch Core & 5.88 & 159 & 0 & 99.1 & 98.1 \\ + CFlow & 14.9 & 56 & 81.6 & 98.3 & \textbf{98.6} \\ + FastFlow & \textbf{21.8} & \textbf{34} & 41.3 & \textbf{99.3} & 98.1\\ \hline \end{tabular} \caption{Complexity comparison in terms of inference speed (FPS), additional inference time (millisecond) and number of additional parameters (M) for various backbones. A.d. Time means the additional inference time and A.d. Parmas is the number of additional parameters compared with backbone network.} \label{table:complexity} \end{table*} \section{Experiments} \subsection{Datasets and Metrics} We evaluate the proposed method on three datasets: MVTec AD~\cite{bergmann2019mvtec}, BTAD~\cite{mishra2021vt} and CIFAR-10~\cite{krizhevsky2009learning}. MVTec AD and BTAD are both industrial anomaly detection datasets with pixel-level annotations, which are used for anomaly detection and localization. CIFAR-10 is built for image classification and we use it to do anomaly detection. Following the previous works, we choose one of the categories as normal, and the rest as abnormal. The anomalies in these industrial datasets are finer than those in CIFAR-10, and the anomalies in CIFAR-10 are more related to the semantic high-level information. For example, the anomalies in MVTec AD are defined as small areas, while the anomalies in CIFAR-10 dataset are defined as different object categories. Under the unsupervised setting, we train our model for each category with its respective normal images and evaluate it in test images that contain both normal and abnormal images. The performance of the proposed method and all comparable methods is measured by the area under the receiver operating characteristic curve (AUROC) at image or pixel level. For the detection task, evaluated models are required to output single score (anomaly score) for each input test image. In the localization task, methods need to output anomaly scores for every pixel. \subsection{Complexity Analysis} We make a complexity analysis of FastFlow and other methods from aspects of inference speed, additional inference time and additional model parameters, ``additional" refers to not considering the backbone itself. The hardware configuration of the machine used for testing is Intel(R) Xeon(R) CPU E5-2680 [email protected] and NVIDIA GeForce GTX 1080Ti. SPADE and Patch Core perform KNN clustering between each test feature of each image patch and the gallery features of normal image patches, and they do not need to introduce parameters other than backbone. CFlow avoids the time-consuming k-nearest-neighbor-search process, but it still needs to perform testing phase in the form of a slice window. Our FastFlow adopts an end-to-end inference phase which has high efficiency of inference. The analysis results are shown in Table~\ref{table:complexity}, we can observe that our method is up to $10\times$ faster than other methods. Compared with CFlow which also uses flow model, our method achieves $1.5\times$ speedup and $2\times$ parameter reduction. When using vision transformers (deit and cait) as the feature extractor, our FastFlow can achieve 99.4 image-level AUC for anomaly detection which is superior to CFlow and Patch Core. From the perspective of additional inference time, our method achieves up to $4\times$ reduction compared to Cflow and $10\times$ reduction compared to Patch Core. Our FastFlow can still have a competitive performance when using ResNet model as feature extractor. \begin{table*}[tbp] \begin{center} \resizebox{\linewidth}{!}{ \begin{tabular}{c|c|c|c|c|c|c|c|c} \hline Method & PatchSVDD & SPADE* & DifferNet & PaDiM & Cut Paste & PatchCore & CFlow & FastFlow \\ \hline carpet & (92.9,92.6) & (98.6,97.5) & (84.0,-) & (-,99.1) & (\textbf{100.0},98.3) & (98.7,98.9) & (\textbf{100.0},99.3) & (\textbf{100.0},\textbf{99.4}) \\ grid & (94.6,96.2) & (99.0,93.7) & (97.1,-) & (-,97.3) & (96.2,97.5) & (98.2,98.7) & (97.6,\textbf{99.0}) & (\textbf{99.7},98.3) \\ leather & (90.9,97.4) & (99.5,97.6) & (99.4,-) & (-,99.2) & (95.4,99.5) & (\textbf{100.0},99.3) & (97.7,\textbf{99.7}) & (\textbf{100.0},99.5) \\ tile & (97.8,91.4) & (89.8,87.4) & (92.9,-) & (-,94.1) & (\textbf{100.0},90.5) & (98.7,95.6) & (98.7,\textbf{98.0}) & (\textbf{100.0},96.3) \\ wood & (96.5,90.8) & (95.8,88.5) & (99.8,-) & (-,94.9) & (99.1,95.5) & (99.2,95.0) & (99.6,96.7) & (\textbf{100.0},\textbf{97.0}) \\ bottle & (98.6,98.1) & (98.1,98.4) & (99.0,-) & (-,98.3) & (99.9,97.6) & (\textbf{100.0},98.6) & (\textbf{100.0},\textbf{99.0}) & (\textbf{100.0},97.7) \\ cable & (90.3,96.8) & (93.2,97.2) & (86.9,-) & (-,96.7) & (\textbf{100.0},90.0) & (99.5,\textbf{98.4}) & (\textbf{100.0},97.6) & (\textbf{100.0},\textbf{98.4}) \\ capsule & (76.7 ,95.8) & (98.6,99.0) & (88.8,-) & (- ,98.5) & (98.6 ,97.4) & (98.1,98.8) & (99.3 ,99.0) & (\textbf{100.0},\textbf{99.1}) \\ hazelnut & (92.0 ,97.5) & (98.9,99.1) & (99.1,-) & (- ,98.2) & (93.3 ,97.3) & (\textbf{100.0},98.7) & (96.8 ,98.9) & (\textbf{100.0},\textbf{99.1}) \\ meta nut & (94.0,98.0) & (96.9,98.1) & (95.1,-) & (-,97.2) & (86.6,93.1) & (\textbf{100.0},98.4) & (91.9,\textbf{98.6}) & (\textbf{100.0},98.5) \\ pill & (86.1,95.1) & (96.5,96.5) & (95.9,-) & (-,95.7) & (\textbf{99.8},95.7) & (96.6,97.1) & (99.9,99.0) & (99.4,\textbf{99.2}) \\ screw & (81.3,95.7) & (99.5,98.9) & (99.3,-) & (-,98.5) & (90.7,96.7) & (98.1,\textbf{99.4}) & (\textbf{99.7},98.9) & (97.8,\textbf{99.4}) \\ toothbrush & (\textbf{100.0},98.1) & (98.9,97.9) & (96.1,-) & (-,98.8) & (97.5 ,98.1) & (\textbf{100.0},98.7) & (95.2,\textbf{99.0}) & (94.4 ,98.9) \\ transistor & (91.5,97.0) & (81.0,94.1) & (96.3,-) & (-,97.5) & (99.8,93.0) & (\textbf{100.0},96.3) & (99.1 ,\textbf{98.0}) & (99.8,97.3) \\ zipper & (97.9,95.1) & (98.8,96.5) & (98.6,-) & (-,98.5) & (\textbf{99.9},\textbf{99.3}) & (98.8,98.8) & (98.5 ,99.1) & (99.5,98.7) \\ \hline AUCROC & (92.1,95.7) & (96.2,96.5) & (94.9,-) & (97.9,97.5) & (97.1,96.0) & (99.1,98.1) & (98.3,\textbf{98.6}) & (\textbf{99.4},98.5) \\ \hline \end{tabular} } \caption{Anomaly detection and localization performance on MVTec AD dataset with the format (image-level AUC, pixel-level AUC). We report the detailed results for all categories.} \label{tab:image-level} \end{center} \end{table*} \subsection{Quantitative Results} \subsubsection{MVTec AD} There are 15 industrial products in MVTec AD dataset~\cite{bergmann2019mvtec}, with a total of 5,354 images, among which 10 are objects and the remaining 5 are textures. The training set is only composed of normal images, while the test set is a mixture of normal images and abnormal images. We compare our proposed method with the state-of-the-art anomaly detection works, including SPADE*~\cite{reiss2021panda}, PatchSVDD~\cite{yi2020patch}, DifferNet~\cite{rudolph2021same}, Mah.AD~\cite{rippel2021modeling}, PaDiM~\cite{defard2020padim}, Cut Paste~\cite{li2021cutpaste}, Patch Core~\cite{roth2021towards}, CFlow~\cite{gudovskiy2021cflow} under the metrics of image-level AUC and pixel-level AUC. The detailed comparison results of all categories are shown in Table~\ref{tab:image-level}. We can observe that FastFlow achieves \textbf{99.4} AUC on image-level and \textbf{98.5} AUC on pixel-level, suppresses all other methods in anomaly detection task. \begin{table}[tbp] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{c|c|c|c|c} Categories & AE MSE & AE MSE+SSIM & VT-ADL & FastFlow \\ \hline 0 & 0.49 & 0.53 & 0.99 & 0.95 \\ \hline 1 & 0.92 & 0.96 & 0.94 & 0.96 \\ \hline 2 & 0.95 & 0.89 & 0.77 & 0.99 \\ \hline Mean & 0.78 & 0.79 & 0.90 & \textbf{0.97}\\ \hline \end{tabular}} \caption{Anomaly localization results on BTAD datasts. We compare our method with convolutional auto encoders trained with MSE-loss and MSE+SSIM loss, and VT-ADL.} \label{table:btad} \end{table} \subsubsection{BTAD} BeanTech Anomaly Detection dataset~\cite{mishra2021vt} has 3 categories industrial products with 2540 images. The training set consists only of normal images, while the test set is a mixture of normal images and abnormal images. Under the measure of pixel-level AUC, we compare the results of our FastFlow with the results of three methods reported in VT-ADL~\cite{mishra2021vt}: auto encoder with mean square error, automatic encoder with SSIM loss and VT-ADL. The comparison results are shown in Table~\ref{table:btad}. We can observe that our FastFlow achieves 97.0 pixel-wise AUC and suppresses other methods as high as 7\% AUC. \begin{table}[tbp] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{c|c|c|c|c|c} \hline Method & OC-SVM & KDE & $\textit{l}_{2}$-AE & VAE & Pixel CNN \\ \hline AUC & 58.6 & 61.0 & 53.6 & 58.3 & 55.1 \\ \hline Method & LSA & AnoGAN & DSVDD & OCGAN & FastFlow \\ \hline AUC & 64.1 & 61.8 & 64.8 & 65.6 & \textbf{66.7} \\ \hline \end{tabular}} \caption{Anomaly detection results on CIFAR-10 datast.} \label{tab:cifar10} \end{table} \subsubsection{CIFAR-10 dataset} CIFAR-10 has 10 categories with 60000 natural images. Under the setting of anomaly detection, one category is regarded as anomaly and other categories are used as normal data. And we need to train the corresponding model for each class respectively. The AUC scores of our method and other methods are reported in Table~\ref{tab:cifar10}. Methods for comparison includes OC-SVM~\cite{scholkopf1999support}, KDE~\cite{bishop2006pattern}, $\textit{l}_{2}$-AE~\cite{hadsell2006dimensionality}, VAE~\cite{an2015variational}, Pixel CNN~\cite{oord2016conditional}, LSA~\cite{abati2019latent}, AnoGAN~\cite{schlegl2017unsupervised}, DSVDD~\cite{ruff2018deep} and OCGAN~\cite{perera2019ocgan}. Our method outperforms these comparison methods. The results in three different datasets show that our method can adapt to different anomaly detection settings. \subsection{Ablation Study} To investigate the effectiveness of the proposed FastFlow structure, we design ablation experiments about the convolution kernel selection in subnet. We compare alternately using $3\times3$ and $1\times1$ convolution kernel and only using $3\times3$ kernel under the AUC and inference speed for the subnet with various backbone networks. The results are shown in Table~\ref{table:ablation}. For the backbone network with large model capacities such as CaiT and Wide-ResNet50-2, alternate using $3\times3$ and $1\times1$ convolution layer can obtain higher performance while reducing the amount of parameters. For the backbone network with small model capacities such as DeiT and ResNet18, only using $3\times3$ convolution layer has higher performance. To achieve the balance of accuracy and inference speed, we use alternate convolution kernels of $3\times3$, $1\times1$ with DeiT, CaiT and Wide-ResNet50-2, and only use $3\times3$ convolution layer with ResNet18. \begin{figure*}[t] \centering \includegraphics[width=0.98\linewidth]{figure4.pdf} \caption{Anomaly localization results of MVTec AD datasets. From top to bottom, input images with ground-truth localization area labeled in red and anomaly localization heatmaps.} \label{fig:results_vis} \end{figure*} \begin{figure}[t] \centering \includegraphics[width=0.975\columnwidth]{ figure3.pdf} \caption{The bidirectional invertible process for FastFlow. ``FE" is the feature extractor, ``FF" is our FastFlow model, ``$\text{FF}^{-1}$" is the reverse for FastFlow. The red and yellow arrows point to the original anomaly and the new anomaly introduced after the noise disturbance respectively.} \label{fig:vis_flow} \end{figure} \subsection{Feature Visualization and Generation.} Our FastFlow model is a bidirectional invertible probability distribution transformer. In the forward process, it takes the feature map from the backbone network as input and transforms its original distribution into a standard normal distribution in two-dimensional space. In the reverse process, the inverse of FastFlow can generate the visual feature from a specific probability sampling variable. To better understand this ability in view of our FastFlow, we visualize the forward (from visual features to probability map) and reverse (from probability map to visual features) processes. As shown in Figure~\ref{fig:vis_flow}, we extract the features of an input image belonging to the leather class and the abnormal area is indicated by the red arrow. We forward it through the FastFlow model to obtain the probability map. Our FastFlow successfully transformed the original distribution into the standard normal distribution. Then, we add noise interference to a certain spatial area which is indicated by the yellow arrow in this probability map, and generate a leather feature tensor from the pollution probability map by using the inverse Fastflow model. In which we visualized the feature map of one channel in this feature tensor, and we can observe that new anomaly appeared in the corresponding pollution position. \begin{table}[tbp] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{c|ccc} Method & A.d. Params (M) & Image-level AUC & Pixel-level AUC \\ \hline DeiT & \\ 3-1 & 14.8 & 98.7 & 98.1\\ 3-3 & 26.6 & 98.7 & \textbf{98.3} \\ \hline CaiT & \\ 3-1 & 14.8 & \textbf{99.4} & 98.5 \\ 3-3 & 26.6 & 98.9 & 98.5 \\ \hline ResNet18 & \\ 3-1 & 2.7 & 97.3 & 96.8 \\ 3-3 & 4.9 & \textbf{97.9} & \textbf{97.2} \\ \hline Wide-ResNet50-2 & \\ 3-1 & 41.3 & \textbf{99.3} & \textbf{98.1} \\ 3-3 & 74.4 & 98.2 & 97.6 \\ \hline \end{tabular}} \caption{Results of ablation experiments with various backbone networks. 3-1 means alternately using $3\times 3$ and $1\times 1$ convolution layers and 3-3 is only using $3\times 3$ convolution layer in the subnet for FastFlow. A.d. Params is the number of additional model parameters compared with backbone network.} \label{table:ablation} \end{table} \subsection{Qualitative Results} We visualize some results of anomaly detection and localization in Figure~\ref{fig:results_vis} with the MVTec AD dataset. The top row shows test images with ground truth masks with and without anomalies, and the anomaly localization score heatmap is shown in the bottom row. There are both normal and abnormal images and our FastFlow gives accurate anomaly localization results. \begin{table}[t] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{c|c|c|c} \hline Backbone & Input Size & Block Index & Feature Size\\ \hline CaiT-M48-distilled & 448 & 40 & 28 \\ \hline DeiT-base-distilled & 384 & 7 & 24 \\ \hline Res18 & 256 & [1,2,3] & [64, 32, 16] \\ \hline WR50 & 256 & [1,2,3] & [64, 32, 16] \\ \hline \end{tabular}} \caption{We use four different feature extractors in all experiments. The input picture size and feature size are set according to the backbone network and the block index indicates the block from which the feature is obtained..} \label{table:implementation} \end{table} \subsection{Implementation Details} We provide the details of the structure of feature extractor, the selection of feature layer and the size of input image in Table~\ref{table:implementation}. For vision transformer, our method only uses feature maps of a specific layer, and does not need to design complicated multi-scale features manually. For ResNet18 and Wide-ResNet50-2, we directly use the features of the last layer in the first three blocks, put these features into the 2D flow model to obtain their respective anomaly detection and localization results, and finally take the average value as the final result. All these backbone are initialized with the ImageNet pre-trained weights and their parameters are frozen in the following training process. For FastFlow, we use 20-step flows in CaiT and DeiT and 8-step flows for ResNet18 and Wide-ResNet50-2. We train our model using Adam optimizer with the learning rate of 1e-3 and weight decay of 1e-5. We use a 500 epoch training schedule, and the batch size is 32. \section{Conclusion} In this paper, we propose a novel approach named FastFlow for unsupervised anomaly detection and localization. Our key observation is that anomaly detection and localization requires comprehensive consideration of global and local information with a learnable distribution modeling method, and efficient inference process, which are ignored in the existing approaches. To this end, we present a 2D flow model denoted as FastFlow which has a lightweight structure and is used to project the feature distribution of normal images to the standard normal distribution in training, and use the probabilities as the anomaly score in testing. FastFlow can be used in typical feature extraction networks such as ResNet and ViT in the form of plug-ins. Extensive experimental results on MVTec AD dataset show FastFlow superiority over the state-of-the art methods in terms of accuracy and reasoning efficiency. \clearpage \twocolumn[ \begin{@twocolumnfalse} \section*{\centering{Supplementary Material for \\ \emph{FastFlow: Unsupervised Anomaly Detection and Localization via 2D Normalizing Flows\\[25pt]}}} \end{@twocolumnfalse} ] \section{More Ablation Studies} \subsection{Channels of Hidden Layers in Flow Model} In the original flow model which has been used in DifferNet~\cite{rudolph2021same} and CFLOW~\cite{gudovskiy2021cflow}, the number of channels of hidden layers in all subnet is set to $2\times$ as much the input and output layer's channel. This kind of design improves the results by increasing the complexity of the model, but it reduces the efficiency of inference. In our FastFlow, we found that using $0.16\times$ number of channels in CaiT and $1\times$ number of channels in Wide-ResNet50-2 can achieve a balance between performance and model parameters. In addition, when we use $0.25\times$ number of channels of Wide-ResNet50-2, we can further reduce the model parameters while still maintaining high accuracy. The results are shown in Table~\ref{tab:alb}. \begin{table}[] \centering \resizebox{\linewidth}{!}{ \begin{tabular}{c|ccc} \hline Channel Ratio & Parameters (M) & Image-level AUC & Pixel-level AUC \\ \hline \hline CaiT \\ \hline $0.16\times$ & 14.8 & 99.4 & 98.5 \\ $0.33\times$ & 29.6 & 98.9 & 98.4 \\ \hline Wide-ResNet50-2 \\ \hline $0.25\times$ & 10.9 & 98.9 & 98.0 \\ $0.5\times$ & 20.7 & 99.1 & 98.1 \\ $1.0\times$ & 41.3 & 99.3 & 98.1 \\ $2.0\times$ & 82.6 & 99.4 & 98.1 \\ \hline \hline \end{tabular}} \caption{Ablation study results about the hidden layer channels for CNN and vision transformer in MVTec AD dataset. Channel Ratio means the ratio of the number of channels in the hidden layer to the number of channels in the input and output layers for subnet in our FastFlow.} \label{tab:alb} \end{table} \subsection{Training Data Augmentation} In order to learn a more robust FastFlow model, we apply various data augmentation methods to the MVTec AD dataset during the training phase. We use random horizontal flip, vertical flip and rotation, with probabilities of 0.5, 0.3 and 0.7, respectively. It should be noted that some categories are not suitable for violent data augmentation. For example, the transistor can not be flipped upside down and rotated. The results are shown in Table~\ref{tab:data_aug}. \begin{table}[t] \centering \begin{tabular}{c|cc} \hline Data Augmentation & Image-level AUC & Pixel-level AUC \\ \hline CaiT \\ w/o & 99.3 & 98.4 \\ w & 99.4 & 98.5 \\ \hline Wide-ResNet50-2 \\ w/o & 98.9 & 98.2\\ w & 99.3 & 98.1 \\ \hline \end{tabular} \caption{The effect of data augmentation on the anomaly detection and localization performance.} \label{tab:data_aug} \end{table} \section{Bad Cases and Ambiguity Label} We visualize bad cases for our method on MVTec AD dataset in Figure~\ref{fig:fig1} to Figure~\ref{fig:fig3} which are summarized into three categories. We show the missing detection cases in Figure~\ref{fig:fig1}, false detection cases in Figure~\ref{fig:fig2} and label ambiguity cases in Figure~\ref{fig:fig3}. In Figure~\ref{fig:fig1}, our method missed a few small and unobvious anomalies. In Figure~\ref{fig:fig2}, our method had false detection results in some background areas, such as areas with hair and dirt in the background. In Figure~\ref{fig:fig3}, our method found some areas belong to abnormal but not be labeled, such as the ``scratch neck" for screw and the ``fabric interior" for zipper. \section{Non-aligned Disturbed MVTec AD Dataset} Considering that the MVTec AD dataset has the characteristic of sample alignment which is infrequent in practical application, we perform a series of spatial perturbations on the test data to obtain an unaligned MVTec AD dataset. In detail, we apply random zoom in/out with 0.85 ratio, random rotation with $\pm15$ angle, random translation with 0.15 ratio to expand the original test dataset by $4\times$ to the new test dataset. We evaluate our FastFlow (with CaiT) in this new test dataset and we obtain 99.2 image-level AUC and 98.1 pixle-level AUC. There is almost no performance loss compared with the results in original aligned MVTec AD test dataset, which proves the robustness of our method. We also give some visualization results in Figure~\ref{fig:fig4}. We can observe that FastFlow can still have high performance on anomaly detection and location result in this non-aligned disturbed MVTec AD dataset. \begin{figure*}[t] \centering \includegraphics[width=0.9\linewidth]{ figure5.pdf} \caption{Bad cases of the missing detection type. All missed detection results of our method in shown in this figure.} \label{fig:fig1} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=0.9\linewidth]{ figure6.pdf} \caption{Bad cases of false detection type. We give the typical results of our method in this figure.} \label{fig:fig2} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=0.9\linewidth]{ figure7.pdf} \caption{Bad cases caused by label ambiguity. In the first two rows, there are abnormal areas localized by our method while not labeled. In the last row of hazelnut, we show the label ambiguity of the ``print" subclass, in which one hazelnut print is labeled finely, while the other is labeled with a rough area.} \label{fig:fig3} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=0.83\linewidth]{ figure8.pdf} \caption{Anomaly localization results of the non-aligned disturbed MVTec AD datasets.} \label{fig:fig4} \end{figure*}
{'timestamp': '2021-11-17T02:10:17', 'yymm': '2111', 'arxiv_id': '2111.07677', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07677'}
arxiv
\section{Introduction} Over the last decade, tissue engineering has been revolutionised through the use of 3D printing technologies that produce 3D bioscaffolds upon which $\textit{in vitro}$ tissues can be grown in biologically realistic geometries~\cite{Ambrosi2019,Dzobo2018}. \textit{In vitro} tissues grown on 3D scaffolds are more reproducible and more biologically realistic than tissues grown in traditional two--dimensional tissue culture~\cite{Lanaro2021}. The experimental images in Figure \ref{fig:1}(a) show the evolution of thin 3D tissues that are produced by seeding a 3D--printed scaffold with osteoblast precursor cells~\cite{Buenzli2020,Browning2021}. In this experiment, cells are seeded onto the perimeter of 3D--printed square shaped pores, where each pore has sides of approximately $300$ $\mu$m in length. Each subfigure in Figure \ref{fig:1}(a) shows four adjacent pores. As the experiment proceeds, individual cells migrate off the scaffold into the pore, and then combined cell migration and cell proliferation leads to the formation of a sharp-fronted tissue profile that invades into the pore. This process eventually forms a thin tissue that closes or \textit{bridges} the pore after approximately 14 days~\cite{Buenzli2020,Browning2021}. A notable feature of these experiments is the fact that tissue formation involves a well--defined moving front that is very obvious in Figure \ref{fig:1}(a). Closer inspection of these experimental images shows that cells not only migrate and proliferate during the pore bridging process, but cells also produce an extracellular medium that is laid down onto the surface of the pore~\cite{Lanaro2021}. \begin{landscape} \begin{figure}[h!] \centering \includegraphics[width=1\linewidth]{Figure1.pdf} \caption{\textbf{Experimental and simulated osteoblast tissue formation within a square--shaped 3D--printed pore.} (a) Composite fluorescence microscopy images of pore bridging experiments~\cite{Buenzli2020,Browning2021}. Cell nuclei are shown in blue, tissue and cytoskeleton are shown in green. Each subfigure shows four adjacent square pores, each with side length of $\hat{L}=300$ $\mu$m, and images are shown at various times, $\hat{t} = 4, 7, 10$ and $14$ days, as indicated. For clarity, in each subfigure we outline the border of the upper--left pore (red dashed). Experimental images are reproduced from~\cite{Buenzli2020} with permission. (b)--(c) Numerical solution of Equations (\ref{eq:GouvdiffUDimensional2D})--(\ref{eq:GouvdiffSDimensional2D}) on a square domain with side length $\hat{L}=300$ $\mu$m. (b) Evolution of $\hat{u}$. (c) Evolution of $\hat{s}$. Each column of the figure corresponds to $\hat{t} = 4, 7, 10$ and $14$ days, as indicated. Parameter values for the mathematical model are $\hat{D}=300$~$\mu$m$^2$/day, $\hat{\lambda} = 0.6$ /day, $\hat{K}_u = 1$ cells/$\mu$m$^2$, $\hat{K}_s = 1$ mol/$\mu$m$^2$, $\hat{r}_1 = 1$ mol/(cells day), $\hat{r}_2 = 1$ /day. The numerical solution of (\ref{eq:GouvdiffUDimensional2D})--(\ref{eq:GouvdiffSDimensional2D}) is obtained on a $101\times101$ mesh, and temporal integration is performed with uniform time steps of duration $\Delta \hat{t} = 1\times10^{-2}$ day.} \label{fig:1} \end{figure} \end{landscape} Continuum mathematical models of tissue formation have a long history, with many early models based on the classical Fisher--KPP model~\cite{Ablowitz11979,Canosa1973,Fisher1937,Kolmogorov1937}. The Fisher--KPP model describes cell migration using a one dimensional linear diffusion term, and cell proliferation is modelled using a logistic source term. Many different types tissue formation experiments have been successfully modelled using the Fisher--KPP model~\cite{Maini2004,Jin2016,Johston2015,Warne2019} or two-dimensional extensions of the Fisher--KPP model~\cite{Sherratt1990,Simpson2013,Swanson2003}. While these studies show that simple mathematical models based on the Fisher-KPP framework successfully capture certain features of tissue formation, there are several well--known limitations of the Fisher--KPP model that can be addressed by considering extensions of that model~\cite{Murray2002}. One such criticism is that the linear diffusion term in the Fisher--KPP model leads to smooth density profiles that do not represent well--defined fronts, such as those we see in Figure \ref{fig:1}(a). One way to overcome this limitation is to work with the Porous--Fisher model where the linear diffusion term is generalised to a degenerate nonlinear diffusion term with a power law diffusivity~\cite{Fadai2020,Sanchez1994,Sengers2007,Witelski1994,Witelski1995}. While the Porous--Fisher model leads to sharp--fronted density profiles, this approach introduces a separate complication of having to justify the choice of the exponent in the power law diffusivity~\cite{Jin2016,McCue2019,Sherratt1990,Simpson2011,Warne2019}. A further weakness of both the Fisher--KPP and Porous--Fisher models is that they deal with a single species, such as a density of cells, and do not explicitly describe how the population of cells invades into surrounding cells, or interacts with the surrounding environment. This second limitation has been addressed by introducing more complicated mathematical models, such as the celebrated Gatenby--Gawlinski model of tumour invasion~\cite{Gatenby1996}, that explicitly describes how a population of tumour cells degrades and invades into a population of surrounding healthy tissue by explicitly modelling both populations and their interactions. Since the Gatenby--Gawlinski framework was proposed in 1996, subsequent studies have since analyzed the relationship between individual--level mechanisms and the resulting population--level continuum descriptions~\cite{Painter2003}, calibrating these mathematical models to match experimental measurements of melanoma invasion~\cite{Browning2019}, as well as analysing travelling wave solutions of these types of multi--species mathematical models~\cite{Colson2021,Elhachem2021,Gallay2001}. In this work we study a continuum mathematical model of cell invasion that is motivated by the experimental images in Figure \ref{fig:1}(a). The mathematical model explicitly describes the evolution of the cell density, $\hat{u}(\hat{\mathbf{x}},\hat{t})$, and the density of substrate produced by the cells, $\hat{s}(\hat{\mathbf{x}},\hat{t})$, giving rise to a coupled system of nonlinear partial differential equations (PDE). We first explore numerical solutions of the mathematical model in two spatial dimensions to mimic the same patterns of tissue development that we see in the experimental images in Figure \ref{fig:1}(a). Within this modelling framework, it is natural for us to ask how the duration of time required for the pore to close is affected by the dynamics of substrate deposition and decay. We address this question by nondimensionalising the mathematical model, and numerically exploring travelling wave solutions in one dimension. Not only does travelling wave analysis of the mathematical model have a direct link to the application in question, we note that travelling wave analyses provide detailed mathematical insight into various models of invasion with applications including tissue engineering~\cite{Landman2007}, directed migration~\cite{Krause2020}, disease progression~\cite{Strobl2020} and various applications in ecology~\cite{Hogan2017,Elhachem2021a}. Our preliminary numerical explorations suggest that, similar to the well--known Porous--Fisher model, the substrate model supports both sharp--fronted and smooth travelling wave solutions. Working in three--dimensional phase space, we show that travelling wave solutions exist for all wave speeds $c \ge c_{\rm{min}}$, where $c_{\rm{min}} > 0$ is some minimum wave speed, and we provide a geometric argument based on a slow manifold reduction to distinguish between sharp--fronted travelling wave solutions that move with the minimum speed $c_{\rm{min}}$, from smooth travelling wave solutions that move faster than the minimum speed, $c > c_{\rm{min}}$. The three--dimensional phase space arguments are supported by some analysis of the time--dependent PDE problem where we show how the long--time travelling wave speed relates to the initial decay rate of the cell density. All phase--space and time--dependent PDE analysis throughout this work are supported by detailed numerical simulations of the full time--dependent PDE model. For completeness we also present various perturbation solutions that give accurate mathematical expressions describing the shape of the travelling waves profiles in various limits. Overall, we show that the substrate invasion model can be viewed as bridge between the relatively simple Porous--Fisher model and more detailed mathematical models of biological invasion. The substrate model supports various types of travelling wave solutions that are reminiscent of travelling wave solutions of the Porous--Fisher model, but the analysis of these travelling wave solutions is quite different, as we shall now explore. \section{Results and Discussion} In this work all dimensional variables and parameters are denoted with a circumflex, and nondimensional quantities are denoted using regular symbols. \subsection{Biological motivation}\label{sec:biologicalmotivation} Following Buenzli et al.~\cite{Buenzli2020}, we consider the following minimal model of cell invasion \begin{align} \label{eq:GouvdiffUDimensional2D} &\dfrac{\partial \hat{u}}{\partial \hat{t}}=\hat{D} \div{\left(\dfrac{\hat{s}}{\hat{K}_s} \grad \hat{u}\right)} +\hat{\lambda} \hat{u}\left(1-\dfrac{\hat{u}}{\hat{K}_u}\right),& \hat{\mathbf{x}} \in \Omega,\\ &\dfrac{\partial \hat{s}}{\partial \hat{t}}= \hat{r}_1 \hat{u} - \hat{r}_2 \hat{s},& \hat{\mathbf{x}} \in \Omega, \label{eq:GouvdiffSDimensional2D} \end{align} where $\hat{u}(\hat{\mathbf{x}},\hat{t}) \ge 0$ is the density of cells, $\hat{s}(\hat{\mathbf{x}},\hat{t}) \ge 0$ is the substrate concentration, $\hat{D}>0$ is the cell diffusivity and $\hat{\lambda}>0$ is the cell proliferation rate. This model assumes that cells produce an adhesive and immobile substrate at rate $\hat{r}_1>0$, and that the substrate decays at a rate $\hat{r}_2 > 0$. We assume that the carrying capacity density of cells is $\hat{K}_u>0$, and that a typical maximum substrate density is $\hat{K}_s>0$. The key feature of this mathematical model is that the diffusive flux of cells is proportional to the substrate density, $\hat{s}$. This assumption couples the cell density to the substrate concentration in a way that the diffusive flux vanishes when $\hat{s}=0$. In this model the evolution of the cell density is affected by the substrate through the cell migration term, without any direct coupling in the cell proliferation term. This assumption is consistent with recent two--dimensional studies that explored how different surface coatings affect combined cell migration and cell proliferation in wound healing assays~\cite{Jin2020}. This work showed that different surface coatings have a dramatic impact on cell migration, whereas cell proliferation is less sensitive. In this modelling framework we make use of the fact that the tissues produced in the experiments in Figure \ref{fig:1}(a) are thin; the horizontal length scale is approximately $300$ $\mu$m whereas the depth of tissue is approximately one cell diameter only, which is around $10-20$ $\mu$m. In this setting it is appropriate and accurate to use a depth--averaged modelling framework where variations in the vertical direction are implicit, rather than being explicitly described~\cite{Simpson2009}. We begin by considering Equations (\ref{eq:GouvdiffUDimensional2D})--(\ref{eq:GouvdiffSDimensional2D}) on a two--dimensional square--shaped domain, $\Omega = \{(\hat{x},\hat{y}):0 \le \hat{x} \le \hat{L}, 0 \le \hat{y} \le \hat{L}\}$ to match the geometry of the experiments in Figure \ref{fig:1}(a). For simplicity we work with Dirichlet boundary conditions by setting $\hat{u}=\hat{K}_u$ and $\hat{s}= \hat{r}_1 \hat{K}_u / \hat{r}_2$ along all boundaries, with spatially uninform initial conditions $\hat{u} = \hat{s} = 0$, at $\hat{t}=0$. A numerical solution of Equation (\ref{eq:GouvdiffUDimensional2D})--(\ref{eq:GouvdiffSDimensional2D}) in Figure \ref{fig:1}(b)--(c) shows the evolution of $\hat{u}$ and $\hat{s}$, respectively. Full details of the numerical methods used to solve Equations (\ref{eq:GouvdiffUDimensional2D})--(\ref{eq:GouvdiffSDimensional2D}) are given in the Supplementary Material. The evolution of $\hat{u}$ in Figure \ref{fig:1}(b) shows that the model predicts the sharp--fronted tissue growth that qualitatively matches the spatial and temporal patterns observed in the experiment. The evolution of $\hat{s}$ in Figure \ref{fig:1}(c) shows that the invading cell density profile is associated with an invading substrate profile. The coupling between the spatial and temporal distribution of the tissue and the underlying substrate is similar to that observed in the experiments~\cite{Lanaro2021}. Given this experimental motivation we will now set about analyzing the mathematical model to provide insight into how the substrate dynamics affect the speed of invasion. \subsection{One-dimensional numerical exploration}\label{sec:1Dexploration} For the purpose of studying travelling wave solutions of the substrate model we re--write Equations (\ref{eq:GouvdiffUDimensional2D})--(\ref{eq:GouvdiffSDimensional2D}) in the one--dimensional Cartesian coordinate system. Introducing the following dimensionless quantities: $u=\hat{u} /\hat{K}_u$, $s=\hat{s} /\hat{K}_s$, $x = \hat{x}\sqrt{\hat{\lambda}/\hat{D}}$, $t = \hat{\lambda} \hat{t}$, $r_1 = \hat{r}_1\hat{K}_u/(\hat{\lambda}\hat{K}_s)$ and $r_2 = \hat{r}_2/\hat{\lambda}$, gives the following non--dimensional model \begin{align} \label{eq:GouvdiffUNonDimensional} &\dfrac{\partial u}{\partial t}= \dfrac{\partial}{\partial x}\left(s \dfrac{\partial u}{\partial x}\right) + u(1-u), &0 < x < \infty\\ &\dfrac{\partial s}{\partial t}= r_1 u - r_2 s, &0 < x < \infty, \label{eq:GouvdiffSNonDimensional} \\ &\dfrac{\partial u(0,t)}{\partial x}=0, \qquad \textrm{and} \quad \ u(x,t) \rightarrow 0, \ x \rightarrow \infty. \label{eq:BCNonDimensional} \end{align} This dimensionless model involves just two free parameters that relate to the rate of substrate production and the rate of substrate decay, $r_1$ and $r_2$, respectively. Note that Equation (\ref{eq:GouvdiffSNonDimensional}) does not involve any spatial derivatives so there is no need to specify any boundary conditions for $s$. In this study we will consider two different types of initial conditions: (i) a biologically--realistic initial condition describing the situation where the initial cell population occupies a particular region, and the cell density vanishes outside of this region~\cite{Maini2004,Simpson2013,Sengers2007}; and, (ii) a mathematically insightful, but less biologically--realistic initial condition where the initial cell density decays exponentially as $x \to \infty$. For the biologically--realistic initial conditions we always consider \begin{align} u(x,0) &= 1 - H(\beta), \label{eq:ICUCompactSupport}\\ s(x,0) &= 0, \label{eq:ICSCompactSupport} \end{align} on $0 < x < \infty$, where $H(x)$ is the usual Heaviside function and $\beta > 0$ is a constant describing the initial length of the domain that is occupied at $t=0$. For the mathematically interesting initial condition we always consider \begin{align} \label{eq:ICUNonCompactSupport} u(x,0) &= \begin{cases} 1, & \ x < \beta, \\ \textrm{exp}[-a(x-\beta)], & \ x > \beta, \end{cases}\\ s(x,0) &= 0, \label{eq:ICSNonCompactSupport} \end{align} on $0 < x < \infty$, where $a > 0$ is the decay rate. For all results, we set $\beta = 10$. We focus on long--time numerical solutions of Equations (\ref{eq:GouvdiffUNonDimensional})-- (\ref{eq:GouvdiffSNonDimensional}) in order to explore travelling wave solutions. Details of the numerical method we use to solve the governing equations are given in the Supplementary Material. Of course, the travelling wave analysis of this model is relevant on the infinite domain, $0 < x < \infty$, but numerically we must always work with a truncated domain $0 < x < X$, where $X$ is chosen to be sufficiently large that the late--time numerical solutions are unaffected by the choices of $X$. All algorithms required to re--create the results in this work are available on \href{https://github.com/ProfMJSimpson/Substrate_Mediated_Invasion}{GitHub}. Before we present and discuss particular travelling wave solutions, it is convenient to state at the outset that we find the substrate invasion model leads to two types of travelling wave solutions, shown schematically in Figure \ref{fig:2}. The travelling wave solution in Figure \ref{fig:2}(a) arises from the biologically--relevant initial conditions (\ref{eq:ICUCompactSupport})--(\ref{eq:ICSCompactSupport}), where we see that there is a well--defined sharp front with $u=s=0$ ahead of the front, and $u \to 1^-$ and $s \to R^-$ well--behind the travelling wave front as $x \to 0^-$. In this case, as we will show, the travelling wave solution corresponds to the minimum wave speed, $c = c_{\rm{min}}$, that depends on the value of $r_1$ and $r_2$. In contrast, the travelling wave solution in Figure \ref{fig:2}(b) arises from the mathematically interesting initial conditions (\ref{eq:ICUNonCompactSupport})--(\ref{eq:ICSNonCompactSupport}). In this second type of travelling wave we have the same behaviour well--behind the wave front as in Figure \ref{fig:2}(a), since $u \to 1^-$ and $s \to R^-$ as $x \to 0^-$. However, in this case we have a smooth travelling wave with $u \to 0^+$ and $s \to 0^+$ as $x \to \infty$. Further, as we will show, these smooth--fronted travelling wave solutions move with a faster travelling wave speed, $c > c_{\rm{min}}$. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{Figure2.pdf} \caption{\textbf{Schematic showing sharp and smooth--fronted travelling wave solutions.} (a) Schematic showing a sharp-fronted travelling wave. (b) Schematic showing a smooth-fronted travelling wave. Arrows show the direction of movement.} \label{fig:2} \end{figure} The fact that the substrate model gives rise to both smooth and sharp--fronted travelling wave solutions is very interesting and worthy of exploration. Throughout this work we will explore parallels between the substrate model and the Porous--Fisher model, and an obvious point of similarity is that both these models support smooth and sharp--fronted travelling wave solutions~\cite{Murray2002,Sanchez1994,Sherratt1996}. As we will explore in this work, however, the differences between the smooth and sharp--fronted travelling waves in the substrate model are more subtle than the Porous--Fisher model, and we must use different methods of analysis to understand these differences. In addition to the schematic solutions in Figure \ref{fig:2}, we present a range of time--dependent PDE solutions in Figure \ref{fig:3} where we explore the role of varying the substrate dynamics by choosing different values of $r_1$ and $r_2$. \begin{landscape} \begin{figure}[h!] \centering \includegraphics[width=1\linewidth]{Figure3.pdf} \caption{\textbf{Time-dependant PDE solutions showing smooth and sharp--fronted travelling wave solutions.} Sharp-fronted travelling wave solutions in (a)--(d) are obtained by solving Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:BCNonDimensional}) with (\ref{eq:ICUCompactSupport})--(\ref{eq:ICSCompactSupport}). Smooth--fronted travelling wave solutions in (e)--(h) are obtained by solving Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:BCNonDimensional}) with (\ref{eq:ICUNonCompactSupport})--(\ref{eq:ICSNonCompactSupport}) and $a=1/2$. Values of $r_1$ and $r_2$ are indicated on each subfigure, and the long-time estimate of the travelling wave speed $c$ is also given to two decimal places. Each subfigure shows profiles for $u(x,t)$ (blue) and $s(x,t)$ (green) at $t=20, 40$ and $60$, with the arrow showing the direction of increasing $t$. All numerical solutions correspond to $\Delta x = 1\times10^{-2}$, $\Delta t = 1\times10^{-3}$ and $\epsilon=1\times10^{-10}$.} \label{fig:3} \end{figure} \end{landscape} Results in Figure \ref{fig:3}(a)--(c) for the sharp--fronted travelling wave solutions show that the long--time minimum travelling wave speed, $c_{\rm{min}}$, depends on $r_1$ and $r_2$. In particular, comparing the results in (a)--(d) show that $c_{\rm{min}}$ appears to increase with $r_1$. In contrast, the smooth--fronted travelling wave solutions in Figure \ref{fig:3}(e)--(h) lead to travelling wave solutions where the wave speed $c > c_{\rm{min}}$ appears to be independent of $r_1$ and $r_2$. These numerical solutions show that the value of $s$ well--behind the travelling wave front depends on the choice of $r_1$ and $r_2$, and motivates us to define \begin{equation} R = \dfrac{r_1}{r_2}, \end{equation} so that we have $s \to R^-$ as $x \to 0^-$, which is consistent with the schematics in Figure \ref{fig:2}. Now we have established that the long--time travelling wave speed for the sharp--fronted travelling wave solutions depends upon $r_1$ and $r_2$, we generate a suite of sharp--fronted travelling wave solutions numerically, and estimate $c_{\rm{min}}$ as a function of $r_1$ and $r_2$, as reported in Figure \ref{fig:4}(a). This heat map suggests that holding $r_2$ constant and increasing $r_1$ leads to an increase in $c_{\rm{min}}$. In contrast, holding $r_1$ constant and increasing $r_2$ reduces $c_{\rm{min}}$. To further explore this relationship we superimpose three straight lines on the heat map in Figure \ref{fig:4}(a). These straight lines correspond to $R=0.5$ (yellow), $R=1$ (red) and $R=2$ (blue). Plotting $c_{\rm{min}}$ as a function of $r_1$ for these three fixed values of $R$ in Figure \ref{fig:4}(b) suggest that $c_{\rm{min}} \to \sqrt{R/2}^{\,-}$ for fixed $R$, as $r_1 \to \infty$. As we will explain later in Section {\ref{sec:approximationr1andr2big}}, this numerical observation is related to the fact that the substrate model simplifies to the Porous--Fisher model when $r_1$ and $r_2$ are sufficiently large~\cite{Buenzli2020}. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{Figure4.pdf} \caption{\textbf{Numerical exploration of the relationship between $c_{\rm{min}}$, $r_1$ and $r_2$.} (a) heat map of $c_{\rm{min}}$ as a function of $r_1$ and $r_2$ obtained by solving (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:BCNonDimensional}) with (\ref{eq:ICUCompactSupport})--(\ref{eq:ICSCompactSupport}). The three straight lines superimposed on (a) correspond to $R=0.5$ (yellow), $R=1$ (red) and $R=2$ (blue), and the relationship between $c_{\rm{min}}$ and $r_1$ for these fixed values of $R$ is given in (b), showing that $c_{\rm{min}} \to \sqrt{R/2}^{\,-}$ as $r_1 \to \infty$. (c) shows $c_{\rm{min}}$ as a function of $r_1$ for $R=0.5,1$ and $2$, suggesting that $c_{\rm{min}} \sim A \sqrt{r_1}$ as $r_1 \to 0$, for some constant $A>0$. All numerical solutions correspond to $\Delta x = 1\times10^{-2}$, $\Delta t = 1\times10^{-2}$ and $\epsilon=1\times10^{-10}$.} \label{fig:4} \end{figure} Results in Figure \ref{fig:4}(b) explore the fast substrate production limit, $r_1 \to \infty$ for fixed $R$, whereas results in Figure \ref{fig:4}(c) explore the small substrate production limit, $r_1 \to 0$. In this case we plot $c_{\rm{min}}$ as a function for $r_1$, for $R=0.5, 1$ and $2$, and we see that the results for different values of $R$ are identical, suggesting that $c_{\rm{min}}$ is independent of $r_2$ as $r_1 \to 0$. Furthermore, the straight line relationship on the log--log plot in Figure \ref{fig:4}(c) suggests that we have $c_{\rm{min}} \sim A \sqrt{r_1}$ as $r_1 \to 0$ for some constant $A>0$. In summary, results in Figure \ref{fig:4} summarise the numerically--determined relationship between $c_{\rm{min}}$, $r_1$, and $r_2$ for sharp--fronted travelling wave solutions of the substrate model. These numerical results are of interest because some results are consistent with well--known results for the Porous--Fisher model as we further explore in Section \ref{sec:approximationr1andr2big}. In contrast, we also observe different behaviour that is inconsistent with the Porous--Fisher model. For example, the non-dimensional Porous-Fisher model has a positive minimum wavespeed $c_{\rm{min}} = 1/\sqrt{2} \approxeq 0.71$, whereas the substrate--mediated invasion model supports sharp--fronted travelling wave solutions with vanishingly small minimum wave speed, $c_{\rm{min}} \to 0$ as $r_1 \to 0$. Table (\ref{tab:ComparisonPorousFSubstrateModel}) summarises the differences and similarities between travelling wave solutions of the Porous--Fisher model and the substrate model. While some of these results have only been numerically explored so far, in later sections we will provide more thorough evidence to support these numerically--based observations. \begin{table}[h!] \caption{Key features of travelling wave solutions of the substrate--mediated invasion model with travelling wave solutions of the Porous--Fisher model.} \centering \begin{tabular}{|c|c|c|c|} \hline \multicolumn{2}{|c|}{Porous-Fisher} & \multicolumn{2}{|c|}{Substrate--mediated model}\\ \hline {Smooth front} & {Sharp front} & {Smooth front} & {Sharp front} \\ \hline $\begin{aligned} c = \begin{cases} \dfrac{1}{a} & a < \sqrt{2}\\ \dfrac{1}{\sqrt 2} & a \ge \sqrt{2}\end{cases} \end{aligned}$ & $\begin{aligned} c_{\textrm{min}} = {\dfrac{1}{\sqrt 2}} \end{aligned}$ & $\begin{aligned} c &= \dfrac{1}{a} \\ \lim_{\substack{r_1 \to \infty \\ r_2 \to \infty}} c &= {\sqrt{\dfrac{R}{2}}}^{\ -} \end{aligned}$ & $\begin{aligned} \lim_{r_1 \to 0^+}c_{\textrm{min}} &= 0^+\\ \lim_{\substack{r_1 \to \infty \\ r_2 \to \infty}}c_{\textrm{min}} &= {\sqrt{\dfrac{R}{2}}}^{\ -} \end{aligned}$ \\ \hline \end{tabular} \label{tab:ComparisonPorousFSubstrateModel} \end{table} Given the numerical evidence developed in this section, we will now use phase space techniques to understand the differences between the sharp--fronted and smooth--fronted travelling wave solutions of the substrate model. \subsection{Phase space analysis for smooth travelling wave solutions}\label{sec:Phaseplaneinz} In the usual way, we seek to study travelling wave solutions of Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:GouvdiffSNonDimensional}) by writing $u(x, t)= U(z)$ and $S(x, t)=S(z)$, where $z$ is the travelling wave variable, $z=x-ct$~\cite{Murray2002} to give \begin{align} \dfrac{\mathrm{d}}{\mathrm{d}z}\left(S \dfrac{\mathrm{d}U}{\mathrm{d}z}\right) + c\dfrac{\mathrm{d}U}{\mathrm{d}z} + U(1-U) &= 0,&-\infty < z < \infty, \label{eq:ODEUz}\\ c\dfrac{\mathrm{d} S}{\mathrm{d} z} + r_1 U- r_2 S&= 0,&-\infty < z < \infty. \label{eq:ODESz} \end{align} Boundary conditions for the smooth travelling wave solutions are $U(z) \rightarrow 1$ and $S(z) \rightarrow R$ as $z\rightarrow -\infty$, and $U(z) \rightarrow 0$ and $S(z) \rightarrow 0$ as $z\rightarrow \infty$. Given such a smooth--fronted travelling wave solution for $U(z)$, we can solve Equation (\ref{eq:ODESz}) to give \begin{equation} S(z)=\frac{r_1}{c}\textrm{exp}\left[\dfrac{r_2 z}{c}\right] \int_{z}^{\infty} \textrm{exp}\left[\dfrac{-r_2 y}{c}\right] \, U(y) \, \mathrm{d} y. \label{eq:SzasfunctionIntU} \end{equation} We will make use of this result later. Following the usual approach to studying smooth travelling wave solutions, we re--write Equations (\ref{eq:ODEUz})--(\ref{eq:ODESz}) as a first order system \begin{align} \label{eq:ODEdUdz} \dfrac{\mathrm{d} U}{\mathrm{d} z} &= W,\\ \dfrac{\mathrm{d} S}{\mathrm{d} z} &= -\left(\dfrac{r_1 U - r_2 S}{c}\right), \label{eq:ODEdSdz}\\ \dfrac{\mathrm{d} W}{\mathrm{d} z} &= W\left(\dfrac{r_1 U - r_2 S-c^2}{cS}\right) - \dfrac{ U(1-U)}{S}. \label{eq:ODEdWdz} \end{align} There are two equilibrium points of the phase space: (i) $(\bar{U},\bar{S},\bar{W}) = (1,R,0)$ as $z\rightarrow -\infty$, which corresponds to the invaded boundary; and, (ii) $(\bar{U},\bar{S},\bar{W}) = (0,0,0)$ as $z\rightarrow \infty$, which corresponds to the uninvaded boundary. To explore the possibility of a heteroclinic orbit connecting the two equilibrium points in the three--dimensional phase space, the Jacobian of this system is \begin{align} \begin{bmatrix} 0 & 0 & 1\\[5pt] -\dfrac{r_1}{c}&\dfrac{r_2}{c}& 0\\[5pt] \displaystyle \dfrac{r_1 \bar{W} - c(1 - 2\bar{U})}{c \bar{S}} & \dfrac{(-r_1 \bar{U} + c^2)\bar{W}+c\bar{U}(1-\bar{U})}{c\bar{S}^2}& \dfrac{ -r_2 \bar{S} +r_1 \bar{U} - c^2}{c\bar{S}}\\[5pt] \end{bmatrix}.\label{eq:JacobianZ} \end{align} We see immediately that we cannot follow the usual practice of evaluating the Jacobian at the uninvaded equilibrium point since it is not defined at $(\bar{U},\bar{S},\bar{W}) = (0,0,0)$ and so linearisation is not useful here. In contrast, the Jacobian at the invaded equilibrium point $(\bar{U},\bar{S},\bar{W}) = (1,R,0)$ is \begin{align} \begin{bmatrix} 0 & 0 & 1\\ -\dfrac{r_1}{c}&\dfrac{r_2}{c}& 0\\ \dfrac{r_2}{r_1}& 0& -\dfrac{c r_2}{r_1}\\ \end{bmatrix}.\label{eq:JacobianZforsaddle} \end{align} The eigenvalues of this Jacobian are $\lambda_1 = r_2/c$ and $\lambda_{2,3} = (-c \pm \sqrt{c^2 + 4 R})/(2R)$. Since these eigenvalues are all real valued, with $\lambda_{1,2} > 0$ and $\lambda_3 < 0$, the invaded equilibrium point is a three--dimensional saddle point. As just mentioned, linearisation about the uninvaded equilibrium point is not possible, and so we revisit the dynamical system (\ref{eq:ODEdUdz})--(\ref{eq:ODEdWdz}) as $z \to \infty$ in more detail in Section \ref{sec:slowmanifold} below. For now, we suppose that a smooth travelling wave $U(z)$ decays exponentially, say \begin{equation} U(z) \sim C\textrm{exp}\left( -b z \right) \quad z \to \infty, \label{eq:Ulargez} \end{equation} where $b > 0$. Under this assumption it follows from (\ref{eq:SzasfunctionIntU}) that \begin{align}\ S(z)& \sim \dfrac{r_1}{b c + r_2}U(z),\label{eq:Slargez}\\ W(z)&\sim -b U(z),\label{eq:Wlargez} \end{align} suggesting that $S(z)$ and $W(z)$ both decay to zero exponentially, at the same rate as $U(z)$, as $z \to \infty$. Further, to leading order as $z \to \infty$, (\ref{eq:ODEdWdz}) gives \begin{align} \dfrac{\mathrm{d} W}{\mathrm{d} z} &\sim (bc-1)\left(\dfrac{b c + r_2}{r_1}\right) \quad \textrm{as} \quad z \to \infty. \end{align} At first glance this results appears inconsistent with our arguments so far, since for smooth travelling wave solutions we expect $\mathrm{d} W / \mathrm{d} z \to 0$ as $z \to \infty$, but here we have $\mathrm{d} W / \mathrm{d} z$ approaching a constant. However, by choosing $c=1/b$ we avoid this inconsistency. This choice implies that the speed of the smooth--fronted travelling wave is related to the far--field decay rate of $U(z)$. We have tested this hypothesis numerically and found and excellent match between (\ref{eq:Ulargez})--(\ref{eq:Wlargez}) and the shape of the smooth--fronted travelling waves for different choices of $r_1$, $r_2$ and $c$, with one example discussed in the Supplementary Material. In addition, we provide further evidence for this far--field behaviour in Section \ref{sec:slowmanifold}. \subsection{Dispersion relationship}\label{sec:dispersionrelationship} We now explore how the decay rate of the initial condition, $a$ in Equation (\ref{eq:ICUNonCompactSupport}), affects the long--time travelling wave speed for smooth--fronted travelling wave solutions. To be consistent with our observations in Section \ref{sec:Phaseplaneinz}, we assume that smooth--fronted travelling wave solutions for $U(z)$ and $S(z)$ decaying at the same rate, and we seek solutions of the form $\tilde{u}(x,t) \sim C \ \textrm{exp} \ [a(x-ct)]$ and $\tilde{s}(x,t) \sim D \ \textrm{exp} \ [a(x-ct)]$ as $x \to \infty$. Substituting these solutions into Equation (\ref{eq:GouvdiffUNonDimensional}), and focusing on the leading edge of these solutions where $\tilde{u}(x,t) \ll 1$, we obtain \begin{equation} c = \dfrac{1}{a}, \label{eq:DispersionRelationship} \end{equation} which relates the long--time speed of the travelling wave solution to the decay rate of the initial condition, $u(x,0)$. Results in Figure \ref{fig:5} explore the validity of Equation (\ref{eq:DispersionRelationship}) by taking time--dependent PDE solutions with initial conditions (\ref{eq:ICUNonCompactSupport})--(\ref{eq:ICSNonCompactSupport}) and varying the decay rate of $u(x,0)$ for various values of $r_1$ and $r_2$. In particular, we generate travelling wave solutions for $r_1 = 1, 5, 10$ and $20$, for fixed $R=0.5, 1$ and $2$. Results in Figure \ref{fig:5}(a)--(c) corresponding to $R=0.5, 1$ and 2, respectively, show that for sufficiently small $a$, we see that the long--time travelling wave speed matches Equation (\ref{eq:DispersionRelationship}) regardless of $r_1$ and $r_2$. These results are consistent with the initial explorations in Figure \ref{fig:3}(e)--(h) where we saw that the wave speed of certain smooth--fronted travelling wave solutions was independent of $r_1$ and $r_2$. As $a$ increases, however, we see that $c$ behaves differently. For large $a > a_{\textrm{crit}}$ we see that $c$ approaches a constant value $c_{\textrm{min}}$ that is independent of $a$. Our numerical evidence suggests that this limiting constant value depends on $r_1$ and $r_2$. For completeness, on each subfigure we plot a horizontal line at $c = \sqrt{R/2}$, and we note that this value appears to be an upper--bound for $c$ as $a$ becomes large. \begin{landscape} \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{Figure5.pdf} \caption{\textbf{Dispersion relationship.} (a)--(c) shows $c$ as a function of the initial decay rate, $a$, for $R=0.5, 1$ and $2$, respectively. Numerical travelling wave speeds are estimated from long--time numerical solutions of Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:BCNonDimensional}) with the initial condition given by Equations (\ref{eq:ICUNonCompactSupport})--(\ref{eq:ICSNonCompactSupport}) with various values of $a$. The dispersion relationship, Equation (\ref{eq:DispersionRelationship}), is plotted (solid blue) and results for $r_1 = 1, 5, 10$ and $20$ are shown in orange discs, yellow squares, purple triangles and green triangles, respectively. Each plot shows a horizontal line at $\sqrt{R/2}$, which is an upper bound for the wavespeed for large $a$. All numerical PDE solutions correspond to $\Delta x = 1\times10^{-2}$, $\Delta t = 1\times10^{-3}$ and $\epsilon=1\times10^{-10}$.} \label{fig:5} \end{figure} \end{landscape} The transition from $c = 1/a$ for $a < a_{\textrm{crit}}$ to constant $c$ for $a > a_{\textrm{crit}}$ in Figure \ref{fig:5} is further explored in Figure \ref{fig:6} for $r_1=r_2=1$. The long--time travelling wave solution in Figure \ref{fig:6}(a)--(b) evolves from an initial condition with decay rate $a=1$. This solution evolves into a smooth travelling wave with $c=1.00$, which is consistent with the dispersion relationship, Equation (\ref{eq:DispersionRelationship}). Although it is clear that the travelling wave solution in Figure \ref{fig:6}(a) is smooth at this scale, we also plot a magnification of the leading edge of that travelling wave in Figure \ref{fig:6}(b). We now explore a series of travelling wave solutions as $a$ increases to visualise the transition reported in Figure \ref{fig:5}. The long--time travelling wave solution in Figure \ref{fig:6}(c)--(d) evolves from an initial condition with a faster decay rate, $a=2$, leading to a smooth--fronted travelling wave with $c=0.50$. Again, this result is consistent with the dispersion relationship, and the magnification of the density profiles near the leading edge in Figure \ref{fig:6}(d) confirms that the travelling wave solution is smooth. The travelling wave solution in Figure \ref{fig:6}(e) for $a=10/3$ leads to a travelling wave solution with $c=0.29$. This estimate from the long--time numerical solution of the PDE is close to the travelling wave speed predicted by the dispersion relationship. At the scale shown in Figure \ref{fig:6}(e) it might seem, at first glance, that the travelling wave is sharp, but the magnification in Figure \ref{fig:6}(f) confirms that this travelling wave is indeed smooth--fronted. Finally, the travelling wave solution in Figure \ref{fig:6}(g) for $a=5$ evolves to a travelling wave solution with $c=0.29$, which is much larger than the speed predicted by the dispersion relationship that would give $c = 1/5 = 0.2$. Again, while the travelling wave solution in Figure \ref{fig:6}(g) appears to be sharp at this scale, the magnification of the solution in Figure \ref{fig:6}(h) confirms that this solution is indeed smooth--fronted. \begin{figure}[H] \centering \includegraphics[width=0.9\linewidth]{Figure6.pdf} \caption{\textbf{Smooth-fronted travelling wave solutions.} Travelling wave solutions $U(z)$ and $S(z)$ are obtained by considering long--time numerical solutions of Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:BCNonDimensional}) with initial conditions given by Equations (\ref{eq:ICUNonCompactSupport})--(\ref{eq:ICSNonCompactSupport}) with variable decay rate, $a$. All results correspond to $r_1=r_2=1$, and results in (a)--(b), (c)--(d), (e)--(f) and (g)--(h) correspond to $a=1, 2, 10/3$ and $5$, respectively, as indicated. Results in the left--most column show the various travelling wave solutions plotted on the usual scale with $0 \le U(z), S(z) \le 1$. Results in the right--most column show a magnification of the leading edge of the travelling waves.} \label{fig:6} \end{figure} In summary, the dispersion relationship suggests that long--time speed of smooth--fronted travelling wave solutions is given by $c = 1/a$, where $a$ is far-field the decay rate of $u(x,0)$. Our numerical explorations in Figures \ref{fig:5}--\ref{fig:6} confirms that this result holds for sufficiently small decay rates, $a < a_{\textrm{crit}}$. As the decay rate increases, $a > a_{\textrm{crit}}$, we observe an interesting transition for smooth--fronted travelling waves where $c$ becomes independent of $a$, and greater than the speed predicted by the dispersion relationship. While these travelling wave solutions remain smooth--fronted as $a$ increases, it becomes increasingly difficult to draw a visual distinction between these smooth--fronted travelling wave solutions and sharp--fronted travelling wave solutions that evolve from initial conditions with compact support, such as those travelling waves in Figure \ref{fig:3}(a)--(d). We now seek to provide a geometric interpretation of the differences between these two classes of travelling wave solutions by returning to the phase space. \subsection{Desingularised phase space and slow manifold reduction}\label{sec:slowmanifold} We now return to the phase space for travelling wave solutions and introduce a change of variables \begin{equation} \zeta(z) = \int_{0}^{z} \dfrac{\mathrm{d}y}{S(y)}, \label{eq:Transformation} \end{equation} which removes the singularity in Equation (\ref{eq:ODEdWdz}) when $S(z)=0$. A similar transformation to desingularise the phase plane is often used in the analysis of sharp--fronted travelling wave solutions of the Porous--Fisher model~\cite{Murray2002}. The desingularised system is given by \begin{align} \label{eq:ODEdUdzeta} \dfrac{\mathrm{d} U}{\mathrm{d} \zeta} &= SW,\\ \dfrac{\mathrm{d} S}{\mathrm{d} \zeta} &= -S\left(\dfrac{r_1 U - r_2 S}{c}\right), \label{eq:ODEdSdzeta}\\ \dfrac{\mathrm{d} W}{\mathrm{d} \zeta} &= W\left(\dfrac{r_1 U - r_2 S-c^2}{c}\right)- U(1-U). \label{eq:ODEdWdzeta} \end{align} There are two equilibrium points of the desingularised phase space: (i) $(\bar{U},\bar{S},\bar{W}) = (1,R,0)$ as $\zeta \to -\infty$, corresponding to the invaded boundary; and, (ii) $(\bar{U},\bar{S},\bar{W}) = (0,0,0)$ as $\zeta \to \infty$, corresponding to the uninvaded boundary. It is important to point out that the phase space analysis in Section \ref{sec:Phaseplaneinz} was relevant only for smooth--fronted travelling wave solutions, whereas the desingularised phase space is appropriate for both the sharp--fronted and smooth--fronted travelling wave solutions. The Jacobian of this system is \begin{align} \begin{bmatrix} 0 & \bar{W} & \bar{S}\\[5pt] -\dfrac{r_1 \bar{S}}{c}&\dfrac{-r_1 \bar{U} + 2 r_2 \bar{S}}{c}& 0\\[5pt] \dfrac{r_1 \bar{W} - c(1 - 2\bar{U})}{c} & -\dfrac{r_2\bar{W}}{c}& \dfrac{ -r_2 \bar{S} +r_1 \bar{U} - c^2}{c}\\[5pt] \end{bmatrix}.\label{eq:JacobianInZeta} \end{align} We can now consider both equilibrium points $(\bar{U}, \bar{S}, \bar{W}) = (1,R,0)$ and $(\bar{U}, \bar{S}, \bar{W}) = (1,0,0)$. The Jacobian at the invaded equilibrium point, $(\bar{U}, \bar{S}, \bar{W}) = (1,R,0)$, is \begin{align} \begin{bmatrix} 0 & 0 & \dfrac{r_1}{r_2}\\ -\dfrac{r_1^2}{r_2}&\dfrac{r_1}{c}& 0\\ 1& 0& -c\\ \end{bmatrix}.\label{eq:JacobianZetaSaddle} \end{align} The eigenvalues of this Jacobian are $\lambda_1 = r_1/c$ and $\lambda_{2,3} = (-c \pm \sqrt{c^2 + 4 R})/2$. Since $\lambda_{1,2} > 0$ and $\lambda_3 < 0$, the uninvaded equilibrium point is a three--dimensional saddle. These expressions are identical to the corresponding expressions in Section (\ref{sec:Phaseplaneinz}), which is not surprising since $\zeta = z$ near the invaded equilibrium point, $z \to -\infty$. The Jacobian at the uninvaded equilibrium point, $(\bar{U}, \bar{S}, \bar{W}) = (0,0,0)$, is \begin{align} \begin{bmatrix} 0 & 0 & 0\\ 0&0& 0\\ -1& 0& -c\\ \end{bmatrix}.\label{eq:JacobianZetaHyperbolic} \end{align} The eigenvalues are $\lambda_1 = -c$ and $\lambda_2 = \lambda_3 = 0$, which means that $(\bar{U}, \bar{S}, \bar{W}) = (0,0,0)$ is a non-hyperbolic equilibrium point suggesting that the dynamics near this point take place on a slow manifold~\cite{Wiggins2003}. To explore these local dynamics near $(\bar{U}, \bar{S}, \bar{W}) = (0,0,0)$ we apply the centre manifold theory to identify the slow manifold. To proceed we rotate the coordinate system using a transformation defined by the eigenvectors $[-c,0,1]^\top$, $[0,1,0]^\top$ and $[0,0,1]^\top$ that are associated with $\lambda_1$, $\lambda_2$ and $\lambda_3$, respectively. The relationship between the original unrotated coordinate system $(U,S,W)$ and the rotated coordinate system $(\mathscr{U},\mathscr{S},\mathscr{W})$ is given by the transformation~\cite{Maclaren2020}, \begin{align} \begin{bmatrix} U\\ S\\ W\\ \end{bmatrix} = \begin{bmatrix} -c & 0 & 0\\ 0&1& 0\\ 1& 0& 1\\ \end{bmatrix} \begin{bmatrix} \mathscr{U}\\ \mathscr{S}\\ \mathscr{W}\\ \end{bmatrix},\label{eq:eigenspaceTransformation} \end{align} and the associated inverse transformation \begin{align} \begin{bmatrix} \mathscr{U}\\ \mathscr{S}\\ \mathscr{W}\\ \end{bmatrix} = \dfrac{1}{c} \begin{bmatrix} -1 & 0 & 0\\ 0&c& 0\\ 1& 0& c\\ \end{bmatrix} \begin{bmatrix} U\\ S\\ W\\ \end{bmatrix}.\label{eq:inverseTransformation} \end{align} These transformations allow us to re-write the dynamical system in the following format \begin{align} \begin{bmatrix} \dfrac{\mathrm{d} \mathscr{U}}{\mathrm{d} \zeta}\\ \dfrac{\mathrm{d} \mathscr{S}}{\mathrm{d} \zeta}\\ \dfrac{\mathrm{d} \mathscr{W}}{\mathrm{d} \zeta}\\ \end{bmatrix} =& \begin{bmatrix} 0 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & -c\\ \end{bmatrix} \begin{bmatrix} \mathscr{U}\\ \mathscr{S}\\ \mathscr{W}\\ \end{bmatrix} \notag \\ &+\dfrac{1}{c} \begin{bmatrix} -\left[\mathscr{S}(\mathscr{U}+\mathscr{W})\right]\\[5pt] \left[\mathscr{S}(r_1c\mathscr{U}+r_2\mathscr{S})\right]\\[5pt] \left[(\mathscr{U}+\mathscr{W})\left[-r_1c\mathscr{U} + (1-r_2)\mathscr{S}\right] + c^2\mathscr{U}(1+c\mathscr{U})\right]\\[5pt] \end{bmatrix}. \label{eq:dUdSdWtransformed} \end{align} To find the slow manifold we take the usual approach of writing the fast dynamics associated with $\lambda_1$ as a function of the slow dynamics that are associated with the zero eigenvalues by assuming that slow manifold can be locally expressed as a quadratic in $\mathscr{U}$ and $\mathscr{V}$. Equating coefficients with the tangency condition~\cite{Wiggins2003} gives the slow manifold, \begin{equation} \mathscr{W}(\mathscr{U},\mathscr{S})=\dfrac{1}{c^2}\left[ c(c^2-r_1) \mathscr{U}^2 + (1-r_2) \mathscr{U}\mathscr{S}\right], \label{eq:slowManifoldWscriptinUSscript} \end{equation} and the dynamics on the slow manifold are given by \begin{align} \dfrac{\mathrm{d} \mathscr{U}}{\mathrm{d} \zeta}&=-\dfrac{1}{c^3}\left[c(c^2-r_1)\mathscr{U}^2\mathscr{S}+(1-r_2)\mathscr{U}\mathscr{S}^2+c^2\mathscr{S}\mathscr{U}\right], \label{eq:ODEdUscriptslowManifold}\\ \dfrac{\mathrm{d} \mathscr{S}}{\mathrm{d} \zeta}&=\dfrac{1}{c}\left[r_2\mathscr{S}^2+r_1c\mathscr{U}\mathscr{S}\right]. \label{eq:ODEdSscriptslowManifold} \end{align} We can now re--write the slow manifold and the dynamics on the slow manifold in the original, unrotated coordinate system, giving \begin{equation} W(U,S)=\dfrac{1}{c^3}\left[(c^2-r_1)U^2 - (1-r_2) U S - c^2 U\right], \label{eq:slowManifoldWinUS} \end{equation} and \begin{align} \dfrac{\mathrm{d} U}{\mathrm{d} \zeta}&=\dfrac{1}{c^3}\left[(c^2-r_1)SU^2 - (1-r_2) U S^2 - c^2SU\right],\label{eq:ODEdUslowManifold}\\ \dfrac{\mathrm{d} S}{\mathrm{d} \zeta}&=\dfrac{1}{c} \left[r_2 S^2 - r_1 U S\right].\label{eq:ODEdSslowManifold} \end{align} With these tools we may now plot the phase space including the two equilibrium points, and superimpose the slow manifold and the heteroclinic orbit obtained be re-writing the long--time PDE solution in terms of the $(U(\zeta), S(\zeta), W(\zeta))$ coordinates. This information is summarised in Figure \ref{fig:7} for two smooth--fronted travelling waves and one sharp--fronted travelling wave, each with $r_1=r_2=1$. Before considering Figure \ref{fig:7} in detail, note that a small $S$ and $U$ analysis of (\ref{eq:ODEdUslowManifold})--(\ref{eq:ODEdSslowManifold}) shows that the heteroclinic orbit must have $U \sim (r_2+1)S/r_1$ as $S \to 0^+$, meaning that the slope of the heteroclinic orbit is $r_1/(r_2+1)$ in the $US$--plane near the origin, and $U \sim A \textrm{exp}(-z/c)$ and $S \sim B \textrm{exp}(-z/c)$, for some constants $A>0$, $B>0$, as $z \to \infty$ for smooth--fronted travelling wave solutions. These results for the flow on the slow manifold confirm (\ref{eq:Ulargez})--(\ref{eq:Slargez}) with $c=1/b$. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{Figure7.pdf} \caption{\textbf{Desingularised phase space and slow manifold reduction}. All results correspond to $r_1=r_2=1$. Results in: (a)--(b) correspond to a smooth--fronted travelling wave with $c_2=10$; (c)--(d) correspond to a smooth--fronted travelling wave with $c_1=1$; and, (e)--(f) correspond to a sharp--fronted travelling wave with $c_{\rm{min}} = 0.29$. Results in the left--most column show the three--dimensional desingularised phase space with the invaded equilibrium point (green dot), the uninvaded equilibrium point (blue dot) and the slow manifold (grey surface). Results in the right--most column show the vector field on the slow manifold, superimposed with several solution trajectories, including the heteroclinic orbit (blue) and several unphysical trajectories (red). The heteroclinic orbit is obtained by solving Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:BCNonDimensional}) numerically with appropriate initial conditions. For (a)--(b) and (c)--(d) the initial conditions are given by Equations (\ref{eq:ICUNonCompactSupport})--(\ref{eq:ICSNonCompactSupport}) with $a=1/10$ and $a=1$, respectively. For (e)--(f) the initial conditions are given by Equations (\ref{eq:ICUCompactSupport})--(\ref{eq:ICSCompactSupport}). All numerical PDE solutions correspond to $\Delta x = 1\times10^{-4}$, $\Delta t = 1\times10^{-3}$ and $\epsilon=1\times10^{-4}$.} \label{fig:7} \end{figure} Figure \ref{fig:7}(a) shows the three--dimensional desingularised phase space together with the invaded equilibrium point in green, the uninvaded equilibrium point in blue, the heteroclinic orbit in solid blue and the slow manifold in grey. In this case we have $c_2 = 10$ and we see that, as expected, the heteroclinic orbit enters the uninvaded equilibrium point after moving along the slow manifold. In Figure \ref{fig:7}(b) we plot the slow manifold locally around the uninvaded equilibrium point together with the vector field defined by Equations (\ref{eq:ODEdUslowManifold})--(\ref{eq:ODEdSslowManifold}). The heteroclinic orbit from the long--time PDE solution is shown in blue. We see that the heteroclinic orbit is tangential to the vector field and enters the uninvaded equilibrium point. For completeness we also solve Equations (\ref{eq:ODEdUslowManifold})--(\ref{eq:ODEdSslowManifold}) numerically to show a number of other solution trajectories on the slow manifold in red. While these other solution curves are valid solutions of Equations (\ref{eq:ODEdUslowManifold})--(\ref{eq:ODEdSslowManifold}), they are unphysical in the sense that they are not associated with the travelling wave solution since they do not form a heteroclinic orbit joining the invaded and uninvaded equilibrium points. Figure \ref{fig:7}(b)--(c) shows a similar set of results to those in Figure \ref{fig:7}(a)--(b) for a different smooth--fronted travelling wave, this time with $c_1 = 1$. Again we see that the heteroclinic orbit moves into the uninvaded equilibrium point along the slow manifold in Figure \ref{fig:7}(c), with additional details shown on the slow manifold in Figure \ref{fig:7}(d). Interestingly, results in Figure \ref{fig:7}(e)--(f), for a sharp--fronted travelling wave with $c_{\rm{min}} = 0.29$ are quite different to the smooth--fronted travelling waves in Figure \ref{fig:7}(a)--(d). Here the heteroclinic orbit joining the invaded and uninvaded equilibrium points enters the uninvaded equilibrium point directly, without moving along the slow manifold. This difference is highlighted in Figure \ref{fig:7}(d) where we see that there is no component of the heteroclinic orbit on the slow manifold. These results in Figure \ref{fig:7} are for one particular choice of $r_1=r_2=1$, and similar results for different choices of $r_1$ and $r_2$ show the same qualitative behaviour (Supplementary Material). In summary, these results show us that we can make a simple geometric distinction between smooth--fronted travelling waves and sharp--fronted travelling waves using the slow manifold reduction. Smooth--fronted travelling waves involve a heteroclinic orbit joining $(\bar{U},\bar{S},\bar{W}) = (1,R,0)$ and $(\bar{U},\bar{S},\bar{W}) = (0,0,0)$, such that the heteroclinic orbit enters $(0,0,0)$ along the slow manifold, given by Equation (\ref{eq:slowManifoldWinUS}). In contrast, sharp--fronted travelling waves involve a heteroclinic orbit joining the same two equilibrium points, with the difference being that the heteroclinic orbit enters $(0,0,0)$ directly, without moving along the slow manifold. These differences are summarised schematically in Figure \ref{fig:8}. \begin{figure}[h!] \centering \includegraphics[width=0.85\linewidth]{Figure8.pdf} \caption{\textbf{Schematic distinction between smooth--fronted and sharp--fronted travelling wave solutions.} The schematic in (a) corresponds to a smooth--fronted travelling wave solution with $c > c_{\rm{min}}$, where the heteroclinic orbit (blue) in the desingularised phase space moves into the $(0,0,0)$ along the slow manifold (grey surface). The schematic in (b) corresponds to a sharp--fronted travelling wave solution with $c = c_{\rm{min}}$, where the heteroclinic orbit (blue) enters the uninvaded equilibrium point, $(0,0,0)$, without moving along the slow manifold (grey surface).} \label{fig:8} \end{figure} It is worth noting that the computational phase space tools in Figure \ref{fig:7}(a),(c) and (e) provide physical insight into the interpretation of the minimum wave speed, $c_{\textrm{min}}$, for the substrate model. While it is not possible to compute a long--time PDE solution with $c < c_{\textrm{min}}$, it is straightforward to plot the three--dimensional phase space and integrate Equations (\ref{eq:ODEdUdzeta})--(\ref{eq:ODEdWdzeta}) numerically to explore various trajectories in the relevant octant where $U \ge 0$, $S \ge 0$ and $W \le 0$. These explorations show that we can identity a unique trajectory that enters the origin just like we did for $c \ge c_{\textrm{min}}$, however part of this trajectory has $U < 0$ which is why it can never be associated with a physically relevant travelling wave solutions (Supplementary Material). This observation shares similarities and differences with the phase plane analysis of the classical Fisher-KPP model, where the exact result $c_{\textrm{min}} = 2$ is found by ensuring that $U > 0$ near the origin~\cite{Murray2002}. In the simpler Fisher-KPP model, the origin is an equilibrium point and so linearisation gives us the local properties of the phase plane, leading to this result. Similar methodology applies for more complicated generalisations of the Fisher-KPP model~\cite{Vittadello2018}. In the case of our substrate model, it appears that $c_{\textrm{min}}$ is also defined by requiring that $U > 0 $ along the heteroclinic orbit (Supplementary Material). Conversely, numerical explorations show that when $c < c_{\textrm{min}}$ we observe that $U < 0$ for portions of the orbit that do not pass through a neighbourhood of the equilibrium point. This observation suggests that linearisation cannot be used to find a mathematical expression for $c_{\textrm{min}}$. For the next part of this work we attempt to understand how the shape of the travelling wave profiles depends upon the parameters in the mathematical model. We will derive two such approximations; one for sharp--fronted travelling wave solutions, and the other for smooth--fronted travelling wave solutions. In both cases we test our approximations using full time--dependent PDE solutions. \subsection{Approximate solution for sharp--fronted travelling waves}\label{sec:approximationr1andr2big} Numerical results in Section \ref{sec:1Dexploration} imply a relationship between the substrate model and the Porous--Fisher model, which we now explore further. For fast substrate production and decay, $r_1\gg 1$ and $r_2\gg 1$, respectively, we anticipate that Equation (\ref{eq:GouvdiffSNonDimensional}) gives approximately $s = Ru$, and that Equation (\ref{eq:GouvdiffUNonDimensional}) is approximately \begin{equation} \label{eq:GouvdiffPorousFisherNonDimensional} \dfrac{\partial u}{\partial t}= R\dfrac{\partial}{\partial x}\left(u \dfrac{\partial u}{\partial x}\right) + u(1-u), \quad 0 < x < \infty, \end{equation} which is the non--dimensional Porous--Fisher model with the diffusion term scaled by the constant $R$. Therefore, we can make use of known results for the Porous--Fisher model in this limit. In particular, sharp--fronted travelling wave solutions of the Porous--Fisher model are known to have the closed--form solution~\cite{Murray2002,Sherratt1996} \begin{align} U(z)&= \begin{cases} 1-\textrm{exp}\left(\dfrac{z-z_c}{2c}\right), & z<z_c,\\ 0, & z > z_c, \label{eq:exactPorousFisherUz} \end{cases}\\ S(z) &= R U(z) \quad \quad \, \, \, -\infty < z < \infty, \label{eq:exactPorousFisherSz} \end{align} where $c = c_{\rm{min}} = \sqrt{R/2}$ and $z_c$ is the location of the sharp front~\cite{Murray2002}. Note that Equation (\ref{eq:exactPorousFisherSz}) is equivalent to substituting Equation (\ref{eq:exactPorousFisherUz}) into Equation (\ref{eq:SzasfunctionIntU}) and evaluating the resulting expression in the limit that $r_1 \to \infty$ and $r_2 \to \infty$. Results in Figure \ref{fig:9} examine how late--time numerical PDE solutions can be approximated by Equations (\ref{eq:exactPorousFisherUz})--(\ref{eq:exactPorousFisherSz}). Results in (a)--(c), (d)--(f) and (g)--(i) correspond to $R=0.5, 1$ and $2$, respectively, and in each case we see that Equations (\ref{eq:exactPorousFisherUz})--(\ref{eq:exactPorousFisherSz}) provide a good match with the shape of the travelling wave solution of the substrate model as $r_1$ and $r_2$ increase. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{Figure9.pdf} \caption{\textbf{Approximate shape of sharp--fronted travelling wave solutions.} Various numerical travelling wave solutions, $U(z)$ and $S(z)$, obtained by solving Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:ICSCompactSupport}) are compared with the approximation given by Equations (\ref{eq:exactPorousFisherUz})--(\ref{eq:exactPorousFisherSz}), where $z$ is shifted so that $z_c=0$. Results in (a)--(c), (d)--(f) and (g)--(i) correspond to $R=0.5, 1$ and $2$, respectively. Each subfigure shows the appropriate value of $r_1$, $r_2$ and $c_{\rm{min}}$. All numerical PDE solutions correspond to $\Delta x = 1\times10^{-2}$, $\Delta t = 1\times10^{-3}$ and $\epsilon=1\times10^{-10}$.} \label{fig:9} \end{figure} \subsection{Approximation solution for smooth--fronted travelling waves}\label{sec:approximationcbig} Previous results in Figure \ref{fig:8} suggest that smooth--fronted travelling waves become less steep as $c$ increases, implying that $W(z)=\mathrm{d}U / \mathrm{d}z \to 0$ as $c \to \infty$. Following the work of Canosa we make use of this observation to develop a perturbation solution by re-scaling the independent variable, $\hat{z} = z/c$ to give~\cite{Canosa1973}, \begin{align} \dfrac{1}{c^2}\dfrac{\mathrm{d}}{\mathrm{d}\hat{z}}\left(S \dfrac{\mathrm{d}U}{\mathrm{d}\hat{z}}\right) + \dfrac{\mathrm{d}U}{\mathrm{d}\hat{z}} + U(1-U) &= 0,&-\infty < \hat{z} < \infty, \label{eq:ODEUcinfinity}\\ \dfrac{\mathrm{d} S}{\mathrm{d} \hat{z}} + r_1 U- r_2 S&= 0,&-\infty < \hat{z} < \infty.\label{eq:ODEScinfinity} \end{align} To proceed, we seek a perturbation solution in terms of the small parameter $1/c^2$ by expanding the dependent variables in a power series~\cite{Murray1984}, \begin{equation} U(\hat{z}) = \sum_{n=0}^{\infty}c^{-2n} U_n(\hat{z}), \quad S(\hat{z}) = \sum_{n=0}^{\infty}c^{-2n} S_n(\hat{z}). \end{equation} Substituting these power series into Equations (\ref{eq:ODEUcinfinity})--(\ref{eq:ODEScinfinity}) and truncating after the first few terms gives \begin{align} &\dfrac{\mathrm{d}U_0}{\mathrm{d}\hat{z}} + U_0(1-U_0) = 0, \label{eq:ode1cinfinity}\\ &\dfrac{\mathrm{d} S_0}{\mathrm{d} \hat{z}} + r_1 U_0 - r_2 S_0 = 0 , \label{eq:ode2cinfinity}\\ &\dfrac{\mathrm{d} }{\mathrm{d}\hat{z}}\left(S_0\dfrac{\mathrm{d} U_0}{\mathrm{d}\hat{z}}\right) + \dfrac{\mathrm{d} U_1}{\mathrm{d}\hat{z}} + U_1(1-2U_0)= 0, \label{eq:ode3cinfinity} \end{align} with boundary conditions $U_0 \rightarrow 1$, $U_1 \rightarrow 0$ and $S_0 \rightarrow R$ as $\hat{z}\rightarrow -\infty$, and $U_0 \rightarrow 0$, $U_1 \rightarrow 0$ and $S_0 \rightarrow 0$ as $\hat{z}\rightarrow \infty$. It is straightforward to solve these differential equations for $U_0(\hat{z})$, $U_1(\hat{z})$ and $S_0(\hat{z})$, however additional terms in the perturbation solution are governed by differential equations that do not have closed--form solutions. Regardless, as we shall now show, these first few terms in the perturbation solution provide accurate approximations, even for relatively small values of $c$. The solution of Equation (\ref{eq:ode1cinfinity}) is \begin{align} U_0(z) = \dfrac{1}{1+\textrm{exp}\left(\hat{z}\right)}, \end{align} where we have arbitrarily chosen the integration constant so that $U_0(0)=1/2$. Given $U_0(z)$, we solve (\ref{eq:ode2cinfinity}) using an integrating factor to give \begin{equation} S_0(\hat{z}) = -r_1 \textrm{exp}\left(r_2 \hat{z}\right)\int_{\hat{z}}^{\infty}\dfrac{\textrm{exp}\left(-r_2 \hat{z}\right)}{1 + \textrm{exp}\left(\hat{z}\right)} \, \mathrm{d}\hat{z}. \label{eq:S0exprintegral} \end{equation} If $r_2$ is an integer we obtain \begin{equation} S_0(\hat{z}) = (-1)^{r_2}\textrm{exp}\left(r_2 \hat{z}\right)r_1\left[\ln\left(\textrm{exp}\left[-\hat{z}\right]+1\right)+\sum_{n=1}^{r_2}\dfrac{\textrm{exp}\left( -n \hat{z}\right)}{n\left(-1\right)^n}\right]. \end{equation} If $r_2$ is not an integer there is no closed--form expression for $S_0(\hat{z})$ that we could find. For particular integer choices of $r_1$ the expression for $S_0(\hat{z})$ is quite simple. For example, with $r_2=1$ we have $S_0(\hat{z}) = r_1\left[1-\textrm{exp}\left(\hat{z}\right)\ln(\textrm{exp}\left[-\hat{z}\right]+1)\right]$, whereas for $r_2=2$ we have $S_0(\hat{z}) =r_1\left[1/2-\textrm{exp}\left(\hat{z}\right)+\textrm{exp}\left(2\hat{z}\right)\ln(\textrm{exp}\left[-\hat{z}\right]+1)\right]$. The solution for $U_1(\hat{z})$ is obtained by integrating Equation (\ref{eq:ode3cinfinity}) using an integrating factor to give \begin{equation} U_1(\hat{z}) = \dfrac{\textrm{exp}\left(\hat{z}\right)}{(1 + \textrm{exp}\left[\hat{z}\right])^2}\int_{\hat{z}}^{\infty} \dfrac{\mathrm{d} }{\mathrm{d}\hat{z}}\left[S_0\dfrac{\textrm{exp}\left(\hat{z}\right)}{(1+\textrm{exp}\left[\hat{z}\right])^2}\right]\left[\dfrac{(1 + \textrm{exp}\left[\hat{z}\right])^2 }{ \textrm{exp}\left(\hat{z}\right)}\right] \mathrm{d}\hat{z}. \label{eq:U1exprintegral} \end{equation} Since this expression for $U_1(\hat{z})$ depends upon the expression for $S_0(\hat{z})$, we can only obtain closed--form expressions for $U_1(\hat{z})$ for integer values of $r_2$. In these cases, expressions for $U_1(\hat{z})$ are relatively complicated and so we include these expressions in the Supplementary Material. We note that care is required when evaluating $U_1(\hat{z})$ since the expression is indeterminate for large $\hat{z}$. We address this simply by expanding $U_1(\hat{z})$ in a Taylor series as $\hat{z} \to \infty$ and plotting the series expansion for large $\hat{z}$. Results in Figure \ref{fig:10} compare the shapes of various smooth--fronted travelling wave solutions, for $c=2$ and $c=4$, with the $\mathcal{O}(1)$ perturbation solution for $S(z)$ and the $\mathcal{O}(c^{-2})$ perturbation solution for $U(z)$. These comparisons are made across a range of values of $r_1$ and $r_2$, and for $c=4$ the perturbation solutions are indistinguishable from the late--time numerical solutions. In cases where $c=2$ we begin to see a small departure between the numerical and perturbation approximations. Given that the perturbation solutions are valid in the limit $c \to \infty$, the quality of match in Figure \ref{fig:10} for $c=2$ and $c=4$ is quite good. \begin{figure}[H] \centering \includegraphics[width=1\linewidth]{Figure10.pdf} \caption{\textbf{Approximate shape of smooth--fronted travelling wave solutions.} Results in (a)--(f) and (g)--(l) compare the numerical and perturbation solutions for $c=2.00$ and $c=4.00$, respectively. Results in the left--most column correspond to $R=0.5$, those in the central column correspond to $R=1$, and those in the right--most column correspond to $R=2$. Numerical solutions correspond to late--time numerical solutions of Equations (\ref{eq:GouvdiffUNonDimensional})--(\ref{eq:BCNonDimensional}), with initial conditions given by Equations (\ref{eq:ICUNonCompactSupport})--(\ref{eq:ICSNonCompactSupport}) with appropriate values of $a$. Numerical solutions of $U(z)$ and $S(z)$ are shown in blue and green, respectively. Each numerical solution is superimposed with an $\mathcal{O}(1)$ perturbation solution for $S(z)$ and an $\mathcal{O}(1/c^2)$ for $U(z)$, and these perturbation solutions are shown in yellow and purple dashed curves, respectively.} \label{fig:10} \end{figure} \newpage \section{Conclusion and Future Work} In this study we investigate a minimal model of cell invasion that couples cell migration, cell proliferation and cell substrate production and decay. A key feature of the mathematical model is that the diffusive flux is proportional to the substrate density so that the flux vanishes when the substrate is absent. This feature leads to predictions of tissue formation involving the propagation of well--defined sharp fronts, and two--dimensional numerical simulations of the mathematical model recapitulate key features of recent experiments that involved the formation of thin tissues grown on D--printed scaffolds~\cite{Lanaro2021}. To gain a deeper understanding of how the rate of substrate production and decay affects the rate of tissue production, the focus of this work is to study solutions of the substrate model in a one--dimensional geometry. Preliminary numerical simulations of the substrate model in one dimension indicate that the mathematical model supports two types of travelling wave solutions. As we show, sharp--fronted travelling waves that propagate with a minimum wave speed, $c_{\rm{min}}$, evolve from initial conditions with compact support, whereas smooth--fronted travelling waves that move with a faster wave speeds, $c > c_{\rm{min}}$, evolve from initial conditions where the density decays exponentially with position. These numerical features are reminiscent of established features of travelling wave solutions of the well--known Porous--Fisher model. Much of our analysis focuses on exploring the relationships between smooth--fronted and sharp--fronted travelling wave solutions, and here key features of the analysis of the substrate model are very different to the analysis of the Porous--Fisher model. For example, there are three equilibrium points in the desingularised phase plane for the Porous--Fisher model whereby travelling wave solutions are characterised by a heteroclinic orbit that enters $(\bar{U},\bar{V}) = (0,0)$, whereas sharp--fronted travelling wave solutions involves a heteroclinic orbit that enters $(\bar{U},\bar{V}) = (0,-c)$. In contrast, the desingularised phase space for the substrate model involves two equilibrium points only. This means that both smooth--fronted and sharp--fronted travelling waves correspond to heteroclinic orbits that enter $(\bar{U}, \bar{S}, \bar{W}) = (0,0,0)$, which is fundamentally different to the Porous--Fisher model. We provide a geometric interpretation that explains the difference between sharp--fronted and smooth--fronted travelling wave solutions since smooth--fronted travelling wave solutions are associated with a heteroclinic orbit that enters the origin in the desingularised phase space by moving along a slow manifold. In contrast, sharp--fronted travelling wave solutions are associated with a heteroclinic orbit that enters the origin of the desingularised phase space directly, without moving along the slow manifold. Additionally, we also develop and test useful closed--form expressions that describe the shape of the travelling wave solutions in various limits. In particular, we provide accurate approximations for the shape of sharp--fronted travelling waves for sufficiently large $r_1$ and $r_2$, as well as accurate approximation of the shape of the smooth--fronted travelling wave solutions relevant for large $c$. There are many avenues for extending the current work, and these options include further analysis of the current model as well as conducting parallel analysis for related mathematical models. In terms of the current model, our analysis has not provided any relationship between $c_{\rm{min}}$ and the two parameters in the nondimensional model, $r_1$ and $r_2$. For simpler mathematical models, such as the Fisher-KPP model, the relationship between the minimum wave speed and the parameters in the model arises by linearising about the leading edge of the travelling wave~\cite{Murray2002}. As we have shown, an interesting feature of the substrate model is that standard techniques to linearise about the leading edge do not apply. Another possibility for extending the analysis of this model would be to consider the mathematical model in two-dimensions, such as describing the late--time dynamics of hole--closing phenomena~\cite{McCue2019}. A different class of extensions of this work would be to consider generalising the nonlinear diffusion term in the substrate model, such as \begin{align} \label{eq:GouvdiffUNonDimensional2} &\dfrac{\partial u}{\partial t}= \dfrac{\partial}{\partial x}\left(\mathcal{D}(s) \dfrac{\partial u}{\partial x}\right) + u(1-u), &0 < x < \infty\\ &\dfrac{\partial s}{\partial t}= r_1 u - r_2 s, &0 < x < \infty. \label{eq:GouvdiffSNonDimensional2} \end{align} This generalised substrate model involves a nonlinear diffusivity function, $\mathcal{D}(s)$. We anticipate that nonlinear diffusivity functions with the property $\mathcal{D}(0) = 0$ will support sharp--fronted travelling wave solutions, and there are many such candidate functions. One option of interest is a power--law diffusivity $\mathcal{D}(s) = s^n$, where $n$ is some exponent. It would be interesting to explore how different choices of $n$ affect various qualitative and quantitative features of the travelling wave solutions that have been established in the present study for $n=1$. We hope to return to address these open questions in future research. \noindent \paragraph{Acknowledgements} This work is supported by the Australian Research Council (DP200100177). We thank Dr Oliver Maclaren for assistance with the slow manifold reduction, and we thank Dr Pascal Buenzli for helpful discussions about tissue engineering applications. \noindent \paragraph{Contributions} All authors conceived and designed the study and performed the mathematical analysis; M.El-H. performed numerical and symbolic calculations. All authors drafted the article and gave final approval for publication. \noindent \paragraph{Competing Interests} We have no competing interests. \newpage
{'timestamp': '2021-11-23T02:28:32', 'yymm': '2111', 'arxiv_id': '2111.07559', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07559'}
arxiv
\section{Improved Unique Decoding for $\varepsilon \leq 1/8$}\label{sec:improve_decoding} In this section we provide two decoding algorithms for the case of $\varepsilon \leq 1/8$, with better decoding radius. The first one is a polynomial time decoding algorithm. The second one is a linear time algorithm with slightly worse parameters. Consider the expander code based on an $(\alpha N, (1-\varepsilon)D)$ bipartite expander. For the case of $\varepsilon \le 1/8$ we provide an efficient algorithm, i.e. Algorithm~\ref{alg:decoding_small_eps}, to decode from more errors. It is again by guessing the correct expansion of the set of corrupted entries. We first give a polynomial time decoding algorithm, then we modify it to give a linear time decoding algorithm. \subsection{Polynomial time decoding} \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon\le 1/8$}\label{alg:decoding_small_eps} \begin{algorithmic}[1] \Function{Decoding}{$y \in \mathbf{F}_2^N,\epsilon \in \mathbf{R},\alpha \in \mathbf{R}$} \For {every integer $i \in [1, N]$, let $x$ satisfy $x \alpha N = i$} \For {every integer $j \in [1, M]$, let $\gamma$ satisfy $(1-\gamma) \cdot D \cdot i = j $} \If{$\gamma x \ge \varepsilon$} \State $\Delta \gets \sqrt{\gamma x \varepsilon} + \frac{c}{N}$ with $c:=c(\varepsilon)$ being a large enough constant. \Else \State $\Delta \gets \varepsilon + \frac{c}{N}$. \EndIf \State $L \gets $ \Call{Find}{$y \in \mathbf{F}_2^n$, $\Delta$} \State Erase the symbols of $y$ that have indices in $L$ to get $y'$, and then apply the decoding from Theorem \ref{thm:decfromerasures} on $y'$ to get a codeword $C'$. \State \Return $C'$ if the distance between $C'$ and $y$ is $\le \frac{1-2\varepsilon}{4 \varepsilon}\alpha N $. \EndFor \EndFor \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} \label{thm:guessexpansion} For every constant $\varepsilon \in (0, 1/8]$, if $\mathcal{C}$ is an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander, then there is a polynomial time decoding algorithm for $\mathcal{C}$ with decoding radius $\frac{\sqrt{2}-1}{2\epsilon} \alpha N -O_{\varepsilon}(1) $ when $\varepsilon< \frac{3-2\sqrt{2}}{2}$ and decoding radius $\frac{1-2\varepsilon}{4\varepsilon} \alpha N - O_{\varepsilon}(1) $ when $\varepsilon \ge \frac{3-2\sqrt{2}}{2}$. \end{theorem} We prove the correctness of Algorithm~\ref{alg:decoding_small_eps} and the theorem in the rest of this section. Again $F$ always denotes the set of corrupted entries. Since we enumerate both $x \alpha N = i$ and $(1-\gamma)D x\alpha N = j$ over all possible values. One pair of them corresponds to the correct size of $F$ and the correct expansion of $F$, i.e., $|F| = x \alpha N$ and $|\Gamma(F)|=(1-\gamma) \cdot D |F|$. Now we only consider this pair $(x, \gamma)$ in the following analysis. First of all, we can bound the expansion of all subsets in $F$. \begin{claim}\label{clm:worst_expansion} Our choice of $\Delta$ always satisfies that \[ \forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|. \] \end{claim} \begin{proof} Let $F' \subseteq F$ be an arbitrary non-empty set, and $|F'| = x' \cdot \alpha N$. \iffalse If $x' > 1$, we consider the collisions in $\Gamma(F)$ and $\Gamma(F')$ ~By collision we mean that given an arbitrary order of the edges, if one edge in this order has its right endpoint the same as any other edge prior to it, then this is called a collision. Since $F'$ is of size $x' \cdot \alpha N$, by Lemma \ref{lem:expansion_larger}, $|\Gamma(F')| \ge (1-x' \cdot \varepsilon) D \cdot x' \alpha N - O_\varepsilon(1)$. So we have that the total number of collisions for edges with left endpoints in $F'$ is at most the total number of collisions for edges with left endpoints in $F$, because a collision in $\Gamma(F')$ is also a collision in $\Gamma(F)$. Thus \[ x' \alpha N \cdot (x' \cdot \varepsilon)D + O_\varepsilon(1) \le |F| \cdot \gamma D. \] \authnote{Xin}{magenta}{The proof here is wrong.} This implies $x' \cdot \varepsilon \le \sqrt{\gamma x\varepsilon } = \Delta - \frac{c}{N}$. When $\gamma x \geq \varepsilon$, we know $|\Gamma(F')| \ge (1-x'\varepsilon) D \cdot |F'| - O_\varepsilon(1) \geq (1-\sqrt{\gamma x\varepsilon}) D \cdot |F'| - O_\varepsilon(1) \geq (1-\Delta) D \cdot |F'|$, when $c$ is large enough. When $\gamma x < \varepsilon$, $|\Gamma(F')| \ge (1-x'\varepsilon) D \cdot |F'| - O_\varepsilon(1) \geq (1-\sqrt{\gamma x\varepsilon}) D \cdot |F'| - O_\varepsilon(1) \geq (1- \varepsilon) D \cdot |F'| - O_\varepsilon(1) \geq (1-\Delta) D \cdot |F'|$, since $\Delta = \varepsilon + \frac{c}{N}$ and $c$ is a large enough constant. \fi If $x'>1$, then assume $|\Gamma(F')| = (1-\beta)D x'\alpha N$. \iffalse Since $|\Gamma(F')| \leq |\Gamma(F)|$, we have $\beta x' \leq \gamma x$.\authnote{Xin}{magenta}{I don't think this inequality follows from $|\Gamma(F')| \leq |\Gamma(F)|$. As in the old version, it should instead follow from the fact that the number of collisions in $F'$ is at most that in $F$. The same for the proof of Claim 7.7} \fi we consider the collisions in $\Gamma(F)$ and $\Gamma(F')$. ~By collision we mean that given an arbitrary order of the edges, if one edge in this order has its right endpoint the same as any other edge prior to it, then this is called a collision. Note that the total number of collisions for edges with left endpoints in $F'$ is at most the total number of collisions for edges with left endpoints in $F$, because a collision in $\Gamma(F')$ is also a collision in $\Gamma(F)$. Thus $$\beta x' \leq \gamma x.$$ Also, since $F'$ has size $x' \cdot \alpha N$, by Lemma \ref{lem:expansion_larger} we have $|\Gamma(F')| \geq (1-x'\varepsilon)D x'\alpha N - O_\varepsilon(1)$. So $ \beta \leq x'\varepsilon + O_\varepsilon(1/N)$. Hence $ \beta (\beta - O_\varepsilon(1/N))/\varepsilon \leq \gamma x $. Thus $ \beta \leq \sqrt{\gamma x \varepsilon } + O_\varepsilon(1/N) $ and $|\Gamma(F')| = (1-\beta)D |F'| \geq (1-\sqrt{\gamma x \varepsilon}) D |F'| - O_\varepsilon(1)$. When $\gamma x\geq \varepsilon$, the algorithm sets $\Delta = \sqrt{\gamma x \varepsilon} + c/N$. So $|\Gamma(F')| \geq (1-\Delta) D |F'|$, when $c$ is large enough. When $\gamma x < \varepsilon$, the algorithm set $\Delta = \varepsilon + c/N $. Notice that $\sqrt{\gamma x \varepsilon} \leq \varepsilon$. Hence again $|\Gamma(F')| \geq (1-\Delta) D |F'|$, when $c$ is large enough. If $x' < 1$, then again we have two cases. When $ \gamma x \ge \varepsilon $, we know $\Delta = \sqrt{\gamma x \varepsilon} \geq \varepsilon $. So by expansion, $ |\Gamma(F')| \ge (1-\varepsilon)D |F'| \geq (1-\Delta)D |F'| $. When $ \gamma x < \varepsilon $, the algorithm sets $\Delta = \varepsilon+ c/N$. So $ |\Gamma(F')| \ge (1-\varepsilon)D |F'| \geq (1-\Delta)D |F'| $. \end{proof} Given the guarantee in Claim~\ref{clm:worst_expansion}, one can show that $L$ contains all the errors. \begin{claim} \label{claim:FsubseteqL} After step 9 in Algorithm~\ref{alg:decoding_small_eps}, we have $F\subseteq L$. \end{claim} \begin{proof} By Claim \ref{clm:worst_expansion}, $\forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|$. So $\forall F' \subseteq F, |\Gamma^1(F')| \ge (1-2\Delta) \cdot D |F'|$, by noticing that $1-2\Delta > 0$ in our setting. By Lemma \ref{lemma:all_errors_in_L}, we know $F\subseteq L$ after \textsc{Find}. \end{proof} Then we calculate the decoding radius and the size of $L$. \iffalse \begin{claim}\label{clm:upper_bound_neighbors} For both $\Delta=\varepsilon$ and $\Delta=\sqrt{\varepsilon \gamma x}$, $|\Gamma(L)| \le |\Gamma(F)| + 2 \Delta D \cdot |L \setminus F|$. \end{claim} \begin{proof} Let $(v_1,\ldots,v_{|L|})$ be the sequence of vertices added to $L$ in the while. By Lemma \ref{lemma:L'allsame}, we can adjust the order of the sequence by putting the vertices in $F$ at first and then put the vertices in $L \setminus F$ after them. The upper bound follows from the fact $F \subseteq L$ from Claim \ref{claim:FsubseteqL} and each vertex in $L \setminus F$ contributes at most $2 \Delta$ to $R$. \end{proof} \fi \begin{claim} \label{claim:guessExpansionLbound1} For the branch which sets $\Delta=\sqrt{\gamma x \varepsilon } + \frac{c}{N}$, if $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N) $, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose after the iterations, $|L| \ge \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. By Claim \ref{clm:worst_expansion} and Lemma \ref{lemma:FAddtoLFirst}, we can consider an $L'$ which is constituted by first adding $F$ and then adding another $ \frac{1-2 \Delta }{2\varepsilon} \alpha N - x \alpha N$ elements. Let $\delta= \frac{|L'| - |F|}{\alpha N} = \frac{1 -2 \Delta }{2 \varepsilon} - x$. Notice that $\frac{|L'|}{\alpha N} = \frac{1 -2 \Delta }{2 \varepsilon} \leq \frac{1-2\varepsilon}{2\varepsilon}$. We show that even having this $L'$ leads to a contradiction. We notice that $\delta \geq 0$ and $x+ \delta \geq 1$. The reason is as follows. Notice that we only need to consider the case $x\geq 1$, since otherwise $\gamma x < \varepsilon$ and thus the algorithm should not go to this branch. Notice that $\gamma \leq x\varepsilon + O_\varepsilon(1/N) $ by Lemma \ref{lem:expansion_larger}. So $\delta = \frac{1 -2 (\sqrt{\gamma x \varepsilon} + c/N ) }{2 \varepsilon} - x \geq \frac{1}{2\varepsilon} - 2x- O_\varepsilon(1/N)$. When $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N) $ and $\varepsilon \leq 1/8$, this is at least $0$. Hence $ x+ \delta \geq 1 $. Next notice that all the unsatisfied checks are in $\Gamma(F)$ and every element in $L'\setminus F$ contributes at most $2\Delta D$ vertices to $R$. Hence $|\Gamma(L')| \le |\Gamma(F)|+2\Delta D\cdot \delta \alpha N$. On the other hand, Lemma~\ref{lem:expansion_larger} implies $|\Gamma(L')| \ge (1-(x+\delta)\varepsilon)D \cdot (x+\delta)\alpha N - O_\varepsilon(1)$. Thus we have \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta)\alpha N - O_\varepsilon(1)\le (1-\gamma)x \alpha N + 2 \Delta \cdot \delta \alpha N \le (1-\gamma)x \alpha N + 2 (\sqrt{\gamma x \varepsilon}+ c/N ) \cdot \delta \alpha N.. \] In the rest of this proof, we show that our choice of $\delta$ yields \begin{equation}\label{eq:ineq1} (1 - (x+\delta)\varepsilon) \cdot (x+ \delta) - O_\varepsilon(1/N) > (1-\gamma) x + 2 (\sqrt{\gamma x \varepsilon} + c/N) \cdot \delta. \end{equation} This gives a contradiction. Towards that, we rewrite inequality~\eqref{eq:ineq1} as \[ 0 > \varepsilon \delta^2 + \left(2 \varepsilon x - 1 + 2 (\sqrt{\gamma x \varepsilon} + c/N) \right)\delta + \varepsilon x^2 - \gamma x + O_\varepsilon(1/N) . \] When $(2 \varepsilon x - 1 + 2 (\sqrt{\gamma x \varepsilon} + c/N) )^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O_\varepsilon(1/N) \right)>0$, the quadratic polynomial will be negative at $\delta =\frac{1 - 2 \varepsilon x -2 (\sqrt{\gamma x \varepsilon}+ c/N) }{2\varepsilon} = \frac{1-2\Delta}{2\varepsilon} -x $. To verify this, we set $z=\varepsilon x$ and only need to verify that \[ (2z - 1 + 2 \sqrt{\gamma z} )^2 - 4 z^2 + 4 \gamma z - O_\varepsilon(1/N) >0. \] This is equivalent to \[ 8 \gamma z + (8z -4 ) \sqrt{\gamma z} + 1 - 4z - O_\varepsilon(1/N) > 0 \Rightarrow 8(\sqrt{\gamma z} +\frac{2z-1}{4})^2 - O_\varepsilon(1/N) + 1 - 4z - 8(\frac{2z-1}{4})^2 > 0. \] When $z=\varepsilon x \leq \frac{\sqrt{2}-1}{2} - O_\varepsilon(1/N)$, i.e. $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N)$, the residue $1 - 4z - 8(\frac{2z-1}{4})^2 -O_\varepsilon(1/N) = 1/2-2z -2 z^2 - O_\varepsilon(1/N)>0$. So the inequality holds. \end{proof} \begin{claim} \label{claim:guessExpansionLbound2} For the branch $\Delta=\varepsilon$, if $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose $|L| \geq \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Consider $L'\subseteq L$ with $|L'| = \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Let $\delta = \frac{1-2\varepsilon}{2\varepsilon} - x$. Notice that $\delta \geq 0$ because $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. Also $x+ \delta \geq 1$ since $\varepsilon \leq 1/8$. By Lemma \ref{lem:expansion_larger}, $|\Gamma(L')| \geq (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1)$. By Lemma \ref{lemma:FAddtoLFirst} we can consider $L'$ as being constituted by first adding all elements in $F$ and then add another $\delta \alpha N$ elements by the algorithm. Notice that all the unsatisfied checks are in $\Gamma(F)$, $|\Gamma(F)| \leq D|F|$, and every element in $L'\setminus F$ contributes at most $2\varepsilon D$ vertices to $R$. Hence $|\Gamma(L')| \leq D|F| + 2\varepsilon D \delta \alpha N$. So we have \[ (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1) \leq |\Gamma(L')| \leq D|F| + 2\varepsilon D \delta \alpha N \] Thus \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta) - O_\varepsilon(1/N) \le x + 2 \varepsilon \delta. \] So this is equivalent to \[ (1- 2\varepsilon - \varepsilon (x+\delta))(x+\delta) - O_\varepsilon(1/N) \le (1-2\varepsilon) x \] Recall that $\delta+x=\frac{1 -2 \varepsilon}{2\varepsilon}$. To get a contradiction, we only need \[ (1-2\varepsilon) x < (1-2\varepsilon)^2/4\varepsilon - O(1/N). \] Namely $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. \end{proof} \begin{proofof}{Theorem \ref{thm:guessexpansion}} One of our enumerations correctly predicts $|F|$ and $|\Gamma(F)|$. Consider Algorithm \ref{alg:decoding_small_eps} under this enumeration. After the function $\textsc{Find}$, all the errors are in $L$ by Claim \ref{claim:FsubseteqL}. Now we bound $|L|$. We can pick the smaller bound of $x$ from Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2}. If $\varepsilon < \frac{3-2\sqrt{2}}{2} $, then $\frac{\sqrt{2}-1}{2\varepsilon} < \frac{1-2\varepsilon}{4\varepsilon}$. So by Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2} when $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N) $ we have $|L| < \frac{1-2\varepsilon}{2\varepsilon}\alpha N $. If $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/8]$, then $\frac{\sqrt{2}-1}{2\varepsilon} \geq \frac{1-2\varepsilon}{4\varepsilon}$. So by Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2} , when $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N) $, we have $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Since the expander is an $(\alpha N, (1-\varepsilon)D)$ expander, by Theorem \ref{thm:decfromerasures}, one can correct all the errors efficiently using $L$ (as the set of erasures) and the corrupted codeword. \end{proofof} \subsection{Linear time decoding} \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon\le 1/8$}\label{alg:decoding_small_eps_lineartime} \begin{algorithmic}[1] \Function{Decoding}{$y \in \mathbf{F}_2^N,\epsilon \in \mathbf{R},\alpha \in \mathbf{R},\eta' \in \mathbf{R}$} \State Enumerate $\tilde{\gamma}\tilde{x}$ from $\{ \eta , 2\eta , \ldots, \lceil\frac{1}{\eta } \rceil \eta \}$, where $\eta=\Theta(\varepsilon \cdot \eta')$. \If{$\tilde{\gamma} \tilde{x}\ge \varepsilon $ } \State $\Delta \gets \sqrt{\tilde{\gamma} \tilde{x} \varepsilon} + \eta $. \Else \State $\Delta \gets \varepsilon + 2\eta $. \EndIf \State $L \gets $ \Call{Find}{$y \in \mathbf{F}_2^n$, $\Delta$} \State Erase the symbols of $y$ that have indices in $L$ to get $y'$, and then apply the decoding from Theorem \ref{thm:decfromerasures} on $y'$ to get a codeword $C'$. \State \Return $C'$ if distance between $C'$ and $y$ is $\le \frac{1-2\varepsilon}{4 \varepsilon}\alpha N $ where the distance comes from Theorem~\ref{thm:dist_expander}. \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} \label{thm:guessexpansion_lineartime} For all constants $\varepsilon \in (0, 1/8], \eta' > 0$, if $\mathcal{C}$ is an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander, then there is a linear time decoding algorithm for $\mathcal{C}$ with decoding radius $(\frac{\sqrt{2}-1}{2\epsilon}\alpha - \eta' ) N $ when $\varepsilon< \frac{3-2\sqrt{2}}{2}$ and decoding radius $(\frac{1-2\varepsilon}{4\varepsilon}\alpha - \eta' ) N $ when $\varepsilon \ge \frac{3-2\sqrt{2}}{2}$. \end{theorem} We prove the correctness of Algorithm~\ref{alg:decoding_small_eps_lineartime} and the theorem in the rest of this section. Again $F$ always denotes the set of corrupted entries, and assume $|F| = x\alpha N$, $|\Gamma(F)| = (1-\gamma)D|F|$. Since we enumerate $\tilde{\gamma}\tilde{x}$ from a sequence with gap $\eta$, one of them is such that $ \gamma x \in [\tilde{\gamma}\tilde{x} , \tilde{\gamma}\tilde{x} + \eta]$. Now we only consider this enumeration in the following analysis. Next we can bound the expansion of all subsets in $F$. \begin{claim}\label{clm:worst_expansion_lineartime} Our choice of $\Delta$ always satisfies that \[ \forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|. \] \end{claim} \begin{proof} Let $F' \subseteq F$ be an arbitrary non-empty set, and $|F'| = x' \cdot \alpha N$. \iffalse If $x' \geq 1$, then consider the collisions in $\Gamma(F)$ and $\Gamma(F')$. ~By collision we mean that given an arbitrary order of the edges, if one edge in this order has its right endpoint the same as any other edge prior to it, then this is called a collision. Since $F'$ is of size $x' \cdot \alpha N$, by Lemma \ref{lem:expansion_larger}, $|\Gamma(F')| \ge (1-x' \cdot \varepsilon) D \cdot x' \alpha N - O_\varepsilon(1)$. So we have that the total number of collisions for edges with left endpoints in $F'$ is at most the total number of collisions for edges with left endpoints in $F$, because a collision in $\Gamma(F')$ is also a collision in $\Gamma(F)$, according to an arbitrary order of all edges connected to vertices in $F$. So \[ x' \alpha N \cdot (x' \cdot \varepsilon)D + O_\varepsilon(1) \le |F| \cdot \gamma D. \] \authnote{Xin}{magenta}{The proof here is wrong.} This implies $x' \cdot \varepsilon \le \sqrt{\gamma x\varepsilon } $. When $\tilde{\gamma} \tilde{x}\ge \varepsilon $, $ \sqrt{\gamma x\varepsilon } \leq \Delta - \Theta(\eta)$ because $\gamma x \leq \tilde{\gamma}\tilde{x} + \eta$, $\Delta = \sqrt{ \tilde{\gamma}\tilde{x}\varepsilon} + \eta $. Hence $|\Gamma(F')| \ge (1-x'\varepsilon)D |F'| - O_\varepsilon(1) \ge (1-\Delta+ \Theta(\eta)) D \cdot |F'| - O_\varepsilon(1) \geq (1-\Delta) D \cdot |F'|$, by noticing $|F'|= x'\alpha N \geq \alpha N$. When $\tilde{\gamma} \tilde{x} < \varepsilon $, $ \sqrt{\gamma x\varepsilon } \leq \varepsilon + \eta.$ Hence $|\Gamma(F')| \ge (1-\varepsilon -\eta) D \cdot |F'| - O_\varepsilon(1) \geq (1-\varepsilon - 2\eta) D \cdot |F'|$, noticing $|F'|= x'\alpha N \geq \alpha N$. \fi If $x'>1$, then assume $|\Gamma(F')| = (1-\beta)D x'\alpha N$. we consider the collisions in $\Gamma(F)$ and $\Gamma(F')$. ~Recall that by collision we mean that given an arbitrary order of the edges, if one edge in this order has its right endpoint the same as any other edge prior to it, then this is called a collision. Note that the total number of collisions for edges with left endpoints in $F'$ is at most the total number of collisions for edges with left endpoints in $F$, because a collision in $\Gamma(F')$ is also a collision in $\Gamma(F)$. Thus $$\beta x' \leq \gamma x.$$ Also, since $F'$ has size $x' \cdot \alpha N$, by Lemma \ref{lem:expansion_larger} we have $|\Gamma(F')| \geq (1-x'\varepsilon)D x'\alpha N - O_\varepsilon(1)$. So $ \beta \leq x'\varepsilon + O_\varepsilon(1/N)$. Hence $ \beta (\beta - O_\varepsilon(1/N))/\varepsilon \leq \gamma x $. Thus $ \beta \leq \sqrt{\gamma x \varepsilon } + O_\varepsilon(1/N) $ and $|\Gamma(F')| = (1-\beta)D |F'| \geq (1-\sqrt{\gamma x \varepsilon}) D |F'| - O_\varepsilon(1)$. When $ \tilde{\gamma} \tilde{x}\ge \varepsilon $, the algorithm sets $\Delta = \sqrt{\tilde{\gamma} \tilde{x}\varepsilon} + \eta$. Notice that $ \sqrt{\gamma x\varepsilon } \leq \Delta - \eta/2$. So $|\Gamma(F')| \geq (1-\Delta) D |F'|$. When $ \tilde{\gamma} \tilde{x} < \varepsilon$, the algorithm sets $\Delta = \varepsilon + 2\eta$. Notice that $\sqrt{\gamma x \varepsilon} \leq \varepsilon + \eta$. Hence again $|\Gamma(F')| \geq (1-\Delta) D |F'|$. If $x' < 1$, then again we have two cases. When $\tilde{\gamma} \tilde{x}\ge \varepsilon $, we know $\Delta \geq \varepsilon + \eta$. So by expansion, $ |\Gamma(F')| \ge (1-\varepsilon)D |F'| \geq (1-\Delta)D |F'| $. When $\tilde{\gamma} \tilde{x}< \varepsilon $, the algorithm sets $\Delta = \varepsilon+2\eta$. So $ |\Gamma(F')| \ge (1-\varepsilon)D |F'| \geq (1-\Delta)D |F'| $. \end{proof} Given the guarantee in Claim~\ref{clm:worst_expansion_lineartime}, one can show that $L$ contains all the errors. \begin{claim} \label{claim:FsubseteqL_lineartime} After step 9 in Algorithm~\ref{alg:decoding_small_eps_lineartime}, we have $F\subseteq L$. \end{claim} \begin{proof} By Claim \ref{clm:worst_expansion_lineartime}, $\forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|$. So $\forall F' \subseteq F, |\Gamma^1(F')| \ge (1-2\Delta) \cdot D |F'|$, since $(1-2\Delta) > 0$ in our setting. By Lemma \ref{lemma:all_errors_in_L}, we know $F\subseteq L$ after \textsc{Find}. \end{proof} Then we calculate the decoding radius and the size of $L$. \begin{claim} \label{claim:guessExpansionLbound1_lineartime} For the branch $\Delta=\sqrt{\tilde{\gamma}\tilde{x} \varepsilon } + \eta $, if $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O(\eta/\varepsilon) $, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} First of all, we will use the fact $\Delta \le \sqrt{\gamma x \epsilon} + \eta$ (since $\gamma x \in [\tilde{\gamma}\tilde{x},\tilde{\gamma}{\tilde{x}}+\eta]$ in the correct guessing) extensively in this proof. Now suppose after the iterations, $|L| \ge \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. By Claim \ref{clm:worst_expansion_lineartime} and Lemma \ref{lemma:FAddtoLFirst}, we can consider an $L'$ which is constituted by first adding $F$ and then adding another $ \frac{1-2 (\sqrt{\gamma x \varepsilon} + \eta ) }{2\varepsilon} \alpha N - x \alpha N$ elements. Let $\delta= \frac{|L| - |F|}{\alpha N} = \frac{1 -2 (\sqrt{\gamma x \varepsilon} + \eta) }{2 \varepsilon} - x$. Notice that $|L'| = \frac{1 -2 (\sqrt{\gamma x \varepsilon} + \eta) }{2 \varepsilon} \leq \frac{1-2\varepsilon}{2\varepsilon}$. We show that even having this $L'$ leads to a contradiction. We notice that $\delta \geq 0, x+ \delta \geq 1$. The reason is as follows. First consider the case $x\geq 1$. Notice that $\gamma \leq x\varepsilon + O_\varepsilon(1/N) $ by Lemma \ref{lem:expansion_larger}. So $\delta = \frac{1 -2 (\sqrt{\gamma x \varepsilon} + \eta) }{2 \varepsilon} - x \geq \frac{1}{2\varepsilon} - 2x- O_\varepsilon(\eta)$. when $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(\eta) $, $\varepsilon \leq 1/8$, this is at least $0$. Also notice that $ x+ \delta \geq \frac{1 }{2 \varepsilon} - x -\Theta_\varepsilon(\eta) \geq 1 $ when $\varepsilon \leq 1/8$. Second if $x<1$, then $\tilde{\gamma}\tilde{x} \leq \gamma x < \varepsilon $ and thus the algorithm should not go to this branch. Next notice that all the unsatisfied checks are in $\Gamma(F)$ where $|\Gamma(F)| = (1-\gamma) D|F|$, and every element in $L'\setminus F$ contributes at most $2\Delta D$ vertices to $R$. Hence $|\Gamma(L')| \le |\Gamma(F)|+2\Delta D\cdot \delta \alpha N$. On the other hand, Lemma~\ref{lem:expansion_larger} implies $|\Gamma(L')| \ge (1-(x+\delta)\varepsilon)D \cdot (x+\delta)\alpha N - O_\varepsilon(1)$. Thus we have \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta)\alpha N - O_\varepsilon(1)\le (1-\gamma)x \alpha N + 2 \Delta \cdot \delta \alpha N \le (1-\gamma)x \alpha N + 2 (\sqrt{\gamma x \varepsilon} + \eta) \cdot \delta \alpha N.. \] In the rest of this proof, we show that our choice of $\delta$ yields \begin{equation}\label{eq:ineq1_lineartime} (1 - (x+\delta)\varepsilon) \cdot (x+ \delta) - O_\varepsilon(1/N) > (1-\gamma) x + 2 (\sqrt{\gamma x \varepsilon} + \eta) \cdot \delta. \end{equation} This gives a contradiction. Towards that, we rewrite inequality~\eqref{eq:ineq1_lineartime} as \[ 0 > \varepsilon \delta^2 + \left(2 \varepsilon x - 1 + 2 (\sqrt{\gamma x \varepsilon} + \eta) \right)\delta + \varepsilon x^2 - \gamma x + O_\varepsilon(1/N) . \] When $(2 \varepsilon x - 1 + 2 (\sqrt{\gamma x \varepsilon} + \eta) )^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O_\varepsilon(1/N) \right)>0$, the quadratic polynomial will be negative at $\delta =\frac{1 - 2 \varepsilon x -2 (\sqrt{\gamma x \varepsilon} + \eta) }{2\varepsilon} $. To verify this, we set $z=\varepsilon x$ and only need to guarantee that \[ (2z - 1 + 2 \sqrt{\gamma z} )^2 - 4 z^2 + 4 \gamma z - 2(1 - 2\varepsilon x - 2 \sqrt{\gamma x \epsilon)}\eta >0. \] This is equivalent to \[ 8 \gamma z + (8z -4 ) \sqrt{\gamma z} + 1 - 4z - 2\eta > 0 \Rightarrow 8(\sqrt{\gamma z} +\frac{2z-1}{4})^2 - 2\eta + 1 - 4z - 8(\frac{2z-1}{4})^2 > 0. \] When $z=\varepsilon x \leq \frac{\sqrt{2}-1}{2} - O(\eta)$ (namely $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O(\eta/\epsilon)$), the residue $1 - 4z - 8(\frac{2z-1}{4})^2 - 2 \eta = \frac{1}{2} -2z -2z^2 - 2 \eta >0$. So the inequality holds. \end{proof} \begin{claim} \label{claim:guessExpansionLbound2_lineartime} For the branch $\Delta=\varepsilon + 2\eta$, if $x \leq \frac{1-2\varepsilon}{4\varepsilon} - 2\eta/\epsilon$, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose $|L| \geq \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Consider $L'\subseteq L$ with $|L'| = \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Let $\delta = \frac{1-2\varepsilon}{2\varepsilon} - x$. Notice that $\delta \geq 0$ because $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(\eta), \varepsilon \leq 1/8$. Also $x+ \delta \geq 1$ since $\varepsilon \leq 1/8$. By Lemma \ref{lem:expansion_larger}, $|\Gamma(L')| \geq (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1)$. By Lemma \ref{lemma:FAddtoLFirst} we can consider $L'$ as being constituted by first adding all elements in $F$ and then add another $\delta \alpha N$ elements by the algorithm. Notice that all the unsatisfied checks are in $\Gamma(F)$, $|\Gamma(F)| \leq D|F|$, and every element in $L'\setminus F$ contributes at most $2\Delta D$ vertices to $R$. Hence $|\Gamma(L')| \leq D|F| + 2\Delta D \delta \alpha N$. So we have \[ (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1) \leq |\Gamma(L')| \leq D|F| + 2\Delta D \delta \alpha N \] Thus \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta) - O_\varepsilon(1/N) \le x + 2 \Delta \delta = x + 2 (\varepsilon + 2\eta) \delta. \] So this is equivalent to \[ (1- 2\varepsilon - \varepsilon (x+\delta))(x+\delta) - 4 \delta \eta \le (1-2\varepsilon) x \] Recall that $\delta+x=\frac{1 -2 \varepsilon}{2\varepsilon}$. To get a contradiction, we only need \[ (1-2\varepsilon) x < (1-2\varepsilon)^2/4\varepsilon - 4 \delta \eta. \] This is satisfied by $x \leq \frac{1-2\varepsilon}{4\varepsilon} - 2\eta/\epsilon$. \end{proof} \begin{proofof}{Theorem \ref{thm:guessexpansion_lineartime}} One of our enumerations has $\tilde{\gamma}\tilde{x}$ such that $ \gamma x \in [\tilde{\gamma}\tilde{x} ,\tilde{\gamma}\tilde{x}+ \eta]$. Consider \textsf{Decoding} in Algorithm \ref{alg:decoding_small_eps_lineartime} under this enumeration. After the function $\mathrm{Find}$, all the errors are in $L$ by Claim \ref{claim:FsubseteqL_lineartime}. Now we bound $|L|$. We can pick the smaller bound of $x$ from Claim \ref{claim:guessExpansionLbound1_lineartime} and Claim \ref{claim:guessExpansionLbound2_lineartime}. If $\varepsilon < \frac{3-2\sqrt{2}}{2} $, then $\frac{\sqrt{2}-1}{2\varepsilon} < \frac{1-2\varepsilon}{4\varepsilon}$. So by Claim \ref{claim:guessExpansionLbound1_lineartime} and Claim \ref{claim:guessExpansionLbound2_lineartime} when $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O(\eta/\varepsilon) $ we have $|L| < \frac{1-2\varepsilon}{2\varepsilon}\alpha N $. If $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/8]$, then $\frac{\sqrt{2}-1}{2\varepsilon} \geq \frac{1-2\varepsilon}{4\varepsilon}$. So by Claim \ref{claim:guessExpansionLbound1_lineartime} and Claim \ref{claim:guessExpansionLbound2_lineartime} , when $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O(\eta/\varepsilon) $, we have $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Since the expander is an $(\alpha N, (1-\varepsilon)D)$ expander, by Theorem \ref{thm:decfromerasures}, one can correct all the errors efficiently using $L$ (as the set of erasures) and the corrupted codeword. The decoding algorithm runs in linear time because we only have a constant number of enumerations, and each enumeration takes linear time. \end{proofof} \section{Improved Decoding for large expansion} Let $\mathcal{C}$ be the expander code of a $(\alpha N, (1-\varepsilon)D)$-expander. Consider the following algorithm modified from \cite{Viderman13b}: \begin{enumerate} \item Choose a parameter $k$ and thus $\mathcal{C}$ is a $(k \alpha N, (1-k \varepsilon)D)$-expander. \item Let $h_0=(1-2k \varepsilon)D$ and $R_0=\{\text{all unsatisfied parties}\}$. \item $L'(0)=\emptyset$. \item $R'(0)=R_0$, $t=0$. \item While $\exists i \in [N] \setminus L'(t)$ s.t. $|N(i) \cap R'(t)| \geq h_t$ do \begin{enumerate} \item $L'(t+1)=L'(t) \cup \{i\}$. \item $R'(t+1)=R'(t) \cup N(i)$. \item $t=t+1$. \end{enumerate} \item $h_t$ is defined as follows: if $|L'(t)| \leq k \alpha N$ then $h_t=h_0$; otherwise $h_t=(1-2\frac{|L'(t)|}{\alpha N}\varepsilon)D$. \end{enumerate} We want to bound $|L'(t)|$ for all $t$ by setting an appropriate $|Corr|$ which is the size of the corrupted bits. First we can show that if the above algorithm stops, then the order of adding $i \in [N]$ to $L'(t)$ does not matter, and we will always end up with the same set $L'(t)$ in the end. Thus, define $Corr_0 = \{i \in Corr | |N(i) \cap R_0| \geq h_0 \}$ and assume that $|Corr_0| \leq k \alpha N$ (we'll later show this assumption holds), WLOG we can assume we add $Corr_0$ to become $L'(0)$ in the first step and continue from there. Now if $|L'(t)| \leq k \alpha N$ for all $t$ then we are already done. Otherwise at some point the size grows larger than $k \alpha N$. We borrow the following claim (Claim 4.6) from \cite{Viderman13b}: \begin{claim} \[|N(Corr_0) \setminus R_0| \leq (D-h_0)|Corr_0| -|R_0|+h_0 |Corr|.\] \end{claim} Now before $|L'(t)|$ reaches $k \alpha N$, the size of $N(L'(t))$ grows by at most $D-h_0$ each time, after that it grows by at most $D-h_t$ each time. So we have the follow inequalities. \begin{align*} (1-\frac{|L'(t)|}{\alpha N}\varepsilon)D |L'(t)| & \leq |N(L'(t))| \leq |R_0|+|N(Corr_0) \setminus R_0|+\sum_{i=1}^{t}(D-h_{t-1}) \\ & \leq (D-h_0)|Corr_0|+h_0 |Corr|+(D-h_0)(k \alpha N-|Corr_0|)+\frac{2\varepsilon D}{\alpha N} \sum_{j=k\alpha N}^{|L'(t)|-1}j\\ & \leq 2k^2 \varepsilon D \alpha N +(1- 2 k \varepsilon) D |Corr|+\frac{2\varepsilon D}{\alpha N} \frac{|L'(t)|^2-(k\alpha N)^2}{2} \\ & = 2k^2 \varepsilon D \alpha N +(1- 2 k \varepsilon) D |Corr|+\frac{\varepsilon D}{\alpha N}(|L'(t)|^2-(k\alpha N)^2). \end{align*} Set $|L'(t)|=x$ and simplify, we get \[x - \frac{2 \varepsilon}{\alpha N} x^2 \leq k^2 \varepsilon \alpha N+(1- 2 k \varepsilon) |Corr|.\] Note that the left hand side is maximized at $x=\frac{\alpha N}{4 \varepsilon}$ with a value of $\frac{\alpha N}{8 \varepsilon}$. Thus as long as we start with $|L'(0)| < \frac{\alpha N}{4 \varepsilon}$ and set $|Corr|$ to be such that $k^2 \varepsilon \alpha N+(1- 2 k \varepsilon) |Corr| < \frac{\alpha N}{8 \varepsilon}$ we can bound $|L'(t)|$ by $\frac{\alpha N}{4 \varepsilon}$. Thus, roughly we can set $k^2 \varepsilon \alpha N+(1- 2 k \varepsilon) |Corr| = \frac{\alpha N}{8 \varepsilon}$ and $|Corr|=\frac{\frac{\alpha N}{8 \varepsilon}-k^2 \varepsilon \alpha N}{1- 2 k \varepsilon}$. This is maximized when setting $k=\frac{1-\frac{1}{\sqrt{2}}}{2\varepsilon}$, where we get $|Corr|=(2-\sqrt{2})\frac{\alpha N}{4 \varepsilon}$. Notice for this setting we have $|Corr|=k \alpha N$ and thus $|Corr_0| \leq |Corr| = k \alpha N$. Furthermore $k \alpha N < \frac{\alpha N}{4 \varepsilon}$. The proof that $Corr \subseteq |L'(t)|$ can use the same argument as the Proof of Proposition 4.3 in \cite{Viderman13b}, and by noticing that $h_0 \geq h_t$. \section{The case of $\varepsilon < \frac{1}{2\sqrt{2}}$} \textcolor{red}{There is a problem here.} In the above analysis, set $k=1$ and the final inequality becomes \[x - \frac{2 \varepsilon}{\alpha N} x^2 \leq \varepsilon \alpha N+(1- 2 \varepsilon) |Corr|.\] When $\varepsilon \leq \frac{1}{2\sqrt{2}}-c$ for any constant $c>0$, we can set $|Corr|$ to be a small enough $\Theta(\alpha N)$ (in particular, $|Corr| < \frac{\alpha N}{2}$) s.t. $ \varepsilon \alpha N+(1- 2 \varepsilon) |Corr| < \frac{\alpha N}{8 \varepsilon}$. We now check the following conditions: \begin{enumerate} \item $|Corr_0| \leq |Corr| < \alpha N$ holds, so that we can use Claim 4.6 from \cite{Viderman13b}. \item $|L'(0)|=|Corr_0| \leq |Corr| \leq \frac{\alpha N}{2} < \frac{\alpha N}{4 \varepsilon}$ holds, so that we start with a $|L'(0)|$ smaller than the value $\frac{\alpha N}{4 \varepsilon}$ which maximizes $x - \frac{2 \varepsilon}{\alpha N} x^2$. \item $ \varepsilon \alpha N+(1- 2 \varepsilon) |Corr| < \frac{\alpha N}{8 \varepsilon}$ holds by our choice of $|Corr|$. \end{enumerate} Thus we still have the bound $|L'(t)| \leq max\{\alpha N, \frac{\alpha N}{4 \varepsilon}\}$. \section{Supplemental Proofs}\label{appen:proof_expansion} \iffalse \begin{proposition} For any $\alpha \in (0,\frac{1}{2}], \epsilon \leqslant \frac{1}{4}$ and $\delta > 0$, there exists $D \in \mathbb{N}$ such that for any sufficient large $N \in \mathbb{N}$, there exists an $(\alpha, \epsilon, D)$--expander but not $(2\alpha, 2\epsilon - \delta, D)$-expander graph with $N$ vertices in the left part. \end{proposition} \begin{proof} We first prove the case of $\alpha = \frac{1}{2}$. Let $p = \frac{(4\epsilon - \delta)D}{N}$, consider a random graph $G(N, p)$ with $N$ vertices. Each vertices pair $(i,j)$ were independently chosen to has an edge between them with probability $p$. Let $d(i)$ denote the degree of the $i$--th vertex. If $d(i) > D$ for some $i$, delete $d(i)-D$ edges starting from it arbitrarily. We will finally get a graph $G$ with maximum degree at most $D$. From $G$ we can construct a left--regular bipartite graph $H$ as follows: Every vertices in $G$ correspond to a vertex in the left part of $H$ with degree $D$. Any vertices pair $i, j$ have $0$ or $1$ common neighbour, and $\left|N(i) \cap N(j)\right| = 1$ iff $i$ and $j$ are connected in $G$. \textbf{Fact}: If $t = O(\frac{1}{N})$, binomial distribution $B(N, t)$ is approximate to $Pois(Nt)$ (specifically, the total variance distance of these two distribution is $2Nt^2 = O(\frac{1}{N})$) \textcolor{red}{Xue: I am confused here. The above fact is stated for $t=O(1/N)$; but we are applying it to $p=\varepsilon D = \Theta(1)$. Why not we use the binomial approximation by Stirling number or the following fact $(n/k)^k \le {n \choose k} \le (en/k)^k$ directly?} \textcolor{blue}{[Minghui: Maybe it's also work here. But the method I used here is more robust. My goal is to calculate the distribution of $|e(X)|$, which is the sum of $\Omega(N^2)$ Bernoulli distribution with parameter $p$. In order to use CLT, I need to split this sum into $\Omega(N)$ part, and the sum inside each part tends to a specific distribution not depend on $N$, namely, $Pois(p(|X|-1)) \approx Pois(\frac{(4\epsilon-\delta) D}{2})$. Then I use CLT for this distribution.]} \textbf{i):}$H$ is $(\frac{1}{2}, \epsilon, D)$--expander with high probability: For any subset $X$ with cardinality $\frac{N}{2}$, the number of edges between $X$ in $G(N, p)$ is $B(\binom{|X|}{2}, p)$. It is approximate to the sum of $\frac{|X|}{2}$ i.i.d. Poisson distributions $Pois(p(|X|-1))$. Let $e(X)$ denotes the set of edges between vertices in $X$ in $G$. By CLT, we have \begin{align*} \mathbb{P}\left( \left|e(X)\right| > \epsilon D|X| \right) &\approx \mathbb{P}\left( \sum_{i = 1}^{\frac{|X|}{2}} X_i > \epsilon D|X| \right) \tag{$X_i \sim Pois(p(|X|-1) = Pois((\frac{4\epsilon - \delta}{2})D))$ iid} \\ &= \mathbb{P}\left( \frac{4}{N} \sum_{i = 1}^{\frac{N}{4}} X_i > 2\epsilon D \right) \tag{$X_i \sim Pois((\frac{4\epsilon - \delta}{2})D)$ iid} \\ &\approx \mathbb{P}\left( Y > 2\epsilon D \right) \tag{$Y \sim \mathcal{N}\left( \frac{(4\epsilon-\delta)D}{2}, \frac{(16\epsilon-4\delta)D}{N} \right)$} \\ &< \frac{e^{-\frac{k^2}{\sqrt{2}\sigma}}}{2k\sqrt{\pi}} \tag{$k = 2\epsilon D - \frac{(4\epsilon-\delta)D}{2}, \sigma = \frac{(16\epsilon-4\delta)D}{N}$} \\ &= O\left(\frac{e^{-\Omega(DN)}}{D}\right) \end{align*} The number of subsets of $[N]$ with cardinality $\frac{N}{2}$ is $\binom{N}{\frac{N}{2}} < 2^N$. By taking $D$ sufficiently large and using union bound, we have that for any $|X| = \frac{N}{2}$, $\left|e(X)\right|$ is less than $\epsilon D|X|$. So $H$ is an $(\frac{1}{2}, \epsilon, D)$--expander graph. \textbf{ii):}$H$ isn't $(1, 2\epsilon - \delta, D)$--expander with high probability. This is equivalent to say the cardinality of right part of $H$ is less than $(1 - 2\epsilon + \delta)DN$. The expectation number of edges in $G$ is the expectation number of edges in $G(N, p)$ minus the expectation number of edges deleted. The first term is $p\binom{N}{2}$, and the degree of a vertex in $G(N, p)$ satisfies $B(N-1, p)$, which is approx to $Pois(p(N-1))$. \begin{align*} \mathbb{E}_{X \sim Pois(p(N-1))} \left( \mathbbm{1}_{X > D}\left(X - D\right) \right) &= \sum_{k > D} \frac{e^{-p(N-1)}\left(p(N-1)\right)^k}{k!}\left(k-D\right) \\ &= p(N-1)\sum_{k \geqslant D} \frac{e^{-p(N-1)}\left(p(N-1)\right)^k}{k!} - D\sum_{k > D} \frac{e^{-p(N-1)}\left(p(N-1)\right)^k}{k!} \\ &< p(N-1)\mathbb{P}_{X \sim Pois(p(N-1))} \left( X \geqslant D \right) \\ &\leqslant p(N-1) \cdot \frac{e^{D-p(N-1)}}{(\frac{D}{p(N-1)} )^D} \tag{large deviation of Poisson distribution.} \end{align*} Since $p = \frac{(4\epsilon - \delta)D}{N}$, so $D-p(N-1) \to -\infty$ when $D \to \infty$. Hence the formula above tends to $0$. This means the expectation number of edges deleted from the graph is $o(N)$. But this number is non-negative, so it is $o(N)$ with high probability. By CLT, the number of edges of $G(N, p)$ lies between $p\binom{N}{2} \pm O(\sqrt{DN})$ with high probability. But $p\binom{N}{2} \approx (4\epsilon - \delta)DN$, so the number of edges in $G$ is greater than $(4\epsilon -\delta - o(1))DN$ with high probability, which means $H$ is not $(1, 2\epsilon - \delta, D)$--expander. For a general $\alpha > 0$, suppose $\frac{1}{2n} \leqslant \alpha < \frac{1}{2(n-1)}$. Take the graph sum of $n-1$ previous constructions with left part cardinality $N$, and one construction with left part cardinality $\left(\frac{1}{2\alpha} - n+1\right)N$. Since $\frac{1}{2\alpha}-n+1 \leqslant 1$, this graph is $(\alpha, \epsilon, D)$--expander, but not $(2\alpha, 2\epsilon - \delta, D)$--expander. \end{proof} \begin{remark} By adjusting the parameters, we can prove this graph is also $(k \alpha, k \epsilon, D)$--expander with high probability for $k \in (0,2)$. So this prove the tightness of lemma \ref{lem:expansion_larger}. \end{remark} \begin{remark} The size of the right part of this construction may greater than the size of the left part, which is not the case we are interested in. This issue could be easily solved by concat a larger expander graph, in which the right part is smaller than the left part. \end{remark} \fi We finish the calculation omitted in Section~\ref{sec:bound_dist} here. We provide one calculation for graphs that is not necessarily regular on the right and another calculation for regular graphs. \begin{proposition}\label{appendix:random_graph} If parameters $\alpha, \epsilon, M, N, D$ satisfies $\left( \frac{e}{\alpha} \right)\cdot\left(\frac{e\alpha ND}{\epsilon M}\right)^{\epsilon D} < 1$, then the probability of a random bipartite graph, where each vertex in $V_L$ has $D$ random neighbros, is $(\alpha N, (1-\epsilon)D)$--expander is close to 1. \end{proposition} \begin{proof} Suppose the left part of the bipartite graph is $[N]$. Fix a subset $X$ of $[N]$ with size $\alpha N$, and let $y_i^1, \cdots, y_i^D$ be the neighbours of the $i$--th vertex in $X$. Then the expansion of $X$ is less than $(1-\epsilon)D$ is equivalent to $\#\left\{y_i^j\right\} < (1-\epsilon)D\alpha N$, where $i \in X$ and $j \in [D]$. Arrange $y_i^j$ in the lexicographic order of $(i, j)$. The probability of the value of $y_i^j$ has been taken before it does not exceeds $\frac{\#\left\{y_{i'}^{j'}\ \middle|\ (i', j') \prec (i, j)\right\}}{M} < \frac{\alpha ND}{M}$. So the probability of the expansion of $X$ is less than $(1-\epsilon)D$ is less than $\binom{\alpha ND}{\epsilon \alpha ND}\cdot \left(\frac{\alpha ND}{M}\right)^{\epsilon \alpha ND}$. Hence, the probability of the random graph is not $(\alpha N, (1-\epsilon)D)$--expander is less than \begin{equation}\label{appendix:formula} \binom{N}{\alpha N}\cdot \binom{\alpha ND}{\epsilon \alpha ND}\cdot \left(\frac{\alpha ND}{M}\right)^{\epsilon \alpha ND} \end{equation} By the approximation of binomial coefficient: $\binom{A}{B} < \left( \frac{eA}{B} \right)^B$, $(\ref{appendix:formula})$ is less than \[ \left(\frac{eN}{\alpha N}\right)^{\alpha N} \cdot \left( \frac{e\alpha ND}{\epsilon\alpha ND} \right)^{\epsilon \alpha ND} \cdot \left(\frac{\alpha ND}{M}\right)^{\epsilon \alpha ND} = \left(\left( \frac{e}{\alpha} \right)\cdot \left( \frac{e\alpha ND}{\epsilon M} \right)^{\epsilon D}\right)^{\alpha N} \] \end{proof} \iffalse Now we choose the parameters to prove the expansion. From the above proposition, we show that when $\alpha$ is sufficiently small, \begin{equation} \label{appendix:formula2} \left( \frac{e}{\alpha} \right)\cdot\left(\frac{e\alpha (N-N')D}{\epsilon (M-M')}\right)^{\epsilon D} < 1. \end{equation} Since $N'<N/2$ and $M'<M/2$ for $M=N/2$ and $\varepsilon D \ge 2$, we choose $\alpha$ such that \[ \left( \frac{e}{\alpha} \right) \cdot \left(\frac{4e\alpha D}{\epsilon }\right)^2 = \frac{4 e^3\alpha D^2}{\epsilon^2} < 1. \] Namely $\alpha=\frac{\varepsilon^2}{8e^3 D^2}$. \fi Given any constant $\varepsilon \in (0, 1)$, by choosing a large enough constant $D$ and let $D_R=\frac{D N}{M}$ be the average degree on the right, Proposition~\ref{appendix:random_graph} immediately implies the following proposition. \begin{proposition}\label{prop:parameterrelation} For any constants $\varepsilon, \eta \in (0, 1)$, there exist a constant $D$ and $(\alpha N, (1-\varepsilon)D)$-expanders such that $\frac{\alpha}{\varepsilon} \geq \frac{1/e-\eta}{D_R}$. \end{proposition} One can also obtain a regular expander by choosing an integer $D_R=\frac{D N}{M}$ and generating $D_R$ permutations. Such a random expander has been proved in \cite{SS96}. We provide an argument for completeness. Here is a technical lemma summarized from \cite{SS96}. \begin{proposition}\label{Prop:regular} Let $B$ be a random $(D, D_R)$--regular bipartite graph with left size $N$ and right size $\frac{D \cdot N}{D_R}$. Then for all $0 < \alpha < 1$, with exponentially high probability all sets of $\alpha n$ vertices in the left part have at least \[ N\left( \frac{D}{D_R}\left( 1-(1-\alpha)^{D_R} \right) - 2\alpha \cdot \sqrt{D \log e/\alpha}\right) \] neighbours \end{proposition} Before we prove this proposition, we show how to choose the parameters to make the expansion at least $(1-\varepsilon)D$. Recall that in the proof of Theorem~\ref{thm:tight_distance} in Section~\ref{sec:bound_dist}, we are looking at a random bipartite graph with $N_1=N-N' \ge N/2$ left vertices, $M_1=M-DN'/2$ right vertices, regular left degree $D$ and regular right degree $D_R=N_1 \cdot D/M_1$. Since $M_1 \ge M/2 \ge N/4$ and $N_1 \le N$, we have $D_R \le 4D$. Next we choose $\alpha = 10^{-3} \cdot (\varepsilon/D)^2$ such that for any $\alpha' \leq 2 \alpha$, $(1-\alpha')^{D_R} \in [1-\alpha' D_R, 1-(1-\varepsilon/2)\alpha' D_R]$ and $1-(1-\alpha')^{D_R} \in \big[ (1-\varepsilon/2) \alpha' D_R, \alpha' D_R \big]$. Note that any subset of size $\alpha N$ has size $\alpha' N_1$ with $\alpha \le \alpha' \le 2 \alpha$. Thus we simplify the bound in the above proposition to get the desired expansion \begin{align*} & N_1\left( \frac{D}{D_R} \cdot (1-\varepsilon/2) \alpha' D_R - 2\alpha' \cdot \sqrt{D \log (e/\alpha')}\right) = N_1 D \alpha' \cdot \left(1-\varepsilon/2 - 2\sqrt{\frac{\log (e/\alpha')}{D}} \right) \\ \ge & N_1D \alpha' \cdot (1-\varepsilon) = \alpha ND \cdot (1-\varepsilon), \end{align*} for a sufficiently large constant $D=D(\varepsilon)$. \begin{proof}[Proof of Proposition~\ref{Prop:regular}] First, we fix a set of $\alpha N$ vertices in the left part, $V$, and estimate the probability that $\Gamma(V)$ is small. The probability of a certain vertex in the right part is contained in $\Gamma(V)$ is at least $1 - (1-\alpha)^{D_R}$. Thus the expected number of neighbours of $V$ is at least $M \cdot (1 - (1-\alpha)^{D_R}) = \frac{nD\left(1-(1-\alpha)^{D_R}\right)}{D_R}$. We will use Azuma inequality to derive that $|\Gamma(V)|$ has a small deviation property, and hence the probability of $|\Gamma(V)|$ less than the expectation minus some deviation is exponentially small. Actually, we number the edges outgoing from V by 1 through $D \alpha N$. Let $X_i$ be the random variable of the expected size of $|\Gamma(V)|$ given the choice of the first $i$ edges leaving from $V$. Clearly, $X_1, \cdots, X_{D \alpha N}$ form a martingale and $|X_{i+1}-X_i| \leqslant 1$. By Azuma's inequality, we have: \[ \mathbb{P}\left( \mathbb{E}\left(X_{D \alpha n}\right) - X_{D \alpha N} > \lambda \sqrt{D \alpha N} \right) < \exp\left( -\lambda^2/2 \right) \] Since there are $\binom{N}{\alpha N}$ choices for the set $V$, it suffices to choose $\lambda$ such that \[ \binom{N}{\alpha N}e^{-\lambda^2/2} \text{ is exponentially small}. \] Since ${N \choose \alpha N} \le (e/\alpha)^{\alpha N}$, we choose $\lambda=2 \cdot \sqrt{\alpha N \cdot \log (e/\alpha)}$ to make it exponentially small. Then the deviation becomes \[ \sqrt{D \alpha N} \cdot 2 \sqrt{\alpha N \cdot \log (e/\alpha)}=2\alpha N \cdot \sqrt{D \log (e/\alpha)} \] \end{proof} \iffalse \begin{remark}\label{appendix:remark} By using \ref{appendix:random_graph}, we could argue that the graph of $G_1$ constructed under \ref{claim:explicit_construction} is $(\alpha N, (1-\epsilon)D)$--expander, which is equivalent to \begin{equation} \label{appendix:formula2} \left( \frac{e}{\alpha} \right)\cdot\left(\frac{e\alpha (N-N')D}{\epsilon (M-M')}\right)^{\epsilon D} < 1 \end{equation} Once we have selected $\epsilon, N, M$ with $M \approx \frac{N}2$, we cut out a sufficiently small part $N', M'$ and use our vertex-edge constructions as mentioned earlier. We may choose $D > \frac{2}{\epsilon}$ and $\alpha < \frac{\epsilon^2(M-M')}{e^3(N-N')^2D^2}$, and hence \[ \left( \frac{e}{\alpha} \right)\cdot\left(\frac{e\alpha (N-N')D}{\epsilon (M-M')}\right)^{\epsilon D} \leqslant \left( \frac{e}{\alpha} \right) \cdot \left(\frac{e\alpha (N-N')D}{\epsilon (M-M')}\right)^2 = \frac{e^3\alpha(N-N')^2D^2}{\epsilon(M-M')} < 1 \] \end{remark} \fi \iffalse \section{Tanner Code distance} \begin{lemma} Let $C_0$ be an $(n_0, k_0, d_0)$ linear code. Let $G$ be a $(\gamma N, (1-\varepsilon)d)$ bipartite expander. Then the Tanner code $T(G, C_0)$ has distance at least $ \frac{1-1/d_0 - o(1)}{\varepsilon} \gamma N$. \end{lemma} \begin{proof} Assume $G$ is a $(\gamma' N, (1-\varepsilon')d)$ bipartite expander. For any left subset $S$ of size $\leq \gamma' N $, the total number of edges connected to vertices in $S $ is $d|S|$ and $|\Gamma(S)| \geq (1-\varepsilon')d)|S|$. Consider an arbitrary codeword in $T$ with $S$ denoting the set of indices of $1$-symbols. There is at least one vertex in $\Gamma(S)$ s.t. its corresponding codeword in $C_0$ has weight at most $$ \frac{d|S|}{|\Gamma(S)|} \leq \frac{d|S|}{(1-\varepsilon')d|S|} = \frac{1}{1-\varepsilon'}. $$ So if we have $\varepsilon' < \frac{d_0-1}{d_0} $ then the above is less than $d_0$, contradicting the definition of Tanner Code. Now consider we start with a $(\gamma N, (1-\varepsilon)d)$ expander. By Lemma \ref{lem:expansion_larger}, it is also a $(k\gamma N, t = (1-k\varepsilon)d-O(dk^2/N) )$ expander. We can view $t$ as $(1-\varepsilon') d$ and let $t > d/d_0 $ s.t. $\varepsilon' < \frac{d_0-1}{d_0}$. When this happens, $k$ can be as large as $ (1-1/d_0 - o(1))/\varepsilon $. So the distance of $T$ is at least $k\gamma N = \frac{1-1/d_0 - o(1)}{\varepsilon} \gamma N$. \end{proof} \section{A random subset has larger expansion in Expectation} Let $G$ be a bipartite graph, left degree $D$, right degree $D'$. \begin{lemma} Assume for a left subset $S$ with $|\Gamma(S)| \geq (1-\varepsilon)D|S|$. Randomly pick a subset $T\subset S$, each vertex picked independently with probability $t/|S|$. Then $$ E|\Gamma(T)| \geq (1-\frac{tD'}{2|S|}\varepsilon). $$ \end{lemma} \begin{proof} To bound $|\Gamma(T)|$, we consider every right vertex $u\in \Gamma(S)$, assuming $u$ has $l$ neighbors $v_1, \ldots, v_l$ in $S$. Notice that $u \in \Gamma(T)$ if and only if $u$ has one neighbor in $T$. By inclusion-exclusion, \begin{align*} |\Gamma(T)| &= \sum_{u\in \Gamma(S)} \left( \sum_{i \in [l]} 1( v_i \in T ) - \sum_{i_1 < i_2 \leq l} 1(v_{i_1} \in T) 1(v_{i_2} \in T) + \cdots + (-1)^{j+1}\sum_{i_1 < i_2 < \cdots< i_j \leq l} \prod_{k=1}^j 1(v_{i_k} \in T) + \cdots \right)\\ & = \sum_{u\in \Gamma(S)} \left( \sum_{i \in [l]} 1( v_i \in T ) - \sum_{j = 2}^{l} (-1)^{j} \sum_{i_1 < i_2 < \cdots< i_j \leq l} \prod_{k=1}^j 1(v_{i_k} \in T) \right) \end{align*} So $$ |\Gamma(T)| \geq \sum_{u\in \Gamma(S)} \left( \sum_{i \in [l]} 1( v_i \in T ) - \sum_{i_1 < i_2 \leq l} 1(v_{i_1} \in T) 1(v_{i_2} \in T) \right)$$ Then \begin{align*} E|\Gamma(T)| &\geq \sum_{u\in \Gamma(S)} \sum_{i \in [l]} \Pr\left[ v_i \in T \right] - \sum_{u\in \Gamma(S)} {l \choose 2} (\frac{t}{|S|})^2 \\ & \geq Dt - (\frac{t}{|S|})^2 \frac{D'}{2}\sum_u (l-1) && ( l \leq D' ) \\ & = Dt - (\frac{t}{|S|})^2 \frac{D'}{2}(D|S| - |\Gamma(S)|) \\ & \geq Dt - (\frac{t}{|S|})^2 \frac{D'}{2} \varepsilon D|S| \\ & = (1-\frac{D't}{2|S|} \varepsilon )Dt \end{align*} \end{proof} \section{ } Let $G$ be a bipartite $(\gamma n , (\frac{1}{2} + \varepsilon)D)$ expander, right degree $D'$. Let $C$ be the expander code based on $\Gamma$. Assume the number of corrupted bits is $k$. \subsection{Integer Programming} \label{IPROG} Consider an integer programming for the following problem. Given a corrupted codeword, a set $L \subseteq [n]$, a integer threshold $t$, the integer programming minimizes the number of unsatisfied checks by only doing flips in $L\subseteq [n]$. The number of flips is bounded by $t$. Let $F_j = \{ S \subseteq \Gamma^{-1}(j) \cap L \mid \mbox{ the } j \mbox{-th check will be false} \mbox{ if bits in } S \mbox{ are flipped} \}$. $\forall j, j'\in [m]$, let $A_{j, j'} = \Gamma^{-1}(j)\cap \Gamma^{-1}(j')$. The integer programming is as follows. \begin{align*} & \min \sum_{j\in [m]} \sum_{S \in F_j} w_{j, S} && (\mbox{Minimize the number of unsatisfied checks})\\ & \forall j\in [m], \quad \sum_{S\subseteq \Gamma^{-1}(j)\cap L} w_{j, S} = 1 && (\mbox{for each } j \mbox{, there is only 1 flip pattern})\\ & \forall j, j'\in [m], T \subseteq A_{j,j'}, \sum_{ S: S \cap A_{j, j'} = T } w_{j, S} = \sum_{S': S'\cap A_{j, j'} = T} w_{j', S'} && (\mbox{Flips should be consistent}) \\ & \sum_{i\in L} \sum_{S \ni i, j} w_{j,S} \frac{1}{D}\leq t. && (\mbox{At most } t \mbox{ flips})\\ & \forall j\in [m], S\subseteq \Gamma^{-1}(j)\cap L, w_{j, S} \in \{0, 1\} \end{align*} $w_{j, S}$ is an indicator variable s.t. $w_{j, S} = 1$ if bits with indices in $S \subseteq \Gamma^{-1}(j)$ are flipped while bits in $\Gamma^{-1}(j)\backslash S$ are not flipped; otherwise $w_{j, S} = 0$. \fi \section{} We give a finding erasure algorithm and then use the Decoding from erasures algorithm in Theorem \ref{thm:vidermandecfromerasures}. \subsection{Find Erasures} Consider the following algorithm: Fix some parameter $x$ which we will choose later, such that $|Corr| =x \alpha N$. In this section we want to maximize $|Corr|$ so we assume $x \geq 1$. Define $h_c=(1-2\frac{|Corr|}{\alpha N}\varepsilon)D=(1-2x \varepsilon)D$. \begin{enumerate} \item Let $R_0=\{\text{all unsatisfied parities}\}$. \item $L'(0)=\emptyset$. \item $R'(0)=R_0$, $t=0$. \item While $\exists i \in [N] \setminus L'(t)$ s.t. $|N(i) \cap R'(t)| \geq h_c$ do \begin{enumerate} \item $L'(t+1)=L'(t) \cup \{i\}$. \item $R'(t+1)=R'(t) \cup N(i)$. \item $t=t+1$. \end{enumerate} \end{enumerate} We have the following claims: \begin{claim} \label{claim:CorrIsInL'1} When the above algorithm stops, we have $Corr \subseteq L'(t)$. \end{claim} We use a similar proof to the proof of 4.3 in \cite{Viderman13b}. \begin{proof} Suppose there is a subset $B \subseteq Corr$ such that $B$ is not contained in $L'(t)$. By the expansion property, the set of unique neighbors of $B$ has size at least $(1-2x\varepsilon)D|B| = h_c|B|$. By the algorithm, every vertex in $B$ has less than $h_c$ neighbors in $R'(t)$. So $B$ has some unique neighbor $v$ not in $R'(t)$. Since $R'(t)$ contains all the neighbors of $Corr \backslash B$, $v$ has to be unsatisfied. Then it has to be included in $R'(0)$ and thus in $R'(t)$. This is a contradiction. \end{proof} Define $Corr_0 = \{i \in Corr \mid |N(i) \cap R_0| \geq h_c \}$, Without loss of generality we can assume we add $Corr_0$ to become $L'(0)$ in the first step and continue from there. This assumption is true by the following claim. \begin{claim} \label{claim:L'allsame} In every iteration, if there are multiple vertices that can be added to $L'$ and we choose one of them arbitrarily, then we always get the same $L'$ after all the iterations. \end{claim} \begin{proof} Consider two different procedures such that they choose different vertices to add to $L'$ in their iterations. Suppose the they get two different $L'$, saying $L_1$ for the first procedure and $ L_2$ for the second. Without loss of generality assume $L_1 \backslash L_2 \neq \emptyset$. Let $u$ be the vertex which is in $L_1 \backslash L_2$ and is the one added first among them in procedure 1. Then all the vertices in $L_1$ added before $u$ is in $L_2$. So for procedure 2 we should have $|N(u)\cap R'| \geq h_c$. Thus $u$ has to be added to $L_2$ in procedure 2. This is a contradiction. Therefore $L_1 = L_2$. \end{proof} Next we borrow the following claim from \cite{Viderman13b}: \begin{claim}[Claim 4.6 from \cite{Viderman13b}] \[|N(Corr_0) \setminus R_0| \leq (D-h_c)|Corr_0| -|R_0|+h_c |Corr|.\] \end{claim} Now we want to bound $|L'(t)|$. \begin{claim} \label{claim:boundOnL'(t)} For every $x$ such that $x < \frac{1}{6\varepsilon}$ and $x\leq \frac{1-2\varepsilon}{2\varepsilon}$, we have $|L'(t)| < \frac{1-2 \varepsilon x}{2 \varepsilon} \alpha N$. \end{claim} \begin{proof} Let $k_0 = \frac{1}{3\varepsilon}$. Suppose this is not true, for some $t$, If for all $t$ we have $|L'(t)| < k_0 \alpha N$ then we are already done. Now before $|L'(t)|$ exceeds $k_0 \alpha N$. Let $|L'(t)|=k \alpha N$. When $k\geq 1$, we have \begin{align*} (1-\frac{|L'(t)|}{\alpha N}\varepsilon)D |L'(t)| & \leq |N(L'(t))| \leq |R_0|+|N(Corr_0) \setminus R_0|+(D-h_c)(|L'(t)|-|Corr_0|) \\ & \leq (D-h_c)|Corr_0|+h_c |Corr|+(D-h_c)(|L'(t)|-|Corr_0|)\\ & =(D-h_c)|L'(t)| +h_c |Corr| =2x \varepsilon D|L'(t)|+(1-2x \varepsilon)D|Corr|\\ \end{align*} Plug into the above inequality and simplify, we get \[(1-k \varepsilon)k \leq 2 x \varepsilon k+(1-2 x \varepsilon) x.\] and \[(1-2\varepsilon x)k -\varepsilon k^2 \leq x-2 \varepsilon x^2.\] The LHS is maximized at $k_0= \frac{1-2 \varepsilon x}{2 \varepsilon}$ with a value of $\frac{(1-2 \varepsilon x)^2}{4 \varepsilon}$. Since $x\leq \frac{1-2\varepsilon}{2\varepsilon}$, we have $k_0 \geq 1$. On the other hand, as $x < \frac{1}{6\varepsilon}$, it must be $\frac{(1-2 \varepsilon x)^2}{4 \varepsilon} > x-2 \varepsilon x^2$. So $k$ has to be less than $k_0$. \end{proof} \begin{theorem} Let $G$ be a $(\alpha N, (1-\varepsilon) D)$ expander with $\varepsilon \leq 1/6 $. The expander code defined by $G$ has an efficient decoding algorithm with decoding radius $(\frac{1}{6\varepsilon}-o(1))\alpha N$. \end{theorem} \begin{proof} Consider that we are decoding from erasures in Corr, where $|Corr| = x\alpha N$. We first run the finding erasures algorithm. By Claim \ref{claim:CorrIsInL'1}, we know Corr is contained in $L'(t)$. When $\varepsilon \leq \frac{1}{6}$, if $ x\alpha N$ is any number less than $\frac{\alpha N}{6 \varepsilon} $, then by Claim \ref{claim:boundOnL'(t)}, we must have $|L'(t)| \leq \frac{1}{3\varepsilon} \alpha N$. By Lemma \ref{lem:expansion_larger}, the expander is a $(\frac{1}{3\varepsilon} \alpha N, \frac{2}{3}D)$ expander. So it is also a $(\frac{1}{3\varepsilon} \alpha N, \frac{1}{3}D)$ unique expander. Hence by Theorem \ref{thm:vidermandecfromerasures}, using $L'(t)$ and the corrupted codeword, we can decode correctly. \end{proof} \fi \section{Parallel algorithm} Let $\mathcal{C}$ be the expander code of a $(\alpha N, (1-\varepsilon)D)$-expander. We know the distance is $\frac{\alpha N}{2\varepsilon}$. Consider the following algorithm: \begin{enumerate} \item In parallel, flip each variable whose $(1-2\varepsilon)D$ neighbors are not satisfied. \item Repeat until no such variable ramains. \end{enumerate} Our main result is the decoding distance. \begin{claim} For any $\varepsilon<1/4$, the above algorithm corrects more than $(\frac{1-2\varepsilon}{4\varepsilon}-o(1)) \cdot \alpha$ fraction errors. \end{claim} Remark: $\frac{1-2\varepsilon}{4\varepsilon}$ is always larger than $\frac{1-3 \varepsilon}{1-2\varepsilon}$ for $\varepsilon<1/4$. \begin{proof} We follow the anaylsis of Theorem 11 \cite{SS96} to argue that the errors reduce in every round. Let $V$ denote the set the corrupted variables on the L.H.S. We use $F \subset V$ to denote those corrupted variables donot flip in this round and $C \subset \overline{V}$ to denote the uncorrupted variables get flipped in this round. So we wanna show $|V| > |F| + |C|$. First of all, we wanna claim $|V \cup C| < k \cdot \alpha n$ for \[k=\frac{1-2\varepsilon}{2\varepsilon} - o(1). \] Without loss of generality, we assume $|V \cup C|=k \alpha n$ and $\delta$ is the expansion of $V$: $N(V)=\delta D \cdot |V|$. Because each variable in $C$ contributes at most $2 \epsilon D$ new neighbors to this union, \[ |N(V \cup C)| \le \delta D \cdot |V| + 2\epsilon D \cdot (k \alpha n - |V|). \] At the same time, by the guarantee of expander graphs, \[ |N(V \cup C)| \ge (1 - k \epsilon) D \cdot k \alpha n. \] So we combine them together and cancel $D$ to obtain \[ (k - k^2 \epsilon - 2 k \epsilon) \alpha n \le (\delta - 2 \epsilon) |V|. \] Since $\delta \le 1$, $|V| \ge \frac{k - k^2 \epsilon - 2 k \epsilon}{1-2\varepsilon} \alpha n$, which is contradicted to the assumption of $|V|$ given \[k - k^2 \epsilon - 2 k \epsilon=(1-2 \epsilon)^2/4\varepsilon - o(1) \] for our choice of $k$. So $|V \cup C| < k \alpha n$ gives us the lower bound on $|N(V \cup C)|$: \begin{equation}\label{eq:neighbors_V_C} (1 - k\varepsilon)D \cdot (|V|+|C|) \le |N(V \cup C)| \le \delta D \cdot |V| + 2 \epsilon D \cdot |C|. \end{equation} Now we bound $\delta D \cdot |V|$ using $F$. Note that each variable in $F$ does not get flipped because it shares at least $2 \varepsilon D$ neighbors with other variables in $V$. In the worst case, these $2 \varepsilon D$ neighbors are shared with other variables in $F$. So $F$ contribute at most $(1-\varepsilon)D \cdot |F|$ neighbors. Then we have \[ \delta D \cdot |V| \le (1 - \varepsilon) D \cdot |F| + D(|V|-|F|)=D(|V|-\varepsilon|F|). \] If we plug this into \eqref{eq:neighbors_V_C}, we conclude \[ (1 - k \varepsilon)D \cdot (|V|+|C|) \le D(|V| - \varepsilon|F|)+ 2\varepsilon D \cdot |C|. \] This shows \[ (1 - k \varepsilon - 2 \varepsilon) |C| + \varepsilon |F| \le k \varepsilon \cdot |V|. \] Given $k \in (1,\frac{1-2\varepsilon}{2\varepsilon})$, we have $k \varepsilon < (1-k \varepsilon - 2 \varepsilon)$. This gives $|V|>|C|+|F|$. \textcolor{red}{This line is problematic.} \end{proof} It may be worth to check previous work \cite{FMSSW07,Viderman13,Viderman13b} and the reference therein about the improvement upon \cite{SS96}. \section{Adaptive Threshold} We consider using multiple thresholds in this section. Let $x \alpha N$ denote the size of corruption $F$. For ease of exposition, we fix $x=1/5\varepsilon$ in the rest calculation. Let $1-\gamma x$ be the expansion of $F$ such that $\Gamma(F)=(1-\gamma x)D \cdot x \alpha N$. We choose the first threshold to be $(1-C \gamma x)D$ for some $C \in [2,\frac{3+\sqrt{5}}{2}-o(1)]$ (we will see the calculation of $C$ later). \begin{remark} By the definition, $\gamma \in [0,\varepsilon]$ and $C \in [2,2.6]$. While we donot know $\gamma$ at the beginning, we could always enumerate $\gamma$ in a polynomial time algorithm (at least for the first threshold). \end{remark} Let $R_0$ be the wrong parity checks on the left hand side and $L_0=\{v | \Gamma(v) \cap R_0 \ge (1-C \gamma x)D\}$. We still use $C_0 = L_0 \cap F$ to denote corrupted vertices in $L_0$. For convenience, let $\delta \alpha N$ denote the number of wrong marked vertices in $L_0$, i.e., $|L_0 \setminus F|$. \begin{claim} Given our parameter $x\varepsilon=1/5$, $\gamma$, and $C=\frac{3+\sqrt{5}}{2} - o(1)$, $\delta \le \frac{\frac{3}{5}-\frac{3+\sqrt{5}}{2} \cdot \gamma x}{2\varepsilon} - o(1)$. \end{claim} \begin{proof} We will consider the expansion of $L_0 \cup F$, whose size is $(\delta + x) \alpha N$. By Lemma~\ref{lem:expansion_larger}, it is at least $\bigg( 1 - (\delta + x)\varepsilon \bigg) D \cdot (\delta+x) \alpha N$. On the other hand, we know $\Gamma(F)=(1-\gamma x)D \cdot x \alpha N$ by the definition of $\gamma$ and each vertex in $L_0 \setminus F$ will contribute at most $C \gamma x D$ vertices to $\Gamma(L_0 \cup F)$. To show the existence of $\delta$, we provide a $\delta$ such that (after normalizing $D \alpha N$) \[ (1 - (\delta+x)\varepsilon) \cdot (\delta + x) \ge (1-x \gamma)x + C\gamma x \delta. \] This is equivalent to show \[ 0 \ge \varepsilon (\delta + x)^2 - \delta - \gamma x^2 + C \gamma x \delta = \varepsilon \delta^2 + (2\varepsilon x +C \gamma x - 1)\delta + (\varepsilon-\gamma)x^2. \] So we only need to show the right quadratic polynomial has two roots. Namely, \begin{equation}\label{eq:bsquare4ac} (2\varepsilon x +C \gamma x - 1)^2 - 4 \varepsilon \cdot (\varepsilon-\gamma)x^2 > 0 \end{equation} such that the above quadratic equation of $\delta$ has two roots. We set $\beta:= \gamma x$ and plug $\varepsilon x=1/5$ to simplify \eqref{eq:bsquare4ac} as \[ (C \beta - 3/5)^2 - 4/25 + 4\beta/5 = C^2 \beta^2 + (4/5 - 6C/5) \beta + 1/5 > 0. \] Since $\gamma$ could be any number in $[0,\varepsilon]$, we choose $C$ such that the above inequality is always true. Namely we want it does not have a root: \[ 0 > (4/5-6C/5)^2 - 4 C^2 /5 = 36 C^2 /25 - 48 C/25 + 16/25 - 4C^2/5. \] So we get \[ C^2 - 3C + 1 < 0 \Rightarrow C \in \left( \frac{3-\sqrt{5}}{2},\frac{3+\sqrt{5}}{2} \right). \] Thus we choose $C=\frac{3+\sqrt{5}}{2} - o(1)$ and get $\delta = \frac{2\varepsilon x + C \gamma x - 1}{2\varepsilon} \pm o(1)$. \end{proof} \begin{corollary} Given $x \ge 1$ such that $x \varepsilon=1/5$, let $F$ be the set of flipped coordinates of size $x \alpha N$. If $N(F)=(1-\beta)D \alpha N$ for $\beta:=\gamma x$ in $[0,1/20] \cup [0.18,0.2]$, we can choose $C$ properly such that $|L_0 \setminus C_0| < |C_0|$. This means we only need to flip all bits in $L_0$ to reduce the error for particular values of $\beta$. \end{corollary} \begin{proof} From the above calculation, we know $|L_0 \setminus C_0| \le \delta \alpha N$ for \[ \delta \le \frac{1-2\varepsilon x - C \gamma x - \sqrt{(1-2\varepsilon x - C \gamma x)^2 - 4 \varepsilon^2 x^2 + 4 \varepsilon x \gamma x}}{2\varepsilon}. \] After plugging $\varepsilon x=1/5$ and $\beta:=\gamma x$, this becomes \[ \delta \le \frac{\frac{3}{5} - C \beta - \sqrt{(\frac{3}{5} - C \beta)^2 - \frac{4}{25} + \frac{4}{5} \beta}}{2\varepsilon}. \] At the same time, $C_0/\alpha N$ is at least \[ x \cdot (1 - 2 \beta / C \beta) = \frac{1-2/C}{5 \varepsilon}. \] So we wanna show for some $\beta$, \[ \frac{\frac{3}{5} - C \beta - \sqrt{(\frac{3}{5} - C \beta)^2 - \frac{4}{25} + \frac{4}{5} \beta}}{2\varepsilon} \le \frac{1-2/C}{5 \varepsilon}. \] When $\beta \le 1/20$, we could choose $C=1/5\beta$, that is at least 4. So it becomes to verify \[ \frac{\frac{3}{5} - \frac{1}{5} - \sqrt{ \frac{4}{5} \beta}}{2\varepsilon} \le \frac{1-10 \beta}{5 \varepsilon}. \] We verify it as \[ 1 - \sqrt{5 \beta} \le 1 - 10 \beta. \] For $\beta \in [0.18,0.2]$, we could choose $C \in [2.4,2.6]$ to show the same thing. \end{proof} \subsection{Attempt 0} \textcolor{red}{Xue: I donot know what is the best way to finish the argument. Here is some naive attempt.} Let us consider $C \ge 2.2$ and $x=1.1$ such that we only need to reset the threshold once. A natural choice of the threshold is $h_1=(1-2\varepsilon)D$ (\textcolor{red}{Xue: One question here --- shall we choose $h_1$ that depends on $\gamma$?}) and apply the algorithm in Section~\ref{sec:improved}. To finish the argument, we wanna show the existence of $\delta_1$ such that \[ (1 - (x+\delta + \delta_1)\varepsilon) \cdot (x+\delta + \delta_1) \ge (1-\gamma x) x + C \gamma x \delta + 2 \varepsilon \delta_1 \] By the same simplification, we get \[ \delta + \delta_1 - (x+\delta + \delta_1)^2 \varepsilon \ge - \gamma x^2 + C \gamma x \delta + 2\varepsilon \delta_1. \] For $x=1$ and $\varepsilon=1/5$, we get \[ 0 > (1+\delta+\delta_1)^2 /5 - \delta - \delta_1 - \gamma + C \gamma \delta + \frac{2}{5} \delta_1 = \delta_1^2/5 + (2/5 + 2 \delta/5 -1 + 2/5)\delta_1 + (1+\delta)^2/5 - \gamma + C \gamma \delta. \] So our goal is to show $\delta_1$, which depends on $\delta,C,\gamma$, such that \[ 0 > \delta_1^2/5 + (2 \delta/5 -1/5)\delta_1 + (1+\delta)^2/5 - \gamma + C \gamma \delta. \] \subsection{OLD material} We consider use two thresholds $h_0$ and $h_1$. Let $x \alpha N$ be the upper bound of $Corr$ and $k \alpha N$ be the upper bound of $L(t)$. We plan to set $h_0 < (1-2x \varepsilon)D$ (say $h_0=(1-3x \varepsilon)D$) such that $bad$ is small and $h_1 > (1-2x \varepsilon)D$. So the inequality becomes \[ (1-k \varepsilon)k \le R_0 + N(Corr_0)\setminus R_0 + N(L_0) \setminus ( N(Corr_0) \cup R_0) + (D-h_1) \cdot (k-L(0)) \] One way to upper bound the right hand side is \[ h_0 \cdot |Corr| + (D-h_0) \cdot |Corr_0| + (D-h_0) \cdot |L(0) \setminus Corr_0| + (k - L(0)) \cdot (D- h_1) = h_0 \cdot |Corr| + (h1-h_0) \cdot |L(0)| + (D-h_1)k. \] As a first step, we wanna bound $L(0)$. Let $\delta$ denote the fraction of $L(0)\setminus |Corr_0|$. In the worst case --- $Corr_0=Corr$, we could consider \[ (1 - (x+\delta)\varepsilon) \cdot (x+\delta) \le x + (1-h_0) \cdot \delta. \] However, to upper bound $\delta$, this seems to force $x \varepsilon \le 1/6$ for $h_0 \le (1-2x \varepsilon)$. \section{Parallel algorithm} Let $\mathcal{C}$ be the expander code of a $(\alpha N, (1-\varepsilon)D)$-expander. We know the distance is $\frac{\alpha N}{2\varepsilon}$. Consider the following algorithm: \begin{enumerate} \item In parallel, flip each variable whose $(1-2\varepsilon)D$ neighbors are not satisfied. \item Repeat until no such variable ramains. \end{enumerate} Our main result is the decoding distance. \begin{claim} For any $\varepsilon<1/4$, the above algorithm corrects more than $(\frac{1-2\varepsilon}{4\varepsilon}-o(1)) \cdot \alpha$ fraction errors. \end{claim} Remark: $\frac{1-2\varepsilon}{4\varepsilon}$ is always larger than $\frac{1-3 \varepsilon}{1-2\varepsilon}$ for $\varepsilon<1/4$. \begin{proof} We follow the anaylsis of Theorem 11 \cite{SS96} to argue that the errors reduce in every round. Let $V$ denote the set the corrupted variables on the L.H.S. We use $F \subset V$ to denote those corrupted variables donot flip in this round and $C \subset \overline{V}$ to denote the uncorrupted variables get flipped in this round. So we wanna show $|V| > |F| + |C|$. First of all, we wanna claim $|V \cup C| < k \cdot \alpha n$ for \[k=\frac{1-2\varepsilon}{2\varepsilon} - o(1). \] Without loss of generality, we assume $|V \cup C|=k \alpha n$ and $\delta$ is the expansion of $V$: $N(V)=\delta D \cdot |V|$. Because each variable in $C$ contributes at most $2 \epsilon D$ new neighbors to this union, \[ |N(V \cup C)| \le \delta D \cdot |V| + 2\epsilon D \cdot (k \alpha n - |V|). \] At the same time, by the guarantee of expander graphs, \[ |N(V \cup C)| \ge (1 - k \epsilon) D \cdot k \alpha n. \] So we combine them together and cancel $D$ to obtain \[ (k - k^2 \epsilon - 2 k \epsilon) \alpha n \le (\delta - 2 \epsilon) |V|. \] Since $\delta \le 1$, $|V| \ge \frac{k - k^2 \epsilon - 2 k \epsilon}{1-2\varepsilon} \alpha n$, which is contradicted to the assumption of $|V|$ given \[k - k^2 \epsilon - 2 k \epsilon=(1-2 \epsilon)^2/4\varepsilon - o(1) \] for our choice of $k$. So $|V \cup C| < k \alpha n$ gives us the lower bound on $|N(V \cup C)|$: \begin{equation}\label{eq:neighbors_V_C} (1 - k\varepsilon)D \cdot (|V|+|C|) \le |N(V \cup C)| \le \delta D \cdot |V| + 2 \epsilon D \cdot |C|. \end{equation} Now we bound $\delta D \cdot |V|$ using $F$. Note that each variable in $F$ does not get flipped because it shares at least $2 \varepsilon D$ neighbors with other variables in $V$. In the worst case, these $2 \varepsilon D$ neighbors are shared with other variables in $F$. So $F$ contribute at most $(1-\varepsilon)D \cdot |F|$ neighbors. Then we have \[ \delta D \cdot |V| \le (1 - \varepsilon) D \cdot |F| + D(|V|-|F|)=D(|V|-\varepsilon|F|). \] If we plug this into \eqref{eq:neighbors_V_C}, we conclude \[ (1 - k \varepsilon)D \cdot (|V|+|C|) \le D(|V| - \varepsilon|F|)+ 2\varepsilon D \cdot |C|. \] This shows \[ (1 - k \varepsilon - 2 \varepsilon) |C| + \varepsilon |F| \le k \varepsilon \cdot |V|. \] Given $k \in (1,\frac{1-2\varepsilon}{2\varepsilon})$, we have $k \varepsilon < (1-k \varepsilon - 2 \varepsilon)$. This gives $|V|>|C|+|F|$. \textcolor{red}{This line is problematic.} \end{proof} It may be worth to check previous work \cite{FMSSW07,Viderman13,Viderman13b} and the reference therein about the improvement upon \cite{SS96}. \iffalse We split $S$ into $k$ subsets $S_1,\ldots, S_k$ where each $S_i$ is of size at most $\gamma/2 \cdot N$. From the property of $G$, we know \begin{equation}\label{eq:bound_S_i} |\Gamma(S_i)| \in [(1-\varepsilon) d \cdot |S_i|, d \cdot |S_i|] \end{equation} and \begin{equation}\label{eq:bound_S_i_j} |\Gamma(S_i \cup S_j)| \in [(1-\varepsilon) d \cdot |S_i \cup S_j|, d \cdot |S_i \cup S_j|]. \end{equation} Now we lower bound $\Gamma(S_1\cup S_2 \cdots \cup S_k)$ by \begin{align*} \sum_{i=1}^k |\Gamma(S_i)| - \sum_{i<j} |\Gamma(S_i) \cap \Gamma(S_j)| & = \sum_{i<j} |\Gamma(S_i \cup S_j)| - (k-2) \sum_i |\Gamma(S_i)| \\ & \ge \sum_{i<j} (1-\varepsilon) d \cdot |S_i \cup S_j| - (k-2) \sum_i d |S_i| \tag{by bounds in \eqref{eq:bound_S_i} and \eqref{eq:bound_S_i_j}}\\ & = (1-\varepsilon)d \cdot (k-1) \cdot |S| - (k-2)d |S|\\ & = \left(1 - (k-1)\varepsilon \right) d |S|. \end{align*} \end{proof} \begin{remark} One intriguing question is whether we could improve it using more levels in the approxiation of inclusion-exclusion formula. For example, when $|S|=3/2 \cdot \gamma N$, we could split it into 6 subsets of size $\gamma /4 \cdot N$ instead of 3 subsets of size $\gamma /2 \cdot N$. Then we have \begin{align*} |\Gamma(S)| & \ge \sum_{i} |\Gamma(S_i)| - \sum_{i_1<i_2} |\Gamma(S_{i_1} \cap S_{i_2})| + \sum_{i_1<i_2<i_3} |\Gamma(S_{i_1} \cap S_{i_2} \cap S_{i_3})| - \sum_{i_1<i_2<i_3<i_4} |\Gamma(S_{i_1} \cap S_{i_2} \cap S_{i_3} \cap S_{i_4}|\\ & = \sum_{i_1<i_2<i_3<i_4} |\Gamma(S_{i_1} \cup S_{i_2} \cup S_{i_3} \cup S_{i_4}| - 2 \sum |\Gamma(S_{i_1} \cup S_{i_2} \cup S_{i_3})| + 3 \sum |\Gamma(S_{i_1} \cup S_{i_2})| - 4\sum |\Gamma(S_i)|. \end{align*} But I didnot see a way to improve the parameter. \end{remark} \paragraph{Distance.} As suggested by Xin, \[ dist(C) \ge \min_{|\Gamma(T)| \le d/2 \cdot |T|} |T|. \] Now we recalculate the distance. \begin{enumerate} \item If $\frac{1/2}{\varepsilon}$ is not an integer, we set $k=[\frac{1/2}{\varepsilon}]+1$. By Lemma~\ref{lem:expansion_larger}, any subset of size $k \cdot \gamma/2 \cdot N$ has $|\Gamma(S)| \ge (1-(k-1)\varepsilon) d |S|$. So the number of unique neighbors is $(1-2(k-1)\varepsilon) d |S|>0$. Then we could add at least another $(1-2(k-1)\varepsilon) |S|$ vertices to $S$ to kill all unique neighbors. So the distance is \[ |S|+(1-2(k-1)\varepsilon) |S| = \left( 1 + 1-2(k-1)\varepsilon \right)\cdot k \cdot \gamma/2 \cdot N. \] \item If $\frac{1/2}{\varepsilon}$ is an integer, by a similar calculation, the distance turns out to be exact \[ (k+1) \cdot \gamma/2 \cdot N \text{ for } k=\frac{1/2}{\varepsilon}. \] \end{enumerate} \section{Adaptive Threshold} \textcolor{red}{This result is problematic unless we can upper bound $|corr\setminus corr_0|$.} Consider the following algorithm with an adaptive threshold $h_t$: $h_t=(1-2\varepsilon)D$ for $L'(t) \le 2 \alpha N$ and $h_t = (1-\varepsilon \cdot \frac{L'(t)}{\alpha N})D$ for $L'(t) > 2 \alpha N$. \begin{enumerate} \item Let $R_0=\{\text{all unsatisfied parities}\}$. \item $L'(0)=\emptyset$. \item $R'(0)=R_0$, $t=0$. \item While $\exists i \in [N] \setminus L'(t)$ s.t. $|N(i) \cap R'(t)| \geq h_t$ do \begin{enumerate} \item $L'(t+1)=L'(t) \cup \{i\}$. \item $R'(t+1)=R'(t) \cup N(i)$. \item $t=t+1$. \end{enumerate} \end{enumerate} If Claims 5.1 and 5.2 hold, we bound $L'(t)$ and $|Corr|$ given $\varepsilon$. Let $k \alpha N$ be the upper bound of $L'(t)$. Similar to the above argument, let $h_0=(1-2\varepsilon)D$ in the following calculation. \begin{align*} (1- \frac{L'(t)}{\alpha N} \varepsilon) \cdot D \cdot |L'(t)| \le & |N(L'(t))| \\ & \le |R_0| + |N(Corr_0)\setminus R_0| + \sum_{j=2 \alpha N + 1}^{k \alpha N} (1-\varepsilon \cdot \frac{L'}{\alpha N})D\\ & \le (D-h_0) \cdot |Corr_0| + h_0 |Corr| + (D-h_0) \cdot (2 \alpha N - |Corr_0|) + \frac{\varepsilon D}{\alpha N} \sum_{j=2\alpha N + 1}^{k \alpha N} j \\ & \le (1-2\varepsilon)D \cdot |Corr| + 2 \varepsilon D \cdot 2 \alpha N + \frac{\varepsilon D}{\alpha N} \cdot \frac{(k-2) \alpha N \cdot \big( (k+2) \alpha N + 1)}{2} \end{align*} We remove the common factor $D$ and normalize both sides by $\alpha N$ to get \[ (1-k \varepsilon) \cdot k \le (1-2 \varepsilon) \frac{|Corr|}{\alpha N} + 4 \varepsilon + \varepsilon \frac{k^2 -4}{2} + \varepsilon \frac{k-2}{\alpha N}. \] Then we omit the last term $\varepsilon \frac{k-2}{\alpha N}$ to get \[ \frac{|Corr|}{\alpha N} \ge \frac{k - 1.5 \varepsilon k^2 - 2\varepsilon }{1 - 2 \varepsilon}. \] For $k=\frac{1}{3\varepsilon}$, the right hand side is about $$\frac{\frac{1}{6\varepsilon} - 2\varepsilon}{1 - 2\varepsilon}.$$ This is slightly better than $1/6\varepsilon$ when $\varepsilon < 1/6$. One restriction of this calculation is that $k>2$ implies $\varepsilon<1/6$. \fi \section{Improved Unique Decoding} Let $\mathcal{C}$ be an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander $\Gamma: [N] \rightarrow [M]$. \subsection{Decoding algorithm for the case $\varepsilon \in (1/6,1/4]$} Consider Algorithm \ref{alg:FindingErasure} with a fixed threshold $\Delta = \varepsilon$. Let the set of errors be $F$ and assume $|F| = x\alpha N$. \begin{claim} \label{claim:errors_in_L} If $x \leq 1$, then when the algorithm stops, we have $F \subseteq L$. \end{claim} \begin{proof} As $x\leq 1$, for every $B\subseteq F$, $|\Gamma(B)| \geq (1-\varepsilon)D|B|$. Hence $|\Gamma^1(B)| \geq (1-2\varepsilon)D|B|$. By Lemma \ref{lemma:all_errors_in_L}, we have $F\subseteq L$, when the algorithm stops. \end{proof} \begin{claim} \label{claim:bound_L} If $\varepsilon \leq 1/4$, then for every $x < \frac{1-2\varepsilon}{4 \varepsilon} - O(1/N)$, $|L| \leq \frac{1-2 \varepsilon}{2 \varepsilon}\alpha N$, when the algorithm stops. \end{claim} Let $R_0$ be the set of unsatisfied checks. Let $F_0$ be the set of errors such that for every $i\in F_0$, $|\Gamma(i)\cap R_0 |\geq (1-2\varepsilon)D$. \begin{proof} Let $L = k \alpha N \geq \alpha N$. By a similar argument to \cite{Viderman13b} we can have \textcolor{red}{Xue: Shall we call Lemma~\ref{lemma:L'allsame}?} \begin{align*} (1-\frac{|L|}{\alpha N}\varepsilon)D |L| - O(1) \leq |\Gamma(L)| & \leq |R_0|+|\Gamma(F_0) \setminus R_0|+(D-h_c)(|L|-|F_0|) \\ & \leq (D-h_c)|F_0|+h_c |F|+(D-h_c)(|L|-|F_0|)\\ & =(D-h_c)|L| +h_c |F| \\ &=2x \varepsilon D|L|+(1-2x \varepsilon)D|F|. \end{align*} Here the first inequality is due to Lemma \ref{lem:expansion_larger}. The second inequality is due to the following. At the beginning we set $R = R_0$. Then by Lemma \ref{lemma:L'allsame}, we can consider that $L$ is generated by first adding all vertices in $F_0$ to $L$ and then add other vertices in $L$. Right after adding $F_0$ to $L$, $R$ is at most $|R_0| + |\Gamma(F_0) \setminus R_0| $. By adding each vertex in $L\setminus F_0$, the size of $R$ increases by at most $D-h_c$. The third inequality is since $ |R_0|+|\Gamma(F_0) \leq (D-h_c)|F_0|+h_c |F|$ by Claim 4.6 of \cite{Viderman13b}.\textcolor{red}{XUe: We may wanna rewrite it or summarize this in Section 3.} So we get \[ (1-k \varepsilon)k -O(1/N) \le 2 \varepsilon k + (1-2\varepsilon)x. \] So it becomes \[ (1-2 \varepsilon)k - \varepsilon k^2 \le (1-2\varepsilon)x + O(1/N). \] Let $k_0 = \frac{1-2 \varepsilon}{2 \varepsilon}$. Since $\varepsilon \leq 1/4$, $k_0 \geq 1$. Suppose $k$ reaches $k_0 $, which maximizes the left hand side to be $ \frac{(1-2\varepsilon)^2}{4 \varepsilon}$. But when $x < \frac{1-2\varepsilon}{4 \varepsilon} - O(1/N)$ the right hand side is less than $ \frac{(1-2\varepsilon)^2}{4 \varepsilon}$. So $k$ can not reach $k_0$. \end{proof} \begin{theorem} Let $\Gamma$ be a $(\alpha N, (1-\varepsilon) D_L)$ expander with $\varepsilon \in [1/6, 1/4] $. The expander code defined by $\Gamma$ has an efficient decoding algorithm with decoding radius $(\frac{1-2\varepsilon}{4\varepsilon})\alpha N - O(1)$. \end{theorem} The whole decoding algorithm is as follows. \begin{algorithm}[h] \caption{Fixed Find and Decode}\label{alg:FixedFindAndDecode} \begin{algorithmic}[1] \Function{FixedFindAndDecode}{$C \in \mathbf{F}_2^N$} \State $L \gets $ \Call{Find}{$C, \varepsilon$} \State Apply Theorem \ref{thm:vidermandecfromerasures} with $L$ and $C$ to get a codeword $C'$. \State \Return $C$ \EndFunction \end{algorithmic} \end{algorithm} \begin{proof} Let $C$ be a corrupted codeword. Let $F$ be the set of errors. We run Algorithm \ref{alg:FixedFindAndDecode} on $C$. As $\varepsilon \geq 1/6$, $\frac{1-2\varepsilon}{4 \varepsilon} \leq 1$. Thus by Claim \ref{claim:errors_in_L}, $F$ is contained in $L$ after finding erasures. As $|F| = x\alpha N \leq \frac{1-2\varepsilon}{4\varepsilon}\alpha N - O(1)$ and $\varepsilon \leq 1/4$, by Claim \ref{claim:bound_L}, $L$ has size at most $k_0 \alpha N = \frac{1-2 \varepsilon}{2 \varepsilon}\alpha N $, which is at least $\alpha N$, since $\varepsilon \leq 1/4$. Notice that $\Gamma$ is an $(\alpha N, (1-\varepsilon) D)$ expander, and $1-k_0\varepsilon-O(1/N)>1/2$. Hence by Theorem \ref{thm:decfromerasures}, we can regard $C$ as having erasures in $L$ and then decode from these erasures. \end{proof} \subsection{Guess threshold for the case $\varepsilon \leq 1/6$} Consider the expander code on an $(\alpha N, (1-\varepsilon)D)$ bipartite expander $\Gamma$. We provide an efficient algorithm to decode more errors in this section by guessing the expansion of the corrupted set. We describe our algorithm in Algorithm~\ref{alg:decoding_small_eps}. \begin{algorithm}[h] \caption{Decoding Algorithm for $\varepsilon\le 1/6$}\label{alg:decoding_small_eps} \begin{algorithmic}[1] \Function{Decoding}{$C \in \mathbf{F}_2^N$ } \For {all possible size $x \alpha N$ of $F$} \For {all possible expansion $(1-\gamma) \cdot D |F|$} \If{$\gamma x \ge \varepsilon$} \State $\Delta \gets \sqrt{\gamma x \varepsilon}$ \Else \State $\Delta \gets \varepsilon$ \EndIf \State $C' \gets $ \Call{Find}{$C \in \mathbf{F}_2^n$ and $\Delta$} \State \Return $C'$ if $d(C,C')\le \frac{\alpha}{4 \varepsilon} N$ \EndFor \EndFor \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} \label{thm:guessexpansion} Consider the expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander. For $\varepsilon< \frac{3-2\sqrt{2}}{2}$, Algorithm~\ref{alg:decoding_small_eps} is a decoding algorithm which corrects at least $\frac{\sqrt{2}-1}{2\epsilon} \alpha N $ errors. Next for $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/6]$, Algorithm~\ref{alg:decoding_small_eps} corrects at least $\frac{1-2\varepsilon}{4\varepsilon} \alpha N - O(1)$ errors. \end{theorem} \textcolor{red}{Remark: (1) I am hiding some small terms in $O(1)$. (2) I did not try to optimize the running time at this moment.} \begin{proof} We prove the correctness of Algorithm~\ref{alg:decoding_small_eps} in the rest of this section. Again $F$ always denotes the subset of entries that are flipped by the adversary. Since we enumerate both $x$ for $|F|=x \alpha N$ and $\gamma$ for $\Gamma(F)=(1-\gamma)D|F|$ over all possible values, we assume $x \alpha N$ denotes the correct size of $F$ and $\gamma$ denotes the correct expansion of $F$ such that $\Gamma(F)=(1-\gamma) \cdot D |F|$ in the analysis. First of all, we bound the expansion of all subsets in $F$. \begin{claim}\label{clm:worst_expansion} For any $F$ with $|F|=x \alpha N$ and $|\Gamma(F)|=(1-\gamma) \cdot D |F|$, our choice of $\Delta$ always satisfies that \[ \forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|. \] \end{claim} \begin{proof} Let $F'$ be the subset of $F$ with the worst expansion, say $|F'|=x' \cdot \alpha N$ and $|\Gamma(F')|=(1-\gamma')D \cdot |F'|$. If $x' \le 1$, $|\Gamma(F')| \ge (1-\varepsilon) \cdot D |F'|$ by the property of $\Gamma$. This is at least $(1-\Delta)D|F'|$ since $\Delta$ is always at least $\varepsilon$ in the algorithm. Otherwise, we consider the collisions in $\Gamma(F)$ and $\Gamma(F')$. Since $F'$ is a subset of $F$ of size $x' \cdot \alpha N$, $|\Gamma(F')| \ge (1-x' \cdot \varepsilon) D \cdot x' \alpha N - O(1)$. So we have \[ x' \alpha N \cdot (x' \cdot \varepsilon) + O(1) \le |F| \cdot \gamma, \] because a collision in $\Gamma(F')$ is also a collision in $\Gamma(F)$. This implies $x' \cdot \varepsilon \le \sqrt{\varepsilon x \gamma} = \Delta$ and hence shows the claim. \end{proof} Given the guarantee in Claim~\ref{clm:worst_expansion}, one could show $L$ covers all the errors. \begin{claim} \label{claim:FsubseteqL} After the while loop in \textsc{Find}, $F\subseteq L$. \end{claim} \begin{proof} Suppose there are $F\backslash L = B \neq \emptyset$. Since $B\subseteq F$, by Claim \ref{clm:worst_expansion}, $|\Gamma(B)| \geq (1-\Delta)D|B|$. So the number of unique neighbors is at least $(1-2\Delta)D|B|$. Hence there is a $v\in B$ which has at least $(1-2\Delta)D$ unique neighbors. But $v$ is not in $L$, meaning it has $<(1-2\Delta)D$ neighbors in $R$. So it has a unique neighbor which is not in $R$. This is a contradiction since this unique neighbor corresponds to an unsatisfied check which has to be in $R_0 \subseteq R$. \end{proof} Then we calculate the decoding radii and the size of $L$. \begin{claim}\label{clm:upper_bound_neighbors} For either $\Delta=\varepsilon$ or $\sqrt{\varepsilon \gamma x}$, $|\Gamma(L)| \le |\Gamma(F)| + 2 \Delta D \cdot |L \setminus F|$. \end{claim} \begin{proof} Let $(v_1,\ldots,v_{|L|})$ be the sequence of vertices added to $L$ in the while. By Lemma \ref{lemma:L'allsame}, we can adjust the order of the sequence by putting the vertices in $F$ at first and then put the vertices in $L \setminus F$ after them. The upper bound follows from the fact $F \subseteq L$ from Claim \ref{claim:FsubseteqL} and each vertex in $L \setminus F$ contributes at most $2 \Delta$ to $R$. \end{proof} \begin{claim} \label{claim:guessExpansionLbound1} For $\Delta=\sqrt{\varepsilon \gamma x}$, $|L| < \frac{1-2\Delta}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose $L \ge \frac{1-2\Delta}{2\varepsilon} \alpha N$. Let $\delta=\frac{1 - 2 \Delta}{2 \varepsilon} - x$. Consider $L' \subseteq L$ that is constituted by $F$ and the first $\delta \alpha N$ vertices in $L\setminus F$ added in the while loop. So $|L'| = \frac{1-2\Delta}{2\varepsilon} \alpha N$. From Claim~\ref{clm:upper_bound_neighbors}, $|\Gamma(L')| \le |\Gamma(F)|+2\Delta D\cdot \delta \alpha N$. On the other hand, Lemma~\ref{lem:expansion_larger} implies $|\Gamma(L')| \ge (1-(x+\delta)\varepsilon)D \cdot (x+\delta)\alpha N - O(1)$. Thus we have \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta)\alpha N - O(1)\le (1-\gamma)x \alpha N + 2 \sqrt{\varepsilon \gamma x} \cdot \delta \alpha N. \] In the rest of this proof, we show that our choice of $\delta$ yields \begin{equation}\label{eq:ineq1} (1 - (x+\delta)\varepsilon) \cdot (x+ \delta) - O(1/N) > (1-\gamma) x + 2 \sqrt{\varepsilon \gamma x} \cdot \delta. \end{equation} This is contradicted to the above discussion. We rewrite inequality~\eqref{eq:ineq1} as \[ 0 > \varepsilon \delta^2 + (2 \varepsilon x - 1 + 2 \sqrt{\varepsilon \gamma x})\delta + \varepsilon x^2 - \gamma x + O(1/N) . \] When $(2 \varepsilon x - 1 + 2 \sqrt{\varepsilon \gamma x})^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O(1/N) \right)>0$, the quadratic polynomial will be negative at $\delta=\frac{1 - 2 \varepsilon x - 2 \sqrt{\varepsilon \gamma x}}{2\varepsilon}$. To verify $(2 \varepsilon x - 1 + 2 \sqrt{\varepsilon \gamma x})^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O(1/N) \right)>0$, we set $c=\varepsilon x$ to rewrite it as \[ (2c - 1 + 2 \sqrt{\gamma c})^2 - 4 c^2 + 4 \gamma c - O(1/N) >0. \] This is equivalent to \[ 8 \gamma c + (8c -4 ) \sqrt{\gamma c} + 1 - 4c - O(1/N) > 0 \Rightarrow 8(\sqrt{\gamma c} +\frac{2c-1}{4})^2 - O(1/N) + 1 - 4c - 8(\frac{2c-1}{4})^2 > 0. \] \textcolor{red}{Xue: We may wanna handle the extra $O(1/N)$ term here. At least, we need to change $\leq$ to $<$.} When $c=\varepsilon x \leq \frac{\sqrt{2}-1}{2}$, i.e. $x \leq \frac{\sqrt{2}-1}{2\varepsilon}$, the residue $1 - 4c - 8(\frac{2c-1}{4})^2 \geq 0$. So the inequality holds. \end{proof} \begin{claim} \label{claim:guessExpansionLbound2} For $\Delta=\varepsilon$, $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose $|L| \geq \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Consider $L'\subseteq L$ with $|L'| = \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Let $\delta = \frac{1-2\varepsilon}{2\varepsilon} - x$. Notice that $\delta >0$ since we only need to consider every $x\leq \frac{1-2\varepsilon}{4\varepsilon} - O(1)$. We have \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta) - O(1/N) \le x + 2 \varepsilon \delta. \] So this is equivalent to \[ (1- 2\varepsilon - \varepsilon (x+\delta))(x+\delta) - O(1/N) \le (1-2\varepsilon) x \] The L.H.S. is maximized at $\delta+x=\frac{1 -2 \varepsilon}{2\varepsilon}$. To get a contradiction, we need to guarantee \[ (1-2\varepsilon) x < (1-2\varepsilon)^2/4\varepsilon - O(1/N). \] Namely $x < \frac{1-2\varepsilon}{4\varepsilon} - O(1/N)$. \end{proof} Consider we run Algorithm \ref{alg:decoding_small_eps}. If $\varepsilon < \frac{3-2\sqrt{2}}{2} $, then by Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2}, when $x \leq \frac{\sqrt{2}-1}{2\varepsilon}$, we have $|L| < \frac{1-2\varepsilon}{2\varepsilon}\alpha N $. If $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/6]$, then again by Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2}, when $x < \frac{1-2\varepsilon}{4\varepsilon} - O(1/N)$, we have $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Since the expander is an $(\alpha N, (1-\varepsilon)D)$ expander, by Lemma \ref{lem:expansion_larger}, it is also a $(\frac{1-2\varepsilon}{2\varepsilon}\alpha N, \left(\frac{1}{2} + \varepsilon \right) D - O(1/N) )$ expander. Then by Theorem \ref{thm:vidermandecfromerasures}, one can correct all the errors efficiently using $L$ (as the erasure area) and the corrupted codeword, since are the errors are in $L$ by Claim \ref{claim:FsubseteqL}. \end{proof} \section{Adaptive thresholds and Flipping} We consider $\varepsilon \in (1/6,1/4)$ in this section. The basic idea is to guess the expansion $(1-\gamma)$ of the corrupted entries and flip all entries with more than $(1-3\gamma)D_L$ wrong parity checks. We describe our algorithm in Algorithm~\ref{alg:decoding_large_eps}. We remark that the flipping only helps us when $1-3\gamma>1-2\varepsilon$. So there are two cases in the decoding procedure. Then we state our main result of this section. \begin{algorithm}[h] \caption{Decoding Algorithm for $\varepsilon<1/4$}\label{alg:decoding_large_eps} \begin{algorithmic}[1] \Function{Decoding}{$C_0 \in \mathbf{F}_2^n$ and $\gamma_i\in \mathbf{R}, i\in [l]$} \State $C \gets C_0$ \State Set a parameter $c \gets 3$. \textcolor{red}{We may adjust this one to get a better bound} \While{$C$ is not a codeword} \State Let $F$ be the subset of corrupted entries and assume $\gamma = \gamma_i$ to be its expansion, i.e., $|\Gamma(F)|=(1-\gamma)D \cdot |F|$. \textcolor{red}{We shall enumerate this for a formal algorithm.} \If{$\gamma \ge 2\varepsilon/3$} \State $C' \gets$ \Call{FixedFindAndDecode}{$C$} \State \Return $C'$ \Else \State Let $L_0$ denote all variables with at least $(1-c \gamma)$ wrong parity checkes \State Flip $L_0$ in $C$ \EndIf \EndWhile \State \Return $C$ \EndFunction \Function{Final Decoding}{$C_0 \in \mathbf{F}_2^n$} \State Enumerate $\gamma_1, \gamma_2, \ldots, \gamma_l$ where $l = c_1 \log N$, with a large enough constant $c_1$. \For{enumeration $\gamma_1, \gamma_2, \ldots, \gamma_l$} \State $C' \gets$ \Call{Decoding}{$C_0, \gamma_i, i\in [l]$} \If{$C'$ is a valid codeword} \State \Return $C'$ \EndIf \EndFor \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} For any constant $\varepsilon<1/4$, Algorithm~\ref{alg:decoding_large_eps} corrects $(1-\varepsilon-o(1)) \cdot \alpha N$ errors. \end{theorem} First of all, we show Function \textsc{FixedFindAndDecode} will recover the codeword whenever $\gamma$ is large. \begin{claim}\label{clm:small_gamma} Suppose the subset $F$ of flipped entries has size at most $(1-\varepsilon) \cdot \alpha N$ and its expansion parameter $\gamma \ge \frac{2\varepsilon}{3}$. Then Function \textsc{FixedFindAndDecode} will return a valid codeword. \end{claim} \begin{proof} We prove that $L$ after \textsc{Find} has size at most $\alpha N$. Suppose not. By Lemma \ref{lemma:all_errors_in_L}, we know, after \textsc{Find}, $L$ covers all the errors. Consider the moment $|L|=\alpha N$. Without loss of generality, we assume $F \subseteq L$ (otherwise we can adjust the order of vertices added to $L$ by Lemma \ref{lemma:L'allsame}). Then we have \[ (1-\varepsilon) D \alpha N \le | \Gamma(L) | \le (1-\gamma)D \cdot |F| + 2 \varepsilon D (\alpha N - |F|). \] Because the expansion of $F$ is $(1-\gamma)D \cdot |F|$ and when adding any vertex in $L\setminus F$ to $L$, $R$ increases by at most $2\varepsilon D$. So \[ (1-\varepsilon) \alpha N \le (1-\gamma) \cdot |F| + 2 \varepsilon (\alpha N - |F|). \] This implies $|F| \ge \frac{1-3\varepsilon}{1-\gamma - 2 \varepsilon} \cdot \alpha N$, which is at least $\frac{1-3\varepsilon}{1-8\varepsilon/3} \alpha N$ given $\gamma \ge 2\varepsilon/3$. Thus, it is contradicted to the assumption of $F \le (1-\varepsilon) \alpha N$ and $\varepsilon<1/4$. \end{proof} We know in one of the parallel procedures, $\gamma_i, i\in [l]$ correspond to the correct guesses of the expansions used in the iterations of the Decoding function. For this enumeration, we have the following. \begin{claim}\label{clm:large_gamma} Suppose $F$ is of size at most $(1-\varepsilon) \alpha N$ and of expansion $\gamma <\frac{2\varepsilon}{3}$. Then flipping $L_0$ will reduce the distance between $C$ and the correct codeword by a small constant fraction. \end{claim} \begin{proof} First of all, $|F \cup L_0| < \alpha N$. To prove it, we assume $|F \cup L_0|=\alpha N$. So \[ (1-\varepsilon) \alpha N \le |\Gamma(F \cup L_0)| \le (1-\gamma) |F| + c \gamma \cdot (\alpha N - |F|). \] This implies $|F| \ge \frac{1-\varepsilon - c \gamma}{1-\gamma - c \gamma} \cdot \alpha N$, which is minimized at $\gamma=0$. Then we still have $|F| \ge (1-\varepsilon) \alpha N$, contradicted to the assumption. Next \begin{equation}\label{eq:F_and_L_0} (1-\varepsilon) \cdot D |F \cup L_0| \le \Gamma(F \cup L_0) \le (1-\gamma)|F| + c \gamma |L_0 \setminus F|, \end{equation} which gives \[ (1-\varepsilon-c \gamma) \cdot |L_0\setminus F| \le (\varepsilon-\gamma) \cdot |F|. \] Now we consider $F \setminus L_0$. Each variable in $F \setminus L_0$ contributes at most $(1-c\gamma) D$ unique neighbors. And the total number of unique neighbors is at least $(1-2\gamma)D \cdot |F|$. So the size of $F\setminus L_0$ is at most $2/c \cdot |F|$. Finally we show \[ \frac{2}{c} + \frac{\varepsilon -\gamma}{1-\varepsilon - c \gamma}< 1. \] For $c=3$, it is equivalent to show \[ \frac{\varepsilon-\gamma}{1-\varepsilon-3\gamma} < 1/3, \] which is always true for $\varepsilon<1/4$. So this implies $|L_0 \setminus F| + |F \setminus L_0|\leq |F|$. Since $\varepsilon$ is a constant, this means the number of errors is reduced by a small constant fraction. \end{proof} \iffalse \section{Adaptive thresholds and Flipping} We consider $\varepsilon \in (1/6,1/4)$ in this section. The basic idea is to consider two cases about the actual expansion of $F$. We describe our algorithm in Algorithm~\ref{alg:decoding_large_eps} and state our main result of this section. \begin{algorithm}[h] \caption{Decoding Algorithm for $\varepsilon> 1/6$}\label{alg:decoding_large_eps} \begin{algorithmic}[1] \Function{Decoding}{$C_0 \in \mathbf{F}_2^n$ and $(\alpha,1-\varepsilon)$} \State $C \gets C_0$ \While{$C$ is not a codeword} \State $C' \gets$ \Call{FixedFindAndDecode}{$C$} \If{$C'$ is a valid codeword with distance at most $\alpha N$ to $C_0$} \State \Return $C'$ \Else \State Let $F$ be the subset of corrupted entries. \State Let $\gamma$ be the expansion of $F$, i.e., $|\Gamma(F)|=(1-\gamma)D \cdot |F|$. \textcolor{red}{We shall enumerate this.} \State We choose $c=\frac{(2+o(1))\varepsilon}{\gamma}$, use a threshold $(1- c \gamma)$ to find $L_0$ \State Flip $L_0$ in $C$ \EndIf \EndWhile \EndFunction \Function{FixedFindAndDecode}{$C \in \mathbf{F}_2^n$} \State $L \gets \emptyset$ \State $R \gets \{\text{wrong parity checks of } C\}$ \While{$\exists i\notin L$ s.t. $|\Gamma(i) \cap R| \ge (1-2\varepsilon)D$} \State $L \gets L \cup \{i\}$ \State $R \gets R \cup \Gamma(i)$ \EndWhile \State Apply the erasure decoding algorithm in \cite{Viderman13} with $L$ to return a codeword $C'$. \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} For any $\delta>0$ and $\varepsilon<1/4$, Algorithm~\ref{alg:decoding_large_eps} corrects $(1-\varepsilon-o(1)) \cdot \alpha N$ errors. \end{theorem} First of all, we show Function \textsc{FixedFindAndDecode} will recover the codeword whenever $\gamma$ is large. \begin{claim}\label{clm:small_gamma} Suppose the subset $F$ of flipped entries has size at most $(1-\varepsilon) \alpha N$ and its expansion parameter $\gamma \ge \frac{2\varepsilon^2}{1-\varepsilon}$. Then Function \textsc{FixedFindAndDecode} will return a valid codeword. \end{claim} \begin{proof} We prove that $L$ after the while loop has size at most $\alpha N$. Consider the moment $|L|=\alpha N$. Without loss of generality, we assume $F \subseteq L$ (otherwise we adjust the order of vertices added to $L$). Then we have \[ (1-\varepsilon) \alpha N \le (1-\gamma) \cdot |F| + 2 \varepsilon (\alpha N - |F|). \] This implies $|F| \ge \frac{1-3\varepsilon}{1-\gamma - 2 \varepsilon} \cdot \alpha N$, which is greater than $(1-\varepsilon) \alpha N$ and contradicted to the assumption of $F$. \end{proof} \begin{claim}\label{clm:large_gamma} Suppose the subset $F$ of flipped entries has size at most $(1-\varepsilon) \alpha N$ and its expansion $\gamma <\frac{2\varepsilon^2}{1-\varepsilon}$. Then flipping $L_0$ will reduce the distance between $C$ and the correct codeword. \end{claim} \begin{proof} First of all, $|F \cup L_0| < \alpha N$. To prove it, we assume $|F \cup L_0|=\alpha N$. So \[ (1-\varepsilon) \alpha N \le |N(F \cup L_0)| \le (1-\gamma) |F| + c \gamma \cdot (\alpha N - |F|). \] This implies $|F| \ge \frac{1-\varepsilon - c \gamma}{1-\gamma - c \gamma} \cdot \alpha N \ge (1-\varepsilon) \cdot \alpha N$ contradicted with our assumption. This shows \begin{equation}\label{eq:F_and_L_0} (1-\varepsilon) \cdot |F \cup L_0| \le (1-\gamma)|F| + c \gamma |L_0 \setminus F|. \end{equation} Now we consider $F \setminus L_0$ and $L_0 \setminus F$. Each variable in $F \setminus L_0$ shares more than $c \gamma$ neighbors with other vertices in $F$. So $N(F \setminus L_0) < (1-c \gamma/2)D \cdot |F \setminus L_0|$ and \[ (1-\gamma)|F| < |F \cap L_0| + (1-c\gamma/2) \cdot |F \setminus L_0| = |F| - c\gamma/2 \cdot |F \setminus L_0|. \] We plug this bound into \eqref{eq:F_and_L_0}: \[ (1-\varepsilon) |F \cup L_0| \le |F| - c \gamma/2 \cdot |F \setminus L_0| + c \gamma |L_0 \setminus F|. \] Namely \[ c \gamma/2 \cdot |F \setminus L_0| + (1-\varepsilon- c\gamma) |L_0 \setminus F| \le \varepsilon |F|. \] So we need $c \gamma/2 > \varepsilon$ and $1-\varepsilon - c \gamma >\varepsilon$ to guarantee that the while loop reduces the number of errors. These require $\varepsilon<1/4$ and $c \gamma>2 \varepsilon$ separately. \end{proof} \fi \section{Unique Decoding by Guessing Expansion with Iterative Flipping }\label{sec:guess_flip} We consider $\varepsilon$ to be an arbitrary constant $ < 1/4 $ in this section. We first show an algorithm which has decoding radius $(1-\varepsilon)\alpha N$. Then by using Lemma \ref{lem:expansion_larger}, we show that the algorithm achieves decoding radius approximately $\frac{3 \alpha}{16\varepsilon} N$. The basic idea of the algorithm is to guess the expansion of the corrupted entries in the algorithm, say $(1-\gamma)D$. Assume we can correctly guess $\gamma$. For the case $\gamma \geq \frac{2}{3}\varepsilon$, we do a finding possible corruptions and then decoding from erasures procedure, similar to \cite{Viderman13b}. Because of the case condition, it can be shown that $(1-\varepsilon)\alpha N$ errors can be corrected. For the case $\gamma < \frac{2}{3}\varepsilon$, we first locate the left subset which contains vertices having at least $1-3\gamma$ unsatisfied checks. We show that this set has (a constant fraction) more corrupted bits than correct bits. So we only need to do flipping in this set to reduce the number of errors. The algorithm iteratively do this to reduce errors significantly and then apply a classic decoding to correct remaining errors. We describe our algorithm in Algorithm~\ref{alg:decoding_large_eps} and then state our main result of this section. For ease of exposition, Algorithm~\ref{alg:decoding_large_eps} does exact enumerations, thus it is only a polynomial time algorithm. To make it a linear time algorithm we need to do approximate enumerations. See Remark~\ref{remark:EnumerationApprox}. \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon<1/4$}\label{alg:decoding_large_eps}\label{alg:MultipleGuessWithFlips} \begin{algorithmic}[1] \Function{Final Decoding}{$y \in \mathbf{F}_2^n, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} //The main procedure. \State Enumerate $\gamma_1, \gamma_2, \ldots, \gamma_l$ where $\ell = O(\frac{1}{1/4-\varepsilon})$. For every $ i\in [\ell]$, the enumeration first enumerate an integer $ a \in [N] $. Then $\gamma_i$ is enumerated by enumerating $b\in [M]$ and taking $\gamma_i$ such that $(1-\gamma_i)D a = b$. (This is a polynomial time enumeration. For linear time enumeration, see Remark~\ref{remark:EnumerationApprox}) \For{enumeration $\gamma_1, \gamma_2, \ldots, \gamma_\ell$} \State $C' \gets$ \Call{Decoding}{$y, \gamma_1, \ldots,\gamma_{\ell}, \alpha, \varepsilon$} \If{$C'$ is a valid codeword and the distance between $C'$ and $y$ is at most $(1-\varepsilon) \alpha N$} \State \Return $C'$ \EndIf \EndFor \EndFunction \Function{Decoding}{$y \in \mathbf{F}_2^n$ and $(\gamma_1,\ldots,\gamma_{\ell}) \in \mathbf{R}^{\ell}, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} \State $z \gets y$ \For{$i=1,\ldots,\ell$} \If{$\gamma_i \ge 2\varepsilon/3 $} \State $z \gets$ \Call{FixedFindAndDecode}{$z, \alpha, \varepsilon$} \State \Return $z$ \Else \State Let $L_0$ denote all variables with at least $(1-3 \gamma_i)$ wrong parity checks \State Flip $L_0$ in $z$ \EndIf \EndFor \State Apply the decoding of Theorem \ref{thm:vidermandec} on $z$ and return the result. \EndFunction \Function{FixedFindAndDecode}{$y \in \mathbf{F}_2^N, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} \State $L \gets $ \Call{Find}{$y, \varepsilon$} \State Apply Theorem \ref{thm:decfromerasures} with $L$ and $y$ to get a codeword $C'$. \State \Return $C'$ \EndFunctio \end{algorithmic} \end{algorithm} \begin{theorem} \label{thm:MultipleGuessWithFlips} For every small constant $\beta > 0$, for every $\varepsilon \leq 1/4 - \beta $, let $\mathcal{C}$ be an expander code defined by a $(\alpha N, (1-\varepsilon)D)$ expander graph. There is a linear time decoding algorithm with radius $(1-\varepsilon ) \cdot \alpha N$. \end{theorem} \begin{remark} \label{remark:EnumerationApprox} In the analysis we consider Algorithm \ref{alg:MultipleGuessWithFlips}. Notice that Algorithm \ref{alg:MultipleGuessWithFlips} only runs in polynomial time because of the enumeration procedure. We claim that the running time can be made linear if we replace the whole enumeration procedure by directly enumerating each $\gamma_i$ from the set $\{0, \eta, 2\eta, \ldots, \lceil\frac{1}{\eta} \rceil \eta \}$, where $\eta$ is a small enough constant (compared to $\beta$). The same decoding radius holds using this approximate enumeration. However, for ease of exposition, our analysis is based on algorithm \ref{alg:MultipleGuessWithFlips}. \end{remark} We focus on the $i$-th iteration, and show that we can make progress (reduce the number of errors) in this iteration. Let $F_i$ denote the set of errors at the beginning of iteration $i$ and $\gamma(F_i) \in [0,\varepsilon]$ be the parameter such that $| \Gamma(F_i) | = (1-\gamma(F_i)) \cdot D|F_i|$. Next, we show Function \textsc{FixedFindAndDecode} will recover the codeword directly whenever $\gamma(F_i)$ is large. \begin{claim}\label{clm:small_gamma} When $|F_i| < (1-\varepsilon ) \cdot \alpha N$, if $\gamma(F_i) \ge \frac{2\varepsilon}{3}$, then Function \textsc{FixedFindAndDecode} will return a valid codeword. \end{claim} \begin{proof} Let $\gamma:= \gamma(F_i)$. We prove that $L$ after \textsc{Find} has size at most $\alpha N$. Suppose not. Since $|F_i| \leq (1-\varepsilon ) \cdot \alpha N$, for every nonempty $ F'\subseteq F_i, |\Gamma(F_i)| \geq (1-\varepsilon)D|F'|$, so by Lemma \ref{lemma:all_errors_in_L}, after \textsc{Find}, $L$ covers all the errors. Consider the moment $|L|=\alpha N$. Without loss of generality, we assume $F_i \subseteq L$ (otherwise we can adjust the order of vertices added to $L$ by Lemma \ref{lemma:L'allsame}). Then we have \[ (1-\varepsilon) D \alpha N \le | \Gamma(L) | \le (1-\gamma)D \cdot |F_i| + 2 \varepsilon D (\alpha N - |F_i|), \] because the expansion of $F_i$ is $(1-\gamma)D \cdot |F_i|$ and when adding any vertex in $L\setminus F_i$ to $L$, $R$ increases by at most $2\varepsilon D$. So \[ (1-\varepsilon) \alpha N \le (1-\gamma) \cdot |F_i| + 2 \varepsilon (\alpha N - |F_i|). \] As $\gamma \leq \varepsilon$, $\varepsilon \leq 1/4$, so $1-\gamma - 2 \varepsilon > 0$, hence this implies $|F_i| \ge \frac{1-3\varepsilon}{1-\gamma - 2 \varepsilon} \cdot \alpha N $. Since $\gamma(F_i) \geq \frac{2\varepsilon}{3} $, we have $|F_i| \geq \frac{1-3\varepsilon}{1-8\varepsilon/3 } \alpha N $. When $\varepsilon \leq 1/4$, one can check that $\frac{1-3\varepsilon}{1-8\varepsilon/3 } \geq 1-\varepsilon $ always holds. It is contradicted to the assumption that $F_i \le (1-\varepsilon ) \alpha N$. As $L$ after \textsc{Find} has size at most $\alpha N$, the expander is an $(\alpha N, (1-\varepsilon)D)$ expander, with $\varepsilon <1/4-\beta$, by Corollary \ref{thm:decfromerasures}, we can correct all the errors using $L$ and $z$. \end{proof} Next we discuss the case that $\gamma_i=\gamma(F_i)$ is less than $2\varepsilon/3$ in the ELSE branch of the IF. We show that flipping $L_0$ will reduce the number of errors. \begin{claim}\label{clm:large_gamma} If $F_i$ is of size smaller than $(1-\varepsilon ) \alpha N$ and $\gamma_i = \gamma(F_i)$ is less than $\frac{2\varepsilon}{3}$, then flipping $L_0$ will reduce the distance between $z$ and the correct codeword by $\frac{4}{3}\beta$ fraction. \end{claim} \begin{proof} First of all, let $\gamma:=\gamma(F_i)$ and $N':=\frac{|F_i|}{(1-\varepsilon) \alpha}$. We show that $|F_i \cup L_0| < \alpha N'$. To prove it, assume $|F_i \cup L_0|=\alpha N'$, i.e. we only take $\alpha N' - |F_i|$ elements from $L_0\setminus F_i$, consider these elements together with elements in $F_i$. By the expander property, $(1-\varepsilon)D \alpha N' \le |\Gamma(F_i \cup L_0)|$. Also notice that $|\Gamma(F_i)| = (1-\gamma)D |F_i|$ and adding each element of $L_0\setminus F_i$ to $L_0$ contributes at most $3\gamma_i D$ to $|\Gamma(F_i \cup L_0)|$. So \[ (1-\varepsilon)D \alpha N' \le |\Gamma(F_i \cup L_0)| \le (1-\gamma)D |F_i| + 3 \gamma_i D \cdot (\alpha N' - |F_i|). \] This implies $|F_i| \ge \frac{1-\varepsilon - 3 \gamma_i}{1-\gamma - 3 \gamma_i} \cdot \alpha N'$. Again we know $ \gamma_i = \gamma$ and this is minimized when $\gamma = 0$. Thus $|F_i| \ge (1-\varepsilon) \alpha N'$, contradicted to the assumption. Since $|F_i\cup L_0| <\alpha N'$, now again we have \begin{equation}\label{eq:F_and_L_0} (1-\varepsilon) \cdot D |F_i \cup L_0| \le \Gamma(F_i \cup L_0) \le (1-\gamma)D|F_i| + 3 \gamma_i D|L_0 \setminus F_i|. \end{equation} As $ |F_i \cup L_0| = |L_0 \setminus F_i| + |F_i| $, this gives \[ (1-\varepsilon-3 \gamma_i) \cdot |L_0\setminus F_i| \le (\varepsilon-\gamma) \cdot |F_i|. \] Now we consider $F_i \setminus L_0$. Each variable in $F_i \setminus L_0$ contributes at most $(1-3\gamma_i) D$ unique neighbors. And the total number of unique neighbors is at least $(1-2\gamma)D \cdot |F_i|$. So the size of $F_i\setminus L_0$ is at most $\frac{2\gamma}{3\gamma_i} \cdot |F_i|$. Finally we show \[ \frac{2\gamma}{3\gamma_i} + \frac{\varepsilon -\gamma}{1-\varepsilon - 3 \gamma_i}< 1 - O(\beta). \] As $\gamma = \gamma_i$, the L.H.S. is at most \[ \frac{2 }{3 } + \frac{\varepsilon - \gamma_i }{1-\varepsilon - 3 \gamma_i }. \] We know $\varepsilon \leq 1/4 - \beta$ and $\gamma_i \in [0, \frac{2}{3}\varepsilon]$. One can check that this is at most $1- \frac{4}{3}\beta$. \end{proof} \begin{proofof}{Theorem \ref{thm:MultipleGuessWithFlips}} The decoding algorithm is Algorithm \ref{alg:MultipleGuessWithFlips}. Given the parameter $\beta$, we first set up a large enough constant $\ell$ based on $\beta$. Then we apply the algorithm on an input corrupted codeword, using parameter $\ell$. The algorithm first do the enumerations. We know in one of the enumerations, $(\gamma_i)_{i\in [l]}$ provide exactly the correct expansion parameters, i.e. $\forall i\in [l]$ in the $i$-th iteration, $\gamma(F_i) = \gamma_i$. Next we consider every iteration. If $\gamma_i \geq 2\varepsilon/3 $, then by Claim \ref{clm:small_gamma}, the algorithm returns the correct codeword. If $\gamma_i < 2\varepsilon/3$, then by Claim \ref{clm:large_gamma}, the number of errors can be reduced by $O(\beta)$ fraction. So in the worst case, when $\ell \geq \log_{1-O(\beta)}\frac{1}{3}$, the number of errors can be reduced to at most $\alpha N / 3$. So finally the algorithm applies the decoding algorithm from Theorem \ref{thm:vidermandec}, which corrects the remaining errors. The running time of Algorithm \ref{alg:MultipleGuessWithFlips} is polynomial, since $\ell = O(1)$ and our enumeration for $a$ takes $O(N)$ time for each $\gamma_i$ takes $O(M)$ time. Moreover, the algorithm can be modified to be a linear time algorithm, by enumerating each $\gamma_i$ from the set $\{0, \eta, 2\eta, \ldots, \lceil\frac{1}{\eta} \rceil \eta \}$, where $\eta$ is a small enough constant (comparing to $\beta$). One can check that we can get the same parameters by a similar analysis. \end{proofof} By using Theorem \ref{thm:MultipleGuessWithFlips} and Lemma \ref{lem:expansion_larger} we can get the following result. \iffalse \begin{theorem} For every constant $\beta > 0$, for every $ \varepsilon \leq 1/4 - \beta $, if $\mathcal{C}$ is an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander, then there is a linear time decoding algorithm for $\mathcal{C}$ which has decoding radius $(\frac{3\varepsilon}{16} - O_\varepsilon(\beta))\alpha N$. \end{theorem} \authnote{Xin}{magenta}{I think by setting $\beta$ appropriately, we should be able to rewrite the theorem statement as follows. Check it. Also, $\varepsilon$ should be in the denominator.} \fi \begin{theorem}\label{thm:MultipleGuessWithFlipsFinal} For every constants $ \varepsilon \in (0, \frac{1}{4}), \eta>0$, if $\mathcal{C}$ is an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander, then there is a linear time decoding algorithm for $\mathcal{C}$ which has decoding radius $(\frac{3 \alpha}{16 \varepsilon} - \eta) N$. \end{theorem} \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon<1/4$ for Larger distance}\label{alg:MultipleGuessWithFlipsLarger} \begin{algorithmic}[1] \Function{Final Decoding For Large Distance}{$y\in \mathbf{F}_2^N, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} \State Let $k = (1/4-\beta - O_\varepsilon(1/N))/\varepsilon$, with $\beta$ being a small enough constant. \State Let $z \gets$ \Call{Final Decoding}{$y, k\alpha, k \varepsilon + O_\varepsilon(1/N)$} . \State \Return $z$. \EndFunction \end{algorithmic} \end{algorithm} \begin{proof} Consider Algorithm \ref{alg:MultipleGuessWithFlipsLarger}. By Lemma \ref{lem:expansion_larger}, the expander graph is also a $ (k\alpha N, (1-k\varepsilon)D - O_\varepsilon(1/N)) $ expander for $k\geq 1$. If taking $k$ to be such that $(1-k\varepsilon)D - O_\varepsilon(1/N) \leq 1/4 - \beta$ with $\beta$ small enough, then by Theorem \ref{thm:MultipleGuessWithFlips}, there is a decoding algorithm with radius $(1 - k\varepsilon - O_\varepsilon(1/N))k\alpha N$. When $k = (1/4-\beta - O_\varepsilon(1/N))/\varepsilon$, this is maximized to be $(\frac{3}{16\varepsilon} - O_{\varepsilon}(\beta))\alpha N$. We can take $\beta$ to be small enough such that decoding radius $(\frac{3 \alpha}{16 \varepsilon} - \eta) N$. The running time is linear by Theorem~\ref{thm:MultipleGuessWithFlips}. \end{proof} \iffalse \section{Adaptive thresholds and Flipping} We consider $\varepsilon \in (1/6,1/4)$ in this section. The basic idea is to consider two cases about the actual expansion of $F$. We describe our algorithm in Algorithm~\ref{alg:decoding_large_eps} and state our main result of this section. \begin{algorithm}[h] \caption{Decoding Algorithm for $\varepsilon> 1/6$}\label{alg:decoding_large_eps} \begin{algorithmic}[1] \Function{Decoding}{$C_0 \in \mathbf{F}_2^n$ and $(\alpha,1-\varepsilon)$} \State $C \gets C_0$ \While{$C$ is not a codeword} \State $C' \gets$ \Call{FixedFindAndDecode}{$C$} \If{$C'$ is a valid codeword with distance at most $\alpha N$ to $C_0$} \State \Return $C'$ \Else \State Let $F$ be the subset of corrupted entries. \State Let $\gamma$ be the expansion of $F$, i.e., $|\Gamma(F)|=(1-\gamma)D \cdot |F|$. \textcolor{red}{We shall enumerate this.} \State We choose $c=\frac{(2+o(1))\varepsilon}{\gamma}$, use a threshold $(1- c \gamma)$ to find $L_0$ \State Flip $L_0$ in $C$ \EndIf \EndWhile \EndFunction \Function{FixedFindAndDecode}{$C \in \mathbf{F}_2^n$} \State $L \gets \emptyset$ \State $R \gets \{\text{wrong parity checks of } C\}$ \While{$\exists i\notin L$ s.t. $|\Gamma(i) \cap R| \ge (1-2\varepsilon)D$} \State $L \gets L \cup \{i\}$ \State $R \gets R \cup \Gamma(i)$ \EndWhile \State Apply the erasure decoding algorithm in \cite{Viderman13} with $L$ to return a codeword $C'$. \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} For any $\delta>0$ and $\varepsilon<1/4$, Algorithm~\ref{alg:decoding_large_eps} corrects $(1-\varepsilon-o(1)) \cdot \alpha N$ errors. \end{theorem} First of all, we show Function \textsc{FixedFindAndDecode} will recover the codeword whenever $\gamma$ is large. \begin{claim}\label{clm:small_gamma} Suppose the subset $F$ of flipped entries has size at most $(1-\varepsilon) \alpha N$ and its expansion parameter $\gamma \ge \frac{2\varepsilon^2}{1-\varepsilon}$. Then Function \textsc{FixedFindAndDecode} will return a valid codeword. \end{claim} \begin{proof} We prove that $L$ after the while loop has size at most $\alpha N$. Consider the moment $|L|=\alpha N$. Without loss of generality, we assume $F \subseteq L$ (otherwise we adjust the order of vertices added to $L$). Then we have \[ (1-\varepsilon) \alpha N \le (1-\gamma) \cdot |F| + 2 \varepsilon (\alpha N - |F|). \] This implies $|F| \ge \frac{1-3\varepsilon}{1-\gamma - 2 \varepsilon} \cdot \alpha N$, which is greater than $(1-\varepsilon) \alpha N$ and contradicted to the assumption of $F$. \end{proof} \begin{claim}\label{clm:large_gamma} Suppose the subset $F$ of flipped entries has size at most $(1-\varepsilon) \alpha N$ and its expansion $\gamma <\frac{2\varepsilon^2}{1-\varepsilon}$. Then flipping $L_0$ will reduce the distance between $C$ and the correct codeword. \end{claim} \begin{proof} First of all, $|F \cup L_0| < \alpha N$. To prove it, we assume $|F \cup L_0|=\alpha N$. So \[ (1-\varepsilon) \alpha N \le |N(F \cup L_0)| \le (1-\gamma) |F| + c \gamma \cdot (\alpha N - |F|). \] This implies $|F| \ge \frac{1-\varepsilon - c \gamma}{1-\gamma - c \gamma} \cdot \alpha N \ge (1-\varepsilon) \cdot \alpha N$ contradicted with our assumption. This shows \begin{equation}\label{eq:F_and_L_0} (1-\varepsilon) \cdot |F \cup L_0| \le (1-\gamma)|F| + c \gamma |L_0 \setminus F|. \end{equation} Now we consider $F \setminus L_0$ and $L_0 \setminus F$. Each variable in $F \setminus L_0$ shares more than $c \gamma$ neighbors with other vertices in $F$. So $N(F \setminus L_0) < (1-c \gamma/2)D \cdot |F \setminus L_0|$ and \[ (1-\gamma)|F| < |F \cap L_0| + (1-c\gamma/2) \cdot |F \setminus L_0| = |F| - c\gamma/2 \cdot |F \setminus L_0|. \] We plug this bound into \eqref{eq:F_and_L_0}: \[ (1-\varepsilon) |F \cup L_0| \le |F| - c \gamma/2 \cdot |F \setminus L_0| + c \gamma |L_0 \setminus F|. \] Namely \[ c \gamma/2 \cdot |F \setminus L_0| + (1-\varepsilon- c\gamma) |L_0 \setminus F| \le \varepsilon |F|. \] So we need $c \gamma/2 > \varepsilon$ and $1-\varepsilon - c \gamma >\varepsilon$ to guarantee that the while loop reduces the number of errors. These require $\varepsilon<1/4$ and $c \gamma>2 \varepsilon$ separately. \end{proof} \fi \section{Improved Unique Decoding for $\varepsilon \leq 1/8$}\label{sec:improve_decoding} Consider the expander code on an $(\alpha N, (1-\varepsilon)D)$ bipartite expander $G$. For the case of $\varepsilon \le 1/8$ we provide an efficient algorithm, i.e. Algorithm~\ref{alg:decoding_small_eps}, to decode more errors. It is again by guessing the expansion of the corrupted entries. For easy of exposition, Algorithm~\ref{alg:decoding_large_eps} does exact enumerations when guessing parameters, thus it only runs in polynomial time. To make it a linear time algorithm we need to do approximate enumerations instead. See Remark~\ref{remark:EnumerationApproximate2}. \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon\le 1/8$}\label{alg:decoding_small_eps} \begin{algorithmic}[1] \Function{Decoding}{$y \in \mathbf{F}_2^N$ } \For {every integer $i \in [1, N]$, let $x$ satisfy $x \alpha N = i$} \For {every integer $j \in [1, M]$, let $\gamma$ satisfy $(1-\gamma) \cdot D \cdot i = j $} \\(For easy of exposition we do exact enumerations. For linear time algorithm, see Remark~\ref{remark:EnumerationApproximate2}.) \If{$\gamma x \ge \varepsilon$ and $x\geq 1$} \State $\Delta \gets \sqrt{\gamma x \varepsilon} + \frac{c}{N}$ with $c:=c(\varepsilon)$ being a large enough constant. \Else \State $\Delta \gets \varepsilon$ \EndIf \State $L \gets $ \Call{Find}{$y \in \mathbf{F}_2^n$ and $\Delta$} \State Apply Theorem \ref{thm:decfromerasures} with $L$ and $y$ to get a codeword $C'$. \State \Return $C'$ if distance between $C'$ and $y$ is $\le \frac{1-2\varepsilon}{4 \varepsilon}\alpha N $ where the distance comes from Theorem~\ref{thm:dist_expander}. \EndFor \EndFor \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} \label{thm:guessexpansion} Consider the expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander. For $\varepsilon< \frac{3-2\sqrt{2}}{2}$, there is a linear time decoding algorithm with radius $\frac{\sqrt{2}-1}{2\epsilon} \alpha N -O_{\varepsilon}(1) $. Next for $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/8]$, there is a linear time decoding algorithm with radius $\frac{1-2\varepsilon}{4\varepsilon} \alpha N - O_{\varepsilon}(1)$. \end{theorem} \begin{remark} \label{remark:EnumerationApproximate2} In Algorithm \ref{alg:decoding_small_eps} we do exact enumerations for $x$ and $\gamma$, for ease of exposition and analysis. The running time of Algorithm \ref{alg:decoding_small_eps} is polynomial instead of linear. However, the algorithm can be modified to be in linear time if we enumerate $x$ and $\gamma$ from the set $\{0, \eta, 2\eta, \ldots, \lceil\frac{1}{\eta} \rceil \eta \}$, where $\eta$ is a small constant. The same decoding radius holds using this approximate enumeration. \end{remark} We prove the correctness of Algorithm~\ref{alg:decoding_small_eps} in the rest of this section. Again $F$ always denotes the subset of entries that are flipped by the adversary. Since we enumerate both $x \alpha N = i$ and $(1-\gamma)D x\alpha N = j$ over all possible values. One pair of them correspond to the correct size of $F$, i.e. $|F| = x \alpha N$ and the correct expansion size of $F$ i.e. $|\Gamma(F)|=(1-\gamma) \cdot D |F|$. Now we only consider this pair $x$ and $\gamma$ in the following analysis. First of all, we bound the expansion of all subsets in $F$. \begin{claim}\label{clm:worst_expansion} Our choice of $\Delta$ always satisfies that \[ \forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|. \] \end{claim} \begin{proof} Let $F'$ be the subset of $F$ with the worst expansion and denote $|F'| = x' \cdot \alpha N$. If $x' \le 1$, $|\Gamma(F')| \ge (1-\varepsilon) \cdot D |F'|$ by the expansion property of the expander. This is at least $(1-\Delta)D|F'|$ since $\Delta$ is always at least $\varepsilon$ in the algorithm. Otherwise, we consider the collisions in $\Gamma(F)$ and $\Gamma(F')$ ~By collision we mean that given an arbitrary order of the edges, if one edge in this order has its right ending the same as any other edge in previous of it, then this is called a collision. Since $F'$ is of size $x' \cdot \alpha N$, by Lemma \ref{lem:expansion_larger}, $|\Gamma(F')| \ge (1-x' \cdot \varepsilon) D \cdot x' \alpha N - O_\varepsilon(1)$. So we have that the total number of collisions for edges with left endings in $F'$ is at most the total number of collisions for edges with left endings in $F$, because a collision in $\Gamma(F')$ is also a collision in $\Gamma(F)$, according to an arbitrary order of all edges connected to vertices in $F$. So \[ x' \alpha N \cdot (x' \cdot \varepsilon)D + O_\varepsilon(1) \le |F| \cdot \gamma D. \] This implies $x' \cdot \varepsilon \le \sqrt{\gamma x\varepsilon } = \Delta - \frac{c}{N}$ and hence $|\Gamma(F')| \ge (1-\Delta+\frac{c}{N}) D \cdot |F'| - O_\varepsilon(1) \geq (1-\Delta) D \cdot |F'|$, when $c$ is large enough. \end{proof} Given the guarantee in Claim~\ref{clm:worst_expansion}, one can show that $L$ contains all the errors. \begin{claim} \label{claim:FsubseteqL} After step 9 in Algorithm~\ref{alg:decoding_small_eps}, we have $F\subseteq L$. \end{claim} \begin{proof} By Claim \ref{clm:worst_expansion}, $\forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|$. So $\forall F' \subseteq F, |\Gamma^1(F')| \ge (1-2\Delta) \cdot D |F'|$. By Lemma \ref{lemma:all_errors_in_L}, we know $F\subseteq L$ after \textsc{Find}. \end{proof} \iffalse \begin{proof} Suppose there are $F\setminus L = B \neq \emptyset$. Since $B\subseteq F$, by Claim \ref{clm:worst_expansion}, $|\Gamma(B)| \geq (1-\Delta)D|B|$. So the number of unique neighbors is at least $(1-2\Delta)D|B|$. Hence there is a $v\in B$ which has at least $(1-2\Delta)D$ unique neighbors. But $v$ is not in $L$, meaning it has $<(1-2\Delta)D$ neighbors in $R$. So it has a unique neighbor which is not in $R$. This is a contradiction since this unique neighbor corresponds to an unsatisfied check which has to be in $R_0 \subseteq R$. \end{proof} \fi Then we calculate the decoding radius and the size of $L$. \iffalse \begin{claim}\label{clm:upper_bound_neighbors} For both $\Delta=\varepsilon$ and $\Delta=\sqrt{\varepsilon \gamma x}$, $|\Gamma(L)| \le |\Gamma(F)| + 2 \Delta D \cdot |L \setminus F|$. \end{claim} \begin{proof} Let $(v_1,\ldots,v_{|L|})$ be the sequence of vertices added to $L$ in the while. By Lemma \ref{lemma:L'allsame}, we can adjust the order of the sequence by putting the vertices in $F$ at first and then put the vertices in $L \setminus F$ after them. The upper bound follows from the fact $F \subseteq L$ from Claim \ref{claim:FsubseteqL} and each vertex in $L \setminus F$ contributes at most $2 \Delta$ to $R$. \end{proof} \fi \begin{claim} \label{claim:guessExpansionLbound1} For $\Delta=\sqrt{\gamma x \varepsilon } + \frac{c}{N}$, if $x \in [1, \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N)]$, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose after the iterations, $|L| \ge \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Let $\delta=\frac{1 - 2 \Delta}{2 \varepsilon} - x$. Notice that $\delta \geq 0$. This is because $\Delta$ is set to be $\sqrt{\gamma x \varepsilon} + \frac{c}{N}$ and by Lemma \ref{lem:expansion_larger}, $\gamma \leq x \varepsilon + O_\varepsilon(1/N)$. So $\delta=\frac{1 - 2 \Delta}{2 \varepsilon} - x \geq \frac{1-2\varepsilon x - \Theta_\varepsilon(1/N)}{2\varepsilon} - x = \frac{1}{2\varepsilon} - 2x - \Theta_\varepsilon(1/N)$. Since $\varepsilon \leq 1/6$ and $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N) $, one can check that $\delta \geq 0$. Also notice that $ x+ \delta \geq \frac{1 }{2 \varepsilon} - x -\Theta_\varepsilon(1/N) \geq 1 $ when $\varepsilon \leq 1/6$. By Claim \ref{clm:worst_expansion} and Lemma \ref{lemma:FAddtoLFirst}, we can let $L' \subseteq L$ be constituted by first adding $F$ and then $\delta \alpha N$ vertices in $L\setminus F$. Notice that all the unsatisfied checks are in $\Gamma(F)$, $|\Gamma(F)| \leq D|F|$, and every element in $L'\setminus F$ contributes at most $2\varepsilon D$ vertices to $R$. Hence $|\Gamma(L')| \le |\Gamma(F)|+2\Delta D\cdot \delta \alpha N$. On the other hand, Lemma~\ref{lem:expansion_larger} implies $|\Gamma(L')| \ge (1-(x+\delta)\varepsilon)D \cdot (x+\delta)\alpha N - O_\varepsilon(1)$. Thus we have \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta)\alpha N - O_\varepsilon(1)\le (1-\gamma)x \alpha N + 2 \Delta \cdot \delta \alpha N. \] In the rest of this proof, we show that our choice of $\delta$ yields \begin{equation}\label{eq:ineq1} (1 - (x+\delta)\varepsilon) \cdot (x+ \delta) - O_\varepsilon(1/N) > (1-\gamma) x + 2 \Delta \cdot \delta. \end{equation} This gives a contradiction. Towards that, we rewrite inequality~\eqref{eq:ineq1} as \[ 0 > \varepsilon \delta^2 + (2 \varepsilon x - 1 + 2 \sqrt{\varepsilon \gamma x})\delta + \varepsilon x^2 - \gamma x + O_\varepsilon(1/N) . \] When $(2 \varepsilon x - 1 + 2 \sqrt{\varepsilon \gamma x})^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O_\varepsilon(1/N) \right)>0$, the quadratic polynomial will be negative at $\delta_0=\frac{1 - 2 \varepsilon x - 2 \sqrt{\varepsilon \gamma x}}{2\varepsilon}=\delta $. To verify $(2 \varepsilon x - 1 + 2 \sqrt{\varepsilon \gamma x})^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O_\varepsilon(1/N) \right)>0$, we set $c=\varepsilon x$ and rewrite it as \[ (2c - 1 + 2 \sqrt{\gamma c})^2 - 4 c^2 + 4 \gamma c - O_\varepsilon(1/N) >0. \] This is equivalent to \[ 8 \gamma c + (8c -4 ) \sqrt{\gamma c} + 1 - 4c - O_\varepsilon(1/N) > 0 \Rightarrow 8(\sqrt{\gamma c} +\frac{2c-1}{4})^2 - O_\varepsilon(1/N) + 1 - 4c - 8(\frac{2c-1}{4})^2 > 0. \] When $c=\varepsilon x \leq \frac{\sqrt{2}-1}{2} - O_\varepsilon(1/N)$, i.e. $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N)$, the residue $1 - 4c - 8(\frac{2c-1}{4})^2 -O_\varepsilon(1/N)>0$. So the inequality holds. \end{proof} \begin{claim} \label{claim:guessExpansionLbound2} For $\Delta=\varepsilon$, if $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose $|L| \geq \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Consider $L'\subseteq L$ with $|L'| = \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Let $\delta = \frac{1-2\varepsilon}{2\varepsilon} - x$. Notice that $\delta \geq 0$ because $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. Also $x+ \delta \geq 1$ since $\varepsilon \leq 1/8$. By Lemma \ref{lem:expansion_larger}, $|\Gamma(L')| \geq (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1)$. By Lemma \ref{lemma:FAddtoLFirst} we can consider $L'$ as being constituted by first adding all elements in $F$ and then add another $\delta \alpha N$ elements by the algorithm. Notice that all the unsatisfied checks are in $\Gamma(F)$, $|\Gamma(F)| \leq D|F|$, and every element in $L'\setminus F$ contributes at most $2\varepsilon D$ vertices to $R$. Hence $|\Gamma(L')| \leq D|F| + 2\varepsilon D \delta \alpha N$. So we have \[ (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1) \leq |\Gamma(L')| \leq D|F| + 2\varepsilon D \delta \alpha N \] Thus \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta) - O_\varepsilon(1/N) \le x + 2 \varepsilon \delta. \] So this is equivalent to \[ (1- 2\varepsilon - \varepsilon (x+\delta))(x+\delta) - O_\varepsilon(1/N) \le (1-2\varepsilon) x \] Recall that $\delta+x=\frac{1 -2 \varepsilon}{2\varepsilon}$. To get a contradiction, we only need \[ (1-2\varepsilon) x < (1-2\varepsilon)^2/4\varepsilon - O(1/N). \] Namely $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. \end{proof} \begin{proofof}{Theorem \ref{thm:guessexpansion}} One of our enumerations correctly predicts $|F|$ and $|\Gamma(F)|$. Consider Algorithm \ref{alg:decoding_small_eps} under this enumeration. After the function $\mathrm{Find}$, all the errors are in $L$ by Claim \ref{claim:FsubseteqL}. Now we bound $|L|$. When $x < 1$, then $\Delta = \varepsilon$ in the algorithm. By Claim \ref{claim:guessExpansionLbound2}, $|L| \leq \frac{1-2\varepsilon}{2\varepsilon}\alpha N $, as long as $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. When $x \geq 1$, to bound $|L|$, we now just need to pick the smaller bound of $x$ from Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2}. If $\varepsilon < \frac{3-2\sqrt{2}}{2} $, then $\frac{\sqrt{2}-1}{2\varepsilon} < \frac{1-2\varepsilon}{4\varepsilon}$. So by Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2} when $x \in [1, \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N)]$ we have $|L| < \frac{1-2\varepsilon}{2\varepsilon}\alpha N $. If $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/8]$, then $\frac{\sqrt{2}-1}{2\varepsilon} \geq \frac{1-2\varepsilon}{4\varepsilon}$. By Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2} , when $x \in [1, \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)]$, we have $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Since the expander is an $(\alpha N, (1-\varepsilon)D)$ expander, by Theorem \ref{thm:decfromerasures}, one can correct all the errors efficiently using $L$ (as the erasure area) and the corrupted codeword. \end{proofof} \section{Improved Unique Decoding for $\varepsilon \leq 1/8$}\label{sec:improve_decoding} Consider the expander code on an $(\alpha N, (1-\varepsilon)D)$ bipartite expander $G$. For the case of $\varepsilon \le 1/8$ we provide an efficient algorithm, i.e. Algorithm~\ref{alg:decoding_small_eps}, to decode more errors. It is again by guessing the expansion of the corrupted entries. \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon\le 1/8$}\label{alg:decoding_small_eps} \begin{algorithmic}[1] \Function{Decoding}{$y \in \mathbf{F}_2^N$ } \State Enumerate $\tilde{x}$ from $\{ \eta , 2\eta , \ldots, \lceil\frac{1}{4\varepsilon \eta } \rceil \eta \}$ and enumerate $\tilde{\gamma}\tilde{x}$ from $\{ \eta , 2\eta , \ldots, \lceil\frac{1}{\eta } \rceil \eta \}$, where $\eta<1$ is a small enough constant. \If{$\tilde{\gamma} \tilde{x}\ge \varepsilon + 3\eta$ and $\tilde{x} \geq 1-\eta$} \State $\Delta \gets \sqrt{\tilde{\gamma} \tilde{x} \varepsilon}$. \Else \State $\Delta \gets \varepsilon$ \EndIf \State $L \gets $ \Call{Find}{$y \in \mathbf{F}_2^n$ and $\Delta$} \State Apply Theorem \ref{thm:decfromerasures} with $L$ and $y$ to get a codeword $C'$. \State \Return $C'$ if distance between $C'$ and $y$ is $\le \frac{1-2\varepsilon}{4 \varepsilon}\alpha N $ where the distance comes from Theorem~\ref{thm:dist_expander}. \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} \label{thm:guessexpansion} Consider the expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander. For $\varepsilon< \frac{3-2\sqrt{2}}{2}$, there is a linear time decoding algorithm with radius $\frac{\sqrt{2}-1}{2\epsilon} \alpha N -O_{\varepsilon}(1) $. Next for $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/8]$, there is a linear time decoding algorithm with radius $\frac{1-2\varepsilon}{4\varepsilon} \alpha N - O_{\varepsilon}(1)$. \end{theorem} We prove the correctness of Algorithm~\ref{alg:decoding_small_eps} in the rest of this section. Again $F$ always denotes the subset of entries that are flipped by the adversary. Again let $F$ be the set of corruptions and assume $|F| = x\alpha N$, $|\Gamma(F)| = (1-\gamma)D|F|$. Since we enumerate $\tilde{x}$ and $\tilde{\gamma}$, one pair of them is such that $x \in [\tilde{x} , \tilde{x}+ \eta], \gamma x \in [\tilde{\gamma}\tilde{x} ,\tilde{\gamma}\tilde{x}+ \eta]$. Now we only consider this pair $\tilde{x}$ and $\tilde{\gamma}$ in the following analysis. First of all, we bound the expansion of all subsets in $F$. \begin{claim}\label{clm:worst_expansion} Our choice of $\Delta$ always satisfies that \[ \forall F' \subseteq F, F'\neq \emptyset, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|. \] \end{claim} \begin{proof} Let $F'$ be the subset of $F$ with the worst expansion and denote $|F'| = x' \cdot \alpha N$. If $\tilde{x} < 1-\eta$, then $x' < 1 $. So then $|\Gamma(F')| \ge (1- \varepsilon) \cdot D |F'|$ by the expansion property. This is at least $(1-\Delta)D|F'|$ since $\Delta = \varepsilon$ in the algorithm. If $\tilde{x} \geq 1-\eta$, then $x' \geq 1-\eta$. We have two cases. First case, $x' \in [1-\eta, 1]$. Then $|\Gamma(F')| \ge (1 - \varepsilon )\cdot D |F'|$ by the expansion property. If $\tilde{\gamma} \tilde{x}\ge \varepsilon + 3\eta $, then notice that this is at least $(1-\Delta)D|F'|$ since $\Delta = \sqrt{\tilde{x}\tilde{\gamma}\varepsilon}\geq \sqrt{(\varepsilon+3\eta)\varepsilon} \geq \varepsilon $. Else, we run into the second branch and $\Delta = \varepsilon$. Second case, $x'\geq 1$. We consider the collisions in $\Gamma(F)$ and $\Gamma(F')$. ~By collision we mean that given an arbitrary order of the edges, if one edge in this order has its right ending the same as any other edge in previous of it, then this is called a collision. Since $F'$ is of size $x' \cdot \alpha N$, by Lemma \ref{lem:expansion_larger}, $|\Gamma(F')| \ge (1-x' \cdot \varepsilon) D \cdot x' \alpha N - O_\varepsilon(1)$. So we have that the total number of collisions for edges with left endings in $F'$ is at most the total number of collisions for edges with left endings in $F$, because a collision in $\Gamma(F')$ is also a collision in $\Gamma(F)$, according to an arbitrary order of all edges connected to vertices in $F$. So \[ x' \alpha N \cdot (x' \cdot \varepsilon)D + O_\varepsilon(1) \le |F| \cdot \gamma D. \] This implies $x' \cdot \varepsilon \le \sqrt{\gamma x\varepsilon } $. When $\tilde{\gamma} \tilde{x}\ge \varepsilon + 3\eta $, $ \sqrt{\gamma x\varepsilon } \leq \Delta - \Theta(\eta)$ because $\gamma x \leq \tilde{\gamma}\tilde{x} + \eta$, $\varepsilon \leq \tilde{\gamma}\tilde{x} - 3\eta $. Hence $|\Gamma(F')| \ge (1-\Delta+ \Theta(\eta)) D \cdot |F'| - O_\varepsilon(1) \geq (1-\Delta) D \cdot |F'|$, noticing $|F'|= x'\alpha N \geq \alpha N$. When $\tilde{\gamma} \tilde{x} < \varepsilon + 3\eta $, $ \sqrt{\gamma x\varepsilon } \leq \varepsilon -\Theta(\eta).$ Hence again $|\Gamma(F')| \ge (1-\varepsilon+ \Theta(\eta)) D \cdot |F'| - O_\varepsilon(1) \geq (1-\varepsilon) D \cdot |F'|$, noticing $|F'|= x'\alpha N \geq \alpha N$. \end{proof} Given the guarantee in Claim~\ref{clm:worst_expansion}, one can show that $L$ contains all the errors. \begin{claim} \label{claim:FsubseteqL} After step 9 in Algorithm~\ref{alg:decoding_small_eps}, we have $F\subseteq L$. \end{claim} \begin{proof} By Claim \ref{clm:worst_expansion}, $\forall F' \subseteq F, |\Gamma(F')| \ge (1-\Delta) \cdot D |F'|$. So $\forall F' \subseteq F, |\Gamma^1(F')| \ge (1-2\Delta) \cdot D |F'|$. By Lemma \ref{lemma:all_errors_in_L}, we know $F\subseteq L$ after \textsc{Find}. \end{proof} \iffalse \begin{proof} Suppose there are $F\setminus L = B \neq \emptyset$. Since $B\subseteq F$, by Claim \ref{clm:worst_expansion}, $|\Gamma(B)| \geq (1-\Delta)D|B|$. So the number of unique neighbors is at least $(1-2\Delta)D|B|$. Hence there is a $v\in B$ which has at least $(1-2\Delta)D$ unique neighbors. But $v$ is not in $L$, meaning it has $<(1-2\Delta)D$ neighbors in $R$. So it has a unique neighbor which is not in $R$. This is a contradiction since this unique neighbor corresponds to an unsatisfied check which has to be in $R_0 \subseteq R$. \end{proof} \fi Then we calculate the decoding radius and the size of $L$. \iffalse \begin{claim}\label{clm:upper_bound_neighbors} For both $\Delta=\varepsilon$ and $\Delta=\sqrt{\varepsilon \gamma x}$, $|\Gamma(L)| \le |\Gamma(F)| + 2 \Delta D \cdot |L \setminus F|$. \end{claim} \begin{proof} Let $(v_1,\ldots,v_{|L|})$ be the sequence of vertices added to $L$ in the while. By Lemma \ref{lemma:L'allsame}, we can adjust the order of the sequence by putting the vertices in $F$ at first and then put the vertices in $L \setminus F$ after them. The upper bound follows from the fact $F \subseteq L$ from Claim \ref{claim:FsubseteqL} and each vertex in $L \setminus F$ contributes at most $2 \Delta$ to $R$. \end{proof} \fi \begin{claim} \label{claim:guessExpansionLbound1} For $\Delta=\sqrt{\tilde{\gamma}\tilde{x} \varepsilon } $, if $x \in [1, \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N)]$, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose after the iterations, $|L| \ge \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Let $\delta=\frac{1 - 2 \sqrt{\gamma x \varepsilon}}{2 \varepsilon} - x$. Notice that $\delta \geq 0$. This is because by Lemma \ref{lem:expansion_larger} , $\gamma \leq x \varepsilon + O_\varepsilon(1/N)$ when $x\geq 1$. So $\delta=\frac{1 - 2 \Delta}{2 \varepsilon} - x \geq \frac{1-2\varepsilon x -O_\varepsilon(1/N)}{2\varepsilon} - x = \frac{1}{2\varepsilon} - 2x -O_\varepsilon(1/N)$. Since $\varepsilon \leq 1/8$, $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N) $, one can check that $\delta \geq 0$. Also notice that $ x+ \delta \geq \frac{1 }{2 \varepsilon} - x -O_\varepsilon(1/N)\geq 1 $ when $\varepsilon \leq 1/8$. By Claim \ref{clm:worst_expansion} and Lemma \ref{lemma:FAddtoLFirst}, we can let $L' \subseteq L$ be constituted by first adding $F$ and then $\delta \alpha N$ vertices in $L\setminus F$. Notice that all the unsatisfied checks are in $\Gamma(F)$, $|\Gamma(F)| \leq D|F|$, and every element in $L'\setminus F$ contributes at most $2\varepsilon D$ vertices to $R$. Hence $|\Gamma(L')| \le |\Gamma(F)|+2\Delta D\cdot \delta \alpha N$. On the other hand, Lemma~\ref{lem:expansion_larger} implies $|\Gamma(L')| \ge (1-(x+\delta)\varepsilon)D \cdot (x+\delta)\alpha N - O_\varepsilon(1)$. Thus we have \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta)\alpha N - O_\varepsilon(1)\le (1-\gamma)x \alpha N + 2 \Delta \cdot \delta \alpha N. \] Notice that $\Delta \leq \sqrt{\gamma x \varepsilon}$, so the R.H.S. is at most $(1-\gamma)x \alpha N + 2 \sqrt{\gamma x \varepsilon} \cdot \delta \alpha N$. In the rest of this proof, we show that our choice of $\delta$ yields \begin{equation}\label{eq:ineq1} (1 - (x+\delta)\varepsilon) \cdot (x+ \delta) - O_\varepsilon(1/N) > (1-\gamma) x + 2 \sqrt{\gamma x \varepsilon}\cdot \delta. \end{equation} This gives a contradiction. Towards that, we rewrite inequality~\eqref{eq:ineq1} as \[ 0 > \varepsilon \delta^2 + (2 \varepsilon x - 1 + 2\sqrt{\gamma x \varepsilon})\delta + \varepsilon x^2 - \gamma x + O_\varepsilon(1/N) . \] When $(2 \varepsilon x - 1 + 2 \sqrt{\gamma x \varepsilon})^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O_\varepsilon(1/N) \right)>0$, the quadratic polynomial will be negative at $\delta_0=\frac{1 - 2 \varepsilon x - 2 \sqrt{\gamma x \varepsilon}}{2\varepsilon}=\delta $. To verify $(2 \varepsilon x - 1 + 2 \sqrt{\gamma x \varepsilon})^2 - 4 \varepsilon \left( \varepsilon x^2 -\gamma x + O_\varepsilon(1/N) \right)>0$, we set $c=\varepsilon x$ and rewrite it as \[ (2c - 1 + 2 \sqrt{\gamma c})^2 - 4 c^2 + 4 \gamma c - O_\varepsilon(1/N) >0. \] This is equivalent to \[ 8 \gamma c + (8c -4 ) \sqrt{\gamma c} + 1 - 4c - O_\varepsilon(1/N) > 0 \Rightarrow 8(\sqrt{\gamma c} +\frac{2c-1}{4})^2 - O_\varepsilon(1/N) + 1 - 4c - 8(\frac{2c-1}{4})^2 > 0. \] When $c=\varepsilon x \leq \frac{\sqrt{2}-1}{2} - O_\varepsilon(1/N)$, i.e. $x \leq \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N)$, the residue $1 - 4c - 8(\frac{2c-1}{4})^2 -O_\varepsilon(1/N)>0$. So the inequality holds. \end{proof} \begin{claim} \label{claim:guessExpansionLbound2} For $\Delta=\varepsilon$, if $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$, then $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. \end{claim} \begin{proof} Suppose $|L| \geq \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Consider $L'\subseteq L$ with $|L'| = \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Let $\delta = \frac{1-2\varepsilon}{2\varepsilon} - x$. Notice that $\delta \geq 0$ because $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. Also $x+ \delta \geq 1$ since $\varepsilon \leq 1/8$. By Lemma \ref{lem:expansion_larger}, $|\Gamma(L')| \geq (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1)$. By Lemma \ref{lemma:FAddtoLFirst} we can consider $L'$ as being constituted by first adding all elements in $F$ and then add another $\delta \alpha N$ elements by the algorithm. Notice that all the unsatisfied checks are in $\Gamma(F)$, $|\Gamma(F)| \leq D|F|$, and every element in $L'\setminus F$ contributes at most $2\varepsilon D$ vertices to $R$. Hence $|\Gamma(L')| \leq D|F| + 2\varepsilon D \delta \alpha N$. So we have \[ (1-(x+\delta)\varepsilon)D |L'| - O_\varepsilon(1) \leq |\Gamma(L')| \leq D|F| + 2\varepsilon D \delta \alpha N \] Thus \[ (1-(x+\delta)\varepsilon) \cdot (x+\delta) - O_\varepsilon(1/N) \le x + 2 \varepsilon \delta. \] So this is equivalent to \[ (1- 2\varepsilon - \varepsilon (x+\delta))(x+\delta) - O_\varepsilon(1/N) \le (1-2\varepsilon) x \] Recall that $\delta+x=\frac{1 -2 \varepsilon}{2\varepsilon}$. To get a contradiction, we only need \[ (1-2\varepsilon) x < (1-2\varepsilon)^2/4\varepsilon - O(1/N). \] Namely $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. \end{proof} \begin{proofof}{Theorem \ref{thm:guessexpansion}} One of our enumerations has $\tilde{x}$ and $\tilde{\gamma}\tilde{x}$ such that $x \in [\tilde{x} , \tilde{x}+ \eta], \gamma x \in [\tilde{\gamma}\tilde{x} ,\tilde{\gamma}\tilde{x}+ \eta]$. Consider Algorithm \ref{alg:decoding_small_eps} under this enumeration. After the function $\mathrm{Find}$, all the errors are in $L$ by Claim \ref{claim:FsubseteqL}. Now we bound $|L|$. When $\tilde{x} < 1 - \eta$ we know $x<1 $ and $\Delta = \varepsilon$ in the algorithm. By Claim \ref{claim:guessExpansionLbound2}, $|L| \leq \frac{1-2\varepsilon}{2\varepsilon}\alpha N $, as long as $x \leq \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)$. When $\tilde{x} \geq 1$, we know $x\geq 1$. To bound $|L|$, we now just need to pick the smaller bound of $x$ from Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2}. If $\varepsilon < \frac{3-2\sqrt{2}}{2} $, then $\frac{\sqrt{2}-1}{2\varepsilon} < \frac{1-2\varepsilon}{4\varepsilon}$. So by Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2} when $x \in [1, \frac{\sqrt{2}-1}{2\varepsilon} - O_\varepsilon(1/N)]$ we have $|L| < \frac{1-2\varepsilon}{2\varepsilon}\alpha N $. If $\varepsilon \in [\frac{3-2\sqrt{2}}{2}, 1/8]$, then $\frac{\sqrt{2}-1}{2\varepsilon} \geq \frac{1-2\varepsilon}{4\varepsilon}$. So by Claim \ref{claim:guessExpansionLbound1} and Claim \ref{claim:guessExpansionLbound2} , when $x \in [1, \frac{1-2\varepsilon}{4\varepsilon} - O_\varepsilon(1/N)]$, we have $|L| < \frac{1-2\varepsilon}{2\varepsilon} \alpha N$. Since the expander is an $(\alpha N, (1-\varepsilon)D)$ expander, by Theorem \ref{thm:decfromerasures}, one can correct all the errors efficiently using $L$ (as the erasure area) and the corrupted codeword. \end{proofof} \section{Improved Distance of Expander Codes}\label{sec:dist_expander} Let $G$ be an $(\alpha N, (1-\epsilon) D)$ expander and $\mathcal{C}$ be the corresponding expander code. We show that when $\varepsilon<1/2$, the distance of $C$ is roughly $\frac{1}{2\varepsilon} \alpha N$. \begin{theorem}\label{thm:dist_expander} Let $G$ be an $(\alpha N, (1-\varepsilon)D)$ bipartite expander. The distance of the expander code defined by $G$ is at least $\frac{\alpha}{2\varepsilon} \cdot N - O(1/\varepsilon)$. \end{theorem} In Section~\ref{sec:bound_dist}, we provide a construction of expander codes to show the above bound $\frac{\alpha}{2\varepsilon} \cdot N$ is almost tight in general. \begin{theorem}\label{thm:tight_distance} Given any constants $0< \varepsilon < 1/2$, $\eta>0$, there exist constants $D$ and $\alpha>0$, such that for infinitely many $N$, there exist $(\alpha N, (1-\varepsilon-\eta)D)$-expanders with $M \in [N/2,2N/3]$ where (1) the rate of the expander code is in $[1/3,1/2]$; and (2) the distance of the expander code is at most $\frac{\alpha}{2\varepsilon} \cdot N$. \end{theorem} \begin{remark} While the graphs we construct in Theorem~\ref{thm:tight_distance} are not strictly regular on the right, they are ``almost regular" in $V_R$, i.e., $D_{max} \leq 1.1 D_R$. \end{remark} To prove Theorem~\ref{thm:dist_expander}, we start with the following lemma which gives a tradeoff between the two parameters $\alpha$ and $\varepsilon$. This is one of our main technical lemmas, and the proof is deferred to Section~\ref{sec:proof_lem_expansion}. \begin{lemma}\label{lem:expansion_larger} For any $k>1$ and any left subset $S$ of size $k \alpha N$, we have \begin{itemize} \item $|\Gamma(S)| \ge (1-k \varepsilon) D \cdot k \alpha N - O(\varepsilon D \cdot k^2)$. \item $|\Gamma(S)| \ge (1-\frac{2k\varepsilon - 1}{3-2/k}) \frac{k}{2} \cdot D \alpha N - O(D_R \cdot D)$ (which is better than the 1st bound for $k>1/2\varepsilon$). \end{itemize} \end{lemma} In particular, the first bound will be extensively used in our decoding algorithms, which shows an $(\alpha N, (1-\epsilon) D)$-expander is also roughly a $(k \alpha N, (1-k \epsilon) D)$-expander for any $k>1$. While this bound is extremely useful for $k \le 1/2\varepsilon$, we will use the second one for larger $k$ to improve the list-decoding radius upon the standard Johnson bound. Using the above lemma, we first prove the following facts in an expander graph. \begin{fact}\label{fact:relations_parameters} Let $G$ be an $(\alpha N, (1-\varepsilon)D)$-expander with left regular degree $D$ and right average degree $D_R$. We always have \begin{enumerate} \item $\varepsilon \ge 1/D$. \item $\frac{\alpha}{4\varepsilon} \le 1/D_R + O(\frac{1}{D \alpha} \cdot M/N^2)$. \end{enumerate} \end{fact} \begin{proof} To prove the first fact, let us consider the smallest non-trivial cycle $C$ in the expander graph $G$. First of all, we observe that $|C|=O(\log |V|)$. To show this, we consider the argument to bound the girth of a graph. Let us fix a vertex $v$ and consider the BFS tree with root $v$. The BFS procedure finds a non-trivial cycle when it finds a vertex in the 2nd time. Since $G$ is $D$-regular in $V_L$, up to depth $2 \log_{D-1} M$, the BFS procedure will find a non-trivial cycle. Then $|\Gamma(C \cap V_L)| \le D \cdot |C \cap V_L|-|C \cap V_R| = (D -1) \cdot |C \cap V_L|$. For the second fact, consider a left subset $S$ of size $2M/D$ in $V_L$. Since $M \le N$ and $D \ge 2$, such an $S$ always exists. Since $|\Gamma(S)| \le M$, we always have \[ (1 - \varepsilon \cdot \frac{|S|}{\alpha N}) \cdot D \cdot |S| - O\left( \varepsilon D \cdot (\frac{2M/D}{\alpha N})^2 \right) \le M. \] This implies \begin{align*} (1 - \varepsilon \cdot \frac{2M/D}{\alpha N}) \cdot D \cdot 2M/D - O(\frac{\varepsilon}{D \alpha^2} \cdot M^2/N^2) & \le M\\ (1 - \varepsilon \cdot \frac{2}{\alpha D_R}) \cdot 2M - O(\frac{\varepsilon}{D \alpha^2} \cdot M^2/N^2) & \le M \qquad (\text{recall } N D=M D_R)\\ M - O(\frac{\varepsilon}{D \alpha^2} \cdot M^2/N^2) & \le \frac{4\varepsilon}{\alpha D_R} \cdot M. \end{align*} So we have $\frac{1}{D_R} \ge \frac{\alpha}{4 \varepsilon} - O(\frac{1}{D \alpha} \cdot M^2/N^2)$, or equivalently, $\frac{\alpha}{4\varepsilon} \le 1/D_R + O(\frac{1}{D \alpha} \cdot M/N^2)$. \end{proof} We can now prove Theorem~\ref{thm:dist_expander}. \begin{proofof}{Theorem~\ref{thm:dist_expander}} Suppose the claim is false, then there exists a non-zero codeword with Hamming weight the same as the distance. Consider any non-zero codeword $z$ of Hamming weight $\frac{\alpha}{2\varepsilon} \cdot N - C/\varepsilon$ for a sufficiently large constant $C$. Notice that the parameter $\frac{\alpha}{2 \varepsilon} \le 2/D_R <1$ from Fact~\ref{fact:relations_parameters}. Let $S \subset [N]$ denote the entries in $z$ that are 1. By Lemma~\ref{lem:expansion_larger}, $\Gamma(S) \ge (1 - \frac{|S|}{\alpha N} \cdot \varepsilon)D \cdot |S| - O(\varepsilon D \cdot (\frac{|S|}{\alpha N})^2)$. For a sufficiently large constant $C$, this is at least \[ (\frac{1}{2} + \frac{C/\varepsilon}{\alpha N} \cdot \varepsilon) D \cdot |S| - O(\varepsilon D \cdot (\frac{|S|}{\alpha N})^2) > \frac{1}{2} \cdot D |S|. \] This implies the existence of unique neighbors in $\Gamma(S)$. Thus $z$ is not a valid codeword, which contradicts our assumption. \end{proofof} \subsection{Distance Upper Bound of Expander Codes}\label{sec:bound_dist} In this section we prove Theorem~\ref{thm:tight_distance}. Given $\eta$ and $\varepsilon$, let $D \ge \frac{1}{\varepsilon \cdot \eta^2}$ be a constant such that there exists a family of degree-$D$ Ramanujan graphs \cite{LPS88} whose 2nd largest absolute value of eigenvalues of the adjacency matrix is $\lambda \le 2\sqrt{D-1}$. In this proof, when the graph $H$ is clear, we use $e(A,B)$ to denote the number of distinct edges between $A$ and $B$. At the same time, we state the following version of the expander mixing lemma by Alon and Chung \cite{AlonChung1988}. \begin{lemma}[Lemma 2.3 in \cite{AlonChung1988}]\label{lem:expander_mixing} Let $H=(V,E)$ be an expander with degree $D$, where the second largest absolute value of eigenvalues of the adjacency matrix is $\lambda$. Then for any subset $A \subset V$, $e(A,A)$, the number of edges inside $A$, is bounded by \[ \left| e(A,A) - \frac{D}{2|V|} \cdot |A|^2 \right| \le \lambda/2 \cdot \sqrt{|A| \cdot (|V|-|A|)}. \] \end{lemma} We now construct an $(\alpha N, (1-\varepsilon-\eta)D)$-expander graph with $N+M$ vertices by putting together two disjoint graphs $G_0$ and $G_1$. For $G_0$, we first choose a Ramanujan graph $H$ with degree $D$ and size $N' = \frac{\alpha}{2\varepsilon} \cdot N$ in the family for a sufficiently small $\alpha$. Then we construct $G_0$ as the vertex-edge bipartite graph corresponding to $H$. Namely $V_L(G_0)=V(H)$ and $V_R(G_0)=E(H)$ such that $(v,e) \in E(G_0)$ if and only if $v \in V(H)$ is a vertex in the edge $e \in E(H)$ of $H$. Notice that $G_0$ has left degree $D$. \begin{claim}\label{claim:explicit_construction} The bipartite graph $G_0$ constructed above is an $(\alpha N, (1-\varepsilon-\eta)D)$-expander. \end{claim} \begin{proof} For any $S \subseteq V_L(G_0)$, $|\Gamma(S)|$ is the number of distinct edges connected to $S \subset V(H)$ in $H$, i.e., $e(S,V(H))$ in the Ramanujan graph $H$. We rewrite $e(S,V(H))=e(S,S)+e(S,\overline{S})$. Since $2 e (S,S)+e(S,\overline{S})=D \cdot |S|$, we upper bound $e(S,S)$ by the expander mixing lemma: \[ e(S,S) \le \frac{D}{2|V(H)|} \cdot |S|^2 + \lambda/2 \cdot \sqrt{|S| \cdot (|V(H)|-|S|)} \le D \cdot |S| \left (\frac{|S|}{2|V(H)|} + \frac{\lambda}{2D} \cdot \sqrt{\frac{|V(H)-|S|}{|S|}} \right). \] Since $|S| \le \alpha N$, $|V(H)|=\frac{\alpha}{2\varepsilon} \cdot N$ and $\lambda/D \le \frac{2}{\sqrt{D}} \le 2 \eta \sqrt{\varepsilon}$, we have $e(S,S) \le (\varepsilon + \eta) D \cdot |S|$ and $e(S,V(H)) = D \cdot |S| - e(S,S) \ge (1-\varepsilon-\eta) \cdot D |S|$. \end{proof} Then we construct $G_1$ as a random regular bipartite graph with $|V_L(G_1)|=N_1=N-N'$, $|V_R(G_1)|=M_1=M-DN'/2$, regular left degree $D$ and regular right degree $D_R=N_1 \cdot D/M_1$. Since we can choose $\alpha$ to be sufficiently small and $M \in [N/2,2N/3]$, such an integer $D_R$ exists. Furthermore, a random bipartite graph with such parameters satisfies $(\alpha N, (1-\varepsilon)D)$ expansion with high probability for a small $\alpha$. For completeness we show this calculation in Appendix~\ref{appen:proof_expansion} and assume this property in the rest of this proof. Overall, because both $G_0$ and $G_1$ satisfy $(\alpha N, (1-\varepsilon-\eta)D)$ expansion, $G= G_0 \cup G_1$ is an $(\alpha N, (1-\varepsilon-\eta)D)$ expander. Moreover, $G$ is almost regular since $G_0$ is small and $G_1$ is regular on both sides. Finally, consider a cedeword that is all $1$ in $V_L(G_0)$, and $0$ everywhere else. It satisfies all parity checks since the right degree of $V_R(G_0)$ is 2. Moreover, its weight is $\frac{\alpha}{2\varepsilon} N$, and thus the distance of the corresponding expander code is at most $\frac{\alpha}{2\varepsilon} N$. \subsection{Proof of Lemma~\ref{lem:expansion_larger} and Its Generalization}\label{sec:proof_lem_expansion} We prove the first lower bound $|\Gamma(S)| \ge (1-k \varepsilon) D \cdot |S| - O(D \cdot k^2)$ by a probabilistic argument. Suppose $|\Gamma(S)|$ is small. Then we consider a random subset $T$ of size $\alpha N$ in $S$ and upper bound \[ \big| \Gamma(T) \big| \le D \cdot |T| - \left(|S| \cdot D - \big |\Gamma(S) \big| \right) \cdot \frac{|T| \cdot (|T|-1)}{|S| \cdot (|S| - 1)}. \] The reason is that consider any neighbor $u$ of $S$ with more than $1$ neighbors in $S$, say $u$ has $d_S(u)$ neighbors in $S$ which are $v_1,\ldots,v_{d_S(u)}$. Since \[ 1\{u \in \Gamma(T)\} \le \sum_{i=1}^{d_S(u)} 1\{v_i \in T\} - \sum_{i=2}^{d_S(u)} 1\{v_1\in T\} \cdot 1\{v_i\in T\} \] Then we take expectation (over $T$) on both sides: \begin{equation}\label{eq:single_vertex} \E_T\left[1\{u \in \Gamma(T)\}\right] \le d_S(u) \cdot \frac{|T|}{|S|} - (d_S(u)-1) \cdot \frac{|T| \cdot (|T|-1)}{|S| \cdot (|S|-1)}. \end{equation} At the same time, we know \begin{equation}\label{eq:two_sums} \sum_{u \in \Gamma(S)} d_S(u)=D \cdot |S| \text{ and } \sum_{u \in \Gamma(S)} (d_S(u)-1) = D \cdot |S| - |\Gamma(S)| \end{equation} Then we consider the summations over $u\in \Gamma(S)$ on the two sides of \eqref{eq:single_vertex}: By linearity of expectation, it becomes \begin{align*} \E_T\left[ \big| \Gamma(T) \big| \right] & \le \sum_u d_S(u) \cdot \frac{|T|}{|S|} - \sum_u (d_S(u)-1) \cdot \frac{|T| \cdot (|T|-1)}{|S| \cdot (|S|-1)} \tag{plug the two summations of \eqref{eq:two_sums}}\\ & = D \cdot |T| - \bigg(|S| \cdot D - \big| \Gamma(S) \big| \bigg) \cdot \frac{|T| \cdot (|T|-1)}{|S| \cdot (|S|-1)} \\ & = |T| \cdot D \left( 1 - \bigg( 1 - \frac{\big| \Gamma(S) \big|}{D \cdot |S|} \bigg) \cdot \frac{ |T|-1}{ |S| - 1} \right) . \end{align*} On the other hand, this is at least $|T| \cdot D (1-\varepsilon)$ by the expander property. So we have \[ 1-\varepsilon \le 1 - \bigg( 1 - \frac{\big| \Gamma(S) \big|}{D \cdot |S|} \bigg) \cdot \frac{ |T|-1}{ |S| - 1} \quad \Leftrightarrow \quad \varepsilon / \frac{ |T|-1}{ |S| - 1} \ge 1 - \frac{\big| \Gamma(S) \big|}{D \cdot |S|}. \] This gives \[ \frac{\big| \Gamma(S) \big| }{D \cdot |S|} \ge 1 - \varepsilon \cdot \left( k + \frac{k-1}{\alpha N - 1} \right). \] We rewrite it to obtain \[ \big| \Gamma(S) \big| \ge (1-\varepsilon k) \cdot D |S| - \varepsilon \frac{(k-1)}{\alpha N-1} \cdot D |S| \ge (1-\varepsilon k) \cdot D |S| - 2 \varepsilon D k^2. \] \paragraph{Generalization.} Next we consider an alternative way to compute $\E[\Gamma(T)]$. The main motivation is to prove a better bound than the above one for $k>1/2\varepsilon$. Let us fix $S$ of size $k \alpha N$ and consider $\Gamma(S)$. Since the total degree of $S$ is $D \cdot k \alpha N$, let $\beta_j \cdot D \alpha N$ denote the number of vertices in $\Gamma(S)$ with exactly $j$ neighbors in $S$. By the definition, \[ \Gamma(S)=(\beta_1 + \cdots + \beta_k) \cdot D \alpha N. \] Moreover, By summing up the degrees, we have \[ \beta_1 + 2 \beta_2 + \cdots + D_R \cdot \beta_{D_R} = k. \] Now we consider \begin{equation}\label{eq:exp_neighbors} \E[\Gamma(T)]=\sum_{i \in \Gamma(S)} \Pr_{T \sim {S \choose \alpha N}}[T \cap \Gamma(i) \neq \emptyset], \end{equation} which is at least $(1-\varepsilon)D \alpha N$ from the property of expansion. For each $i \in \Gamma(S)$ with exactly $j$ edges to $S$, \[ \Pr_{T}[T \cap \Gamma(i) \neq \emptyset] = 1 - \Pr_{T}[T \cap \Gamma(i) = \emptyset] = 1 - \frac{(|S|-|T|) \cdot (|S|-|T|-1) \cdots (|S|-|T|- j + 1)}{|S| \cdot (|S|-1) \cdots (|S|-j+1)}. \] Since we assume $k,D,D_R,\alpha,\varepsilon=\Theta(1)$ and $|S|,|T|=\Theta(N)$, we simplify this probability to \[ \Pr_T[T \cap \Gamma(i) \neq \emptyset]=1 - (\frac{|S|-|T|}{|S|})^j + \frac{O(j)}{|S|} = 1 - (1- \frac{1}{k})^j + O(\frac{D_R}{k \alpha N}) \] and omit the error term $O(\frac{D_R}{k \alpha N})$ for ease of exposition. Plugging this into Eq\eqref{eq:exp_neighbors}, we have the inequality \[ \sum_{j=1}^{D_R} \left[ 1 - (1-\frac{1}{k})^j \right] \cdot \beta_j \ge (1-\varepsilon). \] To lower bound $\Gamma(S)$, we rewrite all constraints as a linear programming: \begin{align} & \min \beta_1 + \cdots + \beta_{D_R} \notag \\ \text{subject to } & \beta_1 + 2 \cdot \beta_2 + \cdots D_R \cdot \beta_{D_R} = k \label{eq:sum_deg}\\ & \sum_{j=1}^{D_R} \left[ 1 - (1-\frac{1}{k})^j \right] \cdot \beta_j \ge (1-\varepsilon) \label{eq:expected_neighbors}\\ & \beta_j \ge 0, \quad \forall j. \notag \end{align} Next we prove that (1) the minimum is achieved by $\beta^*$ with at most two non-zero entries; (2) more importantly, if $\beta^*$ has exactly two non-zero entries, they must be adjacent. We could consider the dual of the above linear program \begin{align} & \max k \cdot x_1 + (1-\varepsilon) \cdot x_2 \notag\\ \text{subject to } & j \cdot x_1 + [1-(1-1/k)^j] \cdot x_2 \le 1 \quad \forall j=1,\ldots,D_R, \label{eq:dual_constraint}\\ & x_2 \ge 0. \notag \end{align} The key property is that those coefficients $\left[ 1 - (1-\frac{1}{k})^j \right]$ in constraints \eqref{eq:expected_neighbors} and \eqref{eq:dual_constraint} constitute a strictly concave curve. Namely, for any $j$, \begin{equation}\label{ineq:concave} \left[ 1 - (1-\frac{1}{k})^j \right] - \left[ 1 - (1-\frac{1}{k})^{j-1} \right] > \left[ 1 - (1-\frac{1}{k})^{j+1} \right] - \left[ 1 - (1-\frac{1}{k})^{j} \right]. \end{equation} Inequality \eqref{ineq:concave} is true for any $j>1$ since $1+(1-1/k)^2 > 2 (1-1/k)$. For contradiction, if $\beta^*$ is supported on three entries say $\ell_1<\ell_2<\ell_3$, we have $j \cdot x_1 + [1-(1-1/k)^j] \cdot x_2=1$ for $j=\ell_1,\ell_2,\ell_3$ by the slackness of linear programming. However, the two equations for $j=\ell_1, \ell_3$ indicate $\ell_2 \cdot x_1 + [1-(1-1/k)^{\ell_2}] \cdot x_2 > 1$. While their linear combination with coefficients $\frac{\ell_3-\ell_2}{\ell_3-\ell_1}$ and $\frac{\ell_2-\ell_1}{\ell_3-\ell_1}$ equals $1$ on RHS from these two equations, this combination on LHS is strictly less than $\ell_2 \cdot x_1 + [1-(1-1/k)^{\ell_2}] \cdot x_2$ in the equation of $j=\ell_2$ by $x_2 \ge 0$ and the concavity of $[1-(1-1/k)^j]$. Similarly, if $\beta^*$ is supported on two non-adjacent entries say $\ell_1<\ell_2$, we have two equations for $j=\ell_1$ and $j=\ell_2$ separately. However, the solution of $(x_1,x_2)$ which satisfies these two equations violates other constraints in the dual --- one can show $(\ell_1+1) \cdot x_1 + [1-(1-1/k)^{\ell_1+1}] \cdot x_2 > 1$ by the same argument again. Now we prove the 2nd lower bound. Let us consider the dual probram where $x_1$ and $x_2$ are determined by \eqref{eq:dual_constraint} with $j=2$ and $j=3$: \begin{align*} 2 x_1 + (2/k - 1/k^2) x_2 & = 1, \\ 3 x_1 + (3/k - 3/k^2 + 1/k^3) x_2 & = 1. \end{align*} We get $x_1=\frac{2-1/k-k}{3-2/k}$ and $x_2=\frac{k^2}{3-2/k}$ such that the objective value is $k \cdot x_1 + (1-\varepsilon)x_2= \frac{2k-1-\varepsilon k^3}{3-2/k}=\frac{k}{2} (1-\frac{2k\varepsilon - 1}{3-2/k})$ (we omit the error $k \cdot O(\frac{D_R}{k \alpha N})$). One can verify this pair of $(x_1,x_2)$ is feasible: \eqref{eq:dual_constraint} is true for $j=1$ since $x_1+\frac{1}{k} x_2=\frac{2-1/k}{3-2/k} \le 1$ given $k>1$. \eqref{eq:dual_constraint} is also true for $j>3$ by the concavity again. So this shows $\min \beta_1 + \cdots + \beta_{D_R}$ of the original LP is at least $\frac{k}{2} (1-\frac{2k\varepsilon - 1}{3-2/k})$. In fact, the first lower bound is obtained from the dual where $x_1$ and $x_2$ are determined by \eqref{eq:dual_constraint} with $j=1$ and $j=2$. Finally we remark that when $1-\varepsilon \in \bigg[ \frac{k}{j+1} \cdot [1-(1-1/k)^{j+1}], \frac{k}{j} \cdot [1-(1-1/k)^j] \bigg]$, the two non-zero entries of $\beta^*$ in the primal are $\beta^*_j$ and $\beta^*_{j+1}$. This indicates that $\frac{k}{2} (1-\frac{2k\varepsilon - 1}{3-2/k})$ is the optimum value of the linear program when $1-\varepsilon \in [1 - \frac{1}{k} + \frac{1}{3k^2}, 1 - \frac{1}{2k}]$, or equivalently, $1/2\varepsilon \le k \le \frac{2/3}{1 - \sqrt{1 - 4\varepsilon/3}}=\frac{1+\sqrt{1-4\varepsilon/3}}{2\varepsilon}$. \iffalse One way to improve this claim is to choose a particular subset $S$. \textcolo1/2\epsr{blue}{As Xin suggested,} we could choose a subset $T$ in $R$ of size $k/D_R \cdot \alpha N$ and set $S$ as its neighbor set $\Gamma(T)$. In another word, this is saying the number of vertices in $\Gamma(S)$ with degree $D_R$ is at least $k/D_R \cdot \alpha N$, i.e., $\beta_{D_R} \ge \frac{k}{D D_R}$. So the L.P. becomes \begin{align*} & \min \beta_1 + \cdots + \beta_k \notag \\ \text{subject to } & \beta_1 + 2 \cdot \beta_2 + \cdots D_R \cdot \beta_{D_R} = k \\ & \sum_{j=1}^{D_R} \left[ 1 - (1-\frac{1}{k})^j \right] \cdot \beta_j \ge (1-\varepsilon)\\ & \beta_{D_R} \ge \frac{k}{D D_R}. \end{align*} Similar to the above analysis, \textcolor{blue}{I guess} when $k$ and $\varepsilon$ satisfy \[ \beta_2 \cdot [1-(1-1/k)^2] +\beta_{D_R} \cdot [1-(1-1/k)^{D_R}]=(1-\varepsilon)\] for $\beta_{D_R}=k/D D_R$ and $\beta_2=(k-k/D)/2$, the minimal value is $\beta_2+\beta_{D_R}=k \cdot (\frac{1}{2} - \frac{1}{2D} + \frac{1}{D D_R}).$ Namely, \textcolor{blue}{not sure how to simplify the relation about $k$ and $\varepsilon$} \begin{align*} k(1-1/D)/2 \cdot (2/k - 1/k^2) + k/D D_R \cdot (1-(1-1/k)^{D_R}) & = 1-\varepsilon \\ (1-1/D) \cdot (1 - 1/2k) + k/D D_R & \approx 1 - \varepsilon \\ 1/D + 1/2k - 1/2k D - k/D D_R & \approx \varepsilon\\ \end{align*} \fi \iffalse \textcolor{red}{Here is the calculation with $D_R$.} , say $\beta_1$ and $\beta_j$. \textcolor{blue}{Xue: I think one non-zero entry must be $\beta_1$; but this may need a formal proof.} Let $c_j<1$ be a constant such that \[ c_j \cdot \eqref{eq:sum_deg} + (1-c_j)k \cdot \eqref{eq:expected_neighbors} \ge \beta_1 + \beta_j. \] This implies \[ c_j \cdot j + (1-c_j) \cdot k(1-(1-1/k)^j) \ge 1 \quad \Rightarrow \quad c_j \ge \frac{1-k(1-(1-1/k)^j)}{j-k(1-(1-1/k)^j)}. \] In the rest of this section, we show $\frac{1-k(1-(1-1/k)^j)}{j-k(1-(1-1/k)^j)} \le 0$ is increasing from $j=2$ to $j=D_R$ such that the minimum of the LP is achieved by $\beta_1$ and $\beta_{D_R}$. Let us show \begin{align*} \frac{1-k(1-(1-1/k)^j)}{j-k(1-(1-1/k)^j)} & < \frac{1-k(1-(1-1/k)^{j+1})}{j+1-k(1-(1-1/k)^{j+1})} \\ \Leftrightarrow \left(1-k(1-(1-1/k)^j)\right) \cdot \left(j+1-k(1-(1-1/k)^{j+1}\right) & < \left(1-k(1-(1-1/k)^{j+1})\right) \cdot \left(j-k(1-(1-1/k)^j)\right) \\ \Leftrightarrow (j+1)-(j+1)k[1-(1-1/k)^j] -k [1 - (1-1/k)^{j+1}] & + k^2[1-(1-1/k)^j][1-(1-1/k)^{j+1}] \\ < j-jk[1-(1-1/k)^{j+1}] -k [1 - (1-1/k)^{j}] & + k^2[1-(1-1/k)^j][1-(1-1/k)^{j+1}]\\ \Leftrightarrow 1 & < jk[1-(1-1/k)^j] - (j-1)k[1-(1-1/k)^{j+1}]\\ \Leftrightarrow j(1-1/k)^j - (j-1) \cdot (1-1/k)^{j+1} & < 1 - 1/k\\ \Leftrightarrow (1-1/k)^{j} \cdot (j/k + 1 - 1/k) & < 1 - 1/k. \end{align*} Since the left hand side is at most $(1-1/k) \cdot (1-1/k)^{j-1} (1+1/k)^{j-1} = (1-1/k) \cdot (1-1/k^2)^{j-1}$, the above fact is true. So the minimal value of the L.P. is \[ \frac{1-k(1-(1-1/k)^{D_R})}{D_R-k(1-(1-1/k)^{D_R})} \cdot k + (1-\frac{1-k(1-(1-1/k)^{D_R})}{D_R-k(1-(1-1/k)^{D_R})}) \cdot k(1-\varepsilon) = k - k \varepsilon \cdot \frac{D_R - 1}{D_R - k\big(1-(1-\frac{1}{k})^{D_R} \big)}. \] \fi \section{Decoding from Erasures, and Finding Possible Corruptions}\label{sec:find} First, we show that by combining Lemma \ref{lem:expansion_larger} and Theorem \ref{thm:vidermandecfromerasures}, we can also get a stronger result for decoding from erasures. \begin{theorem} \label{thm:decfromerasures} Consider an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander $G$. For every $\xi > 0$, there is a linear-time algorithm that corrects $\frac{1-\xi}{2\varepsilon}\alpha N$ erasures. \end{theorem} \begin{proof} By Lemma \ref{lem:expansion_larger}, for any $1 \leq k \leq \frac{1}{\alpha}$ the expander is also a $(k\alpha N, (1-k\varepsilon)D-O_\varepsilon(\frac{1}{ N}))$ expander. Thus if $1 - k\varepsilon - O_\varepsilon(1/N) >1/2 + \xi'$ for a $\xi' > 0$, then by Theorem \ref{thm:vidermandecfromerasures}, one can decode from $k\alpha N$ erasures, using the same algorithm. This means $k $ can be as large as $ \frac{1-\xi}{2\varepsilon} $ for any $\xi > 0$. Notice that if $ \frac{1-\xi}{2\varepsilon} \leq 1 $ the theorem is trivially true by Theorem \ref{thm:vidermandecfromerasures}, and $ \frac{1-\xi}{2\varepsilon} \leq \frac{1}{\alpha} $ by Fact~\ref{fact:relations_parameters}. \end{proof} Next, we provide a simple algorithm to find a super set of the corruptions, which is adapted from a similar algorithm in \cite{Viderman13b}. Let $G$ be an $(\alpha N, (1-\varepsilon)D)$ expander with $N$ left vertices $M$ right vertices and left degree $D$. Let $\mathcal{C}$ be an expander code defined by $G$. The input $y$ is a corrupted message of a codeword $C_0 \in \mathcal{C}$. Let $F$ be the set of corruptions in $y$ compared to $C_0$. We use Algorithm \ref{alg:FindingErasure} to find a super set of $F$ given certain parameters. \begin{algorithm}[h] \caption{The basic algorithm finding a super set of corruptions}\label{alg:FindingErasure} \begin{algorithmic}[1] \Function{Find}{$y \in \mathbf{F}_2^N$ and $\Delta \in \mathbf{R}$} \State $L \gets \emptyset$ \State $R \gets \{\text{unsatisfied parity checks of } y\}$ \State $h \gets (1-2\Delta)D$ \While{$\exists i \in V_L \setminus L$ s.t. $|\Gamma(i) \cap R| \ge h $} \State $L \gets L \cup \{i\}$ \State $R \gets R \cup \Gamma(i)$ \EndWhile \State \Return $L$ \EndFunction \end{algorithmic} \end{algorithm} By a similar proof to that of proposition 4.3 in \cite{Viderman13b}, we have the following properties. \begin{lemma} \label{lemma:all_errors_in_L} If $|\Gamma^1(S)| \geq (1-2\Delta)D |S|$ for any non-empty $S \subseteq F$, then $F$ is contained in $L$ after the while loop. \end{lemma} \begin{proof} Suppose not, then let $B $ be $ F \setminus L$ after running the algorithm, $B\neq \emptyset$. Since $B \subseteq F$, we have $|\Gamma^1(B)| \geq (1-2\Delta)D|B|$. So there is a vertex $u\in B$ such that $u$ has at least $(1-2\Delta)D$ unique neighbors in $\Gamma(B)$. We know that $|\Gamma(u) \cap R| < (1-2\Delta)D$, because otherwise $u$ should be added to $R$ then. Thus there has to be a neighbor $v$ of $u$, such that $v$ is not in $R$ and is only connected to one vertex in $B$, which is $u$. As $F\setminus B \subseteq L$, we know $\Gamma(F\setminus B) \subseteq R$. So $v$ connects to one vertex, i.e., $u$ in $F$. This is not possible since then $v$ has to be unsatisfied and thus it is already in $R$. \end{proof} \begin{lemma} \label{lemma:L'allsame} In every iteration, if there are multiple vertices that can be added to $L$ and we choose one of them arbitrarily, then we always get the same $L$ after all the iterations. \end{lemma} \begin{proof} Consider two different procedures where they choose different vertices to add to $L$ in their corresponding iterations. Suppose that they get two different $L$, say $L_1$ for the first procedure and $ L_2$ for the second. Without loss of generality assume $L_1 \setminus L_2 \neq \emptyset$. Let $u$ be the first vertex in $L_1 \setminus L_2$ that is added in procedure 1. Then all the vertices in $L_1$ added before $u$, denoted by the set $A$, is also contained in $L_2$. Since vertices can only be added to the set $R$, for procedure 2 we should always have $|\Gamma(\{u\})\cap R| \geq h$ when $ A \subseteq L_2$ and $u \notin L_2$. Thus $u$ has to be added to $L_2$ in procedure 2. This is a contradiction. Therefore $L_1 = L_2$. \end{proof} \begin{lemma} \label{lemma:FAddtoLFirst} If $ |\Gamma^1(S)| \geq (1-2\Delta)D |S| $ for any non-empty $S \subseteq F$, then there exists a sequence of choices of the algorithm such that all the elements of $F$ can be added to $L$ in the first $|F|$ iterations. \end{lemma} \begin{proof} We use inductions to show that in each of the first $|F|$ iterations, there exists an element in $F\setminus L$ which can be added to $L$. In the first iteration, since $|\Gamma^1(F)| \geq (1-2\Delta)D |F|$, there exists $u\in F$ such that $|\Gamma(u) \cap \Gamma^1(F)| \ge h$ for $h=(1-2\Delta)D$. Notice that all these neighbors should be unsatisfied and thus in $R$. So $u$ can be added to $L$. Assume in each of the first $i-1<|F|$ iterations, the algorithm can find a distinct element in $F$ to add to $L$. In the $i$-th iteration, let $B = F\setminus L$. Notice that $|F'| = |F|-(i-1)\geq 1$. Hence $|\Gamma^1(F')|\geq (1-2\Delta)D|F'|$. Thus there exists $u \in F'$ such that $|\Gamma(u) \cap \Gamma^1(F')| \geq (1-2\Delta)D = h$. Notice that all these neighbors of $u$ in $\Gamma^1(F')$ have to be in $R$, since otherwise there is a neighbor not in $R$, which also corresponds to an unsatisfied check, contradicting that all the unsatisfied checks are in $R$. Hence $|\Gamma(u) \cap R | \geq (1-2\Delta)D = h$. So $u$ can be added to $L$. \end{proof} The above lemmas imply that as long as $ |\Gamma^1(S)| \geq (1-2\Delta)D |S| $ for any non-empty $S \subseteq F$, when analyzing Algorithm \ref{alg:FindingErasure}, we can assume without loss of generality that the algorithm first adds all corrupted bits into the set $L$. \section{Unique Decoding by Guessing Expansion with Iterative Flipping }\label{sec:guess_flip} Let $\varepsilon \in (0, 1/4)$ be an arbitrary constant in this section. We first show an algorithm which has a decoding radius $(1-\varepsilon)\alpha N$. Then by using Lemma \ref{lem:expansion_larger}, we show that the algorithm achieves decoding radius approximately $\frac{3 \alpha}{16\varepsilon} N$. The basic idea of the algorithm is to guess the expansion of the set of corrupted entries in the algorithm, say $(1-\gamma)D$. Assume we can correctly guess $\gamma$. For the case of $\gamma \geq \frac{2}{3}\varepsilon$, we use a procedure similar to \cite{Viderman13b} to find a super set of possible corruptions, and then decode from erasures. In this case we show that $(1-\varepsilon)\alpha N$ errors can be corrected. For the case of $\gamma < \frac{2}{3}\varepsilon$, we first consider the left subset which contains all vertices with at least $1-3\gamma$ unsatisfied checks, and show that this set contains (a constant fraction) more corrupted bits than correct bits. Thus we can flip all bits in this set and reduce the number of errors by a constant fraction. The algorithm then repeats this step for a constant number of times, until the number of errors is small enough, where we can apply an existing algorithm to correct the remaining errors. We describe our algorithm in Algorithm~\ref{alg:MultipleGuessWithFlips} and then state our main result of this section. \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon = 1/4- \beta$}\label{alg:MultipleGuessWithFlips} \begin{algorithmic}[1] \Function{Final Decoding}{$y \in \mathbf{F}_2^n, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} //The main procedure. \State Enumerate $\gamma_1, \gamma_2, \ldots, \gamma_l$ where $\ell = O(\log_{1-O(\beta)}\frac{1}{3})$. For every $ i\in [\ell]$, $\gamma_i$ is enumerated from the set $\{ \eta, 2\eta, \ldots, \lceil\frac{1}{\eta} \rceil \eta \}$, where $\eta:=\beta/100$. \For{enumeration $\gamma_1, \gamma_2, \ldots, \gamma_\ell$} \State $C' \gets$ \Call{Decoding}{$y, \gamma_1, \ldots,\gamma_{\ell}, \alpha, \varepsilon$} \If{$C'$ is a valid codeword and the distance between $C'$ and $y$ is at most $(1-\varepsilon) \alpha N$} \State \Return $C'$ \EndIf \EndFor \EndFunction \Function{Decoding}{$y \in \mathbf{F}_2^n$ and $(\gamma_1,\ldots,\gamma_{\ell}) \in \mathbf{R}^{\ell}, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} \State $z \gets y$ \For{$i=1,\ldots,\ell$} \If{$\gamma_i \ge 2\varepsilon/3 + \eta $} \State $z \gets$ \Call{FixedFindAndDecode}{$z, \alpha, \varepsilon$} \State \Return $z$ \Else \State Let $L_0$ denote all bits in $z$ with at least $(1-3 \gamma_i)D$ wrong parity checks \State Flip all the bits in $L_0$ \EndIf \EndFor \State Apply the decoding of Theorem \ref{thm:vidermandec} on $z$ and return the result. \EndFunction \Function{FixedFindAndDecode}{$y \in \mathbf{F}_2^N, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} \State $L \gets $ \Call{Find}{$y, \varepsilon$}, where \Call{Find}{} is from Algorithm \ref{alg:FindingErasure}. \State Erase the symbols of $y$ that have indices in $L$ to get $y'$, and then apply the decoding from Theorem \ref{thm:decfromerasures} on $y'$ to get a codeword $C'$. \State \Return $C'$ \EndFunctio \end{algorithmic} \end{algorithm} \begin{theorem} \label{thm:MultipleGuessWithFlips} For every small constant $\beta > 0$, and every $\varepsilon \leq 1/4 - \beta $, let $\mathcal{C}$ be an expander code defined by a $(\alpha N, (1-\varepsilon)D)$ expander graph. There is a linear time decoding algorithm for $\mathcal{C}$ with decoding radius $(1-\varepsilon ) \cdot \alpha N$. \end{theorem} To prove the theorem, we focus on the $i$-th iteration of Function \textsc{Decoding}, and show that we can make progress (either reducing the number of errors or decoding the original codeword) in this iteration. Let $F_i$ denote the set of errors at the beginning of iteration $i$ and $\gamma(F_i) \in [0,\varepsilon]$ be the parameter such that $| \Gamma(F_i) | = (1-\gamma(F_i)) \cdot D|F_i|$. First we show Function \textsc{FixedFindAndDecode} will recover the codeword directly whenever $\gamma_i \ge \frac{2\varepsilon}{3}+\eta$ and $\gamma(F_i) \ge \frac{2\varepsilon}{3}$. \begin{claim}\label{clm:small_gamma} If $|F_i| \leq (1-\varepsilon ) \cdot \alpha N$, $\gamma_i \ge \frac{2\varepsilon}{3} + \eta$, and $\gamma(F_i) \in [\gamma_i-\eta , \gamma_i )$, then Function \textsc{FixedFindAndDecode} in \textsc{Decoding} will return a valid codeword directly. \end{claim} \begin{proof} First notice that when $\gamma_i \ge \frac{2\varepsilon}{3}+\eta$, this iteration of Function \textsc{Decoding} will go to Function \textsc{FixedFindAndDecode}. Let $\gamma:= \gamma(F_i)$. We prove that $L$ after \textsc{Find} has size at most $\alpha N$. Suppose not. Since $|F_i| \leq (1-\varepsilon ) \cdot \alpha N$, by the expander property, for every nonempty $ F'\subseteq F_i, |\Gamma(F')| \geq (1-\varepsilon)D|F'|$, so by Lemma \ref{lemma:all_errors_in_L}, after \textsc{Find}, $L$ covers all the errors. Consider the moment $|L|=\alpha N$. Without loss of generality, we assume $F_i \subseteq L$ (otherwise we can adjust the order of vertices added to $L$ by Lemma \ref{lemma:L'allsame}). Then we have \[ (1-\varepsilon) D \alpha N \le | \Gamma(L) | \le (1-\gamma)D \cdot |F_i| + 2 \varepsilon D (\alpha N - |F_i|), \] because the expansion of $F_i$ is $(1-\gamma)D \cdot |F_i|$ and when adding any vertex in $L\setminus F_i$ to $L$, $R$ increases by at most $2\varepsilon D$. So \[ (1-\varepsilon) \alpha N \le (1-\gamma) \cdot |F_i| + 2 \varepsilon (\alpha N - |F_i|). \] As $\gamma \leq \varepsilon$ and $\varepsilon \leq 1/4$, $1-\gamma - 2 \varepsilon > 0$. This implies $|F_i| \ge \frac{1-3\varepsilon}{1-\gamma - 2 \varepsilon} \cdot \alpha N $. Since $\gamma \geq \gamma_i -\eta \geq \frac{2\varepsilon}{3} $, we have $|F_i| \geq \frac{1-3\varepsilon}{1-8\varepsilon/3 } \alpha N $. When $\varepsilon \leq 1/4 - \beta$ and $\eta$ is small enough, one can check that $\frac{1-3\varepsilon}{1-8\varepsilon/3 } > 1-\varepsilon $ always holds. It is contradicting the assumption that $|F_i| \leq (1-\varepsilon ) \alpha N$. As $L \supseteq F_i$ and is of size at most $\alpha N$, the algorithm can correct all the errors using $L$ and $z$ given $\varepsilon <1/4-\beta$ to Theorem~\ref{thm:decfromerasures}. \end{proof} Next we discuss the case where $\gamma_i<2\varepsilon/3+\eta$, which will result in the Function \textsc{Decoding} finding the set $L_0$ and flipping all the bits in $L_0$. We show that this will reduce the number of errors by a constant fraction. \begin{claim}\label{clm:large_gamma} If $|F_i| \leq (1-\varepsilon ) \alpha N$, $\gamma_i < \frac{2\varepsilon}{3}+\eta$, and $\gamma(F_i) \in [\gamma_i-\eta, \gamma_i )$, then flipping $L_0$ will reduce the distance between $z$ and the correct codeword by at least $ \beta$ fraction. \end{claim} \begin{proof} Let $\gamma:=\gamma(F_i)$ and $N':=\frac{(1+ 3\eta)|F_i|}{(1-\varepsilon) \alpha}$. We show that $|F_i \cup L_0| < \alpha N' $. To prove it, assume $|F_i \cup L_0|=\alpha N'$, i.e., we only take $\alpha N' - |F_i|$ elements from $L_0\setminus F_i$, consider these elements together with elements in $F_i$. As $|F_i| \leq (1-\varepsilon)\alpha N$, $\alpha N' \leq (1+3\eta)\alpha N$. By Lemma \ref{lem:expansion_larger}, $(1-(1+3\eta)\varepsilon)D \alpha N' - O(\varepsilon D (1+3\eta)^2) \le |\Gamma(F_i \cup L_0)|$. Also notice that $|\Gamma(F_i)| = (1-\gamma)D |F_i|$ and adding each element of $L_0\setminus F_i$ to $L_0$ contributes at most $3\gamma_i D$ to $|\Gamma(F_i \cup L_0)|$. So \[ (1-(1+3\eta)\varepsilon - O_\varepsilon(1/N))D \alpha N' \le |\Gamma(F_i \cup L_0)| \le (1-\gamma)D |F_i| + 3 \gamma_i D \cdot (\alpha N' - |F_i|). \] This implies $|F_i| \ge \frac{1-(1+3\eta)\varepsilon- O_\varepsilon(1/N) - 3 \gamma_i}{1-\gamma - 3 \gamma_i} \cdot \alpha N'$. As $ \gamma_i \leq \gamma + \eta $, this is $\geq\frac{1-(1+3\eta)\varepsilon - O_\varepsilon(1/N) - 3 \gamma-3\eta}{1-4 \gamma - 3\eta} \cdot \alpha N'$ which is minimized when $\gamma = 0$. Thus $|F_i|\geq\frac{(1-(1+3\eta)\varepsilon - O_\varepsilon(1/N)-3\eta )}{1-3\eta} \alpha N' = (1- \varepsilon -\frac{6\eta}{1-3\eta}\varepsilon - O_\varepsilon(1/N))\alpha N'$. But we know that $|F_i| = \frac{1-\varepsilon}{1+3\eta}\alpha N' = (1-\varepsilon-\frac{3\eta-3\varepsilon \eta}{1+3\eta})\alpha N' $. This is a contradiction. Let $\varepsilon' = (1+3\eta)\varepsilon + O_\varepsilon(1/N)$. Since $|F_i\cup L_0| <\alpha N'$, now again we have \begin{equation}\label{eq:F_and_L_0} (1-\varepsilon') \cdot D |F_i \cup L_0| \le |\Gamma(F_i \cup L_0) | \le (1-\gamma)D|F_i| + 3 \gamma_i D|L_0 \setminus F_i|. \end{equation} As $ |F_i \cup L_0| = |L_0 \setminus F_i| + |F_i| $, this gives \[ (1-\varepsilon'-3 \gamma_i) \cdot |L_0\setminus F_i| \le (\varepsilon'-\gamma) \cdot |F_i|. \] Now we consider $F_i \setminus L_0$. Each variable in $F_i \setminus L_0$ contributes at most $(1-3\gamma_i) D$ unique neighbors. And the total number of unique neighbors is at least $(1-2\gamma)D \cdot |F_i|$. So the size of $F_i\setminus L_0$ is at most $\frac{2\gamma}{3\gamma_i} \cdot |F_i|$. Finally we prove $|F_i\setminus L_0|+|L_0\setminus F_i| \le (1- \beta) \cdot|F_i|$. From the above bounds on $|F_i\setminus L_0|$ and $|L_0\setminus F_i|$, it is enough to show \[ \frac{2\gamma}{3\gamma_i} + \frac{\varepsilon' -\gamma}{1-\varepsilon' - 3 \gamma_i}< 1 - \beta. \] As $\gamma \in [\gamma_i -\eta, \gamma_i)$, the L.H.S. is at most \[ \frac{2 }{3 } + \frac{\varepsilon' - \gamma_i }{1-\varepsilon' - 3 \gamma_i }. \] We know $\varepsilon \leq 1/4 - \beta$. So $\varepsilon' \leq (1/4-\beta)(1+3\eta) + O_\varepsilon(1/N) < 1/4- 0.9\beta $ when $\eta \le \beta/100$. Also we know $\gamma_i \in [0, \frac{2}{3}\varepsilon+\eta)$. So when $\gamma_i = 0$, $\varepsilon' = 1/4-0.9\beta$, the L.H.S. is at most $1- \beta$. \end{proof} \begin{proofof}{Theorem \ref{thm:MultipleGuessWithFlips}} The decoding algorithm is Algorithm \ref{alg:MultipleGuessWithFlips}. Given the parameter $\beta$, we first set up a large enough constant $\ell=\Theta(1/\beta)$. Then we apply the algorithm on an input corrupted codeword, using parameter $\ell$. The key point is that in the enumerations of the $\gamma_i$'s, one sequence $(\gamma_i)_{i\in [l]}$ provides a good approximation of the actual expansion parameters, i.e. $\forall i\in [l]$ in the $i$-th iteration, $\gamma(F_i)\in [ \gamma_i-\eta, \gamma_i)$. Now we consider every iteration in this sequence. If $\gamma_i \geq 2\varepsilon/3 +\eta $, then by Claim \ref{clm:small_gamma}, the algorithm returns the correct codeword. If $\gamma_i < 2\varepsilon/3 + \eta$, then by Claim \ref{clm:large_gamma}, the number of errors can be reduced by $ \beta $ fraction. So in the worst case, when $\ell \geq \log_{1-O(\beta)}\frac{1}{3}$, the number of errors can be reduced to at most $\alpha N / 3$ in a constant number of iterations. Finally the algorithm applies the decoding algorithm from Theorem \ref{thm:vidermandec}, which corrects the remaining errors. The running time of Algorithm \ref{alg:MultipleGuessWithFlips} is linear, since $\ell = O(1)$ and our enumeration for each $\gamma_i$ takes constant time. The procedures \textsf{FixedFindAndDecode} and the decoding from Theorem \ref{thm:vidermandec} both run in linear time as well. \end{proofof} By using Theorem \ref{thm:MultipleGuessWithFlips} and Lemma \ref{lem:expansion_larger} we can get the following result. \iffalse \begin{theorem} For every constant $\beta > 0$, for every $ \varepsilon \leq 1/4 - \beta $, if $\mathcal{C}$ is an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander, then there is a linear time decoding algorithm for $\mathcal{C}$ which has decoding radius $(\frac{3\varepsilon}{16} - O_\varepsilon(\beta))\alpha N$. \end{theorem} \authnote{Xin}{magenta}{I think by setting $\beta$ appropriately, we should be able to rewrite the theorem statement as follows. Check it. Also, $\varepsilon$ should be in the denominator.} \fi \begin{theorem}\label{thm:MultipleGuessWithFlipsFinal} For every constants $ \varepsilon \in (0, \frac{1}{4}), \eta>0$, if $\mathcal{C}$ is an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander, then there is a linear time decoding algorithm for $\mathcal{C}$ with decoding radius $(\frac{3 \alpha}{16 \varepsilon} - \eta) N$. \end{theorem} \begin{algorithm}[H] \caption{Decoding Algorithm for $\varepsilon<1/4$ with larger decoding radius}\label{alg:MultipleGuessWithFlipsLarger} \begin{algorithmic}[1] \Function{Final Decoding For Large Radius}{$y\in \mathbf{F}_2^N, \alpha \in \mathbf{R}, \varepsilon \in \mathbf{R}$} \State Let $k = (1/4-\beta - O_\varepsilon(1/N))/\varepsilon$, with $\beta$ being a small enough constant. \State Let $z \gets$ \Call{Final Decoding}{$y, k\alpha, k \varepsilon + O_\varepsilon(1/N)$}, where \Call{Final Decoding}{} is from Algorithm~\ref{alg:MultipleGuessWithFlips} \State \Return $z$. \EndFunction \end{algorithmic} \end{algorithm} \begin{proof} Consider Algorithm \ref{alg:MultipleGuessWithFlipsLarger}. By Lemma \ref{lem:expansion_larger}, the expander graph is also a $ (k\alpha N, (1-k\varepsilon)D - O_\varepsilon(1/N)) $ expander for $k\geq 1$. If $k$ satisfies $(1-k\varepsilon)D - O_\varepsilon(1/N) \leq 1/4 - \beta$ for a small constant $\beta$, then by Theorem \ref{thm:MultipleGuessWithFlips}, there is a decoding algorithm with radius $(1 - k\varepsilon - O_\varepsilon(1/N))k\alpha N$. When $k = (1/4-\beta - O_\varepsilon(1/N))/\varepsilon$, this is maximized to be $(\frac{3}{16\varepsilon} - O_{\varepsilon}(\beta))\alpha N$. Here we take $\beta=O(\eta)$ to be small enough such that $k\geq 1$ and the decoding radius becomes $(\frac{3 \alpha}{16 \varepsilon} - \eta) N$. The running time is linear by Theorem~\ref{thm:MultipleGuessWithFlips}. \end{proof} \iffalse \section{Adaptive thresholds and Flipping} We consider $\varepsilon \in (1/6,1/4)$ in this section. The basic idea is to consider two cases about the actual expansion of $F$. We describe our algorithm in Algorithm~\ref{alg:decoding_large_eps} and state our main result of this section. \begin{algorithm}[h] \caption{Decoding Algorithm for $\varepsilon> 1/6$}\label{alg:decoding_large_eps} \begin{algorithmic}[1] \Function{Decoding}{$C_0 \in \mathbf{F}_2^n$ and $(\alpha,1-\varepsilon)$} \State $C \gets C_0$ \While{$C$ is not a codeword} \State $C' \gets$ \Call{FixedFindAndDecode}{$C$} \If{$C'$ is a valid codeword with distance at most $\alpha N$ to $C_0$} \State \Return $C'$ \Else \State Let $F$ be the subset of corrupted entries. \State Let $\gamma$ be the expansion of $F$, i.e., $|\Gamma(F)|=(1-\gamma)D \cdot |F|$. \textcolor{red}{We shall enumerate this.} \State We choose $c=\frac{(2+o(1))\varepsilon}{\gamma}$, use a threshold $(1- c \gamma)$ to find $L_0$ \State Flip $L_0$ in $C$ \EndIf \EndWhile \EndFunction \Function{FixedFindAndDecode}{$C \in \mathbf{F}_2^n$} \State $L \gets \emptyset$ \State $R \gets \{\text{wrong parity checks of } C\}$ \While{$\exists i\notin L$ s.t. $|\Gamma(i) \cap R| \ge (1-2\varepsilon)D$} \State $L \gets L \cup \{i\}$ \State $R \gets R \cup \Gamma(i)$ \EndWhile \State Apply the erasure decoding algorithm in \cite{Viderman13} with $L$ to return a codeword $C'$. \EndFunction \end{algorithmic} \end{algorithm} \begin{theorem} For any $\delta>0$ and $\varepsilon<1/4$, Algorithm~\ref{alg:decoding_large_eps} corrects $(1-\varepsilon-o(1)) \cdot \alpha N$ errors. \end{theorem} First of all, we show Function \textsc{FixedFindAndDecode} will recover the codeword whenever $\gamma$ is large. \begin{claim}\label{clm:small_gamma} Suppose the subset $F$ of flipped entries has size at most $(1-\varepsilon) \alpha N$ and its expansion parameter $\gamma \ge \frac{2\varepsilon^2}{1-\varepsilon}$. Then Function \textsc{FixedFindAndDecode} will return a valid codeword. \end{claim} \begin{proof} We prove that $L$ after the while loop has size at most $\alpha N$. Consider the moment $|L|=\alpha N$. Without loss of generality, we assume $F \subseteq L$ (otherwise we adjust the order of vertices added to $L$). Then we have \[ (1-\varepsilon) \alpha N \le (1-\gamma) \cdot |F| + 2 \varepsilon (\alpha N - |F|). \] This implies $|F| \ge \frac{1-3\varepsilon}{1-\gamma - 2 \varepsilon} \cdot \alpha N$, which is greater than $(1-\varepsilon) \alpha N$ and contradicting the assumption of $F$. \end{proof} \begin{claim}\label{clm:large_gamma} Suppose the subset $F$ of flipped entries has size at most $(1-\varepsilon) \alpha N$ and its expansion $\gamma <\frac{2\varepsilon^2}{1-\varepsilon}$. Then flipping $L_0$ will reduce the distance between $C$ and the correct codeword. \end{claim} \begin{proof} First of all, $|F \cup L_0| < \alpha N$. To prove it, we assume $|F \cup L_0|=\alpha N$. So \[ (1-\varepsilon) \alpha N \le |N(F \cup L_0)| \le (1-\gamma) |F| + c \gamma \cdot (\alpha N - |F|). \] This implies $|F| \ge \frac{1-\varepsilon - c \gamma}{1-\gamma - c \gamma} \cdot \alpha N \ge (1-\varepsilon) \cdot \alpha N$ contradicting our assumption. This shows \begin{equation}\label{eq:F_and_L_0} (1-\varepsilon) \cdot |F \cup L_0| \le (1-\gamma)|F| + c \gamma |L_0 \setminus F|. \end{equation} Now we consider $F \setminus L_0$ and $L_0 \setminus F$. Each variable in $F \setminus L_0$ shares more than $c \gamma$ neighbors with other vertices in $F$. So $N(F \setminus L_0) < (1-c \gamma/2)D \cdot |F \setminus L_0|$ and \[ (1-\gamma)|F| < |F \cap L_0| + (1-c\gamma/2) \cdot |F \setminus L_0| = |F| - c\gamma/2 \cdot |F \setminus L_0|. \] We plug this bound into \eqref{eq:F_and_L_0}: \[ (1-\varepsilon) |F \cup L_0| \le |F| - c \gamma/2 \cdot |F \setminus L_0| + c \gamma |L_0 \setminus F|. \] Namely \[ c \gamma/2 \cdot |F \setminus L_0| + (1-\varepsilon- c\gamma) |L_0 \setminus F| \le \varepsilon |F|. \] So we need $c \gamma/2 > \varepsilon$ and $1-\varepsilon - c \gamma >\varepsilon$ to guarantee that the while loop reduces the number of errors. These require $\varepsilon<1/4$ and $c \gamma>2 \varepsilon$ separately. \end{proof} \fi \section{Introduction} Expander codes \cite{SS96} are error-correcting codes derived from bipartite expander graphs that are notable for their ultra-efficient decoding algorithms. In particular, all known asymptotically good error-correcting codes which admit (almost) linear-time decoding algorithms for a constant fraction of adversarial errors are based on expander codes. At the same time, expander codes are closely related to low-density parity-check (LDPC) codes \cite{Gallager1963} --- a random LDPC code is an expander code with high probability. Over the last twenty years, LDPC codes have received increased attention (\cite{FWK05,FMSSW07,ADS12,dimakis2012ldpc,JNNSM20LDPC} to name a few) because of their practical performance. Along this line of research, the study of decoding algorithms for expander codes, such as belief-propagation \cite{Gallager1963,SS96, luby1998improved}, message-passing \cite{richardson2001the}, and linear programming \cite{FWK05, FMSSW07, Viderman13}, has laid theoretical foundations and sparked new lines of inquiry for LDPC codes. In this work, we consider expander codes for adversarial errors. Briefly, given a bipartite graph $G$ with $N$ vertices of degree $D$ on the left, we say it is an $(\alpha N, (1-\varepsilon)D)$ expander if and only if any left subset $S$ with size at most $\alpha N$ has at least $(1-\varepsilon)D \cdot |S|$ distinct neighbors. The code $\mathcal{C}$ of an expander $G$ assigns a bit to each vertex on the left and views each vertex on the right as a parity check over its neighbors. A codeword $C \in \mathcal{C}$ is a vector in $\{0,1\}^N$ that satisfies all parity checks on the right. Moreover, the distance of $\mathcal{C}$ is defined as the minimum Hamming distance between all pairs of codewords. We defer the formal definitions of expanders and expander codes to Section~\ref{sec:preli}. For typical applications, the parameters $\alpha,\varepsilon$ and $D$ are assumed to be constants, and there exist explicit constructions (e.g., \cite{CRVW}) of such expander graphs with $M<N$. For expander codes defined by $(\alpha N,(1-\varepsilon)D)$-expanders, the seminal work of Sipser and Spielman \cite{SS96} gave the first efficient algorithm to correct a constant fraction (i.e., $(1-2\varepsilon) \cdot \alpha N$) of errors, when $\varepsilon < 1/4$. In fact, their algorithms are super efficient --- they provide a linear time algorithm called belief-propagation and a logarithmic time parallel algorithm with a linear number of processors. Subsequently, Feldman et al.~\cite{FMSSW07} and Viderman \cite{Viderman13, Viderman13b} provided improved algorithms to correct roughly $\frac{1-3\varepsilon}{1-2\varepsilon}\cdot \alpha N$ errors, when $\varepsilon < 1/3$. This fraction of error is strictly larger than that of \cite{SS96} whenever $\varepsilon < 1/4$. Viderman \cite{Viderman13b} also showed how to correct $N^{\Omega_{D,\varepsilon,\alpha}(1)}$ errors when $\varepsilon \in [1/3,1/2)$, and that $\varepsilon < 1/2$ is necessary for correcting even $1$ error.\ However, the following basic question about expander codes remains unclear. \paragraph{Question:}\emph{What is the best distance bound one can get from an expander code defined by arbitrary $(\alpha N,(1-\varepsilon)D)$-expanders?}\\ This question is important since it is well known that for unique decoding, the code can and can only correct up to half the distance number of errors. In \cite{SS96}, Sipser and Spielman showed that the distance of such expander codes is at least $\alpha N$, while a simple generalization improves this bound to $2(1-\varepsilon)\alpha N$ (see e.g., \cite{Sudan2000note} and \cite{Viderman13b}). Perhaps somewhat surprisingly, this simple bound is the best known distance bound for an arbitrary expander code. In fact, Viderman \cite{Viderman13b} asserted that this is the best distance bound one can achieve based only on the expansion property of the graph, and hence when $\varepsilon$ converges to $0$, the number of errors corrected in \cite{Viderman13b}, $\frac{1-3\varepsilon}{1-2\varepsilon}\cdot \alpha N$ converges to the half distance bound. Yet, no evidence was known to support this claim. Thus it is natural to ask whether any improvement is possible, and if so, can one design efficient algorithms to correct more errors? \iffalse In this work, before we study decoding algorithms with larger radii, the first question would be what is the largest possible decoding radius given the expander parameter $(\alpha N, (1-\varepsilon)D)$? Since the unique decoding radius is always half of the distance, this is equivalent to asking what is the largest possible distance of expander codes. Perhaps surprisingly, this best known distance for expander codes is the folklore bound $2(1-\varepsilon) \cdot \alpha N$ (e.g., \cite{Sudan2000note,Viderman13b}). A natural questions would be what is the largest possible distance of expander codes defined by arbitrary $(\alpha N, (1-\varepsilon)D)$-expanders? Furthermore, if the folklore bound $2(1-\varepsilon) \cdot \alpha N$ is not tight, can one decode more errors? \fi \subsection{Our Results} \paragraph{Distance of expander codes.} In this work, we give affirmative answers to the above questions. Our first result shows that the best distance bound of expander codes defined by arbitrary $(\alpha N, (1-\varepsilon)D)$-expanders is roughly $\frac{\alpha N}{2 \varepsilon}$. \begin{theorem}\label{thm:infor_distance}[Informal versions of Theorem~\ref{thm:dist_expander} and Theorem~\ref{thm:tight_distance}] Given any $(\alpha N, (1-\varepsilon)D)$-expander, let $\mathcal{C}$ be the expander code defined by it. The distance of $\mathcal{C}$ is at least $\frac{\alpha}{2\varepsilon} \cdot N - O_{\varepsilon}(1)$. Moreover, for any constant $\eta>0$ there exists an $(\alpha N, (1-\varepsilon)D)$-expander whose expander code has distance at most $(\frac{\alpha}{2\varepsilon}+\eta) \cdot N$. \end{theorem} We remark that the bound $\frac{\alpha}{2\varepsilon} \cdot N$ is always larger than the previous bound $2(1-\varepsilon)\alpha N$ since we always have $\varepsilon< 1/2$ in expander codes. For small $\varepsilon$, this improves upon the previous bound by a factor of $1/4\varepsilon$ roughly, which can be quite significant. \paragraph{Decoding algorithms.} Next we consider algorithms to correct more errors. Given the above bound on the distance of expander codes, the natural goal is to design efficient algorithms that can correct $\Theta(\alpha/\varepsilon) \cdot N$ errors. We achieve this goal for all $\varepsilon<1/4$. \begin{theorem}\label{thm:inf_decode_dist}[Informal version of Theorem~\ref{thm:MultipleGuessWithFlipsFinal}] Given any constants $\alpha, \eta>0$ and $0< \varepsilon<1/4$, there exist a linear time algorithm that for any expander code defined by an $(\alpha N, (1-\varepsilon)D)$-expander, correct up to $(\frac{3 \alpha}{16 \varepsilon}-\eta) \cdot N$ adversarial errors. \end{theorem} The bound $\frac{3 \alpha}{16 \varepsilon} \cdot N$ is larger than all previous bounds for $\varepsilon<1/4$ by at least a constant factor. For example, when $\varepsilon$ is close to $1/4$, all previous works \cite{SS96,FMSSW07,Viderman13b} can only correct roughly $\frac{\alpha}{2} \cdot N$ errors, while our algorithm can correct roughly $\frac{3}{4} \cdot \alpha N$ errors. When $\varepsilon$ is smaller, the improvment is even more significant, as no previous work can correct more than $\alpha N$ errors. On the other hand, given Theorem~\ref{thm:infor_distance}, one can hope for correcting roughly $\frac{\alpha}{4\varepsilon} \cdot N$ errors, so Theorem~\ref{thm:inf_decode_dist} falls slightly short of achieving it. Actually, we can correct more errors when $\varepsilon$ is small. For example, when $\varepsilon<0.08$, our algorithm in~Section~\ref{sec:improve_decoding} can correct more than $\frac{0.2\alpha}{\varepsilon} \cdot N$ errors. We summarize all our results informally in Table~\ref{table:distance}, compared to the previous best results of \cite{FMSSW07,Viderman13b}. \begin{table}[h!] \centering \begin{tabular}[b]{|c | c | c |c|} \hline & $\varepsilon \in (0,\frac{3-2\sqrt{2}}{2})$ & $\varepsilon \in [\frac{3-2\sqrt{2}}{2},1/8)$ & $\varepsilon \in [1/8,1/4)$ \\ [1ex] \hline Distance from Theorem~\ref{thm:infor_distance} of this work & $\frac{1}{2 \varepsilon} \cdot \alpha N$ & $\frac{1}{2 \varepsilon} \cdot \alpha N$ & $\frac{1}{2 \varepsilon} \cdot \alpha N$ \\ [1ex] \hline Decoding radius from \cite{FMSSW07,Viderman13b} & $\frac{1-3\varepsilon}{1- 2 \varepsilon} \cdot \alpha N$ & $\frac{1-3\varepsilon}{1- 2 \varepsilon} \cdot \alpha N$ & $\frac{1-3\varepsilon}{1- 2 \varepsilon} \cdot \alpha N$ \\ [1ex] \hline \multirow{2}{16em}{Decoding radius from this work} & $\frac{\sqrt{2}-1}{2\varepsilon} \cdot \alpha N$ & $\frac{1-2\varepsilon}{4\varepsilon} \cdot \alpha N$ & $\frac{3}{16\varepsilon} \cdot \alpha N$ \\ & from Theorem~\ref{thm:guessexpansion} & from Theorem~\ref{thm:guessexpansion} & from Theorem~\ref{thm:MultipleGuessWithFlipsFinal}\\ \hline \end{tabular} \caption{Summary of the distance and decoding radii for $\varepsilon$.} \label{table:distance} \end{table} \paragraph{List decoding.} Finally, we consider the list-decodability of expander codes. List decoding, introduced by Elias \cite{Elias57listdecoding} and Wozencraft \cite{Wozencraft58} separately, is a relaxation of the classical notion of unique decoding. In this setting, the decoder is allowed to output a small list of candidate codewords that include all codewords within Hamming distance $\rho N$ of the received word. Thus, the list decoding radius $\rho N$ could be significantly larger than half of the distance. For example, a very recent work by Mosheiff et al.~\cite{JNNSM20LDPC} shows random LDPC codes have list decoding radii close to their distance. In this setting, the classical Johnson bound shows that \emph{any} binary code with distance $d$ is list-decodable up to radius $r=\frac{N-\sqrt{N(N-2d)}}{2}$ with list size $N^{O(1)}$. If we set the Johnson bound $r$ as the baseline, a natural question is whether expander codes can list-decode more than $r$ errors given the distance $d=\frac{\alpha}{2\varepsilon}\cdot N$? In Section~\ref{sec:list_decode}, we consider expander codes defined by expanders that has a maximum degree $D_{\max}=O(1)$ on the right, like LDPC codes. Our main results provide an alternative bound on the list-decoding radius of such codes, and show that it is strictly better than the Johnson bound when $\alpha/\varepsilon$ is small and the right hand side is also almost regular, i.e., $D_{\max} \approx D_R$, where $D_R$ is the \emph{average} right degree. \begin{theorem}\label{thm:infor_list_decode}[Informal version of Theorem~\ref{thm:list_decoding_radius}] Given any $(\alpha N,(1-\varepsilon)D)$-expander with regular degree $D$ on the left and maximum degree $D_{\max}$ on the right, its expander code has a list decoding radius $\rho N = (\frac{1}{2} + \Omega(1/D_{\max}) )d$ and list size $N^{O(1)}$. Here $d$ is the distance of the code. Furthermore, if $D_{\max} \leq 1.1 D_R$, $\varepsilon\le 1/4$ and $\alpha/\varepsilon \le 0.1$, $\rho N$ is strictly larger than the Johnson bound $r$ of binary codes with distance $d=\frac{\alpha}{2\varepsilon}\cdot N$. \end{theorem} We remark that, the Johnson bound $r=d/2 + \Theta(d^2/N)$ when $d$ is small. While we did not attempt to optimize the constant hidden in the $\Omega$ notation of $\rho = (\frac{1}{2} + \Omega(1/D_{\max}) )d$, we show that roughly $\frac{1}{D_R} \ge \frac{\alpha}{4\varepsilon}$ in Section~\ref{sec:dist_expander}. When the expander is also almost regular on the right, e.g., $D_{\max} \leq 1.1 D_R$, this bound is better than the Johnson bound with $d=\frac{\alpha}{2\varepsilon}\cdot N$ and a small ratio $\alpha/\varepsilon$. The second condition would follow from a large average right-degree $D_R$ (equivalently, a small $M/N$ or a large code-rate $1-M/N$). In particular, this applies to the graph we construct in Section~\ref{sec:bound_dist}, which has distance arbitrarily close to $\frac{\alpha}{2\varepsilon}\cdot N$. One intriguing question is to design efficient list-decoding algorithms for expander codes. Since these algorithms would also immediately improve all our results of unique decoding, we leave this as a future direction. \paragraph{New combinatorial properties of expander graphs.} Our distance bounds and decoding algorithms make extensive use of a new size-expansion tradeoff for bipartite expander graphs, which we establish in this paper. Specifically, we show that one can always trade the expansion for larger subsets in such a graph. In particular, given any $(\alpha N, (1-\varepsilon)D)$-expander, we prove in Section~\ref{sec:dist_expander} that this graph is also roughly a $(k \alpha N, (1-k\varepsilon)D)$-expander for any $k \ge 1$, provided that $k \alpha N \le N$. This size-expansion tradeoff is potentially of independent interest. For example, besides the applications in our distance bounds and decoding algorithms, we also use it to show a relation between the three basic parameters $(\alpha, \varepsilon, D_R)$ of bipartite expanders. Roughly, we always have $\frac{\alpha}{\varepsilon} \le \frac{4}{D_R}$ (see Fact~\ref{fact:relations_parameters} for a formal statement). On the other hand, using a random graph one can show the existence of $(\alpha N, (1-\varepsilon)D)$-expanders such that roughly $\frac{\alpha}{\varepsilon} \ge \frac{1}{e D_R}$ (see Proposition~\ref{prop:parameterrelation}). Thus our upper bound is tight up to a constant factor. \subsection{Related Work} Sipser and Spielman's definition in \cite{SS96} is actually more general, and is a variant of Tanner codes \cite{Tanner81} based on expanders. Basically, the code requires all symbols in the neighbor set of a right vertex (in some fixed order) to be a codeword from an inner linear code $\mathcal{C}_0$. The expander code studied here is the most popular and well studied case, where the inner code consists of all strings with even weight. Instead of vertex expansion, the expander based Tanner codes are analyzed based on edge expansion, a related concept which has also been well studied in both mathematics and computer science \cite{LPS88,AlonChung1988}. We note that the distance of Tanner codes depends heavily on the inner code $\mathcal{C}_0$, and is thus generally incomparable to the distance of our code. To the best of our knowledge, the best bound on the distance of expander codes based on vertex expansion of bipartite expanders, as studied in this paper, was $2(1-\varepsilon) \cdot \alpha N$. As mentioned before, expander codes are closely related to low-density parity-check (LDPC) codes introduced by Gallager~\cite{Gallager1963}, where the bipartite graph associated with the parity checks has bounded degree on the right but is not necessary an expander. There is a long line of research on random LDPC codes against \emph{random errors} (see \cite{richardson2001the,Shok,ADS12} and the references therein). While a random LDPC code is an expander code with high probability, our results are incomparable with those of random LDPC codes. This is because first, we consider expander codes defined by arbitrary expanders, while many results on random LDPC codes use more properties than the expansion, such as the girth of the underlying graph that can be deduced from random graphs. Second, we consider adversarial errors, while many results on random LDPC codes \cite{richardson2001the,ADS12} consider random errors or memoryless channels. In the context of list decoding, the work of RonZewi-Wootters-Zemor \cite{ron2021linear} studied the problem of erasure list-decoding of expander codes, based on algebraic expansion properties (i.e., eigenvalues of the corresponding adjacency matrix). In the past few decades, a great amount of research has been devoted to expander graphs, leading to a plethora of new results. We refer the reader to the survey by Hoory, Linial, and Wigderson \cite{Hoory2006ExpanderGA} for an overview. Specifically, giving explicit constructions of bipartite expander graphs for expander codes has been a challenge. In particular, Kahale \cite{Kahale} showed that general Ramanujan graphs \cite{LPS88} (with the minimum 2nd largest absolute eigenvalue among all $D$-regular graphs) cannot provide vertex expansion more than half of the degree, which is the threshold required to give expander codes. After decades of efforts, explicit constructions satisfying the requirements of expander codes have been provided in \cite{AlonCapalbo,CRVW} separately. \input{tech_overview} \paragraph{Organization.} The rest of this paper is organized as follows. In Section \ref{sec:preli}, we describe some basic notation, terms, definitions and useful theorems from previous work. In Section \ref{sec:dist_expander}, we show our improved distance bound for expander codes, and prove it is tight in general. In Section \ref{sec:find}, we establish new properties of the algorithm which can find a super set of corruptions. In Section \ref{sec:guess_flip}, we provide our main unique decoding algorithm. In Section \ref{sec:improve_decoding}, we provide our improved unique decoding algorithm for smaller $\varepsilon$. In Section \ref{sec:list_decode}, we show our list-decoding result. Finally, we conclude in Section \ref{sec:open} with some open questions. Appendix~\ref{appen:proof_expansion} contains some relatively standard materials omitted in the main body. \section{List-decoding Radius}\label{sec:list_decode} In this section, we consider expander graphs with bounded maximum degree $D_{\max}=O(1)$. Our main result of this section is the following theorem about the list-decoding radius of almost-regular expander codes. For convenience, we only consider relative distance and relative radii. Throughout this section, $\delta=\alpha/2\varepsilon$ denotes the relative distance, $r$ denotes the relative decoding radius from the Johnson bound, and $\rho$ denotes the relative decoding radius that we will prove. \begin{theorem}\label{thm:list_decoding_radius} Given any $(\alpha N,(1-\varepsilon)D)$-expander $G$ with a regular degree $D$ in $V_L$ and a maximum degree $D_{\max}$ in $V_R$, its expander code has a relative list decoding radius $\rho = (\frac{1}{2} + \Omega(1/D_{\max}) ) \cdot \delta$ and list size $N^{O(1)}$. In particular, when $\varepsilon\le 1/4$, $\alpha/\varepsilon \le 0.1$, and $D_{\max} \le 1.1 D_R$ for the average right degree $D_R$, the relative list-decoding radius $\rho$ is strictly larger than the Johnson bound $r$ of binary codes with relative distance $\delta=\frac{\alpha}{2\varepsilon}$. \end{theorem} We remark that $D_{\max} \le 1.1 D_R$ is a relaxation for $D_R$-regular graphs, which are a standard instantiation of LDPC codes. We finish the proof of Theorem~\ref{thm:list_decoding_radius} in the rest of this section. First of all, recall that the Johnson bound $r$ of binary codes with relative distance $\delta$ is $\frac{1-\sqrt{1-2\delta}}{2}$, which is the limit of the inequality \[ \delta/2 + r^2 - r > 0. \] To prove Theorem~\ref{thm:list_decoding_radius}, the basic idea is to use locality (which we will define more precisely in the proof) of expander codes to improve the average case in the argument of the Johnson bound. In particular, for $L$ codewords $C_1,\ldots,C_L$ within distance $\rho N$ to some string $y$, we will show that the 1s in $C_1 \oplus y, \ldots, C_L \oplus y$ are concentrated on a constant fraction of positions. More precisely, we pick a threshold $\theta>r$ to show the concentration of 1s. We use the following fact about $\theta$ and $r$ in the proof. \begin{claim}\label{clm:threshold_theta} When $\varepsilon \le 1/4$ and $\alpha/\varepsilon \le 0.1$, the relative list decoding radius $r$ of the Johnson bound of relative distance $\delta:=\alpha/2\varepsilon$ of binary codes is less than $0.53 \delta$. Furthermore, when $D_{\max} \le 1.1 D_R$, our choice $\theta:=0.9/D_{\max}$ is at least $0.544 \delta$, which is greater than $r$. \end{claim} We defer the proof of Claim~\ref{clm:threshold_theta} to Section~\ref{sec:proof_threshold} and finish the proof of Theorem~\ref{thm:list_decoding_radius} here. \begin{proofof}{Theorem~\ref{thm:list_decoding_radius}} We first show $\rho>r$ given $\varepsilon \le 1/4$, $\alpha/\varepsilon \le 0.1$ and $D_{\max} \le 1.1 D_R$ then discuss how to prove $\rho=\delta/2 \cdot (1 + \Omega(1/D_{\max}))$ in general. We fix the threshold $\theta:=0.9/D_{\max}$ as in Claim~\ref{clm:threshold_theta}. For convenience, we assume that the decoding radius $\rho$ is always less than $0.54 \delta$ in this proof (otherwise it already satisfies $\rho = \frac{\delta}{2} (1 + \Omega(1/D_{\max})$ and is strictly larger than $r$ from the above claim $r<0.53 \delta$). Moreover, $\theta:=0.9/D_{\max} \ge 0.544 \delta$ from Claim~\ref{clm:threshold_theta} is larger than $\rho$. We fix an arbitrary string $y \in \{0,1\}^N$ and consider the number of codewords within relative distance $\rho$ to it, say, there are $L$ codewords $C_1,\ldots,$ and $C_L$. Let $\Gamma_{odd}(S)$ denote the neighbors of $S$ with an odd number of edges to $S$. Given a $\{0,1\}$-string $z$, let $S_z$ denote the set of 1-entries and $\Gamma_{odd}(z):=\Gamma_{odd}(S_z)$. Back to the $L$ codewords, since $(y\oplus C_i)\oplus (y \oplus C_j)$ is a codeword, $\Gamma_{odd}(y \oplus C_1)=\cdots=\Gamma_{odd}(y \oplus C_L)$ from the definition of the expander code --- all codewords satisfy those parity checks. Hence we use $\Gamma_{odd}$ to denote this neighbor set $\Gamma_{odd}(y \oplus C_1)=\cdots=\Gamma_{odd}(y \oplus C_L)$. First of all, we lower bound $|\Gamma_{odd}|$. We pick $C_i$ such that $|y \oplus C_i| \in [0.5\delta \cdot N, \rho \cdot N]$. Note that such a $C_i$ exists as long as $L \ge 2$. Then $|\Gamma_{odd}(y\oplus C_i)| \ge (1-2\varepsilon \cdot \frac{|y+C_i|}{\alpha N}) D \cdot |y+C_i| - O_{\varepsilon}(1)$ from Lemma~\ref{lem:expansion_larger}, which is at least $0.46 \rho D \cdot N - O_{\varepsilon}(1)$ given $\rho \le 0.54 \delta$ and the range of $|y \oplus C_i|$. For ease of exposition, we use the lower bound $|\Gamma_{odd}| \ge 0.45 \rho \cdot D N$ in the rest of this proof. Let $\tau_i$ denote how many codewords of $C_i$ whose $i$th bit is different from the corresponding bit in $y$, i.e., $\sum_{j=1}^L 1\{i \in \mathsf{supp}(y\oplus C_j)\}$. Since $|y \oplus C_i| \le \rho N$, we have $\sum_i \tau_i \le \rho N \cdot L$ --- in another word, $\E_i [\tau_i] \le \rho L$. The key difference between our calculation and the Johnson bound is that we will prove $\tau_1,\ldots,\tau_n$ have a large deviation. For convenience, we call $i \in V_L$ heavy if and only if $\tau_i \ge \theta \cdot L$ for $\theta=0.9/D_{\max}$ and show that their sum is $\Theta(N L)$: \begin{equation}\label{eq:heavy_elements} S_h:= \sum_{\text{heavy } i} \tau_i \ge 0.45 \rho N \cdot (L - D_{\max} \cdot \theta L). \end{equation} Since $\theta>\rho$ and $\E_i [\tau_i] \le \rho L$, this implies that $\tau_1,\ldots,\tau_N$ have a large deviation. To prove Eq~\eqref{eq:heavy_elements}, the starting observation is that for each $v \in \Gamma_{odd} \subseteq V_R$, $\sum_{i \in \Gamma(v)} \tau_i \ge L$, by the definition of $\Gamma_{odd}$. Since $v$ has $\le D_{\max}$ neighbors, \[ \sum_{\text{heavy } i\in \Gamma(v)} \tau_i \ge L - D_{\max} \cdot \theta L. \] By the double counting argument, \[ \sum_{v \in \Gamma_{odd}} \sum_{\text{heavy }i \in \Gamma(v)} \tau_i \ge (L - D_{\max} \cdot \theta L) \cdot |\Gamma_{odd}| \ge (L-D_{\max} \cdot \theta L) \cdot 0.45 \rho D \cdot N. \] So \[ \sum_{\text{heavy } i} \tau_i \ge \frac{\sum_{v \in \Gamma_{odd}} \sum_{\text{heavy }i \in N(v)} \tau_i}{D} \ge 0.45 \rho N \cdot (L - D_{\max} \cdot \theta L). \] Moreover, let $N_h$ denote the number of heavy elements. We have $\theta L \cdot N_h \le S_h$, which upper bounds $N_h$ by $S_h/\theta L$. Similar to the argument of the Johnson bound, let $T$ denote all triples of the form $(i,j_1,j_2)$ where $i \in [N]$, $j_1,j_2 \in [L]$ and $C_{j_1}(i) \neq C_{j_2}(i)$. Since the distance between $C_{j_1}$ and $C _{j_2}$ is at least $\delta N$ for any $j_1 \neq j_2$, the number of triples is at least ${L \choose 2} \cdot \delta N$. On the other hand, $T$ is equal to $\sum_{i \in [n]} \tau_i (L-\tau_i)$. Then we provide a upper bound on $\sum_{i \in [n]} \tau_i (L-\tau_i)$ under the two constraints $\sum_i \tau_i \le \rho N \cdot L$ and $\sum_{\text{heavy } i} \tau_i \ge 0.45 \rho N \cdot (L- D_{\max} \cdot \theta L)$. \begin{claim}\label{clm:upper_bound_triples} Given $\sum_i \tau_i \le \rho N \cdot L$, the heavy threshold $\theta$, and $S_h \ge 0.45 \rho N \cdot (L- D_{\max} \cdot \theta L)$, $\sum_{i \in [n]} \tau_i (L-\tau_i) \le N_h \cdot \theta L (L-\theta L) + (N-N_h) \cdot e L (L - eL) $ where $S_h = 0.45 \rho N \cdot (L- D_{\max} \cdot \theta L)$, $e=\frac{\rho L N - S_h}{L(N-N_h)}$, and $N_h$ is equal to the upper bound $S_h/\theta L$. \end{claim} We defer the proof of Claim~\ref{clm:upper_bound_triples} to Section~\ref{sec:bound_triples} and summarize the two bounds to get \[ {L \choose 2} \delta N \le T \le N_h \cdot \theta L (L-\theta L) + (N-N_h) \cdot e L (L - eL) \] where $e=\frac{\rho L N - S_h}{L(N-N_h)}$ and $N_h=S_h/\theta L$. This implies \[ \left( \delta/2 + \frac{N_h}{N} \theta^2 + \frac{N-N_h}{N} e^2 - \rho \right) L \le \delta/2. \] So $L$ is upper bounded when the decoding radius $\rho$ satisfies $\delta/2 + \frac{N_h}{N} \theta^2 + \frac{N-N_h}{N} e^2 - \rho>N^{-O(1)}$ where $\frac{N_h}{N} \theta + \frac{N-N_h}{N} e = \rho$. For convenience, let $\rho^*$ be the limit of $\rho$ satisfying the above inequality, i.e., $\delta/2 + \frac{N_h}{N} \theta^2 + \frac{N-N_h}{N} e^2 - (\rho^*)=0$. We show $\rho^*>r$ and provide an explicit lower bound in the rest of this proof. \paragraph{Comparing with the Johnson bound.} Recall that the Johnson bound $r$ is obtained from the equation \[ \delta/2 + r^2 - r = 0, \] which implies $r = \frac{1 - \sqrt{1-2 \delta}}{2}$. Back to the equation of $\rho^*$, \begin{equation}\label{eq:new_radius} \delta/2 + \frac{N_h}{N} \theta^2 + \frac{N-N_h}{N} e^2 - (\rho^*)=0. \end{equation} Given $\frac{N_h}{N} \theta + \frac{N-N_h}{N} e = \rho^*$, the two middle terms \[ \frac{N_h}{N} \theta^2 + \frac{N-N_h}{N} e^2 = (\rho^*)^2 + \frac{N_h}{N} (\theta - \rho^*)^2 + \frac{N-N_h}{N} (e-\rho^*)^2 = (\rho^*)^2 + \frac{N_h}{N} \cdot \frac{N-N_h}{N} (\theta - e)^2. \] This would always increase the range of $\rho^*$ since $\frac{N_h}{N} \cdot \frac{N-N_h}{N} (\theta - e)^2$ is positive. Specifically, the two equations imply \begin{align*} (\rho^*)^2 - r^2 + \frac{N_h}{N} \cdot \frac{N-N_h}{N} (\theta - e)^2 - \rho^* + r & = 0 \\ \Leftrightarrow (\rho^* - r) \cdot (1 - \rho^* - r) & = \frac{N_h}{N} \cdot \frac{N-N_h}{N} (\theta - e)^2 \\ \Leftrightarrow \rho^* - r & = \frac{\frac{N_h}{N} \cdot \frac{N-N_h}{N} (\theta - e)^2}{1-\rho^*-r}. \end{align*} Since $\theta>0.544 \delta$ and $e<\rho \in [0.5 \delta, 0.54 \delta]$, we have $\theta-e=\Omega( \delta)$. Moreover, $N_h/N=\Omega(D_{\max} \cdot \delta)$ from Claim~\ref{clm:upper_bound_triples} and both $r$ and $\rho$ are at most $0.1$; so we have $\rho^*-r = \Omega(D_{\max} \cdot \delta^3)$. \paragraph{Showing $\rho^*=\bigg( \frac{1}{2} + \Omega(1/D_{\max}) \bigg) \delta$.} We only need to consider $1/D_{\max} \ge 2\delta$ such that $\theta=0.9/D_{\max}$ is greater than $\rho$ \big(otherwise $r=( \frac{1}{2} + \Omega(1/D_{\max}) ) \delta$ \big). By the same argument, we will get \eqref{eq:new_radius} as the limit of $\rho$. Then we simplify \eqref{eq:new_radius} to \[ \rho^*>\delta/2 + \frac{N_h}{N} \theta^2 = \delta/2+ \frac{S_h}{N L} \cdot \theta = \delta/2 + 0.045 \rho^* \cdot 0.9 /D_{\max}. \] This implies $\rho^* > \frac{d/2}{1 - 0.04 /D_{\max}} = d/2 \cdot (1+\Omega(1/D_{\max}))$\footnote{While a better constant in $\Omega(1/D_{\max})$ is $0.1125$ obtained via $\theta=1/2D_{\max}$, we did not intend to optimize the constant in this work.}. \end{proofof} \subsection{Proof of Claim~\ref{clm:threshold_theta}}\label{sec:proof_threshold} When $\alpha/\varepsilon \le 0.1$, the Johnson bound $r=\frac{1}{2}(1-\sqrt{1-2\delta})$ has a Taylor expansion $\frac{\delta}{2} + \frac{2^{-2}}{2 \cdot 2!} \cdot (2\delta)^2 + \cdots$. This is at most $1.06 \cdot \frac{\delta}{2}=\frac{0.265 \alpha}{\varepsilon}$ for $\delta=\alpha/2\varepsilon$. Then, we show $\frac{1}{D_{R}} \ge \frac{0.33 \alpha }{\varepsilon}-O(1/M)$. We plan to apply the 2nd lower bound in Lemma~\ref{lem:expansion_larger} for $k:=0.95/\varepsilon$. A subset of size $k \alpha N$ exists because $0.95 \alpha /\varepsilon \le 3.8/D_R + O(1)/M$ from Fact~\ref{fact:relations_parameters}. Since $D_R\ge 4$, this is less than 1 such that one could find a subset of size $k \alpha N$ in $V_L$. Next we apply Lemma~\ref{lem:expansion_larger} to such a subset in $V_L$ of size $k \alpha N$ and have \[ \frac{k}{2} (1- \frac{2k\varepsilon -1}{3-2/k}) \cdot D \alpha N - O(1) \le M. \] For $k=0.95/\varepsilon$, we use $D N = D_R M$ to simplify it to \[ \frac{0.95}{2 \varepsilon} \cdot (1- \frac{0.9}{3-2\varepsilon/0.9}) \cdot \alpha D_R M - O(1) \le M. \] Since $\varepsilon \le 1/4$, we have \[ \frac{0.95 \alpha}{2 \varepsilon} \cdot (1-\frac{0.9}{3}) \le 1/D_R + O(1/M), \]which shows $1/D_R \ge \frac{0.3325 \alpha}{\varepsilon} - O(1/M)$ Given $D_{\max} \le 1.1 D_R$, we have that $\theta:=0.9/D_{\max} \ge 0.9/1.1 D_R \ge 0.272 \alpha /\varepsilon$ is strictly larger than $r<0.265\alpha/\varepsilon$. \subsection{Proof of Claim~\ref{clm:upper_bound_triples}}\label{sec:bound_triples} We divide the proof into four steps: \begin{itemize} \item When $\sum_{i} \tau_i$, $S_h$ and $N_h$ are fixed, $\sum_{i \in [n]} \tau_i (L-\tau_i)$ is maximized at $\tau_i=S_h/N_h$ for heavy elements and $\tau_i=(\sum_{i} \tau_i- S_h)/(N-N_h)$ for non-heavy elements. So we assume heavy elements and non-heavy elements have the same values of $\tau_i$ separately. \item Then we fix $S_h$ and $N_h$ and focus on $\sum_i \tau_i$. Since $\tau_i=(\sum_{i} \tau_i- S_h)/(N-N_h)$ for non-heavy $i$'s is less than $L/2$, increasing $\sum_i \tau_i$ will make $\sum_i \tau_i (L-\tau_i)$ larger. So we assume $\sum_i \tau_i=\rho L N$ to estimate an upper bound. \item Next, when $S_h$ is fixed, the upper bound \begin{equation}\label{eq:upper_bound_johnson} N_h \cdot (S_h/N_h) \cdot (L-S_h/N_h) + (N-N_h) \cdot \frac{\rho L N - S_H}{N-N_h} \cdot (L-\frac{\rho L N - S_H}{N-N_h}) \end{equation} has a positive derivative $(\frac{S_h}{N_h})^2 - (\frac{\rho L N - S_h}{N-N_h})^2$ with $N_h$ from the definition of heavy elements. To estimate an upper bound, we fix $N_h=S_h/\theta L$. \item Finally, by the convexity of $\sum_i \tau_i^2$, the upper bound in \eqref{eq:upper_bound_johnson} is maximized at $S_h=0.45 \rho N (L - D_{\max} \cdot \theta L)$. \end{itemize} So we obtain a upper bound where $N_h=S_h/\theta L$ heavy elements have $\tau_i=\theta L$ and the rest elements have $\tau_i=\frac{\rho L N-S_h}{N-N_h}$. \iffalse We set $\theta=1/2D_R$ to compute an explicit bound on $\rho$ in the end of this proof. Then $S_h=0.4 \rho N \cdot L/2$ and $N_h=0.4 \rho N \cdot D_R$. Thus $e=\frac{\rho L N - 0.2 \rho N L}{LN(1-0.4\rho D_R)} = \frac{0.8 \rho}{1-0.4\rho D_R}$ and the inquality becomes \[ d/2 + 0.4 \rho D_R \cdot (1/2D_R)^2 + (1-0.4 \rho D_R) \cdot (\frac{0.8 \rho}{1-0.4\rho D_R})^2 - \rho >0. \] So we have \begin{align*} d/2 + 0.1 \rho /D_R + 0.64 \rho^2 /(1-0.4\rho D_R) - \rho >0. \end{align*} As long as $d/2 + 0.1\rho/D_R - \rho >0$, i.e., $\rho \le \frac{d/2}{1-0.1/D_R}$, the inequality holds and $L$ is bounded. This shows that the list decoding radius is at least $\frac{d/2}{1-0.1/D_R}=\frac{d}{2} \cdot \big( 1+\Omega(1/D_R) \big)$. \begin{proof} Let the decoding radius $\rho \le 0.6 d$ in this writeup where $d=\frac{\alpha}{2\varepsilon}$ is the distance. More importantly, we assume the expander is $D$-regular on the left and $D_R$-regular on the right. Given $y$, $C_1,\ldots,$ and $C_L$, we assume there exists $C_j$ with $|y \oplus C_j|=\rho$ such that $N_{odd} = N_{odd}(y \oplus C_1)=\cdots=N_{odd}(y \oplus C_L)$ is of size at least $\rho \cdot (1-2\varepsilon \cdot \frac{\rho}{\gamma N}) D \ge 0.4 \rho D$. Then we follow the above notation $\tau_i=\# \left\{j\in[L] \big| i \in \mathsf{supp}(y+C_j) \right\}$. Moreover, we call $\tau_i$ heavy only if $\tau_i \ge \frac{L}{2D_R}$. We first show \begin{equation}\label{eq:sum_heavy_tau} \sum_{i \in [N]: \tau_i \text{ is heavy}} \tau_i \ge 0.2 \cdot L \cdot \rho. \end{equation} First of all, for each $v \in N_{odd}$, $\sum_{i \in N(v)} \tau_i \ge L$ by the definition. Since $v$ has $D_R$ neighbors, \[ \sum_{i \in N(v): \tau_i \text{ is heavy}} \tau_i \ge L/2. \] So we apply the double counting argument \[ \sum_{v \in N_{odd}} \sum_{i \in N(v): \tau_i \text{ is heavy}} \tau_i \ge L/2 \cdot |N_{odd}|. \] This is at least $L \rho \cdot 0.2 D$ given our parameter. On the other hand, \[ \sum_{i: \tau_i \text{ is heavy}} \tau_i \ge \frac{\sum_{v} \sum_{i \in N(v): \tau_i \text{ is heavy}} \tau_i}{D} \ge 0.2 |L| \cdot \rho. \] Next we bound the number of heavy $\tau_i$'s. Since $\tau_i \ge \frac{L}{2 D_R}$ in the definition, the number of heavy $\tau$'s is at most $\frac{0.2 L \rho}{L/2D_R} \le 0.4 \rho D_R$. Finally we consider the inequality \[ \sum_{i=1}^n {L-\tau_i \choose 2} \le (N-d) {L \choose 2}. \] We show the left hand side is lower bounded when $0.4 \rho D_R$ vertices have $\tau_i=L/2D_R$. Let $M$ denote the number of heavy ones. So it is minimized when all heavy ones have $\tau_i=\frac{0.2 L \rho}{M}$ and all light ones have $\tau_i=\frac{L \rho - 0.2 L \rho}{n-M}$. So the left hand side is at least \begin{align*} & M \cdot {L-0.2L\rho/M \choose 2} + (n-M) \cdot {L-\frac{L \rho - 0.2 L \rho}{N-M} \choose 2} \\ = & M (L-0.2 L\rho/M)(L-0.2 L\rho/M - 1)/2 + (N-M) \cdot (L-\frac{L \rho - 0.2 L \rho}{N-M}) \cdot (L-\frac{L \rho - 0.2 L \rho}{N-M}-1)/2 \\ = & \left( M L^2 - 0.4 L^2 \rho + (0.2 L \rho)^2/M - M(L-0.2L\rho/M ) \right)/2 + \\ & \left( (N-M)L^2 -2 \cdot 0.8 L^2 \rho + (0.8 L \rho)^2/(N-M) - (N-M)(L - \frac{0.8 L \rho}{N-M}) \right)/2 \\ = & \left( N \cdot L^2 - 2 L^2 \rho + (0.2 L \rho)^2/M + (0.8 L \rho)^2/(N-M) - NL-\rho L) \right) \end{align*} As $N>>M$, $(0.2 L \rho)^2/M + (0.8 L \rho)^2/(N-M)$ is minimized at the upper bound of $M=0.4 \rho D_R$. We finish the calculation of $\rho$ as follows. For $M=0.4 \rho D_R$, \begin{align*} N \cdot L^2 - 2 L^2 \rho + (0.2 L \rho)^2/M + (0.8 L \rho)^2/(N-M) - NL + \rho L & \le (N-d) L(L-1)\\ - 2 \rho L + 0.04 L \rho^2/M + 0.64 L \rho^2/(N-M) + \rho & \le (N-d) (L-1) - N L + N \\ -2 \rho L + 0.04 L \rho^2/M + 0.64 L \rho^2/(N-M) + \rho & \le -d(L-1) \end{align*} We switch the two sides to obtain \[ d(L-1) \le 2\rho L - 0.1 L \rho /D_R - 0.64 L \rho \cdot \frac{\rho}{N-M} - \rho. \] So $L \le \frac{d - \rho}{d - (2 - 0.1/D_R - 0.64 \cdot \frac{d}{N-M})\rho}$ when $(2 - 0.1/D_R - 0.64 \cdot \frac{d}{N-M}) \cdot \rho \le d$. \textcolor{red}{Xue: We may be able to improve $0.1/D_R$ to $0.2/D_R$ or larger.} \end{proof} In this section, I'm going to implement Xue's argument, to deduce the expander code has list-decoding radius larger than $\frac{1}{2}$. Unfortunately, I can only get a decoding radius approx to $\frac{1}{2} + \Omega(\frac{1}{D D_R})$. \begin{proof} Suppose $n$ is the number of vertices in the left part, $C_1, \cdots, C_L \in B(y, n\rho)$ contained in a hamming ball of center $y$ with relative distance $\rho$. Let $\tau_i = |\{j \in [L] | i \in \mathsf{supp}(y+C_j) \}|$ be the number of $C_j$ which doesn't meet $y$ at vertex $i$. Then we have: \begin{itemize} \item $\sum_{i = 1}^n \tau_i \leqslant LN\rho$. \item $\sum_{i = 1}^n \left( \binom{\tau_i}{2} + \binom{L-\tau_i}{2} \right) \leqslant n(1-\delta)\binom{L}{2}$. \end{itemize} Under the first constraint, the LHS of the second inequality takes minimum value when $\tau_i$ are equal. This will give us Johnson bound. Under Xue's argument, we are going to find a subset $X \subseteq [n]$ such that the average of $\tau$ on $X$ is significantly larger than the global average. And thus get an improvement of Johnson bound. Let $X = N(N_{odd}) \bigcap \cup_{j = 1}^L \mathsf{supp}(y+C_j) = \bigcup_{j = 1}^L \left( N(N_{odd}) \cap \mathsf{supp}(y+C_j) \right)$. Since $|\mathsf{supp}(y+C_j)| \geqslant \frac{n\delta}2$, $|N_{odd}| \geqslant \frac{nD\delta}{4}$ by expander property. Consider the neighbours of $\mathsf{supp}(y+C_j) \setminus \left( N(N_{odd}) \cap \mathsf{supp}(y+C_j) \right)$, it was contained in $N(\mathsf{supp}(y+C_j)) \setminus N_{odd}$, which is bounded by $D|\mathsf{supp}(y+C_j)| - |N_{odd}| \leqslant D|\mathsf{supp}(y+C_j)| - \frac{nD\delta}4$. The expander property tells us that $| \mathsf{supp}(y+C_j) \setminus \left( N(N_{odd}) \cap \mathsf{supp}(y+C_j) \right) |$ should also be small. So it's easy to deduce that $\left| \left( N(N_{odd}) \cap \mathsf{supp}(y+C_j) \right) \right| \geqslant \frac{n\delta}{8}$ when expander parameter is good. Now, I want to consider the average of $\tau_i$ on the set $X$. In Xue's demonstrative case, $\tau_i$ is equaily distributed on $X$. This is a good case, since it gives us a large average on $X$. But the worst case will bring us $1/D$ loss. Consider each parity bit $v \in N_{odd}$, the neighbours of $v$ in the left is at most $D_R$, namely, $i_1, \cdots, i_{D_R}$. Then $\sum_{k = 1}^{D_R} \tau_{i_k} \geqslant L$. For all $v \in N_{odd}$, sum this inequality. We have: \[ \sum_{i \in X} r_i \tau_i \geqslant |N_{odd}|L \] where $\sum_{i \in X} r_i = |N_{odd}|D_R$ and $1 \leqslant r_i \leqslant D$. \emph{This tells us $\frac{1}{|X|} \sum_{i \in X} \tau_i \geqslant \frac{L}{D D_R}$. } Besides, since $\left| \left( N(N_{odd}) \cap \mathsf{supp}(y+C_j) \right) \right| \geqslant \frac{n\delta}{8}$, we have $\sum_{i \in X} \tau_i \geqslant \frac{n\delta L}{8}$. By using the convexity of $\binom{x}{2}$ on $X$ and $[n] \setminus X$ respectively, we have: \[ \frac{n\delta D D_R}{8} \binom{L-\frac{L}{D D_R}}{2} + (n - \frac{n\delta D D_R}{8}) \binom{L-\frac{L\rho - \frac{L\delta}{8}}{1-\delta \frac{D D_R}{8}}}{2} \leqslant n(1-\delta)\binom{L}{2} \] Let $\gamma = \frac{D D_R}8$, we can simplify it and get: \[ \delta \gamma \binom{L - \frac{L}{8\gamma}}{2} + (1 - \delta \gamma) \binom{L-\frac{L\rho - \frac{L\delta}{8}}{1-\delta \gamma}}{2} \leqslant (1-\delta)\binom{L}{2} \] \[ \delta x \binom{L - Ly}{2} + (1 - \delta x) \binom{L-\frac{L\rho - L\delta xy}{1-\delta x}}{2} \leqslant (1-\delta)\binom{L}{2} \] As what we have done in Johnson bound, compare the coefficient of the quadratic term. We only need: \[ \delta \gamma \left(1 - \frac{1}{8\gamma} \right)^2 + (1 - \delta \gamma)\left( 1 - \frac{\rho - \frac{\delta}8}{1 - \delta\gamma} \right)^2 > 1-\delta \] \[ \delta x \left(1 - y \right)^2 + (1 - \delta x)\left( 1 - \frac{\rho - \delta xy}{1 - \delta x} \right)^2 > 1-\delta \] Or equivalently: \[ \rho < \frac{\delta}8 + \left( 1-\delta\gamma - \sqrt{(1-\delta\gamma)\left(1-\delta - \delta\gamma\left(1- \frac{1}{8\gamma}\right)^2\right)} \right) \] \[ \rho < \delta xy + \left( 1-\delta x - \sqrt{(1-\delta x)\left(1-\delta - \delta x \left(1- y\right)^2\right)} \right) \] Ignoring the $O(\delta^2)$ terms, RHS is approx to: \[ \frac{\delta}8 + \left( 1-\delta\gamma - \left( 1 - \frac{\delta\gamma + \delta + \delta\gamma \left(1 - \frac{1}{8\gamma}\right)^2}{2} \right) \right) = \frac{\delta}8 + \left( \frac{\delta\gamma + \delta + \delta\gamma \left(1 - \frac{1}{8\gamma}\right)^2}{2} - \delta\gamma \right) \] \[ \delta xy + \left( 1-\delta x - \left( 1 - \frac{\delta x + \delta + \delta x \left(1 - y\right)^2}{2} \right) \right) = \delta xy + \left( \frac{\delta x + \delta + \delta x \left(1 - y\right)^2}{2} - \delta x \right) \] which is: \[ \frac{\delta}8 + \frac{\delta}2 - \frac{\delta}{8} + \frac{\delta}{128\gamma} = \frac{\delta}{2} + \frac{\delta}{16D D_R} \] \[ \delta xy + \frac{\delta}2 - \delta xy + \frac{\delta xy ^2}{2} = \frac{\delta}2 + \frac{\delta xy^2}2 \] \end{proof} \textcolor{red}{Xue: Thanks for the writing! I think a tighter analysis is to consider $\tau_i \ge \frac{L}{2 D_R}$.} \textcolor{red}{ Basically, this may not be the best bound because the average $\tau_i$ in $X$ --- $L/D_L D_R$ seems too small (at least to me). If we only consider $\tau_i \ge \frac{L}{2 D_R}$. On one hand, for each vertex $v$, $\sum_{i \in N(V)} \tau_i \ge L/2$. On the other hand, we could bound the number of such $\tau_i$ by $\le \frac{\rho D_R}{2}$ using the counting argument again. So can we get an improvement like $\Omega(1/D_R)$ for a smaller constant? } \fi \section{Open Questions}\label{sec:open} Our work leaves many intriguing open questions, and we list some of them here. \begin{enumerate} \item Our distance in Theorem~\ref{thm:infor_distance} is only shown to be tight by a graph that is not strictly regular on the right. For bipartite expander graphs that are regular on both sides, is it possible to get an improved distance bound, or is the bound in Theorem~\ref{thm:infor_distance} still tight? \item Can one design efficient algorithms to correct more errors? Specifically, it would be nice to get close to the half distance bound. Alternatively, is there any hardness result that prevents us from achieving this? \item Can one design efficient algorithms to correct more errors for the case of $\varepsilon \ge 1/4$? So far all our improvements over previous results are only for the case of $\varepsilon < 1/4$. \item Can one get a better list decoding radius for general expander codes? Can one design efficient list decoding algorithms? As mentioned before, any efficient list decoding algorithm would also immediately improve our results on unique decoding, and in particular imply unique decoding up to half distance. If there is any hardness result for unique decoding close to half distance, this would also rule out the possibility of list decoding for general expander codes. \end{enumerate} \section{Preliminary}\label{sec:preli} We will use $1\{\mathcal{E}\} \in \{0,1\}$ to denote the indicator variable of a event $\mathcal{E}$. Moreover, we use $C$ and $c$ to denote different constants in various proofs of this paper. \paragraph{Basic definitions from graph theory.} Given a graph $G$, we use $V(G)$ to denote its vertex set and $E(G)$ to denote its edge set. Given a bipartite graph $G$, we use $V_L(G)$ and $V_R(G )$ to denote the left hand side and right hand side of the bipartite graph separately. When $G$ is clear, we simplify them as $V_L$ and $V_R$. Moreover, we fix two notations $N := |V_L|$ and $M := |V_R|$. For any subset $S \subseteq V_L \cup V_R$, we always use $\Gamma(S)$ to denote its neighbor set in $G$. If a vertex $v \in \Gamma(S)$ is connected to $S$ by exactly one edge, we call $v$ a unique neighbor of $S$ and use $\Gamma^1(S)$ to denote the set of all unique neighbors of $S$. In this work, we consider bipartite graphs that are regular on the left hand side. Thus we use $D$ to denote the \emph{regular} degree in $V_L$ and $D_R$ to denote the \emph{average} degree in $V_R$. Since $N=|V_L|$ and $M=|V_R|$, we have $N \cdot D = M \cdot D_R$. Moreover, we will use $D_{\max}$ to denote the \emph{maximum} degree in $G$, which would be the maximum degree in $V_R$ given $M<N$. A bipartite graph $G$ is an $(\alpha N, (1-\varepsilon)D)$-expander if and only if for any left subset $S$ of size at most $ \alpha N $, its neighbor set $\Gamma(S)$ has size $ \geq (1-\varepsilon)D \cdot |S|$. For convenience, we call $\frac{|\Gamma(S)|}{|S|}$ the expansion of $S$ and say $G$ satisfies $(\alpha N, (1-\varepsilon)D)$ expansion if and only if it is an $(\alpha N, (1-\varepsilon)D)$-expander. Throughout this work, we assume that $D$ and $D_R$ are constants. Since we are interested in expanders with $\varepsilon<1/2$ and $N>M$, we always assume $D > 2$ and $D_R > 3$. \paragraph{Basic definitions from coding theory.} We recall several notations from coding theory and define expander codes formally. \begin{definition} An $(N, k, d)$ binary error correcting code $\mathcal{C}$ is a set of codewords contained in $\mathbf{F}_2^N$, with $|\mathcal{C}| = 2^k$ such that $\forall C_1, C_2 \in \mathcal{C}$, the Hamming distance between $C_1$ and $C_2$ is at least $d$. Moreover we call $k/N$ the rate of $\mathcal{C}$. A linear code is a code whose codewords form a linear subspace of $\mathbf{F}_2^N$. \end{definition} One fact about linear codes is that the distance of a linear code is equal to the minimum weight of non-zero codeword in it. The decoding radius of a decoding algorithm of $\mathcal{C}$ refers to the largest number of errors that the algorithm can correct. \begin{definition}[Expander Codes \cite{SS96}] Given an $(\alpha N, (1-\varepsilon)D)$ expander graph $G$ with $M$ right vertices, the expander code defined by $G$ is $\mathcal{C} \subseteq \mathbf{F}_2^N$ such that \[ \mathcal{C} = \{ C\mid \forall i\in [M], \sum_{j \in \Gamma(i)} C_j = 0\}, \] where the addition is over the field $\mathbf{F}_2$. \end{definition} Given the definition of expander codes, we know its rate is $1-M/N$ and its distance is the minimum weight of non-zero codewords in $\mathcal{C}$. \begin{remark} The original definition of expander codes in \cite{SS96} is more general, where each vertex on the right represents some linear constraints on the codeword bits corresponding to its neighbors. In this paper, we only consider the most popular and well studied case where each vertex on the right represents a parity check. \end{remark} We use the following results of decoding for expander codes, from \cite{Viderman13b}. \begin{theorem}[\cite{Viderman13b}] \label{thm:vidermandecfromerasures} Let $G$ be an $(\alpha N, (\frac{1}{2}+\xi)D)$ expander with $\xi>0$. For the expander code defined by $G$, there is a linear-time algorithm that can correct $ \alpha N$ erasures. \end{theorem} \begin{theorem}[\cite{Viderman13b}] \label{thm:vidermandec} Let $G$ be an $(\alpha N, (1-\varepsilon)D)$ expander for $\varepsilon<1/3$. For the expander code defined by $G$, there is a linear-time algorithm that can correct $\frac{1-3\varepsilon}{1-2\varepsilon} \lfloor \alpha N \rfloor $ errors. \end{theorem} \subsection{Technique Overview} Let $\mathcal{C}$ be an expander code defined by an $(\alpha N, (1-\varepsilon)D)$ expander. Our techniques for the improved distance bound and decoding algorithms are based on the combination of the following three ingredients, together with a new idea of guessing expansions: \begin{itemize} \item A new size-expansion tradeoff for arbitrary bipartite expander graphs, which we establish in this paper. \item A procedure of finding possible corruptions in \cite{Viderman13b}, which we slightly adapt and establish new properties. \item A procedure of flipping bits in the corrupted word to reduce the number of errors, introduced in \cite{SS96}. \end{itemize} We first briefly explain each ingredient. \paragraph{The size-expansion tradeoff.} As mentioned before, we show that any $(\alpha N, (1-\varepsilon)D)$-expander is also roughly a $(k \alpha N, (1-k\varepsilon)D)$-expander for any $k \ge 1$. To prove this, assume for the sake of contradiction that there is a left subset $S$ with size $k \alpha N$ that has smaller expansion. This then implies that there are many \emph{collisions} (two different vertices on the left connected to the same vertex on the right) in the neighbor set of $S$, i.e., more than $k \varepsilon D \cdot k \alpha N=k^2 \alpha \varepsilon ND$ collisions. Now we pick a \emph{random} subset $T \subseteq S$ with size $\alpha N$, then each previous collision will remain with probability roughly $1/k^2$. By linearity of expectation, more than $\alpha \varepsilon ND$ collisions are expected to remain in the neighbor set of $T$, thus implying the expansion of $T$ is smaller than $(1-\varepsilon)D \cdot \alpha N$. This contradicts the expander property. This convenient size-expansion tradeoff is used extensively in our bounds and algorithms. In fact, by using linear programming, we can get a better size-expansion tradeoff for $k \geq \frac{1}{2\varepsilon}$, which we use in our result of list decoding expander codes. \paragraph{The procedure of finding possible corruptions.} Viderman \cite{Viderman13b} introduced the following procedure for finding possible corruptions. Maintain a set $L$ of left vertices, a set $R$ of right vertices and a fixed threshold $h$. Start with $R$ being all the unsatisfied parity checks, then iteratively add left vertices with at least $h$ neighbors in $R$ to $L$, and their neighbors to $R$. Viderman showed that if the number of corruptions is not too large, then when this process ends, $L$ will be a super set of all corruptions and the size of $L$ is at most $\alpha N$. Therefore, one can treat $L$ as a set of erasures and decode from there. In \cite{Viderman13b}, Viderman used sophisticated inequalities to analyze this procedure. In this paper, we show that the process has the following property. \paragraph{Property (*):} If $h =(1-2 \Delta)D$ such that any subset $S$ of corrupted vertices has expansion at least $(1-\Delta)D |S|$, then all corruptions will be contained in $L$. Furthermore, we can assume without loss of generality that the set of corrupted vertices is added to $L$ before any other vertex. \\ This allows us to simplify the analysis in \cite{Viderman13b} and combine with our size-expansion tradeoff. \paragraph{The procedure of flipping bits.} Sipser and Spielman \cite{SS96} introduced a procedure to flip bits in the corrupted word. Again, the idea is to set a threshold $h$, and flip every bit which has at least $h$ wrong parity checks in its neighbors. Sipser and Spielman showed that when $\varepsilon < 1/4$ and the number of corruptions is not too large, this procedure will reduce the number of errors by a constant factor each time. Thus one only needs to run it for $O(\log N)$ times to correct all errors. \paragraph{Our approaches.} We now describe how to combine these ingredients to get our bounds and algorithms. For the distance lower bound, it suffices to choose $k$ such that $1-k\varepsilon > 1/2$. Then a standard analysis as in \cite{SS96} shows the distance of the code is at least $k \alpha N$. Thus, we can set $k \approx \frac{1}{2\varepsilon}$ so that the distance is roughly at least $\frac{\alpha}{2 \varepsilon} N$. A subtle point here is that it is not a prior clear that we can choose $k \approx \frac{1}{2\varepsilon}$, since it may be that $k \alpha N =\frac{\alpha}{2 \varepsilon} N > N$, and no left subset can have size larger than $N$. However, we again use the size-expansion tradeoff to show that this cannot happen. In particular, we show $\frac{\alpha}{\varepsilon} \leq \frac{4}{D_R}$ (recall $D_R$ is the average degree on the right), and thus we can always set $k \approx \frac{1}{2\varepsilon}$. Section~\ref{sec:bound_dist} gives a construction which shows this bound is almost tight. Next we describe our decoding algorithms. \paragraph{Unique decoding for $\varepsilon < 1/4$.} Our algorithm here is based on the following crucial observation. Let $F$ denote the set of corrupted vertices any time during the execution of the algorithm, and assume $|\Gamma(F)|=(1-\gamma)D|F|$, where $\Gamma(F)$ denotes the neighbor set of $F$. If $\gamma$ is large, or equivalently $|\Gamma(F)|$ is small, then the procedure of finding possible corruptions works well. This is because intuitively, the number of vertices added to $L$ will be proportional to $|\Gamma(F)|$, and thus $|L|$ will be small. On the other hand, if $\gamma$ is small, or equivalently $|\Gamma(F)|$ is large, then the procedure of flipping bits works well. This is because intuitively, the procedure of flipping bits works better when the expansion property is better. Hence, we can combine both procedures and set a threshold for $\gamma$. If $\gamma$ is larger than this threshold, we use the procedure of finding possible corruptions; otherwise we use the procedure of flipping bits.\ However, we don't know $\gamma$.\ Thus in our algorithm we guess $\gamma$, and for each possible value of $\gamma$ we apply the corresponding strategy. This is a bit like list-decoding, where we get a small list of possible codewords, from which we can find the correct codeword by checking the Hamming distance to the corrupted word. Note that the procedure of finding possible corruptions always returns a possible codeword; while to get a codeword from the procedure of flipping bits, we need to apply it for a constant number of times, until the number of errors is small enough so that we can easily correct all errors using any known algorithm. Thus we also need to guess $\gamma$ for a constant number of times. Using these ideas, we show that Algorithm~\ref{alg:MultipleGuessWithFlips} can correct $(1-\varepsilon)\alpha N$ errors for any constant $\varepsilon < 1/4$. Now, we can improve this by combining with our size-expansion tradeoff. Specifically, for any constant $\varepsilon < 1/4$ we can choose any $k \ge 1$ such that $k \varepsilon < 1/4$. This implies that a modified algorithm can actually correct $(1-k \varepsilon)k \alpha N$ errors. Setting $k \approx \frac{1}{4 \varepsilon}$ gives us an algorithm that can correct roughly $\frac{3 \alpha}{16 \varepsilon} N$ errors. For the running time, each time we guess $\gamma$, we know $\gamma=1-\frac{|\Gamma(F)|}{D|F|}$ with $|\Gamma(F)| \in [M]$ and $|F| \in [N]$. Thus a naive enumeration will result in $O(M N)=O(N^2)$ possible values. Since we need to guess $\gamma$ for a constant number of times, this will lead to a polynomial running time. However, instead we can enumerate $\gamma$ from $\{0, \eta, 2\eta, \ldots, \lceil \frac{1}{\eta} \rceil \eta\}$ for a small enough constant $\eta>0$. This reduces the running time to linear time, at the price of decreasing the relative decoding radius by an arbitrarily small constant. Finally, we remark that this algorith can be executed in logarithmic time on a linear number of parallel processors, since its main ingredients from \cite{SS96,Viderman13b} have parallel versions in logarithmic time. \paragraph{Unique decoding for smaller $\varepsilon$.} When $\varepsilon$ is even smaller, e.g., $\varepsilon < 1/8$, our algorithm uses the procedure of finding possible corruptions, together with property (*) we established. Let $F$ denote the set of corrupted vertices in the received word. To use property (*), we need to find a $\Delta$ such that for any $S \subseteq F$, $S$ has expansion at least $(1-\Delta)D |S|$. Then we can set the threshold $h=(1-2 \Delta)D$. In \cite{Viderman13b}, one assumes $|F| \leq \alpha N$ and thus it is enough to set $\Delta = \varepsilon$. However, our goal here is to correct more than $\alpha N$ errors, thus this choice of $\Delta$ no longer works. Instead, we use our size-expansion tradeoff to show that if $|\Gamma(F)|=(1-\gamma)D|F|$, then when $S \subseteq F$ and $|S| \ge \alpha N$, we always roughly have $|\Gamma(S)| \geq (1-\sqrt{\frac{\gamma |F| \varepsilon}{\alpha N}})D |S|$, thus we can set $\Delta=\max\{\sqrt{\frac{\gamma |F| \varepsilon}{\alpha N}}, \varepsilon\}$. However, again we don't know $\gamma$ and $|F|$. Thus we apply the same trick as before, and guess both quantities. This leads to Algorithm~\ref{alg:decoding_small_eps}. Since we have two possible cases ($\Delta=\sqrt{\frac{\gamma |F| \varepsilon}{\alpha N}}$ or $\Delta =\varepsilon$), we get two different decoding radii for different ranges of $\varepsilon$. The running time is polynomial if we use the naive enumeration of $\gamma$ and $|F|$, but can be made linear by using a similar sparse enumeration as we discussed before. \paragraph{List decoding radius.} Recall that our goal is to show that given any $y \in \mathbf{F}_2^N$, there is a list of at most $N^{O(1)}$ codewords within distance $\rho N = (\frac{1}{2} + \Omega(1/D_{\max}) )d $ to $y$. Our analysis modifies the double counting argument that is used to show the Johnson bound. The modification is by using the special structure of expander codes. In more details, suppose the list of $L$ codewords within distance $\rho N$ to $y$, is $\{C_1, \ldots, C_L\}$. Let $\tau_i$ be the number of codewords in the list which have their $i$-bit different from $y$. We focus on counting the number $T$ of ``triples'' $(i, j_1, j_2)$, where the pair of codewords $(C_{j_1}, C_{j_2})$ are different in their $i$-th bit. Since the code has distance $d = \delta N$, we know $T \geq {L \choose 2}\delta N$. We also know $T = \sum_{i\in [N]}\tau_i(L-\tau_i)$. The key observation in our analysis is that for expander codes, $\{\tau_i, i\in [N]\}$ have a large deviation. Specifically, we call $\tau_i$ \emph{heavy} if $\tau_i \geq \frac{0.9}{D_{max}}L$, and show that the summation of heavy $\tau_i$'s is $\Theta(NL)$. By using this observation, we manage to get a better upper bound for $T$ than that in the proof of the Johnson Bound in certain situations, which in turn yields a better list-decoding radius.
{'timestamp': '2022-01-11T02:27:48', 'yymm': '2111', 'arxiv_id': '2111.07629', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07629'}
arxiv
\section{Introduction} \label{sec:intro} The use of machine learning in clinical settings is becoming widespread, and with the adoption of electronic health records (EHRs) has produced big health data and been opened to modern machine learning approaches \citep{Jiang2017, vaci2020natural}. Whilst ubiquitous, there is still a relative lack of uptake in the use of machine learning in live clinical settings, with neural networks often labelled black boxes. The transparency and explainability of neural networks is critical to trust and acceptance in clinical environments as useful tools. Research has sought to provide improved interpretability of NLP models using methods to derive extractive rationales for neural networks predictions by the model itself \citep{bastings-etal-2019-interpretable, lei-etal-2016-rationalizing, Sha2020}. The aim of rationale production is to increase explainability of models by extracting the minimal crucial input required to make a class prediction. In NLP, the rationales are subsets of the input text which maintain predictive power. One of the ways rationales have been achieved is by creating a two-module network, i.e., a selector followed by a predictor, which are trained jointly \citep{lei-etal-2016-rationalizing}. Given an input $x$, the selector picks a subset of the input features $r(x)$ (the rationale) by specifying a distribution over the possible rationales. The predictor acts as a standard classifier, taking as input $r(x)$ and predicting a class $\hat{y}$ to compare with the ground truth class $y$. \citet{Sha2020} proposed InfoCal, an improved type of selector-predictor model that uses an information calibration technique and an additional guider module trained jointly with the selector and predictor in an adversarial manner. InfoCal achieves the current state-of-the-art in rationale extraction on tasks such as sentiment analysis and legal judgment prediction, hence we are interested to see how it performs in the medical domain. In this work, we apply InfoCal to the task of predicting hospital readmission from EHRs \citep{Johnson2016}. We compare InfoCal with clinical domain Bidirectional Encoder Transformer (BERT) models, ClinicalBERT \citep{Huang2019} and BioClinicalBERT \citep{Alsentzer2019}. Additionally we compare InfoCal exrractive rationales with importance features in the BERT models via self-attention and layerwise relevance propagation (LRP). We find that the BERT models outperform InfoCal on the classification task, but has a relatively limited mechanism for interpretability in the form of self-attention. InfoCal was able to produce extractive rationales which reach baseline performance on the classification task, and we argue the difficulty lies in the domain expertise created by pretraining present in the BERT based models. \vspace{-0.4cm} \section{Related Work} \label{sec:EHRs} With the advent of big data and machine learning, research is beginning to glean insights from the many types of EHRs data \citep{li2020behrt,Huang2019,Kormilitzin2020,Weng2017, Wang2018, Kuruvilla2014, Barak-Corren, Johnson2016}. Data within EHRs can be either structured (following a pre-defined data structure and type, such as ECG recordings, x-ray images, laboratory results, and demographics) or unstructured data (lacking formal rules, type, and bounds, such as the free-text clinical notes which remain in a natural language format). The frequency and volume in which clinical notes are recorded for individual patients surpass that of any other data type within EHRs, with some patients having hundreds of individual notes over their entire history of care \citep{Huang2019,Boag_etal_2020,Barak-Corren,Wang2018, Weng2017}. Consequently, the information within these clinical notes arguably provides a nuanced, rich picture of a patient's symptoms and trajectory to augment other measures. Other research has applied similar selector-predictor style models to medical text for certain tasks, such as diagnosis code prediction,and treatment success inference \citep{mullenbach2018,Lehman2019}. To our knowledge this work is the first to apply InfoCal to a clinical domain task, and to compare rationales with self-attention and layerwise relevance propagation (LRP) in BERT models. \vspace{-0.4cm} \section{Experiments} \label{sec:methods} \paragraph{Dataset.} We use the Medical Information Mart for Intensive Care III (MIMIC-III) \citep{Johnson2016}, a widely-used, freely available dataset developed by the MIT Lab for Computational Physiology. It comprises of de-identified health data associated with 38,597 critical care patients and 58,976 intensive care unit (ICU) admissions at the Beth Israel Deaconess Medical Center between 2001 and 2012. It includes demographics, vital signs, laboratory tests, medications, caregiver notes, imaging reports, and mortality in and out of hospital. Our task is to predict the likelihood of an individual patient being re-admitted to the hospital within 30 days of their initial entry to the ICU. To model only unexpected readmission, we exclude any patients who revisited the hospital due to a scheduled appointment. Any admissions with deaths are also removed, and we limit the cohort to non-newborns only, because newborn patients are routinely transferred and discharged frequently, leading to a different distribution of clinical notes and readmission when compared with the general population. The final study cohort contains 34,560 patients with 2,963 positive readmission labels and 42,358 negative readmission labels. \paragraph{InfoCal.} This is a modular architecture that utilises adversarial training and information bottleneck to produce extractive rationales to justify the models' predictions. A top-level overview is provided, see Fig.\ref{fig:InfoCal}. The key components are the selector, guider, predictor, and discriminator modules. The goal of the selector and guider is to generate a subset of features or tokens to provide to the predictor using the information bottleneck technique. These selected features are further calibrated through training or fooling a discriminator model via adversarial training. The discriminator is attempting to distinguish the generated features in the selector model from the full set given to the guider model. The goal is to encourage the selected features to contain minimal yet sufficient information from the full set. An important note here is that the original InfoCal paper had also used a pretrained language model regularizer to encourage fluency and coherence in extracted rationales, whereby the rationales produced incurred a higher loss if they did not conform with the language models representation of the corpus: however, this reduced performance in our case, thus was ommited. \begin{figure}[!htb] \centering \includegraphics[width=0.5\textwidth]{Figures/infocal_arch.PNG} \caption{Architecture of InfoCal. The grey boxes are the loss functions, with the red arrows indicating data required to calculate loss. Taken from \citep{Sha2020} } \label{fig:InfoCal} \end{figure} For a full overview of the model architecture and mathematical foundations, please see \citep{Sha2020}. For training details, see appendix. \paragraph{BERT models.} We use two pretrained Bidirectional Encoder Representations from Transformer (BERT) models; ClinicalBERT \citep{Huang2019}, pretrained on MIMIC III clinical text only, initialised from the original BERT model \citep{devlin2019bert} and BioClinicalBERT \citep{Alsentzer2019}, pretrained on all MIMIC III notes data, but initialised from BioBERT \citep{LeeBioBert}, for further details see appendix. \paragraph{Baseline models.} The following machine learning models were also trained on the classification task to compare with the neural networks performance: logistic regression, random forest, and xgboost. Features to the model were bag of words vector representations of token sequences, for details see appendix. \vspace{-0.4cm} \section{Results} Evaluation metrics for ClinicalBERT \citep{Huang2019}, BioClinicalBERT \citep{Clark2019}, InfoCal \citep{Sha2020}, and the baseline models are presented in Table \ref{tab:machines}. A simple visual comparison of interpratibility techniques applied to ClinicalBERT and our InfoCal derived features or rationale is presented in Table \ref{tab:rations}. The techniques used for ClinicalBERT involve looking at self-attention weights of particular layers with respect to the input tokens \citep{devlin2019bert, Huang2019, Clark2019}, and layer-wise relevant propagation, which captures the influence of each input on the model output through back-propagation \citep{Bach2015}, see appendix for further details. \label{sec:results} \begin{table*}[!htb] \centering \caption{Evaluation metrics of each model. Area under the curve (AUC), area under the precision-recall curve (AUPRC), recall at precision 80 (R80), and F1-Macro scores are presented} \label{tab:machines} \input tables/model_evaluation.tex \end{table*} \begin{table*}[!htb] \begin{center} \caption{Comparison of different model derived explanations for an example clinical discharge passage. The selected tokens, highlighted in blue, were those given most weight, or attention by the model in the case of ClinicalBERT, and the selected features or rationale in the case of InfoCal} \label{tab:rations} \begin{tabular}{p{0.1\textwidth}p{0.1\textwidth}p{0.7\textwidth}} \hline \textbf{Model} & \textbf{Prediction} &\textbf{Sample text} \\ \hline clin-BERT with self-attention & Readmission &Has experienced acute on chronic \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{diastolic}} heart failure in the setting of volume overload due to his sepsis \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{prescribed warfarin}} due to high sys blood pressure 160 setting\\ \midrule clin-BERT with LRP & Readmission &Has experienced acute on chronic diastolic \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{heart failure}} in the setting of volume \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{overload}} due to his sepsis prescribed warfarin due to high sys blood pressure 160 \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{setting}} \\ \midrule \textbf{InfoCal rationales} & Readmission &Has experienced acute on chronic diastolic heart failure in the setting of volume overload due to his sepsis prescribed \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{warfarin}} due to \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{high}} sys blood \textcolor[rgb]{0.5543118699137254,0.6900970112156862,0.9955155482352941}{\textbf{pressure}} 160 setting \\ \bottomrule \end{tabular} \end{center} \end{table*} \vspace{-0.4cm} \section{Discussion} \paragraph{Predicting hospital readmission.} The novel InfoCal model achieved results in line with much simpler baseline models and the literature \citep{Huang2019, Barbieri2020}. However, the ClinicalBERT model still outperforms all models significantly. Although, it must be stated that the reported performance of InfoCal reflects predictions based solely on the generated rationale as input to the classifier, which was, on average, substantially fewer tokens than the raw input used by other models presented. We suggest that the relative inability to apply InfoCal to a clinical domain task is due to the lack of medical text pre-training, and also the underlying word vector embeddings and predictor model used. \paragraph{Explaining predictions.} Each of the presented interpretability methods shown in Table \ref{tab:rations} highlight a number of tokens as most important in the models processing and subsequent output. There is some overlap, but it is interesting to see how different approaches yield different features. For the ClinicalBERT model, we explored self-attention weights and layer-wise relevance propagation, which both work in a layer-by-layer manner, and are post-hoc. Self-attention visualisations highlight the attention weights between tokens in the input sequence and can provide insight into the language representation of the BERT model, but do not necessarily highlight direct links between input and classification output. Layer-wise Relevance Propagation (LRP) on the other hand acts like a forward pass in reverse, using the weights and neuron activation as a signal of specific input relevance to the final output \citep{Bach2015, arras-etal-2016-explaining}. Both approaches are utilising the entire input sequence, and provide quite intuitive results, although there are doubts to the usefulness of attention weights as explainability metrics \citep{wiegreffe-pinter-2019-attention}. Furthermore, with large models such as BERT, using LRP can become quite challenging, with a need to design appropriate propagation rules for different neural network layers \citep{Montavon2019}. We argue models with built-in explainability methods may provide more straightforward interpretability, however, without medical domain expertise found in ClinicalBERT the InfoCal model struggles to extract the most useful information. The extracted features or rationales produced by the InfoCal model was shown to achieve solid performance on predicting readmission, although significantly worse than the BERT based models. The InfoCal model intends to yield the least-but-enough information in the form of rationales, which are then used alone to make a prediction on the task at hand. However, it is clear these rationales lack fluency and are often not comprehensible alone, which has been shown to be the case in other applications \citep{kaur2020interpreting, Alufaisan_Marusich_Bakdash_Zhou_Kantarcioglu_2021}. We must reiterate that the original InfoCal work \citep{Sha2020} had used a pretrained language model as a regularizer, which had not worked in our experiment. We feel there is certainly promise in the method presented, with extractive rationales extracted and used by the model. But it is clear the state-of-the-art performance of InfoCal in other domains, did not transfer to the clinical domain and task presented. Further work is needed to extend the presented results, for instance, to improve medical domain performance, components of the InfoCal architecture could be integrated with BERT models. There is a strong possibility that the performance shown by the BERT models is transferable to the InfoCal architecture. Whether or not InfoCal can simply be plugged into a BERT model remains to be seen. To fully investigate the usefulness and interpretability of a models supposed explanations or feature salience will likely require the production of clinician derived ground truths. \acks{NT is supported by the EPSRC Center for Doctoral Training in Health Data Science (EP/S02428X/1), DWJ, ANH and AK are supported by the National Institute for Health Research (NIHR) Artificial Intelligence for Health and Social Care Award (AI-AWARD02183).}
{'timestamp': '2021-11-16T02:28:41', 'yymm': '2111', 'arxiv_id': '2111.07611', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07611'}
arxiv
\section{Introduction} \label{sec:introduction} \subsection{FEM mesh generation} In Figure 1, there are two techniques to mesh a given boundary: structured (Thompson et~al.(1998)) and unstructured meshes (Owen(1998)). All elements in a structured mesh are first arranged in a regular way before being mapped to the real-world boundaries. As a result of the complex boundaries, the mesh quality may be poor. Unstructured mesh can be categorized into indirect and direct methods. Indirect methods require an intermediate triangular mesh, which is prone to instability and has a restricted number of vertices (Garimella et~al.(2004)), whereas direct methods generate quadrilateral pieces directly, avoiding some potential problems (Zeng and Cheng(1993)). Our research is based on the element extraction method, which is the most popular of the direct methods (Docampo-Sanchez and Haimes(2019)). \begin{figure} \centering \subfloat[Structured mesh] { \includegraphics[width=0.244\linewidth]{figures/structure.pdf} } \subfloat[Unstructured mesh] { \includegraphics[width=0.256\linewidth]{figures/unstructure.pdf} } \caption{Two ways to mesh a given boundary. Indirect unstructured meshes have a transformation process while direct ones generate quadrilateral elements directly.} \label{fig:structure} \end{figure} \subsection{Previous works} MCTS with deep neural networks (NN) can defeat world champions in the game of Go, according to previous research in Silver et~al.(2016) and Silver et~al.(2017). NN may train with self-play from a random policy to a top player using Deep Reinforcement Learning (DRL). Yao et~al.(2005) and Pan et~al.(2021) also reported on the notion of utilizing the Artificial Neural Network (ANN) and DRL on FEM mesh generation. The Advantage Actor-Critic (A2C) approach, as shown in Figure 2, trains a policy and a value NN to provide solutions to diverse boundaries. After that, they perform behavior cloning by extracting experience (also known as data-set) and training another NN. With a self-evolving procedure, the supervised-learning-based NN \textit{FreeMesh-S} can address new boundary challenges. \begin{figure} \centering \includegraphics[width=0.5\linewidth]{figures/citelct.pdf} \caption{A previously proposed method to supervise an FNN with experience extracted from itself and another DRL program.} \label{fig:citelct} \end{figure} \subsection{Our approach} According to Hornik(1991), standard multi-layer feed-forward networks with activation function may arbitrarily well approximate any continuous function if there are enough hidden units available. Therefore, once enough experience has been extracted from Reinforcement Learning (RL), we can construct an MLP or ResNet (Shan et~al.(2016)) architecture to solve new boundaries. To improve the quality of data-set in \textit{FreeMesh-S}, \textit{TreeMesh}, our semi-open-source program makes many improvements on \textit{FreeMesh-S}. We replace the A2C DRL algorithm with the more powerful DPPO algorithm and add a brute force MCTS to find nearly-optimal meshes. We use a new state tensor, an action tensor with a smaller range, and a sophisticated reward function to speed up convergence. On the whole, \textit{TreeMesh} aims to use DRL and MCTS to discover an optimal, or nearly-optimal, solution to some problematic boundaries in a large-scale boundary (e.g. sharp angles, bottleneck region, unevenly distributed segments, and holes) with a pre-trained model or from scratch. Further technical improvements in DRL and MCTS algorithms and solving procedures are described in Section 2, mesh results are exhibited in Section 3. We have released a single-threaded version on \href{https://github.com/gt2001/generate-2D-quadrilateral-mesh-with-neural-networks-and-tree-search}{GitHub}. \section{Methodology} \label{sec:Methodology} \subsection{Reinforcement learning in \textit{TreeMesh}} Our method continues to use the actor-critic framework, including a policy network $\pi(S_t, \theta)$ and a value network $V_\pi(S_t, w)$. Both NN use the same input tensor, which includes standardized node coordinates and mesh progression. The value network evaluates the mean return value, whereas the policy network outputs the coordinates for a new element. On one hand, we use the back propagation of the value loss function to assist it in providing increasingly precise evaluations after receiving trajectories. On the other hand, we calculate the time difference error and the probability of choosing each action to back propagate the policy loss function. We adopt linear layers and leaky ReLUs in the NN architecture. NN in \textit{FreeMesh-S} are trained with an actor-critic framework, which was introduced in Konda and Tsitsiklis(2000). We use a distributed version of proximal policy optimization (DPPO), an steady off-policy algorithm based on actor-critic. According to Schulman et~al.(2017), PPO has outperformed A2C, A2C+Trust Region, and CEM on seven MuJoCo environments, including HalfCheetah-v1, Hopper-v1, InvertedDoublePendulum-v1, InvertedPendulum-v1, Reacher-v1, Swimmer-v1, and Walker2d-v1. Each of $N$ parallel actors collects $T_i$ time steps of data in each episode. Then we calculate each trajectory, shuffle them, and back propagate mini-batches with Adam (Kingma and Ba(2014)), for $K$ epochs. In Figure 3, a workflow of Algorithm 1 is shown. Lines 3 to 9 are referred to as the sampling section \textbf{a}, while lines 11 to 20 are referred to as the training section \textbf{b}. \begin{algorithm} \caption{Distributed Proximal Policy Optimization with clipping} \label{alg:DPPO} \begin{algorithmic}[1] \For{episode $i = 1, 2, \cdots, M$} \For{agent $j = 1,2,\cdots, N$} \State Get an initial state $S_1^{ij}$ ($i$ and $j$ are omitted hereafter); \For{time step $t = 1, 2, \cdots, T$} \State Collect value network prediction $V_\pi(S_t, w)$ \State Sample action $A_t\sim\pi(\mid S_t, \theta)$; \State Get the raw reward $R_t^r$ and next state $S_{t+1}$; \State If done, break the loop; \EndFor \EndFor \State Optimize coordinates with Adaptive Laplacian Smoothing (Xi et~al.(2021)), and calculate optimized rewards $R_t^o$; \State Calculate the TD error $\delta_t=\sum\limits_{i=1}^{T-t-1}\lambda^i\left[R_t^o+V_\pi(S_{t+i+1},w)-V_\pi(S_{t+i},w)\right]$ \State Calculate cumulative rewards $U_t=\sum\limits_{i=1}^TR_t^o$ \For{mini-batch number $k = 1, 2, \cdots, K$} ($k$ omitted hereafter) \For{update epoch $l = 1, 2, \cdots, L$} \State Calculate policy loss $J_{\pi}=-\sum\limits_t\min\left\{\frac{\pi^{{\rm new}}_{l}(A_t\mid S_t,\theta)}{\pi^{{\rm old}}(A_t\mid S_t,\theta)}\delta_t,{\rm clip}\left[\frac{\pi^{{\rm new}}_l(A_t\mid S_t,\theta)}{\pi^{{\rm old}}(A_t\mid S_t,\theta)}, 1-\epsilon, 1+\epsilon\right]\delta_t\right\}$ \State Calculate value loss $J_V = \alpha\cdot{\rm smooth\_L1\_loss}\left[V_\pi(S_t, w),U_t\right]$ \State Back propagate $w, \theta$ with $J_{\pi}+J_V$ \EndFor \EndFor \EndFor \end{algorithmic} \end{algorithm} \begin{figure} \centering \includegraphics[width=0.5\linewidth]{figures/rl-fem-trainppo.pdf} \caption{PPO workflow. \textbf{a.} The program is given a state and is asked to perform an action and predict cumulative rewards. A move is sampled using a multivariate normal distribution, with the action prediction serves as the mean value, a decay variance for exploration, and the raw reward serving as a criterion for the move's legality. \textbf{b.} Adaptive Laplacian Smoothing (Xi et~al.(2021)) is used to optimize coordinates and recalculate each rewards. The loss functions are calculated using new rewards and the probability of sampling each moves to update parameters in NN.} \label{fig:trainppo} \end{figure} In compared to business software meshes and the mesh in Pan et~al.(2021), the parameters $w, \theta$ we acquire after DPPO are strong enough to give a state-of-the-art mesh. Many investigations have revealed, however, that higher-quality meshes have higher variance, because the goal of reinforcement learning is for the agent to learn an optimal, or nearly-optimal, policy that maximizes the \textbf{expected} total reward, as described in Russell and Norvig(2010), the policy may never find the ideal solution with a high variance. Thus, we combine NN with an MCTS to search for coordinates surrounding projected action, resulting in more dependable findings. \subsection{Monte-Carlo tree search in \textit{TreeMesh}} We use MCTS to perform a brute-force search to check if there are any better meshes. The prediction point will be the center of a $5 \times 5$ dot array with a unit side length of $0.1$. As shown in Figure 4 and Figure 5, the MCTS uses the policy network $\pi(\mid S_t, \theta)$ to guide its simulations. Each edge in the search tree holds a prior probability $\pi'(A_t\mid S_t)$ with the same mean value as $\pi(A_t\mid S_t, \theta)$. Each episode starts at the root and finds the child node that maximizes an upper confidence bound before it reaches a leaf node: \begin{equation} \begin{aligned} a_t&=\mathop{\arg\max}\limits_{A_t}\left[Q(S_t, A_t)+U(S_t, A_t)\right]\\ &=\mathop{\arg\max}\limits_{A_t}\left[U_0+c_{{\rm PUCT}}\pi'(A_t\mid S_t)\frac{\sqrt{N_t}}{1+N_{t+1}}\right] \end{aligned} \end{equation} $c_{{\rm PUCT}}$ is a hyper-parameter that determines the proportion of UCB to expected quality. $U_0$ is the cumulative reward from time step 0. If the leaf node has been visited, the algorithm will extend all possible moves and choose the first child node. Finally, the algorithm will run all the way to the finish, updating nodes along the way. The whole pseudo code is in Algorithm 2. \begin{algorithm} \caption{Monte-Carlo tree search} \label{alg:MCTS} \begin{algorithmic}[1] \Function{UCBSearch}{$s_0$} \State Create a root node $n_0$ with $N(n_0)=0, Q(n_0)=0, n$'s parent $\leftarrow$ NULL \While{Within computational budget and ($500\nmid$ Episode $i$ or confirm continue)} \State $n\leftarrow$\Call{Selection}{$n_0$} \State $n,Q=$\Call{RollOut}{$n$} \State \Call{Update}{$n, Q$} \EndWhile \State \textbf{return} $n_0$ \EndFunction \Function{Selection}{$n$} \While{$n$ is non-terminal ($N(n)\leq1$)} \State $n\leftarrow\mathop{\arg\max}\limits_{n'\in\ {\rm children\ of}\ n}\left[Q(S_t, A_t)+U(S_t, A_t)\right]$ \EndWhile \If{$N(n)=1$} \State \textbf{return} \Call{Expand}{$n$} \Else \State $N(n)=1$ \State \textbf{return} $n$ \EndIf \EndFunction \Function{Expand}{$n$} \State Add $n'\in$ children of $n$ to $n$'s children list \State \textbf{return} $n$'s 1st child \EndFunction \Function{RollOut}{$n$} \While{not done} \State $n\leftarrow{\rm uniform}(n{\rm 's\ child})$ \EndWhile \State \textbf{return} node $n$, quality $Q$ \EndFunction \Function{Update}{$n,Q$} \While{$n$ is not NULL} \State $N(n)=N(n)+1$ \State $Q(n)=\frac{Q(n)[N(n)-1]+Q}{N(n)}$ \State $n\leftarrow n$'s parent \EndWhile \EndFunction \end{algorithmic} \end{algorithm} \begin{figure} \centering \includegraphics[width=1\linewidth]{figures/rl-fem-mcts.pdf} \caption{MCTS workflow 1. \textbf{a.} Behavior cloning is a quick and easy technique to create effective policies given limited data. \textbf{b.} We train an actor-critic network with the DPPO algorithm and store the policy model, either from scratch or from a pre-trained model. \textbf{c.} In Selection, each simulation traverses the tree by selecting the edge with the highest sum of an expected quality $\overline{Q}$ plus an Upper Confidence Bound (UCB) $U$ based on a prior probability $P$ and visit count $N$ for that edge. In Expansion and Simulation, the leaf node is expanded and evaluated by the quality of one meshing to the end. In Back Propagation, quality $Q$ is utilized to update all evaluations $\overline{Q}$ in the sub-tree under the current episode. Once the search is complete, search times and expected qualities are returned, and the user can choose the next move.} \label{fig:MCTS} \end{figure} \begin{figure} \centering \includegraphics[width=0.5\linewidth]{figures/MCTSlct.pdf} \caption{MCTS workflow 2. Notice that the first "no" corresponds to step 1 in Figure 4, from the first "yes" to "roll out" is step 2, and "update" relates to step 3.} \label{fig:MCTS2} \end{figure} \subsection{State and action setting} As shown in Figure 6 (a), the state tensor has 18 dimensions, including: \begin{enumerate} \item $\left(\frac{x_{P0} - x_{\min}}{x_{\max} - x_{\min}}, \frac{y_{P0} - y_{\min}}{y_{\max} - y_{\min}}\right)$ \item $\left(\frac{x_{Pr1} - x_{\min}}{x_{\max} - x_{\min}}, \frac{y_{Pr1} - y_{\min}}{y_{\max} - y_{\min}}\right)$ \item $(x'_{Pr2}, y'_{Pr2})$ \item $(x'_{Pl1}, y'_{Pl1})$ \item $(x'_{Pl2}, y'_{Pl2})$ \item $(x'_{P\theta1}, y'_{P\theta1})$ \item $(x'_{P\theta2}, y'_{P\theta2})$ \item $(x'_{P\theta3}, y'_{P\theta3})$ \item $\frac{m}{N}$ \item $\frac{n}{N}$ \end{enumerate} As demonstrated in Figure 6 (b), from 1 to 6 are coordinates of $Pr2, Pl1, Pl2, P\theta1, P\theta2, P\theta3$, standardized by coordinates of $P0$ and $Pr1$ (by dragging $P0$ to $O$, and $Pr1$ to $(1, 0)$). The standardization procedure is as follows: \begin{equation} \begin{aligned} \begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix}&= \begin{bmatrix} \cos\theta & \sin\theta & 0 \\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{(x_{P0}-x_{r1})^2+(y_{P0}-y_{r1})^2}} & 0 & 0 \\ 0 & \frac{1}{\sqrt{(x_{P0}-x_{r1})^2+(y_{P0}-y_{r1})^2}} & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & -x_{P0} \\ 0 & 1 & -y_{P0} \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\\ &= E \begin{bmatrix} x \\ y \\ 1 \end{bmatrix} \end{aligned} \end{equation} There are a few notations that need to be clarified. From 1 to 6, $Pli$ and $Prj$ indicate the ith point on the left hand (clockwise) and the jth point on the right hand (anti-clockwise) of $P0$, respectively. These points are particularly relevant to the selection of point $P1$. All points on the current boundary except $P0, Pl1, Pr1$ are traversed to find $P\theta 1,2,3$. They are each in one of the three trisections of $\angle Pr1P0Pl1$ and are close enough to point $P0$. (a composite function is used to sort out the three points). To speed up convergence, the three points are clipped to a circle with a center $P0$ and a radius of $3$ (in the transformed coordinate system). 7 and 8 are coordinates of $P0$ and $Pr1$, re-scaled by coordinates of the top right and bottom left corner points on the original boundary. \begin{figure} \centering \subfloat[State setting] { \includegraphics[width=0.312\linewidth]{figures/zhuangtai.pdf} } \subfloat[Coordinate transformation] { \includegraphics[width=0.355\linewidth]{figures/zuobiaozhuanhuan.pdf} } \caption{A state tensor with 18 dimensions and a sketch showing the coordinate transformation. The tensor includes 12 standardized coordinates, 4 re-scaled coordinates, and 2 progress indicators to aid in the evaluation of the value network. 3 steps are required to standardize coordinates: drag $P0$ to $O$, rotate $P0Pr1$ to x-axis, and re-scale $Pr1$ to $(1, 0)$.} \label{fig:state} \end{figure} 9 and 10 indicates the progress of meshing. $m$ is the number of sides of the remaining polygon, $n$ is the number of meshed quadrilaterals, and $N$ is the maximum step permitted in meshing. The actor-critic network outputs a value and an action. The action is a 2-dimensional tensor of the next point $(x', y')$, and the value $V_\pi(S_t, w)=\mathbb{E}(U_t\mid S_t)$ is an expectation of cumulative rewards. Because the minimum angle for all boundaries is smaller than $\pi$, both coordinates are constrained in $[0, 1.5]$ with a hyperbolic tangent function, the new point is most likely in the first quadrant. An inverse matrix $E^{-1}$ will be used to transform the new point back to the previous coordinate system. \subsection{Reward setting} The reward function is a critical signal for the NN since it allows the NN to determine whether a movement is positive or harmful. We propose an improved reward function upon Pan et~al.(2021). This option delivers superior convergence performance, according to empirical analysis. Noticing that on Algorithm 1 line 7 and line 11, we calculate a raw reward $R_t^r$ and an optimized reward $R_t^o$. The raw reward, with a range $\{-5\}\cup [0, 1]$, is purely for judging a movement in Figure 7 (a), or give a punishment reward (e.g. in Figure 7 (a), the third move is illegal, the other two moves are legal): \begin{equation} R_t^r= \left\{ \begin{aligned} -5&, {\rm illegal} \\ \sqrt[4]{\prod\limits_{i=1}^4\left[\frac{l_i}{\sqrt{A_t}}^{{\rm sgn}\left(\sqrt{A_t}-l_i\right)}\right]\left(1-\frac{\mid a_j-\frac{\pi}{2}\mid}{\frac{\pi}{2}}\right)}&, {\rm legal} \end{aligned} \right. \label{eq:rawreward} \end{equation} \begin{figure} \centering \subfloat[Three possible moves] { \includegraphics[width=0.487\linewidth]{figures/3tiaoguize.pdf} } \subfloat[Variables considered in judgement] { \includegraphics[width=0.262\linewidth]{figures/reward.pdf} } \caption{At any given time step, there are three possible moves. All of the moves generate a new quadrilateral, with the exception of the first, which has no effect on the number of edges, and the other two, which reduce the number of edges by two. As a result, the starting boundary should have an even number of nodes. } \label{fig:reward} \end{figure} At time step t, the three raw rewards will be multiplied by their respective factor $\prod\limits_{i=1}^2\left[\frac{\min\left(\theta_k, \frac{\pi}{3}\right)}{\frac{\pi}{3}}\right]$, and the highest-valued move will be chosen. It's worth noticing that we can also allow the NN to decide which action to take, but this will make convergence more difficult. On line 11, we have collected a trajectory $R_0^r, R_1^r,\cdots, R_T^r$. Assume there are a total of $T_0$ potential steps (with the remaining $T-T_0$ rewards being -5). Then, using Adaptive Laplacian Smoothing (Xi et~al.(2021)), we optimize all internal coordinates and update every effective reward to $R_t^o=\frac{R_t^{r'}\eta}{T_0}$. $\eta$ is a hyper-parameter with a value of $500$ that controls the cumulative rewards in the $[100, 1000]$ range. The penalty for illegal rewards remains at $-5$. \section{Result} \label{sec:Result} \subsection{Some DPPO results} Here, we exhibit our work on two boundaries: a "$11\rightarrow5$" seed-density-changing rectangle, and a pentagonal plate that was studied in Pan et~al.(2021). Table 1 compares \textit{TreeMesh} (DPPO algorithm used only) with ABAQUS on a "$11\rightarrow5$" seed-density-changing boundary. Equation 3 is used to compute the mean quality of the optimized mesh. We outperform ABAQUS in terms of quality by $13.8573\%$. \begin{table} \caption{A "$11\rightarrow5$" seed-density-changing boundary with 4 MLP layers.} \centering \begin{tabular}{cccccc} \toprule Program & Raw Mesh & Optimized Mesh & Quality & Quantity & Time \\ \hline ABAQUS & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/abq-raw-sdc.pdf}} \end{minipage} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/abq-sdc.pdf}} \end{minipage} & $0.7036$ & $22$ & $\approx1s$ \\ \hline \textit{TreeMesh} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/sdcdpporaw.pdf}} \end{minipage} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/sdcdppo.pdf}} \end{minipage} & $0.8011$ & $34$ & $\approx10^3s$ \\ \bottomrule \end{tabular} \label{tab:sdcdppo} \end{table} Table 2 compares \textit{TreeMesh} (DPPO algorithm used only) with ABAQUS and \textit{FreeMesh-S} on a pentagonal boundary. We outperform ABAQUS in terms of quality by $5.3204\%$, and \textit{FreeMesh-S} by $1.4822\%$ in quality, and by around $90\%$ in time. \begin{table} \caption{A pentagonal boundary with 4 MLP layers.} \centering \begin{tabular}{cccccc} \toprule Program & Raw Mesh & Optimized Mesh & Quality & Quantity & Time \\ \hline ABAQUS & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/abq-raw-pp.pdf}} \end{minipage} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/abq-pp.pdf}} \end{minipage} & $0.8646$ & $64$ & $\approx1s$ \\ \hline \textit{FreeMesh-S} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/yz-raw-pp.pdf}} \end{minipage} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/yz-pp.pdf}} \end{minipage} & $0.8973$ & $63$ & $\approx10^4s$ \\ \hline \textit{TreeMesh} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/ppdpporaw.pdf}} \end{minipage} & \begin{minipage}{0.25\columnwidth} \centering \raisebox{0\height}{\includegraphics[width=\linewidth]{figures/ppdppo.pdf}} \end{minipage} & $0.9106$ & $57$ & $\approx10^3s$ \\ \bottomrule \end{tabular} \label{tab:ppdppo} \end{table} \subsection{A DPPO+MCTS time line} A more detailed experiment is conducted on the first boundary (Table 1), with a 3-residual-block architecture. In 1500s, we output the raw mesh created by the DPPO algorithm. Weight files at three time points are rendered to execute a brute force MCTS. At this boundary, a better mesh is discovered and shown in Figure 8's upper right corner. It has been appraised as a state-of-the-art mesh by some engineers. \begin{figure} \centering \includegraphics[width=1\linewidth]{figures/result1.pdf} \caption{Mesh methods with 3 residual blocks and the MCTS method in a "$11\rightarrow5$" seed-density-changing boundary. DPPO results are linked with grey lines, while MCTS results are linked with black lines.} \label{fig:result1} \end{figure} \subsection{Empirical Analysis of DPPO training reward in Table 1 and Table 2} We continued the training for approximately 4 hours. Figure 9 shows the smoothed training reward on both boundaries. The co-variance matrix of the multivariate normal distribution starts at $0.05I$ and decays at a constant rate of $0.999$ per $100$ episodes during the training. This slows convergence slightly but allows the policy NN to explore more policies. The policy NN will eventually stop at a nearly-optimal policy if the initial learning rate is properly set ($\sim10^{-6}$) and decays at the same rate. Here, however, we remain the learning rate constant ($10^{-6}$) to accelerate convergence. \begin{figure} \centering \subfloat[Seed-density-changing rectangle] { \includegraphics[width=0.32\linewidth]{figures/sdctrain.pdf} } \subfloat[Pentagonal plate] { \includegraphics[width=0.32\linewidth]{figures/pptrain.pdf} } \subfloat[Exploration decay] { \includegraphics[width=0.32\linewidth]{figures/decay.pdf} } \caption{Smoothed training reward on two boundaries after 150k episodes and 100k episodes respectively, and exploration decay. The improvement on training reward is a joint effect of both a better policy and a decaying exploration.} \label{fig:EA} \end{figure} \bibliographystyle{unsrtnat}
{'timestamp': '2021-11-30T02:10:10', 'yymm': '2111', 'arxiv_id': '2111.07613', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07613'}
arxiv
\section{Introduction}\label{sec:introduction}} \IEEEPARstart{A}{ttending} to the most task-relevant regions quickly and ignoring the irrelevant parts automatically are named \mtj{as} the attention mechanism, which is \mtj{one of} the inherent proper \mtj{ies} of the human visual syste ~\cite{saliency_attention, hayhoe2005eye, rensink2000dynamic, corbetta2002control}\mtj{.} \mtj{Attention mechanism can help humans} analyze and understand \mtj{a} complex scene \mtj{efficiently and effectively.} \mtj{This inspires researchers} to introduce \mtj{the attention} mechanism into computer vision system\gmh{s} to improve \gmh{their} performance. In \jpt{the} vision system, the attention mechanism can be treated as a dynamic selection process that is realized by adaptive weighting features according to the change of input. It \mtj{has made} great achievement in almost all visual tasks, \em{e.g.}, image classification~\cite{senet, woo2018cbam}, object detection~\cite{dai2017deformable, carion2020endtoend_detr}, semantic segmentation~\cite{YuanW18_ocnet, Fu_2019_danet}, face recognition~\cite{yang2017neural, Wang_2020_CVPR_face}, person re-identification~\cite{li2018harmonious, chen2019mixed}, action recognition~\cite{Wang_2018_nonlocal, rstan}, few-show learning~\cite{Peng_2018_few_shot, he2017single}, medical image processing~\cite{oktay2018attention, guan2018diagnose}, image generation~\cite{gregor2015draw, zhang2019sagan}, pose estimation~\cite{chu2017multicontext}, super resolution~\cite{sr_1, zhang2018image}, 3D vision~\cite{Xie_2018_acnn, Guo_2021_pct}, multi-modal task~\cite{su2020vlbert, xu2017attngan}, \em{etc}. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{./Images/attention_cls_graph.pdf} \caption{ Dividing the existing attention space according to the applied dimension. $\emptyset$ means that we have not found this kind of attention in the existing \mtj{literature. There are six different types of attention including four basic attention categories: channel attention, spatial attention, temporal attention and branch attention as well as two hybrid categories: channel \& spatial attention and spatial \& temporal attention. } \label{fig:attention_category} \end{figure} \begin{figure}[t] \centering \includegraphics[width=\linewidth]{./Images/attention_dims.pdf} \caption{ Explanation of Fig.~\ref{fig:attention_category}. $C$ is \mtj{the} channel dimension, $H$ and $W$ \mtj{are the} spatial dimension\mtj{s}, $T$ is \mtj{the} temporal dimension. This figure is inspired by ~\cite{wu2018group}. } \label{fig:attention_apply_dims} \end{figure} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{./Images/attention_timeline.pdf} \caption{ \gmh{A} brief summary of the development of attention in computer vision since RAM \cite{mnih2014recurrent}. The entire development process can be roughly divided into four parts. The first part is adopting recurrent neural network to construct attention represented by RAM \cite{mnih2014recurrent}. The second part is explicitly predicting important region\gmh{s} represented by \gmh{STN}~\cite{jaderberg2016spatial}. The third part is implicitly completing the attention process represented by \gmh{SENet}~\cite{senet}. The last part is the self-attention~\cite{Wang_2018_nonlocal, vaswani2017attention, dosovitskiy2020vit} related methods. } \label{fig:timeline} \vspace{-1ex} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{./Images/total_attention_summary.pdf} \caption{The developmental context of visual attention. This figure is inspired by~\cite{zhou2021graph}. } \label{fig:total_attention_summary} \vspace{-1ex} \end{figure*} In the past decade, \gmh{the} attention mechanism has been playing an increasingly important role in computer vision. As depicted in Fig.~\ref{fig:timeline}, we briefly summarize the vigorous history of attention-based models in computer vision in the deep learning era. The whole progress can be roughly divided into four parts. The first part begins from RAM~\cite{mnih2014recurrent}, which is the pioneer that combines deep neural network\gmh{s} with attention mechanism\gmh{s}. It recurrently predicts the important region and updates the whole network in an end-to-end manner through policy gradient. After that, some works~\cite{gregor2015draw, xu2015show} adopt \jpt{a} similar strategy to achieve attention in vision. At this part, RNNs become \gmh{necessary} tools to achieve attention mechanism. At the beginning of the second part, Jaderberg et al.~\cite{jaderberg2016spatial} propose STN which introduces a sub-network to predict the affine transformation and uses it to select important region\gmh{s} in the input. Explicitly predicting the \gmh{discriminative input feature} is the major characteristics of the second stage. DCNs~\cite{dai2017deformable,Zhu_2019_CVPR_dcnv2} are the representative works at this stage. SENet~\cite{senet} firstly presents a novel channel-attention network and can be seen as the beginning of the third stage which implicitly predicts the potential vital feature adaptively. CBAM~\cite{woo2018cbam} and ECANet~\cite{Wang_2020_ECA} are the representative works at this stage. The last stage is the self-attention era. Self-attention is firstly proposed in ~\cite{vaswani2017attention} and rapidly realizes great achievement in the field of natural language processing~\cite{vaswani2017attention,devlin2019bert, yang2020xlnet}. Wang et al.~\cite{Wang_2018_nonlocal} take the lead in introducing self-attention into computer vision and present a novel non-local network which achieves great success in video understanding and object detection. After that, a series of works appear to improve its performance, efficiency and generalization ability such as EMANet~\cite{li19ema}, CCNet~\cite{huang2020ccnet}, HamNet~\cite{ham} and Stand-Alone Network~\cite{ramachandran2019standalone}. The recent emergence of various pure deep self-attention networks (Visual Transformers)~\cite{dosovitskiy2020vit, yuan2021tokens, wang2021pyramid, liu2021swin, wu2021cvt, Guo_2021_pct, yuan2021volo, dai2021coatnet} show the huge potential of attention-based models. It reveals that the attention-based models possess the capability to replace convolutional neural networks and become a more powerful \mtj{and} general architecture in computer vision. \gmh{As shown in Fig.~\ref{fig:attention_category} and \mtj{explained in} Fig.~\ref{fig:attention_apply_dims}, } this \mtj{survey} summarizes and classifies the current attention methods in computer vision according to their applied dimensions. As illustrated in Fig.~\ref{fig:attention_category}, we divide the existing attention methods into six taxonomies which include four basic taxonomies: channel attention (``what to attend''~\cite{ChenZXNSLC17}), spatial attention (``where to attend''), temporal attention (``when to attend'') and branch channel (``which to attend''), along with two hybrid taxonomies: channel \& spatial attention and spatial \& temporal attention. The taxonomy standards and related works are summarized in Tab.~\ref{Tab_attentions_category}. \gmh{The main contributions of this paper are summarized as follow\mtj{s: \begin{itemize} \item We provide a systematic review of existing visual attention methods. It covers the development process of the visual attention \mtj{mechanism} and the latest related research, \mtj{making} it friendly for \mtj{beginners} to study and understand the attention mechanism. \item We adopt a well-suited taxonomy which groups different attention methods according to the applied dimension as displayed in Fig.~\ref{fig:attention_apply_dims}. Under this taxonomy, we can link various attention methods in different visual fields as a whole and propose that \mtj{the} attention mechanism can be viewed as an independent research topic, rather than a supplement to other tasks. \item Furthermore, we also \mtj{share} some insights about future potential directions, ho \mtj{ing to} inspire the related researchers and further promote the development of visual attention. \end{itemize} } The rest of the paper first discusses the related works in Sec.~\ref{sec:relatedWork}. We then meticulously review and summarize some representative works in each taxonomy in terms of its motivation, formulation and function in Sec.~\ref{sec:detailedReview}. Furthermore, we present perspectives about future directions in Sec.~\ref{sec:direction}. Finally, we give a conclusion of this paper in Sec.~\ref{sec:conclusion}. \begin{table}[!t] \centering \caption{Summary of common notations used in this paper. Some temporary notations will be explained below the specific formulation.} \label{Tab.notation_defination} \begin{tabular}{cc} \toprule \textbf{Symbol} & \textbf{Description} \\ \midrule $X$ & input feature \\ $Y$ & output feature \\ $W$ & learnable kernel weight \\ $\text{FC}$ & fully-connected layer \\ $\text{Conv}$ & convolution operation \\ $g_\text{avg}$ & global average pooling \\ $g_\text{max}$ & global max pooling \\ $[\quad]$ & concatenation operation \\ $\delta$ & ReLU~\cite{relu} activation function \\ $\sigma$ & sigmoid activation function \\ $\tanh$ & tanh activattion function \\ $\text{Softmax}$ & softmax activate function \\ $BN$ & batch normalization~\cite{ioffe2015batch} \\ $LN$ & layer normalization~\cite{ba2016layernorm} \\ $\text{Expand}$ & expand the input by repeating \\ \bottomrule \end{tabular} \end{table} \begin{table*} \centering \caption{Brief summary of the description of different attention categories and their related works.} \setlength{\tabcolsep}{1.5pt} \label{Tab_attentions_category} \begin{tabular}{lcc} \toprule \textbf{Attention category} & \textbf{Description for this category} & \textbf{Related work} \\ \midrule Channel attention & \makecell[l]{Generate attention \gmh{mask} along with the channel dimension and use it to \\ select important channels. } & \makecell[l]{~\cite{senet, zhang2018encnet, gsopnet, lee2019srm, yang2020gated ,Wang_2020_ECA, qin2021fcanet, diba2019spatiotemporal} \\ ~\cite{chen2019look,shi2020spsequencenet, zhang2018image}} \\ \midrule Spatial attention & \makecell[l]{Generate attention \gmh{mask} along with the spatial dimension and use it to \\ select important spatial regions such as ~\cite{Wang_2018_nonlocal, hu2019gatherexcite} or predict the most \\ relevant spatial position directly e.g.,~\cite{mnih2014recurrent, dai2017deformable}}. & \makecell[l]{~\cite{mnih2014recurrent, gregor2015draw, xu2015show, jaderberg2016spatial, Wang_2018_nonlocal, dosovitskiy2020vit, carion2020endtoend_detr, YuanW18_ocnet} \\~\cite{Xie_2018_acnn, yan2020pointasnl, hu2018relation, Zhang_2019_cfnet, zhang2019sagan, Bello_2019_ICCV_AANet, zhu2019empirical, Li_2020_sprr} \\ ~\cite{huang2020ccnet, ann, cao2019GCNet, chen2018a2nets, chen2018glore, zhang2019latentgnn, yuan2021segmentation_ocr, yin2020disentangled} \\ ~\cite{ham, external_attention, ramachandran2019standalone, hu2019lrnet, Zhao_2020_SAN, pmlr-v119-chen20s-igpt, carion2020endtoend_detr, dosovitskiy2020vit} \\ ~\cite{Guo_2021_pct, chen2021pretrained_ipt, zhao2020pointtransformer, yuan2021tokens, SETR, wang2021pyramid, han2021transformer_tnt, liu2021swin} \\ ~\cite{liu2021query2label, chen2021empirical_mocov3, bao2021beit, xie2021segformer, hu2019gatherexcite, Zhao_2018_psanet, ba2015multiple, sharma2016action} \\ ~\cite{girdhar2017attentional, li2016videolstm, yue2018compact,liu2019l2g,paigwar2019attentional,wen2020cf,yang2019modeling, wu2021cvt} \\~\cite{xu2018attention,liu2017end,zheng2018pedestrian, li2018tell,zhang2020relation,xia2019second,zhao2017diversified,zheng2017learning} \\~\cite{fu2017look,zheng2019looking,guan2018diagnose} }\\ \midrule Branch attention & \makecell[l]{Generate attention \gmh{mask} along with the different branches and use it to \\ select important branches.} & \makecell[l]{~\cite{srivastava2015training, li2019selective, zhang2020resnest, chen2020dynamic}} \\ \midrule Temporal attention & \makecell[l]{Generate attention \gmh{mask} along with the temporal dimension and use it to \\ select key frames.} & \makecell[l]{~\cite{xu2017jointly,zhang2019scan,chen2018video}} \\ \midrule Channel \& Spatial attention & \makecell[l]{Take both channel and spatial into consideration, predict channel and \\ spatial attention \gmh{mask} separately such as ~\cite{woo2018cbam, park2018bam} or generate a 3-D \\ (channel, height, weight) attention \gmh{mask} directly e.g.,~\cite{pmlr-v139-simam, wang2017residual} and use \\ it to select important features.} & \makecell[l]{~\cite{woo2018cbam, park2018bam, wang2017residual, Liu_2020_scnet, misra2021rotate, ChenZXNSLC17, LinsleySES19} \\ ~\cite{roy2018recalibrating, Fu_2019_danet, hou2020strip, zhang2020relation, pmlr-v139-simam,you2018pvnet,xie2020mlcvnet}\\~\cite{wang2018mancs,chen2019mixed,chen2019abd, hou2021coordinate, li2018harmonious}} \\ \midrule Spatial \& Temporal attention & \makecell[l]{Take both spatial and temporal into consideration, compute temporal \\ attention mask and spatial attention mask separately such as\cite{song2016end,rstan}, or \\ produce spatial and temporal attention mask like \cite{Fu_2019_STA}, and then focus \\ on informative regions} & \makecell[l]{~\cite{gao2019hierarchical,STAT, song2016end, meng2019interpretable, he2021gta,li2018diversity},\\ ~\cite{zhang2020multi,shim2020read, liu2021decoupled}} \\ \bottomrule \end{tabular} \end{table*} \section{Related survey} \label{sec:relatedWork} There are some related surveys have reviewed attention methods and visual transformers. In this section, we will briefly discuss the differences between this paper and existing surveys. Chaudhari et al.~\cite{chaudhari2021attentive} provide a survey about attention models in deep neural networks \mtj{concentrating on the field of} natural language processing, while our work focuses on computer vision. ~\cite{han2021survey, khan2021transformers} summarize the development of visual transformers while our paper reviews attention mechanism in vision \gmh{which covers various attention methods rather than only including self-attention. } Wang et al.~\cite{wang2016survey} present a survey of attention models in computer vision. However, it only \mtj{studies the} RNN-based attention models, \gmh \mtj{which} are \mtj{only} a part of our survey.} Besides, different from all \gmh{the} above \mtj{surveys}, we adopt a well-suited taxonomy which groups various attention methods according to the dimension \mtj{they operating on} instead of different applications. \gmh{Under this taxonomy, we can regard various attention methods as a whole rather than a supplement to other tasks. } \section{Review of attention methods in vision} \label{sec:detailedReview} In this section, we will review various attention models according to our proposed taxonomy as shown in Fig.~\ref{fig:attention_category}. \gmh{In each subsection, we will first summarize the representative works of \mtj{a specific} category in a table. Then we will \mtj{dive deeper into} this category of attention strategy along the developing process } in terms of motivation, formulation and function. \subsection{Channel Attention} In deep neural networks, different channels in different feature maps usually represent different objects~\cite{ChenZXNSLC17}. Channel attention which recalibrates the weight of different channels adaptively can be viewed as an object selection process, \mtj{i.e.,} ``what to attend''. \gmh{Hu et al.~\cite{senet} first propose the concept of channel attention and present SENet to achieve channel attention. As shown in Fig.~\ref{fig:total_attention_summary}, three streams \mtj{of work} continue to improving channel attention \mtj{from different aspects.} } In this subsection, we first summarize the representative channel attentions in Tab.~\ref{Tab_channel_attentions} and Fig.~\ref{fig:channel_attention}. Then we discuss various channel attentions along with the developing process respectively. \subsubsection{SENet} \gmh{SENet~\cite{senet} is the pioneer in the realm of channel attention. The core part of SENet is the squeeze-and-excitation (SE) block which is used to collect global information, capture the channel-wise relationships and improve representation ability. } SE blocks can be divided \gmh{into} two parts\mtj{, i.e.,} \gmh{the} squeeze module and \gmh{the} excitation module. The global spatial information is \gmh{collected} in the squeeze module via global average pooling. In the excitation module, it captures channel-wise relationships and output\gmh{s} an attention vector by using fully-connected layers and non-linear layers (ReLU~\cite{relu} and sigmoid). Then, each channel of the input feature is scaled by multiplying the corresponding element in the attention vector. Totally, the squeeze-and-excitation block \mtj{$F_\text{se}$ (with parameter $\theta$) takes $x$ as input and outputs $Y$} as \mtj{follows: \begin{align} \label{eq_se} s = F_\text{se}(X, \theta) & = \sigma (W_{2} \delta (W_{1}g_\text{avg}(X))) \\ Y & = s \cdot X \end{align} \gmh{The explanation of used symbols in above formulation can be found in Tab.~\ref{Tab.notation_defination}}. SE blocks play \gmh{the} role of emphasizing important channels while suppressing noise. An SE block can be added after each residual unit~\cite{resnet} due to its time complexity and space complexity friendly property. \gmh \mtj{However}, SE block also has some shortcomings. In \gmh{the} squeeze module, global average pooling is too simple to capture complex global information. In \gmh{the} excitation module, fully-connected layers increase the complexity of the model. As shown in Fig.~\ref{fig:total_attention_summary}, \gmh{some} following\mtj{-up} works attempt to achieve better performance \mtj{by improving the squeeze module} such as GSoP-Net~\cite{gsopnet}, reduce the complexity of the model \mtj{by improving the excitation module} such as ECANet~\cite{Wang_2020_ECA}, and improve both the squeeze module and the excitation module such as SRM~\cite{lee2019srm}. } \subsubsection{GSoP-Net} SE block capture\mtj{s the} global information \mtj{by only using the global average pooling (first-order statistics),} \gmh{which will limit the statistical modeling capability and lose some necessary high-order statistics } To address the above issues, Gao et al.~\cite{gsopnet} propose Global Second-order Pooling(GSoP) block to \gmh{improve the squeeze module by modeling} high-order statistics for gathering \gmh{more} global information. Following SE block, GSoP block also adopts a squeeze module and an excitation module. In the squeeze module, GSoP block firstly reduces the channel dimension from $c$ to $c'$ ($c'$ < $c$) by an 1x1 convolution. Then it computes a $c' \times c'$ covariance matrix of different channels to obtain the channels correlation. After that, a row-wise normalization is performed on the covariance matrix. Each $(i, j)$ in the normalized covariance matrix \gmh{has explicit content which} stands for the relation between channel $i$ and channel $j$. In the excitation module, GSoP block performs a row-wise convolution to maintain the structural information and output a vector. Then a fully-connected layer and a sigmoid function are applied to get a $c$\mtj{-}dimension\mtj{al} attention vector. Finally, it multiplies input feature\gmh{s} by attention vector like SE block. The GSoP block can be written as Eq.~\ref{eq_gsop}. \begin{align} \label{eq_gsop} s = F_\text{gsop}(X, \theta) & = \sigma (W \text{RC}(\text{Cov}(\text{Conv}(X)))) \\ Y & = s \cdot X \end{align} Here, $\text{Conv}(\cdot)$ is introduced to reduce the channel dimension. $\text{Cov}(\cdot)$ means calculating the covariance martix. $\text{RC}(\cdot)$ means row-wise convolution. By using second-order pooling, the GSoP block improves the capability of \gmh{collecting global information \mtj{over} \gmh{the} SE block. \mtj{However, such an improvement in} the modeling ability is \mtj{achieved at the cost of higher-order computation.} } So, GSoP block is added at the end of several residual blocks. \subsubsection{SRM} Motivated by the success of style transfer task, Lee et al.~\cite{lee2019srm} propose lightweight Style-based Recalibration Module (SRM). SRM combines style transfer and attention mechanism. Its main contribution is the proposed style pooling which utilizes both mean and standard deviation of the input features \gmh{ to improve the capability of capturing global information. Besides, it adopts a lightweight channel-wise fully-connected(CFC) layer, \mtj{substituting the original} fully-connected layer, to reduce \mtj{the} computational overhead. } Given an input feature map $X \in \mathbb{R}^{C \times H \times W}$, SRM first collects global information by using style pooling \mtj{(a.k.a. $\text{SP}(\cdot)$)} which includes two parts global average pooling and global standard deviation pooling. Then a channel-wise fully connected \mtj{(a.k.a. $\text{CFC}(\cdot)$)} layer \mtj{(i.e., performing the fully connected layer channel by channel)}, batch normalization $BN$ and sigmoid function $\sigma$ are adopted continuously to get the attention vector. Finally, it multiplies input features by attention vector like SE block. Totally, the SRM can be written as Eq.~\ref{eq_srm}. \begin{align} \label{eq_srm} s = F_\text{srm}(X, \theta) & = \sigma (BN(\text{CFC}(\text{SP}(X)))) \\ Y & = s \cdot X \end{align} The SRM block \gmh{ improves both squeeze and excitation module\gmh{s} and can be added after each residual unit like SE block. } \subsubsection{GCT} Due to the computation and parameters of fully connected layer \gmh{in the excitation module}, Besides, modeling channel relationships by using fully connected layer\gmh{s} is an implicit procedure. To solve \gmh{the} above problems, Yang et al.~\cite{yang2020gated} propose Gated Channel Transformation(GCT) for efficient collecting information and explicit modeling \gmh{channel-wise} relationships. Different from previous methods, GCT first collects global information by computing $l_{2}$-norm of each channel. After computing $l_{2} $-norm, a learnable vector $\alpha$ is applied to scale feature. Then competition \gmh{mechanism} is adopted by channel normalization to interact between channels. Like other common normalization methods, learnable scale parameter $\gamma$ and bias $\beta$ are applied to rescale the normalization. Different from previous methods, GCT adopts tanh activation function to control the attention vector. Finally, it not only multiplies input feature by attention vector but \mtj{also} adds an identity connection. GCT can be written as Eq.~\ref{eq_gct} \begin{align} \label{eq_gct} s = F_\text{gct}(X, \theta) & = \tanh (\gamma CN(\alpha \text{Norm}(X)) + \beta) \\ Y & = s \cdot X + X, \end{align} where $\alpha$, $\beta$ and $\gamma$ are trainable parameters. $\text{Norm}(\cdot)$ means computing the $l2$-norm of each channel. $CN$ is the channel normalization. The GCT block also reduces the parameters of SE block. Due to the characteristic of lightweight, it can be added at the end of all convolutional layers of a CNN. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{./Images/ChannelAttentions.pdf} \caption{ Exhibition of several channel attentions. GAP=global average pooling, GMP=global max pooling, FC=fully-connected layer, Cov pool=Covariance pooling, RW Conv=row-wise convolution, CFC=channel-wise fully connected, CN=channel normalization, DCT=discrete cosine transform. } \label{fig:channel_attention} \vspace{-1ex} \end{figure*} \begin{table*} \centering \caption{Summary of Representative Channel Attentions sorted by publication time. Publication=First publication, Cls = Classification, Det=Detection, SSeg=Semantic Segmentation, ISeg=Instance Segmentation, ST=Style Transfer, Action=Action Recognition.} \setlength{\tabcolsep}{1.5pt} \label{Tab_channel_attentions} \begin{tabular}{lcccc} \toprule \textbf{Method} & \textbf{Publication} & \textbf{Experiments} & \textbf{Description of the attention process} & \textbf{Function of attention process} \\ \midrule SENet~\cite{senet} & CVPR2018 & Cls, Det &\makecell[l]{a) use global average pooling to get a global descriptor \\ b) adopt MLP and sigmoid to obtain attention vector \\ c) multiply input feature and attention vector to get the output.} & \makecell[l]{a) emphasize important channels \\ b) capture global information} \\ \midrule EncNet~\cite{zhang2018encnet} & CVPR2018 & SSeg &\makecell[l]{a) use a encoder module to get a global descriptor \\ b) adopt linear layer and sigmoid to obtain attention vector \\ c) same as c) process in SENet.} & same as SENet \\ \midrule GSoP-Net~\cite{gsopnet} & CVPR2019 & Cls &\makecell[l]{a) use 2nd-order pooling to get a global descriptor \\ b) adopt convolution, MLP and sigmoid to obtain attention vector \\ c) same as c) process in SENet.} & same as SENet \\ \midrule SRM~\cite{lee2019srm} & arXiv2019 & Cls, ST &\makecell[l]{a) use style pooling to get a global descriptor \\ b) adopt convolution and MLP to obtain attention vector \\ c) same as c) process in SENet.} & same as SENet \\ \midrule GCT~\cite{yang2020gated} & CVPR2020 & Cls, Det, Action &\makecell[l]{a) compute $l2$-norm to get a global descriptor \\ b) adopt channel normalization and tanh to obtain attention vector \\ c) multiply input with attention vector and add input feature.} & same as SENet \\ \midrule ECANet~\cite{Wang_2020_ECA} & CVPR2020 & Cls, Det, ISeg &\makecell[l]{a) use global average pooling to get a global descriptor \\ b) adopt conv1d and sigmoid to obtain attention vector \\ c) same as c) process in SENet.} & same as SENet \\ \midrule FcaNet~\cite{qin2021fcanet} & ICCV2021 & Cls, Det, ISeg &\makecell[l]{a) use discrete cosine transform to get a global descriptor \\ b) same as b) and c) process in SENet .} & same as SENet \\ \bottomrule \end{tabular} \end{table*} \subsubsection{ECANet} To avoid high model complexity, SENet adopts channel dimensionality reduction strategy. \gmh{However, this strategy} \xtx{fails to model direct correspondence between weight vectors and inputs} \gmh{and leads to performance decline. To \mtj{overcome} \gmh{the} above \mtj{drawbacks}, Wang et al.\cite{Wang_2020_ECA} propose \mtj{the} Efficient Channel Attention(ECA) block which use\gmh{s} a 1D convolution to complete the interaction between channels\mtj{, instead of adopting the dimensionality reduction}. } ECA block has \gmh{similar} formulation as SE block including a squeeze module for aggregating global spatial information and an efficient excitation module for modeling cross-channel interaction. Instead of indirect correspondence, ECA block only considers direct interaction between each channel and its k \tjc{nearest} neighbors to control model complexity. Totally, the formulation of ECA block is shown as follows: \begin{align} \label{eq_eca} s = F_\text{eca}(X, \theta) & = \sigma (\text{Conv1D}(g_\text{avg}(X))) \\ Y & = s \cdot X \end{align} $\text{Conv1D}(\cdot)$ denotes 1D convolution with a kernel of shape $k$ along the channel dimension to model local cross-channel interaction. The parameter $k$ decides the coverage of interaction, and ECA proposes that kernel size $k$ can be adaptively determined by channel dimension $C$ instead of manual tuning via cross-validation \begin{equation} k = \psi(C) = \left | \frac{\log_2(C)}{\gamma}+\frac{b}{\gamma}\right |_\text{odd} \end{equation} Here, $\gamma$ and $b$ are hyperparameters. $|x|_\text{odd}$ indicates the nearest odd function of $x$. \gmh{ \mtj{Compared to SENet,} ECANet improves the excitation module and proposes an efficient and effective block. As a lightweight plug-and-play block, it can \mtj{be} incorporate\mtj{d into} various CNNs. } \subsubsection{FcaNet} \gmh{Only using global average pooling in \gmh{the} squeeze module limits the representation ability.} To obtain powerful representation ability, Qin et al.~\cite{qin2021fcanet} \mtj{rethink the} global information \mtj{capture} from \mtj{the viewpoint of} compression and analyse global average pooling in the frequency domain. They prove that global average pooling is a special case of discrete cosine transform (DCT) and \mtj{thus} propose a novel Multi-Spectral Channel Attention. Given an input feature map $x \in \mathbb{R}^{C \times H \times W}$, Multi-Spectral channel attention first splits $x$ into many parts $x^{i} \in \mathbb{R}^{C' \times H \times W}$. Then it applies 2D DCT on each part $x^{i}$. It is worth noting that 2D DCT results can use the pre-processing results to save computation. After processing each part, they concatenate all parts and get the described vector. Finally, fully connected layers, ReLU activation function and sigmoid function are adopted to get the attention vector same as SE block. It can be described as Eq.~\ref{eq_fca}. \begin{align} \label{eq_fca} s = F_\text{fca}(X, \theta) & = \sigma (W_{2} \delta (W_{1}[(\text{Dct}(\text{Group}(X)))])) \\ Y & = s \cdot X \end{align} Here, $\text{Group}(\cdot)$ means dividing input into many group\gmh{s}, $\text{Dct}(\cdot)$ means the 2D discrete cosine transform This work views the SE module from the perspective of information compression and presents a more powerful method by discrete cosine transform. It achieves great performance on \gmh{the} classification task. \subsubsection{EncNet} Inspired by SENet, Zhang et al.\cite{zhang2018encnet} propose the Context Encoding Module(CEM) incorporating Semantic Encoding Loss(SE-loss) to model the relation between scene context and the probabilities of categories and utilize the global scene context information for semantic segmentation Given an input feature map $X\in \mathbb R^{C\times H\times W}$, CEM first learns $K$ cluster centers $D=\{d_1,...d_K\}$ and a set of smoothing factor $S=\{s_1,...s_K\}$ in the training phase. Then, CEM sums the difference between the local descriptors from the input and the corresponding cluster centers with soft-assignment weights to obtain a permutation-invariant descriptor. Then, it \gmh{applies} aggregation to the descriptors of $K$ cluster centers instead of concatenation for computational efficiency. Formally, CEM can be written as follow \begin{align} e_k &= \sum_{i=1}^N \frac{e^{-s_k||X_i-d_k||^2}}{\sum_{j=1}^Ke^{-s_j||X_i-d_j||^2}}(X_i-d_k) \\ e &= \sum_{k=1}^K\phi(e_k) \\ s &= \sigma(W e) \\ Y &= s\cdot X \end{align} Here $d_k \in \mathbb{R}^C$ and $s_k \in \mathbb{R}$ are learnable parameters. $\phi$ denotes Batch Normalization with ReLU activation. In addition to channel-wise scaling vectors, the compact contextual descriptor $e$ is also applied to compute SE-loss to regularize the training, which improves the segmentation of small objects. Not only does CEM enhance the class-dependent feature maps, it forces the network to consider big and small objects equally by incorporating SE-loss. Due to its lightweight architecture, CEM can be applied on various backbones with \gmh{a} small computational overhead. \subsubsection{Bilinear Attention} \gmh{ Similar to GSoP-Net~\cite{gsopnet}, } Fang et al.\cite{fang2019bilinear} claim that previous attention models only use first\gmh{-}order information and disregard higher\gmh{-}order statistical information. Thus they propose a new Bilinear Attention block(Bi-attention) to capture the local pairwise feature interactions along each channel, while preserving the spatial information. Bi-attention employs the Attention in Attention(AiA) mechanism to capture the second\gmh{-}order statistical information. To be more specific, the outer point-wise channel attention vectors are computed by the output of the inner channel attention. Formally, given the input feature map $X\in \mathbb{R}^{C\times H\times W}$, bi-attention first adopts the bilinear pooling to capture second\gmh{-}order information \begin{align} \widetilde{x} = \text{Bi}(\phi(X)) = \text{Vec}(\text{UTri}(\phi(X)\cdot \phi(X)^T)) \end{align} where $\phi$ denotes an embedding function used for dimensionally reduction, $\phi(x)^T$ is the transpose of $\phi(x)$ along \gmh{with} the channel dimension, $\text{Utri}(\cdot)$ is the operator that extracts the upper triangular elements of a matrix and $\text{Vec}(\cdot)$ is vectorization. Then bi-attention employs the inner channel attention mechanism on the feature map $\widetilde{x}\in\mathbb{R}^{\frac{c'(c'+1)}{2}\times H\times W}$ \begin{align} \widehat{x} &= \omega(g_\text{avg}(\widetilde{x})) \cdot \varphi(\widetilde{x}) \end{align} Here $\omega$ and $\varphi$ are embedding functions. Finally the output feature map $\widehat{x}$ is used to compute the spatial channel attention weights of the outer point-wise attention mechanism: \begin{align} s &= \sigma(\widehat{x})\\ Y &= s\cdot X \end{align} Using the bilinear pooling, bi-attention models the local pairwise feature interactions along each channel. With the proposed AiA, the model can pay more attention \gmh{to} higher statistical information. Bi-attention can \mtj{be} incorporate\mtj{d into} any CNN backbones to improve the representation power while suppressing noises. \subsection{Spatial Attention} Spatial attention can be seen as an adaptively spatial regions selection mechanism\mtj{, i.e.,} ``where to attend''. \gmh{As displayed in Fig.~\ref{fig:total_attention_summary}, RAM~\cite{mnih2014recurrent}, STN~\cite{jaderberg2016spatial}, GENet~\cite{hu2019gatherexcite} and Non-Local~\cite{Wang_2018_nonlocal} are representative methods of different spatial attention. RAM represents the RNN-based methods. STN represents \mtj{those which use} a sub-network \mtj{to} explicitly predict relevant regions\gmh{s}. GENet represents \mtj{those which use} a sub-network implicitly \mtj{to} predict a soft mask to select \gmh{the} important regions\gmh{s}. Non-Local represents self-attention related methods. In this subsection, we first summarize representative spatial attentions in Tab.~\ref{Tab_spatial_attentions}. } Then we discuss various spatial attentions according to Fig.~\ref{fig:total_attention_summary}. \begin{table*} \centering \caption{Summary of Representative Spatial Attentions sorted by publication time. Publication=First publication, Cls = Classification, FGCls=Fine-Grain Classification, Det=Detection, SSeg=Semantic Segmentation, ISeg=Instance Segmentation, ST=Style Transfer, Action=Action Recognition, ICap=Image Caption.} \setlength{\tabcolsep}{1.5pt} \label{Tab_spatial_attentions} \begin{tabular}{lcccc} \toprule \textbf{Method} & \textbf{Publication} & \textbf{Experiments} & \textbf{Description of the attention process} & \textbf{Function of attention process} \\ \midrule RAM~\cite{mnih2014recurrent} & NIPS2014 & Cls &\makecell[l]{a)use RNN to recurrently predict the important regions \\ b)adopt reinforcement learning to update network.} & \makecell[l]{a) make the network focus on the \\ discriminative regions. \\ b) avoid high complexity when \\ the input image is large.} \\ \midrule Hard attention~\cite{xu2015show} & ICML2015 & ICap &\makecell[l]{a) compute the similarity between visual features and \\ previous hidden state \\ b) interpret the weight as the probability or as the \\ relative importance \\ c) the training process follows the reinforce learning \\ rule} & \makecell[l]{a) make the network focus on the \\ discriminative regions. \\ b) gain interpret the results of this \\ framework } \\ \midrule STN~\cite{jaderberg2016spatial} & NIPS2015 & Cls, FGCls &\makecell[l]{a) use sub-network to predict an affine transformation \\ b) select relevant features according to the prediction.} & \makecell[l]{a) make the network focus on the \\ discriminative regionss. \\ b) let the network obtain affine \\ transformation invariance.} \\ \midrule Non-Local~\cite{Wang_2018_nonlocal} & CVPR2018 & Action, Det, ISeg &\makecell[l]{a) produce attention map by query vector multiply \\ key vector and softmax normalization \\ b) modulate value vector via attention map.} & \makecell[l]{a) capture long-range dependency \\ b) denoise input feature map} \\ \midrule SASA~\cite{ramachandran2019standalone} & NeurIPS2019 & Cls \& Det &\makecell[l]{a) adopt self-attention with positional embedding \\ to produce a attention map in a local regionss \\ b) aggregate neighborhood information through \\ attention map.} & \makecell[l]{adaptively aggregate neighborhood \\ information} \\ \midrule ViT~\cite{dosovitskiy2020vit} & ICLR2021 & Cls &\makecell[l]{a) divide the feature map into multiple groups \\ along the channel dimension. \\ b) use self-attention in each group respectively.} & \makecell[l]{a) capture long-range dependency \\ b) reduce inductive bias } \\ \midrule GENet~\cite{hu2019gatherexcite} & NIPS2018 & Cls, Det &\makecell[l]{a) gather spatial information by average pooling \\ or depth-wise convolution \\ b) obtain attention map via interpolation and \\ sigmoid function \\ c) multiply the input and attention map to get \\ the output.} & \makecell[l]{adaptively select important \\ spatial features.} \\ \midrule PSANet~\cite{Zhao_2018_psanet} & ECCV2018 & SSeg &\makecell[l]{a) predict a attention map by a sub-network \\ b) collecting global cues by the attention map.} & \makecell[l]{adaptively aggregate global \\ information.} \\ \bottomrule \end{tabular} \end{table*} \subsubsection{RAM} Convolutional neural networks introduce huge computational overhead especially when the input size is large. In order to concentrate limited computing resources on important regions, Mnih et al.~\cite{mnih2014recurrent} propose Recurrent Attention Model (RAM) that adopts recurrent neural network(RNN)~\cite{HochSchm97_lstm} and reinforcement learning(RL)~\cite{sutton2000policy} to make the network learn to where to attend. \gmh{RAM is the pioneer which adopts RNN to \mtj{accomplish the learning of} visual attention. After that, \mtj{more and more} RNN-based methods~\cite{gregor2015draw, xu2015show, ba2015multiple} \mtj{arise}. } As shown in Fig.~\ref{fig:ram}, the RAM has three parts: A) Glimpse Sensor, B) Glimpse Network C) RNN model. The glimpse sensor takes a coordinate $l_{t-1}$ and an image $X_{t}$. It outputs multiple resolution patches $\rho(X_{t}, l_{t-1})$ centered on $l_{t-1}$. The glimpse network $f_{g}(\theta(g))$ includes glimpse sensor and outputs the feature representation $g_{t}$ of input coordinate $l_{t-1}$ and image $X_{t}$. The RNN model considers $g_{t}$ and an internal state $h_{t-1}$ and outputs the next center coordinate $l_{t}$ and the action $a_{t}$ where is the softmax result in image classification task. Since the whole process is not differentiable, it applies RL strategies to complete the update process. This \mtj{work} uses a simple but effective method to make the network focus on key regions, reduces the amount of network calculations \gmh{especially when the input size is large, } and improves the performance of image classification. \subsubsection{Glimpse Network} Inspired by how humans perform visual recognition by sequence, Ba et al.\cite{ba2015multiple} propose a deep recurrent network\mtj{, like RAM~\cite{mnih2014recurrent},} capable of processing a multi-resolution crop of the input image, called a glimpse, for multiple object recognition task. The proposed network updates its hidden state using a glimpse as input, and then predicts a new object as well as the next glimpse location at each step. The glimpse is usually much smaller than the whole image, which makes the network computational efficient. The proposed deep recurrent visual attention model consists of glimpse network, recurrent network, emission network, context network and classification network. First, the context network takes the down-sampled whole image as input to provide the initial state for the recurrent network as well as the location of the first glimpse. Then, supposing the current time step $n$, given the current glimpse $x_n$ and its location tuple $l_n$, the goal of \gmh{the} glimpse network is to extract useful information, expressed as \begin{align} g_n = f_\text{image}(X) \cdot f_\text{loc}(l_n) \end{align} where $f_\text{image}(x)$ and $f_\text{loc}(l_n)$ denote non-linear functions and both of them output vectors with same dimension. $\cdot$ denotes the element-wise product, used for fusing information from two branches. Then, the recurrent network, which consists of two stacking recurrent layers, aggregates information gathered from each individual glimpse. The outputs of the recurrent layers are defined as \begin{align} r_n^{(1)} &= f_\text{rec}^{(1)}(g_n, r_{n-1}^{(1)}) \\ r_n^{(2)} &= f_\text{rec}^{(2)}(r_n^{(1)}, r_{n-1}^{(2)}) \end{align} Given the current hidden state $r_n^{(2)}$ of recurrent network, the emission network \gmh{predicts} where to crop the next glimpse. Formally, it can be written as \begin{align} l_{n+1} = f_\text{emis}(r_n^{(2)}) \end{align} Finally, the classification network outputs a prediction for the class label $y$ based on the hidden state $r_{n}^{(1)}$ of recurrent network \begin{align} y = f_\text{cls}(r_n^{(1)}) \end{align} Compared with a CNN operating on the entire image, the computational cost of \gmh{the} proposed model is much lower, and the proposed model can naturally tackle images of different size because it only processes a glimpse at each step. The robustness is additionally improved by the recurrent attention mechanism, which also alleviates the problem of over-fitting. This pipeline can incorporate with any state-of-the-art CNN backbones or RNN units. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{./Images/RAM_Image.png} \caption{Diagram of attention process of RAM~\cite{mnih2014recurrent}. It can be divided into three parts. (A) is the glimpse sensor which takes image and center coordinates as input and outputs multiple resolution patches. (B) is the glimpse network which include\gmh{s} glimpse sensor. It takes image and center coordinates as input and outputs a feature vector. (C) is the entire network which recurrently uses glimpse network and output\gmh{s} the predicted result as well as the next center coordinates. Figure is taken from ~\cite{mnih2014recurrent}. } \label{fig:ram} \vspace{-1ex} \end{figure*} \subsubsection{Hard attention} To visualize where and what the image caption generation model focus on, Xu et al.\cite{xu2015show} introduces an attention-based model as well as two variants of attention mechanism, named hard attention and soft attention. Given a set of feature vectors $\bm{a} = \{a_1,...a_L\}, a_i\in \mathbb{R}^D$ extracted from the input image, the model aims to produce a caption by generating one word at every time step. Thus they adopt a long short-term memory(LSTM) network as a decoder and attention mechanism is used to \gmh{generate} a contextual vector $z_t$ conditioned on the feature set $\bm{a}$ and the previous hidden state $h_{t-1}$, where $t$ denotes the time step. Formally, the weight $\alpha_{t,i}$ of $i$-th feature vector $a_i$ at the $t$-th time step is defined as \begin{align} e_{t,i} &= f_\text{att} (a_i, h_{t-1})\\ \alpha_{t,i} &= \frac{e^{e_{t,i}}}{\sum_{l=1}^L e^{t,i}} \end{align} Here $f_\text{att}$ is implemented by a multilayer perceptron conditioned on the previous hidden state $h_{t-1}$. The positive weight $\alpha_{t,i}$ can be interpreted either as the probability that location $i$ is the right place to focus on,named hard attention, or as the relative importance between location $i$ and the next word, named soft attention. To obtain the contextual vector $z_t$, hard attention mechanism assigns a multinoulli distribution parametrized by $\{\alpha_{t,i}\}$ and view $z_t$ as a random variable \begin{align} p(s_{t,i} &= 1|\bm{a}, h_{t-1}) = \alpha_{t,i} \\ z_t &= \sum_{i=1}^L s_{t,i}a_i \end{align} On the other hand, soft attention mechanism takes the expectation of the context vector $z_t$ directly \begin{align} z_t &= \sum_{i=1}^L \alpha_{t,i}a_i \end{align} The use of attention mechanism improves the interpretability of \gmh{the} image caption generation process by allowing us to visualize what and where the model focuses on. It also helps to improve the representational capability of network. \subsubsection{Attention Gate} Previous approaches on MR segmentation usually operate on particular regions of interest(ROI) ,which requires excessive and wasteful use of computational resources and model parameters. To \gmh{address} this issue, Oktay et al. \cite{oktay2018attention} propose a simple and yet effective mechanism, named Attention Gate(AG), to focus on targeted regions while suppress\gmh{ing} feature activations in irrelevant regions. Given the input feature map $X\in \mathbb{R}^{C\times H\times W}$ and the gating signal $G\in \mathbb{R}^{C'\times H\times W}$ which is collected from a coarse scale and contains contextual information, AG uses additive attention to obtain the gating coefficient. Both the input $X$ and the gating signal are first linearly mapped to a $\mathbb{R}^{F\times H\times W}$ dimensional space, and then the output is squeezed along the channel dimension to produce a spatial attention weight map $ S \in \mathbb{R}^{1\times H\times W}$. The overall process can be written as follow \begin{align} S &= \sigma(\varphi(\delta(\phi_x(X)+\phi_g(G)))) \\ Y &= X\cdot S \end{align} Here $\varphi$, $\phi_x$ and $\phi_g$ are linear transformation implemented by $1\times 1$ convolution. The proposed AG guides the model's attention to important regions while suppressing feature activation in unrelated areas. It substantially enhances the representational power of the model without adding considerable computing cost or model parameters due to its lightweight design. AG is general and modular, making it simple to plug into CNN models. \subsubsection{STN} The property of translation equivariance makes CNNs suitable for processing image data. However, CNNs lack some other transformation invariance such as rotation invariance, scaling invariance and warping invariance. To achieve those attributes and make CNNs focus on the important regions, Jaderberg et al.~\cite{jaderberg2016spatial} propose spatial transformer networks(STN) that presents \gmh{an} explicit procedure to learn \mtj{the} invariance to translation, scale, rotation and \mtj{other} more generic \mtj{image} warps, make\mtj{ing} the network attend on the most relevant regions. \gmh{STN \mtj{is the first to} explicitly predict the important regions and makes the deep neural network achieve more transformation invariance. After that, some representative works~\cite{dai2017deformable, Zhu_2019_CVPR_dcnv2} appear and realize great\mtj{er} success. } Taking a 2D image as an example, the 2D affine transformation can be formulated as: \begin{align} \label{eq_2d_affine} \begin{bmatrix} \theta_{11} & \theta_{12} & \theta_{13} \\ \theta_{21} & \theta_{22} & \theta_{23} \end{bmatrix} &= f_\text{loc}(U) \\ \begin{pmatrix} x_{i}^{s} \\ y_{i}^{s} \end{pmatrix} &= \begin{bmatrix} \theta_{11} & \theta_{12} & \theta_{13} \\ \theta_{21} & \theta_{22} & \theta_{23} \end{bmatrix} \begin{pmatrix} x_{i}^{t} \\ y_{i}^{t} \\ 1 \end{pmatrix}. \end{align} Here, $U$ is the input feature map, $f_\text{loc}$ can take any differentiable function, such as a lightweight fully-connected network or convolutional neural network. \mtj{$x_{i}^{s}$ and $y_{i}^{s}$} are the coordinates in the output feature map, $x_{i}^{t}$ and $y_{i}^{t}$ are the corresponding coordinates in the input feature map and $\theta$ matrix is the learnable affine matrix. After obtaining the correspondence, it can sample relevant input regions according to the correspondence. To ensure the whole process is differentiable and can be updated in an end-to-end manner, it adopts bilinear sampling to sample the input feature\gmh{s}. The STN helps the networks focusing on discriminative regions automatically and make the network learn invariance to some geometric transformations. \subsubsection{Deformable Convolutional Networks} With similar \mtj{purpose} as STN, Dai et al.~\cite{dai2017deformable} propose deformable convolutional networks(deformable ConvNets) \gmh to make the network invariant to geometric transformations, \mtj{however,} attend\mtj{ing} to \gmh{the} important regions \mtj{with a} different manner. } \mtj{Specifically,} deformable ConvNets do not learn the affine transformation process. It divides convolution into two steps: 1) sampling feature in a regular grid $\mathcal{R}$ from the input feature map; 2) Aggregating sampled feature by weighted summation with the convolution kernel. The process can be written as: \begin{align} Y(p_{0}) &= \sum_{p_i \in \mathcal{R}} w(p_{i}) X(p_{0} + p_{i}) \\ \mathcal{R} &= \{(-1,-1), (-1, 0), ..., (1, 1)\} \end{align} The deformable convolution augments the sampling process by introducing a group of learnable offset $\Delta p_{i}$ which can be generated by a lightweight CNN. After getting the offset $\Delta p_{i}$, the deformable convolution can be formulated as: \begin{align} Y(p_{0}) &= \sum_{p_i \in \mathcal{R}} w(p_{i}) X(p_{0} + p_{i} + \Delta p_{i}). \end{align} Through the above method, it achieves adaptive sampling. However, $\Delta p_{i}$ is a decimal which is not allowed in grid sampling at most time. To \gmh{address} this problem, it adopts bilinear interpolation. This paper also presents a deformable RoI pooling which improves object detection a lot. The deformable ConvNets adaptively select \gmh{the} important regions and enlarge the valid receptive field of convolutional neural network which plays a\gmh{n} important role in object detection and semantic segmentation tasks. \subsubsection{Self-attention and Variants} Self-attention has been proposed and makes a great success in natural language processing(NLP) field ~\cite{bahdanau2016neural, vaswani2017attention, lin2017structured, devlin2019bert, yang2020xlnet, dai2019transformerxl, choromanski2021rethinking}. Recenly, it also reveals \gmh{the} huge potential to become the \mtj{dominated} tool in the field of computer vision~\cite{Wang_2018_nonlocal, dosovitskiy2020vit, carion2020endtoend_detr, pmlr-v119-chen20s-igpt, zhu2021deformable}. At \mtj{most of} time, self-attention is used as a spatial attention to capture the global information. Here, we summarize \gmh{the} self-attention mechanism and its common variants in computer vision. \paragraph{Non-Local Network} Due to the physical locality of convolutional operation, CNNs are inherently poor to obtain large valid receptive field~\cite{liu2015parsenet,Peng_2017_large_kernel} which limits CNNs to understand scenes from \gmh{an} overall view. To get sufficient valid receptive field, Wang et al.~\cite{Wang_2018_nonlocal} firstly introduce self-attention into computer vision to make up for the shortcomings of CNNs. Taking 2D image as an example, given a feature map $F \in \mathbb{R}^{C \times H \times W}$, self-attention first gets $Q, K, V \in \mathbb{R}^{C' \times N}, N = H \times W$ vector by using linear projection and reshape operation. Then self-attention can be formulated as: \begin{align} \label{eq_self_attn} A = (a)_{i,j} & = \text{Softmax}(Q K^T), \\ Y & = A V, \end{align} where $A \in \mathbb{R}^{N \times N} $ is the attention matrix and $\alpha_{i,j}$ is the relationship between the $i$-th and $j$-th elements. The whole process can be visualized as \gmh{the} left part of Fig.~\ref{fig:vit}. Self-attention is a powerful tool to model global information and promotes a series of visual tasks~\cite{YuanW18_ocnet, Xie_2018_acnn, yan2020pointasnl, hu2018relation, Zhang_2019_cfnet, zhang2019sagan, Bello_2019_ICCV_AANet, zhu2019empirical,Li_2020_sprr}. \paragraph{Variants} \jpt{format is not right} However, there are some shortcomings in self-attention such as the quadratic complexity which limit its capability. In the following, we will introduce some variants to alleviate the existing problems of self-attention. \gmh \mtj{Note that} Disentangled Non-Local~\cite{yin2020disentangled} improves the performance\tjc{accuracy/effectiveness} of self-attention while others focus on reducing its computational complexity. }\\ \textbf{CCNet}~\cite{huang2020ccnet} regards self-attention operation as a graph convolution and replace\mtj{s} the densely-connected graph in self-attention with several sparsely-connected graphs. To this \mtj{end}, it proposes a novel cross-criss attention which considers row attention and column attention recurrently to obtain global information. \mtj{CCNet} reduces the complexity of self-attention from $O(N^{2})$ to $O(N \sqrt{N})$. \\ \textbf{EMANet}~\cite{li19ema} views self-attention from the Expectation-Maximization (EM) process. It proposes EM Attention which adopts EM algorithm to get a set of compact bases to instead all points as the reconstruction bases. It reduces the complexity of self-attention from $O(N^{2})$ to $O(NK)$, $K$ is the number of compact bases. \\ \textbf{ANN}~\cite{ann} presents that using all position features as key and vectors is redundant and adopts spatial pyramid pooling~\cite{zhao2017pspnet, He_2014_spp} to obtain few representative key and value features to instead using all points for achieve lightweight attention. \\ \textbf{GCNet}~\cite{cao2019GCNet} analyses attention map of self-attention and finds that the global contexts obtained by self-attention are similar for different query positions in one image. With this observation, it first propose to predict a same attention map for all query points. Then it get global information by weighted sum of input feature according to the attention map. Similar with average pooling, but it is a more general process of collecting global information. \\ \textbf{$A^{2}$Net}~\cite{chen2018a2nets}: Motivated by SENet, $A^{2}$Net divides whole attention into feature gathering and feature distribution process and finish them by using two different attention. The first attention aggregates global information via second-order attention pooling and the second attention distribute the global descriptors by soft selecting attention. \\ \textbf{GloRe}~\cite{chen2018glore} understands self-attention from a graph learning perspective. It first collects $N$ input features into $M(M << N)$ nodes and then learns an adjacency matrix between nodes to interact globally. Finally, the nodes distribute global information to input features. Besides GloRe, the similar idea can be found in LatentGNN~\cite{zhang2019latentgnn}, MLP-Mixer~\cite{tolstikhin2021mlpmixer} and ResMLP~\cite{touvron2021resmlp}. \\ \textbf{OCRNet}~\cite{yuan2021segmentation_ocr} proposes the concept of object-contextual representation which means the weighted aggregation of all object regions representations of the same category, e.g.,weighted average of all cars' regions representations. It replaces key and vector with object-contextual representation making a great success both in efficiency and effectiveness. \\ \textbf{Disentangled Non-Local}: Motivated by ~\cite{cao2019GCNet, Wang_2018_nonlocal}, Yin et al~\cite{yin2020disentangled} deeply analyze the self-attention mechanism and propose disentangled Non-Local module. The core idea is decoupling self-attention into two terms pairwise term and unary term. The pairwise term focuses on modeling relationships while the unary term focuses on salient boundaries. This decomposition prevents the mutual influence between the two terms and improves semantic segmentation, object detection and action recognition a lot.\\ \textbf{HamNet}~\cite{ham} models the capturing global relationships as a low-rank completion problem and designs a series of white-box methods to capture global context by using matrix decomposition. It not only reduce the complexity, but increases the interpretability of self-attention. \\ \textbf{EANet}~\cite{external_attention} proposes that self-attention only considers the correlation in a single sample and ignores the potential relationship between different samples. To explore the correlation between different samples and reduce computations, it firstly proposes external attention that adopts learnable, lightweight and shared key and value vectors . Besides, it also reveals that only using softmax function to normalize attention map is not the optimal way and presents double normalization is a better manner. \\ \paragraph{Local self-attention} In addition to being a complementary to CNNs, self-attention also can be used to aggregate neighborhood information to replace convolution operations. Convolution operation can be formulated as dot product between input feature $X$ and convolution kernel $W$ as Eq.~\ref{eq_conv}. \begin{align} \label{eq_conv} Y_{i,j}^{c} & = \sum_{a,b \in \{0, 1, ..., k-1\}} W_{a,b,c} X_{\hat{a}, \hat{b}} \\ \hat{a} & = i+a-\lfloor k/2 \rfloor, \\ \hat{b} & = j+b-\lfloor k/2 \rfloor \end{align} Here, $k$ means the kernel size and $c$ means the $c$-th channel. The above formulation can be viewed as a process of aggregating neighborhood information by using weighted sum through convolution kernel. The process of aggregating neighborhood information can be defined more general form as Eq.~\ref{eq_general_conv} \begin{align} \label{eq_general_conv} Y_{i,j} &= \sum_{a,b \in \{0, 1, ..., k-1\}} \text{Rel}(i,j,\hat{a},\hat{b}) f(X_{\hat{a},\hat{b}}) \end{align} where $\text{Rel}(i,j,\hat{a},\hat{b})$ is the relation function between position (i,j) and position ($\hat{a}$, $\hat{b}$). Through this definition, local self-attention can be a special case of above definition. For example, SASA~\cite{ramachandran2019standalone} write it as Eq.~\ref{eq_sasa} \begin{align} \label{eq_sasa} Y_{i,j} &= \sum_{a,b \in \mathcal{N}_{k}(i,j)} \text{Softmax}_{ab}(q_{ij}^{T}k_{ab} + q_{ij}r_{a-i, b-j})v_{ab} \end{align} $q,k$ and $v$ are linear projection of input feature $x$, $r_{a-i, b-j}$ means the relative positional embedding of (i,j) and (a,b).The following paragraphs introduce some works to explore local self-attention as basic blocks of neural networks before vision transformer~\cite{dosovitskiy2020vit}. \\ \textbf{SASA}~\cite{ramachandran2019standalone} proposes that using self-attention to collect global information is computing unfriendly and first presents to adopt local self-attention to replace all spatial convolution in CNN. It shows that local self-attention performs a better effect than convolution in terms of performance, parameter and computation. It also explores the behavior of positional embedding and shows relative positional embeddings~\cite{shaw2018relative_position} is a suitable manner. Besides, is also studies how to combining local self-attention with convolution. \\ \textbf{LR-Net}~\cite{hu2019lrnet} is the concurrent work with SASA. LR-Net also studies how to model local relation by using local self-attention. It conducts comprehensive ablation study to probe the effect of positional embedding, kernel size, appearance composability and adversarial attacks. \\ \textbf{SAN}~\cite{Zhao_2020_SAN} explores two modes pairwise and patchwise to utilize attention for local feature aggregation. It proposes a novel vector attention which achieves both adaptive content and adaptive channel and probes its effectiveness from the theoretical and practical aspects. In addition to a significant improvement in the image domain, vector also makes a great success in 3D point cloud~\cite{zhao2020pointtransformer}. \subsubsection{Set Transformer} Although the self-attention mechanism has ability to model direct dependency between each pair of point features, the quadratic computation complexity of full self-attention limits its application on large input sets. Therefore, Lee et al.\cite{lee2019settransformer} proposes variant of self-attention mechanism named Induced Set Attention Block(ISAB) to reduce the $O(N^2)$ computation time to $O(nm)$ where $m$ is a fixed hyperparameter. For the sake of integrality, we first give the formula of Multi-Head Attention mechanism. Formally, the Multi-Head Attention(MHA) mechanism can be written as follow \begin{align} \text{Att}(Q,K,V) &= \omega(QK^\top)V \\ \text{MHA}(Q,K,V) &= [O_1;...;O_h]W^O \\ \text{where}\;\;O_j &= \text{Att}(QW_j^Q,KW_j^K,VW_j^V) \nonumber \end{align} where $W_j^Q$, $W_j^K$,$W_j^V$ and $W^O$ are the weights of pointwise fully-connected layers belonging to the $j$-th head. Given matrices $X,Y \in \mathbb R^{n\times d}$ which represents two set of $d$-dimensional features, the Multi-Head Attention Block(MAB) is formally defined as Eq.\ref{eq_settransformer} \begin{align} \label{eq_settransformer} \text{MAB}(X,Y) &= LN(H+rFF(H))\\ \text{where}\;\; H &= LN(X+\text{MHA}(X,Y,Y)) \nonumber \end{align} Here $LN$ is layer normalization\cite{ba2016layernorm} and $rFF$ denotes any row-wise feedforward layer. Set transformer first projects the input features onto a low-dimensional object, and then maps them back. Following previous definitions, the set transformer can be defined as \begin{align} \text{ISAB}(X) &= \text{MAB}(X,\text{MAB}(I,X)) \end{align} where $I\in \mathbb{R}^{m\times d}$ are trainable parameters called induced points. The induced points plays a role of dimensionality reduction, significantly reducing computation complexity of self-attention mechanism. Same as self-attention mechanism used in spatial dimension, ISAB plays a role of drawing global dependencies between features. It allows each neuron to collect global information and can be added after all layers in permutation-invariant neural networks for its light-weight design. \subsubsection{Vision Transformers} \begin{figure}[t] \centering \includegraphics[width=\linewidth]{./Images/vit_fig.png} \caption{Diagram of vision transformer~\cite{dosovitskiy2020vit}. Left: architecture of vision transformer. It first splits the image into different patches and projects them into feature space. Then a standard transformer is adopted to process them and produce the final result. Right: basic block of vision transformer. The core part is the multi-head attention. Figure is taken from~\cite{dosovitskiy2020vit}. } \label{fig:vit} \end{figure} Transformers have made great success in natural language processing field~\cite{bahdanau2016neural, vaswani2017attention, lin2017structured, devlin2019bert, choromanski2021rethinking, brown2020language_gpt3}. Recently, iGPT~\cite{pmlr-v119-chen20s-igpt} and DETR ~\cite{carion2020endtoend_detr} demonstrates the huge potential of transformer-based models in computer vision. Motivated by this, Dosovitskiy et al~\cite{dosovitskiy2020vit} propose Vision Transformer(ViT) which is the first pure transformer architecture for image processing and achieves comparable performance with modern convolutional neural network. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{./Images/multi-head-attention.png} \caption{Left: Diagram of self-attention. Right: Diagram of multi-head self-attention. Figure is taken from~\cite{vaswani2017attention}. } \label{fig:multi_head_attention} \end{figure} As shown in Fig~\ref{fig:vit}, the main part of ViT is the multi-head attention(MHA) module. MHA takes a sequence as input. It first concatenates a class token and gets the input feature $F \in \mathcal{R}^{N \times C}$, where $N$ is the number of pixels. Then it gets $Q,K \in \mathcal{R}^{N \times C'}$ and $V \in \mathcal{R}^{N \times C}$ by linear projection. After that, $Q, K$ and $V$ divide into $H$ heads along the channel direction and applies self-attention separately. The process of MHA can be shown in Fig.~\ref{fig:multi_head_attention}. The ViT stacks a number of MHA layers with fully connected layers, layer normalization~\cite{ba2016layer} and GELU~\cite{hendrycks2020gelu} activation function. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{./Images/attention_map_vit.png} \caption{Visualized results of attention map from~\cite{dosovitskiy2020vit}. We can find that the network focuses on the discriminative regions in the image. The figure is taken from ~\cite{dosovitskiy2020vit}. } \label{fig:attention_map_vit} \vspace{-1ex} \end{figure*} ViT demonstrates that the pure attention-based network can achieve better performance than convolutional neural network especially when meets large dataset such as JFT-300~\cite{sun2017revisiting} and ImageNet-21K~\cite{Deng2009Imagenet}. After ViT, a lot of transformer-based architectures such as PCT~\cite{Guo_2021_pct}, IPT~\cite{chen2021pretrained_ipt}, PT~\cite{zhao2020pointtransformer},T2T-ViT~\cite{yuan2021tokens}, SETR~\cite{SETR}, PVT~\cite{wang2021pyramid}, TNT~\cite{han2021transformer_tnt} ,Swin-transformer~\cite{liu2021swin}, Query2Label~\cite{liu2021query2label}, MoCoV3~\cite{chen2021empirical_mocov3}, BEiT~\cite{bao2021beit}, SegFormer~\cite{xie2021segformer} and FuseFormer~\cite{liu2021fuseformer} appear and achieve amazing results in many kind of visual tasks e.g., image classification, object detection, semantic segmentation, point cloud processing, action recognition and self-supervised learning. The detailed survey of vision transformers is beyond the scope of this paper. Readers are recommended to recent surveys~\cite{han2021survey, khan2021transformers, guo2021attention_mlp_cnn} for a more comprehensive review of the use of transformer methods for visual tasks. \subsubsection{GENet} Inspired by SENet, Hu et al.~\cite{hu2019gatherexcite} design GENet to capture long-range spatial context information by providing a recalibration function in the spatial dimension. GENet can be split by part gather and excite operations. In the first step, it aggregates input features over large neighborhoods and tries to model the relationship between different spatial locations. In the second step, it first generates the attention map with the same dimensions as the input feature map via using interpolation. Then each position of the input feature map is scaled by multiplying the corresponding element in the attention map. The entire gather-excite operator can be abstracted as: \begin{align} g &= f_\text{gather}(X), \\ s &= f_\text{excite}(g) = \sigma(\text{Interp}(g)) \\ Y &= s \cdot x. \end{align} Here, $f_\text{gather}$ can take any form such as global average pooling or a sequential of depth-wise convolutions to capture spatial correlation and $\text{Interp}(\cdot)$ means interpolation function. Gather-Excite is a lightweight module and can be inserted into each residual unit like SE block. It achieves emphasizing important features while suppressing noise features. \subsubsection{PSANet} Motivated by the success of capturing long-range dependency in the convolutional neural network. Zhao et al.~\cite{Zhao_2018_psanet} present a novel framework PSANet to aggregate global information. It models information aggregation as a kind of information flow and proposes a bi-direction information propagation mechanism to make information flow deliver globally. PSANet first generally formulate the information aggregation as: \begin{align} \label{eq_psa_aggr} z_{i} = \sum_{j \in \Omega(i)} F(x_{i}, x_{j}, \Delta_{ij})x_{j} \end{align} where $\Delta_{ij}$ means the positional relationship between the i and j. $F(x_{i}, x_{j}, \Delta_{ij})$ is a function that takes $x_{i}$, $x_{j}$ and $\Delta_{ij}$ into consideration and controls information flow from j to i. $\Omega_{i}$ represents the aggregation neighborhood of position i. Note that if we want to capture global information, $\Omega_{i}$ concludes all spatial positions. Due to the complexity of calculating function $F(x_{i}, x_{j}, \Delta_{ij})$, it decomposes and approximates the function $F(x_{i}, x_{j}, \Delta_{ij})$ as: \begin{align} F(x_{i}, x_{j}, \Delta_{ij}) \approx F_{\Delta_{ij}}(x_{i}) + F_{\Delta_{ij}}(x_{j}) \end{align} Under this approximation, Eq.~\ref{eq_psa_aggr} can be simplified as: \begin{align} \label{eq_psa_sim} z_{i} = \sum_{j \in \Omega(i)} F_{\Delta_{ij}}(x_{i})x_{j} + \sum_{j \in \Omega(i)} F_{\Delta_{ij}}(x_{j})x_{j} \end{align} Observing above Eq.~\ref{eq_psa_sim}, we can find that the first term $\sum_{j \in \Omega(i)} F_{\Delta_{ij}}(x_{i})x_{j}$ can be viewed as the process of collecting information of position i and the second term $\sum_{j \in \Omega(i)} F_{\Delta_{ij}}(x_{j})x_{j}$ can be viewed as the process of distributing information of position j. The results of function $F_{\Delta_{ij}}(x_{i})$ and $F_{\Delta_{ij}}(x_{j})$ can be seen as an adaptive attention weight. Through the above process, it achieves aggregating global information while emphasizing the relevant features. It can be plugged into the end of convolutional neural network as an effective complement which improves the semantic segmentation a lot. \begin{table*} \centering \caption{Summary of representative temporal attentions sorted by publication time. Publication=First publication, Cls = Classification, FGCls=Fine-Grain Classification, Det=Detection, SSeg=Semantic Segmentation, ISeg=Instance Segmentation, ST=Style Transfer, Action=Action Recognition.} \setlength{\tabcolsep}{1.5pt} \label{Tab_temporal_attentions} \begin{tabular}{lcccc} \toprule \textbf{Method} & \textbf{Publication} & \textbf{Experiments} & \textbf{Description of the attention process} & \textbf{Function of attention process} \\ \midrule GLTR\cite{li2019global} & ICCV2019 & ReID &\makecell[l]{a)adopt dilated convolution with various \\ dilated rates\\b)use self-attention mechanism along the \\ temporal dimension} & \makecell[l]{a)exploit the multi-scale short-term temporal \\ contextual information\\b)capture long-term temporal feature dependencies} \\ \midrule TAM\cite{liu2020tam} & Arxiv2020 & Action &\makecell[l]{a)produce frame-wise attention weights by \\ stacking 1D convolutions\\b)perform convolution with a channel-wise \\ adaptive kernel} & \makecell[l]{a)capture local temporal context \\b)leverage global temporal information to \\ enhance frame-wise features} \\ \bottomrule \end{tabular} \end{table*} \subsection{Temporal Attention} Temporal attention can be seen as a dynamic time selection mechanism\mtj{, i.e.,} ``when to attend'', that usually is used for video processing. \xtx{Previous works\cite{li2019global,liu2020tam} often put emphasis on how to capture both short-term and long-term cross-frame feature dependencies. } In this subsection, we first summarize the representative temporal attentions in Tab.~\ref{Tab_temporal_attentions}. Then we discuss various temporal attentions \gmh{according to the order in Fig.~\ref{fig:total_attention_summary}}. \subsubsection{Self-attention and Variants} \paragraph{GLTR} RNN and temporal pooling or weight learning \gmh{???} have been widely used in previous works on video representation learning to capture interaction between frames, but they have limitations in terms of either efficiency or temporal relation modeling. \gmh{To solve the above problems}, Li et al.\cite{li2019global} propose a Global-Local Temporal Representation(GLTR) to exploit the multi-scale temporal cues in the video sequence. GLTR consists of Dilated Temporal Pyramid(DTP) for local temporal context learning and Temporal Self Attention for capturing global temporal interaction. DTP adopts dilated convolution with dilated rates increasing progressively to cover various temporal ranges, and then concatenate the outputs from different dilated convolution to aggregate multi-scale information. Given the input frame-wise features $F = \{f_1, ... f_T\}$, DTP can be written as follow \begin{align} \{f_1^{(r)}, ..., f_T^{(r)}\} &= \text{DConv}^{(r)}(F) \\ f'_t &= [f_t^{(1)};...f_t^{(2^{n-1})}...;f_t^{(2^{N-1})}] \end{align} Here $\text{DConv}^{(r)}(\cdot)$ denotes dilated convolution with dilation rate $r$. Then, TSA follows self-attention mechanism and adopts convolution layers followed by Batch Normalization and ReLU to generate the query $Q \in \mathbb{R}^{d\times T}$, the key $K \in \mathbb{R}^{d\times T}$ and the value $V \in \mathbb{R}^{d\times T}$ based on the input feature map $F' = \{f'_1, ... f'_T\}$, which can be formally written as \begin{align} F_\text{out} = g(V\text{Softmax}(Q^TK)) + F' \end{align} where $g$ denotes a linear mapping implemented by a convolution. The short-term temporal contextual information from neighboring frames helps to distinguish visually similar regions while the long-term temporary indication serves to reduce occlusions and noise. Combining the advantages of both modules, GLTR enhances the representation \gmh{capability} and suppresses noise. It can \mtj{be} incorporated \mtj{ into} any state-of-the-art CNN backbones to learn a global descriptor for \mtj{the} \gmh{whole} video. \xtx{However, self-attention mechanism spares much computational overhead and requires quadratic time complexity, \gmh{which limits its applications.}} \subsubsection{TAM} To capture complex temporal relationships with both high efficiency and strong flexibility, Liu et al.\cite{liu2020tam} propose Temporal Adaptive Module(TAM). \xtx{It adopts an adaptive kernel instead of self-attention to capture the global contextual information, which reduces time complexity effectively \gmh{compared with GLTR~\cite{li2019global}}.} TAM can be split into two branches, named local branch and global branch. Given the input feature map $X\in \mathbb{R}^{C\times T\times H\times W}$, a global average pooling $g_\text{avg}$ is first applied on the feature map to ensure TAM with a low computational cost. Then the local branch in TAM employs several 1D convolutions with ReLU nonlinearity along the temporal dimension to produce the location-sensitive importance maps to enhance frame-wise features. Formally, the local branch can be written as \begin{align} s &= \sigma(\text{Conv1D}(\delta(\text{Conv1D}(g_\text{avg}(X)))))\\ X^1 &= s\cdot X \end{align} Different from the local branch, the global branch is location invariant and focuses on generating a channel-wise adaptive kernel based on global temporal information on each channel. More formally, for the $c$-th channel, the adaptive kernel can be written as follow \begin{align} \Theta_c = \text{Softmax}(\text{FC}_2(\delta(\text{FC}_1(g_\text{avg}(X)_c)))) \end{align} where $\Theta_c \in \mathbb{R}^{K}$ is generated adaptive kernel for $c$-th channel, and $K$ is the adaptive kernel size. Finally, TAM performs convolution with adaptive kernel $\Theta$ on $X_\text{out}^1$ \begin{align} Y = \Theta \otimes X^1 \end{align} With the help of the local branch and global branch, TAM can capture the complex temporal structure in videos and enhance frame-wise features with low computational cost. Due to its flexibility and lightweight design, TAM can be plugged into any existing 2D CNNs. \subsection{Branch Attention} Branch attention can be seen as a dynamic branch selection mechanism("which to attend") that usually is used for multi-branch structure. In this subsection, we first summarize the representative branch attentions in Tab.~\ref{Tab_branch_attentions}. Then we discuss various branch attentions respectively. \begin{table*} \centering \caption{Summary of Representative Branch Attentions sorted by publication time. Publication=First publication, Cls = Classification, FGCls=Fine-Grain Classification, Det=Detection, SSeg=Semantic Segmentation, ISeg=Instance Segmentation, ST=Style Transfer, Action=Action Recognition.} \setlength{\tabcolsep}{1.5pt} \label{Tab_branch_attentions} \begin{tabular}{lcccc} \toprule \textbf{Method} & \textbf{Publication} & \textbf{Experiments} & \textbf{Description of the attention process} & \textbf{Function of attention process} \\ \midrule Highway Network~\cite{srivastava2015training} & ICML2015W & Cls &\makecell[l]{a) predict gate weight by linear layer \\ and sigmoid function. \\ b) use a gating mechanism to combine \\ $x$ and $H(x)$. } & \makecell[l]{a) alleviate the problem of vanishing gradient \\ b) enable to train a deep network by using \\ a simple gradient descent algorithm. \\ c) dynamically fuse different branches. } \\ \midrule SKNet~\cite{li2019selective} & CVPR2019 & Cls &\makecell[l]{a) predict a group of weighted factors. \\ b) combine different branches according \\ to the predicted factors.} & \makecell[l]{a) adaptively select suitable receptive field \\ b) dynamically fuse different branches.} \\ \midrule CondConv~\cite{yang2020condconv} & NeurIPS2019 & Cls \& Det &\makecell[l]{a) predict a group of attention weight. \\ b) weight different convolution kernels \\ according to the attention weights to obtain \\ mixed convolution kernels. \\ c) use the mixed convolution kernels to \\ perform convolution.} & \makecell[l]{ a) improve the capability of standard \\ convolution efficiently. \\ b) dynamically fuse different convolution \\ kernels.} \\ \bottomrule \end{tabular} \end{table*} \subsubsection{Highway network} Inspired by the Long Short Term Memory Network, Srivastava et al.\cite{srivastava2015training} proposes highway networks that employ adaptive gating mechanisms to enable information flows across layers to address the problems of training very deep networks. Supposing a plain neural network consisting of $L$ layers, where $H_l(X)$ denotes a non-linear transformation on the $l$-th layer, highway network can be denoted as follow \begin{align} \label{eq_highway} Y_l &= H_l(X_l) \cdot T_l(X_l) + X_l \cdot (1-T_l(X_l)) \\ T_l(X) &= \sigma(W_l^TX+b_l) \end{align} Here $T_l(X)$ denotes the transform gate on the $l$-th layer, which regulates the information flow. $X_l$ and $Y_l$ are the inputs and outputs of the $l$-th layer. The gating mechanism and skip-connection structure make it possible to directly train very deep highway networks using simple gradient descent methods. Unlike fixed skip-connection, the gating mechanism is adaptive to the inputs, which helps in routing information across layers. Highway network can be incorporated with any CNN blocks. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{./Images/CondConv.png} \caption{ Diagram of CondConv~\cite{yang2020condconv}. (a) CondConv: It first combine different convolution kernels and then uses the combined kernel to finish convolution. (b) Mixture of experts: It first uses multiple convolution kernels to finish convolution respectively and then merge the multiple results. We can find that (a) and (b) are equivalent, but the (a) manner greatly reduces the computational cost. The figure is taken from~\cite{yang2020condconv}. } \label{fig:CondConv} \end{figure} \subsubsection{SKNet} Numerous researches in the neuroscience community suggest that visual cortical neurons adaptively adjust their receptive field(RF) sizes according to the input stimulus \cite{spillmann2015beyond}, which inspires Li et al.\cite{li2019selective} to propose an automatic selection operation called Selective Kernel(SK) convolution. The SK convolution is implemented by three operations, including \emph{Split}, \emph{Fuse} and \emph{Select}. In the phase of \emph{Split}, transformations with different kernel sizes are conducted on the feature map respectively to obtain different RF sizes. Then information from all branches is fused together via an element-wise summation to compute the gate vector, which is further used to control the information flows from multiple branches. Finally, the output feature map is obtained by aggregating feature maps on all branches, which is guided by the gate vector. To take it more formally, the SK convolution with $K$ branches can be denoted as \begin{align} U_k &= F_k(X) \;\; (k=1...K)\\ U &= \sum_{k=1}^K U_k \\ z &= \delta(BN(W g_\text{avg} (U))) \\ s_k^{(c)} &= \frac{e^{W_k^{(c)} z}}{\sum_{k=1}^K e^{W_k^{(c)} z}} \;\;(k=1...K, c=1...C) \\ Y &= \sum_{k=1}^K s_k \cdot U_k \end{align} Here $F_k$ denotes the transformation on the $k$-th branches with a unique kernel size to carry different scales of information into neurons. For computational efficiency, $F_k$ is usually implemented by grouped/depthwise convolutions and dilated convolution, as well as Batch Normalization and ReLU function in sequence. $t^{(c)}$ denotes the $c$-th element of vector $t$, or the $c$-th row of matrix $t$. SK convolutions enable the network to adaptively adjust neurons' RF sizes according to the input, which leads to a notable performance gain with a little computational cost. The gate mechanism in SK convolutions is used to fuse information from multiple branches. Due to its lightweight design, SK convolutions can be applied to any CNN backbones via replacing all the large kernel convolutions. ResNeSt~\cite{zhang2020resnest} also adopts this attention to improve CNN backbone in a more general way and makes great progress on ResNet~\cite{resnet} and ResNeXt~\cite{resnext}. \subsubsection{CondConv} A basic assumption in CNNs is that the convolution kernels are the same for all samples. Under this premise, people often enhance the representational power of the network by increasing the depth or width of the network, which introduces significant computational cost. In order to increase the capacity of convolutional neural networks efficiently, Yang et al.~\cite{yang2020condconv} propose a novel multi-branch operator CondConv. The ordinary convolution can be formulated as: \begin{align} Y = W * X \end{align} where $*$ means convolutional operation. The learnable parameter $W$ is the same for all samples. As for CondConv, it adaptively combines multiple convolution kernels together and can be written as: \begin{align} Y = (\alpha_{1} W_{1} + ... + \alpha_{n} W_{n}) * X \\ \end{align} Here, $\alpha$ is the learnable weight and can be obtained by Eq.~\ref{eq.condconv_weight}. Observing the above function, we can find that the process of weighting the weights $W_{i}$ can be seen as the ensemble of multiple experts as shown in Fig.~\ref{fig:CondConv}. \begin{align} \label{eq.condconv_weight} \alpha = \sigma(W_{r}(g_\text{avg}(X))) \\ \end{align} The CondConv makes full use of the advantages of the multi-branch structure by branch attention method with little computing overhead. It presents a novel manner to increase the capability of networks efficiently. \subsubsection{Dynamic Convolution} The extremely low computational cost of lightweight CNNs constrains the depth and width of the networks, further decreasing the representational power. To address the above problem, Chen et al.\cite{chen2020dynamic} propose Dynamic Convolution, a novel operator design that increases the representational power with the cost of negligible computational overhead and does not change the width or depth of the network in parallel with CondConv~\cite{yang2020condconv}. Dynamic Convolution uses $K$ parallel convolution kernels which share the same kernel size and input/output dimensions instead of one kernel per layer. Similar to SE blocks, it adopts a squeeze-and-excitation mechanism to generate the attention weights of different convolution kernels. Then these kernels are aggregated dynamically by weighted summation and applied to the input feature map $X\in \mathbb{R}^{C\times H\times W}$. Formally, Dynamic Convolution can be written as \begin{align} s & = \text{softmax} (W_{2} \delta (W_{1}g_\text{avg}(X))) \\ \text{DyConv} &= \sum_{i=1}^{K} s_k \cdot \text{Conv}_k \\ Y &= \text{DyConv}(X) \end{align} Here the addition of convolutions is defined as the summation of weights and biases of convolutional kernels. Compared with the computational complexity of applying convolution on the feature map, the process of squeeze-and-excitation and weighted summation is extremely negligible. Thus Dynamic Convolution provides an efficient operation to improve the representational power and can be easily used as a replacement for any convolution. \subsection{Channel \& Spatial Attention} Channel \& spatial attention combines the advantages of channel attention and spatial attention. It adaptively selects both important objects and regions~\cite{ChenZXNSLC17}. \xtx{Residual Attention Network\cite{wang2017residual} is the pioneer in \gmh{the field of} channel \& spatial attention, which emphasizes informative features in both spatial and channel dimensions. It adopts a bottom-up structure consisting of several convolutions to produce \gmh{3D(Height, Width and Channel)} attention map, whereas it may suffer from high computational overhead and limited receptive field. To leverage global spatial information, some following works\cite{woo2018cbam,park2018bam} enhance \gmh{discrimination} \mtj{of} features by introducing \gmh{global average pooling} \gmh{as well as decoupling} channel attention and spatial channel attention for computational efficiency. Other works\cite{Fu_2019_danet,zhang2020relation} \gmh{apply} self-attention mechanisms into channel \& spatial attention for the exploration of pairwise interaction. Besides, there are also works\cite{Liu_2020_scnet,hou2020strip} \gmh{that adopt the spatial-channel attention mechanism to enlarge the receptive field.} } In this following subsection, we first summarize the representative channel \& spatial attentions in Tab.~\ref{Tab_channel_spatial_attentions}. Then we discuss various channel \& spatial attentions respectively. \begin{table*} \centering \caption{Summary of representative channel \& spatial attentions sorted by publication time. Publication=First publication, Cls = Classification, FGCls=Fine-Grain Classification, Det=Detection, SSeg=Semantic Segmentation, ISeg=Instance Segmentation, KP=Keypoint Detection, ReID=Re-identification.} \setlength{\tabcolsep}{1.5pt} \label{Tab_channel_spatial_attentions} \begin{tabular}{lcccc} \toprule \textbf{Method} & \textbf{Publication} & \textbf{Experiments} & \textbf{Description of the attention process} & \textbf{Function of attention process} \\ \midrule Residual Attention~\cite{wang2017residual} & CVPR2017 & Cls &\makecell[l]{a)adopt a bottom-up top-down fully convolutional \\ structure to compute 3D attention map } & \makecell[l]{a) make the netowrk focus on the \\ discriminative region. \\ b) emphasize important channels.} \\ \midrule SCA-CNN~\cite{ChenZXNSLC17} & CVPR2017 & ICap &\makecell[l]{a)compute channel attention map and spatial \\ attention map using visual features and previous \\ hidden state \\ b) stack channel attention and spatial attention in \\ serial} & \makecell[l]{same as CBAM} \\ \midrule CBAM~\cite{woo2018cbam} & ECCV2018 & Cls \& Det &\makecell[l]{a)stack channel attention and spatial \\ attention in serial \\ b)adopt $3\times 3$ convolution to compute spatial \\ attention} & \makecell[l]{a) make the network focus on \\ discriminative regions. \\ b) emphasize important channels. \\ c) capture global information. \\ d) avoid high computational overhead. } \\ \midrule BAM~\cite{woo2018cbam} & BMVC2018 & Cls \& Det &\makecell[l]{a)compute channel attention and spatial \\ attention in parallel \\ b)adopt bottleneck structure and dilated \\ convolution to compute spatial attention} & \makecell[l]{same as CBAM} \\ \midrule scSE\cite{roy2018recalibrating} & TMI2018 & Seg &\makecell[l]{a)compute channel attention and spatial \\ attention in parallel \\ b)adopt pixel-wise convolution to compute \\ spatial attention} & \makecell[l]{same as CBAM} \\ \midrule Triplet Attention~\cite{misra2021rotate} & WACV2021 & Cls \& Det &\makecell[l]{a)compute the attention maps along any two \\ dimensions \\ b)average the outputs from different branches} & \makecell[l]{a)capture cross-dimension interaction \\ between any two dimensions \\b)make the network focus on the \\ discriminative region } \\ \midrule Dual Attention\cite{Fu_2019_danet} & CVPR2019 & Seg &\makecell[l]{a)adopt self-attention to capture spatial and \\ cross-channel relationship\\ b) fuse the outputs from \\ different branches by summation} & \makecell[l]{a) capture long-range contextual \\ information \\ b)emphasize important channels} \\ \midrule RGA\cite{zhang2020relation} & CVPR2020 & ReID &\makecell[l]{a) use self-attention to capture pairwise relations\\ b) compute attention maps with the input and \\ relation vectors} & \makecell[l]{same as CBAM} \\ \midrule SCNet~\cite{Liu_2020_scnet} & CVPR2020 & Cls\&Det\&ISeg\&KP &\makecell[l]{a)split the input along channel dimension\\b)conduct feature transformation in two different \\ scales\\c)concatenate two outputs along the channel \\ dimension} & \makecell[l]{a)enlarge the receptive field \\b)capture inter-channel dependencies} \\ \midrule Strip Pooling\cite{hou2020strip} & CVPR2020 & Seg &\makecell[l]{a)adopt horizontal global pooling and vertical \\ global pooling respectively\\b)generate attention vectors and fuse the vectors \\ by point-wise summation\\c) adopt convolution and sigmoid to obtain \\ attention map} & \makecell[l]{a)make the network focus on \\informative regions\\b)emphasize important channels\\c)capture long-range dependencies} \\ \bottomrule \end{tabular} \end{table*} \subsubsection{Residual Attention Network} \gmh{Inspired by \gmh{\mtj{the} success of ResNet~\cite{resnet}}, Wang et al.\cite{wang2017residual} \mtj{propose} a very deep convolution neural network Residual Attention Network(RAN) by \mtj{combining the} attention mechanism and the residual connection.} Each Attention Module stacked in Residual Attention Network can be divided into two branches, mask branch and trunk branch. The trunk branch plays an role of processing feature, which can be implemented by any state-of-the-art structure including pre-activation Residual Unit and Inception block. On the other hand, the mask branch uses bottom-up top-down structure to learn the same size mask that softly weight output features from the trunk branch. A sigmoid layer normalizes the output range to $[0,1]$ after two $1\times 1$ convolution layers. Totally, the residual attention can be written as follow \begin{align} s &= \sigma(\text{Conv}_{2}^{1\times 1}(\text{Conv}_{1}^{1\times 1}( h_\text{up}(h_\text{down}(X))))) \\ X_{out} &= s\cdot f(X) + f(X) \end{align} Here $h_\text{up}$ denotes bottom-up structure, which adopts max-pooling several times after Residual Units to increase the receptive field. $h_\text{down}$ denotes top-down part with linear interpolation to keep the output size the same as the input feature map. There also exist some skip-connections between two parts, which are omitted in the formula. $f$ represents the trunk branch which can be adapted to any state-of-the-art structure. Inside each Attention Module, bottom-up top-down feedforward structure models both spatial and cross-channel dependencies, which leads to consistent performance improvement. Furthermore, the residual attention can \mtj{be} incorporate\mtj{d into} any deep network structures in an end-to-end training fashion. \xtx{However, the proposed bottom-up top-down structure fails to leverage global spatial information. \gmh{Besides, predicting a 3D (\mtj{i.e.,} Height, Weight and Channel) attention map directly leads to high computational overhead. }} \subsubsection{CBAM} \xtx{ To enhance informative channels as well as important regions, Woo et al.\cite{woo2018cbam} propose Convolutional Block Attention Module (CBAM) which stacks channel attention and spatial attention in serial. It decouples the channel attention map and spatial attention map for computational efficiency, and leverages spatial global information by introducing \gmh{global pooling.} } CBAM can be split into two sequential sub-modules, channel and spatial. Given an input feature map $X\in \mathbb{R}^{C\times H \times W}$\tjc{previous input feature is denoted in lower case $x$, try to make the notation consistent}, it sequentially infers a 1D channel attention vector $s_c\in \mathbb{R}^C$ and a 2D spatial attention map $s_s\in \mathbb{R}^{H\times W}$. The formula of channel attention sub-module is similar to that of SE Block, except that it adopts more than one type of pooling operation to aggregate global information. Formally, it has two parallel branches using max-pool and avg-pool operations \begin{align} F_\text{avg}^c &= g_\text{avg}^s(X) \\ F_\text{max}^c &= g_\text{max}^s(X) \\ s_c &= \sigma(W_2\delta(W_1 F_\text{avg}^c)+W_2\delta(W_1 F_\text{max}^c))\\ M_c(X) &= s_c\cdot X \end{align} where $g_\text{avg}^s$ and $g_\text{max}^s$ denote average global pooling and maximum global pooling operations along spatial axes respectively. The spatial attention sub-module models the inter-spatial relationship of features, which is complementary to channel attention. Different from channel attention, it applies a convolution layer with a large kernel to generate the attention map \begin{align} F_\text{avg}^s &= g_\text{avg}^c(X) \\ F_\text{max}^s &= g_\text{max}^c(X) \\ s_s &= \sigma(\text{Conv}([F_\text{avg}^s;F_\text{max}^s]))\\ M_s(X) &= s_s\cdot X \end{align} where $\text{Conv}(\cdot)$ represents a convolution operation with a large kernel. $g_\text{avg}^c$ and $g_\text{max}^c$ are global pooling operations along the channel axis respectively. $[]$ denotes the concatenation operation along the channel axis. The overall attention process can be summarized as \begin{align} X' &= M_c(X) \\ Y &= M_s(X') \end{align} Combining channel attention and spatial attention sequentially, CBAM can utilize both inter-spatial and cross-channel relationships of features to tell the network 'what' and 'where' to focus \gmh{on}. To be more specific, it emphasizes useful channels as well as enhances informative local regions. Due to its lightweight design, CBAM can be integrated into any CNN architecture seamlessly with negligible overheads. \xtx{Nevertheless, there is still room for improvement in the channel \& spatial attention mechanism. For instance, CBAM adopts a convolution to produce \mtj{the} spatial attention map. Thus the spatial sub-module may suffer from the limited receptive field.} \subsubsection{BAM} To improve the representational \gmh{capability of network} efficiently, Park et al.\cite{park2018bam} propose an attention module, named Bottleneck Attention Module(BAM), \gmh{which is the concurrent work with CBAM.} \xtx{Compared with CBAM, it uses dilated convolution to enlarge the receptive field of spatial attention sub-module, and build the ``bottleneck structure'' suggested by ResNet for saving computational cost.} For the given input feature map $X\in \mathbb{R}^{C\times H\times W}$, BAM infers the channel attention $s_c \in \mathbb{R}^C$ and spatial attention $s_s\in \mathbb{R}^{H\times W}$ in two parallel streams, then summates two attention maps after resizing both branch outputs to $\mathbb{R}^{C\times H \times W}$. Channel attention branch, like SE Block, applies global average pooling on the feature map to aggregate global information, and then uses an MLP with channel dimensionality reduction. In order to utilize contextual information effectively, the spatial attention branch combines bottleneck structure and dilated convolutions. Totally, BAM can be written as follow \begin{align} s_c &= BN(W_2(W_1g_\text{avg}(X)+b_1)+b_2) \\ s_s &= BN(\text{Conv}_{2}^{1\times 1}(\text{DC}_{2}^{3\times 3}(\text{DC}_{1}^{3\times 3}(\text{Conv}_{1}^{1\times 1}(X))))) \\ s &= \sigma(\text{Expand}(s_s)+\text{Expand}(s_c)) \\ Y &= s\cdot X+X \end{align} Here $W_i, b_i$ denotes the weights and biases of fully connected layers respectively. $\text{Conv}_{1}^{1\times 1}$ and $\text{Conv}_{2}^{1\times 1}$ are convolution layers,both of which are used for channel reduction. $\text{DC}_i^{3\times 3}$ denotes a dilated convolution with $3\times 3$ kernels, which is applied to utilize contextual information effectively. $\text{Expand}$ means expanding the attention maps $s_s$ and $s_c$ to $\mathbb{R}^{C\times H\times W}$. BAM plays a role of emphasizing or suppress features in both spatial and channel dimensions, as well as improving the representational power. Dimensional reduction applied in both channel and spatial attention branches enables it to be integrated with any convolutional neural networks with small extra computational overhead. \xtx{However, although dilated convolutions enlarge the receptive field effectively, it still fails to capture long-range contextual information as well as encoding cross-dimension relationships.} \subsubsection{scSE} To aggregate global spatial information, SE block adopts global pooling on the feature map. However, it ignores pixel-wise spatial information, which is more relevant for \gmh{dense prediction tasks}. Therefore, Roy et al.\cite{roy2018recalibrating} propose spatial and channel SE blocks(scSE). \xtx{Similar to BAM,} it adopts spatial SE blocks, which is complementary to SE blocks, to provide spatial attention weight to focus on important regions. Given the input feature map $X\in \mathbb{R}^{C\times H\times W}$, two parallel modules of scSE block, called spatial SE and channel SE, are applied on feature maps to encode spatial and channel information respectively. Channel SE module has the same form as previously proposed SE block, while spatial SE module adopts $1\times 1$ convolution to obtain spatial squeeze. The outputs from two modules are fused together and the total process can be formally written as \begin{align} s_c & = \sigma (W_{2} \delta (W_{1}g_\text{avg}(X))) \\ X_\text{chn} & = s_c \cdot X \\ s_s &= \sigma(\text{Conv}^{1\times 1}(X)) \\ X_\text{spa} & = s_s \cdot X \\ Y &= f(X_\text{spa},X_\text{chn}) \end{align} Here $f$ denotes the fusion function, which can be implemented as maximum, addition, multiplication or concatenation operation. The proposed scSE block combines channel and spatial attention to enhance the features as well as capturing pixel-wise spatial information. \gmh{Benefiting from this, segmentation tasks achieve a significant improvement.} The integration of scSE block in F-CNNs makes a consistent improvement in semantic segmentation with neglectable model complexity. \subsubsection{Triplet Attention} \xtx{In CBAM and BAM, the channel attention and spatial attention are computed independently of each other, which ignores the relationship between these two dimensions\gmh{~\cite{misra2021rotate}}.} Motivated by spatial attention, Misra et al.~\cite{misra2021rotate} propose triplet attention, a lightweight but effective attention which can capture cross-dimensional interaction. Given an input feature map $X\in \mathbb{R}^{C\times H\times W}$, triplet attention is made up of three branches, each of which plays a role of capturing cross-dimension interaction between any two dimensions of $H$, $W$ and $C$. In each branch, the rotation operations along different axes are conducted on the input first, and then the Z-Pool layer is responsible for aggregating information along the zeroth dimension. Finally, triplet attention adopts a standard convolution layer with kernel size of $k\times k$ to model the relationship between the last two dimensions. To make it formal, the triplet attention can be written as follow \begin{align} X_1 &= \text{Pm}_1(X) \\ X_2 &= \text{Pm}_2(X) \\ s_0 &= \sigma(\text{Conv}_0(\text{Z-Pool}(X))) \\ s_1 &= \sigma(\text{Conv}_1(\text{Z-Pool}(X_1))) \\ s_2 &= \sigma(\text{Conv}_2(\text{Z-Pool}(X_2))) \\ Y &= \frac{1}{3}(X\cdot s_0 + \text{Pm}_1^{-1} (X_1\cdot s_1)+\text{Pm}_2^{-1}(X_2\cdot s_2)) \end{align} Here $\text{Pm}_1$ and $\text{Pm}_2$ denote the rotation operations 90° anti-clockwise along the $H$ axis and the $W$ axis respectively, while $\text{Pm}^{-1}_i$ is the reverse process. $\text{Z-Pool}$ is defined as a concatenation of max-pooling operation and average pooling operation along the zeroth dimension \begin{align} Y = \text{Z-Pool}(X) &= [ g_\text{max}(X); g_\text{avg}(X)] \end{align} Different from CBAM and BAM, triplet attention stresses the importance of capturing cross-dimension interaction instead of computing spatial attention and channel attention independently. It helps in capturing rich discriminative feature representations. Due to its simple but efficient structure, triplet attention can be easily plugged into classic backbone networks as an add-on module. \subsubsection{SimAM} \xtx{Yang et al.~\cite{pmlr-v139-simam} also stress the importance of learning attention weights that vary across both channel and spatial \mtj{dimensions}. Thus they propose SimAM, a simple, parameter-free attention module capable of directly estimating 3D weights instead of expanding 1D or 2D weights. The design of SimAM is based on some well-known neuroscience theories, avoiding manually finetuning the network structure. } Motivated by the spatial suppression phenomenon~\cite{Webb_spatial_supp}, they propose that the neuron which shows suppression effects should be emphasized and define an energy function for each neuron as: \begin{align} \label{eq_sim_energy} e_{t}(w_{t}, b_{t}, y, x_{i}) = (y_{t} - \hat{t})^{2} + \frac{1}{M-1} \sum_{i=1}^{M-1}(y_{o} - \hat{x}_{i}) \end{align} Here, $\hat{t}=w_{t}t+b_{t}$ and $\hat{x}_{i} = w_{t}x_{i}+b_{t}$, $t$ and $x_{i}$ are the target unit and all other units in the same channel where $i \in {1, 2, ..., N}, N= H \times W$. After simplification and optimization, they find the optimal closed-form solution for Eq.~\ref{eq_sim_energy} as formulation Eq.~\ref{eq_sim_solution}. Readers can refer to ~\cite{pmlr-v139-simam} for a detailed derivation process. \begin{align} \label{eq_sim_solution} e_{t}^{\ast} = \frac{4(\hat{\sigma}^{2} + \lambda)}{(t - \hat{\mu})^2 + 2\hat{\sigma}^{2} + 2\lambda} \end{align} where $\hat{\mu}$ is the mean of the input feature and $\hat{\sigma}^{2}$ is the variance of the input feature. Then, they adopt a sigmoid function to control the output range of attention vector. Finally a element-product is applied to get the final output as: \begin{align} Y = \text{Sigmoid}(\frac{1}{E}) \cdot X \end{align} This \mtj{work} simplifies the process of designing attention and successfully proposes a novel 3-D weight parameter-free attention module based on mathematics and neuroscience theories. \subsubsection{Coordinate attention} \xtx{SE block aggregates global spatial information using global pooling before modeling cross-channel relationships, but neglects the importance of positional information. BAM and CBAM adopt convolutions to capture local relations, but fail in modeling long-range dependencies.} \gmh{To solve above problems,} Hou et al.\cite{hou2021coordinate} propose coordinate attention, a novel attention mechanism which embeds positional information into channel attention, so that the network can focus on large important regions without much computational cost. Coordinated attention can be split into two consecutive steps, coordinate information embedding and coordinate attention generation. First, two spatial extents of pooling kernels encodes each channel along the horizontal coordinate and the vertical coordinate, repesctively. In the second step, a shared $1\times 1$ convolutional transformation function is conducted on the concatenation of the outputs from two pooling layers. Then coordinated attention splits the conjunct tensor into two separate tensors and yields attention vectors with the same channel number to the input $X$ along horizontal coordinates and vertical coordinates. Formally, the coordinate attention block can be written as \begin{align} z^h &= g_\text{avg}^h(X) \\ z^w &= g_\text{avg}^w(X) \\ f &= \delta(BN(\text{Conv}_1^{1\times 1}([z^h;z^w]))) \\ f^h, f^w &= \text{Split}(f) \\ s^h &= \sigma(\text{Conv}_h^{1\times 1}(f^h)) \\ s^w &= \sigma(\text{Conv}_w^{1\times 1}(f^w)) \\ Y &= X\cdot s^h \cdot s^w \end{align} Here $g_\text{avg}^h$ and $g_\text{avg}^w$ denote pooling functions along the vertical and horizontal coordinates. $s^h \in \mathbb{R}^{C\times 1\times W}$ and $s^w \in \mathbb{R}^{C\times H\times 1}$ represent attention weights along two coordinates. Using coordinate attention, the network can obtain accurate position of the targeted object. \gmh{Besides, it has a larger receptive field than BAM and CBAM.} Like SE Block, it also plays a role of modeling cross-channel relationships, which effectively enhances the expressive power of the learned features. Due to its lightweight design and flexibility, it can be easily plugged into classic building blocks of mobile networks. \subsubsection{DANet} In the field of scene segmentation, encoder-decoder structures cannot make use of the global relationship between objects, whereas RNN-based structures heavily rely on the output of the long-term memorization. To address the above problems, Fu et al.\cite{Fu_2019_danet} propose a novel framework, called Dual Attention Network(DANet), for natural scene image segmentation. \xtx{Compared with CBAM and BAM, it adopts self-attention mechanism instead of simply stacking convolutions to compute the spatial attention map, which enables the network to capture \gmh{the global information directly}. } DANet adopts two parallel modules including a position attention module and a channel attention module to capture feature dependencies in spatial and channel dimensions respectively. Given the input feature map $X\in \mathbb{R}^{C\times H\times W}$, convolution layers are applied first in the position attention module to obtain new feature maps. Then position attention module selectively aggregates the feature at each position by a weighted sum of the features at all positions, where the weights are decided by the feature similarities between the corresponding two positions. Meanwhile, the channel attention module has a similar form except for dimensional reduction to model cross-channel relations. Finally the outputs from two branches are fused to obtain better feature representations.For the sake of simplicity, we reshape the feature map $X$ into $C\times (H\cdot W)$ and the overall process can be written as follow \begin{align} Q,K,V &= W_qX, W_kX,W_vX \\ Y^\text{pos} &= X+ V\text{Softmax}(Q^TK) \\ Y^\text{chn} &= X+ \text{Softmax}(XX^T)X \\ Y &= Y^\text{pos} + Y^\text{chn} \end{align} Here $W_q, W_k, W_v \in \mathbb{R}^{C\times C}$ are used for generating new feature maps. Position attention module enables DANet to capture long-range contextual information and adaptively integrate similar features at any scale from a global view, while the channel attention module is responsible for enhancing useful channels as well as suppressing noise. \gmh{Taking} spatial and channel relationships into consideration explicitly \gmh{improves} feature representation for scene segmentation. \gmh{However, It brings computational overhead especially when the size of the input feature map is large.} \subsubsection{RGA} \xtx{ Different from Coordinate attention and DANet, which put emphasis on capturing long-range context, Zhang et al.~\cite{zhang2020relation} propose RGA which stresses the importance of global structural information provided by pairwise relations, and leverages them to produce attention maps. } RGA can be categorized into two different types, named Spatial Relation-aware Global Attention (RGA-S) and Channel Relation-aware Global Attention (RGA-C). For RGA-S, it first reshapes the input feature map $X\in \mathbb{R}^{C\times H\times W}$ into $C\times (H\times W)$ and the pairwise relation matrix $R \in \mathbb{R}^{(H\times W)\times (H\times W)}$ can be defined as \begin{align} Q &= \delta(W^QX) \\ K &= \delta(W^KX) \\ R &= Q^TK \end{align} Thus the relation vector $r_i$ on position $i$ are defined by stacking the pairwise relations with all the positions \begin{align} r_i = [R(i, :); R(:,i)] \end{align} and the spatial relation-aware feature $y_i$ can be written as follow \begin{align} Y_i = [g^c_\text{avg}(\delta(W^\varphi x_i)); \delta(W^\phi r_i)] \end{align} Here $g^c_\text{avg}$ denotes global average pooling operation along the channel dimension. Finally, the spatial attention score of position $i$ can be defined as \begin{align} a_i = \sigma(W_2\delta(W_1y_i)) \end{align} RGA-C has the same form as RGA-S, except for taking the input feature map as a set of $H\times W$-dimensional features. RGA leverages the global scope relations to generate the attention score for each feature node, which contains valuable structural information and significantly enhances the representational power. RGA-S and RGA-C can be plugged into any CNN network for their flexibility and Zhang et al. proposes to jointly use them in sequence for better capturing both inter-spatial and cross-channel relationships. \subsubsection{Self-Calibrated Convolutions} Motivated by the success of group convolution, Liu et at~\cite{Liu_2020_scnet} present self-calibrated convolution to enlarge the receptive field for each spatial location. The self-calibrated convolution has two parts self-calibrated convolution part and standard convolution part. It first divide input feature $X$ into $X_{1}$ and $X_{2}$ from the channel dimension. In the self-calibrated convolution part, it first uses the average pooling to reduce the input size and enlarge receptive field as: \begin{align} T_{1} = \text{AvgPool}_{r}(X_{1}) \end{align} where $r$ is the filter size and stride. Then a convolution is adopted to model the channel relationship and a bilinear interpolation operator $Up$ is used to upsample feature map as: \begin{align} X'_{1} = \text{Up}(\text{Conv}_2(T_{1})) \end{align} After that, it applies an element-wise multiplication to finish the self-calibrated process as: \begin{align} Y'_{1} = \text{Conv}_3(X_{1}) \cdot \sigma(X_{1} + X'_{1}) \end{align} Finally, the output feature map of self-calibrated convolutions can be formed as \begin{align} Y_{1} &= \text{Conv}_4(Y'_{1}) \\ Y_2 &= \text{Conv}_1(X_2) \\ Y &= [Y_1; Y_2] \end{align} The proposed self-calibrated convolution can enlarge the receptive field of the network and improve the adaptability of the network. It achieves great results on image classification and some downstream tasks e.g., instance segmentation, object detection and keypoint detection. \subsubsection{SPNet} The existing spatial pooling usually operates on a small grid region which limits the capability to capture long-range dependency and focus on some unrelated region. To address the above issues, Hou et al.~\cite{hou2020strip} propose a novel pooling method Strip Pooling, which is capable of encoding long-range context along either the horizontal or vertical spatial dimensions. Strip Pooling can be divided into two branches, named horizontal strip pooling and vertical strip pooling. In the horizontal strip pooling part, it first pools the input feature $F \in \mathcal{R}^{C \times H \times W}$ in the horizontal direction which can be written as: \begin{align} y^1 = g_\text{avg}^w (X) \end{align} Then a 1D convolution with kernel size 3 is applied on the y to capture the relation between different rows and channels. Next, it repeats $W$ times to make it consistent with the input shape and get the output $y_v$. Formally, it can be expressed as follow \begin{align} y_h = \text{Expand}(\text{Conv1D}(y^1)) \end{align} Similarly, it obtains the output of vertical strip pooling $y_{v}$ via the mirroring approach. Finally, it fuses the outputs from two branches using element-wise summation to produce the attention map and the final process can be formulated as: \begin{align} s &= \sigma(\text{Conv}^{1\times 1}(y_{v} + y_{h})) \\ Y &= s \cdot X \end{align} Based on Strip Pooling Module (SPM), it further presents a Mixed Pooling module (MPM). Both them consider the spatial relationship and channel relationship and alleviate the locality of convolutional neural networks. The SPNet achieves the state-of-the-art result on several complex semantic segmentation benchmarks. \subsubsection{SCA-CNN} \gmh{mark...} As CNN features are naturally spatial, channel-wise and multi-layer, Chen et al.\cite{ChenZXNSLC17} propose a novel Spatial and Channel-wise Attention-based Convolutional Neural Network(SCA-CNN) that introduces Spatial and Channel-wise Attentions into a CNN. SCA-CNN is designed for the task of image captioning, and has an encoder-decoder framework where a CNN first encodes an input image into a vector and then an LSTM decodes the vector into a sequence of words. Given an input feature map $X\in \mathbb{R}^{C\times H\times W}$ and the previous time step LSTM hidden state $h_{t-1} \in \mathbb{R}^d$, spatial attention attempts to pay more attention to the semantic-related regions, which is guided by LSTM hidden state $h_{t-1}$. The definitions of the spatial attention model are written as follow \begin{align} a(h_{t-1}, X) &= \tanh(\text{Conv}^{1\times1}_1(X)\oplus W_1h_{t-1}) \\ \Phi_s(h_{t-1}, X) &= \text{Softmax}(\text{Conv}^{1\times1}_2(a(h_{t-1}, X))) \end{align} where $\oplus$ represents the addition of a matrix and a vector. Similar to spatial attention, channel-wise attention aggregates global information first, and then computes the channel-wise attention weight vector with the hidden state $h_{t-1}$ \begin{align} b(h_{t-1}, X) &= \tanh((W_2g_\text{avg}(X)+b_2)\oplus W_1h_{t-1}) \\ \Phi_c(h_{t-1}, X) &= \text{Softmax}(W_3(b(h_{t-1}, X))+b_3) \end{align} Finally, the proposed SCA mechanism can be written as Eq \ref{eq_cs_sca} where channel-wise attention is applied before spatial attention, or Eq \ref{eq_sc_sca} with spatial attention implemented first \begin{align} \label{eq_cs_sca} Y &= f(X,\Phi_s(h_{t-1}, X\cdot \Phi_c(h_{t-1}, X)), \Phi_c(h_{t-1}, X)) \\ \label{eq_sc_sca} Y &= f(X,\Phi_s(h_{t-1}, X), \Phi_c(h_{t-1}, X\cdot \Phi_s(h_{t-1}, X))) \end{align} Different from previous attention mechanisms which consider each image region equally and use global spatial information to tell the network where to focus, SCA-Net leverages the semantic vector to produce the spatial attention map as well as the channel-wise attention weight vector. More than a powerful attention model, SCA-CNN also provides a better understanding of where and what the model focus on during sentence generation. \subsubsection{GALA} Most previous advents in attention mechanisms learn where to focus using only weak supervisory signals from class labels, which inspires Linsley et al.\cite{LinsleySES19} to investigate how explicit human supervision affects the performance and interpretability of attention models. As a proof of concept, Linsley et al. proposes the global-and-local attention (GALA) module, which extends SE block with spatial attention mechanism. Given the input feature map $X \in \mathbb{R}^{C\times H\times W}$, GALA uses an attention mask that combines global attention and local attention to tell the network where and what to focus. Same as SE blocks, the global attention aggregates global information by global average pooling and then produces a channel-wise attention weight vector using a multilayer perceptron. In local attention, two consecutive $1\times 1$ convolutions are conducted on the input to produce a position-wise weight map. Finally, outputs from the local and global pathways are integrated by addition and multiplication. Formally, GALA can be represented as follow \begin{align} s_g &= W_{2} \delta (W_{1}g_\text{avg}(x)) \\ s_l &= \text{Conv}_2^{1\times 1} (\delta(\text{Conv}_1^{1\times1}(X))) \\ s_g^* &= \text{Expand}(s_g) \\ s_l^* &= \text{Expand}(s_l) \\ s &= \tanh(a \cdot (s_g^*+s_l^*)+m\cdot (s_g^*\cdot s_l^*)) \\ Y &= s\cdot X \end{align} where $a,m \in \mathbb{R}^{C}$ are learnable parameters representing channel-wise weight vectors. Supervised by human-derived feature importance maps, GALA significantly improves the representational power and can incorporate with any state-of-the-art CNN backbones. \subsection{Spatial \& Temporal Attention} Spatial \& temporal attention combines the advantages of spatial attention and temporal attention. It both adaptively selects important regions and key frames. \xtx{ Some of previous works\cite{song2016end,rstan} compute temporal attention and spatial attention separately, while other works\cite{Fu_2019_STA} jointly produce spatial and temporal attention map together. Besides, there are also some works focusing on capturing pair-wise relations\mtj{~\cite{yang2020spatial}}.} In this subsection, we first summarize the representative spatial \& temporal attention attentions in Tab.~\ref{spatial_temporal_attentions}. Then we discuss various spatial \& temporal attentions \gmh{according to the order in Fig.~\ref{fig:total_attention_summary}}. \begin{table*} \centering \caption{Summary of representative spatial \& temporal attentions sorted by publication time. Publication=First publication, Cls = Classification, FGCls=Fine-Grain Classification, Det=Detection, SSeg=Semantic Segmentation, ISeg=Instance Segmentation, ST=Style Transfer, Action=Action Recognition.} \setlength{\tabcolsep}{1.5pt} \label{spatial_temporal_attentions} \begin{tabular}{lcccc} \toprule \textbf{Method} & \textbf{Publication} & \textbf{Experiments} & \textbf{Description of the attention process} & \textbf{Function of attention process} \\ \midrule STA-LSTM\cite{song2016end} & AAAI2017 & Action &\makecell[l]{a)use a sub-network to produce the spatial attention map.\\ b) aggregate spatial information by using spatial attention.\\c)use a sub-network to produce the temporal attention map. \\d)aggregate temporal information. } & \makecell[l]{emphasize key joints along both \\ spatial and temporal dimensions } \\ \midrule RSTAN\cite{rstan} & TIP2018 & Action &\makecell[l]{a)produce spatial attention map for each frame using previous\\ hidden state\\b)aggregate spatial information into frame-wise features\\c)produce temporal attention map using previous hidden state\\d)aggregate global information} & \makecell[l]{a)emphasize important regions along \\ both spatial and temporal dimensions\\b)capture global information} \\ \midrule STA\cite{Fu_2019_STA} & AAAI2019 & ReID &\makecell[l]{a)produce frame-wise attention map using l2 norm\\b)obtain spatial scores for each patch by summation and l1 norm\\c)aggregate global information along the temporal dimension} & \makecell[l]{a)emphasize important regions along \\ both spatial and temporal dimensions\\b)alleviate the occlusion problem in \\ video-based ReID} \\ \midrule STGCN\cite{yang2020spatial} & CVPR2020 & ReID &\makecell[l]{a)partition each frame into patches \\b)flatten spatial and temporal dimensions and construct a patch \\ graph using pairwise similarity\\c)apply graph convolutions on the patch graph} & \makecell[l]{Same as STA} \\ \bottomrule \end{tabular} \end{table*} \subsubsection{STA-LSTM} \xtx{\gmh{A prior~\cite{song2016end} is that} a type of action is generally only connected with a few specific kinematic joints \gmh{in} action recognition. Besides, the flow of action may go through more than one stage.} Motivated by this observation, Song et al.~\cite{song2016end} propose a joint spatial and temporal attention network based on the LSTM~\cite{HochSchm97_lstm} to mining discriminative features and keyframes adaptively. The main attention-related components are the spatial attention sub-network and the temporal attention sub-network. The goal of the spatial attention sub-network is to select important regions and the purpose of the temporal attention sub-network is to select key frames. The spatial attention sub-network can be written as: \begin{align} s_{t} &= U_{s}\tanh(W_{xs}X_{t} + W_{hs}h_{t-1}^{s} + b_{si}) + b_{so} \\ \alpha_{t} &= \text{Softmax}(s_{t}) \\ Y_{t} &= \alpha_{t} \cdot X_{t} \end{align} where $X_{t}$ is the input feature at step t. $U_{s}$, $W_{hs}$, $b_{si}$, and $b_{so}$ are the learnable parameters. $h_{t-1}^{s}$ is the hidden state at step $t-1$. It is worth noting that due to the existence of hidden state h, the attention process takes the temporal relationship into consideration. As for the temporal attention sub-network, it is similar to the spatial branch and produce the attention map as: \begin{align} \beta_{t} = \delta(W_{xp}X_{t} + W_{hp}h_{t-1}^{p} + b_{p}). \end{align} It adopts a ReLU function instead of a normalization function for its easy-to-optimize property. Meanwhile, it also presents a regularized objective function to make the network converge better. Totally, this paper presents a joint spatial and temporal attention method to focus on important joints and keyframes which achieves great results on the action recognition task. \subsubsection{RSTAN} To capture the spatial-temporal context among video frames, Du et al.~\cite{rstan} introduce spatial-temporal attention to adaptively identify key features from the global context. The spatial-temporal attention mechanism in RSTAN consists of spatial attention module and temporal attention module stacked in serial. Given the input feature map $X\in \mathbb{R}^{D\times T\times H\times W}$ and the previous hidden state $h_{t-1}$ of RNN model, spatial-temporal attention aims to produce a spatial-temporal feature representation for action recognition. First, the given feature map $X$ is reshaped into $\mathbb{R}^{D\times T\times (H\times W)}$, and we define $X(n,k)$ as the feature vector at the $k$-th location of the $n$-th frame. The spatial attention mechanism at $t$-th step aims to produce a global feature $l_n$ for each frame, which can be formally written as \begin{align} \alpha_t(n,k) &= w_\alpha \cdot \tanh(W_hh_{t-1}+W_{x}X(n,k)+b_\alpha) \\ \alpha_t^*(n,k) &= \frac{e^{\gamma_\alpha\alpha_t(n,k)}}{\sum_{j=1}^{W\times H}e^{\gamma_\alpha\alpha_t(n,k)}} \\ l_n &= \sum_{k=1}^{H\times W}\alpha_t^*(n,k) X(n,k) \end{align} where $\gamma_\alpha$ is introduced to control the sharpness of the location-score map. After obtaining the frame-wise features $\{l_1,...l_T\}$, RSTAN introduces a temporal attention mechanism to estimate the importance of each frame feature \begin{align} \beta_t(n) &= w_\beta \cdot \tanh(W_h'h_{t-1}+W_{l}l(n)+b_\beta) \\ \beta_t^*(n) &= \frac{e^{\gamma_\beta\beta_t(n)}}{\sum_{j=1}^{T}e^{\gamma_\beta\beta_t(n)}} \\ \phi_t &= \sum_{n=1}^{T}\beta_t^*(n) l(n) \end{align} The spatial-temporal attention mechanism used in RSTAN plays a role of identifying important regions in both spatial and temporal dimensions which are strongly relative to the prediction at the current step of RNN. It can efficiently enhance the representation power of the model and be incorporated with any 2D CNNs. \subsubsection{STA} Previous attention-based methods on video-based person re-identification only assign an attention weight to each frame and lack of capturing jointly spatial and temporal relationships. To address this issue, Fu et al.~\cite{Fu_2019_STA} propose a novel Spatial-Temporal Attention(STA) approach, which assigns attention scores for each spatial region from different frames without any extra parameters. Given the feature maps of an input video $\{X_n|X_n\in \mathbb R^{C\times H\times W}\}_{n=1}^N$, STA first generate the frame-wise attention map by operating the l2 norm on the square sum along the channel dimension \begin{align} g_n(h,w) = \frac{||\sum_{c=1}^C X_n(c,h,w)^2||_2}{\sum_{h=1}^H \sum_{w=1}^W ||\sum_{c=1}^C X_n(c,h,w)^2||_2} \end{align} Then both the feature maps and attention maps are divided into $K$ local regions horizontally, each of which represents one part of the person. The spatial attention score for region $k$ is obtained by \begin{align} s_{n,k} = \sum_{(i,j)\in \text{Region}_k}||g_n(i,j)||_1 \end{align} To capture the relationship between regions from different frames, STA applies the l1 normalization on the attention scores along the temporal dimensions, written as follow \begin{align} S(n,k) = \frac{s_{n,k}}{\sum_{n=1}^N ||s_{n,k}||_1} \end{align} Finally, STA splits the input feature map $X_i$ into $K$ regions $\{X_{n,1},...X_{n,K}\}$ and the output of STA can be written as \begin{align} Y^1 &= [X_{\arg\max_{n}S(n,1),1};...;X_{\arg\max_{n}S(n,K),K}] \\ Y^2 &= [\sum_{n=1}^N S(n,1)X_{n,1};...;\sum_{n=1}^N S(n,K)X_{n,K}] \\ Y &= [Y^1;Y^2] \end{align} Instead of computing spatial attention maps frame by frame, STA considers the spatial and temporal attention information simultaneously, completely using the discriminative parts in both dimensions and weaken the influence of occlusion. Because of its non-parametric design, STA can tackle the input video sequence in variable lengths by combining any 2D CNN backbones. \subsubsection{STGCN} To model the spatial relations within a frame and temporal relations across frames, Yang et al.\cite{yang2020spatial} proposes a novel Spatial-Temporal Graph Convolutional Network (STGCN) to learn a discriminative descriptor for each video. It constructs the patch graph using pairwise similarity, and then adopts graph convolution to aggregate information. STGCN includes two parallel GCN branches, named Temporal Graph Module and Structural Graph Module. Given the feature maps of a video, STGCN first horizontally partitions each frame into $P$ patches and applies average pooling to generate patch-wise features ${x_1...x_N}$, where the total number of patches is $N=T\cdot P$. For the temporal one, it takes each patch as a graph node and construct a patch graph for the video, where the adjacency matrix $\widehat{A}$ is obtained by applying normalization operations on the pairwise relation matrix $E$, defined as \begin{align} E(i,j) &= (W^\phi x_i)^T W^\phi x_j \\ A(i,j) &= \frac{E^2(i,j)}{\sum_{j=1}^N E^2(i,j)} \\ \widehat{A} &= D^{-\frac{1}{2}}(A+I)D^{-\frac{1}{2}} \end{align} where $D(i,i) = \sum_{j=1}^N (A+I)(i,j)$. Given the adjacent matrix $\widehat{A}$, the $m$-th graph convolution can be implemented as \begin{align} X^m = \widehat{A} X^{m-1} W^m + X^{m-1} \end{align} where $X \in \mathbb{R}^{N \times c}$ represents the hidden features for all patches and $W^m \in \mathbb{R}^{c\times c}$ denotes the learnable weight matrix of $m$-th layer. On the other hand, for the spatial branch, STGCN follows a similar definition of adjacent matrix and graph convolution, except for modeling the spatial relations of different regions within a frame. Flattening spatial and temporal dimensions into a sequence, STGCN applies the GCN to capture the spatial-temporal relations of the patches across the different frames. Pairwise attention is used to obtain the weighted adjacent matrix. By leveraging spatial and temporal relationships between patches, STGCN alleviates the occlusion problem while also enhancing informative features. It can be incorporated with any state-of-the-art CNN backbones to process the video. \section{Directions} \label{sec:direction} In this section, we present a perspective about potential research directions. \subsection{General attention block} At the moment, a special attention mechanism needs to be designed for different tasks which takes a lot of time to explore potential attention methods. For instance, channel attention is a good choice for the image classification task while self-attention is well-suited for dense prediction tasks e.g., semantic segmentation and object detection. Meanwhile, channel attention focuses on "what to attend" while spatial attention pays attention to "where to attend". Based on this observation, we consider whether there is a general attention block that takes advantage of all kinds of attention mechanisms. For example, we can build a soft selection mechanism(branch attention) between channel attention, spatial attention and temporal attention according to the specific task. \subsection{Interpretability} The attention mechanism is motivated by the human visual system and aims to build an interpretable computer vision system. Now we usually understand attention-based models by visualizing attention map such as Fig.~\ref{fig:attention_map_vit}. However, this way can only give us intuitive feelings rather than mathematical or neuroscience explanations which limits it to be used in some scenarios with high security requirements e.g., medical diagnostic and automatic driving systems. In summary, developing an interpretable attention model can make them used more widely. \subsection{Attention-based pre-trained models} Large-scale attention-based pre-trained models have realized great success in natural language processing~\cite{brown2020language, bao2021beit}. Recently, MoCoV3~\cite{chen2021empirical_mocov3}, DINO~\cite{caron2021emerging} and BEiT~\cite{bao2021beit} demonstrate that attention-based models also achieve amazing performance in visual tasks. Due to its adaptive property according to the varying input, attention-based models are capable to deal with unseen objects and naturally suit for transferring the pre-trained weight to various tasks. Based on the above analysis, we believe that the combination of pre-training and attention model is appropriate and the training manners, model structures, pre-training tasks and the scale of data are all worth exploring. \subsection{Optimizer} SGD~\cite{qian99_sgd} and Adam~\cite{kingma2017adam} are well-suited for optimizing convolutional neural networks. For visual transformers, AdamW~\cite{loshchilov2019decoupled} has a better performance. Recently, Chen et al.~\cite{chen2021vision} significantly improve visual transformers by using a novel optimizer sharpness-aware minimizer(SAM)~\cite{foret2021sharpnessaware}. We know that attention-based networks and convolutional neural networks are different models, so we should consider different optimization methods for different models to find their optimal solutions respectively. \subsection{Deployment} Convolutional neural networks own a simple and uniform structure which makes them friendly to deploy on various hardware devices. However, it is difficult to optimize complex and various attention-based models on edge devices. Meanwhile, experiments in ~\cite{liu2021swin, wu2021cvt, yuan2021volo} show that attention-based models present a better performance than convolutional neural networks. Based on the above reasons, a simple, efficient and effective attention-based model is worth looking forward to. \section{conclusion} \label{sec:conclusion} Attention mechanism has become an indispensable part\tjc{technique} in the field of computer vision \mtj{in the era of deep learning}. In this \mtj{survey}, we systematically review and summarize the attention mechanisms \mtj{adopted in deep neural networks} in computer vision. \gmh{We groups different attention methods according to \mtj{the} dimension \mtj{the attention mechanism operating on}. Under this taxonomy, we link various attention methods in different tasks as a whole and present that attention models can be regarded as an independent topic rather than a supplement to other topics. Furthermore, we propose some potential directions for this topic. } We hope that this survey can give relevant researchers a deeper understanding of the attention mechanism and \gmh{facilitate} the development of related fields. In addition, we also expect that this work can enable more people to understand and use the attention mechanism proficiently to improve their works. \ifCLASSOPTIONcompsoc \section*{Acknowledgments} This work was supported by the Natural Science Foundation of China (Project 61521002), \else \section*{Acknowledgment} \fi \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran} \section{Introduction}\label{sec:introduction}} \IEEEPARstart{M}{ethods} for diverting attention to the most important regions of an image and disregarding irrelevant parts are called attention mechanisms; the human visual system uses one~\cite{saliency_attention, hayhoe2005eye, rensink2000dynamic, corbetta2002control} to assist in analyzing and understanding complex scenes efficiently and effectively. This in turn has inspired researchers to introduce attention mechanisms into computer vision systems to improve their performance. In a vision system, an attention mechanism can be treated as a dynamic selection process that is realized by adaptively weighting features according to the importance of the input. Attention mechanisms have provided benefits in very many visual tasks, e.g.\ image classification~\cite{senet, woo2018cbam}, object detection~\cite{dai2017deformable, carion2020endtoend_detr}, semantic segmentation~\cite{YuanW18_ocnet, Fu_2019_danet}, face recognition~\cite{yang2017neural, Wang_2020_CVPR_face}, person re-identification~\cite{li2018harmonious, chen2019mixed}, action recognition~\cite{Wang_2018_nonlocal, rstan}, few-show learning~\cite{Peng_2018_few_shot, he2017single}, medical image processing~\cite{oktay2018attention, guan2018diagnose}, image generation~\cite{gregor2015draw, zhang2019sagan}, pose estimation~\cite{chu2017multicontext}, super resolution~\cite{sr_1, zhang2018image}, 3D vision~\cite{Xie_2018_acnn, Guo_2021_pct}, and multi-modal task~\cite{su2020vlbert, xu2017attngan}. \begin{figure}[t!] \centering \includegraphics[width=\linewidth]{attention_cls_graph.pdf} \caption{ Attention mechanisms can be categorised according to data domain. These include four fundamental categories of channel attention, spatial attention, temporal attention and branch attention, and two hybrid categories, combining channel \& spatial attention and spatial \& temporal attention. $\emptyset$ means such combinations do not (yet) exist. } \label{fig:attention_category} \end{figure} \begin{figure}[t] \centering \includegraphics[width=\linewidth]{attention_dims.pdf} \caption{ Channel, spatial and temporal attention can be regarded as operating on different domains. $C$ represents the channel domain, $H$ and $W$ represent spatial domains, and $T$ means the temporal domain. Branch attention is complementary to these. Figure following~\cite{wu2018group}. } \label{fig:attention_apply_dims} \end{figure} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{attention_timeline_3.pdf} \caption{ Brief summary of key developments in attention in computer vision, which have loosely occurred in four phases. Phase 1 adopted RNNs to construct attention, a representative method being RAM~\cite{mnih2014recurrent}. Phase 2 explicitly predicted important regions, a representative method being STN~\cite{jaderberg2016spatial}. Phase 3 implicitly completed the attention process, a representative method being SENet~\cite{senet}. Phase 4 used self-attention methods~\cite{Wang_2018_nonlocal, vaswani2017attention, dosovitskiy2020vit}. } \label{fig:timeline} \end{figure*} \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{total_attention_summary.pdf} \caption{Developmental context of visual attention. } \label{fig:total_attention_summary} \end{figure*} In the past decade, the attention mechanism has played an increasingly important role in computer vision; Fig.~\ref{fig:timeline}, briefly summarizes the history of attention-based models in computer vision in the deep learning era. Progress can be coarsely divided into four phases. The first phase begins from RAM~\cite{mnih2014recurrent}, pioneering work that combined deep neural networks with attention mechanisms. It recurrently predicts the important region and updates the whole network in an end-to-end manner through a policy gradient. Later, various works~\cite{gregor2015draw, xu2015show} adopted a similar strategy for attention in vision. In this phase, recurrent neural networks(RNNs) were necessary tools for an attention mechanism. At the start of the second phase, Jaderberg et al.~\cite{jaderberg2016spatial} proposed the STN which introduces a sub-network to predict an affine transformation used to to select important regions in the input. Explicitly predicting discriminatory input features is the major characteristic of the second phase; DCNs~\cite{dai2017deformable,Zhu_2019_CVPR_dcnv2} are representative works. The third phase began with SENet~\cite{senet} that presented a novel channel-attention network which implicitly and adaptively predicts the potential key features. CBAM~\cite{woo2018cbam} and ECANet~\cite{Wang_2020_ECA} are representative works of this phase. The last phase is the self-attention era. Self-attention was firstly proposed in~\cite{vaswani2017attention} and rapidly provided great advances in the field of natural language processing~\cite{vaswani2017attention,devlin2019bert, yang2020xlnet}. Wang et al.~\cite{Wang_2018_nonlocal} took the lead in introducing self-attention to computer vision and presented a novel non-local network with great success in video understanding and object detection. It was followed by a series of works such as EMANet~\cite{li19ema}, CCNet~\cite{huang2020ccnet}, HamNet~\cite{ham} and the Stand-Alone Network~\cite{ramachandran2019standalone}, which improved speed, quality of results, and generalization capability. Recently, various pure deep self-attention networks (visual transformers)~\cite{dosovitskiy2020vit, yuan2021tokens, wang2021pyramid, liu2021swin, wu2021cvt, Guo_2021_pct, yuan2021volo, dai2021coatnet} have appeared, showing the huge potential of attention-based models. It is clear that attention-based models have the potential to replace convolutional neural networks and become a more powerful \mtj{and} general architecture in computer vision. The goal of this paper is to summarize and classify current attention methods in computer vision. Our approach is shown in Fig.~\ref{fig:attention_category} and further explained in Fig.~\ref{fig:attention_apply_dims}: it is based around data domain. Some methods consider the question of \emph{when} the important data occurs, or others \emph{where} it occurs, etc., and accordingly try to find key times or locations in the data. We divide existing attention methods into six categories which include four basic categories: channel attention (\emph{what to pay attention to}~\cite{ChenZXNSLC17}), spatial attention (\emph{where to pay attention}), temporal attention (\emph{when to pay attention}) and branch channel (\emph{which to pay attention to}), along with two hybrid combined categories: channel \& spatial attention and spatial \& temporal attention. These ideas are further briefly summarized together with related works in Tab.~\ref{Tab_attentions_category}. The main contributions of this paper are: \begin{itemize} \item a systematic review of visual attention methods, covering the unified description of attention mechanisms, the development of visual attention mechanisms as well as current research, \item a categorisation grouping attention methods according to their data domain, allowing us to link visual attention methods independently of their particular application, and \item suggestions for future research in visual attention. \end{itemize} Sec.~\ref{sec:relatedWork} considers related surveys, then Sec.~\ref{sec:detailedReview} is the main body of our survey. Suggestions for future research are given in Sec.~\ref{sec:direction} and finally, we give conclusions in Sec.~\ref{sec:conclusion}. \begin{table}[!t] \centering \caption{Key notation in this paper. Other minor notation is explained where used.} \label{Tab.notation_defination} \begin{tabular}{ll} \hline \textbf{Symbol} & \textbf{Description} \\ \hline $X$ & input feature map, $X \in \mathbb{R}^{C\times H\times W}$\\ $Y$ & output feature map \\ $W$ & learnable kernel weight \\ $\text{FC}$ & fully-connected layer \\ $\text{Conv}$ & convolution \\ $\text{GAP}$ & global average pooling \\ $\text{GMP}$ & global max pooling \\ $[\quad]$ & concatenation \\ $\delta$ & ReLU activation~\cite{relu} \\ $\sigma$ & sigmoid activation \\ $\tanh$ & tanh activation \\ $\text{Softmax}$ & softmax activation \\ $\text{BN}$ & batch normalization~\cite{ioffe2015batch} \\ $\text{Expand}$ & expan input by repetition \\ \hline \end{tabular} \end{table} \begin{table*} \centering \caption{Brief summary of attention categories and key related works.} \label{Tab_attentions_category} \begin{tabular}{|p{3cm}|p{7cm}|p{6cm}|} \hline \textbf{Attention category} & \textbf{Description} & \textbf{Related work} \\ \hline Channel attention & {Generate attention mask across the channel domain and use it to select important channels. } & {~\cite{senet, zhang2018encnet, gsopnet, lee2019srm, yang2020gated ,Wang_2020_ECA, qin2021fcanet, diba2019spatiotemporal} ~\cite{chen2019look,shi2020spsequencenet, zhang2018image}} \\ \hline Spatial attention & {Generate attention mask across spatial domains and use it to select important spatial regions (e.g.~\cite{Wang_2018_nonlocal, hu2019gatherexcite}) or predict the most relevant spatial position directly (e.g.~\cite{mnih2014recurrent, dai2017deformable})}. & {~\cite{mnih2014recurrent, gregor2015draw, xu2015show, jaderberg2016spatial, Wang_2018_nonlocal, dosovitskiy2020vit, carion2020endtoend_detr, YuanW18_ocnet} ,~\cite{Xie_2018_acnn, yan2020pointasnl, hu2018relation, Zhang_2019_cfnet, zhang2019sagan, Bello_2019_ICCV_AANet, zhu2019empirical, Li_2020_sprr} ,~\cite{huang2020ccnet, ann, cao2019GCNet, chen2018a2nets, chen2018glore, zhang2019latentgnn, yuan2021segmentation_ocr, yin2020disentangled} ,~\cite{ham, external_attention, ramachandran2019standalone, hu2019lrnet, Zhao_2020_SAN, pmlr-v119-chen20s-igpt, carion2020endtoend_detr, dosovitskiy2020vit} ,~\cite{Guo_2021_pct, chen2021pretrained_ipt, zhao2020pointtransformer, yuan2021tokens, SETR, wang2021pyramid, han2021transformer_tnt, liu2021swin} ,~\cite{liu2021query2label, chen2021empirical_mocov3, bao2021beit, xie2021segformer, hu2019gatherexcite, Zhao_2018_psanet, ba2015multiple, sharma2016action} ,~\cite{girdhar2017attentional, li2016videolstm, yue2018compact,liu2019l2g,paigwar2019attentional,wen2020cf,yang2019modeling, wu2021cvt} ,~\cite{xu2018attention,liu2017end,zheng2018pedestrian, li2018tell,zhang2020relation,xia2019second,zhao2017diversified,zheng2017learning} ,~\cite{fu2017look, anonymous2022dabdetr, yang2021sampling, zheng2019looking, lee2019settransformer, guan2018diagnose} }\\ \hline Temporal attention & {Generate attention mask in time and use it to select key frames.} & {~\cite{xu2017jointly,zhang2019scan,chen2018video}} \\ \hline Branch attention & {Generate attention mask across the different branches and use it to select important branches.} & {~\cite{srivastava2015training, li2019selective, zhang2020resnest, chen2020dynamic}} \\ \hline Channel \& spatial attention & {Predict channel and spatial attention masks separately (e.g.~\cite{woo2018cbam, park2018bam}) or generate a joint 3-D channel, height, width attention mask directly (e.g.~\cite{pmlr-v139-simam, wang2017residual}) and use it to select important features.} & {~\cite{woo2018cbam, park2018bam, wang2017residual, Liu_2020_scnet, misra2021rotate, ChenZXNSLC17, LinsleySES19}, ~\cite{roy2018recalibrating, Fu_2019_danet, hou2020strip, zhang2020relation, pmlr-v139-simam,you2018pvnet,xie2020mlcvnet} ,~\cite{wang2018mancs,chen2019mixed,chen2019abd, hou2021coordinate, li2018harmonious}} \\ \hline Spatial \& temporal attention & {Compute temporal and spatial attention masks separately (e.g.~\cite{song2016end,rstan}), or produce a joint spatiotemporal attention mask (e.g.~\cite{Fu_2019_STA}), to focus on informative regions.} & {~\cite{gao2019hierarchical,STAT, song2016end, meng2019interpretable, he2021gta,li2018diversity},~\cite{zhang2020multi,shim2020read, liu2021decoupled}} \\ \hline \end{tabular} \end{table*} \section{Other surveys} \label{sec:relatedWork} In this section, we briefly compare this paper to various existing surveys which have reviewed attention methods and visual transformers. Chaudhari et al.~\cite{chaudhari2021attentive} provide a survey of attention models in deep neural networks which concentrates on their application to natural language processing, while our work focuses on computer vision. Three more specific surveys~\cite{xu2022transformers, han2021survey, khan2021transformers} summarize the development of visual transformers while our paper reviews attention mechanisms in vision more generally, not just self-attention mechanisms. Wang et al.~\cite{wang2016survey} present a survey of attention models in computer vision, but it only considers RNN-based attention models, which form just a part of our survey. In addition, unlike previous surveys, we provide a classification which groups various attention methods according to their data domain, rather than according to their field of application. Doing so allows us to concentrate on the attention methods in their own right, rather than treating them as supplementary to other tasks. \section{Attention methods in computer vision} \label{sec:detailedReview} \gmh{In this section, we first sum up a general form for the attention mechanism based on the recognition process of human visual system in Sec.~\ref{sec:general}.} Then we review various categories of attention models given in Fig.~\ref{fig:attention_category}, with a subsection dedicated to each category. In each, we tabularize representative works for that category. We also introduce that category of attention strategy more deeply, considering its development in terms of motivation, formulation and function. \subsection{\gmh{General form}} \label{sec:general} \gmh{ When seeing a scene in our daily life, we will focus on the discriminative regions, and process these regions quickly. The above process can be formulated as: } \begin{align} \label{eq_general} Attention = f(g(x), x) \end{align} \gmh{ Here $g(x)$ can represent to generate attention which corresponds to the process of attending to the discriminative regions. $f(g(x),x)$ means processing input $x$ based on the attention $g(x)$ which is consistent with processing critical regions and getting information. } \gmh{ With the above definition, we find that almost all existing attention mechanisms can be written into the above formulation. Here we take self-attention~\cite{Wang_2018_nonlocal} and squeeze-and-excitation(SE) attention~\cite{senet} as examples. For self-attention, $g(x)$ and $f(g(x), x)$ can be written as } \begin{align} Q, K, V & = \text{Linear}(x) \\ g(x) & = \text{Softmax}(QK) \\ f(g(x), x) & = g(x) V \\ \end{align} For SE, $g(x)$ and $f(g(x), x)$ can be written as \begin{align} g(x) & = \text{Sigmoid(MLP(GAP}(x))) \\ f(g(x), x) & = g(x) x \end{align} In the following, we will introduce various attention mechanisms and specify them to the above formulation. \subsection{Channel Attention} In deep neural networks, different channels in different feature maps usually represent different objects~\cite{ChenZXNSLC17}. Channel attention adaptively recalibrates the weight of each channel, and can be viewed as an object selection process, thus determining \emph{what to pay attention to}. Hu et al.~\cite{senet} first proposed the concept of channel attention and presented SENet for this purpose. As Fig.~\ref{fig:total_attention_summary} shows, and we discuss shortly, three streams of work continue to improve channel attention in different ways. In this section, we first summarize the representative channel attention works and specify process $g(x)$ and $f(g(x), x)$ described as Eq.~\ref{eq_general} in Tab.~\ref{Tab_channel_attentions} and Fig.~\ref{fig:channel_attention}. Then we discuss various channel attention methods along with their development process respectively. \subsubsection{SENet} SENet~\cite{senet} pioneered channel attention. The core of SENet is a \emph{squeeze-and-excitation} (SE) block which is used to collect global information, capture channel-wise relationships and improve representation ability. SE blocks are divided into two parts, a squeeze module and an excitation module. Global spatial information is collected in the squeeze module by global average pooling. The excitation module captures channel-wise relationships and outputs an attention vector by using fully-connected layers and non-linear layers (ReLU and sigmoid). Then, each channel of the input feature is scaled by multiplying the corresponding element in the attention vector. Overall, a squeeze-and-excitation block $F_\text{se}$ (with parameter $\theta$) which takes $X$ as input and outputs $Y$ can be formulated as: \begin{align} \label{eq_se} s = F_\text{se}(X, \theta) & = \sigma (W_{2} \delta (W_{1}\text{GAP}(X))) \\ Y & = s X \end{align} SE blocks play the role of emphasizing important channels while suppressing noise. An SE block can be added after each residual unit~\cite{resnet} due to their low computational resource requirements. However, SE blocks have shortcomings. In the squeeze module, global average pooling is too simple to capture complex global information. In the excitation module, fully-connected layers increase the complexity of the model. As Fig.~\ref{fig:total_attention_summary} indicates, later works attempt to improve the outputs of the squeeze module (e.g.\ GSoP-Net~\cite{gsopnet}), reduce the complexity of the model by improving the excitation module (e.g.\ ECANet~\cite{Wang_2020_ECA}), or improve both the squeeze module and the excitation module (e.g.\ SRM~\cite{lee2019srm}). \subsubsection{GSoP-Net} An SE block captures global information by only using global average pooling (i.e. first-order statistics), which limits its modeling capability, in particular the ability to capture high-order statistics. To address this issue, Gao et al.~\cite{gsopnet} proposed to improve the squeeze module by using a \emph{global second-order pooling} (GSoP) block to model high-order statistics while gathering global information. Like an SE block, a GSoP block also has a squeeze module and an excitation module. In the squeeze module, a GSoP block firstly reduces the number of channels from $c$ to $c'$ ($c' < c$) using a $1 x 1$ convolution, then computes a $c' \times c'$ covariance matrix for the different channels to obtain their correlation. Next, row-wise normalization is performed on the covariance matrix. Each $(i, j)$ in the normalized covariance matrix explicitly relates channel $i$ to channel $j$. In the excitation module, a GSoP block performs row-wise convolution to maintain structural information and output a vector. Then a fully-connected layer and a sigmoid function are applied to get a $c$-dimensional attention vector. Finally, it multiplies the input features by the attention vector, as in an SE block. A GSoP block can be formulated as: \begin{align} \label{eq_gsop} s = F_\text{gsop}(X, \theta) & = \sigma (W \text{RC}(\text{Cov}(\text{Conv}(X)))) \\ Y & = s X \end{align} Here, $\text{Conv}(\cdot)$ reduces the number of channels, $\text{Cov}(\cdot)$ computes the covariance matrix and $\text{RC}(\cdot)$ means row-wise convolution. By using second-order pooling, GSoP blocks have improved the ability to collect global information over the SE block. However, this comes at the cost of additional computation. Thus, a single GSoP block is typically added after several residual blocks. \subsubsection{SRM} Motivated by successes in style transfer, Lee et al.~\cite{lee2019srm} proposed the lightweight \emph{style-based recalibration module} (SRM). SRM combines style transfer with an attention mechanism. Its main contribution is style pooling which utilizes both mean and standard deviation of the input features to improve its capability to capture global information. It also adopts a lightweight \emph{channel-wise fully-connected} (CFC) layer, in place of the original fully-connected layer, to reduce the computational requirements. Given an input feature map $X \in \mathbb{R}^{C \times H \times W}$, SRM first collects global information by using style pooling ($\text{SP}(\cdot)$) which combines global average pooling and global standard deviation pooling. Then a channel-wise fully connected ($\text{CFC}(\cdot)$) layer (i.e.\ fully connected per channel), batch normalization $\text{BN}$ and sigmoid function $\sigma$ are used to provide the attention vector. Finally, as in an SE block, the input features are multiplied by the attention vector. Overall, an SRM can be written as: \begin{align} \label{eq_srm} s = F_\text{srm}(X, \theta) & = \sigma (\text{BN}(\text{CFC}(\text{SP}(X)))) \\ Y & = s X \end{align} The SRM block improves both squeeze and excitation modules, yet can be added after each residual unit like an SE block. \subsubsection{GCT} Due to the computational demand and number of parameters of the fully connected layer in the excitation module, it is impractical to use an SE block after each convolution layer. Furthermore, using fully connected layers to model channel relationships is an implicit procedure. To overcome the above problems, Yang et al.~\cite{yang2020gated} propose the \emph{gated channel transformation} (GCT) to efficiently collect information while explicitly modeling channel-wise relationships. Unlike previous methods, GCT first collects global information by computing the $l_{2}$-norm of each channel. Next, a learnable vector $\alpha$ is applied to scale the feature. Then a competition mechanism is adopted by channel normalization to interact between channels. Like other common normalization methods, a learnable scale parameter $\gamma$ and bias $\beta$ are applied to rescale the normalization. However, unlike previous methods, GCT adopts tanh activation to control the attention vector. Finally, it not only multiplies the input by the attention vector but also adds an identity connection. GCT can be written as: \begin{align} \label{eq_gct} s = F_\text{gct}(X, \theta) & = \tanh (\gamma CN(\alpha \text{Norm}(X)) + \beta) \\ Y & = s X + X, \end{align} where $\alpha$, $\beta$ and $\gamma$ are trainable parameters. $\text{Norm}(\cdot)$ indicates the $L2$-norm of each channel. $CN$ is channel normalization. A GCT block has fewer parameters than an SE block, and as it is lightweight, can be added after each convolutional layer of a CNN. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{ChannelAttentions.pdf} \caption{ Various channel attention mechanisms. GAP=global average pooling, GMP=global max pooling, FC=fully-connected layer, Cov pool=Covariance pooling, RW Conv=row-wise convolution, CFC=channel-wise fully connected, CN=channel normalization, DCT=discrete cosine transform. } \label{fig:channel_attention} \end{figure*} \begin{table*} \centering \caption{Representative channel attention mechanisms ordered by \gmh{category and} publication date. Their key aims are to emphasize important channels and capture global information. Application areas include: Cls = classification, Det = detection, SSeg = semantic segmentation, ISeg = instance segmentation, ST = style transfer, Action = action recognition.\gmh{$g(x)$ and $f(g(x), x)$ are the attention process described by Eq.~\ref{eq_general}. Ranges means the ranges of attention map. S or H means soft or hard attention.(A) channel-wise product. (\uppercase\expandafter{\romannumeral1}) emphasize important channels, (\uppercase\expandafter{\romannumeral2}) capture global information.}} \label{Tab_channel_attentions} \begin{tabular}{|p{2cm}|p{2cm}|p{1.5cm}|p{1cm}|p{3cm}|p{1.4cm}|p{1.2cm}|p{0.8cm}|p{1.0cm}|} \hline \textbf{Category} & \textbf{Method} & \textbf{Publication} & \textbf{Tasks} & \textbf{$\bm{g(x)}$} & \textbf{$\bm{f(g(x), x)}$} & \textbf{Ranges} & \textbf{S or H} & \textbf{Goals} \\ \hline \gmh{Squeeze-and-excitation network} & SENet~\cite{senet} & CVPR2018 & Cls, Det & {global average pooling -> MLP -> sigmoid.} & (A) & (0,1) & S & {(\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral2})} \\ \hline \gmh{Improve squeeze module} & EncNet~\cite{zhang2018encnet} & CVPR2018 & SSeg & {encoder -> MLP -> sigmoid.} & (A) & (0,1) & S & (\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral2}) \\ \cline{2-9} & GSoP-Net~\cite{gsopnet} & CVPR2019 & Cls & {2nd-order pooling -> convolution \& MLP -> sigmoid} & (A) & (0,1) & S & (\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral2}) \\ \cline{2-9} ~ & FcaNet~\cite{qin2021fcanet} & ICCV2021 & Cls, Det, ISeg & { discrete cosine transform -> MLP -> sigmoid.} & (A) & (0,1) & S & (\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral2}) \\ \hline \gmh{Improve excitation module} & ECANet~\cite{Wang_2020_ECA} & CVPR2020 & Cls, Det, ISeg & { global average pooling -> conv1d -> sigmoid.} & (A) & (0,1) & S & (\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral2}) \\ \hline \gmh{Improve both squeeze and excitation module} & SRM~\cite{lee2019srm} & arXiv2019 & Cls, ST & { style pooling -> convolution \& MLP -> sigmoid.} & (A) & (0,1) & S & (\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral2}) \\ \cline{2-9} ~ & GCT~\cite{yang2020gated} & CVPR2020 & Cls, Det, Action & { compute $L2$-norm on spatial -> channel normalization -> tanh.} & (A) & (-1,1) & S & (\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral2}) \\ \hline \end{tabular} \end{table*} \subsubsection{ECANet} To avoid high model complexity, SENet reduces the number of channels. However, this strategy fails to directly model correspondence between weight vectors and inputs, reducing the quality of results. To overcome this drawback, Wang et al.~\cite{Wang_2020_ECA} proposed the \emph{efficient channel attention} (ECA) block which instead uses a 1D convolution to determine the interaction between channels, instead of dimensionality reduction. An ECA block has similar formulation to an SE block including a squeeze module for aggregating global spatial information and an efficient excitation module for modeling cross-channel interaction. Instead of indirect correspondence, an ECA block only considers direct interaction between each channel and its $k$-nearest neighbors to control model complexity. Overall, the formulation of an ECA block is: \begin{align} \label{eq_eca} s = F_\text{eca}(X, \theta) & = \sigma (\text{Conv1D}(\text{GAP}(X))) \\ Y & = s X \end{align} where $\text{Conv1D}(\cdot)$ denotes 1D convolution with a kernel of shape $k$ across the channel domain, to model local cross-channel interaction. The parameter $k$ decides the coverage of interaction, and in ECA the kernel size $k$ is adaptively determined from the channel dimensionality $C$ instead of by manual tuning, using cross-validation: \begin{equation} k = \psi(C) = \left | \frac{\log_2(C)}{\gamma}+\frac{b}{\gamma}\right |_\text{odd} \end{equation} where $\gamma$ and $b$ are hyperparameters. $|x|_\text{odd}$ indicates the nearest odd function of $x$. Compared to SENet, ECANet has an improved excitation module, and provides an efficient and effective block which can readily be incorporated into various CNNs. \subsubsection{FcaNet} Only using global average pooling in the squeeze module limits representational ability. To obtain a more powerful representation ability, Qin et al.~\cite{qin2021fcanet} rethought global information captured from the viewpoint of compression and analysed global average pooling in the frequency domain. They proved that global average pooling is a special case of the discrete cosine transform (DCT) and used this observation to propose a novel \emph{multi-spectral channel attention}. Given an input feature map $X \in \mathbb{R}^{C \times H \times W}$, multi-spectral channel attention first splits $X$ into many parts $x^{i} \in \mathbb{R}^{C' \times H \times W}$. Then it applies a 2D DCT to each part $x^{i}$. Note that a 2D DCT can use pre-processing results to reduce computation. After processing each part, all results are concatenated into a vector. Finally, fully connected layers, ReLU activation and a sigmoid are used to get the attention vector as in an SE block. This can be formulated as: \begin{align} \label{eq_fca} s = F_\text{fca}(X, \theta) & = \sigma (W_{2} \delta (W_{1}[(\text{DCT}(\text{Group}(X)))])) \\ Y & = s X \end{align} where $\text{Group}(\cdot)$ indicates dividing the input into many groups and $\text{DCT}(\cdot)$ is the 2D discrete cosine transform. This work based on information compression and discrete cosine transforms achieves excellent performance on the classification task. \subsubsection{EncNet} Inspired by SENet, Zhang et al.~\cite{zhang2018encnet} proposed the \emph{context encoding module} (CEM) incorporating \emph{semantic encoding loss} (SE-loss) to model the relationship between scene context and the probabilities of object categories, thus utilizing global scene contextual information for semantic segmentation. Given an input feature map $X\in \mathbb R^{C\times H\times W}$, a CEM first learns $K$ cluster centers $D=\{d_1,\dots,d_K\}$ and a set of smoothing factors $S=\{s_1,\dots,s_K\}$ in the training phase. Next, it sums the difference between the local descriptors in the input and the corresponding cluster centers using soft-assignment weights to obtain a permutation-invariant descriptor. Then, it applies aggregation to the descriptors of the $K$ cluster centers instead of concatenation for computational efficiency. Formally, CEM can be written as: \begin{align} e_k &= \frac{\sum_{i=1}^N e^{-s_k||X_i-d_k||^2}(X_i-d_k) }{\sum_{j=1}^Ke^{-s_j||X_i-d_j||^2}}\\ e &= \sum_{k=1}^K\phi(e_k) \\ s &= \sigma(W e) \\ Y &= s X \end{align} where $d_k \in \mathbb{R}^C$ and $s_k \in \mathbb{R}$ are learnable parameters. $\phi$ denotes batch normalization with ReLU activation. In addition to channel-wise scaling vectors, the compact contextual descriptor $e$ is also applied to compute the SE-loss to regularize training, which improves the segmentation of small objects. Not only does CEM enhance class-dependent feature maps, but it also forces the network to consider big and small objects equally by incorporating SE-loss. Due to its lightweight architecture, CEM can be applied to various backbones with only low computational overhead. \subsubsection{Bilinear Attention} Following GSoP-Net~\cite{gsopnet}, Fang et al.~\cite{fang2019bilinear} claimed that previous attention models only use first-order information and disregard higher-order statistical information. They thus proposed a new \emph{bilinear attention block} (bi-attention) to capture local pairwise feature interactions within each channel, while preserving spatial information. Bi-attention employs the \emph{attention-in-attention} (AiA) mechanism to capture second-order statistical information: the outer point-wise channel attention vectors are computed from the output of the inner channel attention. Formally, given the input feature map $X$, bi-attention first uses bilinear pooling to capture second-order information \begin{align} \widetilde{x} = \text{Bi}(\phi(X)) = \text{Vec}(\text{UTri}(\phi(X) \phi(X)^T)) \end{align} where $\phi$ denotes an embedding function used for dimensionality reduction, $\phi(x)^T$ is the transpose of $\phi(x)$ across the channel domain, $\text{Utri}(\cdot)$ extracts the upper triangular elements of a matrix and $\text{Vec}(\cdot)$ is vectorization. Then bi-attention applies the inner channel attention mechanism to the feature map $\widetilde{x}\in\mathbb{R}^{\frac{c'(c'+1)}{2}\times H\times W}$ \begin{align} \widehat{x} &= \omega(\text{GAP}(\widetilde{x})) \varphi(\widetilde{x}) \end{align} Here $\omega$ and $\varphi$ are embedding functions. Finally the output feature map $\widehat{x}$ is used to compute the spatial channel attention weights of the outer point-wise attention mechanism: \begin{align} s &= \sigma(\widehat{x})\\ Y &= s X \end{align} The bi-attention block uses bilinear pooling to model the local pairwise feature interactions along each channel, while preserving the spatial information. Using the proposed AiA, the model pays more attention to higher-order statistical information compared with other attention-based models. Bi-attention can be incorporated into any CNN backbone to improve its representational power while suppressing noise. \subsection{Spatial Attention} Spatial attention can be seen as an adaptive spatial region selection mechanism: \emph{where to pay attention}. As Fig.~\ref{fig:total_attention_summary} shows, RAM~\cite{mnih2014recurrent}, STN~\cite{jaderberg2016spatial}, GENet~\cite{hu2019gatherexcite} and Non-Local~\cite{Wang_2018_nonlocal} are representative of different kinds of spatial attention methods. RAM represents RNN-based methods. STN represents those use a sub-network to explicitly predict relevant regions. GENet represents those that use a sub-network implicitly to predict a soft mask to select important regions. Non-Local represents self-attention related methods. In this subsection, we first summarize representative spatial attention mechanisms and specify process $g(x)$ and $f(g(x), x)$ described as Eq.~\ref{eq_general} in Tab.~\ref{Tab_spatial_attentions}, then discuss them according to Fig.~\ref{fig:total_attention_summary}. \begin{table*} \centering \caption{Representative spatial attention mechanisms sorted by \gmh{category and }date. Application areas include: Cls = classification, FGCls = fine-grained classification, Det = detection, SSeg = semantic segmentation, ISeg = instance segmentation, ST = style transfer, Action = action recognition, ICap = image captioning.\gmh{$g(x)$ and $f(g(x), x)$ are the attention process described by Eq.~\ref{eq_general}. Ranges means the ranges of attention map. S or H means soft or hard attention.(A) choose region according to the prediction. (B) element-wise product, (C)aggregate information via attention map. (\uppercase\expandafter{\romannumeral1})focus the network on discriminative regions, (\uppercase\expandafter{\romannumeral2}) avoid excessive computation for large input images, (\uppercase\expandafter{\romannumeral3}) provide more transformation invariance, (\uppercase\expandafter{\romannumeral4}) capture long-range dependencies, (\uppercase\expandafter{\romannumeral5}) denoise input feature map (\uppercase\expandafter{\romannumeral6}) adaptively aggregate neighborhood information, (\uppercase\expandafter{\romannumeral7}) reduce inductive bias. }} \label{Tab_spatial_attentions} \begin{tabular}{|p{2cm}|p{2cm}|p{1.5cm}|p{1cm}|p{3cm}|p{1.4cm}|p{1.2cm}|p{0.8cm}|p{1.0cm}|} \hline \textbf{Category} & \textbf{Method} & \textbf{Publication} & \textbf{Tasks} & \textbf{$\bm{g(x)}$} & \textbf{$\bm{f(g(x), x)}$} & \textbf{Ranges} & \textbf{S or H} & \textbf{Goals} \\ \hline \gmh{RNN-based methods} & RAM~\cite{mnih2014recurrent} & NIPS2014 & Cls &{use RNN to recurrently predict important regions} & (A) & {(0,1)} & H & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}).} \\ \cline{2-9} & Hard and soft attention~\cite{xu2015show} & ICML2015 & ICap &{a)compute similarity between visual features and previous hidden state -> interpret attention weight.} & (C) & (0,1) & S, H & {(\uppercase\expandafter{\romannumeral1}).} \\ \hline \gmh{Predict the relevant region explictly} & STN~\cite{jaderberg2016spatial} & NIPS2015 & Cls, FGCls &{ use sub-network to predict an affine transformation.} & (A) & {(0,1)} & H & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral3}).} \\ \cline{2-9} & DCN~\cite{dai2017deformable} & ICCV2017 & Det, SSeg &{use sub-network to predict offset coordinates.} & (A) & {(0,1)} & H & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral3}).} \\ \hline \gmh{Predict the relevant region implictly} & GENet~\cite{hu2019gatherexcite} & NIPS2018 & Cls, Det &{average pooling or depth-wise convolution -> interpolation -> sigmoid } & (B) & (0,1) & S & {(\uppercase\expandafter{\romannumeral1}).} \\ \cline{2-9} & PSANet~\cite{Zhao_2018_psanet} & ECCV2018 & SSeg &{predict an attention map using a sub-network.} & (C) & (0,1) & S & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral4}).} \\ \hline \gmh{Self-attention based methods}& Non-Local~\cite{Wang_2018_nonlocal} & CVPR2018 & Action, Det, ISeg &{Dot product between query and key -> softmax } & (C) & (0,1) & S & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral4}), (\uppercase\expandafter{\romannumeral5})} \\ \cline{2-9} & SASA~\cite{ramachandran2019standalone} & NeurIPS2019 & Cls, Det &{Dot product between query and key -> softmax.} & (C) & (0,1) & S & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral6})} \\ \cline{2-9} & ViT~\cite{dosovitskiy2020vit} & ICLR2021 & Cls &{divide the feature map into multiple groups -> Dot product between query and key -> softmax.} & (C) & (0,1) & S & {(\uppercase\expandafter{\romannumeral1}),(\uppercase\expandafter{\romannumeral4}), (\uppercase\expandafter{\romannumeral7}). } \\ \hline \end{tabular} \end{table*} \subsubsection{RAM} Convolutional neural networks have huge computational costs, especially for large inputs. In order to concentrate limited computing resources on important regions, Mnih et al.~\cite{mnih2014recurrent} proposed the \emph{recurrent attention model} (RAM) that adopts RNNs~\cite{HochSchm97_lstm} and reinforcement learning (RL)~\cite{sutton2000policy} to make the network learn where to pay attention. RAM pioneered the use of RNNs for visual attention, and was followed by many other RNN-based methods~\cite{gregor2015draw, xu2015show, ba2015multiple}. As shown in Fig.~\ref{fig:ram}, the RAM has three key elements: (A) a glimpse sensor, (B) a glimpse network and (C) an RNN model. The glimpse sensor takes a coordinate $l_{t-1}$ and an image $X_{t}$. It outputs multiple resolution patches $\rho(X_{t}, l_{t-1})$ centered on $l_{t-1}$. The glimpse network $f_{g}(\theta(g))$ includes a glimpse sensor and outputs the feature representation $g_{t}$ for input coordinate $l_{t-1}$ and image $X_{t}$. The RNN model considers $g_{t}$ and an internal state $h_{t-1}$ and outputs the next center coordinate $l_{t}$ and the action $a_{t}$, e.g.\ the softmax result in an image classification task. Since the whole process is not differentiable, it applies reinforcement learning strategies in the update process. This provides a simple but effective method to focus the network on key regions, thus reducing the number of calculations performed by the network, \gmh{especially for large inputs, } while improving image classification results. \subsubsection{Glimpse Network} Inspired by how humans perform visual recognition sequentially, Ba et al.~\cite{ba2015multiple} proposed a deep recurrent network, similar to RAM~\cite{mnih2014recurrent}, capable of processing a multi-resolution crop of the input image, called a glimpse, for multiple object recognition task. The proposed network updates its hidden state using a glimpse as input, and then predicts a new object as well as the next glimpse location at each step. The glimpse is usually much smaller than the whole image, which makes the network computationally efficient. The proposed deep recurrent visual attention model consists of a context network, glimpse network, recurrent network, emission network, and classification network. First, the context network takes the down-sampled whole image as input to provide the initial state for the recurrent network as well as the location of the first glimpse. Then, at the current time step $t$, given the current glimpse $x_t$ and its location tuple $l_t$, the goal of the glimpse network is to extract useful information, expressed as \begin{align} g_t = f_\text{image}(X) \cdot f_\text{loc}(l_t) \end{align} where $f_\text{image}(X)$ and $f_\text{loc}(l_t)$ are non-linear functions which both output vectors having the same dimension, and $\cdot$ denotes element-wise product, used for fusing information from two branches. Then, the recurrent network, which consists of two stacked recurrent layers, aggregates information gathered from each individual glimpse. The outputs of the recurrent layers are: \begin{align} r_t^{(1)} &= f_\text{rec}^{(1)}(g_t, r_{t-1}^{(1)}) \\ r_t^{(2)} &= f_\text{rec}^{(2)}(r_t^{(1)}, r_{t-1}^{(2)}) \end{align} Given the current hidden state $r_t^{(2)}$ of the recurrent network, the emission network predicts where to crop the next glimpse. Formally, it can be written as \begin{align} l_{t+1} = f_\text{emis}(r_t^{(2)}) \end{align} Finally, the classification network outputs a prediction for the class label $y$ based on the hidden state $r_{t}^{(1)}$ of the recurrent network \begin{align} y = f_\text{cls}(r_t^{(1)}) \end{align} Compared to a CNN operating on the entire image, the computational cost of the proposed model is much lower, and it can naturally tackle images of different sizes because it only processes a glimpse in each step. Robustness is additionally improved by the recurrent attention mechanism, which also alleviates the problem of over-fitting. This pipeline can be incorporated into any state-of-the-art CNN backbones or RNN units. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{RAM_Image.png} \caption{Attention process in RAM~\cite{mnih2014recurrent}. (A): a glimpse sensor takes image and center coordinates as input and outputs multiple resolution patches. (B): a glimpse network includes a glimpse sensor, taking image and center coordinates as input and outputting a feature vector. (C) the entire network recurrently uses a glimpse network, outputting the predicted result as well as the next center coordinates. Figure is taken from ~\cite{mnih2014recurrent}. } \label{fig:ram} \end{figure*} \subsubsection{Hard and soft attention} To visualize where and what an image caption generation model should focus on, Xu et al.~\cite{xu2015show} introduced an attention-based model as well as two variant attention mechanisms, \emph{hard attention} and \emph{soft attention}. Given a set of feature vectors $\bm{a} = \{a_1,\dots,a_L\}, a_i\in \mathbb{R}^D$ extracted from the input image, the model aims to produce a caption by generating one word at each time step. Thus they adopt a long short-term memory (LSTM) network as a decoder; an attention mechanism is used to generate a contextual vector $z_t$ conditioned on the feature set $\bm{a}$ and the previous hidden state $h_{t-1}$, where $t$ denotes the time step. Formally, the weight $\alpha_{t,i}$ of the feature vector $a_i$ at the $t$-th time step is defined as \begin{align} e_{t,i} &= f_\text{att} (a_i, h_{t-1})\\ \alpha_{t,i} &= \frac{\exp(e_{t,i})}{\sum_{k=1}^L \exp(e_{t,k})} \end{align} where $f_\text{att}$ is implemented by a multilayer perceptron conditioned on the previous hidden state $h_{t-1}$. The positive weight $\alpha_{t,i}$ can be interpreted either as the probability that location $i$ is the right place to focus on (hard attention), or as the relative importance of location $i$ to the next word (soft attention). To obtain the contextual vector $z_t$, the hard attention mechanism assigns a multinoulli distribution parametrized by $\{\alpha_{t,i}\}$ and views $z_t$ as a random variable: \begin{align} p(s_{t,i} &= 1 | \bm{a}, h_{t-1}) = \alpha_{t,i} \\ z_t &= \sum_{i=1}^L s_{t,i}a_i \end{align} On the other hand, the soft attention mechanism directly uses the expectation of the context vector $z_t$, \begin{align} z_t &= \sum_{i=1}^L \alpha_{t,i}a_i \end{align} The use of the attention mechanism improves the interpretability of the image caption generation process by allowing the user to understand what and where the model is focusing on. It also helps to improve the representational capability of the network. \subsubsection{Attention Gate} Previous approaches to MR segmentation usually operate on particular regions of interest (ROI), which requires excessive and wasteful use of computational resources and model parameters. To address this issue, Oktay et al. ~\cite{oktay2018attention} proposed a simple and yet effective mechanism, the \emph{attention gate} (AG), to focus on targeted regions while suppressing feature activations in irrelevant regions. Given the input feature map $X$ and the gating signal $G\in \mathbb{R}^{C'\times H\times W}$ which is collected at a coarse scale and contains contextual information, the attention gate uses additive attention to obtain the gating coefficient. Both the input $X$ and the gating signal are first linearly mapped to an $\mathbb{R}^{F\times H\times W}$ dimensional space, and then the output is squeezed in the channel domain to produce a spatial attention weight map $ S \in \mathbb{R}^{1\times H\times W}$. The overall process can be written as \begin{align} S &= \sigma(\varphi(\delta(\phi_x(X)+\phi_g(G)))) \\ Y &= S X \end{align} where $\varphi$, $\phi_x$ and $\phi_g$ are linear transformations implemented as $1\times 1$ convolutions. The attention gate guides the model's attention to important regions while suppressing feature activation in unrelated areas. It substantially enhances the representational power of the model without a significant increase in computing cost or number of model parameters due to its lightweight design. It is general and modular, making it simple to use in various CNN models. \subsubsection{STN} The property of translation equivariance makes CNNs suitable for processing image data. However, CNNs lack other transformation invariance such as rotational invariance, scaling invariance and warping invariance. To achieve these attributes while making CNNs focus on important regions, Jaderberg et al.~\cite{jaderberg2016spatial} proposed \emph{spatial transformer networks} (STN) that use an explicit procedure to learn invariance to translation, scaling, rotation and other more general warps, making the network pay attention to the most relevant regions. STN was the first attention mechanism to explicitly predict important regions and provide a deep neural network with transformation invariance. Various following works~\cite{dai2017deformable, Zhu_2019_CVPR_dcnv2} have had even greater success. Taking a 2D image as an example, a 2D affine transformation can be formulated as: \begin{align} \label{eq_2d_affine} \begin{bmatrix} \theta_{11} & \theta_{12} & \theta_{13} \\ \theta_{21} & \theta_{22} & \theta_{23} \end{bmatrix} &= f_\text{loc}(U) \\ \begin{pmatrix} x_{i}^{s} \\ y_{i}^{s} \end{pmatrix} &= \begin{bmatrix} \theta_{11} & \theta_{12} & \theta_{13} \\ \theta_{21} & \theta_{22} & \theta_{23} \end{bmatrix} \begin{pmatrix} x_{i}^{t} \\ y_{i}^{t} \\ 1 \end{pmatrix}. \end{align} Here, $U$ is the input feature map, and $f_\text{loc}$ can be any differentiable function, such as a lightweight fully-connected network or convolutional neural network. $x_{i}^{s}$ and $y_{i}^{s}$ are coordinates in the output feature map, while $x_{i}^{t}$ and $y_{i}^{t}$ are corresponding coordinates in the input feature map and the $\theta$ matrix is the learnable affine matrix. After obtaining the correspondence, the network can sample relevant input regions using the correspondence. To ensure that the whole process is differentiable and can be updated in an end-to-end manner, bilinear sampling is used to sample the input features STNs focus on discriminative regions automatically and learn invariance to some geometric transformations. \subsubsection{Deformable Convolutional Networks} With similar purpose to STNs, Dai et al.~\cite{dai2017deformable} proposed \emph{deformable convolutional networks} (deformable ConvNets) to be invariant to geometric transformations, but they pay attention to the important regions in a different manner. Specifically, deformable ConvNets do not learn an affine transformation. They divide convolution into two steps, firstly sampling features on a regular grid $\mathcal{R}$ from the input feature map, then aggregating sampled features by weighted summation using a convolution kernel. The process can be written as: \begin{align} Y(p_{0}) &= \sum_{p_i \in \mathcal{R}} w(p_{i}) X(p_{0} + p_{i}) \\ \mathcal{R} &= \{(-1,-1), (-1, 0), \dots, (1, 1)\} \end{align} The deformable convolution augments the sampling process by introducing a group of learnable offsets $\Delta p_{i}$ which can be generated by a lightweight CNN. Using the offsets $\Delta p_{i}$, the deformable convolution can be formulated as: \begin{align} Y(p_{0}) &= \sum_{p_i \in \mathcal{R}} w(p_{i}) X(p_{0} + p_{i} + \Delta p_{i}). \end{align} Through the above method, adaptive sampling is achieved. However, $\Delta p_{i}$ is a floating point value unsuited to grid sampling. To \gmh{address} this problem, bilinear interpolation is used. Deformable RoI pooling is also used, which greatly improves object detection. Deformable ConvNets adaptively select \gmh{the} important regions and enlarge the valid receptive field of convolutional neural networks; this is important in object detection and semantic segmentation tasks. \subsubsection{Self-attention and variants} Self-attention was proposed and has had great success in the field of \emph{natural language processing} (NLP)~\cite{bahdanau2016neural, vaswani2017attention, lin2017structured, devlin2019bert, yang2020xlnet, dai2019transformerxl, choromanski2021rethinking}. Recently, it has also shown the potential to become a dominant tool in computer vision~\cite{Wang_2018_nonlocal, dosovitskiy2020vit, carion2020endtoend_detr, pmlr-v119-chen20s-igpt, zhu2021deformable}. Typically, self-attention is used as a spatial attention mechanism to capture global information. We now summarize \gmh{the} self-attention mechanism and its common variants in computer vision. Due to the localisation of the convolutional operation, CNNs have inherently narrow receptive fields~\cite{liu2015parsenet,Peng_2017_large_kernel}, which limits the ability of CNNs to understand scenes globally. To increase the receptive field, Wang et al.~\cite{Wang_2018_nonlocal} introduced self-attention into computer vision. Taking a 2D image as an example, given a feature map $F \in \mathbb{R}^{C \times H \times W}$, self-attention first computes the queries, keys and values $Q, K, V \in \mathbb{R}^{C' \times N}, N = H \times W$ by linear projection and reshaping operations. Then self-attention can be formulated as: \begin{align} \label{eq_self_attn} A = (a)_{i,j} & = \text{Softmax}(Q K^T), \\ Y & = A V, \end{align} where $A \in \mathbb{R}^{N \times N} $ is the attention matrix and $\alpha_{i,j}$ is the relationship between the $i$-th and $j$-th elements. The whole process is shown in Fig.~\ref{fig:vit}(left). Self-attention is a powerful tool to model global information and is useful in many visual tasks~\cite{YuanW18_ocnet, Xie_2018_acnn, yan2020pointasnl, hu2018relation, Zhang_2019_cfnet, zhang2019sagan, Bello_2019_ICCV_AANet, zhu2019empirical,Li_2020_sprr}. However, the self-attention mechanism has several shortcomings, particularly its quadratic complexity, which limit its applicability. Several variants have been introduced to alleviate these problems. The \emph{disentangled non-local} approach~\cite{yin2020disentangled} improves self-attention's accuracy and effectiveness, but most variants focus on reducing its computational complexity. CCNet~\cite{huang2020ccnet} regards the self-attention operation as a graph convolution and replaces the densely-connected graph processed by self-attention with several sparsely-connected graphs. To do so, it proposes \emph{criss-cross attention} which considers row attention and column attention recurrently to obtain global information. CCNet reduces the complexity of self-attention from $O(N^{2})$ to $O(N \sqrt{N})$. EMANet~\cite{li19ema} views self-attention in terms of expectation maximization (EM). It proposes \emph{EM attention} which adopts the EM algorithm to get a set of compact bases instead of using all points as reconstruction bases. This reduces the complexity from $O(N^{2})$ to $O(NK)$, where $K$ is the number of compact bases. ANN~\cite{ann} suggests that using all positional features as key and vectors is redundant and adopts spatial pyramid pooling~\cite{zhao2017pspnet, He_2014_spp} to obtain a few representative key and value features to use instead, to reduce computation. GCNet~\cite{cao2019GCNet} analyses the attention map used in self-attention and finds that the global contexts obtained by self-attention are similar for different query positions in the same image. Thus, it first proposes to predict a single attention map shared by all query points, and then gets global information from a weighted sum of input features according to this attention map. This is like average pooling, but is a more general process for collecting global information. $A^{2}$Net~\cite{chen2018a2nets} is motivated by SENet to divide attention into feature gathering and feature distribution processes, using two different kinds of attention. The first aggregates global information via second-order attention pooling and the second distributes the global descriptors by soft selection attention. GloRe~\cite{chen2018glore} understands self-attention from a graph learning perspective. It first collects $N$ input features into $M \ll N$ nodes and then learns an adjacency matrix of global interactions between nodes. Finally, the nodes distribute global information to input features. A similar idea can be found in LatentGNN~\cite{zhang2019latentgnn}, MLP-Mixer~\cite{tolstikhin2021mlpmixer} and ResMLP~\cite{touvron2021resmlp}. OCRNet~\cite{yuan2021segmentation_ocr} proposes the concept of \emph{object-contextual representation} which is a weighted aggregation of all object regions' representations in the same category, such as a weighted average of all car region representations. It replaces the key and vector with this object-contextual representation leading to successful improvements in both speed and effectiveness. The \emph{disentangled non-local} approach was motivated by~\cite{cao2019GCNet, Wang_2018_nonlocal}. Yin et al~\cite{yin2020disentangled} deeply analyzed the self-attention mechanism resulting in the core idea of decoupling self-attention into a pairwise term and a unary term. The pairwise term focuses on modeling relationships while the unary term focuses on salient boundaries. This decomposition prevents unwanted interactions between the two terms, greatly improving semantic segmentation, object detection and action recognition. HamNet~\cite{ham} models capturing global relationships as a low-rank completion problem and designs a series of white-box methods to capture global context using matrix decomposition. This not only reduces the complexity, but increases the interpretability of self-attention. EANet~\cite{external_attention} proposes that self-attention should only consider correlation in a single sample and should ignore potential relationships between different samples. To explore the correlation between different samples and reduce computation, it makes use of an external attention that adopts learnable, lightweight and shared key and value vectors. It further reveals that using softmax to normalize the attention map is not optimal and presents double normalization as a better alternative. In addition to being a complementary approach to CNNs, self-attention also can be used to replace convolution operations for aggregating neighborhood information. Convolution operations can be formulated as dot products between the input feature $X$ and a convolution kernel $W$: \begin{equation} \label{eq_conv} Y_{i,j}^{c} = \sum_{a,b \in \{0, \dots, k-1\}} W_{a,b,c} X_{\hat{a}, \hat{b}} \end{equation} where \begin{equation} \hat{a} = i+a-\lfloor k/2 \rfloor, \qquad \hat{b} = j+b-\lfloor k/2 \rfloor, \end{equation} $k$ is the kernel size and $c$ indicates the channel. The above formulation can be viewed as a process of aggregating neighborhood information by using a weighted sum through a convolution kernel. The process of aggregating neighborhood information can be defined more generally as: \begin{align} \label{eq_general_conv} Y_{i,j} &= \sum_{a,b \in \{0, \dots, k-1\}} \text{Rel}(i,j,\hat{a},\hat{b}) f(X_{\hat{a},\hat{b}}) \end{align} where $\text{Rel}(i,j,\hat{a},\hat{b})$ is the relation between position (i,j) and position ($\hat{a}$, $\hat{b}$). With this definition, local self-attention is a special case. For example, SASA~\cite{ramachandran2019standalone} writes this as \begin{align} \label{eq_sasa} Y_{i,j} &= \sum_{a,b \in \mathcal{N}_{k}(i,j)} \text{Softmax}_{ab}(q_{ij}^{T}k_{ab} + q_{ij}r_{a-i, b-j})v_{ab} \end{align} where $q$, $k$ and $v$ are linear projections of input feature $x$, and $r_{a-i, b-j}$ is the relative positional embedding of $(i,j)$ and $(a,b)$. We now consider several specific works using local self-attention as basic neural network blocks SASA~\cite{ramachandran2019standalone} suggests that using self-attention to collect global information is too computationally intensive and instead adopts local self-attention to replace all spatial convolution in a CNN. The authors show that doing so improves speed, number of parameters and quality of results. They also explores the behavior of positional embedding and show that relative positional embeddings~\cite{shaw2018relative_position} are suitable. Their work also studies how to combinie local self-attention with convolution. LR-Net~\cite{hu2019lrnet} appeared concurrently with SASA. It also studies how to model local relationships by using local self-attention. A comprehensive study probed the effects of positional embedding, kernel size, appearance composability and adversarial attacks. SAN~\cite{Zhao_2020_SAN} explored two modes, pairwise and patchwise, of utilizing attention for local feature aggregation. It proposed a novel vector attention adaptive both in content and channel, and assessed its effectiveness both theoretically and practically. In addition to providing significant improvements in the image domain, it also has been proven useful in 3D point cloud processing~\cite{zhao2020pointtransformer}. \subsubsection{Vision Transformers} \begin{figure}[t] \centering \includegraphics[width=\linewidth]{vit_fig.png} \caption{Vision transformer~\cite{dosovitskiy2020vit}. Left: architecture. Vision transformer first splits the image into different patches and projects them into feature space where a transformer encoder processes them to produce the final result. Right: basic vision transformer block with multi-head attention core. Figure is taken from~\cite{dosovitskiy2020vit}. } \label{fig:vit} \end{figure} Transformers have had great success in natural language processing~\cite{bahdanau2016neural, vaswani2017attention, lin2017structured, devlin2019bert, choromanski2021rethinking, brown2020language_gpt3}. Recently, iGPT~\cite{pmlr-v119-chen20s-igpt} and DETR~\cite{carion2020endtoend_detr} demonstrated the huge potential for transformer-based models in computer vision. Motivated by this, Dosovitskiy et al~\cite{dosovitskiy2020vit} proposed the \emph{vision transformer} (ViT) which is the first pure transformer architecture for image processing. It is capable of achieving comparable results to modern convolutional neural networks. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{multi-head-attention.png} \caption{Left: Self-attention. Right: Multi-head self-attention. Figure from~\cite{vaswani2017attention}. } \label{fig:multi_head_attention} \end{figure} As Fig~\ref{fig:vit} shows, the main part of ViT is the multi-head attention (MHA) module. MHA takes a sequence as input. It first concatenates a class token with the input feature $F \in \mathcal{R}^{N \times C}$, where $N$ is the number of pixels. Then it gets $Q,K \in \mathcal{R}^{N \times C'}$ and $V \in \mathcal{R}^{N \times C}$ by linear projection. Next, $Q$, $K$ and $V$ are divided into $H$ heads in the channel domain and self-attention separately applied to them. The MHA approach is shown in Fig.~\ref{fig:multi_head_attention}. ViT stacks a number of MHA layers with fully connected layers, layer normalization~\cite{ba2016layer} and the GELU~\cite{hendrycks2020gelu} activation function. \begin{figure*}[t] \centering \includegraphics[width=\textwidth]{attention_map_vit.png} \caption{Attention map results from~\cite{dosovitskiy2020vit}. The network focuses on the discriminative regions of each image. Figure from~\cite{dosovitskiy2020vit}. } \label{fig:attention_map_vit} \end{figure*} ViT demonstrates that a pure attention-based network can achieve better results than a convolutional neural network especially for large datasets such as JFT-300~\cite{sun2017revisiting} and ImageNet-21K~\cite{Deng2009Imagenet}. Following ViT, many transformer-based architectures such as PCT~\cite{Guo_2021_pct}, IPT~\cite{chen2021pretrained_ipt}, T2T-ViT~\cite{yuan2021tokens}, DeepViT~\cite{zhou2021deepvit}, SETR~\cite{SETR}, PVT~\cite{wang2021pyramid}, CaiT~\cite{touvron2021going}, TNT~\cite{han2021transformer_tnt}, Swin-transformer~\cite{liu2021swin}, Query2Label~\cite{liu2021query2label}, MoCoV3~\cite{chen2021empirical_mocov3}, BEiT~\cite{bao2021beit}, SegFormer~\cite{xie2021segformer}, FuseFormer~\cite{liu2021fuseformer} and MAE~\cite{he2021masked} have appeared, with excellent results for many kind of visual tasks including image classification, object detection, semantic segmentation, point cloud processing, action recognition and self-supervised learning. A detailed survey of vision transformers is omitted here as other recent surveys~\cite{han2021survey, khan2021transformers, guo2021attention_mlp_cnn, xu2022transformers} comprehensively review the use of transformer methods for visual tasks. \subsubsection{GENet} Inspired by SENet, Hu et al.~\cite{hu2019gatherexcite} designed GENet to capture long-range spatial contextual information by providing a recalibration function in the spatial domain. GENet combines part gathering and excitation operations. In the first step, it aggregates input features over large neighborhoods and models the relationship between different spatial locations. In the second step, it first generates an attention map of the same size as the input feature map, using interpolation. Then each position in the input feature map is scaled by multiplying by the corresponding element in the attention map. This process can be described by: \begin{align} g &= f_\text{gather}(X), \\ s &= f_\text{excite}(g) = \sigma(\text{Interp}(g)), \\ Y &= s X. \end{align} Here, $f_\text{gather}$ can take any form which captures spatial correlations, such as global average pooling or a sequence of depth-wise convolutions; $\text{Interp}(\cdot)$ denotes interpolation. The gather-excite module is lightweight and can be inserted into each residual unit like an SE block. It emphasizes important features while suppressing noise. \subsubsection{PSANet} Motivated by success in capturing long-range dependencies in convolutional neural networks, Zhao et al.~\cite{Zhao_2018_psanet} presented the novel PSANet framework to aggregate global information. It models information aggregation as an information flow and proposes a bidirectional information propagation mechanism to make information flow globally. PSANet formulates information aggregation as: \begin{align} \label{eq_psa_aggr} z_{i} = \sum_{j \in \Omega(i)} F(x_{i}, x_{j}, \Delta_{ij})x_{j} \end{align} where $\Delta_{ij}$ indicates the positional relationship between $i$ and $j$. $F(x_{i}, x_{j}, \Delta_{ij})$ is a function that takes $x_{i}$, $x_{j}$ and $\Delta_{ij}$ into consideration to controls information flow from $j$ to $i$. $\Omega_{i}$ represents the aggregation neighborhood of position $i$; if we wish to capture global information, $\Omega_{i}$ should include all spatial positions. Due to the complexity of calculating function $F(x_{i}, x_{j}, \Delta_{ij})$, it is decomposed into an approximation: \begin{align} F(x_{i}, x_{j}, \Delta_{ij}) \approx F_{\Delta_{ij}}(x_{i}) + F_{\Delta_{ij}}(x_{j}) \end{align} whereupon Eq.~\ref{eq_psa_aggr} can be simplified to: \begin{align} \label{eq_psa_sim} z_{i} = \sum_{j \in \Omega(i)} F_{\Delta_{ij}}(x_{i})x_{j} + \sum_{j \in \Omega(i)} F_{\Delta_{ij}}(x_{j})x_{j}. \end{align} The first term can be viewed as collecting information at position $i$ while the second term distributes information at position $j$. Functions $F_{\Delta_{ij}}(x_{i})$ and $F_{\Delta_{ij}}(x_{j})$ can be seen as adaptive attention weights. The above process aggregates global information while emphasizing the relevant features. It can be added to the end of a convolutional neural network as an effective complement to greatly improve semantic segmentation. \begin{table*} \centering \caption{Representative temporal attention mechanisms sorted by date. ReID = re-identification, Action = action recognition. Ranges means the ranges of attention map. S or H means soft or hard attention. $g(x)$ and $f(g(x), x)$ are the attention process described by Eq.~\ref{eq_general}. (A) aggregate information via attention map. (\uppercase\expandafter{\romannumeral1}) exploit multi-scale short-term temporal contextual information (\uppercase\expandafter{\romannumeral2})capture long-term temporal feature dependencies (\uppercase\expandafter{\romannumeral3}) capture local temporal contexts} \label{Tab_temporal_attentions} \begin{tabular}{|p{2cm}|p{2cm}|p{1.5cm}|p{1cm}|p{3cm}|p{1.4cm}|p{1.2cm}|p{0.8cm}|p{1.0cm}|} \hline \textbf{Category} & \textbf{Method} & \textbf{Publication} & \textbf{Tasks} & \textbf{$\bm{g(x)}$} & \textbf{$\bm{f(g(x), x)}$} & \textbf{Ranges} & \textbf{S or H} & \textbf{Goals} \\ \hline Self-attention based methods & GLTR~\cite{li2019global} & ICCV2019 & ReID &{ dilated 1D Convs -> self-attention in temporal dimension } &{(A)} &{(0,1)} &{S} & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}).} \\ \hline Combine local attention and global attention & TAM~\cite{liu2020tam} & Arxiv2020 & Action &{ a)local: global spatial average pooling -> 1D Convs, b) global: global spatial average pooling -> MLP -> adaptive convolution } &{(A)} &{(0,1)} &{S} & {(\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3}).} \\ \hline \end{tabular} \end{table*} \subsection{Temporal Attention} Temporal attention can be seen as a dynamic time selection mechanism determining \emph{when to pay attention}, and is thus usually used for video processing. Previous works~\cite{li2019global,liu2020tam} often emphasise how to capture both short-term and long-term cross-frame feature dependencies. Here, we first summarize representative temporal attention mechanisms and specify process $g(x)$ and $f(g(x), x)$ described as Eq.~\ref{eq_general} in Tab.~\ref{Tab_temporal_attentions}, and then discuss various such mechanisms \gmh{according to the order in Fig.~\ref{fig:total_attention_summary}}. \subsubsection{Self-attention and variants} RNN and temporal pooling or weight learning have been widely used in work on video representation learning to capture interaction between frames, but these methods have limitations in terms of either efficiency or temporal relation modeling. To overcome them, Li et al.~\cite{li2019global} proposed a \emph{global-local temporal representation} (GLTR) to exploit multi-scale temporal cues in a video sequence. GLTR consists of a \emph{dilated temporal pyramid} (DTP) for local temporal context learning and a \emph{temporal self attention} module for capturing global temporal interaction. DTP adopts dilated convolution with dilatation rates increasing progressively to cover various temporal ranges, and then concatenates the various outputs to aggregate multi-scale information. Given input frame-wise features $F = \{f_1, \dots f_T\}$, DTP can be written as: \begin{align} \{f_1^{(r)}, \dots, f_T^{(r)}\} &= \text{DConv}^{(r)}(F) \\ f'_t &= [f_t^{(1)};\dots f_t^{(2^{n-1})}\dots;f_t^{(2^{N-1})}] \end{align} where $\text{DConv}^{(r)}(\cdot)$ denotes dilated convolution with dilation rate $r$. The self-attention mechanism adopts convolution layers followed by batch normalization and ReLU activation to generate the query $Q \in \mathbb{R}^{d\times T}$, the key $K \in \mathbb{R}^{d\times T}$ and the value $V \in \mathbb{R}^{d\times T}$ based on the input feature map $F' = \{f'_1, \dots f'_T\}$, which can be written as \begin{align} F_\text{out} = g(V\text{Softmax}(Q^TK)) + F' \end{align} where $g$ denotes a linear mapping implemented by a convolution. The short-term temporal contextual information from neighboring frames helps to distinguish visually similar regions while the long-term temporal information serves to overcome occlusions and noise. GLTR combines the advantages of both modules, enhancing representation capability and suppressing noise. It can \mtj{be} incorporated into any state-of-the-art CNN backbone to learn a global descriptor for a whole video. However, the self-attention mechanism has quadratic time complexity, limiting its application. \subsubsection{TAM} To capture complex temporal relationships both efficiently and flexibly, Liu et al.~\cite{liu2020tam} proposed a \emph{temporal adaptive module} (TAM). It adopts an adaptive kernel instead of self-attention to capture global contextual information, with lower time complexity than GLTR~\cite{li2019global}. TAM has two branches, a local branch and a global branch. Given the input feature map $X\in \mathbb{R}^{C\times T\times H\times W}$, global spatial average pooling $\text{GAP}$ is first applied to the feature map to ensure TAM has a low computational cost. Then the local branch in TAM employs several 1D convolutions with ReLU nonlinearity across the temporal domain to produce location-sensitive importance maps for enhancing frame-wise features. The local branch can be written as \begin{align} s &= \sigma(\text{Conv1D}(\delta(\text{Conv1D}(\text{GAP}(X)))))\\ X^1 &= s X. \end{align} Unlike the local branch, the global branch is location invariant and focuses on generating a channel-wise adaptive kernel based on global temporal information in each channel. For the $c$-th channel, the kernel can be written as \begin{align} \Theta_c = \text{Softmax}(\text{FC}_2(\delta(\text{FC}_1(\text{GAP}(X)_c)))) \end{align} where $\Theta_c \in \mathbb{R}^{K}$ and $K$ is the adaptive kernel size. Finally, TAM convolves the adaptive kernel $\Theta$ with $X_\text{out}^1$: \begin{align} Y = \Theta \otimes X^1 \end{align} With the help of the local branch and global branch, TAM can capture the complex temporal structures in video and enhance per-frame features at low computational cost. Due to its flexibility and lightweight design, TAM can be added to any existing 2D CNNs. \subsection{Branch Attention} Branch attention can be seen as a dynamic branch selection mechanism: \emph{which to pay attention to}, used with a multi-branch structure. We first summarize representative branch attention mechanisms and specify process $g(x)$ and $f(g(x), x)$ described as Eq.~\ref{eq_general} in Tab.~\ref{Tab_branch_attentions}, then discuss various ones in detail. \begin{table*} \centering \caption{Representative branch attention mechanisms sorted by date. Cls = classification, Det=Object Detection. $g(x)$ and $f(g(x), x)$ are the attention process described by Eq.~\ref{eq_general}.Ranges means the ranges of attention map. S or H means soft or hard attention. (A) element-wise product. (B) channel-wise product. (C) aggergate information via attention. (\uppercase\expandafter{\romannumeral1})overcome the problem of vanishing gradient (\uppercase\expandafter{\romannumeral2}) dynamically fuse different branches. (\uppercase\expandafter{\romannumeral3}) adaptively select a suitable receptive field (\uppercase\expandafter{\romannumeral4}) improve the performance of standard convolution (be) dynamically fuse different convolution kernels. } \label{Tab_branch_attentions} \begin{tabular}{|p{2cm}|p{2cm}|p{1.5cm}|p{1cm}|p{3cm}|p{1.4cm}|p{1.2cm}|p{0.8cm}|p{1.0cm}|} \hline \textbf{Category} & \textbf{Method} & \textbf{Publication} & \textbf{Tasks} & \textbf{$\bm{g(x)}$} & \textbf{$\bm{f(g(x), x)}$} & \textbf{Ranges} & \textbf{S or H} & \textbf{Goals} \\ \hline Combine different branches & Highway Network~\cite{srivastava2015training} & ICML2015W & Cls &{linear layer -> sigmoid } & (A) & (0,1) & S & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}). } \\ \cline{2-9} & SKNet~\cite{li2019selective} & CVPR2019 & Cls &{global average pooling -> MLP -> softmax} & (B) & (0,1) & S & {(\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \hline Combine different convolution kernels & CondConv~\cite{yang2020condconv} & NeurIPS2019 & Cls, Det &{global average pooling -> linear layer -> sigmoid} & (C) & (0,1) & S & {(\uppercase\expandafter{\romannumeral4}), (\uppercase\expandafter{\romannumeral5}).} \\ \hline \end{tabular} \end{table*} \subsubsection{Highway networks} Inspired by the \emph{long short term memory} network, Srivastava et al.~\cite{srivastava2015training} proposed \emph{highway networks} that employ adaptive gating mechanisms to enable information flows across layers to address the problem of training very deep networks. Supposing a plain neural network consists of $L$ layers, and $H_l(X)$ denotes a non-linear transformation on the $l$-th layer, a highway network can be expressed as \begin{align} \label{eq_highway} Y_l &= H_l(X_l) T_l(X_l) + X_l (1-T_l(X_l)) \\ T_l(X) &= \sigma(W_l^TX+b_l) \end{align} where $T_l(X)$ denotes the transform gate regulating the information flow for the $l$-th layer. $X_l$ and $Y_l$ are the inputs and outputs of the $l$-th layer. The gating mechanism and skip-connection structure make it possible to directly train very deep highway networks using simple gradient descent methods. Unlike fixed skip-connections, the gating mechanism adapts to the input, which helps to route information across layers. A highway network can be incorporated in any CNN. \subsubsection{SKNet} Research in the neuroscience community suggests that visual cortical neurons adaptively adjust the sizes of their receptive fields (RFs) according to the input stimulus~\cite{spillmann2015beyond}. This inspired Li et al.~\cite{li2019selective} to propose an automatic selection operation called \emph{selective kernel} (SK) convolution. SK convolution is implemented using three operations: split, fuse and select. During split, transformations with different kernel sizes are applied to the feature map to obtain different sized RFs. Information from all branches is then fused together via element-wise summation to compute the gate vector. This is used to control information flows from the multiple branches. Finally, the output feature map is obtained by aggregating feature maps for all branches, guided by the gate vector. This can be expressed as: \begin{align} U_k &= F_k(X) \qquad k=1,\dots,K\\ U &= \sum_{k=1}^K U_k \\ z &= \delta(\text{BN}(W \text{GAP} (U))) \\ s_k^{(c)} &= \frac{e^{W_k^{(c)} z}}{\sum_{k=1}^K e^{W_k^{(c)} z}} \quad k=1,\dots,K,\quad c=1,\dots,C \\ Y &= \sum_{k=1}^K s_k U_k \end{align} Here, each transformation $F_k$ has a unique kernel size to provide different scales of information for each branch. For efficiency, $F_k$ is implemented by grouped or depthwise convolutions followed by dilated convolution, batch normalization and ReLU activation in sequence. $t^{(c)}$ denotes the $c$-th element of vector $t$, or the $c$-th row of matrix $t$. SK convolutions enable the network to adaptively adjust neurons' RF sizes according to the input, giving a notable improvement in results at little computational cost. The gate mechanism in SK convolutions is used to fuse information from multiple branches. Due to its lightweight design, SK convolution can be applied to any CNN backbone by replacing all large kernel convolutions. ResNeSt~\cite{zhang2020resnest} also adopts this attention mechanism to improve the CNN backbone in a more general way, giving excellent results on ResNet~\cite{resnet} and ResNeXt~\cite{resnext}. \subsubsection{CondConv} A basic assumption in CNNs is that all convolution kernels are the same. Given this, the typical way to enhance the representational power of a network is to increase its depth or width, which introduces significant extra computational cost. In order to more efficiently increase the capacity of convolutional neural networks, Yang et al.~\cite{yang2020condconv} proposed a novel multi-branch operator called CondConv. An ordinary convolution can be written \begin{align} Y = W * X \end{align} where $*$ denotes convolution. The learnable parameter $W$ is the same for all samples. CondConv adaptively combines multiple convolution kernels and can be written as: \begin{align} Y = (\alpha_{1} W_{1} + \dots + \alpha_{n} W_{n}) * X \end{align} Here, $\alpha$ is a learnable weight vector computed by \begin{align} \label{eq.condconv_weight} \alpha = \sigma(W_{r}(\text{GAP}(X))) \end{align} This process is equivalent to an ensemble of multiple experts, as shown in Fig.~\ref{fig:CondConv}. CondConv makes full use of the advantages of the multi-branch structure using a branch attention method with little computing cost. It presents a novel manner to efficiently increase the capability of networks. \begin{figure}[t] \centering \includegraphics[width=\linewidth]{CondConv.png} \caption{ CondConv~\cite{yang2020condconv}. (a) CondConv first combines different convolution kernels and then uses the combined kernel for convolution. (b) Mixture of experts first uses multiple convolution kernels for convolution and then merges the results. While (a) and (b) are equivalent, (a) has much lower computational cost. Figure is taken from~\cite{yang2020condconv}. } \label{fig:CondConv} \end{figure} \subsubsection{Dynamic Convolution} The extremely low computational cost of lightweight CNNs constrains the depth and width of the networks, further decreasing their representational power. To address the above problem, Chen et al.~\cite{chen2020dynamic} proposed \emph{dynamic convolution}, a novel operator design that increases representational power with negligible additional computational cost and does not change the width or depth of the network in parallel with CondConv~\cite{yang2020condconv}. Dynamic convolution uses $K$ parallel convolution kernels of the same size and input/output dimensions instead of one kernel per layer. Like SE blocks, it adopts a squeeze-and-excitation mechanism to generate the attention weights for the different convolution kernels. These kernels are then aggregated dynamically by weighted summation and applied to the input feature map $X$: \begin{align} s & = \text{softmax} (W_{2} \delta (W_{1}\text{GAP}(X))) \\ \text{DyConv} &= \sum_{i=1}^{K} s_k \text{Conv}_k \\ Y &= \text{DyConv}(X) \end{align} Here the convolutions are combined by summation of weights and biases of convolutional kernels. Compared to applying convolution to the feature map, the computational cost of squeeze-and-excitation and weighted summation is extremely low. Dynamic convolution thus provides an efficient operation to improve representational power and can be easily used as a replacement for any convolution. \subsection{Channel \& Spatial Attention} Channel \& spatial attention combines the advantages of channel attention and spatial attention. It adaptively selects both important objects and regions~\cite{ChenZXNSLC17}. The \emph{residual attention network}~\cite{wang2017residual} pioneered the field of channel \& spatial attention, emphasizing the importance of informative features in both spatial and channel dimensions. It adopts a bottom-up structure consisting of several convolutions to produce a 3D (height, width, channel) attention map. However, it has high computational cost and limited receptive fields. To leverage global spatial information later works~\cite{woo2018cbam,park2018bam} enhance discrimination of features by introducing global average pooling, as well as decoupling channel attention and spatial channel attention for computational efficiency. Other works~\cite{Fu_2019_danet,zhang2020relation} apply self-attention mechanisms for channel \& spatial attention to explore pairwise interaction. Yet further works~\cite{Liu_2020_scnet,hou2020strip} adopt the spatial-channel attention mechanism to enlarge the receptive field. Representative channel \& spatial attention mechanisms and specific process $g(x)$ and $f(g(x), x)$ described as Eq.~\ref{eq_general} are in given Tab.~\ref{Tab_channel_spatial_attentions}; we next discuss various ones in detail. \begin{table*} \centering \caption{Representative channel \& spatial attention mechanisms sorted by date. Cls = classification, ICap = image captioning, Det = detection, Seg = segmentation, ISeg = instance segmentation, KP = keypoint detection, ReID = re-identification.$g(x)$ and $f(g(x), x)$ are the attention process described by Eq.~\ref{eq_general}. Ranges means the ranges of attention map. S or H means soft or hard attention. (A) element-wise product. (B) aggregate information via attention map.(\uppercase\expandafter{\romannumeral1}) focus the network on the discriminative region, (\uppercase\expandafter{\romannumeral2}) emphasize important channels, (\uppercase\expandafter{\romannumeral3}) capture long-range information, (\uppercase\expandafter{\romannumeral4}) capture cross-domain interaction between any two domains. } \label{Tab_channel_spatial_attentions} \begin{tabular}{|p{2cm}|p{2cm}|p{1.5cm}|p{1cm}|p{3cm}|p{1.4cm}|p{1.2cm}|p{0.8cm}|p{1.0cm}|} \hline \textbf{Category} & \textbf{Method} & \textbf{Publication} & \textbf{Tasks} & \textbf{$\bm{g(x)}$} & \textbf{$\bm{f(g(x), x)}$} & \textbf{Ranges} & \textbf{S or H} & \textbf{Goals} \\ \hline Jointly predict channel \& spatial attention map & Residual Attention \cite{wang2017residual} & CVPR2017 & Cls &{top-down network -> bottom down network -> $1\times 1$ Convs -> Sigmoid} &{(A)} & {(0,1)} &{S} & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2})} \\ \cline{2-9} & SCNet~\cite{Liu_2020_scnet} & CVPR2020 & Cls, Det, ISeg, KP &{top-down network -> bottom down network -> identity add -> sigmoid} &{(A)} & {(0,1)} &{S}& {(\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \cline{2-9} & Strip Pooling~\cite{hou2020strip} & CVPR2020 & Seg &{a)horizontal/vertical global pooling -> 1D Conv -> point-wise summation -> $1\times 1$ Conv -> Sigmoid} &{(A)} & {(0,1)} &{S}& {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \hline Separately predict channel \& spatial attention maps & SCA-CNN~\cite{ChenZXNSLC17} & CVPR2017 & ICap &{a)spatial: fuse hidden state -> $1\times 1$ Conv -> Softmax, b)channel: global average pooling -> MLP -> Softmax } &{(A)} & {(0,1)} &{S} & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3}) } \\ \cline{2-9} & CBAM~\cite{woo2018cbam} & ECCV2018 & Cls, Det &{a)spatial: global pooling in channel dimension-> Conv -> Sigmoid, b)channel: global pooling in spatial dimension -> MLP -> Sigmoid} &{(A)} & {(0,1)} &{S} & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \cline{2-9} & BAM~\cite{woo2018cbam} & BMVC2018 & Cls, Det &{a)spatial: dilated Convs, b)channel: global average pooling -> MLP, c)fuse two branches} &{(A)} & {(0,1)} &{S} & {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \cline{2-9} & scSE~\cite{roy2018recalibrating} & TMI2018 & Seg &{a)spatial: $1\times 1$ Conv -> Sigmoid, b)channel: global average pooling -> MLP -> Sigmoid, c)fuse two branches } &{(A)} & {(0,1)} &{S}& {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \cline{2-9} & Dual Attention~\cite{Fu_2019_danet} & CVPR2019 & Seg &{a)spatial: self-attention in spatial dimension, b)channel: self-attention in channel dimension, c) fuse two branches} &{(B)} & {(0,1)} &{S}& {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \cline{2-9} & RGA~\cite{zhang2020relation} & CVPR2020 & ReID &{use self-attention to capture pairwise relations -> compute attention maps with the input and relation vectors} &{(A)} & {(0,1)} &{S}& { (\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral2}), (\uppercase\expandafter{\romannumeral3})} \\ \cline{2-9} & Triplet Attention~\cite{misra2021rotate} & WACV2021 & Cls, Det &{compute attention maps for pairs of domains -> fuse different branches} &{(A)} & {(0,1)} &{S}& {(\uppercase\expandafter{\romannumeral1}), (\uppercase\expandafter{\romannumeral4}) } \\ \hline \end{tabular} \end{table*} \subsubsection{Residual Attention Network} Inspired by the success of ResNet~\cite{resnet}, Wang et al.~\cite{wang2017residual} proposed the very deep convolutional \emph{residual attention network} (RAN) by combining an attention mechanism with residual connections. Each attention module stacked in a residual attention network can be divided into a mask branch and a trunk branch. The trunk branch processes features, and can be implemented by any state-of-the-art structure including a pre-activation residual unit and an inception block. The mask branch uses a bottom-up top-down structure to learn a mask of the same size that softly weights output features from the trunk branch. A sigmoid layer normalizes the output to $[0,1]$ after two $1\times 1$ convolution layers. Overall the residual attention mechanism can be written as \begin{align} s &= \sigma(\text{Conv}_{2}^{1\times 1}(\text{Conv}_{1}^{1\times 1}( h_\text{up}(h_\text{down}(X))))) \\ X_{out} &= s f(X) + f(X) \end{align} where $h_\text{up}$ is a bottom-up structure, using max-pooling several times after residual units to increase the receptive field, while $h_\text{down}$ is the top-down part using linear interpolation to keep the output size the same as the input feature map. There are also skip-connections between the two parts, which are omitted from the formulation. $f$ represents the trunk branch which can be any state-of-the-art structure. Inside each attention module, a bottom-up top-down feedforward structure models both spatial and cross-channel dependencies, leading to a consistent performance improvement. Residual attention can be incorporated into any deep network structure in an end-to-end training fashion. However, the proposed bottom-up top-down structure fails to leverage global spatial information. Furthermore, directly predicting a 3D attention map has high computational cost. \subsubsection{CBAM} To enhance informative channels as well as important regions, Woo et al.~\cite{woo2018cbam} proposed the \emph{convolutional block attention module} (CBAM) which stacks channel attention and spatial attention in series. It decouples the channel attention map and spatial attention map for computational efficiency, and leverages spatial global information by introducing global pooling. CBAM has two sequential sub-modules, channel and spatial. Given an input feature map $X\in \mathbb{R}^{C\times H \times W}$ it sequentially infers a 1D channel attention vector $s_c\in \mathbb{R}^C$ and a 2D spatial attention map $s_s\in \mathbb{R}^{H\times W}$. The formulation of the channel attention sub-module is similar to that of an SE block, except that it adopts more than one type of pooling operation to aggregate global information. In detail, it has two parallel branches using max-pool and avg-pool operations: \begin{align} F_\text{avg}^c &= \text{GAP}^s(X) \\ F_\text{max}^c &= \text{GMP}^s(X) \\ s_c &= \sigma(W_2\delta(W_1 F_\text{avg}^c)+W_2\delta(W_1 F_\text{max}^c))\\ M_c(X) &= s_c X \end{align} where $\text{GAP}^s$ and $\text{GMP}^s$ denote global average pooling and global max pooling operations in the spatial domain. The spatial attention sub-module models the spatial relationships of features, and is complementary to channel attention. Unlike channel attention, it applies a convolution layer with a large kernel to generate the attention map \begin{align} F_\text{avg}^s &= \text{GAP}^c(X) \\ F_\text{max}^s &= \text{GMP}^c(X) \\ s_s &= \sigma(\text{Conv}([F_\text{avg}^s;F_\text{max}^s]))\\ M_s(X) &= s_s X \end{align} where $\text{Conv}(\cdot)$ represents a convolution operation, while $\text{GAP}^c$ and $\text{GMP}^c$ are global pooling operations in the channel domain. $[]$ denotes concatenation over channels. The overall attention process can be summarized as \begin{align} X' &= M_c(X) \\ Y &= M_s(X') \end{align} Combining channel attention and spatial attention sequentially, CBAM can utilize both spatial and cross-channel relationships of features to tell the network \emph{what} to focus on and \emph{where} to focus. To be more specific, it emphasizes useful channels as well as enhancing informative local regions. Due to its lightweight design, CBAM can be integrated into any CNN architecture seamlessly with negligible additional cost. Nevertheless, there is still room for improvement in the channel \& spatial attention mechanism. For instance, CBAM adopts a convolution to produce the spatial attention map, so the spatial sub-module may suffer from a limited receptive field. \subsubsection{BAM} At the same time as CBAM, Park et al.~\cite{park2018bam} proposed the \emph{bottleneck attention module} (BAM), aiming to efficiently improve the representational capability of networks. It uses dilated convolution to enlarge the receptive field of the spatial attention sub-module, and build a \emph{bottleneck structure} as suggested by ResNet to save computational cost. For a given input feature map $X$, BAM infers the channel attention $s_c \in \mathbb{R}^C$ and spatial attention $s_s\in \mathbb{R}^{H\times W}$ in two parallel streams, then sums the two attention maps after resizing both branch outputs to $\mathbb{R}^{C\times H \times W}$. The channel attention branch, like an SE block, applies global average pooling to the feature map to aggregate global information, and then uses an MLP with channel dimensionality reduction. In order to utilize contextual information effectively, the spatial attention branch combines a bottleneck structure and dilated convolutions. Overall, BAM can be written as \begin{align} s_c &= \text{BN}(W_2(W_1\text{GAP}(X)+b_1)+b_2) \\ s_s &= \text{BN}(\text{Conv}_{2}^{1\times 1}(\text{DC}_{2}^{3\times 3}(\text{DC}_{1}^{3\times 3}(\text{Conv}_{1}^{1\times 1}(X))))) \\ s &= \sigma(\text{Expand}(s_s)+\text{Expand}(s_c)) \\ Y &= s X+X \end{align} where $W_i$, $b_i$ denote weights and biases of fully connected layers respectively, $\text{Conv}_{1}^{1\times 1}$ and $\text{Conv}_{2}^{1\times 1}$ are convolution layers used for channel reduction. $\text{DC}_i^{3\times 3}$ denotes a dilated convolution with $3\times 3$ kernel, applied to utilize contextual information effectively. $\text{Expand}$ expands the attention maps $s_s$ and $s_c$ to $\mathbb{R}^{C\times H\times W}$. BAM can emphasize or suppress features in both spatial and channel dimensions, as well as improving the representational power. Dimensional reduction applied to both channel and spatial attention branches enables it to be integrated with any convolutional neural network with little extra computational cost. However, although dilated convolutions enlarge the receptive field effectively, it still fails to capture long-range contextual information as well as encoding cross-domain relationships. \subsubsection{scSE} To aggregate global spatial information, an SE block applies global pooling to the feature map. However, it ignores pixel-wise spatial information, which is important in \gmh{dense prediction tasks}. Therefore, Roy et al.~\cite{roy2018recalibrating} proposed \emph{spatial and channel SE blocks} (scSE). Like BAM, spatial SE blocks are used, complementing SE blocks, to provide spatial attention weights to focus on important regions. Given the input feature map $X$, two parallel modules, spatial SE and channel SE, are applied to feature maps to encode spatial and channel information respectively. The channel SE module is an ordinary SE block, while the spatial SE module adopts $1\times 1$ convolution for spatial squeezing. The outputs from the two modules are fused. The overall process can be written as \begin{align} s_c & = \sigma (W_{2} \delta (W_{1}\text{GAP}(X))) \\ X_\text{chn} & = s_c X \\ s_s &= \sigma(\text{Conv}^{1\times 1}(X)) \\ X_\text{spa} & = s_s X \\ Y &= f(X_\text{spa},X_\text{chn}) \end{align} where $f$ denotes the fusion function, which can be maximum, addition, multiplication or concatenation. The proposed scSE block combines channel and spatial attention to enhance features as well as capturing pixel-wise spatial information. Segmentation tasks are greatly benefited as a result. The integration of an scSE block in F-CNNs makes a consistent improvement in semantic segmentation at negligible extra cost. \subsubsection{Triplet Attention} In CBAM and BAM, channel attention and spatial attention are computed independently, ignoring relationships between these two domains~\cite{misra2021rotate}. Motivated by spatial attention, Misra et al.~\cite{misra2021rotate} proposed \emph{triplet attention}, a lightweight but effective attention mechanism to capture cross-domain interaction. Given an input feature map $X$, triplet attention uses three branches, each of which plays a role in capturing cross-domain interaction between any two domains from $H$, $W$ and $C$. In each branch, rotation operations along different axes are applied to the input first, and then a Z-pool layer is responsible for aggregating information in the zeroth dimension. Finally, a standard convolution layer with kernel size $k\times k$ models the relationship between the last two domains. This process can be written as \begin{align} X_1 &= \text{Pm}_1(X) \\ X_2 &= \text{Pm}_2(X) \\ s_0 &= \sigma(\text{Conv}_0(\text{Z-Pool}(X))) \\ s_1 &= \sigma(\text{Conv}_1(\text{Z-Pool}(X_1))) \\ s_2 &= \sigma(\text{Conv}_2(\text{Z-Pool}(X_2))) \\ Y &= \frac{1}{3}(s_0X + \text{Pm}_1^{-1} (s_1X_1)+\text{Pm}_2^{-1}(s_2X_2 )) \end{align} where $\text{Pm}_1$ and $\text{Pm}_2$ denote rotation through 90$^\circ$ anti-clockwise about the $H$ and $W$ axes respectively, while $\text{Pm}^{-1}_i$ denotes the inverse. $\text{Z-Pool}$ concatenates max-pooling and average pooling along the zeroth dimension. \begin{align} Y = \text{Z-Pool}(X) &= [ \text{GMP}(X); \text{GAP}(X)] \end{align} Unlike CBAM and BAM, triplet attention stresses the importance of capturing cross-domain interactions instead of computing spatial attention and channel attention independently. This helps to capture rich discriminative feature representations. Due to its simple but efficient structure, triplet attention can be easily added to classical backbone networks. \subsubsection{SimAM} Yang et al.~\cite{pmlr-v139-simam} also stress the importance of learning attention weights that vary across both channel and spatial domains in proposing SimAM, a simple, parameter-free attention module capable of directly estimating 3D weights instead of expanding 1D or 2D weights. The design of SimAM is based on well-known neuroscience theory, thus avoiding need for manual fine tuning of the network structure. Motivated by the spatial suppression phenomenon~\cite{Webb_spatial_supp}, they propose that a neuron which shows suppression effects should be emphasized and define an energy function for each neuron as: \begin{align} \label{eq_sim_energy} e_{t}(w_{t}, b_{t}, y, x_{i}) = (y_{t} - \hat{t})^{2} + \frac{1}{M-1} \sum_{i=1}^{M-1}(y_{o} - \hat{x}_{i}) \end{align} where $\hat{t}=w_{t}t+b_{t}$, $\hat{x}_{i} = w_{t}x_{i}+b_{t}$, and $t$ and $x_{i}$ are the target unit and all other units in the same channel; $i \in {1, \dots, N}$, and $ N= H \times W$. An optimal closed-form solution for Eq.~\ref{eq_sim_energy} exists:\begin{align} \label{eq_sim_solution} e_{t}^{\ast} = \frac{4(\hat{\sigma}^{2} + \lambda)}{(t - \hat{\mu})^2 + 2\hat{\sigma}^{2} + 2\lambda} \end{align} where $\hat{\mu}$ is the mean of the input feature and $\hat{\sigma}^{2}$ is its variance. A sigmoid function is used to control the output range of the attention vector; an element-product is applied to get the final output: \begin{align} Y = \text{Sigmoid}\left(\frac{1}{E}\right) X \end{align} This \mtj{work} simplifies the process of designing attention and successfully proposes a novel 3-D weight parameter-free attention module based on mathematics and neuroscience theories. \subsubsection{Coordinate attention} An SE block aggregates global spatial information using global pooling before modeling cross-channel relationships, but neglects the importance of positional information. BAM and CBAM adopt convolutions to capture local relations, but fail to model long-range dependencies. To solve these problems, Hou et al.~\cite{hou2021coordinate} proposed \emph{coordinate attention}, a novel attention mechanism which embeds positional information into channel attention, so that the network can focus on large important regions at little computational cost. The coordinate attention mechanism has two consecutive steps, coordinate information embedding and coordinate attention generation. First, two spatial extents of pooling kernels encode each channel horizontally and vertically. In the second step, a shared $1\times 1$ convolutional transformation function is applied to the concatenated outputs of the two pooling layers. Then coordinate attention splits the resulting tensor into two separate tensors to yield attention vectors with the same number of channels for horizontal and vertical coordinates of the input $X$ along. This can be written as \begin{align} z^h &= \text{GAP}^h(X) \\ z^w &= \text{GAP}^w(X) \\ f &= \delta(\text{BN}(\text{Conv}_1^{1\times 1}([z^h;z^w]))) \\ f^h, f^w &= \text{Split}(f) \\ s^h &= \sigma(\text{Conv}_h^{1\times 1}(f^h)) \\ s^w &= \sigma(\text{Conv}_w^{1\times 1}(f^w)) \\ Y &= X s^h s^w \end{align} where $\text{GAP}^h$ and $\text{GAP}^w$ denote pooling functions for vertical and horizontal coordinates, and $s^h \in \mathbb{R}^{C\times 1\times W}$ and $s^w \in \mathbb{R}^{C\times H\times 1}$ represent corresponding attention weights. Using coordinate attention, the network can accurately obtain the position of a targeted object. This approach has a larger receptive field than BAM and CBAM. Like an SE block, it also models cross-channel relationships, effectively enhancing the expressive power of the learned features. Due to its lightweight design and flexibility, it can be easily used in classical building blocks of mobile networks. \subsubsection{DANet} In the field of scene segmentation, encoder-decoder structures cannot make use of the global relationships between objects, whereas RNN-based structures heavily rely on the output of the long-term memorization. To address the above problems, Fu et al.~\cite{Fu_2019_danet} proposed a novel framework, the \emph{dual attention network} (DANet), for natural scene image segmentation. Unlike CBAM and BAM, it adopts a self-attention mechanism instead of simply stacking convolutions to compute the spatial attention map, which enables the network to capture global information directly. DANet uses in parallel a position attention module and a channel attention module to capture feature dependencies in spatial and channel domains. Given the input feature map $X$, convolution layers are applied first in the position attention module to obtain new feature maps. Then the position attention module selectively aggregates the features at each position using a weighted sum of features at all positions, where the weights are determined by feature similarity between corresponding pairs of positions. The channel attention module has a similar form except for dimensional reduction to model cross-channel relations. Finally the outputs from the two branches are fused to obtain final feature representations. For simplicity, we reshape the feature map $X$ to $C\times (H \times W)$ whereupon the overall process can be written as \begin{align} Q,\quad K,\quad V &= W_qX,\quad W_kX,\quad W_vX \\ Y^\text{pos} &= X+ V\text{Softmax}(Q^TK) \\ Y^\text{chn} &= X+ \text{Softmax}(XX^T)X \\ Y &= Y^\text{pos} + Y^\text{chn} \end{align} where $W_q$, $W_k$, $W_v \in \mathbb{R}^{C\times C}$ are used to generate new feature maps. The position attention module enables DANet to capture long-range contextual information and adaptively integrate similar features at any scale from a global viewpoint, while the channel attention module is responsible for enhancing useful channels as well as suppressing noise. Taking spatial and channel relationships into consideration explicitly improves the feature representation for scene segmentation. However, it is computationally costly, especially for large input feature maps. \subsubsection{RGA} Unlike coordinate attention and DANet, which emphasise capturing long-range context, in \emph{relation-aware global attention} (RGA)~\cite{zhang2020relation}, Zhang et al. stress the importance of global structural information provided by pairwise relations, and uses it to produce attention maps. RGA comes in two forms, \emph{spatial RGA} (RGA-S) and \emph{channel RGA} (RGA-C). RGA-S first reshapes the input feature map $X$ to $C\times (H\times W)$ and the pairwise relation matrix $R \in \mathbb{R}^{(H\times W)\times (H\times W)}$ is computed using \begin{align} Q &= \delta(W^QX) \\ K &= \delta(W^KX) \\ R &= Q^TK \end{align} The relation vector $r_i$ at position $i$ is defined by stacking pairwise relations at all positions: \begin{align} r_i = [R(i, :); R(:,i)] \end{align} and the spatial relation-aware feature $y_i$ can be written as \begin{align} Y_i = [g^c_\text{avg}(\delta(W^\varphi x_i)); \delta(W^\phi r_i)] \end{align} where $g^c_\text{avg}$ denotes global average pooling in the channel domain. Finally, the spatial attention score at position $i$ is given by \begin{align} a_i = \sigma(W_2\delta(W_1y_i)) \end{align} RGA-C has the same form as RGA-S, except for taking the input feature map as a set of $H\times W$-dimensional features. RGA uses global relations to generate the attention score for each feature node, so provides valuable structural information and significantly enhances the representational power. RGA-S and RGA-C are flexible enough to be used in any CNN network; Zhang et al. propose using them jointly in sequence to better capture both spatial and cross-channel relationships. \subsubsection{Self-Calibrated Convolutions} Motivated by the success of group convolution, Liu et at~\cite{Liu_2020_scnet} presented \emph{self-calibrated convolution} as a means to enlarge the receptive field at each spatial location. Self-calibrated convolution is used together with a standard convolution. It first divides the input feature $X$ into $X_{1}$ and $X_{2}$ in the channel domain. The self-calibrated convolution first uses average pooling to reduce the input size and enlarge the receptive field: \begin{align} T_{1} = \text{AvgPool}_{r}(X_{1}) \end{align} where $r$ is the filter size and stride. Then a convolution is used to model the channel relationship and a bilinear interpolation operator $Up$ is used to upsample the feature map: \begin{align} X'_{1} = \text{Up}(\text{Conv}_2(T_{1})) \end{align} Next, element-wise multiplication finishes the self-calibrated process: \begin{align} Y'_{1} = \text{Conv}_3(X_{1}) \sigma(X_{1} + X'_{1}) \end{align} Finally, the output feature map of is formed: \begin{align} Y_{1} &= \text{Conv}_4(Y'_{1}) \\ Y_2 &= \text{Conv}_1(X_2) \\ Y &= [Y_1; Y_2] \end{align} Such self-calibrated convolution can enlarge the receptive field of a network and improve its adaptability. It achieves excellent results in image classification and certain downstream tasks such as instance segmentation, object detection and keypoint detection. \subsubsection{SPNet} Spatial pooling usually operates on a small region which limits its capability to capture long-range dependencies and focus on distant regions. To overcome this, Hou et al.~\cite{hou2020strip} proposed \emph{strip pooling}, a novel pooling method capable of encoding long-range context in either horizontal or vertical spatial domains. Strip pooling has two branches for horizontal and vertical strip pooling. The horizontal strip pooling part first pools the input feature $F \in \mathcal{R}^{C \times H \times W}$ in the horizontal direction: \begin{align} y^1 = \text{GAP}^w (X) \end{align} Then a 1D convolution with kernel size 3 is applied in $y$ to capture the relationship between different rows and channels. This is repeated $W$ times to make the output $y_v$ consistent with the input shape: \begin{align} y_h = \text{Expand}(\text{Conv1D}(y^1)) \end{align} Vertical strip pooling is performed in a similar way. Finally, the outputs of the two branches are fused using element-wise summation to produce the attention map: \begin{align} s &= \sigma(\text{Conv}^{1\times 1}(y_{v} + y_{h})) \\ Y &= s X \end{align} The strip pooling module (SPM) is further developed in the mixed pooling module (MPM). Both consider spatial and channel relationships to overcome the locality of convolutional neural networks. SPNet achieves state-of-the-art results for several complex semantic segmentation benchmarks. \subsubsection{SCA-CNN} As CNN features are naturally spatial, channel-wise and multi-layer, Chen et al.~\cite{ChenZXNSLC17} proposed a novel \emph{spatial and channel-wise attention-based convolutional neural network} (SCA-CNN). It was designed for the task of image captioning, and uses an encoder-decoder framework where a CNN first encodes an input image into a vector and then an LSTM decodes the vector into a sequence of words. Given an input feature map $X$ and the previous time step LSTM hidden state $h_{t-1} \in \mathbb{R}^d$, a spatial attention mechanism pays more attention to the semantically useful regions, guided by LSTM hidden state $h_{t-1}$. The spatial attention model is: \begin{align} a(h_{t-1}, X) &= \tanh(\text{Conv}^{1\times1}_1(X)\oplus W_1h_{t-1}) \\ \Phi_s(h_{t-1}, X) &= \text{Softmax}(\text{Conv}^{1\times1}_2(a(h_{t-1}, X))) \end{align} where $\oplus$ represents addition of a matrix and a vector. Similarly, channel-wise attention aggregates global information first, and then computes a channel-wise attention weight vector with the hidden state $h_{t-1}$: \begin{align} b(h_{t-1}, X) &= \tanh((W_2\text{GAP}(X)+b_2)\oplus W_1h_{t-1}) \\ \Phi_c(h_{t-1}, X) &= \text{Softmax}(W_3(b(h_{t-1}, X))+b_3) \end{align} Overall, the SCA mechanism can be written in one of two ways. If channel-wise attention is applied before spatial attention, we have \begin{align} \label{eq_cs_sca} Y &= f(X,\Phi_s(h_{t-1}, X \Phi_c(h_{t-1}, X)), \Phi_c(h_{t-1}, X)) \end{align} and if spatial attention comes first: \begin{align} \label{eq_sc_sca} Y &= f(X,\Phi_s(h_{t-1}, X), \Phi_c(h_{t-1}, X \Phi_s(h_{t-1}, X))) \end{align} where $f(\cdot)$ denotes the modulate function which takes the feature map $X$ and attention maps as input and then outputs the modulated feature map $Y$. Unlike previous attention mechanisms which consider each image region equally and use global spatial information to tell the network where to focus, SCA-Net leverages the semantic vector to produce the spatial attention map as well as the channel-wise attention weight vector. Being more than a powerful attention model, SCA-CNN also provides a better understanding of where and what the model should focus on during sentence generation. \subsubsection{GALA} Most attention mechanisms learn where to focus using only weak supervisory signals from class labels, which inspired Linsley et al.~\cite{LinsleySES19} to investigate how explicit human supervision can affect the performance and interpretability of attention models. As a proof of concept, Linsley et al. proposed the \emph{global-and-local attention} (GALA) module, which extends an SE block with a spatial attention mechanism. Given the input feature map $X$, GALA uses an attention mask that combines global and local attention to tell the network where and on what to focus. As in SE blocks, global attention aggregates global information by global average pooling and then produces a channel-wise attention weight vector using a multilayer perceptron. In local attention, two consecutive $1\times 1$ convolutions are conducted on the input to produce a positional weight map. The outputs of the local and global pathways are combined by addition and multiplication. Formally, GALA can be represented as: \begin{align} s_g &= W_{2} \delta (W_{1}\text{GAP}(x)) \\ s_l &= \text{Conv}_2^{1\times 1} (\delta(\text{Conv}_1^{1\times1}(X))) \\ s_g^* &= \text{Expand}(s_g) \\ s_l^* &= \text{Expand}(s_l) \\ s &= \tanh(a (s_g^*+s_l^*)+m\cdot (s_g^* s_l^*)) \\ Y &= sX \end{align} where $a,m \in \mathbb{R}^{C}$ are learnable parameters representing channel-wise weight vectors. Supervised by human-provided feature importance maps, GALA has significantly improved representational power and can be combined with any CNN backbone. \subsection{Spatial \& Temporal Attention} Spatial \& temporal attention combines the advantages of spatial attention and temporal attention as it adaptively selects both important regions and key frames. Some works~\cite{song2016end,rstan} compute temporal attention and spatial attention separately, while others~\cite{Fu_2019_STA} produce joint spatiotemporal attention maps. Further works focusing on capturing pair-wise relations~\cite{yang2020spatial}. Representative spatial \& temporal attention attentions and specific process $g(x)$ and $f(g(x), x)$ described as Eq.~\ref{eq_general} are summarised in Tab.~\ref{spatial_temporal_attentions}. We next discuss specific spatial \& temporal attention mechanisms \gmh{according to the order in Fig.~\ref{fig:total_attention_summary}}. \begin{table*} \centering \caption{Representative spatial \& temporal attentions sorted by date. Action=action recognition, ReID = re-identification. Ranges means the ranges of attention map. S or H means soft or hard attention. $g(x)$ and $f(g(x), x)$ are the attention process described by Eq.~\ref{eq_general}. (A)element-wise product.(B) aggregate information via attention map.(\uppercase\expandafter{\romannumeral1}) emphasize key points in both spatial and temporal domains, (\uppercase\expandafter{\romannumeral2})capture global information.} \label{spatial_temporal_attentions} \begin{tabular}{|p{2cm}|p{2cm}|p{1.5cm}|p{1cm}|p{3cm}|p{1.4cm}|p{1.2cm}|p{0.8cm}|p{1.0cm}|} \hline \textbf{Category} & \textbf{Method} & \textbf{Publication} & \textbf{Tasks} & \textbf{$\bm{g(x)}$} & \textbf{$\bm{f(g(x), x)}$} & \textbf{Ranges} & \textbf{S or H} & \textbf{Goals} \\ \hline Separately predict spatial \& temporal attention & STA-LSTM~\cite{song2016end} & AAAI2017 & Action &{a)spatial: fuse hidden state -> MLP -> Softmax, b)temporal: fuse hidden state -> MLP -> ReLU} & (A) & {(0,1), (0,+$\infty$)} & {S} & {(\uppercase\expandafter{\romannumeral1}) } \\ \cline{2-9} & RSTAN~\cite{rstan} & TIP2018 & Action &{a)spatial: fuse hidden state -> MLP -> Softmax, b)temporal: fuse hidden state -> MLP -> Softmax } &(B)&{(0,1)}&{S}&{(\uppercase\expandafter{\romannumeral1}) (\uppercase\expandafter{\romannumeral2})} \\ \hline Jointly predict spatial \& temporal attention & STA~\cite{Fu_2019_STA} & AAAI2019 & ReID &{a) tenporal: produce per-frame attention maps using $l_2$ norm b) spatial: obtain spatial scores for each patch by summation using $l_1$ norm.} &{(B)}&{(0,1)}&{S} & {(\uppercase\expandafter{\romannumeral1})} \\ \hline Pairwise relation-based method & STGCN~\cite{yang2020spatial} & CVPR2020 & ReID &{ construct a patch graph using pairwise similarity} &{(B)}&{(0,1)}&{S} & {(\uppercase\expandafter{\romannumeral1})} \\ \hline \end{tabular} \end{table*} \subsubsection{STA-LSTM} In human action recognition, each type of action generally only depends on a few specific kinematic joints~\cite{song2016end}. Furthermore, over time, multiple actions may be performed. Motivated by these observations, Song et al.~\cite{song2016end} proposed a joint spatial and temporal attention network based on LSTM~\cite{HochSchm97_lstm}, to adaptively find discriminative features and keyframes. Its main attention-related components are a spatial attention sub-network, to select important regions, and a temporal attention sub-network, to select key frames. The spatial attention sub-network can be written as: \begin{align} s_{t} &= U_{s}\tanh(W_{xs}X_{t} + W_{hs}h_{t-1}^{s} + b_{si}) + b_{so} \\ \alpha_{t} &= \text{Softmax}(s_{t}) \\ Y_{t} &= \alpha_{t} X_{t} \end{align} where $X_{t}$ is the input feature at time $t$, $U_{s}$, $W_{hs}$, $b_{si}$, and $b_{so}$ are learnable parameters, and $h_{t-1}^{s}$ is the hidden state at step $t-1$. Note that use of the hidden state $h$ means the attention process takes temporal relationships into consideration. The temporal attention sub-network is similar to the spatial branch and produces its attention map using: \begin{align} \beta_{t} = \delta(W_{xp}X_{t} + W_{hp}h_{t-1}^{p} + b_{p}). \end{align} It adopts a ReLU function instead of a normalization function for ease of optimization. It also uses a regularized objective function to improve convergence. Overall, this paper presents a joint spatiotemporal attention method to focus on important joints and keyframes, with excellent results on the action recognition task. \subsubsection{RSTAN} To capture spatiotemporal contexts in video frames, Du et al.~\cite{rstan} introduced \emph{spatiotemporal attention} to adaptively identify key features in a global way. The spatiotemporal attention mechanism in RSTAN consists of a spatial attention module and a temporal attention module applied serially. Given an input feature map $X\in \mathbb{R}^{D\times T\times H\times W}$ and the previous hidden state $h_{t-1}$ of an RNN model, spatiotemporal attention aims to produce a spatiotemporal feature representation for action recognition. First, the given feature map $X$ is reshaped to $\mathbb{R}^{D\times T\times (H\times W)}$, and we define $X(n,k)$ as the feature vector for the $k$-th location of the $n$-th frame. At time $t$, the spatial attention mechanism aims to produce a global feature $l_n$ for each frame, which can be written as \begin{align} \alpha_t(n,k) &= w_\alpha \tanh(W_hh_{t-1}+W_{x}X(n,k)+b_\alpha) \\ \alpha_t^*(n,k) &= {e^{\gamma_\alpha\alpha_t(n,k)}}/{\sum_{j=1}^{W\times H}e^{\gamma_\alpha\alpha_t(n,k)}} \\ l_n &= \sum_{k=1}^{H\times W}\alpha_t^*(n,k) X(n,k) \end{align} where $\gamma_\alpha$ is introduced to control the sharpness of the location-score map. After obtaining frame-wise features $\{l_1,\dots,l_T\}$, RSTAN uses a temporal attention mechanism to estimate the importance of each frame feature \begin{align} \beta_t(n) &= w_\beta \tanh(W_h'h_{t-1}+W_{l}l(n)+b_\beta) \\ \beta_t^*(n) &= {e^{\gamma_\beta\beta_t(n)}}/{\sum_{j=1}^{T}e^{\gamma_\beta\beta_t(n)}} \\ \phi_t &= \sum_{n=1}^{T}\beta_t^*(n) l(n) \end{align} The spatiotemporal attention mechanism used in RSTAN identifies those regions in both spatial and temporal domains which are strongly related to the prediction in the current step of the RNN. This efficiently enhances the representation power of any 2D CNN. \subsubsection{STA} Previous attention-based methods for video-based person re-identification only assigned an attention weight to each frame and failed to capture joint spatial and temporal relationships. To address this issue, Fu et al.~\cite{Fu_2019_STA} propose a novel \emph{spatiotemporal attention} (STA) approach, which assigns attention scores for each spatial region in different frames without any extra parameters. Given the feature maps of an input video $\{X_n|X_n\in \mathbb R^{C\times H\times W}\}_{n=1}^N$, STA first generates frame-wise attention maps by using the $l_2$ norm on the squares sum in the channel domain: \begin{align} g_n(h,w) = \frac{||\sum_{c=1}^C X_n(c,h,w)^2||_2}{\sum_{h=1}^H \sum_{w=1}^W ||\sum_{c=1}^C X_n(c,h,w)^2||_2} \end{align} Then both the feature maps and attention maps are divided into $K$ local regions horizontally, each of which represents one part of the person. The spatial attention score for region $k$ is obtained using \begin{align} s_{n,k} = \sum_{(i,j)\in \text{Region}_k}||g_n(i,j)||_1 \end{align} To capture the relationships between regions in different frames, STA applies $l_1$ normalization to the attention scores in the temporal domain, using \begin{align} S(n,k) = \frac{s_{n,k}}{\sum_{n=1}^N ||s_{n,k}||_1} \end{align} Finally, STA splits the input feature map $X_i$ into $K$ regions $\{X_{n,1},\dots,X_{n,K}\}$ and computes the output using \begin{align} Y^1 &= [X_{\arg\max_{n}S(n,1),1};\dots;X_{\arg\max_{n}S(n,K),K}] \\ Y^2 &= [\sum_{n=1}^N S(n,1)X_{n,1};\dots;\sum_{n=1}^N S(n,K)X_{n,K}] \\ Y &= [Y^1;Y^2] \end{align} Instead of computing spatial attention maps frame by frame, STA considers spatial and temporal attention information simultaneously, fully using the discriminative parts in both dimensions. This reduces the influence of occlusion. Because of its non-parametric design, STA can tackle input video sequences of variable length; it can be combined with any 2D CNN backbone. \subsubsection{STGCN} To model the spatial relations within a frame and temporal relations across frames, Yang et al.~\cite{yang2020spatial} proposed a novel \emph{spatiotemporal graph convolutional network} (STGCN) to learn a discriminative descriptor for a video. It constructs a patch graph using pairwise similarity, and then uses graph convolution to aggregate information. STGCN includes two parallel GCN branches, the temporal graph module and the structural graph module. Given the feature maps of a video, STGCN first horizontally partitions each frame into $P$ patches and applies average pooling to generate patch-wise features ${x_1,\dots,x_N}$, where the total number of patches is $N=T P$. For the temporal module, it takes each patch as a graph node and construct a patch graph for the video, where the adjacency matrix $\widehat{A}$ is obtained by normalizing the pairwise relation matrix $E$, defined as \begin{align} E(i,j) &= (W^\phi x_i)^T W^\phi x_j \\ A(i,j) &= {E^2(i,j)}/{\sum_{j=1}^N E^2(i,j)} \\ \widehat{A} &= D^{-\frac{1}{2}}(A+I)D^{-\frac{1}{2}} \end{align} where $D(i,i) = \sum_{j=1}^N (A+I)(i,j)$. Given the adjacency matrix $\widehat{A}$, the $m$-th graph convolution can be found using \begin{align} X^m = \widehat{A} X^{m-1} W^m + X^{m-1} \end{align} where $X \in \mathbb{R}^{N \times c}$ represents the hidden features for all patches and $W^m \in \mathbb{R}^{c\times c}$ denotes the learnable weight matrix for the $m$-th layer. For the spatial module, STGCN follows a similar approach of adjacency matrix and graph convolution, except for modeling the spatial relations of different regions within a frame. Flattening spatial and temporal dimensions into a sequence, STGCN applies the GCN to capture the spatiotemporal relationships of patches across different frames. Pairwise attention is used to obtain the weighted adjacency matrix. By leveraging spatial and temporal relationships between patches, STGCN overcomes the occlusion problem while also enhancing informative features. It can used with any CNN backbone to process video. \section{Future directions} \label{sec:direction} We present our thoughts on potential future research directions. \subsection{\gmh{Necessary and sufficient condition for attention}} We find the Eq.~\ref{eq_general} is a necessary condition but not a necessary and sufficient condition. For instance, GoogleNet~\cite{szegedy2014going} conforms to the above formula, but does not belong to the attention mechanisms. Unfortunately, we find it difficult to find a necessary and sufficient condition for all attention mechanisms. The necessary and sufficient conditions for the attention mechanism are still worth exploring which can promote our understanding of attention mechanisms. \subsection{General attention block} At present, a special attention mechanism needs to be designed for each different task, which requires considerable effort to explore potential attention methods. For instance, channel attention is a good choice for image classification, while \gmh{spatial attention} is well-suited to dense prediction tasks such as semantic segmentation and object detection. Channel attention focuses on \emph{what to pay attention to} while spatial attention considers \emph{where to pay attention}. Based on this observation, we encourage consideration as to whether there could be a general attention block that takes advantage of all kinds of attention mechanisms. For example, a soft selection mechanism (branch attention) could choose between channel attention, spatial attention and temporal attention according to the specific task undertaken. \subsection{Characterisation and interpretability} Attention mechanisms are motivated by the human visual system and are a step towards the goal of building an interpretable computer vision system. Typically, attention-based models are understood by rendering attention maps, as in Fig.~\ref{fig:attention_map_vit}. However, this can only give an intuitive feel for what is happening, rather than precise understanding. However, applications in which security or safety are important, such as medical diagnostics and automated driving systems, often have stricter requirements. Better characterisation of how methods work, including modes of failure, is needed in such areas. Developing characterisable and interpretable attention models could make them more widely applicable. \subsection{\gmh{Sparse activation}} We visualize some attention map and obtains consistent conclusion with ViT~\cite{dosovitskiy2020vit} shown in Fig.~\ref{fig:attention_map_vit} that attention mechanisms can produce sparse activation. There phenomenon give us a inspiration that sparse activation can achieve a strong performance in deep neural networks. It is worth noting that sparse activation is similar with human cognition. Those motivate us to explore which kind of architecture can simulate human visual system. \subsection{Attention-based pre-trained models} Large-scale attention-based pre-trained models have had great success in natural language processing~\cite{brown2020language, bao2021beit}. Recently, MoCoV3~\cite{chen2021empirical_mocov3}, DINO~\cite{caron2021emerging}, BEiT~\cite{bao2021beit} and MAE~\cite{he2021masked} have demonstrated that attention-based models are also well suited to visual tasks. Due to their ability to adapt to varying inputs, attention-based models can deal with unseen objects and are naturally suited to transferring pretrained weights to a variety of tasks. We believe that the combination of pre-training and attention models should be further explored: training approach, model structures, pre-training tasks and the scale of data are all worth investigating. \subsection{Optimization} SGD~\cite{qian99_sgd} and Adam~\cite{kingma2017adam} are well-suited for optimizing convolutional neural networks. For visual transformers, AdamW~\cite{loshchilov2019decoupled} works better. Recently, Chen et al.~\cite{chen2021vision} significantly improved visual transformers by using a novel optimizer, the \emph{sharpness-aware minimizer} (SAM)~\cite{foret2021sharpnessaware}. It is clear that attention-based networks and convolutional neural networks are different models; different optimization methods may work better for different models. Investigating new optimzation methods for attention models is likely to be worthwhile. \subsection{Deployment} Convolutional neural networks have a simple, uniform structure which makes them easy to deploy on various hardware devices. However, it is difficult to optimize complex and varied attention-based models on edge devices. Nevertheless, experiments in~\cite{liu2021swin, wu2021cvt, yuan2021volo} show that attention-based models provide better results than convolutional neural networks, so it is worth trying to find simple, efficient and effective attention-based models which can be widely deployed. \section{Conclusions} \label{sec:conclusion} Attention mechanisms have become an indispensable technique in the field of computer vision in the era of deep learning. This survey has systematically reviewed and summarized attention mechanisms for deep neural networks in computer vision. We have grouped different attention methods according to their domain of operation, rather than by application task, and show that attention models can be regarded as an independent topic in their own right. We have concluded with some potential directions for future research. We hope that this work will encourage a variety of potential application developers to put attention mechanisms to use to improve their deep learning results. We also hope that this survey will give researchers a deeper understanding of various attention mechanisms and the relationships between them, as a springboard for future research. \ifCLASSOPTIONcompsoc \section*{Acknowledgments} This work was supported by the Natural Science Foundation of China (Project 61521002, 62132012). We would like to thank Cheng-Ze Lu, Zhengyang Geng, Shilong liu, He Wang, Huiying Lu and Chenxi Huang for their helpful discussions and insightful suggestions. \else \section*{Acknowledgment} \fi \ifCLASSOPTIONcaptionsoff \newpage \fi \bibliographystyle{IEEEtran}
{'timestamp': '2021-11-16T02:29:12', 'yymm': '2111', 'arxiv_id': '2111.07624', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07624'}
arxiv
\section{Introduction} Named-entity recognition (NER) is the common NLP task of classifying named entities appearing in texts into pre-defined categories. The most prevalent type of NER is in-domain recognition, in which the model is trained on a well-studied domain that contains a large amount of labeled data such as news and also evaluated on texts from the same domain. However, it is common that texts might originate from different domains and we need to perform NER well on a new domain \cite{lee2018transfer}. But retraining the model on the target domain is not necessarily an option since labeled data of good quality can be difficult, expensive, and time-consuming to obtain. Label scarcity is especially pronounced for patient note de-identification, the task of removing protected health information from medical notes. Tuning NER systems to perform well in a new domain by hand is possible, but requires significant effort and is often not feasible \cite{lee2018transfer}. In this scenario, we have to resort to cross-domain NER. Having a system that can perform well on domains where labeled data is scarce or even non-existing would be extremely valuable. We propose ZERO, a model that performs zero-shot or few-shot learning in NER with external knowledge. The external knowledge comes in the form of word embeddings originating from either GloVe or Conceptnet Numberbatch \cite{sennington2014glove,speer2019ensemble,speer2017conceptnet}. We obtain word embeddings for each label as well as entity representations from LUKE (Language Understanding with Knowledge-based Embeddings) for each token in the sentences \cite{yamada2020luke}. For each entity, we calculate dot products for all possible entity-label pairs and obtain the corresponding probabilities for these pairs. The label with the highest probability will be the output label. This enables us to obtain a probability value directly from the pre-trained embeddings rather than relying on having learned the labels during training. The main contributions of our work are: \begin{itemize} \item ZERO would allow training a well-performing NER model without any labeled examples in target domains which saves efforts and expenses on labeling. \item ZERO outperforms LUKE in few-shot learning. When there are only a few samples in the target domain, ZERO serves as a better choice to accomplish the NER tasks. \item We find that the KL divergence is inversely correlated with ZERO's performance and can be used to estimate how well it will perform on a given source-target domain transfer. \end{itemize} \section{Related work} \subsection{LUKE} We use pre-trained LUKE (Language Understanding with Knowledge-based Embeddings) as our backbone architecture \cite{yamada2020luke}. LUKE is based on a transformer trained on a large amount of entity-annotated corpora obtained from Wikipedia \cite{vaswani2017attention}. A key difference between LUKE and other contextualized word representations (CWRs) is that LUKE regards both words and entities as independent tokens allowing intermediate and output representations to be computed for all tokens using the transformer (see Figure \ref{fig:zero}). Since entities are regarded as tokens, LUKE can be used to directly model the relationships between entities. \subsection{Zero-Shot Learning} Zero-shot learning is the task of predicting labels not seen during training. Pioneering research on zero-shot learning began in the area of computer vision and used human-engineered features encoded as vectors. These vectors denote the presence or absence of any of the features \cite{5206772,5206594}. The model then learns a direct mapping between the image features and the class vectors and is able to predict unseen class encodings. \subsection{Commonsense Knowledge and Word Embeddings} Commonsense knowledge is the type of knowledge that most humans are expected to know about the everyday world, e.g.\ ``a car is capable of driving''. The current SOTA commonsense knowledge graph is ConceptNet which employs knowledge from a combination of crowdsourced and expert-created resources \cite{speer2017conceptnet}. Roy et al.\ describe an approach for encoding commonsense knowledge to a zero-shot learning system using ConceptNet and a graph convolution network-based autoencoder \cite{roy2020common}. However, for NLP-related tasks where we can directly encode a ``meaning'' in the words in the form of word embeddings, this step can be avoided. Word2Vec popularized the concept of word embeddings and was since improved upon by GloVe \cite{mikolov2013word2vec, sennington2014glove}. The Conceptnet Numberbatch is an ensemble of the word embeddings Word2Vec, GloVe, and FastText retrofitted with the ConceptNet knowledge graph \cite{bojanowski2017fasttext, speer2019ensemble}. This retrofitted embedding is shown to be superior to e.g.\ GloVe for a wide array of tasks \cite{speer2019ensemble}. \section{Methodology} The architecture of ZERO is shown in Figure \ref{fig:zero}. The first input of the model is a tokenized sentence. Each token is assumed to have an embedding representation $\mathbf{x}_i$, $i \in 1, \dots, K$ where $K$ equals the number of tokens in the input sentence. The second input is the source and target domain, which we use to indicate the corresponding label set. Inspired by the most recent works on NER, we adopt a network base to obtain a contextualized representation of words and entities \cite{devlin2019bert}. For this component, which we indicate as $\phi$, we take inspiration from the LUKE architecture since it is the current state-of-the-art of traditional NER \cite{yamada2020luke}. LUKE outputs contextualized representation for each word and entity. The LUKE model is trained on a set of downstream tasks, such as NER and Q\&A. Since the LUKE network has no knowledge of what the domain of the input sentence is, we use the output representation as the contextual token features. We denote such a vector as $\mathbf{h}_i=\phi(\mathbf{x}_i)$, where $i \in 1, \dots, K$. Once given the domain, each label entity features $\mathbf{e}_j$ are derived from the pre-trained distributed word embedding, such as GloVe or Conceptnet Numberbatch that aim to capture the label's semantics. An FCN then reduces the dimensionality of $\mathbf{h}_i$ to a more compact representation before we finally compute the dot product of each token feature $\mathbf{h}_i$ with each of the label entity features $\mathbf{e}_j$. We use Eq.\ (\ref{eq:zero-eq}) to annotate the $i$-th token with the final prediction. \begin{equation} \label{eq:zero-eq} y_i = \underset{j}{\mathrm{argmax}}(\mathrm{softmax}(\mathbf{h}_i \cdot \mathbf{e}_j)) \end{equation} \begin{figure*}[ht] \begin{center} \includegraphics[width=\textwidth]{zero.png} \end{center} \caption{ZERO - Zero-shot learning architecture.} \label{fig:zero} \end{figure*} \section{Experiments} \subsection{Dataset} We use the CrossNER dataset \cite{liu2020crossner}. It consists of a general news domain \textit{Reuters} as well as the five domains \textit{AI}, \textit{literature} (LI), \textit{music} (MU), \textit{politics} (PO), and \textit{natural science} (NS) with 900-1400 labeled NER samples per domain. The domains have shared general categories such as ``person'' and ``location'' and their own specialized entity categories such as ``book'' and ``poem'' for the domain of literature. \subsection{Results} The results for a zero-shot learning, few-shot learning, and in-domain context are shown in respectively Figure \ref{fig:word-embed-res}, Figure \ref{fig:few-shot-learning}, and Table \ref{tab:in-domain}. \begin{figure}[ht!] \begin{center} \includegraphics[width=\linewidth]{macro-f1-confusion-h.pdf} \end{center} \caption{Macro F1 scores for zero-shot learning (multiplied by 100 for readability). Rows are the source (train) domains and columns are the target (test) domains. The average of non-diagonal values is 0.2323 (GloVe) and 0.2283 (ConceptNet). } \label{fig:word-embed-res} \end{figure} \begin{figure}[ht!] \begin{center} \includegraphics[width=\linewidth]{luke-compare-big.pdf} \end{center} \caption{Macro F1 scores for few-shot learning. $n \in \{0, 1, 5, 10\}$ training examples per label from the target domain seen during training. Scores are the average of the domain pairs of music-science and science-music.} \label{fig:few-shot-learning} \end{figure} \begin{table}[ht!] \centering \begin{tabular}{lccccc} \hline & AI & LI & MU & PO & NS \\ \hline Z & 0.769 & 0.703 & 0.772 & \textbf{0.886} & 0.770 \\ L & \textbf{0.772} & \textbf{0.747} & \textbf{0.871} & 0.875 & \textbf{0.783} \\ \hline \end{tabular} \caption{Macro F1 scores in an in-domain context of respectively ZERO (Z) using GloVe and LUKE (L). In-domain refers to the source and target domain being the same.} \label{tab:in-domain} \end{table} \section{Discussions} \subsection{Word Embedding Comparison} In Figure \ref{fig:word-embed-res}, we observe noticeable better macro F1 scores of ZERO when we use GloVe for the underlying word embeddings as compared to Conceptnet Numberbatch. This is an interesting finding, since as mentioned Conceptnet Numberbatch is shown to be superior to GloVe for a wide array of tasks. We hypothesized that while Conceptnet is superior in general, GloVe might be particularly good for the specific labels and concepts in CrossNER. To test our hypothesis using a quantifiable method, we extract the embeddings for all labels and concepts. With these, we perform unsupervised clustering using $k$-Means where we know in reality there should be 5 clusters. Comparing the obtained clusters to the ground truth labels with standard clustering performance metrics in Table \ref{tab:cluter-metrics}, we find that GloVe indeed results in better clusters for our task. \begin{table}[H] \centering \begin{tabular}{lrr} \hline & Adj.\ Rand Score & V-Measure \\ \hline GloVe & \textbf{0.0630} & \textbf{0.1230} \\ ConceptNet & -0.0307 & 0.0971 \\ \hline \end{tabular} \caption{Adjusted rand score and V-Measure when performing $k$-Means with $k=5$.} \label{tab:cluter-metrics} \end{table} \subsection{Correlation Between Domain Similarity and Performance} We explore whether the performance obtained on all domain pairs using the GloVe embeddings is correlated with the domain similarity. Vocabulary distributions are established for each domain based on word frequencies of the corpora of these domains and then all distributions are defined on the same probability space. We calculate the KL divergence between all domain pairs $P-Q$ as in Eq.\ (\ref{eq:kl}) to represent domain distances. $D_{\textrm{KL}} (P \ || \ Q)$, the KL divergence from domain $Q$ to domain $P$, is regarded as the distance when the model is transferred from domain $Q$ to domain $P$. For all words $w \in \mathscr{V}$ where $\mathscr{V}$ is the global vocabulary space, we denote $P(w)$ as the probability distribution function for $w$ in domain $P$. \begin{equation} \label{eq:kl} D_{\textrm{KL}} (P\ || \ Q) = \sum_{w\in\mathscr{V}} P(w)\log \left( \frac{P(w)}{Q(w)} \right) \end{equation} A regression line is fit based on the performances and distances. The regression result is displayed in Figure \ref{fig:per-sim} which shows an inverse correlation between the F1 macro score and KL divergence with an $R^2$ of $0.19$. This gives us an intuition that if the similarity from one domain to another domain is very high the corresponding domain adaptation will have a higher tendency to perform well. \begin{figure}[H] \begin{center} \includegraphics[width=\linewidth]{similarity-performance.pdf} \end{center} \caption{Correlation between domain similarity (divergence) and performance.} \label{fig:per-sim} \end{figure} \subsection{In-Domain Comparison With LUKE} We evaluate the strength of our approach by comparing the in-domain performance of ZERO against LUKE, meaning that both models are trained and tested in the same domain. As shown in Table \ref{tab:in-domain}, we find that jointly learning with additional domain features is able to achieve competitive macro F1 scores. Except for the music domain, ZERO only performs slightly worse than LUKE in the domains of AI, literature, and science. \subsection{Few-Shot Learning} We examine how effective ZERO is in a few-shot learning setting. We add a few training examples per label from the target domain and compare the performance of ZERO in terms of F1 score against LUKE where both are trained on the original training examples from the source domain and the additional few training examples from the target domain. Our observations show that ZERO significantly outperforms LUKE when the number of training examples on the target domain is small. Specifically, given a single training example per label, LUKE obtains a 0 macro F1 score whereas ZERO obtains 0.5507 or a 0.2766 improvement from the zero-shot learning setting. \subsection{Limitations} With an average macro F1 score of 0.2323 for zero-shot-learning, the performance might not yet be good enough for practical applications. For example, for patient note de-identification, this performance would not be acceptable since it would fail to remove a large amount of the protected health information. Furthermore, the small size of the CrossNER dataset may result in both greater uncertainty of the results and lower performance of the trained model. Other large datasets such as CoNLL-2003 for NER exist, but they are limited to a single domain. These problems could be solved if larger datasets with more samples per label and more domains existed. \section{Conclusion} We propose a zero-shot learning NER approach with external knowledge. In contrast to traditional NER models like LUKE, our model utilises dot products of label entity features and token features to classify, allowing it to perform inference without retraining on the target domain. Experiments show that our model outperforms LUKE in zero-shot and few-shot learning; meanwhile, it also gets comparable results with LUKE in supervised in-domain recognition. Future work may explore more recent SOTA pre-trained language models and word embeddings. Furthermore, a solution to the limited size of the CrossNER dataset would be to artificially create a larger cross-domain dataset. One could, for example, use a dataset such as CoNLL-2003 which is based on the domain of news for training and then test the performance on another large dataset such as AnEM which is based on the domain of anatomy. Thus the zero-shot learning method is preserved while allowing for much larger training datasets and hence better generalization. \newpage \section{Broader Impact} Improvements in cross-domain NER has a large number of beneficial applications for society, namely the ones that benefit from being able to perform NER in a domain where little to no training data is available. However, we understand that it also has potentially harmful consequences. In case of failure of the NER system, it can have severe implications depending on the domain and use case. E.g.\ for the application of patient note de-identification, it would mean that protected health information would be kept in the medical notes that were to be distributed to a larger population, severely harming the anonymity of the individuals who happened to be kept in the medical notes. ZERO is also likely display certain biases towards different genders, ethnicity etc. This is largely due to the fact that our proposed system utilizes word embeddings for the external knowledge, which have been shown to include biases \cite{Bolukbasi2016}. For a dataset like CrossNER, if e.g.\ the embedding of `scientist' is closer to the embeddings of male or western-sounding names than to those of female or black-sounding names, then it would mean minorities would more often be missed by the system, enforcing stereotypes and possibly harming publicity and career aspects of the individuals affected. There are known methods for minimizing biases in word embeddings and these should be applied before deploying ZERO in a production scenario \cite{Bolukbasi2016, ananya2019genderquant}.
{'timestamp': '2021-11-16T02:33:39', 'yymm': '2111', 'arxiv_id': '2111.07734', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07734'}
arxiv
\section{Introduction} A crucial question arising in machine learning is how to \emph{certify} the generalisation ability of a predictor. Commonly, the quality of a predictor is estimated by its average error on a finite sample, namely a held-out test set, despite the fact that sample averages have many well-known shortcomings (sampling error, sensitivity to outliers, and in general being a poor numerical summary for many types of distributions). In statistical learning theory, the generalisation ability of a predictor is given by its risk, also known as out-of-sample error, which is a measure of how accurately it performs on random data from the same distribution that generated the training data. The learning theory community has great interest in generalisation bounds, which upper-bound the gap between the out-of-sample error and the sample average, and provide statistically sound performance guarantees. Generalisation bounds are constructed so that (i) they are valid at population level (i.e. not just the given finite sample) and (ii) they hold with high confidence. These two properties overcome some of the shortcomings of test set errors. The machine learning practitioner community, on the other hand, has great interest in numerical measures of performance that are informative and of practical use. Therefore, for generalisation bounds to be of interest to practitioners, an additional and much desirable property is \emph{tightness} of the bounds. Intuitively speaking, when a generalisation bound is tight, its numerical values are informative of the (inaccessible) value of the true risk or out-of-sample error. The best known generalisation bounds for neural network classifiers are test set bounds \cite{Langford2002,LangfordCaruana2001} and PAC-Bayes bounds \cite{LangfordCaruana2001,McAllester1998,McAllester1999,catoni2004,catoni2007,alquier2021user}. Test set bounds, as their name indicate, are evaluated on a held-out dataset which may not be used for learning a predictor. However, these bounds are simple and cost-effective to compute and can be used with any deterministic predictor. PAC-Bayes bounds, on the other hand, can be computed on training data exclusively, meaning they could potentially avoid the need to hold out data and instead make it possible to use all the available data for learning a predictor. They rely, nonetheless, on randomised predictors and are more costly in terms of computation. The question of comparing PAC-Bayes bounds and test set bounds has been revisited recently by \cite{foong2021tight}, who showed that PAC-Bayes bounds could be of comparable tightness to test set bounds. Earlier findings had made significant progress towards non-vacuous \cite{dziugaite2017computing} and tighter \cite{perez2020} PAC-Bayes bounds. Our paper draws inspiration from \cite{foong2021tight} where it is asked how tight PAC-Bayes bounds can be in the small data regime when compared to test set bounds. This is, of course, a very relevant question, given that holding out data can harm the learning process when dealing with a small dataset, and this could be avoided when using PAC-Bayes bounds. The core research question we attempt to answer with our work is whether we can leverage this advantage of PAC-Bayes bounds (through self-certified learning) to learn accurate predictors and certify their risk in datasets of different sizes. Recently, learning strategies that optimise PAC-Bayes bounds \cite{dziugaite2017computing,perez2020} have shown great promise, by delivering randomised neural network predictors that are competitive compared to the test set error rates obtained by standard empirical risk minimisation (ERM), as well as tight risk certificates \cite{perez2020}. Tightness is, we believe, what sets the difference between `certificates' (which might be of practical use) and traditional guarantees (which may still be of interest but may not be truly informative of the predictor's generalisation ability in cases when they are loose). For the sake of consensus, we propose to say that a numerical generalisation bound value is`tight' when it shows the same order of magnitude as the best test set error estimates that have been reported in the literature for a given dataset. In particular, this implies that the requirement of `tightness' is stronger than requiring non-vacuous values: For an estimator of a probability of error, a non-vacuous value is any probability value smaller than 1 which corresponds to what was called non-trivial value in \cite{LangfordCaruana2001}, while a tight value needs to be really very close to the probability of error it is trying to estimate. Recent works \cite{dziugaite2017computing,perez2020} have focused on Probabilistic Neural Network (PNN) models, which are realised as probability distributions over the neural network weight space \cite{blundell2015weight}. PNNs themselves come with many advantages, such as enabling principled approaches for uncertainty quantification \cite{blundell2015weight}. However, most importantly, PNNs coupled with PAC-Bayes bounds delivered the first non-vacuous generalisation bound values for overparametrised neural network classifiers \cite{dziugaite2017computing}, and more recently it was reported that this combination could bring us closer to the concept of self-certified learning \cite{perez2020,Freund1998}. For emphasis, in the self-certified learning paradigm one uses all the available data for (i) learning a predictor and (ii) certifying the predictor's performance at population level with high confidence and with a numerical value that is tight. The certification strategy would then not require held-out validation and test sets, which may allow a more efficient use of the available data (in contrast to test set bounds and most traditional risk estimation strategies used in the machine learning community, which require held-out data). Achieving self-certified learning could radically change not only how we compute generalisation ability but also how we approach model selection in machine learning, since both could be done without needing to hold out data \cite{perez2020} which might be more efficient. Such methods would also provide statistically sound and tight risk certificates that might be useful in machine learning research and algorithmic governance. However, to claim self-certified learning we first require self-certification strategies that deliver tight risk certificates \cite{perez2020}, so that the certificates are indeed informative of the true out-of-sample error. Again, the tightness is crucial, and it could be observed if the computed certificates closely match the error rates evaluated on a test set. In this paper, we evaluate the progress towards self-certification by comparing self-certified PAC-Bayes inspired PNNs to standard neural networks learnt by ERM where we evaluate the performance with test set bounds and test set errors. Thus, the question we ask is whether self-certified learning has been achieved, i.e., if we achieve better results by using all the available data for learning using our PAC-Bayes inspired algorithmic recipe. Fig.~\ref{fig:partitions} shows the data partitions used at the different stages of learning and certification for (i) traditional learning strategies and (ii) our strategy leading to self-certified predictors. \begin{figure*}[t!] \begin{center} \centerline{\includegraphics[width=0.90\textwidth]{drawing3.pdf}} \caption{Comparison of data partitions in traditional machine learning vs. self-certified learning through PAC-Bayes inspired learning and certification strategies \protect\cite{perez2020}. Note that the latter does use data partitions, but in such a way to effectively use all the available data for learning the predictor } \label{fig:partitions} \end{center} \end{figure*} \section{Elements of Statistical Learning} Supervised classification algorithms receive training data $S = ((X_1,Y_1),\ldots,(X_n,Y_n))$ consisting of pairs that encode inputs $X_i \in \cX \subseteq \R^d$ and their labels $Y_i \in \cY$. Classifiers $h_w : \cX \to \cY$ are mappings from input space $\cX$ to label space $\cY$, and we assume they are parametrised by `weight vectors' $w \in \cW \subseteq \R^p$. The quality of $h_w$ is given by its risk $L(w)$, which by definition is the expected classification error on a randomly chosen pair $(X,Y)$. However, $L(w)$ is an inaccessible measure of quality, since the distribution that generates the data is unknown. An accessible measure of quality is given by the empirical risk functional $\hat{L}_S(w) = n^{-1}\sum_{i=1}^{n} \ell(h_w(X_i),Y_i)$, defined in terms of a loss function $\ell : \R \times \cY \rightarrow [0,\infty)$ which may be the zero-one loss or a surrogate loss function. Indeed, the empirical risk minimisation (ERM) paradigm aims to find $w \in \cW$ that minimises this empirical functional, typically for some choice of surrogate loss that is amenable to gradient-based optimisation, such as the squared loss or the cross-entropy loss for classification. The outcome of training a PNN is a distribution $Q$ over weight space and this distribution depends on the sample $S$. Then, given a fresh input $X$, the randomised classifier predicts its label by drawing a weight vector $W$ at random from $Q$ and applying the predictor $h_W$ to $X$. For the sake of simplicity, we identify the randomised predictor with the distribution $Q$ that defines it. The quality of this randomised predictor is measured by the expected loss notions under the random draws of weights. Thus, the loss of $Q$ is given by $L(Q) = \int_{\cW} L(w) Q(dw)$; and the empirical loss of $Q$ is given by $\hat{L}_S(Q) = \int_{\cW} \hat{L}_S(w) Q(dw)$. The PAC-Bayes-quadratic bound \cite{perez2020} says that for any $\delta \in (0,1)$, with probability of at least $1-\delta$ over size-$n$ i.i.d. random samples $S$, simultaneously for all distributions $Q$ over $\cW$ we have: \begin{equation} \label{eq:quad-bound} L(Q) \leq \left( \sqrt{ \hat{L}_S(Q) + \frac{\KL(Q \Vert Q^0) + \log(\frac{2\sqrt{n}}{\delta})}{2n} } \right. \nonumber + \left. \sqrt{ \frac{\KL(Q \Vert Q^0) + \log(\frac{2\sqrt{n}}{\delta})}{2n} } \right)^2. \end{equation} In this case the prior $Q^0$ must be chosen without any dependence on the data $S$ on which the empirical term $\hat{L}_S$ is evaluated. In this work, we use a partitioning scheme for the training data $S = S_{\mathrm{pri}} \cup S_{\mathrm{cert}}$ such that the prior is trained on $S_{\mathrm{pri}}$, the posterior is trained on the whole set $S$ and the risk certificate is evaluated on $S_{\mathrm{cert}}$. See Fig.~\ref{fig:partitions}. The `prior' and `posterior' distributions that appear in PAC-Bayes bounds should not be confused with their Bayesian counterparts. In PAC-Bayes bounds, what is called `prior' is a reference distribution, and what is called `posterior' is an unrestricted distribution, in the sense that there is no likelihood factor connecting them (we refer the reader to \cite{guedj2019primer,rivasplata2020beyond}). \section{Learning and Certification Strategy} In a nutshell, the learning and certification strategy used (we refer to \cite{perez2020, perezortiz2021learning}) has three components: (1) choose/learn a prior; (2) learn a posterior; and (3) evaluate the risk certificate for the posterior. \subsection{Data-dependent PAC-Bayes priors} We experiment with Gaussian PAC-Bayes priors $Q^0$ with a diagonal covariance matrix centered at (i) random weights (uninformed data-free priors) and (ii) learnt weights (data-dependent priors) based on a subset of the dataset which is does not overlap with the subset used to compute the risk certificate (see Fig.~\ref{fig:partitions}). In all cases, the posterior is initialised to the prior. Similar approaches have been considered before in the PAC-Bayesian literature (we refer to \cite{% JMLR:v13:parrado12a, perez2020, dziugaite2021role% }). To learn the prior mean we use ERM with dropout. The prior scale is set as a hyperparameter as done in \cite{perez2020}. \subsection{Posterior Optimisation \& Certification} We now present the essential idea of training PNNs by minimising a PAC-Bayes upper bound on the risk. We use a recently proposed PAC-Bayes inspired training objective \cite{perez2020}, derived from Eq.~\eqref{eq:quad-bound} in the context of neural network classifiers: \begin{equation} \label{eq:obj-quad} f_{\mathrm{quad}}(Q) = \left( \sqrt{ \hat{L}^{\text{x-e}}_S(Q) + \frac{\KL(Q \Vert Q^0) + \log(\frac{2\sqrt{n}}{\delta})}{2n} } \right. \nonumber + \left. \sqrt{ \frac{\KL(Q \Vert Q^0) + \log(\frac{2\sqrt{n}}{\delta})}{2n} } \right)^2. \end{equation} This objective is implemented using the cross-entropy loss, which is the standard surrogate loss commonly used in neural network classification. Since the PAC-Bayes bounds of Eq.~\eqref{eq:quad-bound} require the loss within [0,1], we construct a `bounded cross-entropy' loss by lower-bounding the network probabilities by a value $p_\mathrm{min}>0$ (cf. \cite{dziugaite2018data, perez2020}) and re-scaling the resulting bounded loss to [0,1]. The empirical risk term $\hat{L}^{\text{x-e}}_S(w)$ is then calculated with this bounded version of the cross-entropy loss. Optimisation of the objective in Eq. \eqref{eq:obj-quad} entails minimising over $Q$. By choosing $Q$ in a parametric family of distributions, we can use the pathwise gradient estimator (see e.g. \cite{jankowiak2018pathwise}) as done by \cite{blundell2015weight}. The details of the reparameterisation strategy are outlined in \cite{perez2020}. Following \cite{blundell2015weight}, the reparameterisation we use is $W = \mu + \sigma \odot V$ with Gaussian distributions for each coordinate of $V$. The optimisation uses $\sigma = \log(1+\exp(\rho))$, thus gradient updates are with respect to $\mu$ and $\rho$. \subsection{Evaluation of the Risk Certificates} After optimising the posterior distribution over network weights through the previously presented training objective, we compute a risk certificate on the error of the stochastic predictor. To do so, we follow the procedure outlined in \cite{perez2020}, which was used before by \cite{dziugaite2017computing} and goes back to the work of \cite{LangfordCaruana2001}. This certification procedure uses the PAC-Bayes-kl bound. In particular, the procedure is based on numerical inversion of the binary KL divergence, as done by \cite{dziugaite2017computing,perez2020}. \section{Experiments} Our work aims at empirically investigating these questions: \emph{ Could self-certified learning algorithms inspired by PAC-Bayes bounds, making use of all the available data, provide tighter risk certificates than test set bounds? How far are these bounds (both kinds) from test set errors? Can we conclude that the numerical bound values are close enough to the out-of-sample errors? In other words, has self-certified learning been achieved? } To answer these questions, we compare: (a) PNNs learnt by optimising the PAC-Bayes-quadratic bound following \cite{perez2020} (both in a self-certified and traditional data partition fashion) and (b) standard neural networks learnt by empirical risk minimisation (traditional strategy, \emph{i.e.,} using a held-out test set). For the former we compute the PAC-Bayes-kl bound from \cite{LangfordCaruana2001}, while the latter is evaluated with a test set bound (we used the Chernoff and binomial test set bounds, see \cite{Langford2002} and the recent \cite{foong2021tight}). \subsection{Experimental setup} In all experiments the models are compared under the same experimental conditions, \emph{i.e.} architecture, weight initialisation and optimiser (SGD with momentum), as well as data partitions and confidence for the bounds. The prior mean $\mu_0$ for each weight is initialised randomly from a truncated centered Gaussian distribution with standard deviation set to $1/\sqrt{n_\mathrm{in}}$, where $n_\mathrm{in}$ is the dimension of the inputs to a particular layer, truncating at $\pm 2$ standard deviations. All risk certificates are computed using the the PAC-Bayes-kl inequality, as explained in Section 6 of \cite{perez2020}, with $\delta=0.025$ and $\delta'=0.01$ and $m=150 000$ Monte Carlo model samples. We report the average 01 error of the stochastic predictor, where we randomly sample fresh model weights for each test example $100$ times and compute the average 01 error. Input data was standardised for all datasets. Test set bounds are evaluated with $\delta = 0.035$ (to match the total confidence level $0.025 + 0.01$ used for the PAC-Bayes-kl bound). We experiment with fully connected neural networks (FCN) with 3 layers (excluding the `input layer') and 100 units per hidden layer. ReLU activations are used in each hidden layer. For learning the prior we ran the training for 500 epochs. Posterior training was run for 100 epochs. We use a training batch size of $250$. ERM was run for $600$ epochs. In all experiments we reserve 1\% of the training data (or prior training data in the case of PAC-Bayes inspired learning) to validate the prior, as done in \cite{perezortiz2021learning}. Note, however, that this `prior validation data' is later used to learn the posterior, so it is ultimately used during training For all experiments we use the same hyper-parameters, which were found to work well in previous work and architectures for these datasets \cite{perezortiz2021learning}. However, previous work has shown that hyperparameter tuning could be done in a self-certified fashion, not needing any validation sets and using PAC-Bayes bounds \cite{perez2020}. The prior distribution scale hyper-parameter (i.e., standard deviation $\sigma_0$) is set to $0.005$. For SGD with momentum the learning rate is set to $1\mathrm{e}^{-3}$ and momentum to $0.95$. The same values are used for learning the prior. The dropout rate used for learning the prior was $0.01$ and applied to all layers. For PAC-Bayes inspired learning, we test multiple splits of data for learning the prior and certifying the posterior from $0.5$ to $0.8$ and choose the one that provides the best risk certificates, as it has been shown that the optimal percentage may be dataset dependent \cite{perezortiz2021learning}. \begin{table}[ht!] \centering \small \setlength{\tabcolsep}{3pt} \begin{tabular}{| c | cc c|} \hline Dataset & $n$ & $\#f$ & $\#c$ \\ \hline Bioresponse & 3751 & 1777 & 2 \\ Spambase & 4601 & 58 & 2 \\ Har & 10299 & 562 & 6 \\ Mammography & 11183 & 7 & 2 \\ \hline \end{tabular} \vspace{1.5mm} \caption{Datasets used. In the rightmost columns, $n$ is the total number of data points for the dataset, $\#f$ is the number of features (i.e., input dimension), and $\#c$ is the number of classes. } \label{tab:datasets} \end{table} We experiment with the four datasets described in Table~\ref{tab:datasets}, which are publicly available (\url{OpenML.org}) and were selected so as to represent a wide range of characteristics (dataset size, data dimensionality, and number of classes). Moreover, we create datasets of different sizes by removing data at random. Our experiments span $[0.00, 0.25, 0.50, 0.75, 0.90, 0.95, 0.97, 0.98]$\% of data removed at random for each dataset. For all datasets we selected 10\% of the data as test set (stratified with class label). \begin{figure*}[h!] \begin{center} \centerline{\includegraphics[width=\textwidth]{firstexpsv1.pdf}} \caption{Left panel: we compare test set errors for standard neural networks learnt by ERM and PNNs learnt by PAC-Bayes inspired objectives. Right panel: we compare values of the PAC-Bayes-kl bound for the self-certified PNN and the PNN certified with traditional partitions. The latter uses a held out test set. } \label{fig:averagecomparison} \end{center} \end{figure*} \begin{figure*}[h!] \begin{center} \centerline{\includegraphics[width=\textwidth]{drawingresults.pdf}} \caption{Comparison of results obtained with (i) self-certified PNNs with PAC-Bayes bounds and (ii) traditional learning standard neural networks with test set bounds. Note that in both cases the compared strategies make use the same amount of data, however the self-certified learner uses all available data for training, instead of holding out part of the data for testing, as done in the traditional certification cases. The plot shows mean and confidence intervals computed over $5$ runs.} \label{fig:selfcertifiedcomparison} \end{center} \vspace*{-3mm} \end{figure*} \subsection{Results} We experiment with the four mentioned datasets (see Table~\ref{tab:datasets}) and study the small data regime (\emph{i.e.,} we remove data at random from each dataset). In all cases, we reserve 10\% of the available data as test (except for self-certified PNNs, which use all the available data for training). Note that our results and conclusions may be susceptible to the percentage of data that is reserved for testing purposes, as this will impact the gains achieved by self-certified learning, as well as the predictors in traditional strategies and the test set bounds. In our experience, similar results were obtained when holding 20\% of data as test. Note that when we remove data we do so from the whole dataset, which effectively impacts the size of the test set. This is to mimic more realistically what would happen in the small data regime in which both training and test sets are reduced. For a related prior work exploring how tight PAC-Bayes bounds can be in the small data regime, with comparison to test set bounds, see \cite{foong2021tight}. This comparison between PAC-Bayes bounds and test set bounds is particularly interesting in the data starvation regime as one cannot hold-out data without significantly affecting the learning process, in particular how well the data distribution is captured during learning, which could also consequentially harm the performance of the predictor. We reiterate that \cite{foong2021tight} is a prior work to ours which in fact influenced our work significantly, in particular regarding the choice of test set bounds (binomial and Chernoff bounds) for the deterministic NNs as reference measures to which the values obtained via the PAC-Bayes-kl bound for PNNs are compared. The left plot of Fig.~\ref{fig:averagecomparison} shows test set errors for deterministic neural networks and PNNs. First, we note that these models have comparable test set performance. Additionally, the test set error of the stochastic predictor (when sampling networks from the posterior distribution) does not deviate significantly from the test set error of the posterior mean. This has been shown in the literature before \cite{perez2020, dziugaite2018data}, with the intuition that these training objectives may promote flatter minima. The right plot of Fig.~\ref{fig:averagecomparison} shows a comparison of the PAC-Bayes certificate for PNNs obtained by the self-certified strategy and those that used the traditional learning strategy. As expected, risk certificates seem to be improved by a self-certified setting, but especially so in the small data regime. Both plots show the average across 4 datasets (which are subsets of those described in Table~\ref{tab:datasets}) and 5 runs per dataset. Fig.~\ref{fig:selfcertifiedcomparison} shows a comparison of self-certified learning with PAC-Bayes bounds and the traditional learning strategy with test set bounds for 4 datasets and different amounts of data missing at random. The results show that the PAC-Bayes bound of the self-certified version is competitive with the test set bounds for the traditional setting, specially with the commonly used Chernoff bound. In the small data regime (specifically when removing at least 75\% of training data), self-certified learning shows a clear advantage, demonstrating significantly tighter bounds than both of the test set bounds considered for traditional learning. See for example the case of Spambase and Bioresponse (the smallest datasets), where test set bounds on the zero-one error achieve values between 0.7 and 0.8, while PAC-Bayes bounds stay below 0.2 and 0.5 respectively. We hypothesise that we cannot see such a difference for Har and Mammography because these datasets are initially larger, so removing 98\% of the data at random would still give a dataset of around 206 and 224 points respectively, whereas for Spambase and Bioresponse we would have a total dataset size of 92 and 75 data points. Interestingly, our empirical findings disagree with the ones in \cite{foong2021tight}, a very related work that studies theoretically and empirically how tight can PAC-Bayes can be in the small data regime. In \cite{foong2021tight} it is reported that PAC-Bayes bounds can be, at most, of comparable tightness than test set bounds; whereas we find that, if using a self-certified learning strategy, PAC-Bayes certification strategies could deliver tighter bounds than traditional learning strategies with test set bounds. This difference could be explained by the fact that our settings are significantly different in terms of training strategies and datasets. Note that our experiments are on real benchmark datasets, while theirs rely on a synthetic classification dataset with one-dimensional inputs. Perhaps the most significant difference is the strategy to learn the predictors: our strategy consists of learning a posterior over weights by minimising a PAC-Bayes bound, while theirs uses meta-learning to find algorithms that are suited for a given bound so that effectively their strategy produces meta-learners that are trained to optimise the value of the bound in expectation over the given task distribution. \section{Discussion} This work is an empirical analysis of the progress towards self-certified neural networks, where we experiment with predictors trained on all the available data for a given dataset and certified via a PAC-Bayes generalisation bound. With this approach, we do not need held-out sets for certifying the performance of the predictor or for hyperparameter tuning \cite{perez2020}. In turn, we hypothesize that this use of all the available data could lead to predictors of better quality, specially if the additional data (test set data traditionally held out for evaluating a point estimator for the out-of-sample error) may significantly improve how well the data distribution is captured by the sample. Our results first show that self-certified PNNs trained optimising PAC-Bayes inspired objectives reach competitive risk certificates compared to predictors evaluated with commonly used test set bounds. At the same time, the numerical values of both types of bounds are shown to be relatively close to test set errors. These conclusions are especially true for the small data regime, where PAC-Bayes bounds with self-certified learning strategies give significantly tighter values than Chernoff and binomial tail test set bounds. Thus, self-certified learning can be claimed to have been achieved in the small data regime. Obviously, unlike the widespread practice, we will not be able to evaluate the `test error' for these predictors that use all the available data for training, but in any case we believe that the community should move to more reliable estimators of performance, as summarised by the discussion of the shortcomings of sample averages such as the test set error. Instead, the performance of these predictors could be certified by tight risk certificates, which may be evaluated using PAC-Bayes generalisation bounds. These not only have been recently shown to be tight \cite{perez2020}, but also to correlate linearly with test set errors across multiple datasets \cite{perezortiz2021learning}. The point on correlation between the risk certificates and the test set errors may indicate that the said certificates also correlate with the out-of-sample errors. This effectively could mean that if the generalisation bound achieved by using all data in a self-certified fashion has a small value, then we can expect the out-of-sample error to have a small value as well, hypothetically meaning that we have a better predictor! Validation of this hypothesis will require experimenting on more datasets. A limitation worth mentioning of the PAC-Bayes inspired self-certified strategy is computational cost. This is because i) PNNs require twice the parameters than standard neural networks, ii) PAC-Bayes inspired training objectives are also more costly than empirical risk minimisation and iii) finally, the certification strategy requires Monte Carlo sampling. This computational cost, however, seems viable for the small data regime. We will study in future work the scalability of the approach to larger datasets and deeper architectures. We believe that as new generalisation bounds are developed and used to inspire learning algorithms, we may get closer to the ambitious promise of self-certified learning, where all data can be used to learn and certify a predictor (without needing to hold-out test set data for measuring generalisation ability and model selection purposes) and we have statistically sound risk certificates of predictors' performance which do not suffer from sampling bias and hence could be used for setting performance standards when developing and governing machine learning algorithms. \begin{ack} We gratefully acknowledge support and funding from the U.S. Army Research Laboratory and the U. S. Army Research Office, and by the U.K. Ministry of Defence and the U.K. Engineering and Physical Sciences Research Council (EPSRC) under grant number EP/R013616/1. This work is also partially supported by the European Commission funded project "Humane AI: Toward AI Systems That Augment and Empower Humans by Understanding Us, our Society and the World Around Us" (grant 820437). Omar Rivasplata gratefully acknowledges funding from the U.K. Engineering and Physical Sciences Research Council (EPSRC) under grant number EP/W522636/1. Emilio Parrado-Hern\'andez acknowledges support from the Spanish State Research Agency (AEI) through project PID2020-115363RB-I00. \end{ack}
{'timestamp': '2021-12-13T02:14:41', 'yymm': '2111', 'arxiv_id': '2111.07737', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07737'}
arxiv
\section{Introduction and Related Work} \label{sec:Introduction} Reinforcement Learning shows great potential for tasks with clearly specified objectives, such as games \citep{mnih2015human, silver2016mastering, openai2019dota}. Yet, in many real-world scenarios, manually specifying a suitable reward is complicated and can lead to unintended behavior. Thus, Inverse Reinforcement Learning (IRL) \citep{russell1998learning} aims at recovering a reward from expert demonstrations instead. Many tasks allow various solutions and different experts may chose different approaches, leading to multi-modal, versatile demonstrations. Properly capturing this versatility does not only better reflects the nature of the task but also naturally provides robustness to changes in the environment. See Figure \ref{fig:introduction} for an example. Many approaches \citep{ziebart2008maximum, ziebart2010maxcausalent, ratliff2006maximum, brown2019extrapolating, brown2020better} use uni-modal policies together with maximum likelihood objectives, which forces the model to average over modes of data that cannot be represented. Another recent line of work \citep{finn2016guided, fu2018learning} is closely connected to Generative Adversarial Networks \citep{goodfellow2014generative}. They build on Generative Aderversarial Imitation Learning \citep{ho2016generative}, but reparameterize the discriminator by inserting the learned policy. It can be shown that this modified discriminator then estimates the density of the expert demonstrations, which can be used as a reward. These methods implicitly optimize the reverse KL-divergence allowing them to focus on a single behavior. See e.g., \citep{ghasemipour2020imitationLearning, arenz2020nonadversarial} for a detailed discussion. While this prevents averaging over multiple potential solutions, the uni-modal nature of the policy still prevents properly capturing the versatility. We introduce Versatile Inverse Reinforcement Learning (V-IRL), an approach designed specifically for learning reward functions form highly-versatile demonstrations. We build on recent works in Varitional Inference \citep{arenz2018efficient, arenz2020trust} and most notably on Expected Information Maximization (EIM) \citep{Becker2020Expected}, a method for density estimation that trains a mixture model where each component is able to focus on a different mode of the given data. EIM is able to reliably model versatile behavior, but does not provide a reward function. We extend EIM to still produce a similar multi-modal policy while also making its reward function explicit, producing a fine-grained and versatile reward in the process. We experiment on diagnostic tasks designed to have versatile solutions. The results show that V-IRL is the only method that is able to consistently capture the multimodal nature of the tasks while recovering a fine-grained reward. \par \begin{figure}[t] \centering \begin{minipage}{0.23\textwidth} \centering \includegraphics[width=.88\textwidth]{figures/intro_full.pdf} \subcaption[]{} \end{minipage}% \begin{minipage}{0.23\textwidth} \centering \includegraphics[width=.88\textwidth]{figures/intro_maximum_likelihood.pdf} \subcaption[]{} \end{minipage}% \begin{minipage}{0.23\textwidth} \centering \includegraphics[width=.88\textwidth]{figures/intro_i_projection.pdf} \subcaption[]{} \end{minipage}% \begin{minipage}{0.23\textwidth} \centering \includegraphics[width=.88\textwidth]{figures/intro_blocked_path.pdf} \subcaption[]{} \end{minipage}% \caption{\textbf{a)} A versatile path-panning task, where to goal is to find an efficient path from the diamond to the circle. \textbf{b)} Maximum likelihood methods average over modes, leading to poor solutions. \textbf{c)} Choosing a single behavior via the information projection works, but is not flexible. \textbf{d)} V-IRL reconstructs a versatile reward function that allows for good solutions even when some paths are obstructed.} \label{fig:introduction} \end{figure} \section{Algorithm} \label{sec:algorithm} We consider sample trajectories $\bm{x}$ which follow an unknown distribution $p(\bm{x})$ and are given by the expert. Under the common maximum entropy assumption \citep{ziebart2008maximum, haarnoja2017reinforcement} the expert's reward is given by $R\left(\bm{x}\right) = \log p\left(\bm{x}\right) - c$ for some constant offset $c$. Recovering the log density of the unknown distribution $p\left(\bm{x}\right)$ thus also recovers a reward which explains the experts behavior. Expected Information Maximization (EIM) \citep{Becker2020Expected} iteratively minimizes the reverse KL-Divergence $\text{KL}\left(q\left(\bm{x}\right)||~p\left(\bm{x}\right)\right)$ between a latent variable policy $q\left(\bm{x}\right) = \int q\left(\bm{x}|\bm{z}\right)q(\bm{z})d\bm{z}$ and an unknown distribution $p\left(\bm{x}\right)$ of which only samples are available. Similar to EM \citep{dempster1977maximum}, EIM uses a variational bound to make the optimization tractable. This bound is given by a reformulation of the bound used in \citep{arenz2018efficient}, $q_{t+1}^*\left( \bm{x}\right) =$ \begin{equation} \label{eq:eim_objective} \argmin_{q\left(\bm{x}\right)} \mathbb{E}_{q\left(\bm{x}|\bm{z}\right)q\left(\bm{z}\right)} \left[ - \log \dfrac{p\left(\bm{x}\right)}{q^*_t\left(\bm{x}\right)}\right] + \text{KL}(q(\bm{z}) || q^*_t(\bm{z})) + \mathbb{E}_{q\left(\bm{z}\right)}\left[\text{KL}\left(q\left(\bm{x}|\bm{z}\right) || q^*_t\left(\bm{x}|\bm{z}\right)\right)\right]\text{,} \end{equation} where $q^*_t\left(\bm{x}|\bm{z}\right)$ and $q^*_t\left(\bm{z}\right)$ denote the model from the previous iteration. Relating Equation \ref{eq:eim_objective} to IRL, $q_t\left(\bm{x}\right)$ can be seen as an iteratively optimized behavioral cloning policy. The KL penalties enforce that consecutive $q_t\left(\bm{x}\right)$ do not change too quickly, acting like trust regions \citep{schulman2015trust}. To use this bound under the assumption that only samples of $p(x)$ are available, EIM employs density ratio estimation techniques \citep{sugiyama2012density} to approximate $\log \left(p\left(\bm{x}\right) / q^*_t\left(\bm{x}\right)\right)$ with a neural network $\phi_t\left(\bm{x}\right)$. In the practical implementation of the approach the change of the model between iterations is limited and thus, in each iteration, the density ratio estimator can be reused after a few update steps. At iteration $t$, $q^*_{t+1}\left(\bm{x}\right)$ in Equation \ref{eq:eim_objective} is optimal for $ q^*_{t+1}\left(\bm{x}\right) \propto \exp \left(\log q^*_{t}\left(\bm{x}\right) +\phi_t\left(\bm{x}\right)\right) $ \citep{abdolmaleki2015model}. From there, induction over $t$ shows that $ \log q^*_{t+1}\left(\bm{x}\right) = \log q^*_{0}\left(\bm{x}\right) + \sum_{i=0}^t \phi_i\left(\bm{x}\right) + c $ for some arbitrary prior $q^*_{0}\left(\bm{x}\right)$ and constant offset $c$. Assuming convergence at iteration $T$, plugging this into $R\left(\bm{x}\right) = \log p\left(\bm{x}\right) - c$ yields \begin{equation} \label{eq:cumulative_reward} \begin{alignedat}{-1} R\left(\bm{x}\right) = &\log q^*_0\left(\bm{x}\right) +\sum_{i=0}^{T-1} \phi_i\left(\bm{x}\right)\text{,} \end{alignedat} \end{equation} where we dropped constant offsets as they do not play a role in optimization. Intuitively, each $\phi_t\left(\bm{x}\right)$ acts as a change of reward that refines the current recovered reward $q^*_{t}\left(\bm{x}\right)$. By adding more $\phi_t\left(\bm{x}\right)$s, this gradually produces a more and more precise estimate of the reward. At convergence, the target distribution $p\left(\bm{x}\right)=q^*_T\left(\bm{x}\right)$ is recovered and $\phi_T\left(\bm{x}\right)=0$ everywhere. Since each $q^*_t\left(\bm{x}\right)$ is the accumulation of $t$ different estimators $\phi_i\left(\bm{x}\right)$, we call this a \textit{cumulative reward}. Comparing V-IRL to EIM, we see that V-IRL can represent an arbitrarily complex reward, as each additional $\phi_t\left(\bm{x}\right)$ adds capacity to the model. Opposed to this, EIM only recovers a policy and is thus limited to the capacity of this policy by construction. V-IRL also acts in an off-policy setting, allowing for large update steps of the policy without destabilizing the training. In contrast, both EIM and generative approaches \citep{finn2016guided, fu2018learning} often need to take sufficiently small steps for the method to converge \citep{arenz2020nonadversarial}. Formulating the IRL problem as a sum of changes of rewards is conceptually easier than having a generative reward, because estimating a ratio is easier than estimating a density \citep{sugiyama2012density}. Another benefit lies in the multi-modal structure of our approach. Since the log density ratio estimate $\phi_t\left(\bm{x}\right)$ gives a strong signal in areas of uncovered expert modes by design, the recovered reward will eventually cover the relevant modes of the expert distribution and naturally prefer those with higher density over lower density ones. If some modes become unavailable at inference time due to changes in dynamics caused by e.g., obstructions, a policy trained on the recovered reward can still use the remaining ones as a reward signal. \paragraph{Importance Sampling} In general, $q^*_t\left(\bm{x}\right)$ may become arbitrarily complex and can not easily be samples from. To work around this, we introduce a tractable sampling policy $\tilde{q}_t\left(\bm{x}\right)$ that approximates $q^*_t\left(\bm{x}\right)$. In our experiments, we use a recent method for variational inference, Variational Inference by Policy Search (VIPS) \citep{arenz2018efficient, arenz2020trust} to train $\tilde{q}_t$ by minimizing $\text{KL}\left(\tilde{q}_t\left(\bm{x}\right)||q^*_t\left(\bm{x}\right)\right)$. Given $\tilde{q}_t\left(\bm{x}\right)$, we employ importance sampling to train a discriminator between expert demonstrations and samples of $\tilde{q}_t\left(\bm{x}\right)$ that are weighted by $q^*_t\left(\bm{x}\right)$. These samples then act as the importance sampling estimate of samples of $q^*_t\left(\bm{x}\right)$. To do this, we minimize the weighted binary cross entropy loss \begin{equation} \label{eq:i2rl_phi_objective} \mathcal{L}_{BCE}(\phi_t, p, \tilde{q}_t, q^*_t) = \E{\bm{x}\sim p\left(\bm{x}\right)}{-\log \sigma\left(\phi_t\left(\bm{x}\right)\right)}+\E{\bm{x}\sim \tilde{q}_t\left(\bm{x}\right)}{-w_t\left(\bm{x}\right)\log \left(1-\sigma\left(\phi_t\left(\bm{x}\right)\right)\right)} \end{equation} with normalized importance weights $w_t\left(\bm{x}\right) = \frac{1}{\int q^*_t\left(\bm{x}\right)\mathop{\text{d}\bm{x}}} \frac{q^*_t\left(\bm{x}\right)}{\tilde{q}_t\left(\bm{x}\right)}$ and logits $\phi_t\left(\bm{x}\right)$. It has been shown that Equation \ref{eq:i2rl_phi_objective} causes the logits $\phi_t\left(\bm{x}\right)$ of the network to recover a log density ratio estimate at convergence \citep{sugiyama2012density}. In other words, $\phi_t\left(\bm{x}\right) = \log \left(p\left(\bm{x}\right) / q^*_t\left(\bm{x}\right)\right)$, which is precisely the change of reward used in Equation \ref{eq:cumulative_reward}. Finally, we add the newly obtained $\phi_t\left(\bm{x}\right)$ to $q^*_t\left(\bm{x}\right)$ to obtain a new reward estimate. We iterate over this until convergence at iteration $T$, and obtain $q^*_T\left(\bm{x}\right)$ as the recovered reward and $\tilde{q}_T\left(\bm{x}\right)$ as an optimal policy for this reward. Pseudocode for the approach can be found in Appendix \ref{app_sec:pseudocode}. \paragraph{Kernel Density Estimation} \begin{wrapfigure}{r}{0.53\textwidth} \vspace{-16pt} \begin{minipage}[b]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{figures/gaussians/simplified_30_ground_truth_no_axis.pdf} \subcaption{} \end{minipage}% \begin{minipage}[b]{0.3\textwidth} \centering \includegraphics[width=\textwidth]{figures/gaussians/2d_average_task_evaluation.pdf} \subcaption{} \end{minipage} \caption{ \textbf{a)}: Visualization of a $30$-component GMM. The heatmap shows the log-density of the GMM. The ellipsoids are $95\%$-covariances of the components. Expert demonstrations are shown with a grey `$\times$'. \textbf{b)}: Results for different numbers of target components. V-IRL provides a stable solution and is able to represent a larger number of modes than the baselines for the same number of policy components. } \label{fig:gaussians} \end{wrapfigure} \label{ssec:kernel_density_estimate} In practical settings with highly-versatile behavior, $\tilde{q}\left(\bm{x}\right)$ is unlikely to cover all relevant modes of $q^*\left(\bm{x}\right)$, causing high-variance estimates in the importance sampling procedure and thus a poor coverage of the density ratio estimators and subsequently the reward recovered from them. To prevent this, we follow prior work \citep{finn2016guided, fu2018learning} and enrich the sampling distribution $\tilde{q}_t\left(\bm{x}\right)$ with an estimate $\tilde{p}\left(\bm{x}\right)$ of the target distribution $p\left(\bm{x}\right)$, resulting in a fusion distribution $ \mu_t\left(\bm{x}\right) = 0.5\tilde{q}_t\left(\bm{x}\right)+0.5\tilde{p}\left(\bm{x}\right)\text{.} $ \citet{finn2016guided} and \citet{fu2018learning} use a Gaussian for $\tilde{p}\left(\bm{x}\right)$. Since this is ill-suited for versatile behavior, we instead resort to a Kernel Density Estimate \citep{rosenblatt1956, parzen1962estimation} of the expert samples, using a Gaussian kernel for our estimate. Thus, $\mu_t\left(\bm{x}\right)$ covers all modes of $p\left(\bm{x}\right)$ by construction. Intuitively, $\tilde{p}\left(\bm{x}\right)$ has the purpose of roughly covering $p\left(\bm{x}\right)$ to stabilize the training process, while $\tilde{q}_t\left(\bm{x}\right)$ is used to explore and approximate some modes of $p\left(\bm{x}\right)$ more closely. \section{Experiments} \label{sec:experiments} We conduct all our experiments in a non-contextual and episodic setting. We choose Gaussian Mixture Models (GMMs) for the policies of the different methods. Note that extensions to a contextual setting are readily available in the form of Gaussian Mixtures of Experts, which we leave as a promising direction for future work. For hyperparameter settings, refer to Appendix \ref{app_sec:hyperparameters}. We use EIM \citep{Becker2020Expected} as a baseline for versatile behavioral cloning, using the log-density of its policy as a surrogate reward function. Additionally, we adapt Adversarial Inverse Reinforcement Learning (AIRL) \citep{fu2018learning} to versatile tasks by combining it with EIM. We use the EIM objective of Equation \ref{eq:eim_objective} for the general training procedure, but reparameterize the density ratio according to the AIRL formulation as $\phi_t\left(\bm{x}\right) = \log \left(\exp(R_t\left(\bm{x}\right)) / q_t\left(\bm{x}\right)\right)$. Here, $q_t\left(\bm{x}\right)$ is the density of the current sampling policy and $R_t\left(\bm{x}\right)=\log p\left(\bm{x}\right)$ is a learned function that recovers the reward up to a constant. We call this approach generative EIM (G-EIM), and also enrich it with the fusion distribution mentioned in Section \ref{ssec:kernel_density_estimate}. Note that G-EIM is a novel and interesting approach for versatile IRL in itself. \paragraph{Gaussian Experiments} We start with a versatile toy task to showcase the ability of VIRL to precisely capture highly multi-modal distributions. For this task, the reward is represented by the log-density of a $2$-dimensional GMM with $m$ randomly drawn and weighted components, leading to a complex and highly multi-modal target reward. An example for $m=30$ is given in the left of Figure \ref{fig:gaussians}. We evaluate the reverse KL by computing the numerical I-Projection near the ground truth data, comparing EIM, G-EIM and V-IRL with $1$ (`1c') and $10$ (`10c') GMM components each. We optimize for $m=50$ target components and evaluate on $m\in\{5, 10, \dots, 50\}$ components. We report the average results between the best evaluated iteration and the final iteration to account for instabilities in the training and evaluation. Results for $5$ random seeds can be seen in the right of Figure \ref{fig:gaussians}. We find that V-IRL scales gracefully with the number of modes to be covered, comparing favorably to both baselines. Inference experiments on the recovered rewards can be found in Appendix \ref{app_sec:additional_experiments}. \paragraph{Grid Walker} \begin{figure}[t] \centering \begin{minipage}[b]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{figures/grid_walker/walker_generative_cropped.pdf} \subcaption[]{G-EIM Training} \end{minipage}% \begin{minipage}[b]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{figures/grid_walker/walker_generative_inference_cropped.pdf} \subcaption[]{G-EIM Inference} \end{minipage}% \begin{minipage}[b]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{figures/grid_walker/walker_cumulative_cropped.pdf} \subcaption[]{V-IRL Training} \end{minipage}% \begin{minipage}[b]{0.23\textwidth} \centering \includegraphics[width=\textwidth]{figures/grid_walker/walker_cumulative_inference_cropped.pdf} \subcaption[]{V-IRL Inference} \end{minipage} \caption{Grid walker experiments. Each walk is made up of $d=5$ line segments. The solid lines are policy component means, the dotted lines are samples from these components. Lines with a higher opacity correspond to a higher evaluation of the recovered reward. The intermediate targets are denoted by the vertical dotted lines. \textbf{a)} a $10$-component sampling policy of G-EIM. \textbf{b)} a $25$-component inference policy trained on the reward recovered by a). \textbf{c)} and \textbf{d)} repeat this for V-IRL. Both V-IRL and GEIM produce high-quality sampling policies during training. However, only V-IRL is able to also recover a reward function that extends to modes that were not seen during training.} \label{fig:inference_grid_walker_vis} \end{figure} A more realistic highly-versatile task is the path-planning task of Figure \ref{fig:introduction}. We model this task as a walk over $d$ steps of uniform size, where each step is given by an angle. For optimal solutions, the walker can either go up or down in each step. As a result, all efficient solutions lie on a regular grid. Appendix \ref{app_ssec:grid_walker} presents a detailed construction of the task. We train V-IRL and G-EIM with $10$-component policies for $d=5$ path segments, using the negative ELBO (see e.g., \citep{blei2017variational}) as the optimization metric. The resulting hyperparameters can be seen in Table \ref{tab:app_optuna_hyperparameters_walker}. We then perform inference on the recovered rewards for policies with $25$ components. The results are shown in Figure \ref{fig:inference_grid_walker_vis}. We find that the sampling policies for both V-IRL and G-EIM are versatile and precise. However, the inference policy of G-EIM is mostly limited to behaviors that were found during the training of the recovered reward. Opposed to this, the recovered reward of V-IRL allows for previously unexplored modes to be found by the inference policy. We explore this behavior in more detail in Appendix \ref{app_ssec:grid_walker}. \section{Conclusions} We propose a novel approach for Inverse Reinforcement Learning for versatile behavior that recovers a reward by accumulating iteratively trained discriminative models. The key idea of our approach is that every discriminator is trained to represent an optimal change of the previous sum of discriminators, and thus this sum ultimately recovers an appropriate reward. We show that this cumulative reward formulation works well in a variety of versatile tasks, outperforms strong baselines and yields rewards that generalize beyond the capabilities of the sampling policy. \subsubsection*{Acknowledgments} The authors acknowledge support by the state of Baden-Württemberg through bwHPC. \bibliographystyle{plainnat}
{'timestamp': '2021-11-16T02:30:32', 'yymm': '2111', 'arxiv_id': '2111.07667', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07667'}
arxiv
\section*{Keywords} \textbf{Keywords:} Translation Quality Evaluation, Quality Estimation, Post-editing Distance, Confidence Intervals, Monte Carlo Modeling, Bernoulli Statistics \section{Introduction} \label{sec:intro} Machine Translation (MT) is one of the pioneering artificial intelligence (AI) tasks dating back from the 1950s \cite{Weaver1955}. It emphasizes the interaction of Language and Machine, and how machine can learn human languages with cognitive knowledge. Before MT, human translation (HT) of written text and documents has always played an important role in science and literature communication between different language speakers, breaking the language barriers. From both MT and HT perspectives, translation quality evaluation (TQE), sometimes incorrectly referred as translation quality assessment (TQA)\footnote{ISO 9001 distinguishes between ``assessment'' (which relates to the quality management process per se) and evaluation (which is the quality measurement task), so it is incorrect to refer to quality evaluation as ``quality assessment'' \url{https://www.iso.org/iso-9001-quality-management.html}.}, is an important task to reflect how well the source text is translated into the target languages \cite{han-etal-2021-TQA}. On the one hand, for low resource language pair scenarios, human translators still play the dominant role in translation production. The translated text and documents can contain unavoidable errors due to personal bias, input efforts, or the training level of the translators. On the other hand, for high resource language pair situation, neural MT (NMT) has achieved remarkable improvement especially on fluency level, compared to conventional rule-based and statistical phrase-based MT models; however, NMT still has ``poisoned cookie'' problem struggling to achieve real human parity, for instance, on adequacy level, meaning preservation, and on idiomatic expression translations \cite{Sag2002MWE,han-etal-2020-multimwe,Google2016MultilingualNMT,han-etal-2020-alphamwe}. Translation service providers (TSPs) relying on both MT, HT, and human post-editing of MT output (TPE) carry out translation and editing tasks with the high demand and harsh constraints nowadays. Thus, TQE role in this workflow remains to be critical. However, it is tedious, costly, and time-consuming to check through the entire translated text given the huge amount of data TSP and customers process. One obvious solution, to this point, is to extract a sub-set of the translated text and make a conclusion about the overall translation quality by results of TQE of the sample, which has always been done in real practice. However, one question arises here: \textit{how large the sample size shall be to estimate the overall translation quality of the entire material reliably?} In other words, what is the confidence interval of such evaluation on certain desired confidence level (which is commonly taken as 95\%) with the samples we choose to estimate the overall translation quality? In this work, we carry out such a motivated experimental investigation on confidence evaluation of translation quality evaluation. To take advantage of statistical modeling techniques, we start with the assumption that error distribution is uniform across the entire material, and minimum unit where the error occurs is one sentence (since errors can be between words, in the form of punctuation and conjugation, etc.). This assumption is the best case scenario which potentially ensures the smallest size of the sample, because if it is not correct we immediately arrive to situation when we need to check more, if not entire text. We start from high quality translation assumption that errors are rare (average error density is as low as 0.07 errors per sentence). Then, on the second stage of experiment, by taking post-editing distance (PED) measurement for evaluation, we prove that such assumption can be applied to the situation where errors are much more frequent, with large number of ``errors'' (edits) per one sentence. We use Bernoulli Statistical Distribution Modeling (BSDM) and Monte Carlo Sampling Analysis (MCSA) to explore the confident level sample size estimation. With this methodology, we expect to reach a conclusion where practical suggestion can be given on confident sample size of translated text/document quality evaluation. To our knowledge, this is the first study to carry out statistical confidence intervals estimation for MT quality assessment, while in all practical situations, researchers and practitioners very often take it for granted by randomly choosing a sample size from MT outputs to estimate the system quality. This paper is organized as below: Section \ref{sec:intro} presents the topic of this work, Section \ref{sec:related} covers some related work to our study, Section \ref{sec:method_statistic} introduces the statistical modelling, Section \ref{sec:monte_carlo} presents the Monte Carlo (MC) simulation, Section \ref{sec:monte_carlo_for_ped} carries out confidence estimation for post-editing distance metric using MC simulation, and finally Section \ref{sec:conclude} concludes the work with discussions and future work. \section{Related Work} \label{sec:related} Quality estimation and measurement have been explored using various strategies for both human and machine translated text. For instance, human evaluation criteria have included intelligibility, fidelity, fluency, adequacy, and comprehension as earlier stage development. These are often carried out based on both source text and candidate translations. Then, editing distance, or post-editing distance are applied to such study by calculating editing steps that are needed to revise the candidate translations towards a correct text sometimes using reference translations. Whenever reference translations are available, automatic reference-based evaluation of the candidate translation quality can be measured via many computational metrics including n-gram based simple word matching as well as some linguistic motivated features such as paraphrasing and Part-of-Speech tagging \cite{han-etal-2021-TQA}. For automatic post-editing distance based metrics, algorithms are designed to calculate the editing steps of insertion, deletion, substitution and/or word reordering. While automatic metrics have been getting very popular due to their low cost and repeatability, and thus easier to perform comparisons to previously published work, the credibility of such automatic evaluations have always been an issue. For instance, in contrast to the findings from conversational statistical MT researchers \cite{sanchez-torron-koehn-2016-machine_MT_Post_edit}, very recent research work on Neural MT (MT) by \cite{Zouhar2021NMT_Postediting,google2021human_evaluation_TQA,HanJonesSmeatonBolzoni2021decomposition4mt_MWE} has shown that automatic evaluation metrics such as BLEU do not agree well with professional translators or experts based human evaluations, instead they tend to correlate closely to lower-quality crowd-source based human evaluation. Another disadvantage for automatic evaluation is that we can not get in-depth view of what kind of errors the candidate translations present in the studied context, except for an overall evaluation score, or segment-level scores, not to mention that most metrics do not even allow for clear interpretation of what does the score exactly mean. Regarding this aspect, professional translators can always do a much better job by giving transparent error analysis and categorization on the candidate translations, such as idiomatic expressions \cite{han-etal-2020-alphamwe,han-etal-2020-multimwe}. However, another issue arrives at this point, that is how to correctly chose a confident sample from the candidate translation, instead of just take a random sample for granted and try to blindly extrapolate its result to the entire material? Actually this is not a brand new challenge in natural language processing (NLP) field. Having it in mind that randomly chosen samples may contain model bias against a proper evaluation, \cite{prabhu-etal-2019-sampling_classification} proposed an uncertainty sampling approach for \textit{text classification} task, and their statistical models can reduce the bias effectively with smaller size of data in comparison to confessional models; Similarly, \cite{haertel-etal-2008-assessing} carried out work on how statistical sampling models can help reduce the high cost for Penn Tree-bank annotation while maintaining the higher accuracy; \cite{nadeem-etal-2020-systematic_sampling} carried out one systematic comparison of several sampling algorithms used for language generation task, including top-\textit{k}, nucleus and tempered sampling, looking into quality-diversity trade-off. Sampling method was also applied into confident level evaluation of MT. For instance, \cite{koehn-2004-statistical-significance} proposed to use bootstrap re-sampling methods to test the significance level of automatic metric BLEU, but using a fixed number of sentences, i.e. 300. Like many other research work, the chosen number of sentences for evaluation was never explained or justified with any statistical validation. In contrast, we carry out statistical sampling modelling to estimate the number of sentences that is confident enough to achieve reliable quality evaluation, which means a better representation and generalization of the overall candidate translations in question, with an confidence-cost tread-off. \begin{comment} ... MT significance testing transaltionese quality estimation post-editing distance \end{comment} \section{Statistical Modelling} \label{sec:method_statistic} \subsection{Study Setup} \label{subsec:study_setup_for_sta_model} To carry out a statistical modeling of our research questions under study, i.e. \textit{how to confidently choose a sample size of translation outputs to estimate the overall translation quality, from either HT or MT}, we setup the following initial assumptions: \begin{itemize} \item Translation errors belong to several independent categories \item Errors of one category are independent from each other. \item Errors of one category occur in text randomly. \item The smallest unit of text where language error occurs is a sentence (in other words, error can be between words, but cannot be between sentences). \item The resulting error distribution is a superposition of distribution of errors of different categories. \end{itemize} Then, if we further project these assumptions into simpler mathematical notes as bellow, it meets definition of Bernoulli trial \cite{Brown_etal2001Interval,Agresti_Coull1998_approximate}: \begin{itemize} \item Errors of certain type (category) either present in a sentence, or not. \item Errors are independent from each other. \item The probability of errors is the same. \end{itemize} Generally speaking, we cannot always assume that the distribution of errors in the text is uniform, but for the purpose of this exercise it is a reasonable assumption because it is the best possible scenario. The reason is that if errors themselves are not normally distributed across the text, then errors are not distributed uniformly across the material, and the sample size should be much larger to capture clusters of errors, or even 100\% review of the material may be required to fund such clusters. Therefore, the assumption that errors are uniformly distributed is the best scenario, which allows for the smallest sample size possible. While this assumption may be questioned, in our experimental evaluations, it proves that the starting value of random seed does not affect the overall model behavior and its solutions. For high quality human translation, these assumption can be actually very reasonable. Regarding MT outputs and less than premium quality translation scenarios, where many errors per one sentence is not something unusual, we will deal with such more error-prone materials separately in later sections of this paper (Section \ref{sec:monte_carlo}). \subsection{Bernoulli Distribution} \label{subsec:bernoulli} In Bernoulli statistical distribution, when the sample size $n$ is significantly smaller than the overall population $N$, the standard derivation of sample measurement falls into the following formula: \[ \sigma = \sqrt{\frac{p\cdot(1-p)}{n}} \] \noindent where \textit{p} is the probability estimation of an event under study. The confidence interval $CI$, using the Wald interval \cite{Newcombe-book2012confidence}), will be: \[ CI = p \pm \Delta \] \noindent where $\Delta$ is the product of standard deviation and factor 1.96 (when confidence level 95\% is chosen) \cite{Agresti_Coull1998_approximate}. \[ \Delta = 1.96\cdot \sigma =1.96 \cdot \sqrt{\frac{p\cdot(1-p)}{n}} \] When the sample size $n$ is comparable to the population size $N$, e.g. in a smaller translation evaluation project for our study, the standard deviation is calculated as bellow and the $\Delta$ value updates correspondingly: \[ \sigma = \sqrt{\frac{p\cdot(1-p)}{n}\cdot\frac{N-n}{N-1}} \]\\ Let's come back to our study, with this even distribution assumption of each sentence regarding translation errors, having error probability $p$ with value 1 and no error probability $1 - p$ with value 0, each sentence represents a random variable in the modelling. This forms a Binomial distribution \textit{B(n, p)} where \textit{n} is the number of sentences. \subsection{Case Studies} \label{subsec_case_study_of_Statistical_Modelling} We present case studies using both high quality translation text and low quality one. We first carried out a case study using high quality translation. Statistics from language service providers \footnote{for instance, \url{https://logrusglobal.com/}} shows that the average length of English sentence is 17 words; there are about 250 words on standard page; we therefore can assume that there are 15 English sentences on a standard page. Let's assume that there is very high quality translation document, where there are no more than one error per page (one error per 15 sentences); then error density $p = 0.07$. And, if we set $\Delta$ value as 0.02. Thus the confidence interval falls into 0.07 ± 0.02, i.e. from 0.05 to 0.09, which is already wide interval. If we use a confidence level 95\%, we have the following recommended number of sentences to check as derived from the formula mentioned earlier: \[ n = {\frac{1.96^2 \cdot p \cdot (1-p)}{\Delta^2}} \] \[ n = {\frac{1.96^2\cdot0.07\cdot(1-0.07)}{0.02^2}} = 625 \] \noindent which requires us to check 625 sentences, or 42 pages, or 10,000 words (all these numbers are rounded) as demonstrated in Figure \ref{fig:high_MT_625_sent}. If we want to achieve measurement accuracy with confidence interval $0.07 \pm 0.01$ then we will have to check 2500 sentences, or 166 pages, or 42,000 words. If we check 10 pages the confidence interval will be 0.04, and the measured result will be $0.07 \pm 0.04$ (from 0.03 to 0.11), and if we check only 1 page: $0.07 \pm 0.12$ (from 0 to 0.19). If we try to check only one sentence even of high quality translation, we really can't say anything about the quality because the error probability of such measurement will be $0.07 \pm 0.5$ (from 0 to 0.57) which is too high. \renewcommand{\figurename}{Fig.} \begin{figure \begin{center} \includegraphics[width=0.9\textwidth]{pic625.png} \end{center} \caption{A 95\% confidence level credible interval for sample size from 100 to 2000 sentences, for high quality translation with error density 0.07. $\Delta$ is shown for sample size 625 sentences (42 pages).} \label{fig:high_MT_625_sent} \end{figure} Then let's have a look into examples with lower quality translation text, for instance, an error density of 0.2, i.e., one error for every 5 sentences. The confidence interval of checking only one page will be $\pm 0.2$: the measurement confidence will be $0.2 \pm 0.2$ and the actual value can be anywhere from 0 to 0.4 as shown in Figure \ref{fig:low_MT_15_sent}. As we can see, the one page measurement in this situation is not reliable at all. \renewcommand{\figurename}{Fig.} \begin{figure \begin{center} \includegraphics[width=0.9\textwidth]{pic15.png} \end{center} \caption{A 95\% confidence level credible interval for sample size from 100 to 2000 sentences, for low quality (machine) translation with error density 0.2. $\Delta$ is shown for sample size 15 sentences (1 page).} \label{fig:low_MT_15_sent} \end{figure} As we mentioned in Section \ref{subsec:bernoulli}, the formulas above only apply for the cases when the sample size is much smaller than the overall population size. If sample size $n$ is comparable to the population size $N$, the standard deviation of such measurement in the case of high quality translation evaluation will be differently calculated as: \[ \Delta = 1.96\cdot\sqrt{\frac{p\cdot(1-p)}{n}\cdot\frac{N-n}{N-1}} \] Practicality of this can be illustrated with the following example: suppose that we have a translation quality evaluation (TQE) scorecard measuring the quality of 1000 words job by doing TQE on 400 words sample checked by reviewer, who found 2 minor errors. Then measured error density is 2 errors per 23.5 sentences, or 0.085 errors per sentence. The 95\% confidence interval for such measurement will be $\pm\Delta$, where: \[ \Delta = 1.96\cdot\sqrt{\frac{0.085\cdot(1-0.085)}{23.5}\cdot\frac{58.82-23.5}{58.82-1}} = 0.088 \] Therefore, with such a scorecard measurement we can only say that the measured error density is 0.085 $\pm$ 0.088, i.e. with 95\% confidence the actual error density is in the range [0.034 - 0.173]. Of course, we can check all 1000 words of this job, and then we will be 100\% certain about the number of errors in this job (assuming that the reviewer is reliable, but that’s another story), but then the measurement confidence interval will relate to the generalized conclusion about the work of this supplier in general, on population size much larger than 1000 words. In summary, we have the following findings from Bernoulli Distribution modeling for the case studies: \begin{enumerate} \item If the sample size is much smaller than the entire material, the correct sample size for the measurement does NOT depend on the size of the material, but does depend on the error density in the material and sample size. This case applies to continuous delivery cases, and spot checks on them, or very large projects. \item If the sample size is comparable with the size of the entire material, the correct sample size for the measurement also depends on the size of the material as well as on the error density in the material and sample size. This case applies to small jobs. \item The more precisely we want to measure, the more we need to check. \end{enumerate} However, in reality, the formulas for Bernoulli distribution will not always apply successfully because that the error distribution in the text is sometimes not uniform. In order to see what is happening with reliability of quality evaluation in more challenging scenarios, in the next section, we conduct numerical Monte-Carlo sampling experiment to examine how our theory comes to practice and then introduce real life complications. \section{Monte Carlo Simulation (MSC)} \label{sec:monte_carlo} Monte Carlo Simulation (MCS) was first developed, in the last century when computer machine was still newborn, for a gambling situation when various outcomes can't be easily predicted or determined due to many random variables. MCS assigns some variables from a task that have certain uncertainty with random values, then runs the model to predict a result, which process is subsequently repeated with a great number of times. Finally, estimation will be achieved by averaging the large number of results. These results can also be used to assess statistical properties of error distribution in the samples. The repeated process is also called sampling in many applications, such as in our translation quality evaluation task under study \cite{Goodfellow-et-al-2016} (\textit{Chap. 17}). To conduct a numerical experiment we need to take certain parameters of the translation error distribution in a sample of given size. It is intuitively clear that, the number of errors in one sample will be different each time when the sample is generated simply because errors are distributed randomly throughout the text. This includes the situations of 100\% correct judgments of errors and no false positives. It is less obvious that the parameters of error distribution in the sample are different from parameters of error distribution in the entire material ( \textit{aka} ``population''). A degenerated case of minimal sample (e.g. one sentence) helps to understand this: if error density in population is 5\% and we only analyze one sentence, with 95\% probability there will be no errors in that sentence, however it is 100\% sure that there are errors in entire material. The estimation of rare event probabilities are best analyzed with MCS method, sometimes it is probably the only way to handle such phenomena. As we mentioned, MCS relies on repeated random sampling to obtain numerical results for random variables where models are not available analytically. In our study, it is the case of translation error in the text, with many types of it which interact in a complex way, and the distribution of these errors is not uniform due to the text having a structure of unequal content. The possible reasons for this include that different people have worked on the entire text, and a plethora of other sophisticated reasons. Our initial experiment will not be dealing with the complexity of many types of errors but examines the simplified model described in earlier section (Section \ref{sec:method_statistic}). Correspondingly, our numerical MCS experiment to assess parameters of this distribution is described as follows: \begin{enumerate} \item We take a sample size N = 2000 for repeated process \item We generate the random distribution of errors in the entire ``population'' of all the sentences of the material. \item The number of errors found in these samples represent error distribution of a total number of errors in a sample. \item We use the large number of sampled data to estimate the entire collection of materials, the error distribution, mean and confidence intervals of such distribution. \item We take the same error density assumption of 0.07 as in the earlier section (Section \ref{subsec_case_study_of_Statistical_Modelling}). \end{enumerate} After, we will be able to assign different values of these parameters and see how this affects the corresponding results. Now that we have 2000 samples of text to be evaluated, we can look into the parameters of error distribution in such samples, based on a large data-set. We can calculate the mean of a number of errors in a sample, by creating a list of 2000 elements with one value - the number of errors found in a sample set. When this is done we have a 2000 elements array of error numbers in 2000 samples, and we can plot the histogram, as shown on Fig. \ref{f_lenratio_trx}. This histogram is a discreet representation of probability density function of distribution of error numbers across the samples. It is not a surprise that the distribution is a Bell curve; regardless of whether errors in the entire population are uniformly distributed or not, the number of errors in the sample is normally distributed, provided the number of samples is sufficiently large, according to the Central Limit Theorem. \renewcommand{\figurename}{Fig.} \begin{figure \begin{center} \includegraphics[width=0.66\textwidth]{histogram-05-realdistribution_new.jpg} \end{center} \caption{Distribution histogram of error number in samples, with sample size of 1000 sentences.} \label{f_lenratio_trx} \end{figure} The parameters of this distribution can be reconstructed with \textit{norm.fit} function of \textbf{scipy.stats} \footnote{\url{https://docs.scipy.org/doc/scipy/reference/stats.html}} programming package, as in Figure \ref{f_lenratio_trx_recon}. \begin{figure \begin{center} \includegraphics[width=0.66\textwidth]{sample-error-PDF_new.png} \end{center} \caption{Reconstructed probability density function of distribution of error number in samples of 1000 sentences.} \label{f_lenratio_trx_recon} \end{figure} Now, if we take a much smaller (10 times smaller) sample size of 100 sentences we will get a much wider bell, as in Figure \ref{f_lenratio_trx_100}. \begin{figure \begin{center} \includegraphics[width=0.5\textwidth]{histogram-06-realdistribution_new.jpg} \end{center} \caption{Distribution histogram of error number in samples, with sample size of 100 sentences.} \label{f_lenratio_trx_100} \end{figure} \noindent which naturally corresponds to wider probability distribution, in Figure \ref{f_lenratio_trx_100_recon}. \begin{figure \begin{center} \includegraphics[width=0.66\textwidth]{sample-error-wide_new.png} \end{center} \caption{Reconstructed probability density function of distribution of error number in samples of 100 sentences.} \label{f_lenratio_trx_100_recon} \end{figure} If we run a computational experiment to plot 95\% confidence level credible interval for sample sizes from 10 to 2000 sentences, such an experiment will produce results very close to the formulas in previous section (Section \ref{subsec_case_study_of_Statistical_Modelling}), as shown on Figure \ref{fig:high_MT_625_sent}. In the next section, we will demonstrate how MCS can be applied to the confidence estimation on language quality metrics (LQMs), such as post-editing distance. \section{MCS for Post-editing Distance (PED) Confidence Estimation} \label{sec:monte_carlo_for_ped} As we mentioned in Section \ref{sec:intro}, in this section, we investigate how MCS can be applied to simulate translation quality evaluation and confidence estimation task. Due to the lack of reliable and precise automatic language quality evaluation (LQE) metrics, currently Post-Editing Distance (PED) score remains one of the popular measurement. The PED score is often tracked on segment level, in comparison to document or system level, to examine how good the MT output is in comparison to human edited final translation. We further conduct analysis of confidence interval (CI, or $\Delta$) for average PED score depending on the sample size. The absolute PED score is the minimal number of deletion and insertion operation/editing steps form initial candidate translation to post-edited translation text, divided by the length of source sentence. Because the number editing steps can be larger than the number of words in the source sentence, the absolute PED score can be greater than 1. However, since we design to compare the PED with vector similarity, the absolute PED score needs to be normalized to a [0, 1] range. We propose a normalization function of PED (represented as PEDn) as bellow: \[ PEDn = 1 - tanh (c \cdot PED) \] \noindent where \textit{c} is a parameter defining the value of PED which brings the value of normalized PED to [0, 1], as shown in Figure \ref{fig:ped_to_pedn}. \renewcommand{\figurename}{Fig.} \begin{figure \begin{center} \includegraphics[width=0.8\textwidth]{ped_vs_ped_norm.png} \end{center} \caption{Relationship between plain PED and normalized PEDn.} \label{fig:ped_to_pedn} \end{figure} Using the MCS methods we introduced in the last section (Section \ref{sec:monte_carlo}), we conduct numerical experiment to estimate confidence interval (Delta) for average normalized measurement PEDn as function of sample size (number of sentences). This allows us to understand the number of sentences to calculate average PEDn from samples with confidence interval $\pm \Delta$ value. First we simulate Delta (half of confidence interval) as function of the sample size, as in Figure \ref{fig:delta_as_func_of_sample_size}. Then the confidence interval is shown in Figure \ref{fig:95_CI_for_mean_pedn} which graphic indicates that confidence interval starts going out of control when the sample size is less than 200 sentences (approximately 3500 words). \renewcommand{\figurename}{Fig.} \begin{figure \begin{center} \includegraphics[width=0.8\textwidth]{ped-delta.jpg} \end{center} \caption{Delta as function of sample size.} \label{fig:delta_as_func_of_sample_size} \end{figure} \renewcommand{\figurename}{Fig.} \begin{figure \begin{center} \includegraphics[width=0.8\textwidth]{ped-confidence.jpg} \end{center} \caption{A 95\% confidence level credible interval for mean PEDn.} \label{fig:95_CI_for_mean_pedn} \end{figure} This means that reliable conclusions can not be reached about the quality of MT proposals based on post-editing sample sizes of 2000 words or less. A sample size above 4000 words is recommended to get reasonably confidence interval in a better scenario, for purely statistical reasons, set aside subjective difference of opinions of different editors, content irregularities, and other possible factors. \section{Discussions and Conclusions} \label{sec:conclude} In this article, we proposed the research question on confident sample size of translation documents to estimate the overall material quality, which is a crucial question for both academic research and industrial applications, such as for clients and language service providers. We started the experimental investigation of translation quality evaluation (TQE) by assuming that the errors in translated text are evenly distributed, with errors being rare (7 errors per 100 sentences, on average). This assumption is placed as a random seed of our statistical Bernoulli modelling which does not affect the overall model behavior. To simulate the practical situation where the errors can come from different translators and different types, and span into a different weight across the translated text and documents, we applied the Monte Carlo Simulation analysis, using a sample size of 2000 sentences and 95\% confidence level. We also applied MCS into confidence estimation of post-editing distance measurement which is currently widely adopted evaluation metric for translation assessment, and gained very valuable findings from empirical investigations regarding practical situations when translation quality evaluation (TQE) is deployed. Furthermore, we suggest that, ideally, a reliability level of analytic sample quality measurement can be added to every analytic TQE scorecard in the form of confidence interval at certain confidence level as one important indicator of the level of certainty of measurement results. In the future work, we plan to compare different sampling methods, as well as apply the confidence estimation model into broader TQE metrics. \begin{comment} \input{sec-00-abstract} \input{sec-01-intro} \input{sec-02-relwork} \input{sec-03-idea} \input{sec-04-exp} \input{sec-05-eva} \input{sec-06-conc} \section*{Acknowledgements} The ADAPT Centre for Digital Content Technology is funded under the SFI Research Centres Programme (Grant 13/RC/2106) and is co-funded under the European Regional Development Fund. \renewcommand{\figurename}{Fig.} \begin{figure}[!t] \begin{center} \includegraphics[width=0.72\textwidth]{ped-confidence.jpg} \end{center} \caption{Mean \textit{PEDn} value variation with increasing sample size using a 95\% confidence level.} \label{fig:mean_PED_sample_size} \end{figure} \end{comment} \bibliographystyle{coling}
{'timestamp': '2021-11-16T02:32:01', 'yymm': '2111', 'arxiv_id': '2111.07699', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07699'}
arxiv
\section{Introduction}\label{intro} Managing, orchestrating and controlling environments which include distributed devices spanning highly heterogeneous networks is becoming an increasingly complex task. For this reason, the interest in more intelligent and automation geared management methods, such as utilization of intent based network (IBN) management, has also been on the rise, and is significantly improving both the automation and management process in wide spectrum of application domains and complex ICT systems. IBN systems are designed to translate high-level intents into a structured format with the help of natural language processing techniques, thus easing the system management also for non-experts. Structured specifications translated from the intent configure the systems in a policy-based fashion, without the need to manually check the conflicts in a large-scale system. IBN typically deploy various ML techniques not only for natural language processing, but also for the entire suite of network management functions, such as resource management or security. Whereas IBN concepts are generally specific to the use case envisioned, the underlying ICT platforms are generally heterogenous, comprised of complex processing units, including CPU/GPU, CPU/FPGA and CPU/TPU combinations. Hence, for the system to choose between multiple potentially new ML model configurations is not only potentially time-critical, but can also result in computationally ineffective choice of ML techniques on a specific hardware. Moreover, intents are useful precisely because they enable system configurations where a problem can be solved by choosing from a set of candidate ML-based solutions, whereby each of the candidates can give the comparable output, but with different accuracy and run-time. Hence, an efficient IBN system needs to be able to predict how long it takes for a potential ML solution to execute for a given intent, while preserving a threshold of accuracy. This brings into question of what the optimal way of estimating performance of ML solutions in an IBN system is, and whether it is possible to learn and extract features that relate the performance of a specific intent to the hardware in an implicit way. What is needed is an intent-based networking paradigm that would allow administrators to choose and deploy best ML models on the most suited hardware platform, through simple use of high level intents. The objective of this paper is three-fold. Firstly, we introduce a specific case study of complex IBN management systems implemented in ICT supply chain systems. The implementation of intents in a specific case study enables us to define meaningful intents, which in turn allows for an easier system administration. Second, we focus on the design of the ML benchmarking solution for intents, using a specific module within IBN-based management system, we refer to as \emph{ML Recommender}. This module estimates the computational performance of ML-based techniques on heterogeneous hardware devices in the system, without explicit knowledge about the number of operations, framework, or the device processing characteristics of each ML technique. To discover and learn the features that link the performance of a specific ML model to the hardware in an implicit way we will use Collaborative Filtering (CF), as a commonly used tool in recommendation systems \cite{delimitrou2013paragon}. Finally, we evaluate the system performance by measuring the quality of forecasting using a small number of tests on some devices, and the information from previous execution of other ML techniques on existing hardwares. The information collected about the performance is represented as a sparse matrix. The matrix would contain information about the computational performance of certain ML tasks, such as Deep Learning models, which were hosted on specific hardware devices in previous executions. After that, ML algorithm called Singular Value Decomposition (SVD), will be used in order to estimate the missing values of the input matrix, which will in turn be used as valid ML-performance estimation. We show how the estimated outcome effectively enhances IBN-based management systems capabilities of scheduling, planning or hardware provisioning. The rest of this paper is organized as follows. Section \ref{sec:1} describes the related work. Section \ref{sec:2} describes the case study of intent-based management in ICT supply chains. The ML benchmarking solution is presented in \ref{sec:MLrec}. Section \ref{sec:evaluation} evaluates the performance. We conclude the paper in Section \ref{sec:conclusion}. \section{Related work} \label{sec:1} With a rise of complex network environments and system architectures, there has also been an increased interest in more intelligent and autonomous management methods, with intent based networking as one of the leading trends. Intent based networking is a practical concept used in specific reference scenarios. In \cite{su12072782} and \cite{8004109}, multi-platform 5G and IoT network infrastructures are studies with IBN solutions. In \cite{9200928} distributed, multi-technology, and multi-stakeholder network infrastructures are taken as examples to drive the need for intelligent automation and orchestration. Our previous work in \cite{bensalem2021role} introduced and motivated intent-based networking in the so-called ICT supply chain system, defined as \emph{a system integrating ICT products and services, transforming raw materials, and components into a finished product or service from supplier to the end user.}. Similarly, a part of closed-loop automation was analyzed in supply chains, with different management system requirements formulated with intents \cite{gomes2021intent}. Every IBN architecture deploys ML techniques, which in general need to run on rich heterogeneous hardware platform environments. Hence, for an intent to be executed effectively, it is critical to understand the performance of the ML solution deployed. In \cite{nemirovsky2017machine}, an ML approach based on artificial neural network was proposed, with the aim of predicting the performance of different applications and with that advancing the effectiveness of scheduling on a CPU hardware. In \cite{makrani2019xppe}, the execution time of an application on a specific FPGA is used to predict the execution time on other hardware without making a real implementation, using neural networks as a tool for estimation. In addition, software developers need to define some system characteristics of their developed components before deploying in production. In \cite{hafnaoui2016simulation}, a methodology is presented that estimates the execution time of software components on a specific architecture using simulation and analytical tools that uses parts of system information. The paper compared the estimated execution times of certain software components using the simulation based system and the real benchmarks. The work presented in \cite{delimitrou2013paragon} proposes an online and scalable datacenter scheduler, considering the heterogeneity of hardware and the interference between executed workloads, using the collaborative filtering prediction technique. The same technique will be used in this paper, due to its wide use in recommendation systems. One of the most famous applications of CF is Netflix Challenge \cite{bell2008bellkor}, which will also be used as a reference method in our work, as well as the framework developed in \cite{delimitrou2013paragon}. \section{A Case Study of Intent-Based Management in ICT Supply Chains} \label{sec:2} As ICT supply chain networks are comprised of heterogeneous and complex infrastructures, with the high interoperability requirements. Here, managing, orchestrating and enforcing policies at scale is a challenge. To tackle this challenge and develop an intelligent management strategy, we employ the paradigm of intent-based networking in order to allow administrators to set high level intents that instruct the system of \emph{what to do} instead of \emph{how} a task should be executed. \subsection{IBN Reference Architecture} The case study of IBN based management system design is illustrated in Fig.~ \ref{fig:sysarch}, with the ML-based intelligence as the key enabler of the proposed solution, considering the need for automation of system configurations. The ICT supply chain network typically consists of several domains, such as factories, transportation facilities, warehouses, and retailers. Each domain can have its own computing servers, which are used for various computational functionalities, such as networking, security, system optimization, and system management. Tasks can be forwarded to dedicated servers depending on the required computation, memory, throughput etc. \begin{figure*} \centering \includegraphics[scale=0.43]{refarch2.pdf} \caption{Reference architecture of an intelligent intent based management system in ICT supply chain} \label{fig:sysarch} \vspace{-0.2 cm} \end{figure*} The reference architectural design of the intelligent intent based management system is illustrated in Fig.~\ref{fig:sysarch}. The system consists of ICT supply chain network infrastructure, including various IoT devices such as security cameras, RFIDs, and sensors, edge computing nodes located geographically close to the IoT devices, a centralized ICT supply chain network controller to monitor and manage the infrastructure, and a high-level intent-based orchestrator. The network controller collects telemetry from the infrastructure, manage and enforce policies in the system. The intent-based orchestrator is a high-level layer that interacts with the network administrator in order to provide an easy-to-use management interface. It includes different modules that insures the translation of user, i.e., system administrator, intents into configured policies to be applied by the network controller: a dashboard, intent-based interface, intent manager, policy configurator, knowledge base, monitoring, and ML recommender. The \textit{dashboard} provides a user interface, where the intents given by the network administrator are read and then parsed by an \textit{intent-based interface}. An \textit{intent manager} component is designed to translate high-level intents into a structured format with the help of natural language processing techniques. Structured specifications translated from the intent are then forwarded to the \textit{policy configurator} component, which matches the user requirements with possible predefined policies stored in a \textit{knowledge base}, and more specifically in a \textit{policy store}. After configuring these policies, conflicts are checked and verified. Then the \textit{policy configurator} triggers the network controller to apply changes in the network infrastructure. Monitoring tools are used by the network controller to collect metrics and provide the real time state of the network. The \textit{Monitoring} component in the intent-based orchestrator filters the telemetry collected from the network and uses the \textit{knowledge base} to store some selected telemetry such as CPU/GPU performance, memory, latency, throughput, security state of links and devices, application logs, and security camera results etc. One important telemetry information is the the ML techniques performance on different hardware, which is saved in an \textit{ML techniques store}. In order to use this telemetry and improve policy configuration methods such as scheduling of functions on servers, routing, and enhancing access control configuration, we design an intelligent module called \textit{ML Recommender}. This module will tackle one of the most important challenges related to choosing and deploying the best ML-based algorithms in the most suitable server of the supply chain infrastructure, using the performance information collected in the \textit{ML techniques store}.\\ \subsection{Benchmarking ML Solutions in IBN Systems}\label{sec:ML-in-ibn} ML solutions are widely used for various tasks in ICT supply chains, such as threat detection, demand forecasting, and face detection. When a new device joins the network, it has no performance history, which makes the system enable to accurately take several decisions such as ML techniques allocation. To solve this problem, the \textit{ML Recommender} is introduced, which is responsible on benchmarking the performance of ML techniques on new coming device or the performance of new ML techniques on existing devices. (The next section describes the design of the ML recommender in detail.) From a system design side, in order to trigger the \textit{ML Recommender}, we propose two intent types that can be used by the system administrator, as follows: \begin{itemize} \item For adding a new hardware device: "add device $\textit{device\_id}$ to domain $\textit{domain\_id}$" \item For adding a new ML technique: "add ML-technique $\textit{ML-tech\_id}$ to ML-technique type $\textit{ML-tech\_type\_name}$" \end{itemize} The intent manager then discovers the intent types from the input text and parse it in a structured JSON format as: \{intent\_name : "adding device", device: "device\_id", domain: "domain\_id"\}, and \{intent\_name : "adding ML-technique", ML-technique: "ML-tech\_id", ML-technique\_type: "ML-tech\_type\_name"\}. After that the policy configurator matches the given intent with the required policies. For instance, this can be defined as follow: check the connectivity of device ("device\_id"), or check the existence of ML-technique ("ML-tech\_id") in an ML techniques store using its "ML-tech\_type\_name", alert the user if the checking operation fails, trigger the \textit{ML Recommender} with the provided information, or similar.\\ \section{ML Benchmarking}\label{sec:MLrec} As a part of the intelligent intent based management system, \textit{ML Recommender} module will have the task of benchmarking and estimating the performance of different ML techniques on heterogeneous ICT supply chain hardware platforms. Instead of running all existing ML techniques on each device, to link the performances of a specific ML model to the hardware we will use Collaborative Filtering. This section first explains the CF techniques envisioned, after which we present how they are being applied to estimate technique-device benchmarks. \subsection{Collaborative Filtering Techniques}\label{subsec:1-1} We adopt a single rating CF system for product recommendation, where the input is modeled as a sparse matrix $E\in \mathbb{R}^{m,n}$, where $m$ is the number of users and $n$ is the number of items. Each user $i$ is represented by one row and each item $j$ by one column. In this example, we denote by $e_{i,j}$ the rating of item $j$ by user $i$. A new incoming user will rate a limited number of items, then the existing user rating is used to estimate the ratings for other missing items. CF algorithms ensure that the predicted value is always in the same range used by all users. After obtaining the complete rating information, a recommendation system recommends the list of Top-N most likable items by the user. One of the efficient methods of CF, which among many other recommender systems was also used in the Netflix Challenge \cite{bell2008bellkor}, is the Singular Value Decomposition SVD, that we will adopt as a first step of our estimation approach. SVD is a technique of dimensionality reduction used to decompose a matrix into three matrices $U$, $V$, and $\Sigma$, in order to find lower bi-dimensional feature space. \begin{equation}\label{eq:svd} SVD(E)= \begin{pmatrix} e_{1,1}& . &. & .&e_{1,n}\\ e_{2,1}& . &. &. &e_{2,n} \\ .& . &. &. &. \\ .& . & e_{i,j} & . &. \\ .& . &. &. & .\\ e_{m,1}& . & . & . &e_{m,n} \end{pmatrix} =U\Sigma V^{T} \end{equation} Where $U$ and $V$ are $m \times r$and $n\times r$ orthogonal matrices, representing the left and right singular vectors respectively, and $\Sigma$ is an $r \times r$ diagonal matrix, representing the singular values, $r$ denotes the rank of matrix $E$, and expresses the number of features of similarity resulted by SVD. The application of SVD requires the factorization of our input matrix $E$, which is a complex problem due the sparsity of the matrix. Traditional SVD algorithms cannot work with incomplete information about the entries and in addition they cause the issue of overfitting, meaning that the estimation will converge to some known values from the given input. \\ In order to recover missing entries of the matrix $E$, PQ-reconstruction method \cite{delimitrou2013paragon} will be used. To that end we define the matrices $Q=U$, $P^T=\Sigma V^{T}$, and $R=Q\times P^T$ as the approximation of A, including the missing entries. The vector associated to the item $j$ is denoted by $q_j\in \mathbb{R}^r$, which expresses the features representation of item $j$. Similarly for users, $p_i\in \mathbb{R}^r$ denotes the vector associated to the user $i$, to express its features representation. Therefore, the elements of the approximation matrix $R$ can be represented as: \begin{equation}\label{eq:r} r_{i,j}=q_j^T p_i \end{equation} The estimation of any rating of a user $i$ to an item $j$ can be easily obtained, once we have the feature vectors $p_i$ and $q_j$. In matrix reconstruction, the estimation model is built using the observed ratings and avoiding the missing entries, represented by zero values in the sparse matrix $E$. For the overfitting problem, a regularization term is used while minimizing the error during the learning phase. The following minimization formulation of the problem tries to minimize the squared error between the rating and the estimation, considering the regularization term: \begin{equation}\label{eq:min} \min_{q,p} \sum_{(i,j)\in S} (r_{i,j} - q_j^T p_i)^2 + \lambda (||q_j ||^2+ (||p_i||^2) \end{equation} Where $S$ represents the set of non-zero values of matrix $E$, and $\lambda$ is a regularization parameter. The non-zero values are considered to model the previously observed ratings in order to create a general fitting function able to predict unknown ratings, while minimizing the error. The regularization parameter $\lambda$ is used to adjust the minimization function and prevent overfitting the model with known values. Next, we adopt the Stochastic Gradient Descent as a learning algorithm that processes the matrix $E$ to improve the estimation. The feature vectors $p_i$ and $q_j$ are initialized randomly and iterated over all the training set of ratings. In each iteration the value of the rating using eq. (\ref{eq:r}) is predicted and computed as follows: \begin{equation}\label{eq:epsilon} \epsilon_{i,j}=r_{i,j}-q_j^T p_i \end{equation} Afterwards, we update the feature vectors $q_j$ and $p_i$ using a learning rate $\sigma$, considering the regularization factor $\lambda$, as follows: \\ \begin{equation}\label{eq:q} q_j = q_j+\sigma \cdot (\epsilon_{i,j} \cdot p_i - \lambda \cdot q_j) \end{equation} \begin{equation}\label{eq:p} p_i = p_i+\sigma \cdot (\epsilon_{i,j} \cdot q_j - \lambda \cdot p_i) \end{equation} The algorithm iterates over all matrix entries s times, where s is a parameter to be defined, as well as the learning rate $\sigma$, regularization factor $\lambda$, and the number of features $r$ (called latent factors). The utilization of the previously described algorithm to estimate the performance of a ML-based technique is described in the next subsection. \subsection{Predicting Performance of Various ML Techniques}\label{sub-sec:similarity} In proposed intelligent intent based management system, we assume the existence of $M$ ML techniques, that can be executed on $N$ hardware devices. Example of ML-based techniques can be various object detection algorithms used to monitor security cameras, executing different tasks like employee detection, threat detection, product quality monitoring, etc. Different ML models can do the same task, while having different speed performance in inference, memory consumption, and accuracy of results. One of the most important factors that need to be measured is the inference performance, which will be the main objective of our proposed solution to predict. Fig. \ref{fig:idea} represents an abstraction of our problem, where we assume the existence of an ML techniques store containing ML models and several heterogeneous computing devices. The previously explained matrix $E$ of user-item ratings in this system represents the execution performance of matching pairs of devices and ML technique pairs. When a new ML technique is registered throught the intent-based orchestrator, as described in section \ref{sec:ML-in-ibn} e.g. \textbf{"add ML-technique $\textit{MobileNet-V2-threat\_1}$ to ML-technique type $\textit{threat-detection}$"}, we add a new raw to the performance matrix $E$ with empty zeros. After that, the \textit{ML Recommender} chooses randomly a set of devices for the benchmarking of new ML technique. The collected performance information is then added to $E$ as shown in Fig. \ref{fig:estimation}. a., then the SVD method is used to estimate the performance on the rest of devices using eq.\ref{eq:svd}, \ref{eq:p}, \ref{eq:q}, and \ref{eq:epsilon} in order to minimize the error defined in eq. \ref{eq:min}. Finally the \textit{ML Recommender} saves the new performance entries into the \textit{ML techniques store}. \\ \begin{figure} \centering \includegraphics[scale=0.55]{idea3.pdf} \caption{Running ML technique on heterogeneous computing devices} \label{fig:idea} \vspace{-0.5cm} \end{figure} \subsection{System Scaling} An important factor to be considered in an IBN system design, which also is its salient feature, is the scalability. To this end, we consider a scenario where a new hardware device is added to the system. We start with the assumption that there is no any prior knowledge about the performance of ML techniques on a newly added device. The procedure of performance estimation in this case, is similar to the procedure used for a new incoming technique, triggered by the user from the intent-based orchestrator, e.g. \textbf{"add device $\textit{edge\_100}$ to domain $\textit{warehouse\_5}$"}. The estimation process again follows two phases, warm-up and online, where the warm-up phase is the same as used previously in Fig. \ref{fig:idea}. When a new device is added, the performance of existing ML-based techniques on that device needs to be benchmarked. In Fig.\ref{fig:estimation}.b, an illustration of this process is shown. Assuming that $k$ techniques are chosen from the ML techniques store, they are executed one by one on the new device, and with their performance results collected. After this, a new column is added to the matrix $E$ associated to the new device, with the entries corresponding to each benchmarked technique filled. Next, the new matrix is normalized, followed by applying the previously explained SVD algorithm \ref{subsec:1-1}, where eq.\ref{eq:svd}, \ref{eq:p}, \ref{eq:q}, and \ref{eq:epsilon} are used for error minimization in eq. \ref{eq:min}. The missing performance estimation is then obtained, out of all the registered techniques in the system, saved in the \textit{ML techniques store}, which allows us to scale up, migrate or replicate using the new hardware device. \begin{figure} \centering \includegraphics[scale=0.55]{estimation1.pdf} \caption{Performance estimation of a ML techniques on a newly added device.} \label{fig:estimation} \vspace{-0.2 cm} \end{figure} \section{Performance Evaluation} \label{sec:evaluation} To evaluate the performance of our proposed ML algorithm, an online store of AI benchmark experiments is used \cite{aibenchmark2019}. It contains numerous AI tasks and deep learning architectures, tested on multiple hardware platforms. Most popular DL architecture like \textit{MobileNet-V2} (classification), \textit{Inception-V3} (classification), \textit{VGG-19} (image-to-image mapping) and \textit{LSTM} (sentence sentiment analysis), and \textit{DeepLab} (image segmentation) are evaluated in terms of training time and inference time (per one image), as well as memory utilization. An updated dataset from 2019 containing 42 different AI tasks built for desktops is used in our work \cite{ignatov2019ai}. Popular hardware platforms, such as CPUs, GPUs and TPUs, are configured to run deep learning models. In the store, 192 different hardware platforms are tested, e.g. \textit{Tesla V100 SXM2 32Gb}, \textit{NVIDIA TITAN V},\textit{ GeForce GTX 1080 Ti}, \textit{AMD Threadripper 3970X}, \textit{Intel Xeon Gold 6130}, etc. To emulate the behavior of the proposed ML recommender, we assume that our system consists of 191 heterogeneous hardware units, and an \textit{ML techniques store} of 42 AI tasks. A new hardware is added to our network, which needs to be tested in order to collect the performance of all the existing AI tasks in the store. The \textit{knowledge base} of the intent-based orchestrator is initialized with a subset of the existing AI tasks and a subset of the existing hardware platforms. The \textit{ML Recommender} is triggered throught the \textit{dashboard} using the following intents: \textbf{"add ML-technique $\textit{MobileNet-V2}$ to ML-technique type $\textit{threat-detection}$"}, where the \textit{ML-tech-id} is replaced by a different ML technique from the store for every replication e.g. \textbf{\textit{Inception-V3}, \textit{VGG-19}}, etc. After that SVD algorithm runs to predict the benchmark values of missing hardware devices. The metric used to evaluate the machine learning algorithm is the normalized root mean squared error (RMSE) and can be expressed as follows: \begin{equation} \text{RMSE} = \sqrt{\frac{\sum_{i=1}^{N}\sum_{j=1}^{N}\epsilon_{i,j}^2}{N^2}} \end{equation} \begin{equation} \text{normalized RMSE} = \frac{\text{RMSE}}{\max{R}-\min{R}} \end{equation} where R is the matrix that contains predictions, $\max{R}$ and $\min{R}$ represent the maximum and minimum values in the matrix. The number of iterations is set to 5000, the latent factors are set to 10, learning rate is 0.04, and $\beta=5 \cdot 10^{-6}$. In figure \ref{fig:missingvalues} the percentage of missing benchmark is varied from 30\% to 90\%. For each test, 5 replications are evaluated where a random device is chosen for benchmark prediction for every replication. Then the average normalized RMSE is calculated and plotted. The performance of prediction is expected to decrease (normalized RMSE increase) when the percentage of missing values increases. Thus, the more benchmarks we obtain from real measurements, the better our estimation of the AI tasks performance on other hardware devices. For a 30\% of missing devices, the normalized RMSE is equal to 0.03, which is a promising results. However the normalized RMSE for 90\% of missing benchmarks is very high around 0.2, which needs to be improved, in order to use our system for practical applications, where benchmarking techniques are time consuming, and when scheduling must happen in real time using accurate performance evaluations. \begin{figure} \centering \includegraphics[scale=0.4]{missingv.pdf} \caption{Performance of benchmark prediction using Normalized RMSE with different settings of missing benchmarks.} \label{fig:missingvalues} \vspace{-0.2 cm} \end{figure} \section{Conclusion and Future work} \label{sec:conclusion} With the rise of heterogeneous devices in complex ICT systems and the rise of machine learning based solutions that are implemented to solve problems in every domain of application, it is becoming an imperative to study the challenges of managing ML solutions running in such systems in an innovative way. We first proposed intent-based networking (IBN) solution as the approach for intelligent managing of ICT supply chain systems. Afterwards, we studied the problem of benchmarking these ML solutions, through a module called \emph{ML Recommender}. This module is used for estimating the computational performance of ML-based techniques on heterogeneous hardware devices, considering the lack of explicit knowledge about the number of operations, framework, or the device processing characteristics for each ML-based technique. Collaborative Filtering techniques like Singular Value Decomposition (SVD) are used to estimate the missing values of the benchmark input matrices, which is planned to be used to enhance the management system capabilities of scheduling, planning or hardware provisioning. A dataset of 42 ML model benchmarked on 196 different hardware platform were used for testing the proposed algorithm, where the results are promising in terms of estimation correctness. As a future work, we plan to extend our system design of the ML recommender to consider the scheduling and planning problem, and to show how can a user requirement given as a high-level intent be automatically translated into scheduling decisions using our benchmarking solution. \section*{Acknowledgment} This work is partially funded by European Commission under the H2020-952644 contract for project FISHY: A coordinated framework for cyber resilient supply chain systems over complex ICT infrastructures. \bibliographystyle{IEEEtran}
{'timestamp': '2021-11-16T02:33:00', 'yymm': '2111', 'arxiv_id': '2111.07724', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07724'}
arxiv
\section{Introduction} Possibilistic logic is the most popular approach to represent and reason with uncertain and partially inconsistent knowledge. Regarding normal forms, the encoding of real-world problems does usually not result in a clausal formula and although a possibility non-clausal formula is theoretically equivalent to some possibilistic clausal formula \cite{DuboisP14, DuboisP94}, approaches needing clausal form transformations are practically infeasible or have experimentally shown to be highly inefficient as discussed below. \vspace{.05cm} Two kinds of clausal form transformation are known: (1) one is based on the repetitive application of the distributive laws to the input non-clausal formula until a logically equivalent clausal formula is obtained; and (2) the other transformation, Tsetin-transformation \cite{Tseitin83}, is based on recursively substituting sub-formulas in the input non-clausal formula by fresh literals until obtaining an equi-satisfiable, but not equivalent, clausal formula. \vspace{.05cm} The first transformation blows up exponentially the formula size, and since real-world problems have a large number of variables and connectives, the huge dimension of the resulting clausal formulas prevents even highly-efficient state-of-the-art solvers from attaining solutions in a reasonable time. \vspace{.05cm} The second kind of transformation also involves a number of drawbacks. The Tseitin-transformation usually produces an increase of formula size and number of variables, and also a loss of information about the formula's original structure. Besides in most cases, the normal form is not unique. Deciding how to perform the transformation enormously influences the solving process and it is usually impossible to predict which strategy is going to be the best, as this depends on the concrete solver used and on the kind of problem which should be solved. Further, Tseitin-transformation keeps the satisfiability test but losses the logical equivalence, which rules out its usage in many real-world problems. \vspace{.05cm} We abandon the assumption that the input formula should be transformed to clausal form and directly process it in its original structure. Since real-world problems rarely occur in clausal form, we allow an arbitrary nesting of conjunctions and disjunctions and only limit the scope of the negation connective. The non-clausal form considered here is popularly called negation normal form (NNF), and can be obtained deterministically and causing only a negligible increase of the formula size. \vspace{.05cm} Developing methods for NC reasoning is an actual concern in the principlal fields of classical logic, namely satisfiability solving \cite{Otten11,LiMS19}, logic programming \cite{ConfalonieriN11,CabalarFSS19}, theorem proving \cite{FarberKaliszyk19,OliverO20} and quantified boolean formulas \cite{EglySW09,BubeckB13}, and in many other fields (see \cite{Imaz2021horn} and the references thereof). And within non-classical logics, NC formulas with different functionalities have been studied in a profusion of languages: signed many-valued logic \cite{ MurrayRosenthal94, BeckertHE98, Stachniak01}, \L ukasiewicz logic \cite{Lehmke96}, Levesque's three-valued logic \cite{CadoliS96}, Belnap's four-valued logic \cite{CadoliS96}, M3 logic \cite{Aguilera97}, fuzzy logic \cite{Habiballa12}, fuzzy description logic \cite{Habiballa07}, intuitionistic logic \cite{Otten17}, modal logic \cite{Otten17}, lattice-valued logic \cite{00010HZC18} and regular many-valued logic \cite{Imaz21b}. We highlight the proposal in \cite{NievesL12,NievesL15} as is the only existing approach, to our knowledge, to deal with possibilistic non-clausal formulas, concretely within the answer set programming field. \vspace{.05cm} On the other side, the Horn clausal formulas are pivotal elements of our proposed possibilistic reasoning approach towards combining non-clausal expressiveness with high efficiency. Horn formulas are recognized as central for deductive databases, declarative programming, and more generally, for rule-based systems. In fact, Horn formulas have received a great deal of attention since 1943 \cite{McKinsey43,Horn51} and, at present, there is a broad span of areas within artificial intelligence relying on them, and their scope covers a fairly large spectrum of realms spread across many logics and a variety of reasoning settings. \vspace{.05cm} Regarding possibilistic Horn formulas, computing their inconsistency degree is a tracta-ble problem \cite{Lang00} and even almost-lineal \cite{AlsinetG00}. Related to this standard Horn class but going beyond clausal form, we present a novel possibilistic class, denoted $ \mathcal{\overline{H}}_\Sigma$, that is in NC form and that we call Horn Non-Clausal (Horn-NC). We show that $ \mathcal{\overline{H}}_\Sigma$ is a sort of non-clausal analogous of the possibilistic Horn class. Besides the latter, $ \mathcal{\overline{H}}_\Sigma$ also subsumes the class of propositional Horn-NC formulas recently presented \cite{Imaz2021horn}. \vspace{.05cm} From a computational view, we prove that computing the inconsistency degree of $ \mathcal{\overline{H}}_\Sigma$ members is a tractable problem. This result signifies that polynomiallity in our context is preserved when upgrading both from clausal to non-clausal form and from propositional to possibilistic logic. Polynomiallity is preserved when upgrading from clausal to non-clausal form because both classes possibilistic Horn \cite{Lang00} and possibilistic Horn-NC are tractable. Similarly, polynomiallity is preserved when upgrading from propositional to possibilistic logic because both classes propositional Horn-NC \cite{Imaz2021horn} and possibilistic Horn-NC are tractable. \vspace{.05cm} In summary, our contributions are: introducing the hybrid class of {\em Possibilistic Horn Non-Clausal Knowledge Bases,} or $\mathcal{\overline{H}}_\Sigma $, and then, proving that computing their inconsistency degree is a polynomial problem. Our contributions are outlined next. \vspace{.05cm} {\bf Firstly,} the syntactical Horn-NC restriction is determined by lifting the Horn clausal restriction ``a formula is Horn if all its clauses have any number of negative literals and at most one positive literal", to the non-clausal level in the following manner: {\em ``a propositional NC formula is Horn-NC if all its disjunctions have any number of negative disjuncts and at most one non-negative disjunct".} By extending such definition to possibilistic logic, we establish straightforwardly that: a possibilistic NC knowledge base is Horn-NC only if all its propositional formulas are Horn-NC. Accordingly, $\mathcal{\overline{H}}_\Sigma $ is defined as the {\em class of Possibilistic Horn-NC Knowledge Bases}. Note that $\mathcal{\overline{H}}_\Sigma $ naturally subsumes the standard possibilistic Horn clausal class. \vspace{0.05cm} The set relations that the new class $\mathcal{\overline{H}}_\Sigma $ bears to the standard possibilistic classes Horn ($\mathcal{H}_\Sigma$), Non-Clausal ($\mathcal{NC}_\Sigma$) and Clausal ($\mathcal{C}_\Sigma$) are depicted in {\bf Fig. 1}. Specifically, we show the next relationships of $\mathcal{\overline{H}}_\Sigma $ with $\mathcal{H}_\Sigma$ and $\mathcal{NC}_\Sigma$: (1) $\mathcal{\overline{H}}_\Sigma $ and $ \mathcal{{H}}_\Sigma $ are related in that $\mathcal{\overline{H}}_\Sigma $ subsumes syntactically $\mathcal{{H}}_\Sigma $ but both classes are semantically equivalent; and (2) $\mathcal{\overline{H}}_\Sigma $ and $\mathcal{NC}_\Sigma$ are related in that $\mathcal{\overline{H}}_\Sigma $ contains all NC bases whose clausal form is Horn. Thus, in view of (1) and (2) relations, $\mathcal{\overline{H}}_\Sigma $ is a sort of NC analogous of $ \mathcal{{H}}_\Sigma $. \vspace{-.1cm} \begin{center} \begin{tikzpicture} \begin{scope}[blend group=soft light] \fill[black!40!white] (270:.9) circle (2.3); \fill[green!100!white] (230:1.2) circle (1.3); \fill[red!100!white] (310:1.2) circle (1.3); \end{scope} \node at (100:.8) {\bf \ $\ \mathcal{NC}_\Sigma$}; \node at (215:1.6) {\bf $\mathcal{C}_\Sigma$}; \node at (325:1.6) {\bf $\mathcal{\overline{H}}_\Sigma$}; \node at (270:.9) {\bf $\mathcal{{H}}_\Sigma$}; \end{tikzpicture} \vspace{.1cm} \footnotesize{{\bf Fig. 1.} The Horn, clausal, Horn-NC and NC classes.} \end{center} {\bf Secondly,} we establish the inferential calculus {\em Posibilistic Non-Clausal Unit-Resolution}, or $\mathcal{UR}_\Sigma$, and then prove that $\mathcal{UR}_\Sigma$ correctly computes the inconsistency degree of the bases in the class $\mathcal{\overline{H}}_\Sigma $. NC unit-resolution for propositional logic has been recently presented \cite{Imaz2021horn} and $\mathcal{UR}_\Sigma$ is its generalization to possibilistic logic. $\mathcal{UR}_\Sigma$ is formulated in a clausal-like fashion, which contrasts with the functional-like fashion of the existing (full) non-clausal resolution \cite{Murray82}. We argue that our clausal-like formulation eases the understanding of $\mathcal{UR}_\Sigma$, the building of the required formal proofs and the future generalization of $\mathcal{UR}_\Sigma$ to determine Non-Clausal Resolution for possibilistic and for other uncertainty logics. \vspace{.05cm} {\bf Thirdly,} we prove that computing the consistency degree of $\mathcal{\overline{H}}_\Sigma $ members has polynomial complexity. There indeed exist polynomial classes in possibilistic logic but all of them are clausal \cite{Lang00}, and so, the tractable non-clausal fragment was empty. We think that this is just a first tractable result in possibilistic reasoning and that the approach presented here will serve to widen the tractable possibilistic non-clausal fragment. \vspace{0.05cm} Below we give an specific possibilistic non-clausal base $\Sigma $, whose suffix notation will be detailed in Section \ref{sec:NCbasis} and wherein $ P, Q, \ldots $ and $ \neg {P}, \neg {Q}, \ldots $ are positive and negative literals, respectively, and $ \phi_1 $, $ \phi_2 $ and $ \phi_3 $ are non-clausal propositional formulas. We will $$\varphi= \{\wedge \ \, P \ \, (\vee \ \ \neg Q \ \ \{\wedge \ \ (\vee \ \ \neg P \ \ \neg Q \ \ R \,) \ \ (\vee \ \ \phi_1 \ \ \{\wedge \ \ \phi_2 \ \ \neg P \,\} \, ) \ \, Q \,\} \,) \ \ {\phi_3} \ \} $$ $$\Sigma= \{\,\langle \varphi : {\bf 0.8} \rangle \quad \langle P : {\bf 0.8} \rangle \quad \langle \neg Q : {\bf 0.6} \rangle \quad \langle R : {\bf 0.6} \rangle \quad \langle \phi_1 : {\bf .3} \rangle \quad \langle \phi_3 : {\bf 1} \rangle \, \}$$ \noindent show that $ \Sigma $ is Horn-NC when $ \phi_3 $ is Horn-NC and at least one of $ \phi_1 $ or $ \phi_2 $ is negative. \vspace{.1cm} Recapitulating, the list of properties of $ \mathcal{\overline{H}}_\Sigma $ is given below, where the last two properties have been shown in \cite{Imaz2021horn} for propositional logic but are inherited by $ \mathcal{\overline{H}}_\Sigma $: \begin{itemize} \item Computing the inconsistency degree of $ \mathcal{\overline{H}}_\Sigma $ is tractable. \vspace{-.25cm} \item $ \mathcal{\overline{H}}_\Sigma $ subsumes syntactically the possibilitic Horn class. \vspace{-.25cm} \item $ \mathcal{\overline{H}}_\Sigma $ is equivalent semantically to the possibilitic Horn class. \vspace{-.25cm} \item $ \mathcal{\overline{H}}_\Sigma $ contains all possibilitic NC bases whose clausal form is Horn. \vspace{-.25cm} \item $ \mathcal{\overline{H}}_\Sigma $ is linearly recognizable \cite{Imaz2021horn}. \vspace{-.25cm} \item $ \mathcal{\overline{H}}_\Sigma $ is strictly succincter\footnote{Succinctness was defined in \cite{GogicKPS95}.} than the possibilistic Horn class \cite{Imaz2021horn}. \end{itemize} The presented approach serves as starting point to develop approximate non-clausal reasoning based on (1) DPLL and (2) resolution: (1) $\mathcal{UR}_\Sigma$ paves the way to define DPLL in NC since its NC Unit-Propagation is based on NC Unit-Resolution, i.e. $\mathcal{UR}_\Sigma$; and (2) the existing NC resolution \cite{Murray82} presents some deficiencies derived from its functional-like formalization, such as not precisely defining the potential resolvents. Our clausal-like formalization of $\mathcal{UR}_\Sigma$ skips such deficiencies and signifies a step forward towards defining NC resolution for at least those uncertainty logics for which clausal resolution is already defined, e.g. possibilistic logic \cite{DuboisP87, DuboisP90}. \vspace{.05cm} This paper is organized as follows. Section \ref{sec:NCbasis} and \ref{sec:refresher} present background on propositional non-clausal formulas and on possibilistic logic, respectively. Section \ref{sec:definClassHorn-NCChapeau} defines the class $\mathcal{\overline{H}}_\Sigma $. Section \ref{sec:Non-Clausal-Unit-resolution} introduces the calculus $\mathcal{UR}_\Sigma$. Section \ref{sec:illustrativeexamples} provides examples illustrating how $\mathcal{UR}_\Sigma$ computes $\mathcal{\overline{H}}_\Sigma $ members. Section \ref{sect:ProofsProperties} provides the formal proofs of the correctness of $\mathcal{UR}_\Sigma$ and of the tractability of $\mathcal{\overline{H}}_\Sigma $. Section \ref{sec:relatedwork } focuses on related and future work. Last section summarizes the main contributions. \section{Propositional Non-Clausal Logic} \label{sec:NCbasis} This section presents some terminologies used in this paper and background on non-clausal (NC) propositional logic (see \cite{DBLP:books/daglib/0029942} for a complete background). We present first the needed syntactical concepts and then the semantical ones. We begin by introducing the language. \begin{definition} \label{def:alphCNF} The NC language is formed by the sets: constants $ \{{\bf \bot, \top}\} $, propositions $\mathcal{P}=$ \{P, Q, R, \ldots \}, connectives \{$\neg, \vee, \wedge\}$ and auxiliary symbols (, ), {\em \{ {\em and} \}}. \end{definition} Next we describe the required elements relative to clausal formulas. \begin{definition} $X $ (resp. $ \neg {X}$) with $ X \in \mathcal{P} $ is a positive (resp. negative) literal. $ \mathcal{L}$ is the set of literals. Constants and literals are atoms. $(\vee \ \ell_1 \ \ell_2 \ \ldots \ \ell_k)$, the $ \ell_i$ being literals, is a clause. A clause with at most one positive literal is Horn. $\{\wedge \ C_1 \ C_2 \ \ldots \ C_n\}$, the $ C_i $ being clauses, is a clausal formula. $ \mathcal{C} $ and $ \mathcal{H} $ are the set of clausal and Horn formulas, respectively. \end{definition} \noindent {\bf Note.} We firstly justify our chosen notation of non-clausal formulas before defining them. Thus, for the sake of readability of non-clausal formulas, we will employ: \begin{enumerate} \item The prefix notation as it requires only one $\vee / \wedge$-connective per formula, while infix notation requires $k-1$, $k$ being the arity of the involved $\vee / \wedge$-connective. \item Two formula delimiters (see Definition \ref{def:NCformulas}), $(\vee \,\ldots \,)$ for disjunctions and $\{\wedge \,\ldots \,\}$ for conjunctions, to better distinguish them inside non-clausal formulas. \end{enumerate} \noindent So our next definition is that of non-clausal formulas\footnote{Also called "negation normal form formulas" in the literature.}, whose differential feature is that the connective $ \neg $ can occur only in front of propositions, i.e. at atomic level. \begin{definition} \label{def:NCformulas} The non-clausal formulas over a set of propositional variables $\mathcal{P} $ is the smallest set $\mathcal{NC}$ such that the following conditions hold: \begin{itemize} \item $\{\bot, \top\} \cup \mathcal{L} \,\subset \,\mathcal{NC}$. \item If \ $\forall i \in \{1, \ldots k \}$, $\varphi_i \in \mathcal{NC}$ \,then \,$\{\wedge \ \varphi_1 \ldots \varphi_{i} \ldots \varphi_k\} \in \mathcal{NC}$. \item If \ $\forall i \in \{1, \ldots k \}$, $\varphi_i \in \mathcal{NC}$ \,then \,$\,(\vee \ \varphi_1 \ldots \varphi_{i} \ldots \varphi_k) \in \mathcal{NC}$. \end{itemize} \vspace{.1cm} -- $\{\wedge \,\varphi_1 \ldots \varphi_{i} \ldots \varphi_k \}$ and any $\varphi_i$ are called conjunction and conjunct, respectively. \vspace{.1cm} -- $(\vee \,\varphi_1 \ldots \varphi_{i} \ldots \varphi_k )$ and any $\varphi_i$ are called disjunction and disjunct, respectively. \vspace{.1cm} -- $[ \odot \,\varphi_1 \ldots \varphi_{i} \ldots \varphi_k]$ stands for both $(\vee \,\varphi_1 \ldots \varphi_{i} \ldots \varphi_k ) \mbox{\ and \ } \{\wedge \,\varphi_1 \ldots \varphi_{i} \ldots \varphi_k \}.$ \end{definition} \begin{example} \label{exsec1:varisexamples} $ \varphi_1 $ to $ \varphi_3 $ below are NC formulas, while $ \varphi_4 $ is not. We will show that $ \varphi_2 $ is Horn-NC while $ \varphi_1 $ is not Horn-NC, and as $ \varphi_3 $ includes $ \varphi_1 $, then $ \varphi_3 $ is not Horn-NC either. On the other side, the example in the Introduction is Horn-NC under certain conditions. \begin{itemize} \item $ \ \varphi_1=\{\wedge \ \ (\vee \ \ \neg {P} \ \ Q \ \ \bot \,) \ \ (\vee \ \ Q \ \ \{\wedge \ \neg {R} \ \ S \ \ \top \, \} \, ) \, \}$ \item $ \ \, \varphi_2= (\vee \ \ \{\wedge \ \ \neg {P} \ \ \top \} \ \ \{\wedge \ \ (\vee \ \ \neg {P} \ \ R \,) \ \ \{\wedge \ \ Q \ \ (\vee \ \ P \ \ \neg {S} \,) \,\} \,\} \ \ \{\wedge \ \ \bot \ \ Q\}\,)$ \item $ \ \varphi_3=(\vee \ \ \varphi_1 \ \ \{\wedge \ \ Q \ \ (\vee \ \ \varphi_1 \ \ \neg {Q} \ \ \varphi_2) \,\} \ \ \{\wedge \ \ \varphi_2 \ \ \top \ \ \varphi_1 \,\} \,)$ \item \ $ \varphi_4= \neg (\vee \ \varphi_1 \ \varphi_2) $ \qed \end{itemize} \end{example} \begin{definition} \label{def:sub-for} Sub-formulas are recursively defined as follows. The unique sub-formula of an atom is the atom itself, and the sub-formulas of a formula $\varphi=\langle \odot \ \varphi_1 \ldots \varphi_i \ldots \varphi_k \rangle$ are $\varphi$ itself plus the sub-formulas of the $\varphi_i$'s. \end{definition} \begin{example} The sub-formulas of a clausal formula are the formula itself plus its clauses, literals and constants. \end{example} \begin{definition} \label{def:graphformula} NC formulas are modeled by trees if: (i) the nodes are: each atom is a {\em leaf} and each occurrence of a $ \wedge /\vee $-connective is an {\em internal node}; and (ii) {\em the arcs} are: each sub-formula $[ \odot \ \varphi_1 \ldots \varphi_{i} \ldots \,\varphi_k ]$ is a $k$-ary hyper-arc linking the node of $\odot$ with, for every $i$, the node of $\varphi_i$ if $\varphi_i$ is an atom and with the node of its connective otherwise. \end{definition} \begin{example} \label{Ex:tree} The tree of $\{\wedge \ \, \neg R \ \, (\vee \ \, \{\wedge \ \, \neg P \ \, Q \} \ \, \bot \ \, (\vee \ \, \neg P \ \, \neg R)\,)\,\} $ is given in Fig. 2. \begin{center} \begin{tikzpicture}[sibling distance=10em, every node/.style = {shape=rectangle, rounded corners, draw, align=center, top color=pink, bottom color=pink!100}]] \node {$\wedge$} child { node {$\neg {R}$} } child { node {$\vee$} child { node {$\wedge$} child { node {$\neg {P}$} } child { node {$Q$} } } child { node {$\bot$} } child { node {$\vee$} child { node {$\neg {P}$} } child { node {$\neg {R}$} }}}; \end{tikzpicture} \vspace{.1cm} {\normalsize{\bf Fig. 2.} Tree of Example \ref{Ex:tree}.} \end{center} \vspace{-.5cm} \qed \end{example} \noindent \noindent {\bf Remark.} Directed acyclic graphs (DAGs) generalize trees and allow for important savings in space and time. Our approach also applies when NC formulas are represented and implemented by DAGs. Nevertheless, for simplicity, we will use formulas representable by trees in the illustrative examples throughout this article. \vspace{.15cm} \noindent $-$ In the remaining of this section, we present semantical notions. \vspace{.1cm} \noindent $-$ In the next definition (first line), the empty disjunction $ (\vee) $ is considered equivalent to a $ \bot $-constant and the empty conjunction $ \{\wedge\} $ to a $ \top $-constant. \begin{definition} \label{def:interpretation} An interpretation $\omega$ maps the formulas $ \mathcal{NC} $ into the truth-value set $\{0,1\}$ and is extended from propositional variables $ \mathcal{P}$ to formulas $ \mathcal{NC} $ via the rules below, where $X \in \mathcal{P}$ and $ \varphi_i \in \mathcal{NC}$, $1 \leq i \leq k $. We will denote $ \Omega $ the universe of interpretations. \begin{itemize} \item $\omega(\bot)=\omega(\,(\vee)\,)=0$ \, and \, $\omega(\top)=\omega(\,\{\wedge\}\,)=1$. \item $\omega(X) + \omega(\neg X)= 1 $. \item $\omega( \, (\vee\ \varphi_1 \ldots \varphi_{i} \ldots \varphi_k) \, ) \,= \mathrm{max}\{\omega(\varphi_i): 1 \leq i \leq k \}$. \item $\omega(\, \{\wedge\ \varphi_1 \ldots \varphi_{i} \ldots \varphi_k\}\, ) = \mathrm{min}\{\omega(\varphi_i): 1 \leq i \leq k \}$. \end{itemize} \end{definition} \begin{definition} \label{def:model} $ \varphi $ and $ \varphi' $ being formulas, some well-known semantical notions follow. An interpretation $\omega$ is a model of $\varphi$ if $\omega(\varphi)=1.$ If $\varphi$ has a model then it is consistent and otherwise inconsistent. $\varphi$ and $\varphi'$ are (logically) equivalent, denoted $\varphi \equiv \varphi'$, if $\forall \omega$, $\omega(\varphi)=\omega(\varphi')$. $\varphi'$ is logical consequence of $\varphi$, denoted $\varphi \models \varphi'$, if $\forall \omega$, $\omega(\varphi) \leq \omega(\varphi')$. \end{definition} Next, some well-known rules allowing to simplify formulas are supplied. \begin{definition} \label{def:simpl} Constant-free, equivalent formulas are straightforwardly obtained by recursively applying to sub-formulas the simplifying rules below: \vspace{.25cm} $\bullet$ Replace \ \,$(\vee \ \top \ \varphi \,)$ \ with \ $ \top $. \vspace{.1cm} $\bullet$ Replace \ $\{\wedge \ \bot \ \varphi \,\}$ \ with \ $ \bot $. \vspace{.1cm} $\bullet$ Replace \ $\{\wedge \ \top \ \varphi \,\}$ \ with \ $ \varphi $. \vspace{.1cm} $\bullet$ Replace \ \,$(\vee \ \bot \ \varphi \,)$ \ \,with \ $ \varphi$. \end{definition} \begin{example} \label{ex:constantsfree} The constant-free, equivalent NC formula of $ \varphi_2 $ in Example \ref{exsec1:varisexamples} is: $$ \varphi=(\vee \ \ \neg P \ \ \{\wedge \ \ (\vee \ \ \neg P \ \ R ) \ \ \{\wedge \ \ Q \ \ (\vee \ \ P \ \ \neg S ) \, \} \, \} )$$ \end{example} \noindent {\bf Remark.} For simplicity and since free-constant, equivalent formulas are easily obtained, hereafter we will consider only free-constant formulas. \section{Necessity-Valued Possibilistic Logic} \label{sec:refresher} Let us have a brief refresher on necessity-valued possibilistic logic (the reader may consult \cite{DuboisP94,DuboisP04a, DuboisP14} for more details). \subsection{Semantics} At the semantic level, possibilistic logic is defined in terms of a {\em possibilistic distribution} $ \pi $ on the universe $ \Omega $ of interpretations, i.e. an $ \Omega \rightarrow [0,1] $ mapping which intuitively encodes for each $ \omega \in \Omega$ to what extent it is plausible that $ \omega $ is the actual world. $ \pi(\omega)=0 $ means that $\omega $ is impossible, $ \pi(\omega)=1 $ means that nothing prevents $ \omega $ from being true, whereas $ 0 < \pi(\omega) < 1 $ means that $ \omega $ is only somewhat possible to be the real world. Possibility degrees are interpreted qualitatively: when $ \pi(\omega) > \pi(\omega')$, $ \omega $ is considered more plausible than $ \omega' $. A possibilistic distribution $ \pi $ is \emph{normalized} if $ \exists \omega \in \Omega, \pi(\omega)=1$, i.e. at least one interpretation is entirely plausible. \vspace{.1cm} A possibility distribution $ \pi $ induces two uncertainty functions from the formulas $ \mathcal{NC} $ to $ [0,1] $, called possibility and necessity functions and noted $ \Pi $ and $ N $, respectively, which allow us to rank formulas. $ \Pi $ is defined by Dubois \emph{et al.} (1994) \cite{DuboisP94} as: $$ \Pi(\varphi)=\mathrm{max}\{\pi(\omega) \ \vert \ \omega \in \Omega, \omega \models \varphi\}, $$ \noindent and evaluates the extent to which $ \varphi $ is consistent with the beliefs expressed by $ \pi $. The dual \emph{necessity measure} $ N $ is defined by: $$ N (\varphi)= 1- \Pi(\neg \varphi)=\mathrm{inf}\{1-\pi(\omega) \ \vert \ \omega \in \Omega, \omega \nvDash \varphi \},$$ \noindent and evaluates the extent to which $ \varphi $ is entailed by the available beliefs \cite{DuboisP94}. So the lower the possibility of an interpretation that makes $ \varphi $ False, the higher the necessity degree of $ \varphi $. $ N(\varphi)=1 $ means $ \varphi $ is a totally certain piece of knowledge, whereas $ N(\varphi)=0 $ expresses the complete lack of knowledge of priority about $ \varphi $. Note that always $ N(\top)=1 $ for any possibility distribution, while $ \Pi(\top)=1 $ (and, related, $ N(\bot) $=0) only holds when the possibility distribution is normalized, i.e. only normalized distributions can express consistent beliefs \cite{DuboisP94}. \vspace{.1cm} A major property of $N$ is Min-Decomposability: $\forall \varphi, \psi, N(\varphi \wedge \psi)= \mathrm{min}(N(\varphi),N(\psi)) $. However, for disjunctions only $ N(\varphi \vee \psi) \geq \mathrm{max}(N(\varphi),N(\psi))$ holds. Further, one has $ N(\varphi) \leq N (\psi) $ if $ \varphi \models \psi $, and hence, $ N(\varphi)=N (\psi) $ if $ \varphi \equiv \psi $. \subsection{Syntactics} A possibilistic formula is a pair $ \langle \varphi :\alpha \rangle \in \mathcal{NC} \times (0,1]$, where $ \varphi $ is a propositional NC formula, $ \alpha \in (0,1]$ expresses the certainty that $ \varphi $ is the case, and it is interpreted as the semantic constraint $ N(p) \geq \alpha $. So formulas of the form $ \langle \varphi : 0 \rangle $ are excluded. A {\em possibilistic base} $ \Sigma $ is a collection of possibilistic formulas $\Sigma=\{ \langle\varphi_i : \alpha_i \rangle\, \vert \, i=1, \ldots, k \,\}$ and corresponds to a set of constraints on possibility distributions. The classical knowledge base associated with $ \Sigma $ is denoted as $ \Sigma^* $, i.e. $ \Sigma^*=\{\varphi \vert \langle \varphi : \alpha \rangle \in \Sigma\} $. $ \Sigma $ is consistent if and only if $ \Sigma^* $ is consistent. It is noticeable that, due to Min-Decomposability, {\em a possibilistic logic base can be easily put in clausal form.}\footnote{Nevertheless, as said previously, this translation can blow up exponentially the size of formulas and so can dramatically reduce the overall efficiency of the clausal reasoner.} \vspace{.1cm} Typically, there can be many possibility distributions that satisfy the set of constraints $ N(\varphi) \geq \alpha $ but we are usually only interested in the \emph{least specific possibility distribution}, i.e. the possibility distribution that makes minimal commitments, namely, the {\em greatest possibility distribution} w.r.t. the following ordering: $ \pi $ is a least specific possibility distribution compatible with $ \Sigma $ if for any $ \pi' $, $ \pi' \neq \pi $, compatible with $ \Sigma $, one has $ \forall \omega \in \Omega, \pi(\omega) \geq \pi'(\omega) $. Such a least specific possibility distribution always exists and is unique \cite{DuboisP94}. \vspace{.1cm} Thus, for a given $ \langle \varphi : \alpha \rangle $, possibilistic distributions should consider that an $ \omega $ that makes $ \varphi$ True is possible at the maximal level, say 1, while an $ \omega $ that makes $ \varphi $ False is possible at most at level $ 1 -\alpha $. Thus the semantic counterpart of a base $ \Sigma $, or the least specific distribution $ \pi_\Sigma $ is defined by, $\forall \omega, \omega \in \Omega $: % $$\pi_\Sigma(\omega)= \left\{ \begin{array}{l l} 1 & \ \mbox{if} \ \ \forall\langle\varphi_i,\alpha_i\rangle \in \Sigma, \omega \models \varphi_i\\ \mathrm{min}\{1- \alpha_i \,\vert \, \omega \nvDash \varphi_i, \, \langle\varphi_i, \alpha_i\rangle \in \Sigma\} & \ \mbox{otherwise}\\ \end{array} \right. $$ \begin{proposition} \label{propos:leastspecific} Let $ \Sigma $ be a possibilistic base. For any possibility distribution $ \pi $ on $ \Omega $, $ \pi $ satisfies $ \Sigma $ if and only if $ \pi \leq \pi_\Sigma $. \end{proposition} Proposition \ref{propos:leastspecific} says that $ \pi_\Sigma $ is the least specific possibility distribution satisfying $ \Sigma $ and it has been shown in reference \cite{DuboisP94}. \subsection{Syntactic Deduction} This subsection introduces some few notions about deduction in possibilistic logic and starts by the well-known possibilistic inference rules to be handled in this article: \begin{definition} \label{def:inderences} We define below three rules, where $ \ell \in \mathcal{L}; \varphi,\psi \in \mathcal{NC}$ and $\alpha, \beta \in (0,1] $. The first is possibilistic resolution \cite{DuboisP87,DuboisP90}; the second rule is Min-Decomposability; and the third rule, Max-Necessity, follows from the semantic constraint meaning of $ \langle \varphi : \alpha \rangle$. \begin{itemize} \item $\mbox{\underline{Resol}}: \quad \ \langle \, (\vee \ \, \ell \ \, \varphi) : \alpha \rangle, \langle \, (\vee \ \, \neg \ell \ \, \psi) : \beta \, \rangle \ \vdash \ \langle \ (\vee \ \, \varphi \ \psi) : \mbox{\bf min}\{\alpha, \beta\} \ \rangle$. \item $ \mbox{\underline{MinD}}: \quad \,\langle \varphi : \alpha \rangle, \ \langle \psi : \beta \rangle \ \vdash \ \langle \ \{\wedge \, \varphi \ \psi \} : \mbox{\bf min}\{\alpha, \beta\} \ \rangle$. \item $ \mbox{\underline{MaxN}}: \quad \langle \varphi : \alpha \rangle, \ \langle \varphi : \beta \rangle \ \vdash \ \langle \ \varphi : \mbox{\em \bf max}\{\alpha, \beta\} \ \rangle$. \end{itemize} \end{definition} Before formulating the soundness and completeness theorem in possibilistic logic, we need to introduce the next concept of $ \alpha $-cut; we call the $ \alpha $-cut (resp. strict $ \alpha $-cut) of $ \Sigma$, denoted $ \Sigma_{\geq \alpha}$ (resp. $ \Sigma_{> \alpha}$), the set of classical formulas in $ \Sigma$ having a necessity degree at least equal to $ \alpha $ (resp. strictly greater than $ \alpha $), namely $ \Sigma_{\geq \alpha} =\{ \varphi \,\vert \,\langle\varphi :\beta\rangle \in \Sigma, \beta \geq \alpha\}$ (resp. $ \Sigma_{> \alpha} =\{ \varphi \,\vert \,\langle\varphi :\beta \rangle \in \Sigma, \beta > \alpha\}$). \begin{theorem} \label{theo:soundn+complete} The following soundness and completeness theorem holds: $$ \Sigma \models_\pi \langle\varphi :\alpha \rangle \ \Leftrightarrow \ \Sigma \vdash_\mathrm{Res} \langle \varphi : \alpha \rangle \quad \Longleftrightarrow \quad \Sigma_{\geq \alpha} \models \varphi \ \Leftrightarrow \ \Sigma_{\geq \alpha} \vdash \varphi $$ \noindent where $\models_\pi$ means any $ \omega $ compatible with $ \Sigma$ is also compatible with $\langle\varphi :\alpha \rangle $, or formally, $ \forall \omega, \pi_\Sigma(\omega) \leq \pi_{\{\langle p : \alpha \rangle\}} (\omega) $. $ \vdash_\mathrm{Res} $ relies on the repeated use of possibilistic resolution. \end{theorem} The last half of the above expression reduces to the soundness and completeness theorem of propositional logic applied to each level cut of $ \Sigma $, which is an ordinary propositional base. \subsection{Partial Inconsistency} The inconsistency degree of a base $ \Sigma $ in terms of its $ \alpha $-cut can be equivalently defined as the largest weight $ \alpha $ such that the $ \alpha $-cut of $ \Sigma $ is inconsistent: $$\mathrm{Inc}(\Sigma)=\mathrm{max}\{\alpha \, \vert \, \Sigma_{\geq \alpha }\, \mathrm{is \ inconsistent}\}.$$ $ \mathrm{Inc}(\Sigma)=0 $ entails $ \Sigma^* $ is consistent. In \cite{DuboisP94}, the inconsistency degree of $ \Sigma $ is defined by the least possibility distribution $ \pi_\Sigma $, concretely $\mathrm{Inc}(\Sigma)=1-\mathrm{sup}_{\omega \in \Omega} \pi_\Sigma (\omega).$ \vspace{.1cm} To check whether $ \varphi$ follows from $ \Sigma $, one should add $ \langle\neg \varphi : 1 \rangle $ to $ \Sigma $ and then check whether $ \Sigma \cup \{\langle\neg \varphi : 1 \rangle\} \vdash \langle \bot : \alpha \rangle$. Equivalently the maximum $ \alpha $ s.t. $ \Sigma \models \langle \varphi : \alpha \rangle$ is given by the inconsistency degree of $ \Sigma \cup \{\langle\neg \varphi : 1 \rangle \}$, i.e. $ \Sigma \models \langle \varphi : \alpha \rangle$ iff $ \alpha=\mathrm{Inc}(\Sigma \cup \{\langle \neg \varphi, 1 \rangle\} ).$ \begin{proposition} \label{pro:iff-iff-iff} The next statements are proven in \cite{DuboisP94}: $$ \Sigma \models \langle \varphi : \alpha \rangle \ \ \mbox{\em iff} \ \ \Sigma \cup \{ \langle\neg \varphi : 1 \rangle \} \vdash \langle\bot : \alpha \rangle \ \ \mbox{\em iff} \ \ \alpha = \mathrm{Inc}(\Sigma \cup \{\langle\neg \varphi : 1\rangle \}) \ \ \mbox{\em iff} \ \ \Sigma_{\geq \alpha} \vdash \varphi. $$ \end{proposition} This result shows that any deduction problem in possibilistic logic can be viewed as computing an inconsistency degree. \subsection{Clausal and Non-Clausal Bases} According to previous definitions, to each class of propositional formulas corresponds a class of possibilistic bases. Below, we define the possibilistic classes handled here and after recall the complexity of computing the inconsistency degree of their members. \begin{definition} A possibilistic base $\Sigma=\{ \langle\varphi_i : \alpha_i \rangle\, \vert \, i=1, \ldots, k \,\}$ is called Horn, clausal or NC if all its formulas $ \varphi_i, 1 \leq i \leq 1 $, are Horn, clausal or NC, respectively. $\mathcal{H}_\Sigma$, $\mathcal{C}_\Sigma$ and $\mathcal{NC}_\Sigma$ denote, respectively, the classes of possibilistic Horn, clausal and NC bases. \end{definition} In this article we define in Definition \ref{def:HNCKnowledgeBase} a novel possibilistic class, i.e. the possibilistic Horn-NC class. Next we just define acronyms associated to the problems of computing the inconsistency degree of the four mentioned possibilistic classes. \begin{definition} \label{def:complexitiesofclassesofbases} Horn-INC, CL-INC, Horn-NC-INC and NC-INC denote respectively the problems of computing the inconsistency degree of Horn, clausal, Horn-NC and NC bases. \end{definition} \noindent {\bf Complexities.} Regarding the complexities of the previous problems, we have: \begin{enumerate} \item [$ \bullet $] Clausal Pbs.: CL-INC is Co-NP-complete \cite{Lang00} and Horn-INC is polynomial \cite{Lang00}. \vspace{-.1cm} \item [$ \bullet $] NC-INC is Co-NP-complete. This claim stems from: (i) Theorem \ref{theo:soundn+complete} applies to both clausal and NC bases; and (ii) checking whether an interpretation is a model of an NC propositional formula is polynomial as for clausal formulas. \vspace{-.1cm} \item [$ \bullet $] Horn-NC-INC has polynomial complexity as proven in Section \ref{sect:ProofsProperties}. \end{enumerate} \section{The Possibilistic Horn-NC Class: $\mathcal{\overline{H}}_\Sigma$} \label{sec:definClassHorn-NCChapeau} This section defines the class {\em $\mathcal{\overline{H}}_\Sigma$} of Possibilistic Horn Non-Clausal (Horn-NC) bases and states its properties and relationships with other possibilistic classes. % The proofs were given in \cite{Imaz2021horn} but are provided in an Appendix for the sake of the paper being self contained. \vspace{.15cm} {\em $\mathcal{\overline{H}}_\Sigma$} subsumes the next two classes: \begin{itemize} \vspace{-.15cm} \item possibilistic Horn, or $\mathcal{{H}}_\Sigma$; and \vspace{-.2cm} \item propositional Horn-NC, or $\mathcal{\overline{H}}$ (recently presented \cite{Imaz2021horn}). \end{itemize} \vspace{-.15cm} \noindent We first define the latter, i.e. the class $\mathcal{\overline{H}}$ of propositional Horn-NC formulas, which is the propositional component of the new possibilistic class $\mathcal{\overline{H}}_\Sigma$ to be introduced. \subsection{Simple Definition of $\mathcal{\overline{H}}$} Below, we define $\mathcal{\overline{H}}$ in a simple way, and in the next subsection, will give its detailed definition by taking a closer look to this simple definition. \noindent We start by defining the negative formulas, which generalize the negative literals in the clausal framework. \begin{definition} \label{def:negative} A non-clausal formula is negative if it has uniquely negative literals. We will denote $\mathcal{N }^-$ the set of negative formulas. \end{definition} \begin{example} Trivially negative literals are basic negative formulas. Another example of negative NC formula is $(\vee \ \ \{\wedge \ \, \neg P \ \, \neg R \, \} \ \ \{\wedge \ \, \neg S \ \,(\vee \ \, \neg P \ \, \neg Q \,)\,\}\,) \in \mathcal{N}^-$. \qed \end{example} Next we upgrade the Horn pattern ``a Horn clause has (any number of negative literals and) at most one positive literal" to the NC context in the next straightforward way: \begin{definition} \label{theorem:visual} An NC formula is Horn-NC if all its disjunctions have any number of negative disjuncts and at most one non-negative disjunct. We denote $\mathcal{\overline{H}}$ the class of Horn-NC formulas. \end{definition} Clearly the class $\mathcal{\overline{H}}$ subsumes the Horn class $ \mathcal{H}$. From Definition \ref{theorem:visual} it follows trivially that all sub-formulas of any Horn-NC are Horn-NC too. Yet, the converse does not hold: there are non-Horn-NC formulas whose all sub-formulas are Horn-NC. \begin{example} \label{exam:simple} One can see that $\varphi_1$ below has only one non-negative disjunct and so $\varphi_1$ is Horn-NC, while $\varphi_2$ is not Horn-NC as it has two non-negative disjuncts. \begin{itemize} \item $\varphi_1 = (\vee \ \ \{\wedge \ \ \neg Q \ \ \neg S \} \ \ \{\wedge \ \ R \ \ P \,\} \,).$ \item $\varphi_2 = (\vee \ \ \{\wedge \ \ \neg Q \ \ S \} \ \ \{\wedge \ \ R \ \ \neg P \,\} \,)$. \qed \end{itemize} \end{example} \begin{example} \label{Ex:morecomplex} We now consider both $\varphi$ in Example \ref{ex:constantsfree} (copied below) and $\varphi'$ below too, which results from $\varphi$ by just switching its literal $\neg P $ for $P $: \begin{itemize} \item $ \varphi=(\vee \ \ \neg P \ \ \{\wedge \ \ (\vee \ \ \neg P \ \ R ) \ \ \{\wedge \ \ Q \ \ (\vee \ \ P \ \ \neg S ) \, \} \, \} )$ \item $\varphi'= (\vee \ \ \ P \ \ \,\{\wedge \ \ (\vee \ \ \neg P \ \ R ) \ \ \{\wedge \ \ Q \ \ (\vee \ \ P \ \ \neg S ) \, \} \, \} )$ \end{itemize} \noindent All disjunctions of $\varphi$, i.e. $(\vee \ \, \neg P \ \, R )$, $(\vee \ P \ \neg S )$ and $\varphi$ itself (By Definition \ref{def:sub-for}, $\varphi$ is a sub-formula of $\varphi$), have exactly one non-negative disjunct; so $\varphi$ is Horn-NC. Yet, $\varphi' =(\vee \ P \ \phi)$, $\phi$ being non-negative, has two non-negative disjuncts; thus $\varphi'$ is not Horn-NC. \qed \end{example} \subsection{Detailed Definition of $\mathcal{\overline{H}}$} \noindent Before giving a fine-grained definition of $\mathcal{\overline{H}}$, we individually and inductively specify: \vspace{.2cm} $\bullet$ Horn-NC conjunctions, in Lemma \ref{def:HNCconjunc}, and \vspace{.08cm} $\bullet$ Horn-NC disjunctions, in Lemma \ref{def:disjunHNC}, \vspace{.2cm} \noindent and subsequently, we {\em compactly} specify $\mathcal{\overline{H}}$ by merging both specifications. \vspace{.15cm} Just as conjunctions of Horn clausal formulas are Horn too, likewise conjunctions of Horn-NC formulas are Horn-NC too, which is straightforwardly formalized next. \begin{lemma} \label{def:HNCconjunc} Conjunctions of Horn-NC formulas are Horn-NC as well, formally: $$\{\wedge \ \varphi_1 \,\ldots\, \varphi_{i} \ldots \,\varphi_k\} \in \mathcal{\overline{H}} \mbox{\em \ \ iff \ \ for } 1 \leq i \leq k, \ \varphi_i \in \mathcal{\overline{H}}.$$ \end{lemma} \begin{niceproof} It is obvious that if all sub-formulas $\varphi_{i}$ individually verify Definition \ref{theorem:visual} so does a conjunction thereof, and vice versa. \end{niceproof} \begin{example} \label{ex:Semant-Conjunt} If $H$ is Horn, $\phi_1$ is $ \varphi_1 $ from Example \ref{exam:simple} and $\phi_2$ is $ \varphi $ from Example \ref{Ex:morecomplex}, i.e. $\phi_1$ and $\phi_2$ are Horn-NC, then for instance $\varphi_1=\{\wedge \ H \ \phi_1 \ \phi_2 \}$ is Horn-NC. \qed \end{example} In order to give now a detailed definition of $ \mathcal{\overline{H}} $, we verify that Definition \ref{theorem:visual} can be equivalently reformulated in the next inductive manner: {\em ``an NC is Horn-NC if all its disjunctive sub-formulas have any number of negative disjuncts and one disjunct is Horn-NC".} This leads to the next formalization and statement. \begin{lemma} \label{def:disjunHNC} A NC disjunction $\varphi=(\vee \ \varphi_1 \ldots \varphi_i \ldots \varphi_k)$ with $k \geq 1$ disjuncts pertains to $ \mathcal{\overline{H}} $ iff $ \varphi $ has $k-1$ negative disjuncts and one Horn-NC disjunct, formally $$\varphi=(\vee \ \varphi_1 \ldots \varphi_i \ldots \varphi_k) \in \mathcal{\overline{H}} \mbox{\em \ \ iff} \quad \exists i \ \mbox{\em s.t.} \ \varphi_i \in \mathcal{\overline{H}} \ \ \mbox{\em and} \ \ \forall j \neq i, \varphi_j \in \mathcal{N}^-.$$ \end{lemma} \begin{niceproof} See Appendix. \end{niceproof} \noindent The next claims follow trivially from Lemma \ref{def:disjunHNC}: \vspace{.2cm} $\bullet$ Horn clauses are non-recursive Horn-NC disjunctions. \vspace{.1cm} $\bullet$ NC disjunctions with all negative disjuncts are Horn-NC. \vspace{.1cm} $\bullet$ NC disjunctions with $ k \geq 2$ non-negative disjuncts are not Horn-NC. \vspace{.2cm} \noindent Next, we first reexamine, bearing Lemma \ref{def:disjunHNC} in mind, the formulas from Example \ref{exam:simple}, included in Example \ref{exam:NF}, and then those from Example \ref{Ex:morecomplex}, included in Example \ref{ex:disjunHNC}. \begin{example} \label{exam:NF} Below we analyze $\varphi_1$ and $\varphi_2$ from Example \ref{exam:simple}. \begin{itemize} \item $\varphi_1 = (\vee \ \ \{\wedge \ \ \neg Q \ \ \neg S \} \ \ \{\wedge \ \ R \ \ P \,\} \,).$ -- Clearly $\{\wedge \ \ \neg Q \ \ \neg S \} \in \mathcal{N}^-$. -- By Lemma \ref{def:HNCconjunc}, $\{\wedge \ \ R \ \ P \,\} \in \mathcal{\overline{H}}$. -- By Lemma \ref{def:disjunHNC}, $\varphi_1 \in \mathcal{\overline{H}}$. \item $\varphi_2 = (\vee \ \ \{\wedge \ \ \neg Q \ \ S \} \ \ \{\wedge \ \ R \ \ \neg P \,\} \,)$. -- Obviously $\{\wedge \ \ \neg Q \ \ S \} \notin \mathcal{N}^-$ and \ $\{\wedge \ \ R \ \ \neg P \,\} \notin \mathcal{N}^-$. -- According to Lemma \ref{def:disjunHNC}, $\varphi_2 \notin \mathcal{\overline{H}}$. \qed \end{itemize} \end{example} \begin{example} \label{ex:disjunHNC} Consider again $\varphi$ and $\varphi'$ from Example \ref{Ex:morecomplex} and recall that $\varphi'$ results from $\varphi$ by just switching its literal $\neg P $ for $P $. Below we check one-by-one whether or not the sub-formulas of both $\varphi$ and $\varphi'$ are in $\mathcal{\overline{H}}$. \begin{itemize} \item By Lemma \ref{def:disjunHNC}, $(\vee \ \ \neg P \ \ R ) \in \mathcal{\overline{H}}$. \item By Lemma \ref{def:disjunHNC}, $(\vee \ \ P \ \ \neg S ) \in \mathcal{\overline{H}}$. \item By Lemma \ref{def:HNCconjunc}, $\{\wedge \ \ Q \ \ (\vee \ \ P \ \ \neg S ) \, \}\in \mathcal{\overline{H}}$. \item By Lemma \ref{def:HNCconjunc}, $\phi=\{\wedge \ \ (\vee \ \ \neg P \ \ R ) \ \ \{\wedge \ \ Q \ \ (\vee \ \ P \ \ \neg S) \, \} \, \} \in \mathcal{\overline{H}}$. \item Using previous formula $\phi$, we have $\varphi= (\vee \ \neg P \ \,\phi \,)$. \hspace{.5cm} -- Since $\neg P \in \mathcal{N}^-$ and $\phi \in \mathcal{\overline{H}}$, by Lemma \ref{def:disjunHNC}, $\varphi \in \mathcal{\overline{H}}$. \item The second formula in Example \ref{Ex:morecomplex} is $\varphi'=(\vee \ P \ \phi \,)$. \hspace{.5cm} -- Since $P ,\,\phi \notin \mathcal{N}^-$, by Lemma \ref{def:disjunHNC}, $\varphi' \notin \mathcal{\overline{H}}$. \qed \end{itemize} \end{example} \noindent By using Lemmas \ref{def:HNCconjunc} and \ref{def:disjunHNC}, the class $\mathcal{\overline{H}}$ is syntactically, compactly and inductively defined as follows. \begin{definition} \label{def:syntacticalNC} We define the set $\mathcal{\widehat{H}}$ over the set of propositional variables $ \mathcal{P} $ as the smallest set such that the conditions below hold, where $k \geq 1$ and $\mathcal{L}$ is the set of literals. \begin{itemize} \item [(1)] \ $\mathcal{L} \subset \mathcal{\widehat{H}}.$ \hspace{10.05cm} \item [(2)] \ If \ $\forall i, \,\varphi_i \in \mathcal{\widehat{H}} \ \ \mbox{then} \ \ \{\wedge \ \varphi_1 \,\ldots\, \varphi_{i} \ldots \varphi_k\} \in \mathcal{\widehat{H}}.$ \hspace{3.27cm} \item [(3)] \ If \ $\varphi_i \in \mathcal{\widehat{H}}$ \ and \ $\forall j \neq i$, $\varphi_j \in \mathcal{N}^- \ \ \mbox{then} \ \ (\vee \ \varphi_1 \ldots \varphi_i \ldots \,\varphi_k) \in \mathcal{\widehat{H}}.$ \hspace{.24cm} \end{itemize} \end{definition} \begin{theorem} \label{th:HNCequality} We have that \ $\mathcal{\widehat{H}}=\mathcal{\overline{H}}$. \end{theorem} \begin{niceproof} See Appendix. \end{niceproof} Theorem \ref{th:HNCequality} below states that $\mathcal{\widehat{H}}$ and $\mathcal{\overline{H}}$ indeed coincide, namely Definition \ref{def:syntacticalNC} is the recursive and compact definition of the class $\mathcal{\overline{H}}$ of Horn-NC formulas. Besides, inspired by Definition \ref{def:syntacticalNC}, in \cite{Imaz2021horn} a linear algorithm is designed that recognizes whether a given NC $ \varphi $ is Horn-NC and, such property is inherited by the possibilistic Horn-NC formulas. \begin{example} \label{ex:ExamComplet} Viewed from Definition \ref{def:syntacticalNC}, we analyze $\varphi$ and $\varphi'$ from Example \ref{ex:disjunHNC}: \begin{itemize} \item By ({3}), $(\vee \ \ \neg P \ \ R ) \in \mathcal{\overline{H}}$. \item By ({3}), $(\vee \ \ P \ \ \neg S ) \in \mathcal{\overline{H}}$. \item By ({2}), $\{\wedge \ \ Q \ \ (\vee \ P \ \ \neg S ) \, \} \in \mathcal{\overline{H}}$. \item By ({2}), $\phi=\{\wedge \ \ (\vee \ \ \neg P \ \ R ) \ \ \{\wedge \ \ Q \ \ (\vee \ \ P \ \ \neg S ) \, \} \, \} \in \mathcal{\overline{H}}$. \item By ({3}), $\varphi= (\vee \ \ \neg P \ \ \phi \,) \in \mathcal{\overline{H}}$ \item By ({3}), $\varphi'=(\vee \ \ P \ \ \phi \,) \notin \mathcal{\overline{H}}$. \qed \end{itemize} \end{example} \begin{example} \label{ex:nested} If we assume that $\varphi_1$, $\varphi_2$ and $\varphi_3$ are negative and $\varphi_4$ and $\varphi_5$ are Horn-NC, then according to Definition \ref{def:syntacticalNC}, four examples of Horn-NC formulas follow. \begin{itemize} \item By ({3}), \ $\varphi_6=(\vee \ \ \varphi_1 \ \ \varphi_4 ) \in \mathcal{\overline{H}}$. \item By ({2}), \ $\varphi_7=\{\wedge \ \ \varphi_1 \ \ \varphi_5 \ \ \varphi_6 \} \in \mathcal{\overline{H}}$. \item By ({3}), \ $\varphi_8=(\vee \ \ \varphi_1 \ \ \varphi_2 \ \ \varphi_7) \in \mathcal{\overline{H}}$. \item By ({2}), \ $\varphi_9=\{\wedge \ \ \varphi_6 \ \ \varphi_7 \ \ \varphi_8 \} \in \mathcal{\overline{H}}$. \qed \end{itemize} \end{example} \noindent Next, we analyze a more complete example, concretely $\varphi $ from the Introduction. \begin{example} \label{ex:introduction} Let us take $ \varphi $ below, wherein $ \phi_1, \phi_2$ and $\phi_3$ are NC formulas: \vspace{.25cm} $\varphi=\{\wedge \ \, P \ \, (\vee \ \ \neg Q \ \ \{\wedge \ \ (\vee \ \ \neg P \ \ \neg Q \ \ R \,) \ \ (\vee \ \ \phi_1 \ \ \{\wedge \ \ \phi_2 \ \ \neg P \,\} \, ) \ \, Q \,\} \,) \ \ {\phi_3} \ \}.$ \vspace{.25cm} \noindent The disjunctions of $ \varphi $ and the proper $ \varphi $ can be rewritten as follows: \begin{itemize} \item $\psi_1= (\vee \ \ \neg P \ \ \neg Q \ \ R \,) $. \item $\psi_2= (\vee \ \ \phi_1 \ \ \{\wedge \ \ \phi_2 \ \ \neg P \} \, ) $. \item $\psi_3=(\vee \ \ \neg Q \ \ \{\wedge \ \ \psi_1 \ \ \psi_2 \ \, Q \,\} \,) .$ \item $ \varphi = \{\wedge \ \ P \ \ \psi_3 \ \ \phi_3 \,\}.$ \end{itemize} \noindent We analyze one-by-one such disjunctions and finally the proper $ \varphi $: \begin{itemize} \item $ \psi_1$: \ Trivially, $ \psi_1 $ is Horn, so $ \psi_1 \in \mathcal{\overline{H}}$. \item $ \psi_2 $: \ $ \psi_2 \in \mathcal{\overline{H}}$ \ if \ $ \phi_1, \phi_2 \in \mathcal{\overline{H}} $ \ and if at least one of $ \phi_1$ or $ \phi_2$ is negative. \item $ \psi_3 $: \ $ \psi_3 \in \mathcal{\overline{H}}$ \ if \ $\psi_2 \in \mathcal{\overline{H}}$ (as $ \psi_1 \in \mathcal{\overline{H}}$). \item \ $ \varphi $: \ $ \varphi \in \mathcal{\overline{H}}$ \ if \ $ \psi_2, \phi_3 \in \mathcal{\overline{H}}$ (as $ \psi_3 \in \mathcal{\overline{H}}$ \ if \ $\psi_2 \in \mathcal{\overline{H}}$). \end{itemize} \noindent Summarizing the conditions on $ \varphi $ and on $ \psi_2 $, we have that: \vspace{.2cm} \noindent \ $\bullet$ $ \varphi $ is Horn-NC \underline{if} $\phi_3$, $\phi_1$ and $ \phi_2$ are Horn-NC \underline{and if at least one of} $ \phi_1 $ or $ \phi_2 $ is negative. \vspace{.2cm} \noindent If we consider that $ \varphi $ implicitly verifies Definition \ref{theorem:visual} (all sub-formulas of a Horn-NC are Horn-NC), then we conclude that $ \varphi $ is Horn-NC if at least one of $ \phi_1 $ or $ \phi_2 $ is negative. \qed \end{example} \subsection{Properties of the Class $ \mathcal{\overline{H}} $ } An important feature of Horn-formulas is the following: \begin{theorem} \label{the:HNCtoHorn} Applying $ \vee/\wedge $-distributivity to a Horn-NC $ \varphi $ results in a Horn formula. \end{theorem} \begin{niceproof} See Appendix. \end{niceproof} We already saw that syntactically $ \mathcal{\overline{H}} $ subsumes $\mathcal{{H}} $, but besides, $ \mathcal{\overline{H}} $ is semantically related to $ \mathcal{{H}} $ as Theorem \ref{theo:relation-Horn-Horn} claims. \begin{theorem} \label{theo:relation-Horn-Horn} $ \mathcal{\overline{H}} $ and $\mathcal{{H}} $ are semantically equivalent: each formula in a class is logically equivalent to some formula in the other class. \end{theorem} \begin{niceproof} By Theorem \ref{the:HNCtoHorn}, for every $ \varphi \in \mathcal{\overline{H}}$ there exists $ H \in \mathcal{H} $ such that $ \varphi \equiv H $. The converse follows from the fact that $ \mathcal{H} \subset \mathcal{\overline{H}}$. \end{niceproof} The next theorem make it explicit how the classes Horn-NC and NC are related. \begin{theorem} \label{theo:relation-NC-H} $ \mathcal{\overline{H}} $ contains the next NC fragment: if applying $ \wedge /\vee $ distributivity to an NC formula $ \varphi $ results in a Horn formula, then $ \varphi $ is in $ \mathcal{\overline{H}} $. \end{theorem} \begin{niceproof} See Appendix. \end{niceproof} The syntactical and semantical properties exhibited by $ \mathcal{\overline{H}} $ affirmed by the last three theorems suggest that $ \mathcal{\overline{H}} $ is a kind of NC analogous of the standard Horn class $ \mathcal{{H}} $. \subsection{The Definition of $\mathcal{\overline{H}}_\Sigma$} \vspace{.1cm} Finally, from $ \mathcal{\overline{H}} $, we straightforwardly define the class $\mathcal{\overline{H}}_\Sigma $ of possibilistic Horn-NC bases. \begin{definition} \label{def:HNCKnowledgeBase} A possibilistic Horn-NC formula is a pair $ \langle\varphi : \alpha \rangle$, where $ \varphi \in \mathcal{\overline{H}} $ and $ \alpha \in (0 \ 1] $. A possibilistic Horn-NC base $ \Sigma $ is a set of possibilistic Horn-NC formulas. $ \mathcal{\overline{H}}_\Sigma $ denotes the class of possibilistic Horn-NC bases. \end{definition} \begin{example} We take the next Horn-NCs: $ \varphi $ from Example \ref{Ex:morecomplex} and $ \varphi_9 $ from Example \ref{ex:nested}. By $ \varphi' $ we denote $ \varphi $ from Example \ref{ex:introduction} considering that the specified conditions warranting that $ \varphi $ is Horn-NC are met. An example of a possibilistic Horn-NC base is: $$\{\,\langle P \, : \, {\bf .8}\rangle, \ \langle \varphi \, : \, {\bf .8} \rangle, \ \langle \varphi_9 \, , \, {\bf .5} \rangle, \ \langle \varphi' \, , \, {\bf .9} \rangle, \ \langle \neg Q \, , \, {\bf .1} \rangle \, \}. $$ \end{example} \begin{corollary} $ \mathcal{\overline{H}}_\Sigma $ and $\mathcal{{H}}_\Sigma$ are semantically equivalent: each formula in a class is equivalent to some formula in the other class. \end{corollary} \begin{niceproof} It follows from the definitions of $ \mathcal{\overline{H}}_\Sigma $ and $\mathcal{{H}}_\Sigma$ and Theorem \ref{theo:relation-Horn-Horn}. \end{niceproof} \begin{corollary} $ \mathcal{\overline{H}}_\Sigma $ is the next $ \mathcal{NC}_\Sigma $ fragment: if $ \langle \varphi : \alpha \rangle \in \mathcal{NC}_\Sigma$ and applying $ \wedge /\vee $ distributivity to $ \varphi $ results in a Horn formula, then $ \langle \varphi : \alpha \rangle \in \mathcal{\overline{H}}_\Sigma$. \end{corollary} \begin{proof} It follows from the definitions of $ \mathcal{\overline{H}}_\Sigma $ and $ \mathcal{NC}_\Sigma $ and Theorem \ref{theo:relation-NC-H}. \end{proof} \noindent {\bf Remark.} Since $ \mathcal{\overline{H}} $ is the NC analogous of $ \mathcal{{H}} $ so is $ \mathcal{\overline{H}}_\Sigma $ of $ \mathcal{{H}}_\Sigma $. \section{Possibilistic NC Unit-Resolution {\em $\mathcal{UR}_\Sigma$}} \label{sec:Non-Clausal-Unit-resolution} Possibilistic clausal resolution was defined in the 1980s \cite{DuboisP87,DuboisP90} but possibilistic non-clausal resolution has not been proposed yet. This section is a step forward towards its definition as we define Possibilistic Non-Clausal Unit-Resolution, denoted $\mathcal{UR}_\Sigma$, which is an extension of the calculus presented in \cite{Imaz2021horn} for propositional logic. The main inference rule of {\em $\mathcal{UR}_\Sigma$} is called {\em UR$_{\Sigma}$}, and while the other rules in $\mathcal{UR}_\Sigma$ are simple, {\em UR$_\Sigma$} is somewhat involved and so is presented progressively as follows: \vspace{.15cm} $\bullet$ for quasi-clausal Horn-NC bases in Subsection \ref{subsec:Quasi-ClausalHNCs}; and \vspace{.1cm} $\bullet$ for nested Horn-NC bases in Subsection \ref{subsec:GeneralHNCs}. \vspace{.15cm} Afterwards, \underline{Subsection \ref{subsec:TheCalculus}} describes $\mathcal{UR}_\Sigma$, which besides {\em UR$_{\Sigma}$}, comprises: (a) the propositional rule {\em UR$_P$}, which is {\em UR$_{\Sigma}$} adapted to propositional logic, (b) the propositional simplification rules, and (c) the possibilistic rules {\em MinD} and {\em MaxN}. \underline{Subsection \ref{subsect:find}} gives the algorithm to obtain $ \mbox{Inc}(\Sigma) $ which combines {\em $\mathcal{UR}_{\Sigma}$} with $ \alpha $-cuts of the input $ \Sigma $. To end this section, \underline{Subsection \ref{subsub:2inferencerules}} gives two further inferences rules, not needed for warranting the completeness of $\mathcal{UR}_\Sigma$. We recall that $ \bot $ and $ (\vee) $ are equivalent (see Definition \ref{def:interpretation}). \subsection{ Quasi-Clausal NC Unit-Resolution} \label{subsec:Quasi-ClausalHNCs} \vspace{.05cm} We start our presentation with propositional formulas and then switch to possibilistic bases. Assume propositional formulas with the quasi-clausal pattern below in which $ {\textcolor{red} {\ell}} $ and $ {\textcolor{blue} {\neg {\ell}}} $ are any literal and its negated one, and the $ \varphi $'s and the $ \phi $'s are formulas: $$\{{\textcolor{red} {\wedge}} \ \varphi_1 \, \ldots \, \varphi_{l-1} \ {\textcolor{red} {\ell}} \ \varphi_{l+1} \, \ldots \, \varphi_{i-1} \ ({\textcolor{blue} {\vee}} \ \, \phi_1 \, \ldots \, \phi_{j-1} \ {\textcolor{blue} {\neg {\ell}}} \ \phi_{j+1} \, \ldots \, \phi_k) \ \varphi_{i+1} \, \ldots \, \varphi_n \}$$ \noindent We say that these formulas are quasi-clausal because if the $\varphi$'s and $\phi$'s were clauses and literals, respectively, then such formulas would be clausal. It is not hard to see that a quasi-clausal formula is equivalent to a formula of the kind: $$\{{\textcolor{red} {\wedge}} \ \varphi_1 \, \ldots \, \varphi_{l-1} \ {\textcolor{red} {\ell}} \ \varphi_{l+1} \, \ldots \, \varphi_{i-1} \ ({\textcolor{blue} {\vee}} \ \phi_1 \, \ldots \, \phi_j \, \phi_{j+1} \, \ldots \, \phi_k) \ \varphi_{i+1} \, \ldots \, \varphi_n \}$$ \noindent and thus, one can derive the next simple inference rule for propositional formulas: \begin{equation} \label{eq:simpleinf} \frac{{\textcolor{red} {\ell}} \ {\textcolor{red} {\wedge}} \ ({\textcolor{blue} {\vee}} \ \ \phi_1 \, \ldots \, \phi_j \ {\textcolor{blue} {\neg {\ell}}} \ \phi_{j+1} \, \ldots \, \phi_k) } {({\textcolor{blue} {\vee}} \ \ \phi_1 \, \ldots \, \phi_j \ \phi_{j+1} \, \ldots \, \phi_k) } \end{equation} Notice that for clausal formulas, {\em Rule (\ref{eq:simpleinf}) coincides with clausal unit-resolution.} \vspace{.15cm} Now let us switch to possibilistic bases. The setting in which NC unit-resolution is applicable is when $ \Sigma $ has two Horn-NC formulas such that one is a unit clause $\langle {\textcolor{red} {\ell}} : \alpha\rangle$ and the other has the pattern: $\langle \, \{\wedge \ \varphi_{1} \, \ldots \, \varphi_i \ ({\textcolor{blue} {\vee}} \ \, \phi_1 \, \ldots \, \phi_{j-1} \ {\textcolor{blue} {\neg {\ell}}} \ \phi_{j+1} \, \ldots \, \phi_k) \ \varphi_{i+1} \, \ldots \, \varphi_n \} : \beta \, \rangle$. Namely, as $ \Sigma $ is an implicit conjunction of its formulas, then $ \Sigma $ contains a conjunction: \begin{equation}\label{eq:quasi-clausal-possi-unit} \langle {\textcolor{red} {\ell}} : \alpha\rangle \wedge \langle \, \{\wedge \ \varphi_{1} \, \ldots \, \varphi_{i-1} \ ({\textcolor{blue} {\vee}} \ \, \phi_1 \, \ldots \, \phi_{j-1} \ {\textcolor{blue} {\neg {\ell}}} \ \phi_{j+1} \, \ldots \, \phi_k) \ \varphi_{i+1} \, \ldots \, \varphi_n \} : \beta \, \rangle \end{equation} In this setting and by using Min-Decomposability, i.e. $ N(\varphi \wedge \psi) = \mathrm{min}(N(\varphi), N(\psi)) $ (Definition \ref{def:inderences}), one can easily derive the next possibilistic inference: \begin{equation} \label{eq:firstposs} \frac{ \langle {\textcolor{red} {\ell}} \, : \, \alpha\rangle \ {\textcolor{red} {\wedge}} \ \langle\,({\textcolor{blue} {\vee}} \ \ \phi_1 \, \ldots \, \phi_j \ {\textcolor{blue} {\neg {\ell}}} \ \phi_{j+1} \, \ldots \, \phi_k)\, : \,\beta\rangle } {\langle\,({\textcolor{blue} {\vee}} \ \ \phi_1 \, \ldots \, \phi_j \ \phi_{j+1} \, \ldots \, \phi_k) \, : \, \mathrm{\bf min}\{\alpha, \beta\} \,\rangle } \end{equation} The soundness of (\ref{eq:firstposs}) follows immediately from the property Min-Decomposability. If $\mathcal{D}({\textcolor{blue} {\neg {\ell}}})$ stands for $(\vee \ \phi_1 \, \ldots \, \phi_j \, \phi_{j+1} \, \ldots \, \phi_n)$, then the previous rule can be concisely rewritten as: \begin{equation} \label{eq:without-conjun} \frac{ \langle{\textcolor{red} {\ell}} \, : \, \alpha\rangle \ \, {\textcolor{red}\wedge} \ \, \langle \,({\textcolor{blue} {\vee}} \ \, {\textcolor{blue} {\neg {\ell}}} \ \, \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,)\, : \beta \rangle } { \langle\mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \, : \, \mathrm{\bf min}\{\alpha,\beta\} \,\rangle}{{\mbox{\,}}} \end{equation} Notice that the previous rule amounts to substituting the formula referred to by the right conjunct in the numerator with the formula in the denominator, and in practice, to just eliminate $ {\textcolor{blue} {\neg {\ell}}} $ and update the necessity weight. Let us illustrate these notions. \begin{example} \label{ex:withoutconj} Let $ \Sigma $ be a base including $ \varphi_1 $ and $ \varphi_2 $ below, where $ \phi $ is a formula: \begin{itemize} \item $ \varphi_1=\langle {\textcolor{red} P} : {\bf .8} \rangle$ \ \quad \item $\varphi_2= \langle \, \{{\textcolor{red} {\wedge}} \ \phi \ (\vee \ \ \neg {R} \ \ {\textcolor{blue} {\neg {P}}} \ \ S \,) \ \ (\vee \ \ S \ \ \{\wedge \ \ \neg {Q} \ \ \neg {P} \,\} \, ) \ \ R \,\} \, : \, {\bf .6} \rangle.$ \end{itemize} Taking $ {\textcolor{red} P} $ in $ \varphi_1 $ and the left-most ${\textcolor{blue} {\neg {P}}}$ in $\varphi_2$, we have $\mathcal{D}({\textcolor{blue} {\neg {P}}})=(\vee \ \neg {R} \ S )$, and by applying $$\Sigma \leftarrow \Sigma \, \cup \, \langle\, \{{\textcolor{black} {\wedge}} \ \, \phi \ \, (\vee \ \ \neg {R} \ \ S \,) \ \ (\vee \ \ S \ \ \{\wedge \ \ \neg {Q} \ \ \neg {P} \,\} \, ) \ \ R \,\} \, : \, {\bf .6} \, \rangle.$$ Rule (\ref{eq:without-conjun}) to $ \varphi_2 $, the above formula is deduced and added to the base $ \Sigma $. \qed \end{example} We now extend our analysis from formulas with pattern $\langle \, ({\textcolor{blue} {\vee}} \ \, {\textcolor{blue} {\neg {\ell}}} \ \, \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,) : \beta \rangle$ to formulas with pattern $\langle \, ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}})\ \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}})\, ) : \beta \, \rangle$ wherein $\mathcal{C}({\textcolor{blue} {\neg {\ell}}})$ is the maximal sub-formula that becomes false when $ {\textcolor{blue} {\neg {\ell}}} $ is false, namely, $\mathcal{C}({\textcolor{blue} {\neg {\ell}}})$ is: $(i)$ the maximal sub-formula, and $(ii)$ equivalent to a conjunction of the kind ${\textcolor{blue} {\neg {\ell}}} \,\wedge \, \psi $. In other words, $\mathcal{C}({\textcolor{blue} {\neg {\ell}}})$ is the maximal sub-formula "conjunctively linked" to ${\textcolor{blue} {\neg {\ell}}}$. \vspace{.15cm} \noindent For instance If the input base $ \Sigma $ contains $\langle {\textcolor{red} {{\ell}}} : \alpha \rangle$ and another formula of the kind: $$ \langle \ (\vee \ \varphi_1 \quad \{\wedge \ \phi_ 1 \ \{\wedge \ {\textcolor{blue} {\neg {\ell}}} \ (\vee \ \ \phi_2 \ \neg {P} \,)\} \ \phi_3\} \quad \varphi_2 ): \beta \ \rangle$$ \vspace{.1cm} \noindent then $\mathcal{C}({\textcolor{blue} {\neg \mathcal{\ell}}})=\{\wedge \ \phi_ 1 \ \{\wedge \ {\textcolor{blue} {\neg {\ell}}} \ (\vee \ \ \phi_2 \ \neg {P} \,)\} \ \phi_3\,\}$ because: \vspace{.15cm} $(ii)$ \quad \ $\mathcal{C}({\textcolor{blue} {\neg \mathcal{\ell}}})$ is equivalent to ${\textcolor{blue} {\neg {\ell}}} \wedge \psi= {\textcolor{blue} {\neg {\ell}}} \wedge \{\wedge \ \phi_ 1 \ (\vee \ \phi_2 \ \neg {P} \,) \ \phi_3\}$; and \ $(i)$ \quad \, no sub-formula $\mathcal{C}'({\textcolor{blue} {\neg \mathcal{\ell}}}) $ bigger than $\mathcal{C}({\textcolor{blue} {\neg \mathcal{\ell}}})$ verifies $\mathcal{C}'({\textcolor{blue} {\neg \mathcal{\ell}}})\equiv {\textcolor{blue} {\neg {\ell}}} \wedge \psi'$. \vspace{.15cm} \noindent Clearly, if $ {\textcolor{blue} {\neg {\ell}}} $ becomes false so does $\mathcal{C}({\textcolor{blue} {\neg \mathcal{\ell}}})=\{\wedge \ \phi_ 1 \ \{\wedge \ {\textcolor{blue} {\neg {\ell}}} \ (\vee \ \ \phi_2 \ \neg {P} \,)\} \ \phi_3\,\}$. \vspace{.1cm} \noindent {\bf Remark. } $\mathcal{C}({\textcolor{blue} {\neg {\ell}}})$ contains ${\textcolor{blue} {\neg {\ell}}}$ but $\mathcal{D}({\textcolor{blue} {\neg {\ell}}})$ excludes it. \begin{example}\label{ex:with-conjuction} The formula given below is an extension of $\varphi_2 $ from Example \ref{ex:withoutconj}, in which, by clarity, its previous sub-formula $ (\vee \ S \ \{\wedge \ \neg {Q} \ \neg {P} \,\} \, ) $ is denoted $ \phi_1 $ and the previous literal $ {\textcolor{blue} {\neg {P}}} $ is now extended to the formula $ \{\wedge \ {\textcolor{blue} {\neg {P}}} \ (\vee \ S \ \neg {R} ) \, \} $ including $ {\textcolor{blue} {\neg {P}}} $: $$ \varphi = \langle\, \{{\textcolor{red} {\wedge}} \ \phi \ (\vee \ \neg {R} \ \{\wedge \ {\textcolor{blue} {\neg {P}}} \ (\vee \ S \ \neg {R} ) \, \} \ \ S \,) \ \ \phi_1 \ \ R \,\} \, : \, {\bf .6} \,\rangle$$ Taking the left-most ${\textcolor{blue} {\neg {P}}}$ ($ \phi_1 $ has also another literal ${\neg {P}}$), $\varphi$ has a sub-formula with pattern $ ({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg {P}}}) \ \mathcal{D}({\textcolor{blue} {\neg {P}}})\, )$, in which $\mathcal{C}({\textcolor{blue} {\neg {P}}})=\{\wedge \ {\textcolor{blue} {\neg {P}}} \ \ (\vee \ S \ \neg {R} ) \, \}$ and $\mathcal{D}({\textcolor{blue} {\neg {P}}})= (\vee \ \, \neg {R} \ S).$ \qed \end{example} Regarding the inference rule, we have that when $ \Sigma $ has both a unitary clause $ \langle{\textcolor{red} \ell} \, : \, \alpha \rangle $ and another formula $\langle \varphi : \beta \rangle $ such that $ \varphi $ has the pattern $ ({\textcolor{blue} {\vee}} \ \, \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \, \mathcal{D}({\textcolor{blue}{\neg {\ell}}}) \,) $, then the \underline{possibilistic} NC unit-resolution rule is easily obtained by extending Rule (\ref{eq:without-conjun}) as follows: \begin{equation} \label{eq:with-conjunct} \frac{ \langle {\textcolor{red} {\ell}} \, : \, \alpha \rangle \ \, {\textcolor{red}\wedge} \ \, \langle\,({\textcolor{blue} {\vee}} \ \, \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \, \mathcal{D} ({\textcolor{blue} {\neg {\ell}}}) \,)\, : \beta \,\rangle } { \langle \, \mathcal{D}({\textcolor{blue} {\neg {\ell}}} \, ) \, : \, \mathrm{\bf min}(\alpha,\beta ) \,\rangle}{{\mbox{\,}}} \end{equation} The soundness of (\ref{eq:with-conjunct}) follows from ${\textcolor{red} {\ell}} \wedge \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \equiv \bot$ and its proof is given in Section \ref{sect:ProofsProperties}. {\bf Fig. 3} depicts Rule (\ref{eq:with-conjunct}) where the left and right trees represent, respectively, the numerator and denominator of (\ref{eq:with-conjunct}). \begin{center} \begin{adjustbox}{valign=t} \begin{tikzpicture} [every node/.append style = {text=black}, sibling distance=1.5cm ] \node {{\textcolor{red}{$\wedge$}}} child[line width=.2mm] {node {$\langle{\textcolor{red} \ell} : \alpha \rangle \ \ $}} child[line width=.2mm] {node {$\langle {\textcolor{blue}{\vee}} : \beta \rangle$} child[line width=.2mm] {node {$\mathcal{C}({\textcolor{blue}{\neg {\ell}}})$}} child[line width=.2mm] {node {$\mathcal{D}({\textcolor{blue}{\neg {\ell}}})$}} } ; \end{tikzpicture} \end{adjustbox} \begin{adjustbox}{valign=t} \hspace{1.5cm} \begin{tikzpicture} [every node/.append style = {text=black}, sibling distance=1.8cm ] \node {{\textcolor{red}{$\wedge$}}} child[line width=.2mm] {node {$\langle{\textcolor{red} \ell} : \alpha \rangle \ \ $}} child[line width=.2mm] {node {$\ \ \langle{\textcolor{blue}{\vee}} : \mathrm{\bf min}(\alpha,\beta)\rangle$} child[line width=.2mm] {node {$\mathcal{D}({\textcolor{blue}{\neg {\ell}}})$}} } ; \end{tikzpicture} \end{adjustbox} \vspace{.2cm} {\small {\bf Fig. 3.} Depicting Rule (\ref{eq:with-conjunct}}). \end{center} \begin{example} Rule (\ref{eq:with-conjunct}) with $ \varphi_1=\langle {\textcolor{red} P} : {\bf .3} \rangle$ and with $ \varphi $ from Example \ref{ex:with-conjuction} derives: $$\Sigma \leftarrow \Sigma \, \cup \, \langle\,\{{\textcolor{black} {\wedge}} \ \, \phi \ \, (\vee \ \, \neg {R} \ S \,) \ \ \phi_1 \ \ R \,\} \, : \, {\bf .3} \,\rangle.$$ \vspace{-.6cm} \end{example} \subsection{Nested NC Unit-Resolution} \label{subsec:GeneralHNCs} Coming back to the almost-clausal formulas expressed in (\ref{eq:quasi-clausal-possi-unit}) and extending its literal $ {\textcolor{blue} {\neg {\ell}}} $ to $ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) $, we now rewrite them compactly as indicated below, where $ \Pi $ and $ \Pi' $ denote a concatenation of formulas, namely $ \Pi=\varphi_1 \ldots \varphi_{i-1}$ and $ \Pi'=\varphi_{i+1} \ldots \varphi_n $: $$\langle{\textcolor{red} {\ell}} \, : \, \alpha\rangle \wedge \langle \ \{{\textcolor{red} {\wedge}} \ \, \Pi \ \, ({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,) \ \, \Pi' \} : \beta \ \rangle$$ We now analyze the \underline{nested} Horn-NC bases $ \Sigma $ to which NC unit-resolution can be indeed applied. That is, $ \Sigma $ must have a unit-clause $\langle {\textcolor{red} {\ell}} \, : \, \alpha\rangle $ and a possibilistic nested Horn-NC formula, denoted $\langle \Pi : \beta \rangle$, with a syntactical pattern of the next kind\footnote{The notation $ [ \odot \ \varphi_1 \ldots \varphi_k ] $ was introduced in Definition \ref{def:NCformulas}, bottom.}: $$ \langle \ [ \odot_1 \ \, \Pi_1 \ \ldots \ \ [ \odot_k \ \ \Pi_{k} \ \, ({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,) \ \, \Pi'_k \, ] \ \ \ldots \ \, \Pi'_1 \,] : \beta \ \rangle $$ \noindent where all the $\Pi_j$'s and $\Pi_j'$'s are concatenations of formulas, e.g. for the nesting level $ j, 1 \leq j \leq k$, we have $\Pi_j=\varphi_{j_1} \ldots \varphi_{j_{i-1}}$ and $\Pi'_j=\varphi_{j_{i+1}} \ldots \varphi_{j_{n_j}}$. Since the presence of formulas in the base $ \Sigma $ means that they are conjunctively linked, then one has: \begin{equation} \label{eq:formulaexpresiongeneral} \langle {\textcolor{red} {\ell}} \, : \, \alpha\rangle \wedge \ \langle \ [ \odot_1 \ \, \Pi_1 \ \ldots \ \ [ \odot_k \ \ \Pi_{k} \ \, ({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,) \ \, \Pi'_k \, ] \ \ \ldots \ \, \Pi'_1 \,] : \beta \ \rangle \end{equation} By following the same principle that led us to Rule (\ref{eq:with-conjunct}) and taking into account that $ N(\varphi_1 \wedge \varphi_2)=\mbox{min}\{N(\varphi_1),N(\varphi_1)\} $, one obtains the nested NC unit-resolution rule: \vspace{.05cm} \begin{equation} \label{eq:generalPN-Horn} \frac{ \langle {\textcolor{red} {\ell}} \, : \, \alpha\rangle \wedge \ \langle \, [ \odot_1 \ \Pi_1 \ldots [ \odot_k {\textcolor{red} \ \ \Pi_{k} \ \ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,) \ \ \Pi'_k\,] } \ldots \, \Pi'_1] : \beta \ \rangle} { \langle \ [ \odot_1 \ \Pi_1 \ldots [ \odot_k {\textcolor{blue} \ \ \Pi_{k} \ \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \ \ \Pi'_k\,] } \ldots \, \Pi'_1 ] : \mbox{\bf min}\{\alpha,\beta\} \ \rangle } {\ \mbox{}} \end{equation} \vspace{.05cm} Recapitulating, Rule (\ref{eq:generalPN-Horn}) indicates that if the Horn-NC $ \Sigma $ has two formulas such that one is a unit clause $ \langle {\textcolor{red} {\ell}} \, : \, \alpha\rangle $ and the other $\langle \Pi: \beta \rangle $ has the pattern of the right conjunct in the numerator, then $ \Pi $ can be {\bf replaced} with the formula in the denominator. In practice, applying (\ref{eq:generalPN-Horn}) amounts to just removing $\mathcal{C}({\textcolor{blue} {\neg {\ell}}})$ from $ \Pi $ and updating the necessity weight. \vspace{.15cm} We now denote $ \Pi $ the right conjunct in the numerator of (\ref{eq:generalPN-Horn}) and by $\Pi \succ ({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,)$ denote that $({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,)$ is a sub-formula of $\Pi$. Rule (\ref{eq:generalPN-Horn}) above can be compacted, giving rise to a more concise formulation of {\em UR$_{\Sigma}$}: $$\tcboxmath{\frac{\langle \textcolor{red} \ell : \alpha \rangle \ {\textcolor{red} {\wedge}} \ \langle \ \Pi \succ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg \ell}}) \ \ \mathcal{D}({\textcolor{blue} {\neg \ell}}) \,) : \beta \ \rangle } { \langle \ \Pi \succ \mathcal{D}({\textcolor{blue} {\neg \ell}}) : \mathrm{\bf min}\{\alpha,\beta\} \ \rangle }{\mbox{\,{\em UR$_{\Sigma}$}}}}$$ \vspace{.2cm} The soundness of the rule {\em UR$_{\Sigma}$} follows from $ {\textcolor{red} \ell} \wedge \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \equiv \bot$ and is proven in Section \ref{sect:ProofsProperties}. Two simple examples illustrating how {\em UR$_{\Sigma}$} works are Examples \ref{ex:firstexample} and \ref{ex:secondexample}. Two more complete examples are Examples \ref{ex:BasePossib} and \ref{ex:basepossib-cont} but they employ other inferences and mechanisms relative to $ \mathcal{UR}_ \Sigma $ given in the remaining of this section. \vspace{.1cm} {\bf Remark.} It is not difficult to check that, for clausal formulas, {\em UR$_{\Sigma}$} {\em coincides with the} {\em standard possibilistic clausal unit-resolution \cite{DuboisP94, DuboisP14}.} This clausal-like formulation of NC unit-resolution contrasts with the functional-like one of classical NC resolution handled until now in the literature and presented in \cite{Murray82} (see also \cite{BachmairG01}). We believe that our version, as previously said, is more suitable to understand, implement and formally analyze. \subsection{The Calculus $\mathcal{UR}_\Sigma$} \label{subsec:TheCalculus} Besides {\em UR$_\Sigma$,} the calculus $\mathcal{UR}_\Sigma$ also includes the rules: (a) propositional NC unit-resolution, or {\em UR$_P$}, which is {\em UR$_\Sigma$} but applied inside propositional formulas, (b) the rules to simplify propositional formulas, and (c) the possibilistic rules Min-Decomposability (MinD) and Max-Necessity (MaxN) mentioned in Definition \ref{def:inderences}. \subsubsection{Propositional NC Unit-Resolution} A major difference between computing the inconsistency degree of clausal and non-clausal bases is that the unity members of the former, i.e. clauses, are always consistent, while a non-clausal formula can itself be inconsistent. That is, the input $ \Sigma $ can contain a formula $ \langle \Pi : \alpha \rangle $ where $ \Pi $ is inconsistent, and if so, $ \langle \Pi : \alpha \rangle $ is equivalent to $ \langle \bot : \alpha \rangle $, which brings to: \begin{proposition} \label{prop:input-propo-form} If $ \langle \Pi : \alpha \rangle \in \Sigma$ and $ \Pi $ is inconsistent then $ \mathrm{Inc}(\Sigma) \geq \alpha $. \end{proposition} \begin{niceproof} By definition $ \mathrm{Inc}(\Sigma) = \mathrm{max}\{\beta \,\vert \, \Sigma_{\geq \beta} \mbox{ is inconsistent} \} $. Trivially if $ \Pi $ is inconsistent then $ \bot \in \Sigma_{\geq \alpha} $, and thus, $\Sigma_{\geq \alpha} $ is inconsistent. So $ \mathrm{Inc}(\Sigma) \geq \alpha $. \end{niceproof} Hence, first of all, the propositional formula $ \Pi$ of each $ \langle \Pi : \alpha \rangle \in \Sigma$ must be checked for consistency. If $ \Pi $ is inconsistent, then, by definition, $ \mathrm{Inc}(\Sigma) $ is the maximum of $ \alpha $ and the inconsistency degree of the strict $ \alpha $-cut of $ \Sigma $. Thus, one can remove from $ \Sigma $ all formulas $ \langle \Pi : \beta \rangle $ such that $ \beta \leq \alpha $ and search whether $ \mathrm{Inc}(\Sigma_{> \alpha}) > 0$. \vspace{.1cm} The inference rule {\em UR$_P$} testing the consistency of a propositional $ \Pi $, where $ \langle \Pi : \alpha \rangle \in \Sigma$, is easily derived from {\em UR$_\Sigma$} by considering that the conjunction of a unit clause ${\textcolor{red} {{\ell}}} $ and of a formula $ \Pi $ containing $ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) $ happens inside $ \Pi $. Thus {\em UR$_P$} is as follows: \begin{equation} \label{eq:Propo-UR} \tcboxmath{\frac{\langle \ {\textcolor{red} \ell} \ {\textcolor{red} {\wedge}} \ \Pi \succ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg {\ell}}}) \ \ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) \,) : \alpha \ \rangle } {\langle \ \Pi \succ \mathcal{D}({\textcolor{blue} {\neg {\ell}}}) : \alpha \rangle }{\mbox{\em UR$_P$}}} \end{equation} A complete example through which we show how {\em UR$_P$} proceeds testing the consistency of propositional NC formulas is Example \ref{ex:FormulaPropo} in the next section, and Example \ref{ex:combination-example} illustrates the effects of applying Proposition \ref{prop:input-propo-form}. \subsubsection{Simplification Formulas Rules} Each application of the previous {\em UR$_\Sigma$} and {\em UR$_P$} demands the subsequent application of trivial logical simplifications of propositional formulas. For instance, $ (\vee \ \varphi \ (\vee \ P \ (\vee \ \neg R \ \phi) )) $ and $ (\vee \ P \ \{\wedge \ (\vee) \ \varphi \} ) $ can be obviously substituted by $ (\vee \ \varphi \ P \ \neg R \ \phi) $ and $ P $, respectively. Next we formalize such kind of simplification rules. Being $ \Pi $ the propositional formula of a possibilistic formula $ \langle \Pi : \alpha \rangle $ in a base $ \Sigma $, the first two rules below simplify formulas by (upwards) propagating $(\vee)$ from sub-formulas to formulas: $$\frac{ \langle \ \Pi \succ \, ({\textcolor{black} {\vee}} \ \ \phi_1 \ldots \phi_{i-1} \, (\vee) \, \phi_{i+1} \ldots \phi_k \,) : \alpha \rangle } { \langle \ \Pi \succ ({\textcolor{black} {\vee}} \ \ \phi_1 \ldots \phi_{i-1} \, \phi_{i+1} \ldots \phi_k \,) : \alpha \ \rangle}{{\bf \bot}\vee}$$ $$\frac{\langle \ \Pi \succ \{{\textcolor{black} {\wedge}} \ \ \varphi_1 \ldots \varphi_{i-1} \, (\vee) \, \varphi_{i+1} \ldots \varphi_k \,\} : \alpha \rangle } { \langle \ \Pi \succ \, (\vee) : \alpha \ \rangle }{{\bf \bot}\wedge}$$ \noindent The next two rules remove redundant connectives. The first one removes a connective $ \odot $ if it is applied to a single formula, i.e. $ [ \odot \ \phi_1 ] $, and the second one removes a connective if it is inside another equal connective, i.e. applies to sub-formulas with the pattern $ [ {\textcolor{black} {\odot_1}} \ \ \varphi_1 \ldots \varphi_{i-1} \, [ \odot_2 \ \phi_1 \ldots \phi_n \,] \, \varphi_{i+1} \ldots \varphi_k \,], \odot_1=\odot_2 $. So the formal rules are: $$\frac{ \langle \ \Pi \succ [ {\textcolor{black} {\odot_1}} \ \ \varphi_1 \ldots \varphi_{i-1} \, [\, \odot_2 \ \phi_1 \,] \, \varphi_{i+1} \ldots \varphi_k \,] : \alpha \rangle } {\langle \ \Pi \succ [ {\textcolor{black} {\odot_1}} \ \ \varphi_1 \ldots \varphi_{i-1} \, \phi_1 \, \varphi_{i+1} \ldots \varphi_k \,] : \alpha \rangle }{\, \odot \phi }$$ $$\frac{\langle \ \Pi \succ [ {\textcolor{black} {\odot_1}} \ \ \varphi_1 \ldots \varphi_{i-1} \, [ \odot_2 \ \phi_1 \ldots \phi_n \,] \, \varphi_{i+1} \ldots \varphi_k \,] : \alpha \ \rangle, \odot_1=\odot_2 } {\langle \ \Pi \succ [ {\textcolor{black} {\odot_1}} \ \ \varphi_1 \ldots \varphi_{i-1} \, \phi_1 \ldots \phi_n \, \varphi_{i+1} \ldots \varphi_k \,] : \alpha \ \rangle } {\,\odot \odot}$$ \subsubsection{Possibilistic Rules} We recall the possibilistic rules in Definition \ref{def:inderences}. We pay attention to the case in which a conjunction $ \langle \, \{\wedge \ \ \varphi_1 \ldots \varphi_i \ldots \varphi_k\} : \alpha \rangle $ is deduced. It is clear that, in this case, we can deduce that the necessity weight of each individual conjunct $ \varphi $ is $ \alpha $: $$ \frac{\langle \, \{\wedge \ \ \varphi_1 \ldots \varphi_i \ldots \varphi_k\} : \alpha \rangle } {\{\langle \varphi_1 : \alpha \rangle, \ldots, \langle \varphi_i : \alpha\rangle, \ldots, \langle \varphi_k : \alpha \rangle \} } {\mbox{\em \ \underline{MinD}}}$$ \vspace{.15cm} The last needed rule to be included in $ \mathcal{UR}_\Sigma $ is {\em MaxN}: $$ \langle \varphi : \alpha \rangle, \langle \varphi : \beta \rangle \vdash \langle \varphi : \mbox{max}\{\alpha, \beta \} \rangle \quad \mbox{\em \underline{MaxN}}$$ \subsubsection{The Calculus $\mathcal{UR}_\Sigma$ } \label{subsec:Calculus} The calculus $\mathcal{UR}_\Sigma$ is composed of all the above inference rules: \begin{definition} We define $\mathcal{UR}_\Sigma$ as the calculus formed by {\em UR$_{\Sigma}$}, {\em UR$_P$}, the rules {\em MinD} and {\em MaxN}, and the simplification rules, namely {\em $$\mathcal{UR}_\Sigma=\{\mbox{UR}_{\Sigma}, \mbox{UR}_P,\mbox{MinD}, \mbox{MaxN}, {\bf \bot} \vee, {\bf \bot} \wedge, \odot \,\phi, \odot \odot \, \}.$$ } \end{definition} Examples \ref{ex:firstexample} and \ref{ex:secondexample} are simple examples of how $\mathcal{UR}_\Sigma$ proceeds. Example \ref{ex:BasePossib}, and its continuation Example \ref{ex:basepossib-cont}, are quite complete examples. Example \ref{ex:BasePossib} illustrates how $ \mathcal{UR}_\Sigma $ searches for just one empty clause $ \langle \bot : \alpha \rangle $ and Example \ref{ex:basepossib-cont} determines $ \mbox{Inc}(\Sigma) $. \vspace{.15cm} {\bf Remark.} Having established possibilistic NC unit-resolution, the procedure NC unit-propagation for possibilistic NC formulas can be designed, and on top of it, the possibilistic NC DPLL scheme can be defined. \subsection{Finding $\mbox{Inc}(\Sigma)$} \label{subsect:find} The calculus $ \mathcal{UR}_\Sigma $ determines {\bf just one} sub-set of contradictory formulas along with its inconsistency degree. Yet, a given $\Sigma $ can typically contain many contradictory subsets, each of them induces the deduction of one empty clause $ \langle \bot : \alpha \rangle $. By definition of $ \mbox{Inc}(\Sigma)=\mbox{max}\{\alpha: \Sigma_{\geq \alpha} \mbox{is inconsistent} \}$ and by Proposition \ref{pro:iff-iff-iff}, we have that: \begin{equation} \label{eq:INCSigma} \mbox{Inc}(\Sigma)=\mbox{max}\{\alpha: \Sigma_{\geq \alpha} \mbox{is inconsistent} \}=\mbox{max}\{\alpha \,\vert \, \Sigma \vdash \langle \bot : \alpha \rangle\}. \end{equation} Our simple strategy to find $ \mbox{Inc}(\Sigma)$ is as follows. Firstly, using $\mathcal{UR}_\Sigma$, we determine one inconsistent subset $ \Sigma_1 \subseteq \Sigma $ and its $ \mbox{Inc}(\Sigma_1)=\alpha $, which according to (\ref{eq:INCSigma}), amounts to deducing $\langle \bot: \alpha \rangle$. In the future, we are only interested in knowing whether $ \mbox{Inc}(\Sigma)>\alpha $ and so, for that, we require only the strict $ \alpha $-cut of $ \Sigma $, i.e. $ \Sigma_{>\alpha} $. Again using $\mathcal{UR}_\Sigma$, we attempt to deduce $\langle \bot: \beta \rangle$ and, if it is obtained, continue with $ \Sigma_{>\beta} $. These operations are recursively performed until getting a consistent base, i.e. the empty clause is no longer deduced. Then the $ \alpha $-cut of the last inconsistent base is the sought $ \mbox{Inc}(\Sigma)$. This process is algorithmically described below. {\bf Find} should be called with {\bf Inc} = 0. \vspace{.4cm} \noindent \ \ {\bf Find($ \Sigma$, Inc) } \vspace{-.1cm} {\em \begin{enumerate} \item [(1)] Apply \, $ \mathcal{UR}_\Sigma $ to $\Sigma $ and if $\langle \bot : \alpha \rangle$ is derived then go to (2) else Return {\bf Inc}. \item [(2)] We search whether there exists $ \beta > \alpha $ such that $ \Sigma_{> \beta} $ is inconsistent. Thus, we update $ \Sigma \leftarrow \{\langle \varphi : \beta \rangle \ \vert \ \langle \varphi : \beta \rangle \in \Sigma, \ \beta > \alpha\} $ and $ {\bf Inc} \leftarrow \alpha $; and call \,{\bf Find($ \Sigma $, Inc)}. \end{enumerate} } \noindent The value {\bf Inc} returned by {\bf Find} is $\mbox{Inc}(\Sigma) $, which is proven in Section \ref{sect:ProofsProperties}. If {\bf Inc} = 0 then the input $ \Sigma $ is consistent. In Example \ref{ex:basepossib-cont}, we illustrate the algorithmic strategy of {\bf Find}. \subsection{Further Inferences Rules} \label{subsub:2inferencerules} This last subsection presents two further inferences rules no required to ensure completeness but, since they allow shorter proofs, their appropriate management can yield significant speed-ups. These two rules are: Propositional NC Local Unit-Resolution and Possibilistic NC Hyper Unit-Resolution. \subsubsection{Propositional NC Local-Unit-Resolution} {\em $\mbox{UR}_{P} $} could also apply to propositional sub-formulas and can be used in the general framework of non-Horn-NC bases. The {\em $\mbox{UR}_{P} $} local application means that applying {\em $\mbox{UR}_{P} $} to sub-formulas $ \varphi $ of any formula $ \Pi $, where $\langle \Pi : \alpha \rangle \in \Sigma $, such that $ \varphi $ has the {\em $\mbox{UR}_{P} $} numerator pattern, should be authorized. Namely, applying {\em $\mbox{UR}_P $} to sub-formulas with pattern $\varphi={\textcolor{red} {\ell}} \ {\textcolor{red} {\wedge}} \ \Pi \cdot ({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg \ell}}) \ \mathcal{D}({\textcolor{blue} {\neg \ell}}) \,)$ should be permitted and so, $ \varphi $ could be substituted with ${\textcolor{red} {\ell}} \ {\textcolor{red} {\wedge}} \ \Pi \cdot \mathcal{D}({\textcolor{blue} {\neg \ell}}) $. Hence, the formal specification of the Propositional NC Local-Unit-Resolution rule, {\em $\mbox{LUR}$}, for any non-Horn-NC $ \varphi $ is: $$\tcboxmath{\frac{\langle \ \Pi \succ (\,{\textcolor{red} {\ell}} \ \ {\textcolor{red} {\wedge}} \ \ \varphi \succ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg \ell}}) \ \ \mathcal{D}({\textcolor{blue} {\neg \ell}}) \,) \ \ ) : \alpha \ \rangle} {\langle \ \Pi \succ (\,{\textcolor{red} {\ell}} \ {\textcolor{red} {\wedge}} \ \varphi \succ \mathcal{D}({\textcolor{blue} {\neg \ell}}) \,) : \alpha \ \rangle }{{\mbox{\em \ \underline{LUR}}}}}$$ This inference rule should be read: if $\langle \Pi : \alpha \rangle \in \Sigma $ and $ \Pi $ has a conjunctive {\bf sub-formula} with a literal $ \textcolor{red} \ell $ conjunctively linked to a sub-formula $ \varphi $ having pattern $ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg \ell}}) \ \ \mathcal{D}({\textcolor{blue} {\neg \ell}}) \,) $, then its component $\mathcal{C}({\textcolor{blue} {\neg \ell}})$ can be eliminated. \vspace{.1cm} An example illustrating the functioning of the previous rule is Example \ref{ex:LUR}. \vspace{.1cm} {\bf Remark.} The introduction of this new rule {\em $\mbox{LUR}$} applicable to certain sub-formulas habilitates new sequences of inferences, and so, shorter proofs are now available. \begin{proposition} Let $ \langle\Pi, \alpha \rangle \in \Sigma $. If applying {\em ${\mbox{\em LUR}}$} to $ \Pi $ results in $ \Pi' $, then $ \Pi $ and $ \Pi' $ are logically equivalent. \end{proposition} \begin{niceproof} The soundness of ${\mbox{\em LUR}}$ follows from that of {\em UR$_P$} proved in Lemma \ref{lem:propo-complet}. \end{niceproof} \noindent {\bf Remark.} The obtaining of the simplification rules for their local application to sub-formulas is similarly obtained. \subsubsection{Possibilistic NC Hyper-Unit-Resolution} The given definition of possibilistic NC unit-resolution, or {\em UR$_\Sigma$}, can be extended in order to obtain Possibilistic NC Hyper-Unit-Resolution (${\mbox{\em HUR}}$). Then assume that the possibilistic base has a unit-clause $ \langle \textcolor{red} \ell : \alpha \rangle $ and two sub-formulas $ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg \ell^1}}) \ \ \mathcal{D}({\textcolor{blue} {\neg \ell^1}}) \,) $ and $ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg \ell^2}}) \ \ \mathcal{D}({\textcolor{blue} {\neg \ell^2}}) \,) $, where $\neg \ell^i $ denotes a specific occurrence of $ \neg \ell $. The simultaneous application of NC unit-resolution with two sub-formulas is formally expressed as follows: $$\frac{ \langle \textcolor{red} \ell : \alpha \rangle \ {\textcolor{red} {\wedge}} \ \langle\Pi^1 \succ \, ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg \ell^1}}) \ \ \mathcal{D}({\textcolor{blue} {\neg \ell^1}}) \,) : \beta^1 \rangle \ {\textcolor{red} {\wedge}} \ \langle\Pi^2 \succ \, ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg \ell^2}}) \ \ \mathcal{D}({\textcolor{blue} {\neg \ell^2}}) \,) : \beta^2 \rangle} { \langle \Pi^1 \succ \mathcal{D}({\textcolor{blue} {\neg \ell^1}}) : \mathrm{\bf min}\{\alpha,\beta^1\} \, \rangle \, \wedge \, \langle \Pi^2 \succ \mathcal{D}({\textcolor{blue} {\neg \ell^2}}) : \mathrm{\bf min}\{\alpha, \beta^2\} \, \rangle }{\mbox{\em }}$$ \noindent If the sub-formula $\langle \Pi^i \succ ({\textcolor{black} {\vee}} \ \mathcal{C}({\textcolor{black} {\neg \ell^i}}) \ \mathcal{D}({\textcolor{black} {\neg \ell^i}}) ) : \beta^i \rangle$ is denoted $\langle\Pi, \mathcal{CD}({\textcolor{black} {\neg \ell}}), \beta \rangle^i$, then ${\mbox{\em HUR}}$ for $ k $ sub-formulas is formally expressed below, where, for $ i, 1 \leq i \leq k $, $\beta'^i =min\{\alpha,\beta^i\}$. $$\tcboxmath{\frac{ \langle {\textcolor{red} {\ell }} : \alpha \rangle \ {\textcolor{red} {\wedge}} \ \langle \Pi, \mathcal{CD}({\textcolor{blue} {\neg \ell}}), \beta \rangle^1 {\textcolor{red} {\wedge}} \ldots {\textcolor{red} {\wedge}} \ \langle \Pi, \mathcal{CD}({\textcolor{blue} {\neg \ell}}), \beta \rangle^i \ {\textcolor{red} {\wedge}} \,\ldots {\textcolor{red} {\wedge}} \ \langle \Pi , \mathcal{CD}({\textcolor{blue} {\neg \ell}}), \beta \rangle^k } { \langle \Pi, \mathcal{D}({\textcolor{blue} {\ell}}), \beta' \rangle^1 \ {\textcolor{red} {\wedge}} \ \ldots \ {\textcolor{red} {\wedge}} \ \langle \Pi, \mathcal{D}({\textcolor{blue} {\ell}}), \beta' \rangle^i \ {\textcolor{red} {\wedge}} \ \ldots \ {\textcolor{red} {\wedge}} \ \langle \Pi, \mathcal{D}({\textcolor{blue} {\neg \ell}}), \beta' \rangle^k } {\mbox{\em \ \underline{HUR}}}}$$ Since $ {\textcolor{black} {\neg \ell^i }}, 1 \leq i\leq k $, are literal occurrences that are pairwise different, so are the sub-formulas $ \mathcal{CD}^i $ (and so $ \mathcal{D}^i $) in the numerator and denominator of ${\mbox{\em HUR}}$. However, the formulas $ \Pi^i $ are not necessarily different; see {\bf Example \ref{ex:HUR}} for this concrete question and in general for checking the working of the rule ${\mbox{\em HUR}}$. \vspace{.1cm} {\bf Remark.} An NC hyper unit-resolution rule, more general than ${\mbox{\em HUR}}$, can be devised to include simultaneously several unit-clauses so that for each unit-clause $ \langle \ell : \alpha \rangle $ several sub-formulas $\langle \Pi^i \succ ({\textcolor{black} {\vee}} \ \mathcal{C}({\textcolor{black} {\neg \ell^i}}) \ \mathcal{D}({\textcolor{black} {\neg \ell^i}}) ) : \beta^i \rangle$ can be considered. In other words, one can consider simultaneously $ k \geq 2 $ unit clauses and so simultaneously apply $ k \geq 2 $ {\em HUR} rules. \section{Illustrative Examples} \label{sec:illustrativeexamples} This section gives examples illustrating the notions presented in the previous sections. Concretely, we provide the next examples: \vspace{.15cm} -- Example \ref{ex:firstexample}: a simple inconsistent possibilistic Horn-NC base. \vspace{.05cm} -- Example \ref{ex:secondexample}: a simple consistent possibilistic Horn-NC base. \vspace{.05cm} -- Example \ref{ex:FormulaPropo}: a complete propositional Horn-NC formula. \vspace{.05cm} -- Example \ref{ex:combination-example}: an input base with an inconsistent propositional formula. \vspace{.05cm} -- Example \ref{ex:BasePossib}: a complete possibilistic Horn-NC base. \vspace{.05cm} -- Example \ref{ex:basepossib-cont}: an example showing the strategy of {\bf Find}. \vspace{.05cm} -- Example \ref{ex:LUR}: an example of NC Local Unit-Resolution. \vspace{.05cm} -- Example \ref{ex:HUR}: an example of NC Hyper Unit-Resolution. \vspace{.15cm} \noindent Among such examples, we highlight Examples \ref{ex:BasePossib} and \ref{ex:basepossib-cont}, which contain a rather complete Horn-NC base, whose inconsistency degree is obtained in two phases. The first one is provided in Example \ref{ex:BasePossib}, and the second in Example \ref{ex:basepossib-cont}. All inference rules of $\mathcal{UR}_{\Sigma}$ are needed as well as their combination with the strict $ \alpha $-cuts of the input $ \Sigma $. \begin{example} \label{ex:firstexample} Let us assume that $ \Sigma $ is the next possibilistic Horn-NC base: $$\Sigma= \{ \, \langle P : {\bf .8} \rangle, \ \, \langle \, \Pi_1=(\vee \ \ \{\wedge \ \ \neg P \ \ \neg Q\} \ \ Q ) : {\bf .6} \rangle, \ \, \langle \, (\vee \ \neg P \ \neg Q ) : {\bf .7} \rangle \}$$ \begin{itemize} \item {\em UR$_\Sigma$} with $\langle P : {\bf .8} \rangle$ and $ \Pi_1 $ gives rise to the next matchings: -- $ \ \Pi=\Pi_1 $ -- $ \ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg P}}) \ \mathcal{D}({\textcolor{blue} {\neg P}}) \,) =\Pi_1$ -- $ \ \mathcal{C}({\textcolor{blue} {\neg P}})= \{\wedge \ \ \neg P \ \ \neg Q\}$ -- $ \ \mathcal{D}({\textcolor{blue} {\neg P}})= Q $ \item Hence, {\em UR$_{\Sigma}$} adds: \quad $\Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \, Q ) : {\bf .6} \rangle$ \item Applying simplifications to the last formula: \quad $\Sigma \leftarrow \Sigma \ \cup \ \langle Q : {\bf .6} \rangle$ \item {\em UR$_\Sigma$} with $\langle Q : {\bf .6} \rangle$ and with the last formula in the initial $ \Sigma $ gives: -- $ \ \Pi=(\vee \ \neg P \ \neg Q ) $ -- $ \ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg Q}}) \ \mathcal{D}({\textcolor{blue} {\neg Q}}) \,) =\Pi$ -- $ \ \mathcal{C}({\textcolor{blue} {\neg Q}})= {\textcolor{blue} {\neg Q}}$ -- $ \ \mathcal{D}({\textcolor{blue} {\neg Q}})= \neg P $ \item Hence, {\em UR$_{\Sigma}$} adds: \ $ \Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \neg P ) : {\bf .6} \rangle$ \item Resolving $\langle P : {\bf .8} \rangle$ in the input $ \Sigma $ with the last formula: $\Sigma \leftarrow \Sigma \ \cup \langle \bot : {\bf .6} \rangle$ \item Therefore {\em $\mathcal{UR}_{\Sigma}$} obtains $ \mbox{Inc}(\Sigma)= {\bf .6}$ \qed \end{itemize} \end{example} \begin{example} \label{ex:secondexample} Let us assume that $ \Sigma $ is the next possibilistic Horn-NC base: $$\Sigma= \{ \, \langle Q : {\bf .8} \rangle, \ \, \langle \, \Pi_1=(\vee \ \ \neg Q \ \ \{\wedge \ \ R \ \ (\vee \ \ {\textcolor{blue} {\neg Q}} \ \ \{\wedge \ \ S \ \ \neg P \} \,) \, \} \,) : {\bf .6} \rangle, \ \, \langle \, (\vee \ \neg P \ \neg Q ) : {\bf .7} \rangle \}$$ \begin{itemize} \item {\em UR$_{\Sigma}$} with $\langle Q : {\bf .8} \rangle$ and with the rightest $ {\textcolor{blue} {\neg Q}} $ in $ \Pi_1 $ gives the next matchings: -- $ \ \Pi=\Pi_1 $ -- $ \ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg Q}}) \ \mathcal{D}({\textcolor{blue} {\neg Q}}) \,) =(\vee \ \ {\textcolor{blue} {\neg Q}} \ \ \{\wedge \ \ S \ \ \neg P \} \,)$ -- $ \ \mathcal{C}({\textcolor{blue} {\neg Q}})= {\textcolor{blue} {\neg Q}}$ -- $ \ \mathcal{D}({\textcolor{blue} {\neg Q}})= \{\wedge \ \ S \ \ \neg P \} $ \item Hence, {\em UR$_{\Sigma}$} adds: \quad $\Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \ \neg Q \ \ \{\wedge \ \ R \ \ (\vee \ \ \{\wedge \ \ S \ \ \neg P \} \,) \, \} \,) : {\bf .6} \rangle$ \item After simplifications: \ $\Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \ {\textcolor{blue} {\neg Q}} \ \ \{\wedge \ \ R \ \ S \ \ \neg P \, \} \,) : {\bf .6} \rangle$ \item Using again $\langle Q : {\bf .8} \rangle$ and the last formula: -- $ \ \Pi=(\vee \ \ {\textcolor{blue} {\neg Q}} \ \ \{\wedge \ \ R \ \ S \ \ \neg P \, \} \,) $ -- $ \ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg Q}}) \ \mathcal{D}({\textcolor{blue} {\neg Q}}) \,) =\Pi$ -- $ \ \mathcal{C}({\textcolor{blue} {\neg Q}})= {\textcolor{blue} {\neg Q}}$ -- $ \ \mathcal{D}({\textcolor{blue} {\neg Q}})= \{\wedge \ \ R \ \ S \ \ \neg P \, \} $ \item Hence, {\em UR$_{\Sigma}$} adds: \ $\Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \ \{\wedge \ \ R \ \ S \ \ \neg P \, \} \,) : {\bf .6} \rangle$ \item After simplifications: \ $\Sigma \leftarrow \Sigma \ \cup \ \langle \, \{\wedge \ \ R \ \ S \ \ \neg P \, \} \ : {\bf .6} \rangle$ \item Applying the rule {\em MinD}: \ $\Sigma \leftarrow \Sigma \ \cup \{\langle R : {\bf .6} \rangle, \langle S : {\bf .6} \rangle, \langle \neg P : {\bf .6} \rangle \}$. \item Using the first and last formulas in the initial $ \Sigma $: \ $\Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \neg P ) : {\bf .7} \rangle$ \item Applying {\em MaxN} with $\langle \neg P : {\bf .6} \rangle$ and $ \langle \, (\vee \ \neg P ) : {\bf .7} \rangle$ the former is eliminated. \item No more resolvents apply. \item The propositional component of $ \Sigma $ is consistent, so $ \mbox{Inc}(\Sigma)=0 $. \qed \end{itemize} \end{example} Next, we give a rather elaborated \underline{propositional} formula and show how the propositional NC unit-resolution, or {\em UR$_P$}, together with the simplification rules, detect its inconsistency. \begin{example} \label{ex:FormulaPropo} Let us assume that the input $ \Sigma $ has a possibilistic Horn-NC $ \langle \varphi: \alpha \rangle$ given below, where $ \phi_1 $ and $ \phi_2 $ are assumed to be Horn-NC formulas. $$ \langle \ \varphi=\{\wedge \ \ (\vee \ \ R \ \phi_1) \ \ (\vee \ \ \neg {P} \ \ \{\wedge \ \ (\vee \ \ \neg {P} \ \ \neg {R} \,) \quad (\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\textcolor{blue} {\neg {P}}} \,\} \, ) \ \ R \, \} \, ) \ {\textcolor{red} P} \,\} : \alpha \ \rangle$$ \noindent The tree associated with $ \varphi $ is depicted in {\bf Fig. 4}, left. \begin{center} \begin{adjustbox}{valign=t} \begin{tikzpicture}[] \Tree [.{$\wedge : \alpha$} [.$\vee$ [.R\\ ][.$\phi_1$\\ ] ] [.$\vee$ [.{\color{black}$\neg {P}$}\\ ] [.$\wedge$ [.$\vee$ [.$\neg {P}$\\ ] [.$\neg {R}$\\ ] ] [.$\vee$ [.$\phi_2$\\ ] [.$\wedge$ [.$\neg {Q}$\\ ] [.{\color{blue}$\neg {P}$}\\ ] ] ] [.R\\ ] ] ] [.{\color{red} P}\\ ] ] \end{tikzpicture} \end{adjustbox} \begin{adjustbox}{valign=t} \hspace{.5cm} \begin{tikzpicture}[] \Tree [.{$\wedge : \alpha$} [.$\vee$ [.R\\ ][.$\phi_1$\\ ] ] [.$\vee$ [.{\color{blue}$\neg {P}$}\\ ] [.$\wedge$ [.$\vee$ [.$\neg {P}$\\ ] [.$\neg {R}$\\ ] ] [.$\vee$ [.$\phi_2$\\ ] ] [.R\\ ] ] ] [.{\color{red} P}\\ ] ] \end{tikzpicture} \end{adjustbox} \vspace{-.3cm} {\small {\bf Fig. 4.} {\em Formulas $ \varphi $ (left) and $ \varphi' $ (right)}} \end{center} \noindent Thus, before computing the inconsistency degree of $ \Sigma $, one needs to check whether its propositional formulas are inconsistent. We show below how {\em UR$_P$} checks the inconsistency of $ \varphi $. \noindent {\em UR$_P$} with ${\textcolor{red} P}$ and the right-most ${\textcolor{blue} {\neg {P}}}$ yields the next matchings in the {\em UR$_P$} numerator: \begin{itemize} \item $\Pi =(\vee \ \ \neg {P} \ \ \ \{\wedge \ \ (\vee \ \ \neg {P} \ \ \neg {R} \,) \ \ \,(\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\color{blue}\neg {P}} \,\} \, ) \, \ \ R \, \} \, )$ \item $ (\vee \ \mathcal{C}({\color{blue}\neg {P}}) \ \mathcal{D}({\color{blue}\neg {P}})) =(\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\color{blue}\neg {P}} \,\} \, ).$ \item $ \mathcal{C}({\color{blue}\neg {P}})=\{\wedge \ \ \neg {Q} \ \ {\color{blue}\neg {P}} \,\} $ \item $ \mathcal{D}({\color{blue}\neg {P}})= \phi_2 $ \end{itemize} \noindent Applying {\em UR$_P$} to $ \varphi $ yields: $$\varphi'=\langle \ \{\wedge \ \ (\vee \ \ R \ \phi_1) \ \ (\vee \ \ \neg {P} \ \ \{\wedge \ \ (\vee \ \ \neg {P} \ \ \neg {R} \,) \quad (\vee \ \ \phi_2 \, ) \ \ R \, \} \, ) \,\} : \alpha \ \rangle$$ \noindent The resulting tree is the right one in {\bf Fig. 4}. Assume that we proceed now with a second NC unit-resolution step by picking the same ${\textcolor{red} P}$ and the left-most ${\color{blue}\neg {P}}$ (colored blue in {\bf Fig. 4}, right). Then, the right conjunct of the numerator of {\em UR$_P$} is as follows: \begin{itemize} \item $\Pi = (\vee \ {\color{blue}\neg {P}} \ (\vee \ \{\wedge \ \ (\vee \ \neg {P} \ \ \neg {R} \,) \ \ (\vee \ \phi_2 \, ) \ \ R \, \} \, )) $ \item $ (\vee \ \mathcal{C}({\color{blue}\neg {P}}) \ \mathcal{D}({\color{blue}\neg {P}})) = \Pi$ \item $\mathcal{C}({\color{blue}\neg {P}})={\color{blue}\neg {P}}$ \item $\mathcal{D}({\color{blue}\neg {P}})=(\vee \ \{\wedge \ \ (\vee \ \neg {P} \ \ \neg {R} \,) \ \ (\vee \ \phi_2 \, ) \ \ R \, \} \, )$ \end{itemize} \noindent By applying {\em UR$_P$} to $ \varphi' $, the obtained formula is depicted in {\bf Fig. 5}, left: \begin{center} \begin{adjustbox}{valign=t} \begin{tikzpicture}[] \Tree [.{$\wedge : \alpha$} [.$\vee$ [.R\\ ][.$\phi_1$\\ ] ] [.$\vee$ [.$\wedge$ [.$\vee$ [.$\neg {P}$\\ ] [.$\neg {R}$\\ ] ] [.$\vee$ [.$\phi_2$\\ ] ] [.R\\ ] ] ] [.{\color{red} P}\\ ] ] \end{tikzpicture} \end{adjustbox} \begin{adjustbox}{valign=t} \hspace{2.cm} \begin{tikzpicture}[] \Tree [.{$\wedge : \alpha$} [.$\vee$ [.R\\ ][.$\phi_1$\\ ] ] [.$\vee$ [.{\textcolor{blue}{$\neg {P}$}}\\ ] [.{\textcolor{blue}{$\neg {R}$}}\\ ] ] [.$\phi_2$\\ ] [.{\textcolor{red} R}\\ ] [.{\textcolor{red} P}\\ ] ] \end{tikzpicture} \end{adjustbox} \vspace*{-.4cm} {\small {\bf Fig. 5.} {\em Example \ref{ex:FormulaPropo} continued.}} \end{center} \noindent After three simplification steps, one gets the formula associated with the right tree in {\bf Fig. 5.} Finally, two applications of {\em UR$_P$} to the two pairs {\textcolor{red} {$R$}} and {\textcolor{blue}{$\neg {R}$}}, and {\textcolor{red} {$P$}} and {\textcolor{blue}{$\neg {P}$}}, lead the calculus to derive $\langle (\vee) : \alpha\rangle$. \qed \end{example} In the next example, we illustrate the effects of finding that one of the propositional formulas of the input base is inconsistent. \begin{example} \label{ex:combination-example} Let $ \varphi $ be the formula from Example \ref{ex:FormulaPropo} and $\Sigma_1 $ be $ \Sigma $ from Example \ref{ex:firstexample} and let us analyze the base $ \Sigma = \Sigma_1 \cup \{\langle \varphi : {\bf .6} \rangle \}$. Then, firstly the propositional rules of {\em $\mathcal{UR}_\Sigma$} are applied to each propositional Horn-NC in $ \Sigma $, and in particular, to $ \langle \varphi : {\bf .6} \rangle $, which, according to Example \ref{ex:FormulaPropo}, yields $ \langle (\vee) : {\bf .6} \rangle $. Then before calling {\bf Find}, $ \Sigma_1 $ is reduced to $ \Sigma_1=\{\langle P : {\bf .8} \rangle, \ \langle \, (\vee \ \neg P \ \neg Q ) : {\bf .7} \rangle\} $ and then {\bf Find} is called with such $ \Sigma_1 $. Since $ \Sigma_1$ is consistent, one can conclude that $ \mathrm{Inc}(\Sigma) = {\bf .6} $. \end{example} We next give a complete formula and illustrate how $\mathcal{UR}_\Sigma$ determines just one inconsistent subset $ \Sigma_1 $ of a Horn-NC base $ \Sigma $ and its degree $ \mathrm{Inc}(\Sigma_1) $. By now, we are not concerned with finding the maximum inconsistency degree, but just in finding one inconsistent subset. Later, in Example \ref{ex:basepossib-cont}, we will illustrate the process performed by {\bf Find} to obtain the inconsistency degree $ \mathrm{Inc}(\Sigma) $. \begin{example} \label{ex:BasePossib} Let us assume that $ \Sigma $ is the next possibilistic Horn-NC base: $$\Sigma= \{ \, \langle P : {\bf .8} \rangle, \ \, \langle \, \Pi_1 : {\bf .6} \rangle, \ \, \langle \, \Pi_2 : {\bf .5} \rangle, \ \, \langle \, \{\wedge \ \neg P \ \neg Q \} : {\bf .7} \rangle \}$$ \noindent wherein the propositional formulas $ \Pi_1 $ and $ \Pi_2 $, both individually consistent, are as follows: \begin{itemize} \item $ \Pi_1 = (\vee \ \ \{\wedge \ \ \neg P \ \ \neg Q\} \ \ \{\wedge \ \, Q \ \ P \}) $ \item $ \Pi_2 = (\vee \ \ \neg Q \ \ \{\wedge \ \ R \ \ (\vee \ \ \neg Q \ \ \{\wedge \ \ S \ \ \neg P \} \,) \, \} \,) $ \end{itemize} \noindent The input base $ \Sigma $ is inconsistent and below, we step-by-step provide the inferences carried out by the calculus {\em $\mathcal{UR}_\Sigma$} to derive one empty formula $ \langle \bot : \alpha \rangle $. \begin{itemize} \item We apply {\em UR$_{\Sigma}$} with $ \langle P : {\bf .8} \rangle $ and $ \langle \, \Pi_1 : {\bf .6} \rangle $ and the next matchings: -- $\ \Pi=\Pi_1 $ -- $ \ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg P}}) \ \ \mathcal{D}({\textcolor{blue} {\neg P}}) \,)=\Pi_1 $ -- $\ \mathcal{C}({\textcolor{blue} {\neg P}})=\{\wedge \ \neg P \ \neg Q\} $ -- $\ \mathcal{D}({\textcolor{blue} {\neg P}})=\{\wedge \ Q \ P\} $ \item Hence, {\em UR$_{\Sigma}$} adds: \quad $\Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \, \{\wedge \ Q \ P \}) : {\bf .6} \rangle$ \item Simplifying the last formula: \quad $\Sigma \leftarrow \Sigma \ \cup \ \langle \, \{\wedge \ Q \ P \} : {\bf .6} \rangle$ \item Applying {\em MinD} to the last formula: \ $\Sigma \leftarrow \Sigma \ \cup \ \langle \, Q \ : {\bf .6} \rangle \cup \langle P : {\bf .6} \rangle$ \item Since $\langle P : {\bf .8} \rangle, \langle P : {\bf .6} \rangle \in \Sigma$, by {\em MaxN}: \ $ \Sigma \leftarrow \Sigma /\langle P : {\bf .6}\rangle $ \item Applying {\em UR$_{\Sigma}$} with $ \langle \, Q \ : {\bf .6} \rangle $ and the rightest $ \neg Q $ of $ \langle \, \Pi_2 : {\bf .5} \rangle $: -- $ \ \Pi=\Pi_2 $ -- $ \ ({\textcolor{blue} {\vee}} \ \mathcal{C}({\textcolor{blue} {\neg Q}}) \ \mathcal{D}({\textcolor{blue} {\neg Q}}) \,) =(\vee \ {\textcolor{blue} {\neg Q}} \ \{\wedge \ S \ \neg P \} \,) $ -- $ \ \mathcal{C}({\textcolor{blue} {\neg Q}})= {\textcolor{blue} {\neg Q}}$ -- $ \ \mathcal{D}({\textcolor{blue} {\neg Q}})=\{\wedge \ S \ \neg P\} $ \item Thus {\em UR$_{\Sigma}$} adds: \quad $ \Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \, \neg Q \ \, \{\wedge \ \, R \ \, (\vee \ \, \{\wedge \ \, S \ \, \neg P \} \,) \, \} \,) : {\bf .5} \rangle$ -- We denote $ \langle \Pi_3 : {\bf .5} \rangle $ the last added formula. \item Applying {\em UR$_{\Sigma}$} with again $ \langle \, Q : {\bf .6} \rangle $ and the last formula $ \langle \Pi_3 : {\bf .5} \rangle $: -- $ \ \Pi=\Pi_3 $ -- $ \ ({\textcolor{blue} {\vee}} \ \ \mathcal{C}({\textcolor{blue} {\neg Q}}) \ \mathcal{D}({\textcolor{blue} {\neg Q}}) \,) =\Pi_3$ -- $ \ \mathcal{C}({\textcolor{blue} {\neg Q}})= {\textcolor{blue} {\neg Q}}$ -- $ \ \mathcal{D}({\textcolor{blue} {\neg Q}})=\{\wedge \ \ R \ \ (\vee \ \ \{\wedge \ \ S \ \ \neg P \} \,) \, \} $ \item Hence {\em UR$_{\Sigma}$} adds: \quad $\Sigma \leftarrow \Sigma \ \cup \ \langle \, (\vee \ \, \{\wedge \ \, R \ \ (\vee \ \, \{\wedge \ \, S \ \, \neg P \} \,) \, \} \,) : {\bf .5} \rangle$ \item Simplifying the last formula: \quad $ \Sigma \leftarrow \Sigma \ \cup \ \langle \, \{\wedge \ \ R \ \ S \ \ \neg P \} : {\bf .5} \rangle $ \item Using the rule {\em InvMinD:} \ $ \Sigma \leftarrow \Sigma \ \cup \ \{ \langle \, R : {\bf .5} \rangle, \langle \, S : {\bf .5} \rangle, \langle \, \neg P : {\bf .5} \rangle \} $ \item From $\langle \, \neg P : {\bf .5} \rangle$ and the initial $\langle P : {\bf .8} \rangle$: \quad $\Sigma \leftarrow \Sigma \cup \langle \, (\vee) : {\bf .5} \rangle$. \item So the (first) inconsistency degree found is {\bf .5}. \qed \end{itemize} \end{example} \noindent Next example continues the previous one towards, this time, computing the proper $ \mbox{Inc}(\Sigma) $. This example illustrates the strategy of {\bf Find} to do so. \begin{example} \label{ex:basepossib-cont} Let us continue with Example \ref{ex:BasePossib}. Since $\langle \, (\vee) : {\bf .5} \rangle$ was found, for checking whether $ \mbox{Inc}(\Sigma) > {\bf .5}$, all possibilistic formulas whose necessity weight is not bigger than ${\bf .5}$ are useless, that is, one can obtain the strict {\bf .5}-cut of $ \Sigma $. Thus, the new base is $ \Sigma_{>{\bf .5}}= \Sigma_1 \cup \Sigma_2 $, where $ \Sigma_1 $ and $ \Sigma_2 $ are the strict {\bf .5}-cut of the \underline{initial formulas} and of the \underline{deduced formulas}, respectively, and which are given below: $$\Sigma_1= \{ \, \langle P : {\bf .8} \rangle, \ \, \langle \, \Pi_1 : {\bf .6} \rangle, \ \, \langle \, \{\wedge \ \neg P \ \neg Q \} : {\bf .7} \rangle \, \}$$ $$\Sigma_2=\{\langle \, (\vee \ \, \{\wedge \ Q \ P \}) : {\bf .6} \rangle, \ \ \langle \, \{\wedge \ Q \ P \} : {\bf .6} \rangle, \ \ \langle \, Q \ : {\bf .6} \rangle, \} $$ One can check that the only non-subsumed formula in $ \Sigma_2 $ is $\langle \, Q \ : {\bf .6} \rangle$. So, $\Sigma_2 $ is reduced to $\Sigma_2 = \{ \langle \, Q \ : {\bf .6} \rangle\}$. Now, {\bf Find} newly launches the process to compute the inconsistency of $ \Sigma= \Sigma_1 \cup \{ \langle \, Q \ : {\bf .6} \rangle\}$ with {\em ${\bf Inc}={\bf .5}$} and follows the next steps: \begin{itemize} \item Using $ \langle \, Q \ : {\bf .6} \rangle$ and right-most formula in $ \Sigma_1 $ yields: \ \ $\langle \, (\vee) : {\bf .6} \rangle$. \item The new $ \Sigma $ is $ \Sigma= \{ \langle P : {\bf .8} \rangle, \langle \, \{\wedge \ \neg P \ \neg Q \} : {\bf .7} \rangle \}$ and the new {\bf Inc} is {\bf .6}. \item $\mathcal{UR}_\Sigma $ is relaunched and finds $\langle \, (\vee) : {\bf .7} \rangle$. \item The new $ \Sigma$ is $\{ \, \langle P : {\bf .8} \rangle \, \}$ and the new {\bf Inc} is {\bf .7}. \item $\mathcal{UR}_\Sigma $ finds $ \Sigma $ is consistent. \item Hence {\bf Find} returns {\bf Inc = .7.} \end{itemize} \end{example} Next example illustrates the application of NC Local Unit-resolution, or {\em LUR.} \begin{example} \label{ex:LUR} Consider again the formula $ \varphi $ from Example \ref{ex:FormulaPropo}: $$\langle \ \varphi=\{\wedge \ \ (\vee \ \ R \ \phi_1) \ \ (\vee \ \ \neg {P} \ \ \{\wedge \ \ (\vee \ \ \neg {P} \ \ \neg {R} \,) \quad (\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\textcolor{black} {\neg {P}}} \,\} \, ) \ \ R \, \} \, ) \ {\textcolor{black} P} \,\} : \alpha \ \rangle.$$ \noindent One can check that its sub-formula $$ \phi=(\vee \ \ \neg P \ \ \{\wedge \ \ (\vee \ \ \neg P \ \ {\textcolor{blue} {\neg R}}) \ \ (\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\textcolor{black} {\neg P }} \} ) \ \ {\textcolor{red} R} \} \,)$$ has the pattern of the ${\mbox{\em LUR}}$ numerator regarding $ {\textcolor{blue} {\neg R}} $ and $ {\textcolor{red} R} $. Thus ${\mbox{\em LUR}}$ can be applied and so $ \phi $ be replaced, after simplifications, with $ (\vee \ \ \neg P \ \ \{\wedge \ \ \neg P \ \ (\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg Q \ \ {\textcolor{black} {\neg P }} \} ) \ \ R \} )$ in the formula $ \varphi $. In this specific example, only one literal is removed, but in a general case, big sub-formulas may be eliminated. \qed \end{example} The next example is devoted to the rule of NC hyper unit-resolution, or {\em HUR.} \begin{example} \label{ex:HUR} Let us reconsider also the formula in previous Example \ref{ex:FormulaPropo} (recall that the $i$ superscript in $ {\textcolor{blue} {\neg {P}^i}} $ denotes an specific literal occurrence of $ {\textcolor{blue} {\neg {P}}} $): $$ \langle \ \{\wedge \ \ (\vee \ \ R \ \phi_1) \ \ (\vee \ \ {\textcolor{blue} {\neg {P}^1}} \ \ \{\wedge \ \ (\vee \ \ {\textcolor{blue} {\neg {P}^2}} \ \ \neg {R} \,) \quad (\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\textcolor{blue} {\neg {P}^3}} \,\} \, ) \ \ R \, \} \, ) \ {\textcolor{red} P} \,\} : \alpha \ \rangle$$ \noindent One can apply NC Hyper Unit-Resolution with $ {\textcolor{red} P} $ and the three literals ${\textcolor{blue} {\neg {P}^i}}$. The formula $ \Pi $ in the numerator of {\em HUR} is the same for the three literals, so it is noted $ \Pi^{1,2,3}$, but the formulas $ (\vee \ \ \mathcal{C}(\neg {P}^i) \ \ \mathcal{D}(\neg {P}^i))$ are different and are given below: \vspace{.2cm} -- $ \Pi^{1,2,3}= (\vee \ \ \neg {P} \ \ \{\wedge \ \ (\vee \ \ \neg {P} \ \ \neg {R} \,) \quad (\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\textcolor{black} {\neg {P}}} \,\} \, ) \ \ R \, \} \, )$ \vspace{.15cm} -- $ (\vee \ \ \mathcal{C}(\neg {P}^1) \ \ \mathcal{D}(\neg {P}^1))=\Pi^{1,2,3}$ \vspace{.15cm} -- $ (\vee \ \ \mathcal{C}(\neg {P}^2) \ \ \mathcal{D}(\neg {P}^2))= (\vee \ \ {\textcolor{blue} {\neg {P}^2}} \ \ \neg {R} \,) $ \vspace{.15cm} -- $ (\vee \ \ \mathcal{C}(\neg {P}^3) \ \ \mathcal{D}(\neg {P}^3))= (\vee \ \ \phi_2 \ \ \{\wedge \ \ \neg {Q} \ \ {\textcolor{blue} {\neg {P}^3}} \,\} \, )$ \vspace{.25cm} By applying NC Hyper Unit-Resolution, one gets: $$ \langle \ \{\wedge \ \ (\vee \ \ R \ \phi_1) \ \ (\vee \ \ \{\wedge \ \ (\vee \ \ \neg {R} \,) \quad (\vee \ \ \phi_2 \, ) \ \ R \, \} \, ) \ {\textcolor{red} P} \,\} : \alpha \ \rangle$$ After simplifying: $$ \langle \ \{\wedge \ \ (\vee \ \ R \ \phi_1) \ \ \neg {R} \ \ \phi_2 \ \ R \,\ {\textcolor{red} P} \,\} : \alpha \ \rangle$$ \vspace{.15cm} Clearly, a simple NC unit-resolution deduces $ \langle (\vee) : \alpha \rangle $. Altogether, in this particular example, the rule {\em HUR} accelerates considerably the proof of inconsistency. \end{example} \section{Correctness of $\mathcal{UR}_{\Sigma}$ and Polynomiality of $ \mathcal{\overline{H}}_\Sigma$} \label{sect:ProofsProperties} This section provides the proofs of both, the correctness of $\mathcal{UR}_{\Sigma}$ to determine the inconsistency degree of $ \mathcal{\overline{H}}_\Sigma$ and of the tractability of $ \mathcal{\overline{H}}_\Sigma$ (i.e. of Horn-NC-INC, Definition \ref{def:complexitiesofclassesofbases}). Some proofs, as those of soundness of the simplification rules, are simple and intuitive and so are omitted. The following formal proofs are provided: \vspace{.15cm} -- soundness of quasi-clausal NC unit-resolution (Rule (\ref{eq:with-conjunct})); \vspace{.05cm} -- soundness of nested NC unit-resolution {\em UR$_{\Sigma}$}; \vspace{.05cm} -- correctness of the propositional rules of $\mathcal{UR}_{\Sigma}$; \vspace{.05cm} -- correctness of the complete {\em $\mathcal{UR}_{\Sigma}$}; \vspace{.05cm} -- correctness of the algorithm {\bf Find}; and \vspace{.05cm} -- polynomial complexity of $ \mathcal{\overline{H}}_\Sigma$. \begin{proposition} Rule (\ref{eq:with-conjunct}) is sound: $$\langle{\textcolor{black} {\ell}} \, : \, \alpha \rangle \, {\textcolor{black}\wedge} \, \langle \,({\textcolor{black} {\vee}} \ \, \mathcal{C}({\textcolor{black} {\neg {\ell}}}) \ \, \mathcal{D}({\textcolor{black} {\neg {\ell}}}) )\, : \beta \rangle \ \models \ \langle \, \mathcal{D}({\textcolor{black} {\neg {\ell}}}) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle .$$ \end{proposition} \begin{niceproof} Denoting $ \mathcal{F}=\langle{\textcolor{black} {\ell}} \, : \, \alpha \rangle \, {\textcolor{black}\wedge} \, \langle \,({\textcolor{black} {\vee}} \ \, \mathcal{C}({\textcolor{black} {\neg {\ell}}}) \ \, \mathcal{D}({\textcolor{black} {\neg {\ell}}}) )\, : \beta \rangle$, we have: \vspace{.2cm} - By {\em MinD}, \ $\mathcal{F} \models \ \langle \, ({\vee} \ \ {\ell} \wedge \mathcal{C}( {\neg {\ell}}) \ \ {\ell} \wedge \mathcal{D}( {\neg {\ell}})) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle $. \vspace{.2cm} - Since $ {\ell}\wedge\mathcal{C}( {\neg {\ell}} \,) \equiv \bot $ then: $ \ \mathcal{F} \models \ \langle\, {\ell} \wedge \mathcal{D}( {\neg {\ell}} \,) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle $. \vspace{.2cm} - By {\em MinD}, \ $ \mathcal{F} \models \ \langle\, \mathcal{D}( {\neg {\ell}} \,) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle $. \end{niceproof} \begin{proposition} \label{prop:soundnessgeneral} Te rule UR$_\Sigma $ is sound: $$\langle{\textcolor{black} {\ell}} \, : \, \alpha \rangle \, {\textcolor{black}\wedge} \, \langle \,\Pi \succ ({\textcolor{black} {\vee}} \ \, \mathcal{C}({\textcolor{black} {\neg {\ell}}}) \ \, \mathcal{D}({\textcolor{black} {\neg {\ell}}}) )\, : \beta \rangle \ \models \ \langle \, \mathcal{D}({\textcolor{black} {\neg {\ell}}}) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle .$$ \end{proposition} \begin{niceproof} By denoting $ \mathcal{F}=\langle{\textcolor{black} {\ell}} \, : \, \alpha \rangle \, {\textcolor{black}\wedge} \, \langle \,\Pi \succ ({\textcolor{black} {\vee}} \ \, \mathcal{C}({\textcolor{black} {\neg {\ell}}}) \ \, \mathcal{D}({\textcolor{black} {\neg {\ell}}}) )\, : \beta \rangle$, we have: \begin{enumerate}[$-$] \item By {\em MinD}, \ $ \mathcal{F} \models \langle \ell \wedge \Pi \succ ({\textcolor{black} {\vee}} \ \, \mathcal{C}({\textcolor{black} {\neg {\ell}}}) \ \, \mathcal{D}({\textcolor{black} {\neg {\ell}}}) )\, :\mathrm{\bf min}\{\alpha,\beta\} \rangle$. \item Then, \ $ \mathcal{F} \models \langle \ell \wedge \Pi \succ ({\textcolor{black} {\vee}} \ \, \ell \wedge \mathcal{C}({\textcolor{black} {\neg {\ell}}}) \ \, \ell \wedge \mathcal{D}({\textcolor{black} {\neg {\ell}}}) )\, :\mathrm{\bf min}\{\alpha,\beta\} \rangle $. \item Since $ {\ell}\wedge\mathcal{C}( {\neg {\ell}} \,) \models \bot $ then, \ $ \ \mathcal{F} \models \langle \ell \wedge \Pi \succ {\ell}\wedge\mathcal{D}( {\neg {\ell}} \,) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle $. \item Then, \ $ \mathcal{F} \models \langle \ell \wedge \Pi \succ \mathcal{D}( {\neg {\ell}} \,) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle $. \item By {\em MinD}, \ $ \mathcal{F} \models \langle \Pi \succ \mathcal{D}( {\neg {\ell}} \,) : \mathrm{\bf min}\{\alpha,\beta\} \,\rangle $. \end{enumerate} \vspace{-.7cm} \end{niceproof} The next lemma states the correctness of the propositional rules of $ \mathcal{UR}_\Sigma $. \begin{lemma} \label{lem:propo-complet} Let $ \mathcal{UR}_P $ be the subset $\{\mbox{UR}_P, {\bf \bot} \vee, {\bf \bot} \wedge, \odot \phi, \odot \odot \} \subset \mathcal{UR}_\Sigma$. A propositional Horn-NC formula $ \varphi $ is inconsistent iff $ \mathcal{UR}_P $ with input $ \langle\varphi : \alpha\rangle$ derives some $ \langle \bot : \alpha\rangle$. \end{lemma} \begin{niceproof} We analyze below both directions of the lemma. \vspace{.1cm} $\bullet \ \Rightarrow $ Let us assume that $\varphi$ is inconsistent. Then $\varphi$ must have a sub-formula verifying the {\em $\mbox{UR}_P $} numerator; otherwise, all complementary pairs of literals $\ell$ and $\neg \ell$ are included in disjunctions. In this case, since all disjunctions of $ \varphi $, by definition of Horn-NC formula, have at least one negative literal, $ \varphi $ would be satisfied by assigning to all propositions the value $0$, which contradicts the initial hypothesis. Therefore, {\em $\mbox{UR}_P $} is applied to $ \varphi $ with two complementary literals $\ell$ and $\neg \ell$ and the resulting formula is simplified. The new formula is equivalent to $ \varphi $ and has at least one literal less than $ \varphi $. Hence, by induction on the number of literals of $ \varphi $, we obtain that $ \mathcal{UR}_P$ ends only when $ \langle (\vee ) : \alpha \rangle$ is derived. $ \bullet \Leftarrow$ Let us assume that {\em $ \mathcal{UR}_P $} has been iteratively applied until a formula $ \varphi' $ different from $ \langle (\vee ) : \alpha \rangle$ is obtained. Clearly, if the {\em $\mbox{UR}_P $} numerator is not applicable then there is not a conjunction of a literal $\ell$ with a disjunction including $\neg \ell$. Then we have, firstly, since {\em $ \mathcal{UR}_P $} is sound, that $ \varphi $ and $ \varphi' $ are equivalent. Secondly, if $\varphi'$ has complementary literals, then they are integrated in disjunctions. Thus $\varphi'$ is satisfied by assigning the value 0 to all its unassigned propositions, since, by definition of Horn-NC formula, all disjunctions have at least one negative disjunct. Therefore, since $\varphi'$ is consistent so is $\varphi$. \end{niceproof} The next lemma claims the correctness of $ \mathcal{UR}_\Sigma $. \begin{lemma} \label{lem:correctnessURSigma} Let $ \Sigma $ be a possibilistic Horn-NC base. $ \mathcal{UR}_\Sigma $ derives some empty clause $ \langle (\vee) : \alpha \rangle $ iff $ \Sigma $ is inconsistent, and if $ \mathcal{UR}_\Sigma $ derives $ \langle (\vee) : \alpha \rangle $ then $ \mbox{Inc}(\Sigma) \geq \alpha $. \end{lemma} \begin{niceproof} The propositional component of possibilistic NC unit-resolution verifies Lemma \ref{lem:propo-complet}, and hence, \ $ \mathcal{UR}_\Sigma $ derives an empty formula $ \langle (\vee) : \alpha \rangle$ iff the conjunction of the propositional formulas in the base $\Sigma $ is inconsistent, namely if $\Sigma^* $ is inconsistent. If $ \mathcal{UR}_\Sigma $ derives $ \langle (\vee) : \alpha \rangle$, then by Lemma \ref{lem:propo-complet}, $ \mathcal{UR}_\Sigma $ detects a subset $ \Sigma_1 \subseteq \Sigma $ which is indeed inconsistent. Then by Proposition \ref{prop:soundnessgeneral}, the degree $ \alpha$ found by $ \mathcal{UR}_\Sigma $ corresponds to $\mbox{Inc}(\Sigma_1) $. Since obviously $\mbox{Inc}(\Sigma_1) \leq \mbox{Inc}(\Sigma)$, the lemma holds. \end{niceproof} The next lemma states the correctness of the algorithm {\bf Find}. \begin{lemma} \label{lem:correctFind} If \,{\bf Find($ \Sigma, 0$)} returns $ \alpha $ then $ \mathrm{Inc}(\Sigma)=\alpha $. \end{lemma} \begin{niceproof} We denote $ \Sigma' $ and \mbox{\bf Inc} the variables of {\bf Find} in a given recursion. Let us prove that the next hypothesis holds in every call to \mbox{\bf Find}: $$ \Sigma_{> \mbox{\footnotesize \bf Inc}}= \Sigma' \mbox{\ \, and \ } \mbox{Inc}(\Sigma)= \mbox{max}\{\mbox{Inc}(\Sigma'), \mbox{\bf Inc}\} $$ -- We check that the initial call {\bf Find($ \Sigma, 0$)} verifies the hypothesis: \newpage \hspace{.5cm } - We have $ \Sigma'=\Sigma $ and \mbox{\bf Inc} = 0. \vspace{.15cm} \hspace{.5cm } - So indeed we have $\Sigma_{> 0}=\Sigma' $ and $\mbox{Inc}(\Sigma)= \mbox{max}\{\mbox{Inc}(\Sigma'),0\}= \mbox{Inc}(\Sigma) $ \vspace{.15cm} -- We prove that if the hypothesis holds for $ k \geq 1 $ then it holds for $ k + 1 $. \vspace{.15cm} -- First of all, $ \mathcal{UR}_\Sigma $ is applied to $ \Sigma' $. \vspace{.15cm} -- By Lemma \ref{lem:correctnessURSigma}, if $ \mathcal{UR}_\Sigma $ derives $ \langle \bot : \alpha \rangle$ then $ \mbox{Inc}(\Sigma') \geq \alpha$, else $ \Sigma' $ is consistent. \vspace{.15cm} -- {\em Case $ \Sigma' $ is consistent:} $\mbox{Inc}(\Sigma')=0 $. \vspace{.15cm} \hspace{.5cm} - By induction hypothesis $ \mbox{Inc}(\Sigma)= \mbox{max}\{\mbox{Inc}(\Sigma'), \mbox{\bf Inc}\}={\bf Inc}$ \vspace{.15cm} \hspace{.5cm} - So {\bf Find} correctly returns $ \mbox{Inc}(\Sigma) $ and ends. \vspace{.15cm} -- {\em Case $ \Sigma' $ is inconsistent:} $\mbox{Inc}(\Sigma')=\alpha > 0 $. \vspace{.15cm} \hspace{.5cm} - By induction hypothesis $\Sigma' =\Sigma_{> \mbox{\footnotesize \bf Inc}}$, and so $ \alpha > \mbox{\bf Inc} $. \vspace{.15cm} \hspace{.5cm} - The next $ \Sigma' $, noted $ \Sigma'' $, and {\bf Inc}, noted {\bf Inc'}, are $ \Sigma''=\Sigma'_{>\alpha} $ and {\bf Inc'}=$ \alpha $. \vspace{.07cm} \hspace{.8cm} We check in $(i)$ and $(ii)$ that the hypothesis holds: \vspace{.15cm} \hspace{.5cm} $(i)$ By induction hypothesis: $ \Sigma' =\Sigma_{> \mbox{\footnotesize \bf Inc}} $ \vspace{.15cm} \hspace{1.5cm} -- Since $ \alpha > \mbox{\bf Inc} $ then trivially $\Sigma'_{> \alpha}=\Sigma_{> \alpha}$ \vspace{.15cm} \hspace{1.5cm} -- Hence $\Sigma''=\Sigma'_{> \alpha} =\Sigma_{>\alpha}=\Sigma_{> \mbox{\footnotesize \bf Inc'}} $. \vspace{.15cm} \hspace{.5cm} $(ii)$ By Lemma \ref{lem:correctnessURSigma}, $ \mbox{Inc}(\Sigma') \geq \alpha $ \vspace{.15cm} \hspace{1.5cm} -- Since $ \Sigma'=\Sigma_{> \mbox{\footnotesize \bf Inc}}$ and $ \alpha > $ {\bf Inc} then $ \mbox{Inc}(\Sigma) \geq \alpha $ \vspace{.15cm} \hspace{1.5cm} -- Hence $ \mbox{Inc}(\Sigma)=\mbox{max}\{\mbox{Inc}(\Sigma_{>\alpha}), \alpha \}= \mbox{max}\{\mbox{Inc}(\Sigma''), \mbox{\bf Inc'} \}$ \vspace{.15cm} Altogether, the hypothesis holds until {\bf Find} finds $ \Sigma' $ consistent and then correctly returns $ \mbox{Inc}(\Sigma)$. Hence Lemma \ref{lem:correctFind} holds. \end{niceproof} The next three propositions prove that finding $\mbox{Inc}(\Sigma) $ of any Horn-NC $ \Sigma $ is polynomial. \begin{proposition} \label{propo:onesequence} If $ \Sigma $ is a possibilistic Horn-NC base, then $ \mathcal{UR}_\Sigma $ with input $ \Sigma $ performs at most $ n^2$ inferences, $ n$ being the number of symbols (size) of $ \Sigma $. \end{proposition} \begin{niceproof} On the one hand, each rule of $ \mathcal{UR}_\Sigma $ adds a formula $\langle \varphi : \alpha \rangle$, where $ \varphi $ is a sub-formula of a propositional formula $ \Pi $ of a possibilistic formula $\langle \Pi : \beta \rangle$ in the current base. Hence, the current base always contains only sub-formulas from $\Sigma $. On the other hand, the weight $ \alpha $ of added formulas $\langle \varphi : \alpha \rangle$ is the minimum of two weights in the current base. Hence, the weights of formulas in the current base always come from $\Sigma $. Thus, the maximum number of deduced formulas is $ m \times k $, where $ m $ is the number of sub-formulas in $ \Sigma $ and $ k $ is the number of different weights in $ \Sigma $. Hence, the maximum number of inferences performed by $ \mathcal{UR}_\Sigma $ is $ m \times k $. If $ n $ is the size of $ \Sigma $, then $ m,k \leq n $ and so the proposition holds. \end{niceproof} \begin{proposition} \label{propo:inferencesconsistency} If $ \Sigma $ is a possibilistic Horn-NC base, then {\bf Find}{\em ($\Sigma$,\,0)} performs at most $ n^2 $ recursive calls, $ n$ being the number of symbols of $ \Sigma $. \end{proposition} \begin{niceproof} {\bf Find} stops when it detects that the current base is consistent. If it is inconsistent then $ \langle (\vee) : \alpha \rangle $ is deduced, and for future calls, {\bf Find} cancels the set $ \{\langle \phi : \beta \rangle \ \vert \ \langle \phi : \beta \rangle \in \Sigma, \beta \leq \alpha\}$. This set trivially contains at least one formula as $ \langle (\vee) : \alpha \rangle $ has been derived. On the other hand and as discussed in the previous proof, the maximum number of inserted formulas in the base is at most $ m \times k $, where $ m $ is the number of sub-formulas in $ \Sigma $ and $ k $ is the number of different weights in $ \Sigma $. Thus, the number of performed recursive calls is at most $ m \times k $. Since $ m, k \leq n$, then Proposition \ref{propo:inferencesconsistency} holds. \end{niceproof} The next proposition states that the overall complexity to determine $\mbox{Inc}( \Sigma) $, $ \Sigma \in \mathcal{\overline{H}}_\Sigma $, is polynomial. \begin{proposition} \label{propo:complexity} If $ \Sigma $ is a possibilistic Horn-NC base, then computing $\mbox{Inc}( \Sigma) $ takes polynomial time, i.e. the class $ \mathcal{\overline{H}}_\Sigma $ is polynomial. \end{proposition} \begin{niceproof} On the one hand, by Propositions \ref{propo:onesequence} and \ref{propo:inferencesconsistency}, the number of performed: the hypothesis holds. inferences in each recursive call and the number of recursive calls are both polynomial. Hence the total number of inferences is polynomially bounded. On the other hand, it is not hard to find a data structure so that each inference in $ \mathcal{UR}_\Sigma $ can be polynomially performed w.r.t the size of $ \Sigma $. Therefore, the complexity to determine $ \mbox{Inc}(\Sigma) $ is polynomial. \end{niceproof} \noindent {\bf Remark.} Determining a tight polynomial degree of the worst-case complexity of computing a Horn-NC base, is planed for future work (see Section \ref{sec:relatedwork }). It should be mentioned that the polynomial degree of computing their counterpart Horn clausal bases has not been specified either. \section{Related and Future Work} \label{sec:relatedwork } In this section we briefly discuss related work in a number of possibilistic logical contexts and succinctly propose objectives towards which our future work can be oriented. \vspace{.3cm} $ \Box$ \underline{Discovering polynomial NC classes.} In propositional logic, the valuable contribution to clausal efficiency of the conjunction of Horn formulas and Horn-SAT algorithms is reflected by the fact that the highly efficient DPLL solvers embed a Horn-SAT-like algorithm, so-called Unit Propagation. Hence, searching for polynomial (clausal) super-classes of the Horn class in propositional logic has been a key issue for several decades towards improving clausal reasoning and has led to a great number of such classes being currently known: hidden-Horn, generalized Horn, Q-Horn, extended-Horn, etc. (see \cite{FrancoMartin09,Imaz2021horn} for short reviews). So it is arguable that, just as the tractable clausal fragment has helped to grow overall clausal efficiency, likewise widening the tractable non-clausal fragment would grow overall non-clausal efficiency. Indeed, inspired by such polynomial non-clausal classes, efficient non-clausal algorithms can be devised. Nevertheless, we stress that the current tractable non-clausal fragment is almost empty, which signifies a manifest disadvantage with respect to its clausal counterpart. We will extrapolate the previous argumentation to possibilistic logic and determine further NC subclasses whose inconsistency-degree computing have polynomial complexity. In our next work, we will search for polynomial classes obtained by lifting the possibilistic renameable (or hidden) Horn formulas to the NC level. \vspace{.3cm} $ \Box$ \underline{Designing low-degree polynomial algorithms.} As we have seen in Section \ref{sect:ProofsProperties}, the number of inferences required by $ \mathcal{UR}_\Sigma $ and the number of recursive calls to {\bf Find} are both bounded by $ O(n^2) $, where $ n $ is the symbol number of the input base. Also, all inferences in $ \mathcal{UR}_\Sigma $ can be reasonably performed in $ O(n) $. Altogether, the complexity of determining $ \mbox{Inc}(\Sigma) $ of Horn-NC bases is in $ O(n^5) $. This complexity, though polynomial, is of course no satisfactory for real-world applications where the size of formulas can be relatively huge. However no much care has been taken in the proofs of Section \ref{sect:ProofsProperties} because the goal was proving tractability, and so, first of all, a fine-grained analysis of complexity is pending. This analysis will permit likely to precise a tighter polynomial-degree complexity. Nevertheless, the work presented here should be resumed in order to notably decrease the polynomial-degree. Also, advances in several directions are obliged such as finding suitable data-structure and proposing optimized algorithms. Finally, we mention that this optimization effort has not been done so far in the clausal framework either. In fact, no explicit upper bounds of complexity algorithms that compute possibilistic clausal bases are available. \vspace{.3cm} $ \Box$ \underline{Combining necessity and possibility measures.} Our approach considers only necessity-valued formulas but it can be extended to bases where formulas can have associated a possibility or a necessity measure. Such logical context has already been studied by previous authors \cite{Hollunder95, Lang00,CouchariereLB08}. If a formula is possibility-valued $ \langle \varphi : \Pi(\varphi) \geq \alpha\rangle$ it can be converted into the follow: the hypothesis holds.ing necessity-valued formula $ \langle \neg \varphi : N(\neg \varphi) \leq 1- \alpha\rangle $. Hence, bases having both possibility and necessity formulas can be converted into equivalent necessity formulas, where the threshold $ \alpha $ is additionally accompanied by the indication of whether the formula must have a necessity level either greater or smaller than $ \alpha $. On the other side, resolution for possibility-necessity formulas is well-known \cite{DuboisP94, DuboisP04a, DuboisP14}, but its extension to the NC level towards defining a possibility/necessity NC unit-resolution calculus seems not to be trivial and is an open question. \vspace{.3cm} $ \Box$ \underline{Computing general NC bases:} Since $ \mathcal{\overline{H}}_\Sigma $ is an NC sub-class, computing arbitrary NC bases is a natural continuation of the presented approach. As said in the Introduction, real-world problems are generally expressed in NC form, and so clausal reasoning requires the usage of a previous NC-to-clausal transformation. However, such transformation is highly inadvisable as it increases the formula size and number of variables, and losses the logical equivalence and the formula's original structure. Besides the clausal form is not unique and how to guide the nondeterministic process towards a ''good'' clausal formula is not known. So, real-world efficiency is reached if formulas are computed in its original non-clausal form. Here we have favored non-clausal reasoning with contributions which particularly facilitate deduction based on resolution and DPLL. Brief discussions for future work related to how compute possibilistic general NC formulas by means of resolution and DPLL can be found below in the items \mbox{``$ \Box$ Defining NC Resolution''} and ``$ \Box$ Defining NC DPLL". \vspace{.3cm} $ \Box$ \underline{Developing NC logic programming.} Possibilistic logic programming has received notable attention, and in fact, after the pioneer work in \cite{DuboisLP91}, a number of approaches e.g. \cite{BenferhatDP93,AlsinetG00,AlsinetGS02,AlsinetCGS08} are available in the state-of-the-art. However, all of them focus exclusively on the clausal form and so are Horn-like programs where the body of rules is a conjunction of propositions and the head is a single proposition. Our future work in this research direction will be oriented to show that $\mathcal{\overline{H}}_\Sigma $ and $\mathcal{UR}_\Sigma$ allow to handle non-clausal logic programs, and more concretely: \noindent $(1)$ To conceive a language for {\em Possibilistic Non-Clausal Logic Programing} denoted $ \mathcal{LP}_\Sigma $. So, instead of Horn-like rules, in $ \mathcal{LP}_\Sigma $, one may handle Horn-NC-like rules wherein bodies and heads of rules are NC formulas with slight syntactical restrictions (issued from $\mathcal{\overline{H}}_\Sigma $). In fact, one can check that a rule with syntax $\langle \Pi \rightarrow \mathrm{Hnc} : \alpha \rangle$, where $ \Pi $ is an NC formula with only positive literals and Hnc is a Horn-NC formula, is indeed a possibilistic Horn-NC formula. Therefore a set of such kind of rules, i.e. a program, is a Horn-NC base. \noindent $(2)$ To answer queries with an efficiency qualitatively comparable to the clausal one, i.e. polynomial, which is possible thanks to the next two features: (i) an $ \mathcal{LP}_\Sigma $ program belongs to $\mathcal{\overline{H}}_\Sigma $ and $\mathcal{\overline{H}}_\Sigma $ is a polynomial class; and (ii) the bases in $\mathcal{\overline{H}}_\Sigma $ have only one minimal model, since, as aforementioned, they are equivalent to a Horn clausal formula. \vspace{.3cm} $ \Box$ \underline{Developing NC answer set programming.} After the works in possibilistic logic programming, a succession of works on possibilistic answer set programming has been carried out, started by \cite{NicolasGSL06} and continued with e.g. \cite{NievesOC07,NievesOC13,ConfalonieriNOV12,ConfalonieriP14,BautersSCV12,BautersSCV14}. Although, like in possibilistic logic programming, they also focus on the clausal form, there exists an exception as indicated in the Introduction. Indeed, NC possibilistic logic has been formerly dealt with by the auhors in \cite{NievesL12,NievesL15}. However, in this work no effectiveness issues are addressed. Instead, the authors extend, to possibilistic logic, proper concepts of non-clausal answer set programming within classical logic as originally defined in \cite{LifschitzTT99}; so their aim is distinct from ours. Our future work in this research direction will be oriented to show the scope of the expressiveness of the class $ \mathcal{\overline {H}}_\Sigma $ for possibilistic NC answer set programming and to analyze the efficiency allowed by $ \mathcal{\overline {H}}_\Sigma $. Although answering queries in possibilistic answer set programming is an intractable problem \cite{NicolasGSL06}, we do not rule out the possibility of finding tractable sub-classes. \vspace{.3cm} $ \Box$ \underline{Partially ordered possibilistic logic.} In this work we have assumed that possibility and necessity measures, which rank interpretations and formulas, were in the real unit-interval $[0, 1]$, i.e. the available information is supposed to be totally ordered. Thus for two different necessity values $ \alpha, \beta $, we have always that either $ \alpha > \beta $ or $ \alpha < \beta $. However, considering a more real-world context with only partial orders has already been studied \cite{BenferhatLP03,BenferhatLP04,CayrolDT14}. For instance, partial orders avoid comparing unrelated pieces of information, which happens when we merge multiple sources information and the merged pieces do not have a shared reference for uncertainty. So, considering a partial pre-order on interpretations by means of a partial pre-order on formulas is a more real-world scenario to which the presented method is planned to be generalized. \vspace{.3cm} $ \Box$ \underline{Casting richer logics into possibilistic logic}. In our logical framework, propositional logic is casted into possibilistic logic. Casting richer logics into possibilistic logic has already been carried out by several authors, for instance, Alsinet et al. \cite{AlsinetG00} cast G\"{o}del logic many-valued logic in a possibilistic framework and several researchers \cite{Hollunder95,CouchariereLB08,QiJPD11} do similarly with description logics. See reference \cite{DuboisP04a} to know other embeddings. Since the Horn-NC class has already been defined in \cite{Imaz21b} for regular many-valued logic, our next aim in this research line will be to embed regular-many-valued into possibilistic logic. Specifically, we will attempt to define the class of regular-many-valued possibilistic Horn-NC bases as well as to generalize other notions presented in this article such as defining regular-many-valued possibilistic NC Unit-resolution. An open question is whether polinomiallity is preserved when two uncertainty logics are combined within the non-clausal level. \vspace{.3cm} $ \Box$ \underline{Defining NC resolution}. The formalization of the existing NC resolution \cite{Murray82} (see also \cite{BachmairG01}) that dates back to the 1980s is somewhat confusing. Its functional-like definition has important weaknesses such as not precisely identifying the available resolvents or requiring complex formal proofs \cite{HahnleMurrayRosenthal04} of its logical properties. Another symptom of its barriers is that, contrary to our approach, it has not led so far, to define either NC unit-resolution or NC hyper-resolution. Our definition of NC unit-resolution is clausal-like because, as stated in Section \ref{sec:Non-Clausal-Unit-resolution}, in presence of clausal formulas, $ \mathcal{UR}_\Sigma $ coincides with clausal resolution \cite{DuboisP87, DuboisP90}. We believe that our kind of definition is fairly well oriented to define (full) NC Resolution and to generalize it to some uncertainty logics, and similarly, to be analyzed and to formally prove its logical properties. \vspace{.3cm} $ \Box$ \underline{Defining NC DPLL}. DPLL for possibilistic clausal formulas have already been studied \cite{DuboisP94, Lang00} but DPLL for possibilistic non-clausal formulas has received no attention. We argue below that the present article supposes an important step forward to specify the scheme NC DPLL for possibilistic logic. The principle of DPLL relies on: (1) the procedure Unit-Propagation; (2) a suitable heuristic to choice the literal $ \ell $ on which performs branching; and (3) the determination of the formulas $ \Sigma \wedge \ell $ and $ \Sigma \wedge \neg \ell $, namely the formulas on which DPLL should split the search. One can do the next observations: (1) NC Unit-Propagation is based on NC unit-resolution, and (2) formulas $ \Sigma \wedge \ell $ and $ \Sigma \wedge \neg \ell $ are obtained with NC unit-resolution. Hence, the unique aspect not studied here is that of the (2) heuristic to choice the branching literal. Thus, for future work, we will propose the DPLL schema for possibilistic non-clausal reasoning after studying heuristics and taking a closer look to other aspects presented in this article. \vspace{.3cm} $ \Box$ \underline{Generalized Possibilistic Logic} A restriction in standard possibilistic logic is that only conjunctions of weighted formulas are allowed. Dubois et al. \cite{DuboisPS12,DuboisPS17,DuboisP18} have conceived the Generalized Possibilistic Logic (GPL) in which the disjunction and the negation of standard possibilistic formulas are handled. In this logic, for instance the formula $ (\vee \ \ \langle \varphi : \alpha \rangle \ \ \langle \psi : \beta \rangle \,) $ belongs to the GPL's language, and since possibility-valued formulas are also smoothly embedded in GPL, formulas like the next one belong to GPL: $$ \{\wedge \ \ \langle (\vee \ P \ Q) : \mbox{N} \ {\bf 1} \rangle \ \langle \neg Q : \mbox{N} \ {\bf .75} \rangle \ \neg \langle (\vee \ \neg P \ R) : \mbox{N} \ {\bf 1} \rangle \ \ \ (\vee \ \langle \neg R : \Pi \ {\bf .75} \rangle \ \langle \varphi : \Pi \ {\bf .25} \rangle \ ) \ \}$$ One can see that in GPL, connectives can be internal or external (GPL is a two-tired logic) with their corresponding and different semantics, and also, GPL formulas can be expressed in NC form. In fact, observe that the previous formula is non-clausal. In \cite{DuboisPS17} the authors prove that the satisfiability problem associated to GPL formulas is $ \mathcal{NP} $-complete. It is clear that the standard possibilistic Horn formulas are encapsulated in GPL and so are the Horn-NC formulas defined here. We think that in GPL, sub-classes of external Horn formulas can also be defined, as well as sub-classes that are both internally and externally Horn. Thus GPL turns out to be an interesting logic in the sense that it embeds a variety of classes of Horn-like formulas which potentially could be lifted to the NC level. So for future work, we will study the different classes of Horn-NC GPL formulas that are definable and then attempt to prove their complexity. It will be challenging to determine when polymiality is preserved in the NC level. Of course, once we have mastered the solution of GPL Horn-NC-like formulas, the solving of unrestricted non-clausal GPL formulas can be envisaged by proposing inference and solving mechanisms. \vspace{.3cm} $ \Box$ \underline{Finding Models or Inconsistency Subsets.} Our method focuses on exclusively determining $ \mbox{Inc}(\Sigma) $. However, one important issue for increasing theoretical and practical interest is the obtaining of models or contradictory subsets of the knowledge. In some frameworks as for instance, when the knowledge base is not definitive and is in an experimentation phase, the only data of $ \mbox{Inc}(\Sigma) $ may be of not much help. For example, if one expects the knowledge base to be consistent and the consistency checker finds it is inconsistent, knowing the knowledge subset causing contradiction, called "witness" in the literature, can be necessary. Thus for future work, we will envisage deductive calculi oriented to providing witnesses as a return data. In this context, a more complicated problem is the determination of whether a knowledge base has exactly one model or one inconsistent subset, since determining if a problem has a unique solution is computationally more expensive than testing if has at least one solution (see \cite{Papadimitriu94}, Chapter 17). \section{Conclusions} As the encoding of practical problems is usually expressed in non-clausal form, restricting deductive systems to handle clausal formulas obliges them to use non-clausal-to-clausal transformations, which are very expensive in terms of: increase of formula size and number of variables, and loss of logical equivalence and original formula's structure. Further, the clausal form is not unique and however no insights are available to guide towards a ''good'' clausal form the non-clausal-to-clausal transformation. These drawbacks deprive clausal reasoning systems to efficiently perform in real-world applications. \vspace{.1cm} To overcome such limitations and avoid the costs induced by the normal form transformation, we process formulas in non-clausal form, concretely in negation normal form (NNF). This form allows an arbitrary nesting of conjunctions and disjunctions and only limits the scope of the negation connective. NNF can be obtained deterministically and solely causes a negligible, easily assumable increase of the formula size. \vspace{.1cm} Thus, along the lines of previous works in propositional and regular many-valued logics \cite{Imaz2021horn, Imaz21b}, we have extrapolated the previous argumentation to possibilistic logic, the most extended approach to deal with knowledge impregnated of uncertainty and presenting partial inconsistencies. Thus our first contribution has been lifting the possibilistic Horn class to the non-clausal level obtaining a new possibilistic class, which has been called Horn Non-Clausal, denoted $ \mathcal{\overline{H}}_\Sigma $ and shown that it is a sort of non-clausal analogous of the standard Horn class. Indeed, we have proven that $ \mathcal{\overline{H}}_\Sigma $ subsumes syntactically the Horn class and that both classes are semantically equivalent. We have also proven that all possibilistic NC bases whose clausal form is Horn belong to $ \mathcal{\overline{H}}_\Sigma $. \vspace{.1cm} In order to compute the inconsistency degree of $ \mathcal{\overline{H}}_\Sigma $ members, we have established the calculus Possibilistic Non-Clausal Unit-Resolution, denoted $\mathcal{UR}_\Sigma $. We formally proved that $\mathcal{UR}_\Sigma $ correctly computes the inconsistency degree of any $ \mathcal{\overline{H}}_\Sigma $ base. $ \mathcal{\overline{H}}_\Sigma $ was nonexistent in the literature and extends the propositional logic calculus given in \cite{Imaz2021horn} to possibilistic logic. \vspace{.1cm} After having specified $ \mathcal{\overline{H}}_\Sigma $ and $\mathcal{UR}_\Sigma$, we have studied the computational problem of computing the inconsistency degree of $ \mathcal{\overline{H}}_\Sigma $ via $\mathcal{UR}_\Sigma$ and determined that it is polynomial, and hence, $ \mathcal{\overline{H}}_\Sigma $ is the first found class to be possibilistic, non-clausal and polynomial. \vspace{.1cm} Our formulation of $\mathcal{UR}_\Sigma$ is unambiguously clausal-like since, when applied to clausal formulas, $\mathcal{UR}_\Sigma $ indeed coincides with clausal unit-resolution. This aspect is relevant in the sense that it lays the foundations towards redefining NC resolution in a clausal-like manner which could avoid the barriers caused by the existing functional-like definition (see related work). We believe that this clausal-like definition of NC resolution will allow to generalize it to some other uncertainty logics. \vspace{.1cm} Finally, in this work we also attempted to show that effective NC reasoning for possibilistic and for some other uncertainty logics is an open research field and, in view of our outcomes, we consider the presented research line is rather promising. A symptom of such consideration is the possibility of our method to be extended to different possibilistic logic contexts giving rise to a number of future research directions that were briefly discussed: \vspace{.1cm} Computing possibilistic arbitrary NC bases; discovering additional tractable NC subclasses; conceiving low-degree-polynomial algorithms; extending generalist possibilistic logic to NC; combining necessity and possibility measures; considering partially ordered possibility measures; developing possibilistic NC logic programming; developing possibilistic NC answer set programming; casting richer logics in possibilistic logic; defining possibilistic NC resolution; defining possibilistic NC DPLL; and finding models. \vspace{.15cm} Some of the above listed future objectives can also be searched in the context of other non-classical logics such as \L ukasiewicz logics, G\"{o}del logic, product logic, etc. \vspace{.3cm} \noindent {\bf Funding Source.} Spanish project ISINC (PID2019-111544GB-C21).
{'timestamp': '2021-11-16T02:30:06', 'yymm': '2111', 'arxiv_id': '2111.07648', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07648'}
arxiv
\section{Introduction} \vspace{-1.5ex} \label{sec:intro} Convolution is one of the most commonly used operators for computer vision applications \cite{he2016deep, ren2015faster, he2017mask}. However, recent studies \cite{hu2019local, parmar2019stand, Zhao2020ExploringSF, wang2020axial, dosovitskiy2021an} suggest that the convolution operator is unnecessary for computer vision tasks, and that the self-attention module \cite{vaswani2017attention} might be a better alternative. For example, Axial-DeepLab \cite{wang2020axial} built stand-alone self-attention models for image classification and segmentation. Although these attention-based models show promising results to take the place of convolution-based models, these attention-based models are all human-designed \cite{parmar2019stand, wang2020axial}, making it challenging to achieve optimal results on new dataset, tasks, or computation budgets. \begin{figure}[t] \centering \includegraphics[width=0.8\textwidth]{images/arch.pdf} \vspace{-2ex} \caption{Searched TrioNet A and D. Conv, Local and Axial denotes convolution, local-attention and axial-attention. $\times$1/2, $\times$1/4, $\times$1/8 are expansion rates. TrioNet consistently uses convolutions at low level and self-attention at high level. } \vspace{-3.5ex} \label{fig:searchedmodel} \end{figure} Given a target dataset, task, and computation budget, Neural Architecture Search (NAS) \cite{2017rlnas, Zoph2018LearningTA, Real2019RegularizedEF, liu2018darts, liu2018hierarchical, Pham2018EfficientNA, wu2019fbnet, efficientnet} is an efficient technology to automatically find desirable architectures with marginal human labor. Due to its effectiveness, previous works \cite{2017rlnas, liu2018darts, Pham2018EfficientNA, Cai2020Once-for-All:, Yu2020BigNASSU} have successfully applied NAS to different computer vision tasks, including object detection \cite{Wang2020NASFCOSFN, Ghiasi2019NASFPNLS}, semantic segmentation \cite{Liu2019AutoDeepLabHN}, medical image analysis \cite{Zhu2019VNASNA}, and video understanding \cite{Wang2020PVNASPN}. However, most of the searched models for these computer vision tasks are built upon convolutional neural network (CNN) backbones \cite{howard2017mobilenets, sandler2018mobilenetv2, howard2019searching}. Previous convolution-based NAS methods usually consider attention modules as plugins \cite{Li2020NeuralAS}. During the search procedure, the search algorithm needs to decide whether an attention module should be appended after each convolution layer. This strategy results in the searched network architecture majorly consisting of convolution operators, causing a failure to discover the potentially stronger attention-based models. Therefore, in this paper, we study how to search for combined vision models which could be fully convolutional or fully self-attentional~\cite{parmar2019stand, wang2020axial}. Specifically, we search for TrioNets where all three operators (local-attention~\cite{parmar2019stand}, axial-attention~\cite{wang2020axial}, and convolution) are considered equally important and compete with each other. Therefore, self-attention is no longer an extra plugin but a primary operator in our search space. Seemingly including the self-attention module into the search space could achieve our goal, we observe it is difficult to apply the commonly used weight-sharing NAS methods~\cite{cai2018proxylessnas,Cai2020Once-for-All:,Yu2020BigNASSU} due to two issues. One issue is that self-attention modules and convolution blocks make our search space much more complicated and imbalanced than convolution-only spaces~\cite{cai2018proxylessnas, Cai2020Once-for-All:, Yu2020BigNASSU}. For instance, convolution usually contains kernel size and width to search while self-attention have more options like query, key and value channels, spatial extent and multi-head numbers. The self-attention operators correspond to much larger search spaces than convolution, with the same network depth. This imbalance of self-attention and convolution's search space makes the training of supernets intractable. Therefore, we propose Hierarchical Sampling, which samples the operator first uniformly before sampling other architecture options. This sampling rule suits our setting better because it ensures an equal chance for each operator to be trained in the supernet, alleviating the bias of search space size. The other issue is that the multi-head design of attention operators poses a new challenge for weight-sharing \cite{Cai2020Once-for-All:, Yu2020BigNASSU} NAS algorithms. Current weight-sharing strategy \cite{Stamoulis2019SinglePathND, Cai2020Once-for-All:, Yu2020BigNASSU} always shares the first few channels of a full weight matrix to construct the weight for small models. However, in self-attention modules, the channels are split into multi-head groups to capture different dependencies \cite{vaswani2017attention}. The current weight-sharing strategy ignores the multi-head structure in the weights and allocates the same channel to different heads depending on the sampled multi-head groups and channels, forcing the same channel to capture different types of dependencies at the same time. We hypothesize and verify by experiments that such weight-sharing is harmful to the training of supernets. Instead, we share our model weights only if they belong to the same head in multi-head self-attention. This dedicated strategy is named Multi-Head Sharing strategy. We evaluate our TrioNet on ImageNet \cite{krizhevsky2012imagenet} dataset and various small datasets \cite{stanfordcars, fgvc, cub, caltech101, 102flowers}. The TrioNet architectures found on ImageNet are shown in \figref{fig:searchedmodel}. We observe that TrioNets outperform stand-alone convolution~\cite{he2016deep}, local-attention~\cite{parmar2019stand} and axial-attention \cite{wang2020axial} models with fewer FLOPs on ImageNet where self-attention performs better than convolution. On small datasets where self-attention models perform inferior to convolution, our TrioNet is still able to matche the best operator with fewer FLOPs on average. To summarize, our contributions are four-fold: (1) We regard self-attention and convolution as equally important basic operators and propose a new search space that contains both stand-alone self-attention models and convolution models. (2) In order to train a supernet on our highly imbalanced search space, we adopt Hierarchical Sampling rules to balance the training of convolution and self-attention operators. (3) A Multi-Head Sharing strategy is specifically designed for sharing weights in multi-head self-attention operators. (4) Our searched TrioNet reduces computation costs and improves results on ImageNet classification, compared with hand-designed stand-alone networks. The same phenomenon is observed when TrioNets are searched on small datasets as well. \vspace{-4ex} \section{Related work} \vspace{-1.5ex} \paragraph{Self-attention.} Self-attention was firstly proposed for NLP tasks \cite{bahdanau2014neural, wu2016google, vaswani2017attention}. People then successfully apply self-attention module to many computer vision tasks \cite{wang2018non,bello2019attention,chen20182,huang2019ccnet, zhu2019asymmetric, Cao2019GCNetNN}. More recently, it has been shown that self-attention can be used to replace convolution in vision models. Hu \emph{et al}\bmvaOneDot~\cite{hu2019local} and Local self-attention~\cite{parmar2019stand} build the whole model with self-attention restricted to a local patch. SAN \cite{Zhao2020ExploringSF} explores a boarder self-attention formulation. Axial-DeepLab \cite{wang2020axial} extends local self-attention to global self-attention with axial self-attention blocks. Later, ViT \cite{dosovitskiy2021an} approaches image classification with the original NLP transformer architecture. Variants \cite{Wu2021CvTIC, Han2021TransformerIT, Liu2021SwinTH, Yuan2021TokenstoTokenVT} of ViT propose a few hand-designed ways of applying local constraints to the global self-attention in ViT. In this paper, we automatically search for an architecture in a combined space that includes convolution, local self-attention~\cite{parmar2019stand}, and axial global self-attention~\cite{wang2020axial}. \paragraph{Neural Architecture Search.} Neural Architecture Search (NAS) was proposed to automate architecture design \cite{2017rlnas}. Early NAS methods usually sample many architectures and train them from scratch for picking up a good architecture, leading to large computational overhead \cite{2017rlnas, Zoph2018LearningTA, Real2019RegularizedEF, liu2018hierarchical, efficientnet, Cai2020Once-for-All:, Yu2020BigNASSU, sahni2021compofa}. More recently, people develop an one-shot pipeline by training a single over-parameterized network and sampling architectures within it to avoid the expensive train-from-scratch procedure \cite{2018understand, brock2018smash, liu2018darts, Pham2018EfficientNA, cai2018proxylessnas, Yu2019NetworkSB, Hu2020DSNASDN, Guo2020SinglePO, chu2021fairnas}. However, the search space of these methods is restricted in the MobileNet-like space \cite{howard2017mobilenets, sandler2018mobilenetv2, howard2019searching}. There are also some attempts to search for self-attention vision models \cite{Li2020NeuralAS, Wang2020AttentionNASSA, Li2021BossNASEH}. These works mainly focus on the single block design \cite{Wang2020AttentionNASSA} and positions \cite{Li2020NeuralAS}, or searches in a small space \cite{Li2021BossNASEH}. In this paper, self-attention and convolution are considered equally in our search space. \vspace{-4ex} \section{Method} \vspace{-1.5ex} In this section, we first define our operator-level search space that contains both convolution and self-attention. Next, we discuss our one-shot architecture-level search algorithm that trains a supernet. Finally, we present our proposed Hierarchical Sampling (HS) and Multi-Head Sharing (MHS) that helps training the supernet. \vspace{-3ex} \subsection{Operator-Level Search Space} \label{operator} \vspace{-1ex} Convolution is usually the default and the only operator for a NAS space \cite{2017rlnas, efficientnet, cai2018proxylessnas, Cai2020Once-for-All:, Yu2020BigNASSU}. In this paper, however, we introduce self-attention operators into our operator-level space and search for the optimal combination of convolution and self-attention operators \cite{vaswani2017attention}. Specifically, we include efficient self-attention operators that can be used as a stand-alone operator for a network. We use axial-attention \cite{wang2020axial} instead of fully connected 2D self-attention \cite{dosovitskiy2021an} as an instantiation of global self-attention for computational efficiency. \paragraph{Local Self-Attention.} Local self-attention~\cite{parmar2019stand} limits its receptive field to a local window. Given an input feature map $x \in \mathbb{R}^{h \times w \times d_{in}}$ with height $h$, width $w$, and channels $d_{in}$, the output at position $o=(i,j)$, $y_{o} \in \mathbb{R}^{d_{out}}$, is computed by pooling over the projected input as: \vspace{-1ex} \begin{equation} \vspace{-1.5ex} \label{eqn:standalone} y_{o} = \sum_{p \in \mathcal{N}_{m \times m}(o)} \text{softmax}_{p}(q_{o}^T k_{p} + q_{o}^T r_{p-o}) v_{p} \end{equation} where $\mathcal{N}_{m \times m}(o)$ is the local $m \times m$ square region centered around location $o=(i,j)$. Queries $q_{o}=W_Q x_{o}$, keys $k_{o}=W_K x_{o}$, values $v_{o}=W_V x_{o}$ are all linear projections of the input $x_{o}~\forall o \in \mathcal{N}$. $W_Q, W_K \in \mathbb{R}^{d_{q} \times d_{in}}$. $W_V \in \mathbb{R}^{d_{out} \times d_{in}}$ are all learnable matrices. The relative positional encodings $r_{p-o} \in \mathbb{R}^{d_{q}}$ are also learnable vectors and the inner product $q_{o}^T r_{p-o}$ measures the compatibility from location $p=(a,b)$ to location $o=(i,j)$. In practice, this single-head attention in \equref{eqn:standalone} is extended to multi-head attention to capture a mixture of affinities~\cite{vaswani2017attention}. In particular, multi-head attention is computed by applying $N$ single-head attentions in parallel on $x_{o}$ (with different learnable matrices $W_Q^n, W_K^n, W_V^n, \forall n \in \{1, 2, \dots, N\}$ for the $n$-th head), and then obtaining the final output $z_{o}$ by concatenating the results from each head, \emph{i.e}\bmvaOneDot, $z_{o}=\text{concat}_n(y^n_{o})$. The choice of local window size $m$ significantly affects model performance and computational cost. Besides, it is not clear how many local self-attention layers should be used for each stage or how to select a window size for each individual layer. For these reasons, we include local self-attention in our search space to find a good configuration \paragraph{Axial Self-Attention.} Axial-attention~\cite{wang2020axial,huang2019ccnet,ho2019axial} captures global relations by factorizing a 2D self-attention into two consecutive 1D self-attention operators, one on the height-axis, followed by one on the width axis Both of the axial-attention layers adopt the multi-head attention mechanism, as described above. Note that we do not use the PS-attention~\cite{wang2020axial} or BN~\cite{ioffe2015batch} layers for fair comparison with local-attention~\cite{parmar2019stand} and faster implementation. Despite capturing global contexts, axial-attention is less effective to model local relations if two local pixels do not belong to the same axis. In this case, combining axial-attention with convolution or local-attention is plausible. So we study the combination in this paper by including axial-attention into our operator-level search space. \vspace{-3ex} \subsection{Architecture-Level Search Space} \vspace{-1ex} \begin{table*}[bt] \footnotesize \centering \begin{tabular}{c c c c} \hline Operator & Convolution & Local Attention~\cite{parmar2019stand} & Axial Attention~\cite{wang2020axial}\\ \hline Expansion rates & 1/8, 1/4 & 1/4, 1/2 & 1/4, 1/2 \\ Kernel size & 3, 5, 7 & 3, 5, 7 & - \\ Query (key) channel rates & - & 1/2, 1 & 1/2, 1 \\ Value channels rates & - & 1/2, 1 & 1/2, 1\\ Number of heads & - & 4, 8 & 4, 8 \\ \hline Total choices (cardinality) & 6 & 48 & 16 \\ \hline \end{tabular} \caption{The imbalanced search space for each operator.} \label{tab:space} \vspace{-4ex} \end{table*} Similar to hand-designed self-attention models, Local-attention~\cite{parmar2019stand} and Axial-DeepLab~\cite{wang2020axial}, we employ a ResNet-like \cite{he2016deep} model family to construct our architecture-level search space. Specifically, we replace all 3$\times$3 convolutions by our operator-level search space that contains convolution, local-attention, and axial-attention. \tabref{tab:space} summarizes our search space for each block. Different from a cell-level search space in the NAS literature~\cite{Cai2020Once-for-All:, Yu2020BigNASSU}, our spatial operators are not shared in each residual block. As a result, our search space allows a flexible combination of different operators at each layer. This space also includes pure convolutional \cite{he2016deep}, pure local-attention \cite{parmar2019stand}, and pure axial-attention\cite{wang2020axial} ResNets. Our search space contains roughly $7.2 \times 10^{25}$ models in total, 3.6 M times larger than that of OFA \cite{Cai2020Once-for-All:} ($2 \times 10^{19}$). \vspace{-3ex} \subsection{Searching Pipeline} \vspace{-1ex} Given this search space, we employ the one-shot NAS pipeline \cite{Cai2020Once-for-All:, Yu2020BigNASSU}, where the entire search space is built as a weight-sharing supernet. The typical strategy~\cite{cai2018proxylessnas, Stamoulis2019SinglePathND} of most one-shot NAS works is shown in \figref{fig:blockmodel} a). A MobileNet-like~\cite{howard2017mobilenets, sandler2018mobilenetv2, howard2019searching} supernet is built with blocks that contain several parallel candidates with different channels and receptive fields. Consequently, the supernet needs a lot of parameters to hold the large search space, making it inapplicable to our huge search space (\tabref{tab:space}). OFA and BigNAS \cite{Cai2020Once-for-All:, Yu2020BigNASSU} propose to share candidate weights in a single block, as shown in \figref{fig:blockmodel} b). This allows a much larger search space with manageable parameters but it still limited one operator only. In our case, different spatial operators can not share all the parameters. Based on these works \cite{cai2018proxylessnas, Cai2020Once-for-All:, Yu2020BigNASSU}, we make a step forward. We insert local-~\cite{parmar2019stand} and axial-~\cite{wang2020axial} attention into the single block parallel with the spatial convolution as the primary spatial operator. These parallel spatial operators share the same projection layers and increase the flexibility of the supernet without introducing many parameters. Like \cite{Cai2020Once-for-All:, Yu2020BigNASSU}, we can formulate the problem as \vspace{-1.5ex} \begin{equation} \vspace{-2ex} \label{eqn:training} \min _{W_{o}} \mathbb{E}_{\alpha \sim \Gamma(\mathcal{A})}[\mathcal{L}_{\text {train}}\left(C\left(W_{o}, \operatorname{\alpha}\right)\right)] \end{equation} where $\left(C\left(W_{o}, \operatorname{\alpha}\right)\right)$ denotes that the selection of the parameters from the weights of the supernet $W_{o}$ with architecture configuration $\alpha$, $\Gamma(\mathcal{A})$ is the sampling distribution of $\alpha \in \mathcal{A}$ and $\mathcal{L}_{\text {train}}$ denotes the loss on the training dataset. After training the supernet, an evolutionary algorithm is used to obtain the optimal model ${\alpha}_{o}$ on the evolutionary search validation dataset with the goal as \vspace{-1ex} \begin{equation} \vspace{-1ex} \label{eqn:search} {\alpha}_{o} = \underset{\alpha}{\operatorname{argmin}}\mathcal{L}_{\text {val }}\left(C\left(W_{o}, \operatorname{\alpha}\right)\right) \end{equation} Finally, we retrain the searched model from scratch on the whole training set and validate it on the validation set. Next, we discuss two issues of the default supernet training pipeline and our solutions. \begin{figure}[t] \centering \includegraphics[width=0.7\textwidth]{images/block.pdf} \vspace{-2ex} \caption{{\bf Supernet candidate sampling.} Left: ProxylessNAS-style \cite{cai2018proxylessnas}. Middle: OFA-style \cite{Cai2020Once-for-All:}. Right: our TrioNet with shared projection layers and three separate parallel operators.} \vspace{-4ex} \label{fig:blockmodel} \end{figure} \vspace{-3ex} \subsection{Hierarchical Sampling} \vspace{-1ex} \label{samplingstrategy} Previous work~\cite{wang-etal-2020-hat} trains supernets by sampling candidates uniformly. However, as shown in \tabref{tab:space}, our search space candidates are highly biased towards the local-attention operator, leading to an imbalanced training of the operators and worse performance of the searched model. Therefore, we propose Hierarchical Sampling (HS). For each block, we first sample the spatial operator uniformly. Given the operator, we then randomly sample a candidate from the operator space. We can formulate this as \vspace{-1.5ex} \begin{equation} \vspace{-1.5ex} \label{eqn:hs} \alpha = (\beta, \theta), \beta \sim \mathcal{U}(\mathcal{B}), \theta \sim \mathcal{U}(\Theta) \end{equation} where the architecture $\alpha$ can be expressed as operators configuration $\beta \in \mathcal{B}$ sampled from \tabref{tab:space} (the first row) and weights configuration $\theta \in \Theta$ sampled from \tabref{tab:space} (from the second to the sixth row) with uniform distribution $\mathcal{U}$. In this way, we ensure an equal sampling chance for all operators. In addition, we notice that the training is biased towards middle-sized models. We attributes this to the fact that the search space is full of middle-sized models and thus random sampling trains mostly middle-sized models. To address this issue, we use Sandwich rule~\cite{Yu2019UniversallySN, Yu2020BigNASSU} that samples the smallest candidate, the biggest candidate and 2 random candidates. Sandwich rule is adopted in our Hierarchical Sampling after the operator for each block is selected. \vspace{-3ex} \subsection{Multi-Head Sharing} \vspace{-1ex} \begin{figure}[tb] \hspace{2ex} \begin{minipage}[c]{0.5\textwidth} \includegraphics[width=0.95\linewidth]{images/weight_sharing.pdf} \end{minipage} ~~ \begin{minipage}[c]{0.37\textwidth} \caption{{\bf Multi-Head Sharing.} Previous: The default weight-sharing samples the second output channel sometimes for head 1 (top) and sometimes for head 2 (bottom). Ours: Our proposed Multi-Head Sharing samples all channels consistently according to the multi-head structure.} \label{fig:weightsharing} \end{minipage} \vspace{-1em} \end{figure} The weight-sharing strategy for convolution has been well studied. Previous works \cite{Stamoulis2019SinglePathND, Yu2020BigNASSU, Cai2020Once-for-All:, Bender2020CanWS} share common parts of a convolution weight for different kernel sizes and channels. However, this strategy cannot be simply applied to our search space with multi-head self-attention operators. The varying number of heads makes sharing channels more complicated than convolution. In multi-head attention, the channels are split into multi-head groups to capture different dependencies~\cite{vaswani2017attention}. Thus, as shown in \figref{fig:weightsharing}, the default weight-sharing strategy allocates the same channels for different multi-head groups, which is harmful to the supernet training. To deal with this issue, we propose Multi-Head Sharing (MHS). As shown in \figref{fig:weightsharing}, we take into account the multi-head structure and first split all output channels into number-of-head groups. Then, we share channel weights only if they belong to the same head in multi-head self-attention. We show the selection procedure with PyTorch-like \cite{paszke2019pytorch} pseudo code in Alg. \ref{algo:mhs}. In this way, we ensure that different channel groups do not interfere with each other. \vspace{-1em} \begin{algorithm}[H] \caption{Pseudo code of Multi-Head Sharing in a PyTorch-like style} \algsetup{linenosize=\tiny} \scriptsize \PyComment{w: weight matrix, c\_in: in channels}\\ \PyComment{c\_out: max out channels, s\_c\_out: sampled out channels, n: multi-head number} \\ \PyCode{h\_c = s\_c\_out / n}\\ \PyCode{w = w.reshape(n, -1, c\_in)} \\ \PyCode{w = w[:, :h\_c, :]} \PyComment{h\_c, n, c\_in}\\ \PyCode{w = w.reshape(s\_c\_out, c\_in)} \\ \PyCode{return w} \\ \label{algo:mhs} \vspace{-1em} \end{algorithm} \vspace{-2em} \vspace{-2ex} \section{Experiments} \vspace{-0.5ex} Our main experiments are conducted on ImageNet \cite{krizhevsky2012imagenet} dataset. We also provide detailed ablation studies on the proposed Hierarchical Sampling and Multi-Head Sharing. Finally, we evaluate the adaptation of our searching algorithm on various small classification datasets. \vspace{-3ex} \subsection{ImageNet Classification} \vspace{-1ex} \tabref{tab:cls} shows the main results of our searched models with different FLOPs constraints. The searched models are compared with stand-alone convolution \cite{he2016deep}, stand-alone local self-attention~\cite{parmar2019stand} and stand-alone axial-attention~\cite{wang2020axial} models. As shown in \figref{fig:acc}, with 2B FLOPs budget, our TrioNet-A achieves 74.8\% accuracy and outperforms ResNet with 57.4\% less computation. With 3B FLOPs budget, our TrioNet-B achieves 75.9\% accuracy, which outperforms stand-alone local self-attention and axial-attention respectively with 33.3\% and 14.3\% fewer FLOPs. These results show that our searched TrioNet is able to outperform all hand-designed single-operator networks in terms of computation efficiency. In addition to our main focus in the low computation regime, we also evaluate models in the high computation regime. With 4B and 4.7B FLOPs budgets, our TrioNet-C and TrioNet-D achieve comparable performance-FLOPs trade-offs with stand-alone axial-attention and still outperforms fully convolution \cite{he2016deep} or local self-attention~\cite{parmar2019stand} methods with fewer FLOPs. Compared with OFA \cite{Cai2020Once-for-All:} under the same training settings as ours, TrioNet outperforms OFA with 1.1\%, 0.2\%, 0.2\% and 0.3\% accuracy with 16.7\%, 11.8\%, 13.0\% and 2.1\% less computation. Note that the larger models (TrioNet-C and TrioNet-D) are already close to the limit of our architecture space, which might lead to performance degrade. If large models instead of lightweight models are desired, our TrioNet searching pipeline can be directly extended to a high computation search space as well. \vspace{-3ex} \subsection{Ablation Studies} \vspace{-1ex} \begin{figtab}[t] \begin{minipage}[c]{.49\linewidth} \includegraphics[width=0.9\textwidth]{images/plot_flops.pdf} \figcaption{Comparing Top-1 accuracy vs. FLOPs on ImageNet classification.} \label{fig:acc} \end{minipage} \begin{minipage}[c]{.49\linewidth} \footnotesize \centering \begin{tabular}{c cc c} \hline \textbf{Model} & \textbf{Params} & \textbf{FLOPs} & \textbf{Top-1} \\ \hline ResNet-26 \cite{he2016deep, parmar2019stand} & 13.7M & 4.7B & 74.5 \\ ResNet-38 \cite{he2016deep, parmar2019stand} & 19.6M & 6.5B & 76.2 \\ ResNet-50 \cite{he2016deep, parmar2019stand} & 25.6M & 8.2B & 76.9 \\ OFA-A \cite{Cai2020Once-for-All:} \footnotemark[1]\global\let\saved & 9.6M & 2.4B & 73.7 \\ OFA-B \cite{Cai2020Once-for-All:} \footnotemark[1]\global\let\saved & 14.4M & 3.4B & 75.7 \\ OFA-C \cite{Cai2020Once-for-All:} \footnotemark[1]\global\let\saved & 19.2M & 4.6B & 76.6 \\ OFA-D \cite{Cai2020Once-for-All:} \footnotemark[1]\global\let\saved & 20.7M & 4.8B & 76.8 \\ \hline Local-26 \cite{parmar2019stand} & 10.3M & 4.5B & 75.8 \\ Local-38 \cite{parmar2019stand} & 14.1M & 5.7B & 77.1 \\ Local-50 \cite{parmar2019stand} & 18.0M & 7.0B & 77.4 \\ Axial-26 \cite{wang2020axial} \footnotemark[2]\global\let\saved & 5.9M & 3.5B & 75.5 \\ Axial-38 \cite{wang2020axial} \footnotemark[2]\global\let\saved & 8.7M & 4.4B & 77.1 \\ Axial-50 \cite{wang2020axial} \footnotemark[2]\global\let\saved & 12.4M & 5.6B & 77.8 \\ \hline TrioNet-A & 5.1M & 2.0B & 74.8 \\ TrioNet-B & 9.4M & 3.0B & 75.9 \\ TrioNet-C & 10.6M & 4.0B & 76.8 \\ TrioNet-D & 10.9M & 4.7B & 77.1 \\ \hline \end{tabular} \tabcaption{Results on ImageNet classification.} \label{tab:cls} \end{minipage} \vspace{-3ex} \end{figtab} \footnotetext[1]{Our retrained results.} \footnotetext[2]{Our retrained models removing some BN and positional encoding.} In this subsection, we provide more insights by ablating each of our proposed components separately. The experiments are also performed on ImageNet~\cite{krizhevsky2012imagenet}. We monitor the training process of the supernets by directly evaluating the largest possible model for each operator. \paragraph{Hierarchical Sampling.} \figref{fig:dwssampling} a) visualizes the supernet training curves with and without our proposed Hierarchical Sampling. We observe that sampling all candidates uniformly hurts convolution models a lot due to the low probability of convolution being sampled. However, with our proposed Hierarchical Sampling, all the model results are improved. It is worth mentioning that with our Hierarchical Sampling strategy, the local self-attention~\cite{parmar2019stand} models are improved too, even if they are not sampled as often as the case without Hierarchical Sampling. We hypothesize that the comparable performances of all three parallel candidates help the optimization of all operators. \paragraph{Multi-Head Sharing.} \figref{fig:dwssampling} b) compares the training process of the supernet with and without our proposed Multi-Head Sharing. We observe that our Multi-Head Sharing strategy helps large multi-head self-attention models achieve higher accuracy. Similar curves are observed for small models as well, though the curves are omitted in the figure. In addition to the training curves of the supernet, we also analyze the searched model results. As shown in \tabref{tab:abla}, adopting Multi-Head Sharing in the supernet training improves the searched architecture by 1.5\%, from 75.4\% to 76.9\%. \paragraph{Sandwich rule.} \figref{fig:sand} a) plots the training curves with and without Sandwich rule~\cite{Yu2019UniversallySN, Yu2020BigNASSU}. It shows that Sandwich rule helps the training of large models by a large margin for all operators. \figref{fig:sand} b) shows the distribution of the sub-models selected from the supernet under different strategies. It can be observed that some middle-sized models are comparable with the biggest models because they are trained more and gain a lot from the large models optimization \cite{Yu2020BigNASSU}. However, this accuracy partial order cannot reflect the training from scratch accuracy, and the searched model accuracy in \tabref{tab:abla} also shows this. With Sandwich rule, the sampling distribution is changed and the ranking of these models are kept. \paragraph{Number of epochs.} Weight-sharing NAS methods require a long supernet training schedule because the candidates need to be well-trained before they can accurately reflect how good each candidate is. Similarly, we evaluate how our TrioNet searching algorithm scales with longer training schedules. As shown in \figref{fig:abla} a), our searched models does not perform well with 20 epochs and 60 epochs, probably because the candidates have not been well-trained with such a short schedule. However, we do not observe a huge difference between 180 epochs and 540 epochs, probably because our supernet saturates with our simple ResNet-like training recipe and the weak data augmentation used. \paragraph{Amount of data.} Our TrioNet searching algorithm is also tested with different amount of data. To achieve this goal, we train the supernets with 10k, 100k images and the full training dataset (we still remove the evolutionary search set). Then, the searched architectures are still trained from scratch on the full training set. In this way, we evaluate only the contribution of data on the searching algorithm, or the quality of the searched architecture, which is decoupled with the amount of data used to the searched models from scratch. \figref{fig:abla} b) shows that the searching on only 10k images gives a poor architecture, and our searching algorithm scales well, \emph{i.e}\bmvaOneDot, finds better architectures, with more data consumed. \begin{figure}[t] \begin{tabular}{cc} \centering \quad \; \includegraphics[width=0.35\textwidth]{images/hsample.pdf}\quad \quad \quad & \includegraphics[width=0.35\textwidth]{images/dws.pdf}\vspace{-1ex} \\(a) Effect of Hierarchical Sampling. & (b) Effect of Multi-Head Sharing. \\ \end{tabular} \caption{Hierarchical Sampling and Multi-Head Sharing helps the training of the supernet.} \vspace{-2ex} \label{fig:dwssampling} \end{figure} \begin{figure}[t] \begin{tabular}{cc} \quad \; \includegraphics[width=0.35\textwidth]{images/sand.pdf} \quad \quad \quad & \includegraphics[width=0.35\textwidth]{images/sand_curve.pdf} \\(a) Better large models. & (b) Worse middle-sized models. \\ \end{tabular} \caption{Effect of Sandwich rule to the supernet training.} \label{fig:sand} \vspace{-2ex} \end{figure} \paragraph{Summary.} \label{sec:ablaacc} \begin{table*}[tb] \footnotesize \centering \begin{tabular}{ccccc|cc} \hline \textbf{Settings} & \textbf{Sandwich} & \textbf{HS} & \textbf{MHS} & \textbf{Epochs} & \textbf{FLOPs (B)} & \textbf{Acc (\%)}\\ \hline Random model & - & - & - & - & 4.8 & 74.7 \\ \hline w/o Sandwich & & \checkmark & \checkmark & 180 & 3.6 & 74.9 \\ w/o HS & \checkmark & & \checkmark & 180 & 3.5 & 75.6 \\ w/o MHS & \checkmark & \checkmark & & 180 & 5.1 & 75.4 \\ Ours & \checkmark & \checkmark & \checkmark & 180 & 5.2 & 76.9 \\ \hline Ours w/ more epochs & \checkmark & \checkmark & \checkmark & 540 & 4.7 & \textbf{77.1} \\ \hline \end{tabular} \caption{Comparison of searched models under different searching settings.} \label{tab:abla} \vspace{-4ex} \end{table*} \tabref{tab:abla} summarizes the searched model accuracies of our ablated settings. We notice that without Sandwich rules \cite{Yu2019UniversallySN, Yu2020BigNASSU}, the searched model only achieves 74.9\% accuracy with 3.6B FLOPs, which is a middle-sized model. This indicates that the sandwich rules prevent our searching from biasing towards middle-sized models. Besides, our proposed Hierarchical Sampling shows 1.3\% performance gain on the searched model and Multi-Head Sharing strategy promotes the searched model with 1.5\% accuracy improvement. Furthermore, we also test a random model with the comparable size as the searched model, which only gets 74.7\% accuracy. Our NAS pipeline achieves 2.4\% improvement compared with the random model. \begin{figure}[t] \begin{tabular}{cc} \quad \; \includegraphics[width=0.35\textwidth]{images/epoch.pdf} \quad\quad\quad & \includegraphics[width=0.35\textwidth]{images/dataset.pdf} \\(a) Varying number of epochs & (b) Varying number of images \end{tabular} \caption{TrioNet architectures become better if searched with more epochs and images.} \label{fig:abla} \vspace{-1.5ex} \end{figure} \vspace{-3ex} \subsection{Results on Small Datasets} \vspace{-1ex} The goal of NAS is to automate the architecture design on the target data, task, and computation budget. From this perspective, we adapt our TrioNet NAS algorithm to other datasets beyond ImageNet~\cite{krizhevsky2012imagenet}, in order to evaluate if the algorithm is able to find a good architecture on the target datasets. These adaptation experiments are performed on five small datasets: Stanford Cars \cite{stanfordcars}, FGVC Aircraft \cite{fgvc}, CUB \cite{cub}, Caltech-101 \cite{caltech101} and 102 Flowers \cite{102flowers}. \paragraph{Overall Performance.} \begin{table*}[tb] \vspace{-2ex} \footnotesize \centering \begin{tabular}{c|cc|cc|cc|cc} \hline \multirow{3}{*}{\textbf{Dataset}} & \multicolumn{2}{c|}{\textbf{ResNet-18}} & \multicolumn{2}{c|}{\textbf{Local-26}} & \multicolumn{2}{c|}{\textbf{Axial-26}} & \multicolumn{2}{c}{\textbf{TrioNet}} \\ & \textbf{FLOPs} & \textbf{Acc} & \textbf{FLOPs} & \textbf{Acc} & \textbf{FLOPs} & \textbf{Acc} & \textbf{FLOPs} & \textbf{Acc} \\ & (B) & (\%) & (B) & (\%) & (B) & (\%) & (B) & (\%) \\ \hline Stanford Cars & 3.6 & 86.8 & 4.5 & 84.4 & \textbf{3.5} & 78.2 & 3.7 & \textbf{88.5} \\ FGVC Aircraft & 3.6 & 79.8 & 4.5 & \textbf{82.4} & 3.5 & 74.4 & \textbf{2.9} & 82.1 \\ CUB & 3.6 & \textbf{69.3} & 4.5 & 65.2 & 3.5 & 58.9 & \textbf{2.4} & 68.4 \\ Caltech-101 & 3.6 & \textbf{75.3} & 4.5 & 71.4 & 3.5 & 66.1 & \textbf{2.4} & 72.2 \\ 102 Flowers & 3.6 & \textbf{91.4} & 4.5 & 87.7 & \textbf{3.5} & 81.9 & 3.6 & 90.3 \\ \hline Average & 3.6 & \textbf{80.5} & 4.5 & 78.2 & 3.5 & 71.9 & \textbf{3.0} & 80.3 \\ \hline \end{tabular} \caption{Comparison with stand-alone models on different datasets.} \label{tab:dataset}\vspace{-3ex} \end{table*} \begin{table*}[tb] \vspace{-1ex} \footnotesize \centering \setlength{\tabcolsep}{1.3mm} \begin{tabular}{c|ccc|ccc|ccc|c} \hline \textbf{Settings} & \multicolumn{3}{c|}{\textbf{ResNet-18}} & \multicolumn{3}{c|}{\textbf{Local-26}} & \multicolumn{3}{c|}{\textbf{Axial-26}} & \textbf{TrioNet w/ supernet weights}\\ \hline \textbf{Survival Prob} & 1.00 & 0.80 & 0.33 & 1.00 & 0.80 & 0.33 & 1.00 & 0.80 & 0.33 & -\\ \hline \textbf{Stanford Cars} & 86.8 & 85.7 & 81.5 & 84.4 & 83.5 & 82.7 & 78.2 & 81.7 & 79.7 & \textbf{87.7} \\ \textbf{FGVC Aircraft} & 79.8 & 78.6 & 73.8 & \textbf{82.4} & 75.8 & 72.9 & 74.4 & 74.0 & 74.6 & 80.5 \\ \hline \end{tabular} \caption{Regularization effect of supernet training and stochastic depth.} \label{tab:joint} \vspace{-2ex} \end{table*} \tabref{tab:dataset} shows the results of our TrioNet models searched directly on various small datasets \cite{stanfordcars, fgvc, cub, caltech101, 102flowers} and finetuned from supernet weights, as well as the accuracies of baseline models. Empirically, we notice that axial-attention~\cite{wang2020axial}, which outperforms ResNet~\cite{he2016deep} by a large margin on ImageNet~\cite{krizhevsky2012imagenet}, performs poorly on these small datasets with a big gap to ResNet (8.6\% accuracy on average), probably because the global axial-attention uses less induction bias than convolution or local-attention. However, in this challenging case, our TrioNet finds a better architecture than the hand-designed local self-attention~\cite{parmar2019stand} and axial self-attention~\cite{wang2020axial} methods. On these datasets, TrioNet is able to match the performance of the best operator, convolution in this case, with 20\% fewer FLOPs. This result, together with our ImageNet classification result, suggests that TrioNet robustly finds a good architecture no matter what operator the target data prefers. \paragraph{Regularization Effect.} Our sampling-based supernet training, where we sample an operator and then sample a candidate in the supernet, is similar to stochastic depth~\cite{huang2016deep} with a survival probability of 0.33 for each operator. Therefore, we compare our TrioNet (weights directly copied from the supernet) with stand-alone models of various survival probability on Stanford Cars \cite{stanfordcars} and FGVC Aircraft \cite{fgvc}, as shown in \tabref{tab:joint}. We notice that most stand-alone models perform worse with stochastic depth \cite{huang2016deep}. However, our TrioNet with its weights directly sampled from the supernet still outperforms these stand-alone models on Stanford Cars \cite{stanfordcars}. This suggests that the joint training of different operators is contributing to the performance as a better regularizer than stochastic depth \cite{huang2016deep}. \vspace{-3ex} \subsection{Results on Segmentation Tasks} \vspace{-1ex} \begin{table*}[tb] \footnotesize \centering \begin{tabular}{c|cc|cccc} \hline \multirow{2}{*}{\textbf{Backbone}} & \multicolumn{2}{c|}{\textbf{Semantic Segmentation}} & \multicolumn{4}{c}{\textbf{Panoptic Segmentation}}\\ & FLOPs & $mIoU$ & FLOPs & $PQ$ & $PQ^{Th}$ & $PQ^{St}$\\ \hline ResNet-50 \cite{he2016deep} & 66.4B & \textbf{71.2} & 97.1B & 31.1 & 31.8 & 29.9 \\ Axial-26 \cite{wang2020axial} & 33.9B & 67.5 & 60.4B & 30.6 & 30.9 & 30.2 \\ TrioNet-B & \textbf{29.6B} & 69.3 & \textbf{52.3B} & \textbf{31.8} & \textbf{32.4} & \textbf{30.8} \\ \hline \end{tabular} \caption{Comparison on segmentation tasks.} \label{tab:seg} \vspace{-2ex} \end{table*} In this section, we evaluate TrioNet on semantic segmentation \cite{long2015fully, deeplabv12015} and panoptic segmentation \cite{kirillov2018panoptic} tasks. The ImageNet pretrained models are employed. For semantic segmentation, we apply DeepLabV3 \cite{chen2017deeplabv3} on PASCAL VOC datasets \cite{voc10}. For panoptic segmentation, we perform the experiments on COCO datasets \cite{lin2014microsoft} with Panoptic-DeepLab \cite{cheng2019panoptic} under a short training schedule. All experiments only replace the backbone with TrioNet-B. \paragraph{Results.} \tabref{tab:seg} shows the semantic segmentation and panoptic segmentation results. Using TrioNet-B as the backbone outperforms Axial-26 \cite{wang2020axial} by 1.8\% mIoU on semantic segmentation with 12.7\% less computation. On panoptic segmentation, TrioNet-B outperforms Axial-26 \cite{wang2020axial} by 1.2\% $PQ$ with 13.4\% fewer FLOPs. \vspace{-3.5ex} \section{Conclusion} \vspace{-2ex} In this paper, we design an algorithm to automatically discover optimal deep neural network architectures in a space that includes fully self-attention models~\cite{parmar2019stand, wang2020axial}. We found it is not trivial to extend the conventional NAS strategy \cite{Cai2020Once-for-All:, Yu2020BigNASSU} directly because of the difference between convolution and self-attention operators. We therefore specifically redesign the searching algorithm to make it effective to search for self-attention vision models. Despite our observation is from studying the self-attention module, we believe this is readily to extend to searching for other components such as normalization modules~\cite{ioffe2015batch}. \FloatBarrier
{'timestamp': '2021-11-16T02:26:41', 'yymm': '2111', 'arxiv_id': '2111.07547', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07547'}
arxiv
\section{Introduction} \label{intro} Among a society of equals, decisions affecting members' lives are of the utmost importance. Accordingly, in the pre-AI age, it was a widely accepted---but unfortunately less widely practiced---principle that society should entrust carefully selected human decision-makers with such choices. Ideally, those positions would be associated with strict requirements on appropriate expertise and moral integrity, as well as rigorous accountability mechanisms, to provide sufficient assurance for society to trust the judgment of those in charge. Over time, however, technological innovation has enabled the automation of a growing number of tasks in, e.g., production processes, transport, and the information and communication sector. Successful attempts of automation radically improved human performance, significantly raising humanity's welfare and continuously changing our way of life. Most episodes of innovation have entailed more or less severe temporary disruptions until the economy adjusted to the effects of innovation, society has become familiar with the new technologies in question and either grew to trust them or rejected their adoption due to negative experiences. Recent leaps in computing capabilities coupled with the availability of large data sets and breakthroughs in \emph{machine learning} (ML)---a prominent subset of AI approaches, which employs algorithms that rely on a variety of methods to build machine-interpretable knowledge representations---have now ushered in a new era of innovation: One, in which ML-based algorithmic data-driven decision-making systems (A3DMs) are assuming an increasing role in making decisions across diverse domains reaching from lending~\cite{Aziz2019}, insurance, and housing to college admissions~\cite{Jamison,Thomas16}, hiring~\cite{Chalfin2016}, and the justice system~\cite{Kugler2018,Heidari2019}. On the bright side, such AI systems can easily map humanly untraceable correlations, outperforming their human counterparts. Better results in cancer diagnosis in healthcare~\cite{LITJENS201760} and correcting potentially substandard performance of human judges who \begin{quote} \emph{``effectively under-weight key observable variables like prior criminal record''}~\cite{Kleinberg2017} \end{quote} are just two examples of the benefits ML-assisted decisions can provide. The flip side of the coin is, however, that ML-based AI systems are prone to learn biases present in training data and incorporate systematic error, which are unacceptable where their decisions crucially affect human lives~\cite{Osoba2017AnII}. In part, this is an inevitable by-product of their inductive-learning nature, but there are many other sources of problems. For instance, for various reasons, exploiting big-data sets with ML\/ tools can lead to discriminatory models that issue unfair decisions~\cite{Corbett2018}. Moreover, \emph{Adversarial examples}---i.e, inputs where the ML\/ systematically produces the wrong answer although humans would easily perform correctly~\cite{athalye2017synthesizing,brown2017adversarial}---are an issue with deep neural network-based classifiers. Some architectures also tend to get very opaque, and it is particularly challenging to design and train systems in a manner that aligns with human values~\cite{Gunning_Aha_2019}. Academic literature and a wide range of domestic and international policy documents are striving to put forward proposals to alleviate these problems: Topics in the focus of attention include algorithmic fairness and transparency~\cite{Lee2019}, explainability~\cite{Holzinger2018,miller2019,rudin2019}, human-in-the-loop~\cite{Amershi2014,vandenelzen2011}, human-centric and ethical design of AI systems~\cite{OECD2019,IEEE2019}, legal liability~\cite{EE2020}, and many more aspects contributing to the trustworthiness of AI technologies~\cite{Ustun2019,LD2020,EUReport,EC2020,EMCCD2020,FFLT2020,MR2020}. The current perspective is that AI applications---like other machines---are but mere tools lacking moral agency~\cite{SK2018,FES2020} and legal personality~\cite{CK1994}. Thus, any harm they may bring about is by definition the result of human stakeholders' poor design or misuse, for which these human actors rather than the artificial agents are responsible~\cite{SW2020}. Still, it is interesting to look into when exactly we would deem an AI system fair or ethical. Even before the advent of AI, views on the right or ethical behavior in any given situation have been varying widely across different ethical theories, cultures, and time dimensions. Most of these differences have proven themselves to be virtually insurmountable and persist to date. Somewhat reassuringly, however, we understand the mathematical principles of AI technologies and can---as long as the prior probabilities of new cases are known and remain unchanged---accurately estimate their precision in unseen cases within the same context. But there are substantial technical limits to instilling moral values into AI systems. The challenges have been epitomized by the so-called \emph{value alignment problem} that requires AI to be deployed with moral values aligned with those of humanity. Various proposals have been put forward advocating the design of AI systems that are capable to reason about the virtue of their actions~\cite{Hall} or otherwise exhibit moral agency~\cite{Adam2008,FuenmayorB20,Wallach}. Some commentators propose to supply AI with moral-decision making ability using deontic reasoning~\cite{Young1995,BringsjordGMS18} or conceptual spaces. An example for the latter approach is the idea to construct a geometric space of moral principles and solved ethical cases and make decisions by finding the Voronoi cell for a given situation~\cite{Peterson2019}. This can be either categorized as case-based reasoning~\cite{Sriram1997} or instance-based learning~\cite{Witten}. Thus, challenges arise both when determining (1) which and how many dimensions suitably conform the moral space and (2) what specific metrics should be used to find the nearest solved moral situation or principle. These examples illustrate that, at present, technical solutions to the value alignment problem are significantly incomplete. Others advocate that ML\/ should incorporate equal opportunity by design. This suggestion is based on a series of proposals on various notions of fairness and/or non-discrimination such as \emph{independency constraints}~\cite{Calders2009}, \emph{group and individual fairness}~\cite{Zemel2013}, \emph{equality of odds}~\cite{Hardt2016}, and \emph{predictive value parity}~\cite{Kleinberg2017measure}. Apart from practical obstacles of implementing such fairness criteria in the design of algorithms, this begs the question of which notion of fairness, if any, deserves priority. Again, opinions differ, with some rejecting the idea altogether, arguing that ethics always implies human choice~\cite{Vallor2018}, hence machines should never be allowed to meddle with human affairs~\cite{Rosenberg2004}. The use of AI in legal processes is also heavily criticized~\cite{Piccolo2018}. This diversity of views introduces additional layers of complexity in the debate, making the prospect of international consensus rather remote. In this paper, we do not aim to include the full spectrum of AI approaches and all the possible ways in which they may affect human lives. Instead, we only deal with ML-based AI systems that perform supervised classification tasks. This is because, even before the emergence of deep-learning, most ML\/ and data mining deployments center around classification tasks~\cite{Wutop10AI}: Fields, such as computer vision~\cite{Himanshu} and Internet of Things~\cite{Cui2018}, are dominated by applications that build and deploy classifiers. Supervised model training is the core method to master classification tasks in specific industrial settings, such as construction~\cite{HONG2020109831}. We only consider moral choices made by such AI systems, i.e., voluntary, reasoned choices that affect others~\cite{Quinn}. That said, we do not attempt to go to the bottom of centuries-long, intricate, moral debates and how these may or may not apply to ML-based AI systems. The reason for this is that an ethical decision---on whatever ethical basis---is only conceivable under a full-information assumption at the time of decision-making. However, virtually all settings in which reliance on AI decision-making is necessary are characterized by some degree of uncertainty (the outcome is typically in the future)---indeed, the presence of uncertainty is the very reason for using AI predictive systems. Against this background---without addressing specific moral justifications---we model moral decisions of artificial agents in a game-theoretic manner with the objective to arrive at two conclusions. Our first conclusion proposes that there exist random classifiers that perform at least as well as their deterministic piers, making them the optimal choice of classifier in some settings. This finding is significant, as humanity's notion of \emph{automation} has so far been predominantly deterministic: Automation has been practically equivalent to determinism, in that machines are considered to be deterministic devices implementing functions, whereby from a given state and input only one successor state is possible, unless the machine is malfunctioning (e.g., if we push button ``5'' in an elevator, we expect it to drop us off at the 5th floor of the building, not some unpredictable level). Similarly, the vast majority of supervised ML literature~\cite{Bishop,Hastie,Mitchell1997,Michie95} considers the search for a classifier a search for a \emph{mathematical function}, and therefore implemented by a deterministic algorithm that consistently produces the same output from a given input~\cite{Hastie}. \begin{quote} \emph{``Our goal is to find a useful approximation $f'(x)$ to the function $f(x)$ that underlies the predictive relationship between the inputs and outputs''}~\cite{Hastie}. \end{quote} \emph{Feedback-loop controllers} are also crucially defined as functions---to each specific input, there is only one output---\cite{AstromMurray}, and robot safety has been equivalent to robots consistently keeping their distance and stopping fast enough when people are around~\cite{Malm2019}. For our second conclusion, we argue that in a game-theoretic model of the interactions of the decision-making AI and other rational agents, the AI may only be able to behave optimally---i.e., so as to yield a Nash Equilibrium---if it follows a mixed strategy, that is, a randomized algorithm. This follows from the fact that games are guaranteed to have a Nash Equilibrium only in the space of mixed-strategies. Also, by equating settings with incomplete information to the game of matching pennies, we show that any pure strategy the AI may adopt would be sub optimal. Moreover, pure strategies, when used repeatedly, can---and eventually will---be exploited by other (human) agents, which seek to selfishly maximize their own utility. Thus, mixed strategies are the most suitable strategies when decision makers face repetition (i.e., repeated games)~\cite{GeckilAnderson}. Therefore, paradoxically, it would seem that in certain situations, a truly ethical, fair, and trustworthy AI must behave randomly and gamble with our faith, regardless of which ethical theory and/or notion of fairness it is basing its actions on. This is not to say that we are opposed to the idea that automated decision-making systems have strong ethical foundations. On the contrary, these play a crucial role in our models. However, we argue that within those moral frameworks, there exist situations, in which fairness may dictate randomized choices. Accordingly, the focus of this paper is not so much on any particular notion of fairness and/or ethical theory as on the conditions under which random decisions are unavoidably necessary and what they imply. Accepting the premise that trustworthy AI must act randomly under specific conditions has certain profound implications. First, we will need to revise our deterministic notion of automation. Doing so will require a fundamental mindset change---be it in the general public, businesses, academia, or among policymakers. This will not be easy to achieve. That said, reassuringly, there is already some recognition that randomization cannot be simply equated with erratic, irrational, unpredictable, uncontrollable, and hence irresponsible actions, but is a very much rational---sometimes even optimal---behavior~\cite{GeckilAnderson}: \begin{quote} \emph{``Game theory models, by definition, focus on the effects of one party's decision on another's interest. Such decisions are not random ones. We assert this is true even when an opponent follows a `mixed strategy' that includes the use of random actions, because the choice to use randomization as the basis for an action is a specific decision itself, not a random event.'' } \end{quote} As we pointed our earlier, the field of machine ethics~\cite{Moor2006,Wallach} has also adopted that an explicit ethical agent must display rationality by logical argumentation and justify moral decisions with some form of cognition~\cite{Serafimova}. However, others are critical of this position~\cite{Allen}. \begin{quote} \emph{``What we don't want to do is make the stronger claim that the whole of cognition is just theorem proving, model finding, expectation maximization, or some similarly general inference procedure''}~\cite{Bello2013}. \end{quote} We emphasize that game theory solutions explicitly consider the rationality of all decision-makers: One player's decision process takes account of those of other players'. Rationality is thus not only relevant to game theory, but also constitutes a form of theory of mind~\cite{cuzzolin_morelli_cirstea_sahakian_2020,premack_woodruff_1978}. Such modeling of others for moral decision-making is also present in debates on machine ethics~\cite{Clark2010,Bello2013}. To the best of our knowledge, only a few papers have discussed game theory as a mechanism for moral agency~\cite{Hall}. We explore this matter further in Subsection~\ref{TheCaseForMixedStrategies} where we examine mixed strategies. Colman uses game theory to discuss Kant's categorical imperative and other ethical matters~\cite{Colman99}. This discussion shows that game theory concepts are useful to refine philosophical arguments. However, Colman's presentation fails to consider mixed strategies to debate issues such as the universality of and balance between altruist and selfish behavior~\cite{Colman99}. Second, accepting that trustworthy AI may have to act randomly also offers an opportunity to reflect on the appropriate levels of transparency requirements for AI systems. Although random classifiers are somewhat less susceptible to exploitation, we later show that transparency may raise issues even here. Finally, we face an implementation problem: Under the current state of art of technology it is debatable whether true randomness can be achieved. We report a empirical study consisting of a series of surveys to test the public's attitude towards randomized artificial decision-makers. Our results show that despite the above mentioned difficulties of implementing randomized AI systems, humans do not seem to be particularly concerned about machines randomly deciding over various aspects of their lives. On the contrary, they often prefer machine-made decisions over human decisions. The rest of the paper is structured as follows: Section~\ref{Prelims} presents the necessary notations to make a case for our argument that in certain situations, AI systems need to use randomized algorithms to behave optimally. Section~\ref{Results} outlines our results. Section~\ref{ImplandPol} considers certain implementation and policy issues that arise from the use of random classifiers. Section~\ref{casestudy} presents our empirical study, and Section~\ref{Conclusion} concludes. \section{Preliminaries} \label{Prelims} In this section, we outline some basic ML\/ and game theory notions necessary for our purposes, as well as notations we will use throughout this paper. For a detailed overview of ML\/ see~\cite{Bishop,Hastie,Mitchell1997,Witten} and on cooperative and non-cooperative game theory, see~\cite{Hespanha,Myerson97,rot:b:economics-computation}. \subsection{Machine Learning} The most dominant application of AI technologies by several indicators and by several orders of magnitude is ML~\cite{Columbus}. For instance, \$28.5 billion USD was invested in machine learning applications in the first calendar quarter of 2019, leading all other AI investment categories~\cite{Columbus}. \emph{Supervised learning} is the family of ML\/ algorithms that enables a computer system to receive labeled data and produce another algorithm---called a \emph{classifier} in case of classification tasks or more generally a \emph{model} for other tasks---that will obtain accurate predictions when supplied unlabeled data. More precisely, assume we have a large data set $C=\{ c_{1},\ldots,c_{n}\}$ of cases. For each case $c_{i}$ we have a vector (also known as \emph{attribute or feature vector}) $\vec{x}_{i} \in \mathbb{R}^d$ of values for some properties. We also have a \emph{label} or \emph{class} $\mbox{\cal A}(c_{i})$, where $\mbox{\cal A}(c_{i})\in \{A_{1},\ldots,A_{k} \}$. If the set of possible labels is finite, we face a classification task, if it is infinite, a regression task. The most common formulation of the \emph{induction principle}~\cite{CherkasskyM98} for supervised learning is to minimize the cost of misclassification---i.e., maximize accuracy---in \emph{unseen cases}. The latter are sometimes also referred to as \emph{cases in the future}~\cite{Hastie} or \emph{cases outside the training set} $C$. In any case, the classifier's job is to complete the missing information (provide the label) for an unlabeled case. Statistical decision theory~\cite{Hastie} analyzes the accuracy in the future as follows~\cite{Michie95}\footnote{We chose an early reference on ML\/ terminology to ensure is compatible with all recent developments, but others~\cite{Hastie} offer similar notation and treatment.}: We assume that there is a prior probability $\pi_j$ for each class $A_j$. That is, $\pi_j=\mbox{Prob}(A_j)$ means that the chances of running into a case whose label is $A_j$ in the future is given by $\pi_j$. The ML\/ algorithm will build a classifier $M$ that will map the vector $\vec{x}_{c}$ (of attribute values of case $c$) into a label $M( \vec{x}_{c} ) \in \{A_{1},\ldots,A_{k} \}$. Every time $M( \vec{x}_c ) \neq \mbox{\cal A}(c)$, the classifier $M$ commits a misclassification error that has a cost $\kappa(c,M( \vec{x}_c ))$. If $M$ ignores all information about a case, i.e., ignores the attributes $\vec{x}_c$, and deterministically chooses the class $A_d$ for all inputs, it incurs a cost of \[ \sum_{j} \pi_j \kappa(c_j,d), \] where $c_j$ denotes a case in class $A_j$. Choosing within the family of models that ignore all evidence and information about a case can be optimized and the optimal model (under uniform miss-classification costs) in the family responds with the class with the highest prior probability. ML\/ generally also involves a heuristic search algorithm within a typically very large family of models to find the member of the family that optimizes accuracy estimators and potentially other structural properties. We usually do not know the $\pi_j$'s---otherwise there is little learning to do. Continuing with our discussion, ML\/ algorithms do deliver classifiers that examine and use the evidence, i.e., the attributes $\vec{x}_c$ of case $c$. The relevant probability now is the conditional probability $\mbox{Prob}(A_{j} | \vec{x}_c )$ of the class $A_j$ being the correct class when we observe $\vec{x}_c$ in the input case $c$. Thus, to identify the model of minimum cost, this should be conditional on the information $\vec{x}$. Now, when $M$ decides $A_d$ when the evidence is $\vec{x}$, the expected cost is \begin{equation} E[[M\mbox{ decides } A_d ]] = \sum_{j} \mbox{Prob}(A_j | x) \kappa(j,d), \label{costRaw} \end{equation} where $\kappa(j,d)$ is the cost of miss classifying as $A_d$ when the case actually belongs to $A_j$. Using Bayes theorem, \begin{equation} \mbox{Prob}(A_j | x) = \pi_j \frac{ \mbox{Prob} ( x | A_j) } {\sum_s \pi_s \mbox{Prob}(x | A_s) }. \label{Bayes} \end{equation} However, since $ \sum_s \pi_s \mbox{Prob}(x | A_s)$ is a constant, we can simplify Equation~(\ref{Bayes}) and then replace $\mbox{Prob}(A_j | x)$ in Equation~(\ref{costRaw}). We conclude that deciding on $A_d$ has a cost of \begin{equation} \sum_{j} \pi_j \kappa(j,d) \mbox{Prob} ( x | A_j), \end{equation} modulo a constant factor that is the same for all $d\in \{1,\ldots,k\}$. Under the assumption that these are continuous distributions where the probability density function is $f_{j}(\vec{x})= f(\vec{x} | A_j)$, the optimum is the $d\in \{1,\ldots,k\}$ where \begin{equation} \sum_{j} \pi_j \kappa(j,d) f_{j} ( \vec{x}) \label{Distributions} \end{equation} is minimum. In the case of discriminating between two classes $j_1$ and $j_2$ ($k=2$) and $\kappa(j_1,j_1)=\kappa(j_2,j_2)=0$, Equation~(\ref{Distributions}) reduces to $M$ declaring class $A_{j_1}$ if \[ \frac{ f_{j_1}( \vec{x} ) }{f_{j_2}( \vec{x}) } > \frac{ \pi_{j_2} \kappa(j_1,j_2) } { \pi_{j_1} \kappa(j_2,j_1)}. \] The classifier $M$ should declare $A_{j_2}$ otherwise. This is a fundamental likelihood ratio all supervised ML\/ algorithms are attempting to optimize---commonly even assuming $\kappa(j_1,j_2)= \kappa(j_2,j_1)$. We now interpret this result examining some simple cases. Consider not only $k=2$ but $\kappa(j_1,j_2)=1$ when $j_1 \neq j_2$. Moreover, we will assume $ \pi_{j_1}= \pi_{j_2} =1/2$. That is, we have a balanced mixture from where our cases are drawn, and with equal probability we have a case from class $A_{j_1}$ or class $A_{j_2}$. If we do not look at the evidence, choosing $M$ as a constant function will make errors $50\%$ of the time (the two classifiers in the family of constant functions are as good or as bad). If the classifier can examine the evidence $\vec{x}$ and we know $f_{j_1}( \vec{x})$ and $f_{j_2}( \vec{x})$, the optimal classifier is given by \begin{equation} M( \vec{x} ) = \left\{ \begin{array}{ll} A_{j_1} & \mbox{if } f_{j_1}( \vec{x}) > f_{j_2}( \vec{x}), \\ A_{j_2} & \mbox{if } f_{j_2}( \vec{x}) > f_{j_1}( \vec{x}). \end{array} \right. \end{equation} This should be intuitively clear. In fact this leads to \emph{Fisher's Linear Discriminant} being the optimal classifier if the environment draws classes from a mixture of two multivariate normal distributions with \begin{enumerate} \item equal diagonal covariance matrices $\Sigma = \lambda I_{d}$ and \item equal weights, i.e., $1/2$ each. \end{enumerate} If we have a mixture of more than two classes but all the weights equal to $1/k$ and all covariance matrices are again diagonal matrices with the value $\lambda$ in the diagonal, the optimal classifier is the $k$-nearest neighbor that, on vector $\vec{x}$, declares the class where the mean $\vec{\mu}_{j}$ is nearest to $\vec{x}$. One way to visualize this last case is to note that the multidimensional bell shape of the multivariate normal \[ \mbox{\cal N}(\mu,\Sigma) = (2 \pi)^{-d/2} det( \Sigma)^{-1/2} e^{-\frac{1}{2} (\vec{x}-\vec{\mu})^{T} \Sigma^{-1} (\vec{x}-\vec{\mu})} \] will have level curves that are spheres around $\mu$ and $f_{j_s}( \vec{x}) > f_{j_t} ( \vec{x})$ if $\vec{x}$ is closer to $\vec{\mu}_{j_s}$ than to $\vec{\mu}_{j_t}$. Note that when $\Sigma = \lambda I_{d}$ for each class, $(\vec{x}-\vec{\mu})^{T} \Sigma^{-1} (\vec{x}-\vec{\mu})$ is the Euclidean metric scaled by the same factor for all components of the mixture. \subsection{Game theory} At present, the vast majority of artificial decision-makers operating in all sorts of industrial settings are constructed by applying supervised ML. There are huge data sets of labeled cases and digital records of attributes. The classes are decisions---for instance whether or not to award credit to a customer based on the data indicated in their credit application. Some of these decisions have ethical consequences because they impact individuals' well-being. At the extreme, classifiers as autonomous machines may have to make life-and-death decisions (e.g., targeting decisions of autonomous weapon systems and \emph{trolley problem} type of scenarios~\cite{Foot1967}, where the classifier has to decide whether to harm individual(s) $X$'s or individual(s) $Y$'s welfare). In such cases, it is of paramount importance to make the right decision, so the question arises: How can such algorithms make optimal choices? Game theory---which studies conflict and cooperation between rational agents---is helpful to answer that question. A \emph{game} abstracts the fundamentals involved in decision-making---such as agents' possible moves, actions, choices, and decisions---and formalizes \emph{rationality} as acting to maximize \emph{utility}. Games can be either cooperative---where agents form factions in order to maximize their utility---or non-cooperative---where agents do not coordinate their actions. This paper only uses non-cooperative settings where one agent is the \emph{environment} (or \emph{future}), which clearly cannot cooperate. It is common to apply game theory with such an adversary to achieve \emph{robust designs}~\cite{Hespanha}. Given a game, a solution is to determine the most rational decision each agent should reach. Importantly, all information for making the decision is represented in the modeling of the game---if there was more information, we would be discussing a different game. The game also identifies the decision-makers or influencers as \emph{players} and all options available to them---typically a set of exclusive decisions. Formally, in a game with $p$ agents, for each agent $P_i$, $1\leq i \leq p$, there is a set $D_i$ that defines agent $i$'s set of possible decisions it can pick. The elements of this universe of decisions are called \emph{pure strategies}. The solution of the game is the set of strategies that each agent must perform to maximize their individual utility. In a game with $p$ players, the value each player will receive when all players have declared their decision is specified ahead by \emph{payoff functions} (sometimes also called the \emph{payoff matrix}). These are typically a set of functions $u_{j}(d_{1},\ldots,d_{p})$ that provide the utility to player $P_j$, $j \in \{1,\ldots,p\}$, when each player $P_i$ makes decision $d_{i}$, for all $i\in\{1,\ldots,p\}$. From very early on in the study of game theory, it was observed that players can also use \emph{mixed strategies}. A mixed strategy is a randomized algorithm, i.e., a probability distribution over the possible pure strategies. A \emph{Nash equilibrium} is a solution that suggests the ultimate rational behavior for agents: It implies that---even if other players' decision-making strategies became known to them---none of the players $P_i$ would have any incentive to change their behavior. That is, in a Nash equilibrium, every player selects its strategy and cannot do better even if other players disclose theirs: For every player $P_j$, despite knowing the choice $d_{i}$ for all other players $j\neq i$, changing their choice $d_j$ cannot increase the value of $u_{j}(d_{1},\ldots,d_{p})$. An alternative characterization is that, in a Nash equilibrium, a player's choice is the best response to the others' best-responses (and this is true for each player). While every finite game has a Nash equilibrium with mixed-strategies, a Nash equilibrium with pure-strategies may not exist. A very famous illustration of game theory applicable to many cultures is the game \emph{rock, paper, scissors}. Here, each player makes a decision selecting one from the set $D= \{ \mbox{\emph{rock}}, \mbox{\emph{paper}}, \mbox{\emph{scissors}} \}$. The choices are simultaneous. \emph{Scissors} cut \emph{paper}, \emph{rock} breaks \emph{scissors}, and \emph{paper} covers \emph{rock}. Using the pure mathematical formulation of the game, it is clear that programming a machine to play this game deterministically is vulnerable to exploitation after inspection---there is no Nash equilibrium with pure strategies. However, a mixed strategy---a randomized algorithm that selects one of the three pure strategies with probability $1/3$---will win the same number of times as it ties or loses. This results in zero expected utility, which happens to be the optimum. It follows that, facing an opponent using a randomized strategy, it is best to use the same mixed-strategy as the opponent. \subsection{Equal Opportunity Principle} As emphasized earlier, for artificial decision-makers to be trustworthy and fair, they must base their decisions on some ethical theory and/or notion of fairness. When learning a classifier to enable their decision-making capability, AI systems need to convert some ethical principle(s) and/or fairness notion(s) into a formulation of the costs $\kappa$ of miss-classification. Similarly, the payoff functions of games modeling the interactions of the decision-making AI and its environment are ideally defined based on some ethical principle(s) and/or fairness notion(s). In line with our focus on the necessity and implications of randomized classifiers that employ mixed strategies, rather than debating the vices and virtues of different fairness concepts and ethical theories, we will adopt the principle of \emph{equality of opportunity (EOP)}. The reason for our choice is that the EOP is a central ideal of fairness studied in political philosophy and economics, which has been suggested to be a generalization of several measures of fairness for ML~\cite{Heidari2019}. We remark again that \emph{statistical parity}~\cite{Feldman2015}, \emph{equality of odds}~\cite{Hardt2016} \emph{equality of accuracy}~\cite{BuolamwiniG18}, and \emph{predictive value parity}~\cite{Kleinberg2017measure} can be regarded as particular forms of EOP~\cite{Heidari2019}. Essentially, the EOP aims to establish an initial level playing field---equality of opportunity---among individuals based on their innate qualifications rather than exogenous factors. At the same time, it allows for competition between individuals for different positions. This may result in different \emph{outcomes}, which are morally acceptable as long as they reflect individuals' \emph{merit} or \emph{deservingness}. Thus, the EOP distinguishes between morally acceptable and unacceptable inequality. Note that merit is highly contested~\cite{McCRUDDEN} and many question whether providing true equal opportunity is feasible in practice~\cite{Fishkin}. These concerns are particularly relevant for AI systems, which typically perform moral decisions based on incomplete information: With all likelihood, they do not consider all attributes of merit or measure merit accurately, all of which impairs their ability to precisely ascertain the differences in opportunity. But we need not deal with these problems here: What matters for our argument that AI decisions must use randomization is not \emph{what} particular ethical principle/fairness notion we use, but rather \emph{that} we need to use one of them. This is because, reliance on some ethical principle---in our case the EOP---is instrumental to, given a case $c$, defining $d$ attributes and their values that define the vector $\vec{x}_{c}\in \mathbb{R}^{d}$ for the AI classifier to make decision $M( \vec{x}_{c})$. Consider the example of a sentencing decision made by an AI system. In deciding the length of time in prison, merit attributes would be considered: What degree of remorse has the offender shown, how did their actions impact the victim(s), was the offense intentional and premeditated or rather reactive and emotional? These would constitute attributes of merit, ultimately determining the length of the sentence. Alternatively, in an AI-assisted parole hearing or release assessment, the application of the EOP may lead to considering attributes of (positive) merit like good behavior and increased educational level. These examples illustrate the role of ethical principles, such as the EOP, in dictating the dimensions (attributes) of the vector for an AI-based system to make a decision. They also give a feel for what we mean by incomplete information: At the time of sentencing, the AI-judge has to make a decision in the absence of the valuable hindsight that is available from the data to the AI-judge at the time of the parole hearing. In Appendix~\ref{EOPintro}, we reproduce the instructions to the subjects of our empirical study and the background on the EOP that was supplied to them. \section{The Case for Non-Deterministic Classifiers} \label{Results} Although randomization (non-determinism) is prevalent in mathematics, computer science, and artificial intelligence, we believe that the focus on deterministic classifiers derives from the tradition to perform the analysis of misclassification error using statistical decision theory~\cite{Hastie}. As we already explained, such analysis formulates that classifiers should be mathematical functions, selected by the learning process from families of functions~\cite{CherkasskyM98}, and thus deterministic mappings from inputs to outputs reflecting the \emph{decision boundaries}~\cite{HandSmythMannila} in the classes. This view of classifiers as functions reflecting decision boundaries~\cite{DudaHart} or decision surfaces~\cite{Bishop} is pervasive across models, whether it is artificial neural networks~\cite{Beale1990NeuralC}, support vector machines~\cite[Page~2]{cristianini_shawe-taylor_2000}, conceptual learning~\cite{Langley}, or decision-tree learning~\cite{Thornton}. \subsection{Random Classifiers May Be Optimal} \label{RandomCassifiers} Despite the predominantly deterministic approach towards automation so far, we argue that randomized algorithms~\cite{MotwaniR97} are mathematically valid families from which to infer and implement classifiers. We describe a simple case in which a randomized algorithm is optimal, i.e., no ML\/ algorithm can produce a deterministic classifier with less misclassification cost. \begin{proposition} There exist settings where randomized classifiers are optimal, i.e., no other classifier learned by any supervised learning technique can deliver a classifier with less misclassification cost. \end{proposition} \begin{proofs} Consider a scenario where the evidence is just one value $x \in \mathbb{R}$ (i.e., a vector of dimension $d=1$) and where the distribution of the two classes $f_{j_1}( x)$ and $f_{j_2}( x)$ is given as follows. Let the probability distribution of the first class be uniform on the interval $[0,b]$: \[ f_{j_1}( x) = \left\{ \begin{array}{ll} \frac{1}{b} & \mbox{if } 0\leq b \\ 0 & \mbox{otherwise}. \end{array} \right. \] The probability distribution of the second class is also uniform but on the interval $[a,c]$ of the same length: \[ f_{j_2}( x) = \left\{ \begin{array}{ll} \frac{1}{b} & \mbox{if } a\leq c \\ 0 & \mbox{otherwise}, \end{array} \right. \] with $0<a,b<c$ and $b=c-a.$ Moreover, we assume the mixture of these two distributions has equal weights with value $1/2$. See Figure~\ref{MixtureOfUniformDistributions}. \begin{figure} \centering \includegraphics[width=0.5\textwidth]{MixtureOfUniform} \caption{\label{MixtureOfUniformDistributions} Two uniform distributions with support of length $b$, where the second is the first shifted by $a$.} \end{figure} From our earlier discussion, the following deterministic classifier is optimal: \begin{equation} M_d (x) = \left\{ \begin{array}{ll} A_{j_2} & \mbox{if } (a+b)/2 \leq x \\ A_{j_1} & \mbox{if } (a+b)/2 > x. \\ \end{array} \right. \end{equation} This classifier is optimal whether $a<b$, $a=b$ or $b<a$. It always chooses the higher (or not lower) between $f_{j_1}( x)$ and $ f_{j_2}( x)$. However, consider the case illustrated in Figure~\ref{MixtureOfUniformDistributions} or the case $a=b$, and the following randomized classifier: \begin{equation} M_r (x) = \left\{ \begin{array}{ll} A_{j_2} & \mbox{if } b < x \\ A_{j_1} & \mbox{if } x < a \\ B(1,1/2)[ A_{j_1}, A_{j_2}] & \mbox{if } a \leq x \leq b, \\ \end{array} \right. \end{equation} where $B(1,1/2)[u,v]$ is one Bernoulli trial with probability $1/2$ where $u$ is selected on success and $v$ on fail. We argue that $M_r$ is optimal for all cases, even $a<b$ because by vacuity, the third case part of the definition of $M_r$ would not apply, so $M_r$ coincides with $M_d$. If Figure~\ref{MixtureOfUniformDistributions} or $a=b$ applies, any case with evidence $x$ with $a \leq x \leq b$ has equal probability of coming from class $A_{j_1}$ or class $A_{j_2}$. When $a \leq x \leq b$, the evidence is completely uninformative. If we choose the deterministic classifier $M_d (x) $ that always responds with $A_{j_1}$, it will be correct and wrong, respectively, $50\%$ of the time. The same holds if we choose $A_{j_2}$ for all $a \leq x \leq b$. Classifier $M_d (x) $ is not constant. It makes an error $50\%$ of the time for $a \leq x (a+b)/2$ because it always declares $A_{j_1}$, even though $50\%$ of the cases are from $A_{j_2}$. But it also has a $50\%$ error rate for $(a+b)/2 < x < b$, declaring $A_{j_2}$ on cases that are $A_{j_1}$. We now show that the random classifier $M_r (x)$ also makes the same expected error. Note that this analysis is the same as the profit analysis for the 2-player game \emph{Matching Pennies} introduced in the following subsection. The environment can draw from class $A_{j_1}$ or class $A_{j_2}$ with equal probability $p=1/2$. $M_r (x)$ declares $A_{j_1}$ or class $A_{j_2}$ with equal probability $p=1/2$ as well. The scenario is equivalent to tossing two fair coins as independent Bernoulli events, both with probability $1/2$, and declaring success when the coins match (i.e., outcomes (head, head) and (tails, tails)) and declaring a failure when the coins do not match (i.e., outcome (head, tails)). Thus, classifier $M_r (x)$ is correct $50\%$ of the time and incorrect $50\%$ of the time. \end{proofs} We may be tempted to say that for evidence $\vec{x}$ where $f_{j_1}(\vec{x}) = f_{j_2}(\vec{x})$ \emph{it does not matter} what the classifier determines as a class. The point we want to emphasize here is that randomized algorithms/classifiers (choosing differently each time they run) are not less optimal compared to systematic (deterministic) classifiers, hence their use in artificial decision-makers is worth consideration. \subsection{The Problem of Deterministic Classifiers} Matching Pennies is a simple game in basic game theory, which starts by two players submitting a covered penny, respectively, either heads or tails up. The players then simultaneously reveal their pennies with one of the following two outcomes: (1) if the pennies match---both heads or both tails---the first player (named the \emph{even player}) collects both as profit, (2) if they do not match---one head the other tail---the second player collects both pennies. Matching Pennies is one of the simplest examples of a game where Nash equilibria only exist with mixed strategies. We now use matching pennies to elaborate on our previous example of an AI system determining a sentence length. Aside from punishing offenders, deterring future crimes, and serving justice for victims and society, sentencing also pursues rehabilitation objectives: The intention is to calibrate sentences so as to ensure that offenders can redeem themselves and no longer pose danger to society after their release. That is, we want the AI prediction to achieve accuracy in the future. The problem is, however, that merit attributes relevant for determining whether or not the offender can be safely released into society upon completion of their sentence only materialize in the future, but none of them are available to our sentencing AI. The sentencing AI cannot possibly know if all convicts have equal opportunity to redeem themselves regardless of which correctional facility they have served their sentence in (probably not). This means that the vector $\vec{x}_{c}$ on which the sentencing AI supports its decision is only a projection to the present and is missing all the attributes of the future that will be known when deciding on the release. Accordingly, penitentiary systems mostly treat original sentences as mere estimates and regularly review release conditions before and during completion of the sentence. The environment plays as an adversary---as mentioned before, we alluded to this when we mentioned that game theory is used for robust design~\cite{Hespanha}. Thus, the sentencing AI is playing the game of matching pennies with the penitentiary system as to whether the sentence will achieve all its objectives. Much like this example, moral decisions made by AI systems are characterized by incomplete information. Often, cases look equivalent in the current set of attributes (in the current projection), but they are missing information on attribute values that are only completed later on. Suppose we are to construct a classifier that makes decisions affecting the well-being of two individuals: For instance, amidst the COVID-19 pandemic, a hospital has only one intensive care unit (ICU) available and two patients ($c_1$ and $c_2$) require it. We wish to allocate the ICU to the patient with the highest probability of survival. We feed extensive clinical and virological data~\cite{Chen2020,Lescure2020,ZhouLANCET2020} of identified risk factors from the now millions of patients infected with the disease into ML algorithms to obtain the classifier that decides between $c_1$ and $c_2$. As per the previous section, this means we have attribute value vectors $\vec{x_1}$ and $\vec{x_2}$ that codify the values in identified risk factors (e.g., age, obesity, diabetes, to name just a few). Note that problems arise when the available feature vector is uninformative, i.e., it does not allow to distinguish between the merit of $c_1$ and that of $c_2$---they are of the same age, weight, and so on. To whom should the classifier award the ICU in such cases? Deterministically, always on a first-come-first-serve basis? Is this fair or ethical by some metric? How will the public react if it notices that the individual who is entered as first patient into the classifier's input file always receives the ICU when both patients have the same merit? Now consider a different example: Training an ML system to make decisions in autonomous vehicles (AVs). Suppose that---when facing an imminent collision with either a motorcyclist wearing a helmet or a motorcyclist not wearing one---vehicles equipped with such classifier select the motorcyclist with a helmet as the victim due to the lesser likelihood of sustaining serious injuries. It is not hard to see how this may eventually motivate motorcyclists to drive without helmet to avoid being selected as victims by AVs---an outcome that is clearly undesirable from a general safety perspective. A potential solution could be for the AI to play a (finitely or infinitely) \emph{repeated game}~\cite{Dutta}. For now, we will not further entertain game theoretic repeated games. Suffice to say that automating with an AI implies the use of a large amount of instances and repeated games typically result in extremely different behaviors from single interaction games. The list of examples could go on. The point we would like to emphasize is that individuals are likely to change their choices to exploit the classifier if its decisions are deterministic---a behavior that becomes easier the more transparent the classifier is. This shows that (1) transparency may have substantial adverse effects in pure-strategy game settings---although, as we will explain below, it poses issues even in mixed-strategy game settings, (2) deterministic classifiers cannot necessarily achieve a Nash equilibrium, i.e., behave optimally, and (3) it is of crucial significance whether or not we can anticipate all the factors relevant to making a decision, i.e., whether or not we have a complete feature vector for a particular case. \subsection{The case for mixed strategies} \label{TheCaseForMixedStrategies} Our arguments in the previous sections already support the idea that AI-classifiers should use a mixed strategy and make random choices (but note that `random choice' under a mixed strategy is not any arbitrary unjustifiable choice, it is to wisely select a particular optimal and fixed probability distribution, which can be justified in a game theory sense, and from there to apply it to select a pure strategy). To stress this point further, we now use a 2-player game to examine the challenge faced by a classifier that can choose only between two options. The classifier is the first player, and has two \emph{pure} strategies at its disposal: (1)~to harm the welfare of individual(s) $X$ or (2)~to harm the welfare of individual(s) $Y$. The other player is again the environment, which can place the negative merit that leads to the scenario of harm either on~$X$ or~$Y$. We start with a scenario, where the AI faces the rare luxury that merit is ascertainable. As shown below, even such settings can raise complex moral dilemmas: \begin{center} \fbox{ \parbox{0.95\textwidth}{ {\scriptsize Two passengers in an AV are driving safely and obeying the speed limit in a lane labeled as only for AVs. As an extra safety measure, the road also has barriers to minimize pedestrians accidentally invading the designated AV lane. Six intoxicated pedestrians who have illegally jumped the barriers and failed to check if there were oncoming vehicles suddenly jump in front of the AV. Should the AV harm the pedestrians or swerve and harm the passengers? }}} \end{center} Here, the AI can ascertain that the illegally crossing pedestrians are responsible for the now unavoidable harm to human lives. Best efforts to apply brakes, yet not changing direction and causing some unavoidable harm is widely regarded as acceptable even for human drivers~\cite{Bonnefon,Estivill-CastroEthics,Moore}. Presumably, thus, such a merit-based, deterministic decision would not raise any eyebrows even in the case of AI decision-makers. That said, the best course of action dictated by utilitarian ethics may change depending on the particular circumstances of a given scenario and the \emph{ethical} action may not be \emph{feasible} in practice: For instance, the vast majority of society would accept utilitarian cars and confirm that if the six pedestrians were correctly crossing the street, the ethical decision by the AV---by utilitarian standards---would be to swerve risking the well-being of the two passengers. But, people also admit they would not own such a vehicle~\cite{Bonnefon,Estivill-CastroEthics,Moore} and would game the system by artificially adding passengers to their cars. Such practical issues may be at least to some extent alleviated if some degree of randomization is introduced into the classifier. Leaving aside the question of how exactly such randomization is achieved for the moment, we restrict ourselves to point out that this observation provides a strong argument for randomized classifiers even in scenarios where merit is ascertainable. Now consider a variation of this scenario where merit is not readily ascertainable: \begin{center} \fbox{ \parbox{0.95\textwidth}{ {\scriptsize The two passengers in the AV are driving safely and obeying the speed limit in the same AV lane as in the previous scenario. The six pedestrians suddenly appear in front of the AV. However, they are neither intoxicated nor crossing the road unlawfully. Rather, they cross over a zebra-indicated zone that is also equipped with traffic lights, which unfortunately do not work. It is unknown, whether or not they took all reasonable safety measures before crossing. What should the software be programmed to do? }}} \end{center} In this new scenario, it is likely that the AI---while reasoning about merit---reaches the conclusion that it is not ascertainable. We already mentioned that many oppose against any machine participation in moral decisions impacting humans. In the case of AVs, this is confirmed by the Report of the German Ethics Commission on Automated and Connected Driving~\cite{GERMANreport2017}, suggesting that any tragedy involving AV's would be attributed to humans only and not machines. Thus, authorities regard our current AI systems as fully the responsibility of their human designers---a premise that implies the following reasoning by the AI: \begin{enumerate} \item Only human agents should decide, but I am facing a decision to choose between the welfare of one human being over that of another. \item This situation should not have occurred. \item Therefore, some human agent is at fault. \item According to the EOP, I must optimize for the number of human casualties and, in particular, the consequences of this tragedy should be endured by the human agent(s) at fault. \end{enumerate} However, the same report~\cite{GERMANreport2017} admits the AV would not be in a position to fully ascertain which human agent is at fault or the level of negative merit---the gravity of fault---at the time of decision-making, necessitating settlement of the matter before court. The challenges of this second scenario, where the AI cannot determine merit and must choose between two evils---harm individual(s) $X$'s or individual(s) $Y$'s welfare---can be formulated in a game analogous to matching pennies and resolved with mixed strategies as follows: For simplicity, we assume---like others~\cite{Bonnefon}---there is no other information. Also, we model merit as negative utility. One player is the artificial decision-maker, which has only two \emph{pure} strategies at its disposal: (1) to harm the welfare of individual(s) $X$ or (2) to harm the welfare of individual(s) $Y$. The other player is the environment, which can place the negative merit that leads to the scenario of harm either on human $X$ or on human $Y$. In the scenario involving only two humans, the payoff matrix for the artificial agent is as follows: \begin{center} \begin{tabular}{l c c } & \multicolumn{2}{c}{\tiny Payoff matrix for the AV} \\ & \parbox{2cm}{\tiny Human~$X$ was at fault} & \parbox{2cm}{\tiny Human~$Y$ was at fault} \\ \cline{2-3} \parbox{2cm}{\tiny AI chooses to harm~X} & \multicolumn{1}{|c|}{0} & \multicolumn{1}{c|}{$-m_{X}*v_{X}$} \\ \cline{2-3} \parbox{2cm}{\tiny AI chooses to harm~Y} & \multicolumn{1}{|c|}{$-m_{Y}*v_{Y}$} & \multicolumn{1}{c|}{0} \\ \cline{2-3} \end{tabular} \end{center} When the AI chooses to harm the human who is at fault in causing the scenario, there is no penalty (no negative utility). But when it chooses to harm the welfare of the innocent human, the AI pays the price of the merit of the negatively affected human times a value of worth for that human---this allows us to account for several pedestrians or several passengers in our illustration. So, harming $X$ when the fault was $Y$'s impacts negatively on humanity in the amount of the merit of $X$ times the number of humans of type $X$. The payoff matrix for the environment which can choose to cause a scenario with $X$ at fault or $Y$ at fault is the same, except the values are positive (it is a zero-sum game). For this game, it is not hard to show that there is no Nash equilibrium with pure strategies, and that in a Nash equilibrium with mixed strategies the artificial agent chooses to harm individual(s) $X$ with probability $m_{Y}*v_{Y}/(m_{X}*v_{X}+m_{Y}*v_{Y})$ and individual(s) $Y$ with probability $m_{X}*v_{X}/(m_{X}*v_{X}+m_{Y}*v_{Y})$~\cite{vonStengel02}. The exact probabilities are not crucial for our argument here. The important message is that the algorithm is randomized. If the AV cannot be sure who is at fault, its two passengers or the 6 pedestrians, then despite the fact that six pedestrians are more lives than the two passengers, the EOP commands that the passengers still deserve a roll at the die---with probability $2/8$---to be saved! This illustrates our point that whenever an AI decision-maker does not possess full information on merit---as is the case in the vast majority of settings in which we engage AI systems---randomized classifiers constitute the optimal and fairest option. David McFarland's \emph{Epilogue: The Alien Mind} uses ethical dilemmas to debate the characteristics and properties we would need to anticipate on an alien mind to qualify it as one of us (among them, the robot would need to be accountable for its actions and provide a rational justification for its actions)~\cite{McFarland}. Being amoral is not an argument against random classifiers, as the law deals with other instances of ``amorality''' like insanity~\cite{Bonnie}. Moreover, we already argued that current machines are regarded as amoral, whether deterministic or not. Another important point for randomized algorithms: Most ML\/ formulations are optimization problems where parameters of a model in a family of models are being sought for some inductive principle~\cite{CherkasskyM98}. Such optimizations can be performed by hill-climbing, gradient descent or other heuristics, because finding the optimal model (i.e., the global optimum) is typically computationally infeasible. For instance, the famous back-propagation algorithm of artificial neural networks is a gradient descent method, and the initial weights are typically randomly chosen values. Thus, algorithms, such as hill-climbing or gradient descent, must be randomized regarding their starting point, and robustness is achieved by taking the best model out of the randomized multi-start. Another aspect that makes supervised learning randomized is the shuffling of the dataset instances to avoid bias to presentation order. This observation, that the learning involves randomization, applies to supervised learning, but also to unsupervised learning---recall the most popular of all: $k$-means starts with a random clustering. Today randomized algorithms are the dominant approach used to build AI-models. Thus, at each successive learning occurrence, a new convolutional neural network---or any other classifier---despite being deterministic, would still be likely to produce different outputs from the previous learning occurrence. Overall, it seems somewhat contradictory to demand that the output of learning be a deterministic algorithm while what is used to obtain such classifier is a randomized algorithm. Our approach does not oppose the accurate representation, computer-mechanization, and artificial reasoning with ethical theories. The adoption of moral facets amenable to logic programming~\cite{FuenmayorB20,PereiraSaptawijaya} emerges from the focus on moral decisions being the result of reasoning. Among those adopted are the \emph{Doctrine of Double Effects} (DDE)~\cite{sep-double-effect} and \emph{contractualism}~\cite{Scanlon}. Computational versions of the Doctrine of Double Effects have been implemented with systems such as QUAL, ACONDA, and Probabilistic EPA (as well as other more recent proposals~\cite{GovindarajuluB17}). These systems have been illustrated with several versions of the trolley dilemma~\cite{PereiraSaptawijaya}. They are plagued with limitations~\cite{GovindarajuluB17}---indeed, the original source for trolley dilemmas~\cite{Foot1967} is also a critique to the DDE. Moreover, Foot presents examples where refinements of the DDE (as to whether direct or oblique intention, or the distinction between avoiding injury and bringing aid) are insufficient to make a choice~\cite{Foot1967}. For instance, \begin{quote} \emph{``shipwrecked mariners who believed that they must throw someone overboard if their boat was not to founder in a storm, [sic] there is no conflict of interests so far as the decision to act is concerned; only in deciding whom to save.''}~\cite{Foot1967}. \end{quote} But if all sailors have equal merit to survive; a random decision might be justifiable. Similarly, there has been remarkable progress towards explicit ethical artificial agents by showing that Gewirth's ``Principle of Generic Consistency (PGC)'' \cite{Gewirth} can be derived by computer-mechanization using higher order logic~\cite{FuenmayorPRICAI2019}. That is, from premises such as ``I am a prospective purposive agent (PPA)'' (that is, I act voluntarily for some (freely chosen) purpose $E$) and ``My freedom and well-being (FWB) are generically necessary conditions of my agency,'' the artificial agent concludes that ``Every PPA has a right to claim their FWB.'' As an ethical principle, the PGC seems to be a variation of the \emph{golden rule}: ``treat others as you wish to be treated.'' The PGC is not uncontroversial~\cite{Beyleveld1991}. But it has been praised~\cite{Kornai} for being instrumental to impose morality on artificial agents who would respect humans: Artificial agents with sound reasoning mechanisms would conclude they must respect the well being of all PPAs and would recognize both humans and themselves as PPAs. But, Trolley problems are not about whether an agent is a PPA or not, but about choosing the less evil among PPAs. Moreover, such an artificial PPA endowed with morality based on deductive-reasoning ---when faced with the choice between acting against the well-being of one PPA or another---must conclude that one of them is not a PPA (particularly if we insist that AI should not make moral decisions). A further complication is that the AI performing such deductive-reasoning may still be required to make a choice without being able to ascertain which one is or is not a PPA. A final point in favour of mixed strategies is that they offer an interpretation of probabilities as frequencies (proportions)~\cite{Hespanha} as they apply to populations. Suppose we need to program robots for a tournament involving our earlier example of \emph{rock, paper, scissors}, where robots are only allowed to use pure strategies. The teams consist of a large number of robots (say $1,000$), each of which we can program differently and shuffle across teams. The mixed-strategy solution in this situation is to program one third of the robots in each team to deterministically choose one of the three actions. However, even this use of deterministic programs shuffled randomly is less acceptable than randomized algorithms: We would need to hide away what deterministic algorithm each AI decision-maker is using (i.e. block all transparency). Humans would seek to breach this by discovering or identifying the deterministic AI decision-maker that favors their situation above other humans. \section{Implementation and Policy Issues} \label{ImplandPol} Section~\ref{Results} provided compelling arguments for employing randomized classifiers in the above outlined scenarios. However, as theoretic arguments are not necessarily easily implemented in practice, we now look into implementation issues. First, the success of the societal adoption of any novel technology---here deploying trustworthy and fair randomized classifiers to make moral decisions impacting the welfare of human beings---hinges on society's trust and acceptance. Since humanity's notion of automation has so far been predominantly deterministic and change is often met with considerable resistance, building societal confidence in non-determinism may not be so easy to achieve. In particular, for game theory, mixed strategies---although extremely intuitive in settings that can be modeled by matching pennies or rock, paper, scissors---have received heavy opposition. For instance, preferential voting schemes that have been shown to be optimal by a game-theoretic analysis and also superior empirically have been rejected~\cite{RivestCOMSOC}. To assess societal preferences, we conducted a series of surveys using classic ethical dilemmas to evaluate the public's stance on randomness. We also explored under which circumstances people prefer moral decisions to be made by humans, artificial agents, or a combination of both such that human decision-makers are assisted by computer technology to varying degrees. Our goal was to gather empirical evidence to help identify areas where emerging AI capabilities could realistically automate decisions that affect human lives. Our experimental setting is introduced in Section~\ref{casestudy}. We found that society would be inclined to accept random choices by artificial agents and feel comfortable with technology eventually fully replacing human decision-makers in specific areas. Second, initiatives to achieve ever-higher levels of transparency, traceability, and auditability of AI systems are now ubiquitous. Prominent examples include the OECD Principles on AI~\cite{OECD2019}, the European proposal for an Artificial Intelligence Act ~\cite{AIA}, the Feasibility Study of the Council of Europe's Ad-Hoc Committee on Artificial Intelligence (CAHAI)~\cite{CAHAI2020}, and existing and ongoing standardization efforts of both European and international standardization bodies, most notably the European Committee for Standardization (CEN), the European Committee for Electrotechnical Standardization (CENELEC), the International Standardization Organization (ISO), the International Electrotechnical Commission (IEC), and the Institute of Electrical and Electronics Engineers (IEEE)~\cite{IEEE2019}. However, we would like to stress once more that transparency may also open up avenues for exploitation and is hence not always desirable. For instance, transparency with regard to the algorithm used changes our game-theoretic proposal. It is relatively clear that deterministic classifiers that act as agents in pure-strategy games are gamed if the strategies are known---with particular ease if the game is repeated. Take the example of AV owners inviting others for a ride to increase the value of human welfare on board and bias the odds in favor of passengers and against pedestrians. But transparency can also pose an issue with randomized classifiers in mixed-strategy game settings. Our discussion assumed that the artificial agent cannot infer any information on the merit to force a deterministic behavior. However, given easy access to big data, it is conceivable that ML\/ techniques could produce models to predict the merit---or negative merit, i.e., fault---of the human agents involved. For instance, provided sufficient training data, individuals may use ML\/ models to infer and discover which attributes an AI system regards as leading to meritorious outcomes in a certain situation and adjust their strategy accordingly. In particular, knowledge that the system is applying logistic-regression is sufficient to use many of the methods in the literature to find the most influential attributes, allowing people to artificially boost their values for those. Even if the model used by the AI is unknown, the use of logistic-regression, feature selection, or methods based on information gain can reveal to human agents the most influential attributes used by the AI to ascertain their merit, leaving plenty of room for human manipulation. Another question is whether, in settings where merit is not ascertainable, regulators should require AI designers to install the best predictive models of human fault in their systems. This would encourage continuous efforts to at least approximate non-ascertainable attributes with a view to arrive at more precise decisions. Ultimately, these are questions for policymakers to decide, we just want to raise awareness to potential problems stemming from ever-increasing transparency requirements and suggest that there may be certain trade-offs to consider. Third, although we have established that randomized decisions are mathematically optimal and probably acceptable, we face a substantial implementation problem: According to the Church–Turing thesis, no function computable by a finite algorithm can implement a true random oracle. In other words, true randomness in the mathematical sense is impossible to achieve in a deterministic Turing machine or von Neumann architecture. The closest thing to generating random sequences are cryptographic hash functions. These are merely pseudo-random sequences, which are still susceptible to attacks and may become truly vulnerable with certain advances in quantum cryptography~\cite{Goldreich1988,Buchmann2017}. Random oracles have been used to prove the security of some cryptographic protocols formally, but these proofs have come under severe criticism~\cite{Canetti2004} and become subject of heated debates in the cryptographic community~\cite{Koblitz2015}. Despite their theoretic weakness, most users of cryptographic protocols remain unconcerned that, in practice, random oracles are replaced by cryptographic hash functions~\cite{Koblitz2015}. A promising emerging solution to the problem is the novel trend of stepping away from the deterministic Turing machine and the von Neumann model towards the use of hardware random number generators. These use random numbers from a physical process---such as thermal noise---to harvest entropy~\cite{Goichon}. Although they still do not qualify as mathematically random, these sequences have in some cases been extremely unpredictable---but note that from a cryptographic perspective, they have turned out to be less secure than originally anticipated~\cite{Kim2013}. In any case, harvesting entropy may also lead to problems: for example, large logs may be required to satisfy the trustworthy AI requirements, which designers can review to fix a problem in the event of tragedies. There are some deterministic processes, like cellular automata, which can be used to generate unpredictable sequences~\cite{Wolfram}. But still, how current computers would generate true random sequences raises a series of philosophical questions: If hardware random generators in combination with pseudo-random generators replaced the notion of pure random oracle for lack of a better implementation in our current hardware, and machines proliferated around us making decisions about our lives, the world could become potentially distressing. In our previous AV example, perhaps owners would be particularly interested in breaking into the code of the pseudo-random number generator in their car to anticipate its decisions---even with entropy sources attacks are possible~\cite{Kim2013}. Similarly, law firms could invest resources in finding the pseudo-random code behind AI judges to find the best strategies for their clients. In such cases, unpredictable AI rulings would be preferable. Otherwise, too much transparency of the model behind the AI may result in a learnable behavior, from which ML\/ algorithms could build an accurate model. The model could be used to take advantage and be able to present the attributes of a case much more favorably than otherwise. Note that randomization is used to combat manipulative strategies even in the context of human judges: Such is the perception that knowledge of the judge traits can bias the trial, that human judges for federal cases are typically assigned randomly in the US. \section{Empirical study} \label{casestudy} There is an increase of research on moral human-robot interaction~\cite[and references]{MalleScheutzArnold} where variants of the trolley dilemma~\cite{Foot1967,SW2020} are used to elicit humans' perceptions. For instance, it has been consistently found that humans expect robots to make utilitarian choices~\cite{Bonnefon,Estivill-CastroEthics,MalleScheutzArnold}. However, we designed our questionnaire to gather empirical evidence on the level of trust society places in technology---or distrusts human decision-makers acting without technological support. We were interested in situations where AI, artificial agents, embedded systems, and robotics could substitute human agents. Some questions have been motivated by examples provided by reports on the use of AI tools in assisting judges in sentencing and bail decisions~\cite{Kugler2018}. While we expected most people to agree that, in principle, machine assistance improves human decision-making performance, we suspected differences in opinion as to the extent such technologies should substitute human decision-makers, particularly when decisions directly impact another person. To measure such differences, we selected three different groups of participants, each with different levels of exposure to the debate on moral decision-making by AI systems. While our initial questions assumed deterministic AI behavior, later questions touched on the issue of randomness. \subsection{Method} Prior to the survey, we familiarized participants with the EOP to provide a relatively simple, underlying framework to avoid confrontation with the many fairness definitions against which classifiers' performance may be judged~\cite{Heidari2019}. For the introductory paragraph and the questionnaire, see Appendix~\ref{ap_research_inst}. We recruited participants through four different methods. The first set of participants were Australian full-time employed high-school teachers holding a university degree, who participated in a series of professional development workshops to include or expand the use of technology in their pedagogy. They came from 34 different schools with their levels of delivery including junior secondary, year~7 to~9, year~7 to~12, year~10, STEM~P-6, year~9 to~12, VET, primary school, year~8 to~12, and K~6. Participation in the survey was an optional activity offered in the workshops. Out of 65 invited participants, 53 replied to our questionnaire and 12 declined. We will refer to this group of participants as \emph{teachers} in Section~\ref{Analysis}. The second means of recruitment was an online survey ~\cite{MalleScheutzArnold} using SurveyMonkey Inc.~\footnote{The data was collected using SurveyMonkey~Audience. We chose Age Balancing: Basic, Gender Balancing: Census, COUNTRY: United States (USA) - SurveyMonkey, HOUSEHOLD INCOME: $\$50k-\$200k+$, AGE: $25-100+$, Education: Graduate degree. Information on how respondents are recruited to SurveyMonkey is available here: www.surveymonkey.com/mp/audience}, through which we collected $124$ responses. We limited the group of acceptable respondents, since we believe the concepts and issues regarding the potential applications of AI in supporting and replacing human decision-making are not trivial, particularly regarding moral standing and fairness: (1) One excluded respondent class were children, as their views on robots significantly differ from adults~\cite{BartlettECS03,KahnFH03}. (2) We selected respondents from the US, who were above the age of 25, held a graduate degree, and had a household income of \$50K-\$200k. Our choice of participant group was motivated by the fact that individuals' engagement in policymaking largely depends on their socialisation and education, and we targeted the US because of its culture of deep and genuine citizen participation~\cite{AustralianParliMentReport}. Many reports~\cite{AndersonFACTTANK} highlight that there is different levels of adoption of technology in the US, but we assume that the minimum household income and their use of SurveyMonkey represents a homogeneous group in this regard. We note that other on-line experiments have a similar sample size and data collection approach for a generic view by humans~\cite{MalleScheutzArnold}. We will refer to this group of participants as \emph{online respondents} in Section~\ref{Analysis}. Third, we performed a robotics demonstration on Nathan Campus, Brisbane, at University Open Day. Our robots engaged visitors in conversation by randomly picking shorter versions of the survey questions. 17 visitors became curious and agreed to complete the survey. We will refer to this group of participants as \emph{Open Day visitors} in Section~\ref{Analysis}. Finally, we collected 13 surveys from IT academics, whom we invited to our department's research seminar. We will refer to this group of participants as \emph{academics} in Section~\ref{Analysis}. All survey participants were provided with a consent and information sheet as per the conditions of our Research Ethics Committee's approval. Thus, participation was completely voluntary, anonymous, and could stop at any time. For the SurveyMonkey collection, we ensured respondents could not go back and alter their answers for previous questions. The other data collection methods used printed versions of the questionnaire, so we cannot guarantee people did not revise their answers. However, we feel this is very unlikely as we found no amendments when capturing the answers. Most of the questions in our questionnaire can be considered Likert-type scale questions (i.e., we give the survey participants five worded points they can choose from). Whenever possible, we will avoid debate about whether the data collected should be considered as interval-level data or ordered-categorical data. As mentioned above, we will use a five item option with a clear middle neutral point. Questions are symmetrical although potentially not equidistant; their presentation aimed for respondents to assume equidistance. We will use diverging stacked bar charts when presenting the descriptive statistic analysis of ordinal data~\cite{JSSv057i05} and bar charts in the remaining cases. Since we will be comparing different groups of respondents for the same question, the responses can not be paired (sample sizes are different), and we are not making any assumptions about the normality of the data. We have overlapping samples which we will analyse for statistical difference of medians using the non-parametric Mann-Whitney U test\footnote{We replicated the calculation using the Mann-Whitney U Test Calculator from https://www.socscistatistics.com and R~\cite{citingR}.}~\cite{DerrickWhiteLikert}. Given two random variables $X$ and $Y$ with their cumulative distribution functions $f$ and $g$, respectively. For ordered samples $x_1, \ldots , x_n$ and $y_1, \ldots , y_m$ of $X$ and $Y$, respectively, let the statistic $U$ count the number of how many times a $y$ value precedes an $x$ value. The Mann-Whitney U Test uses the statistic $U$ for testing the hypothesis $f=g$~\cite{mann-whitney}. The null hypothesis $H_0$ in our tests is going to be that the two cumulative distribution functions are the same (i.e., two different groups have the same scoring tendency). In all of our tests we will use the significance level $\alpha=0.05$. Furthermore, we will specify the \emph{$p$-value}, the probability (assuming that $H_0$ is true) that we obtain a test statistic that is at least as extreme as the observed value of the test statistic. If the $p$-value is less than the level of significance, we reject the null hypothesis and accept the alternative hypothesis. \subsection{Analysis} \label{Analysis} \subsubsection{Evidence for preference for automated judgments} The results in this subsection show that some groups of participants' distrust in humans leads them to prefer AI over human decision-makers. Figure~\ref{Question1divergent} shows the divergent bar chart of responses to Question~\ref{Q1} from our groups as percentages. \begin{figure} \centering \subfloat[\label{Question1divergent}Question~\ref{Q1}: Who is fairer, humans or computers, to implement EOP.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question01}} $\;\;$ \subfloat[\label{Question03divergent}Question~\ref{Q3}: How to select which passenger should be left behind from a flight.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question03}} \caption{\vspace{-1mm}\label{Q1ANDQ3divergent} Divergent bar charts of responses to Question~\ref{Q1} and Question~\ref{Q3}. } \vspace{-2.5mm} \end{figure} Eleven teachers felt humans are never fairer, and none felt humans are better than automation. A small percentage ($13.7\%$) of SurveyMonkey respondents were of the opinion that humans can be fairer, but $40.3\%$ believed humans are slightly worse at being fair. Teachers' and Open Day visitors' median and mode indicated that humans were somewhat worse at being fair, while the academic view was neutral. The difference between teachers and academics is statistically significant ($U=137$, $p=0.00042$) and so is the difference between Open Day visitors and academics ($U=49.5$, $p=0.0057$). \textbf{Discussion:} Figure~\ref{Question1divergent} shows results for Question~\ref{Q1} and assesses individuals' level of trust in human decision-makers not supported by technology. The responses accumulate away from the use of human judgment alone. In this case, the results are consistent with the generally accepted view~\cite{Kugler2018} that machines analyze facts without human bias, irrationality, or mistakes. Thus, it seems teachers and Open Day visitors perceive machines as more impartial than humans. Although this view may shift due to the growing recognition of the need for a human-in-the-loop approach~\cite{EUReport}, these groups of respondents do not seem to be dissuaded from automation. Question~\ref{Q3} (refer to Figure~\ref{Question03divergent}), which concerns the automation of decisions on regrouping passengers across flights, also shows preference for AI-decisions over human involvement. Teachers' median and mode are again for a computer program with some human monitoring. Not a single academic selected only human judgment. Open Day visitors' median and mode are also for this level of automation, and so is the mode of the online survey. Teachers' preference for automation is significantly different from that of online respondents ($U=1921$, $p=0.0001$) and Open Day visitors ($U=302.5$, $p=0.04338$). The responses for Question~\ref{Q11} (see Figure~\ref{Question11divergent}) on automating visa applications show an almost identical pattern to Question~\ref{Q3}. Responses are clearly in favor of automation and reject human judgment: Teachers' and Open Day visitors' median and mode unambiguously reflect this preference, and the mode of online respondents is also for automation (the median is neutral). To a slightly lesser extent, academics also favor automation. Both Question~\ref{Q3} and Question~\ref{Q11} received a non-trivial number of responses on the extreme values, but mainly advocating fully automated decisions. Albeit in the opposite direction, we will see below the results for Question~\ref{Q2}, which generally favors human judgment. But even in Question~\ref{Q2}, there are also non-trivial numbers of those who would prefer the selection to be entirely without human intervention. The difference between the responses of teachers and online respondents is again statistically significant ($U=1968$, $p=0.0001$). But interestingly, here, Open Day visitors' high preference for an AI-judgment is statistically significant with respect to online respondents ($U=696$, $p=0.02382$). Question~\ref{Q12}---concerning decisions on credit-card applications---shows responses even more in favor of automation (refer to Figure~\ref{Question12divergent}). The median and mode for teachers, academics, and Open Day visitors indicates ruling over credit-card applications should be a matter for computer programs with some human monitoring, yet without checking each individual case. Almost all teachers favor automation, clearly rejecting human judgment even if supported by technology. Online respondents, academics, and Open Day visitors also show a strong tendency towards automation: human judgment is less than $8\%$ of the responses for all participants. Even given all groups' preference for the use of technology, note that teachers' are in favor of automation to such an extent that the difference between their views and that of online respondents is statistically significant ($U=1967.5$, $p=0.00001$). \textbf{Discussion:} A possible explanation for such a high level of acceptance of automated decision-making over human judgment in this scenario is that the massive benefits of automation in the credit-card industry pushed an early penetration of ML\/ technology in the sector: ML\/ has been applied to credit-card application assessments for more than 25 years~\cite{Carter87,Davis92}. In this setting, there have been calls for accepting technology with little questioning~\cite{Rosenberg2008}. \begin{figure} \centering \subfloat[\label{Question11divergent}Question~\ref{Q11}: Who should evaluate a travel visa application, human or artificial agent.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question11}} $\;\;$ \subfloat[\label{Question12divergent}Question~\ref{Q12}: Who should decide over awarding a credit-card and its limit, humans or machines.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question12}} \caption{\vspace{-1mm}\label{Q11ANDQ12divergent} Divergent bar charts of responses to Question~\ref{Q11} and Question~\ref{Q12}. } \vspace{-2.5mm} \end{figure} With less overall preference for a machine-driven decision, Figure~\ref{Q7ANDQ8divergent} shows the results of Question~\ref{Q7} and Question~\ref{Q8}. \begin{figure} \centering \subfloat[\label{Question7divergent}Question~\ref{Q7}: How much automation when ruling over child adoption.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question07}} $\;\;$ \subfloat[\label{Question8divergent}Question~\ref{Q8}: How much automation when judging over a bail hearing.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question08}} \caption{\vspace{-1mm}\label{Q7ANDQ8divergent} Divergent bar charts of responses to Question~\ref{Q7} and Question~\ref{Q8}. } \vspace{-2.5mm} \end{figure} Figure~\ref{Question7divergent} and Figure~\ref{Question8divergent} show almost identical proportions and the positions of the bars. For online respondents and for Open Day visitors, there is strong centrality, and a firm rejection for complete automation of the decision-making. Less than $5\%$ of online respondents chose the fully automated option for both of these questions. However, the teacher group shows a strong preference for the decision to be strongly guided by full automation or only some human supervision. Responses for teachers on both questions have a median and mode for using a computer program with some human supervision for both scenarios. Teachers' preference for AI-judgments is statistically significant with respect to online respondents ($U=1360.5$, $p=0.00001$ for Question~\ref{Q7} and $U=2184$, $p=0.00004$ for Question~\ref{Q8}) and with respect to Open Day visitors for Question~\ref{Q7} ($U=143.5$, $p=0.00001$) but not for Question~\ref{Q8}. The results for Question~\ref{Q14} also show central/neutral responses for Open Day visitors and online respondents (see Figure~\ref{Question14divergent}). However, once more, teachers show a statistically significant higher preference for automation over online respondents ($U=2276.5$, $p=0.00124$) and Open Day visitors ($U=272.5$, $p=0.0151$). \begin{figure} \centering \subfloat[\label{Question14divergent}Question~\ref{Q14}: Who assesses fairly a funding application from a school, humans or artificial agents.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question14}} $\;\;$ \subfloat[\label{Question21divergent}Question~\ref{Q21}: Who is fairer at specifying the sentences for a convicted criminal.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question21}} \caption{\vspace{-1mm}\label{Q14ANDQ21divergent} Divergent bar charts of responses to Question~\ref{Q14} and Question~\ref{Q21}. } \vspace{-2.5mm} \end{figure} Question~\ref{Q21} (see Figure~\ref{Question21divergent}) shows the public's tendency to centrality with respect to automating sentencing decisions, with a very slight shift in favour of human intervention: Open Day visitors' median and mode and online respondents' mode indicates a preference for technologically assisted human sentencing decisions. On the other hand, the median and mode of academics and teachers is clearly in favor of AI-enabled, automated decision-making with some monitoring and supervision by a judge. Teachers' preference for an AI-judge is statistically significant over that of online respondents ($U=1778$, $p=0.00001$) and Open Day visitors ($U=228$, $p=0.00236$). Academics' support for the AI-judge is even stronger: None of them contemplates a position below neutral. Hence, academics' preference for automated decisions in this setting is statistically significant not only with respect to online respondents ($U=123$, $p=0.00001$), but also Open Day visitors ($U=12$, $p=0.00001$) and teachers ($U=120.5$, $p=0.00016$). \textbf{Discussion:} The teachers were surveyed after a professional development day for the inclusion of ICTs in the teaching-learning process. Some of the technologies demonstrated and discussed were virtual-reality, robotics, and cloud tools. Therefore, they may hold high hopes for the automation of judgment. Alternatively, ICT academics and teachers may be more aware of works on bounded rationality---suggesting that cognitive limitations prevent humans from being fully rational~\cite{Simon1957,Lindblom2017}---and studies indicating that humans suffer from predictable biases that influence judgment~\cite{KahnemanTversky1979}. These insights presumably encourage them to be more cautious and meticulous when evaluating and designing decision-making methods that may affect human beings. The fact that the systematic design of such methods is typically supported by computer programs may provide a further explanation for this groups' high preference for automation. \subsubsection{Evidence for preference for human involvement in judgments} Let us now turn to the results showing that some groups of participants exhibit distrust in AI decision-makers and hence prefer their human counterparts. Figure~\ref{Question02divergent} shows the corresponding divergent bar chart of responses for Question~\ref{Q2}, which aimed to find out the public's preferred level of automation in the context of a language test. The accumulated results did not swing either way: Teachers preferred some automation, academics even more. Their mode and median were for a computer program with some human monitoring. Open Day visitors' view was in-line with the online survey. The remarkable point here is the issue at the extremes: In all data collections, there is some non-trivial number of preferences for exclusively human judgment without technological support. Apart from academics, all other respondents rejected total automation. \begin{figure} \centering \centering \subfloat[\label{Question02divergent}Question~\ref{Q2}: Who is fairer at evaluating command of foreign language.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question02}} $\;\;$ \subfloat[\label{Question05divergent}Question~\ref{Q5}: Would a minority person be judged fairly by human/artificial security officer.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question05}} \caption{\vspace{-1mm}\label{Q2ANDQ5divergent} Divergent bar charts of responses to Question~\ref{Q2} and Question~\ref{Q5}. } \vspace{-2.5mm} \end{figure} Although the results we discuss next show a tendency for a neutral response---with some involvement of technology---they also indicate a clear desire by participants to maintain some human involvement, rejecting decisions by fully autonomous AI decision-makers. Question~\ref{Q5} considers a scenario in which a subject, who belongs to a visibly distinct group, needs to request assistance. Some of the responses here show strong evidence that complete reliance on human judgment is unacceptable. The median and mode for both online respondents and Open Day visitors are that if they were a minority, they would prefer the involvement of computer programs with some human supervision. Teachers' and academics' responses for this question are remarkably neutral (refer to Figure~\ref{Question05divergent}). Figure~\ref{Q4ANDQ6divergent} shows a global neutral response for two questions. For Question~\ref{Q4}, most respondents stay away from fully-automated rulings but also dislike purely humans verdicts that lack any support from computer systems. No single respondent from the Open Day visitors elected the fully automatic option. In the US online survey, the utterly automatic option has less than $6\%$ of the respondents. While the median and mode for the online respondents and the Open Day visitors is the neutral option, teachers' responses again show distrust in human decisions and their median and mode are for the use of a computer program with some human supervision for ruling on punishments at school for children (see Figure~\ref{Question04divergent}). \begin{figure} \centering \subfloat[\label{Question04divergent}Question~\ref{Q4}: Ruling on discipline measures for a child of a minority group at school.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question04}} $\;\;$ \subfloat[\label{Question06divergent}Question~\ref{Q6}: Judging behaviour at nightclub by human/artificial security guard.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question06}} \caption{\vspace{-1mm}\label{Q4ANDQ6divergent} Divergent bar charts of responses to Question~\ref{Q4} and Question~\ref{Q6}. } \vspace{-2.5mm} \end{figure} Teachers' preference for technology is statistically significant both with respect to online respondents ($U= 1933 $, $p=0.00001$) and Open Day visitors ($U= 234.5$, $p=0.00159$). Academics are even more in favor of higher levels of machine-based decisions in this setting, and their position is statistically significant both with respect to online respondents ($U= 394$, $p=0.00126$) and Open Day visitors ($U= 47.5$, $p=0.0044$). A similar picture of neutrality emerges from Question~\ref{Q6} (refer to Figure~\ref{Question06divergent}). The responses are more or less even, except again that very few respondents would accept a completely artificial security guard. None of the responses from Open Day visitors corresponds to this option. However, academics remain inclined for automation---none of them selected a human security guard alone. And interestingly, in this question, teachers have shifted to a more even and spread opinion. Nevertheless, the Mann-Whitney U Test does not reveal a statistical difference at the $0.05$ level for any two groups of responses. \subsubsection{Data on acceptance of technological assistance} We now show results for questions we later use for contrasting sub-groups between the respondents. Question~\ref{Q9} (refer to Figure~\ref{Question09}) shows mixed results. Although one side indicates complete comfort with disclosing medical conditions to a human pharmacist, while the other an absolute preference for no human involvement in fulfilling a prescription, the options in this question may not be considered symmetric or an ordered categorical scale. Figure~\ref{Question09} shows bar charts of percentages of responses and \begin{figure} \centering \subfloat[\label{Question09}Question~\ref{Q9}: Discussing your medical condition to a human versus a robot.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question09}} $\;\;$ \subfloat[\label{Question17}Question~\ref{Q17}: Has artificial intelligence surpassed human performance for the game of chess.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question17}} \caption{\vspace{-1mm}\label{Q9ANDQ17bar} Bar charts of responses to Question~\ref{Q9} and Question~\ref{Q17}. } \vspace{-2.5mm} \end{figure} we note that there is a similar dispersion of preferences between teachers' and online respondents' responses. These two groups are comfortable discussing prescriptions with pharmacists. However, Open Day visitors never picked the option to discuss face-to-face with a human and have far more preference for full automation. The mode for academics is also full automation. \textbf{Discussion:} We formulated Question~\ref{Q9} as a result of the reports~\cite{Reese2017} around the virtues of using a robot as a point of sale in retail (the first $1,000$ Pepper robots were hired for Nescafe in December 2015 to help customers searching for coffee machines in their appliance stores). This question is also motivated by the suggestion that technological interventions~\cite{Scoglio2019,Farreretal2013} in which humans interact with a robot enable humans to feel more at ease. However, the reverse is also possible (recall the uncanny valley debate~\cite{PIWEK2014271}). Upon reflection, there could have been more questions and research to explore the perception by a human patient to receive fair or appropriate treatment from a robotic nurse versus a human nurse. Biases in medical treatment because of factors that could be considered discrimination are well documented~\cite{Hall2105}. Question~\ref{Q10} and Question~\ref{Q15} attempt to measure a construct by which technological assistance to humans is accepted because it has prevailed for several generations. Note that acceptance of new information technologies has been researched extensively~\cite{AgarwalPrasad} but familiarity with the notion of autopilot in planes is not comparable to familiarity with robots/machines as judges or moral decision makers. That is, information technologies are appearing at a much faster rate than some innovations in automation. The origins of the plane's autopilot is attributed to the Sperry family (or Corporation) in 1912, and in 1947 a US Air Force C-53 completed a transatlantic flight apparently with all phases in autopilot. Similarly, cruise control patents appeared in the 50s and 60s, although widespread use of cruise control appeared in the 1070s because of its positive impact on fuel consumption. We speculate that our respondents are all comfortable with the idea that it is advantageous to have autopilots in long flights and that cruise control is a positive option. \begin{figure} \centering \subfloat[\label{Question10}Question~\ref{Q10}: Is the autopilot preferable than not having one.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question10}} $\;\;$ \subfloat[\label{Question15}Question~\ref{Q15}: Does cruise control facilitate driving.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question15}} \caption{\vspace{-1mm}\label{Q10ANDQ15bars} Bar charts of responses to Question~\ref{Q10} and Question~\ref{Q15}. } \vspace{-2.5mm} \end{figure} Figure~\ref{Question10} confirms that respondents concur on an autopilot being useful. The mode for all is that an autopilot is preferable (in Figure~\ref{Question10} we can see that all groups chose this option more than $50\%$ of the time except Open Day visitors, but even they have above $40\%$ for constant computer assistance). Almost no respondents would change the auto-pilot for a human co-pilot. Similarly, barely any respondent answered that a car is harder to drive with cruise control. Academics see no benefit from cruise control and a non trivial proportion of online respondents and Open Day visitors see no impact of cruise control in reducing speeding fines or accidents (refer to Figure~\ref{Question15}). While cruise control and autopilot originally involved mechanical devices, they are now operational through digital micro-controllers. We explored the issue of ``thinking machines''~\cite{Vega,Bibel2020} with what has been traditionally perceived as an intellectual challenge (even after the birth of artificial intelligence). Therefore, Question~\ref{Q17} was designed expecting the vast majority of respondents accepting that mechanized reasoning and performance by artificial chess-players is superior to human performance. Figure~\ref{Question17} shows that this is the case (especially academics), but even online respondents' responses show less than $4\%$ believe that chess programs are worse than the average human. \begin{figure} \centering \subfloat[\label{Question18}Question~\ref{Q18}: Has ICT and search engines provide and advantage to compete in Trivial Pursuit.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question18}} $\;\;$ \subfloat[\label{Question19}Question~\ref{Q19}: Has ICT improved the performance of office workers.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question19}} \caption{\vspace{-1mm}\label{Q18ANDQ19bars} Bar charts of responses to Question~\ref{Q18} and Question~\ref{Q19}. } \vspace{-2.5mm} \end{figure} \subsubsection{Analysis as to whether justifications are necessary} Since the deployment of expert systems, it became clear that explanations~\cite{Darlington2013AspectsOI} are crucial for human users' trust~\cite{Swartout1993,WangPH2016} and acceptability of these AI systems~\cite{YeJ95}. We formulated two questions regarding the transparency of the decision provided by artificial agents. The European Union considers transparency---including traceability, explainability, and communication---as central issues for Trustworthy AI~\cite{EUReport}. In these questions (Question~\ref{Q22} and Question~\ref{Q23}) the categories are not ordinal. We offered one option for artificial agents being forced to explain, communicate, and justify their decisions. The other three options were such that the AI-Judge would not be required to provide an explanation. One was simply a certification that the system is fair by some third party, while the second was that the system could be used publicly as a black box. The third option for the non-transparent version was to combine the two previous ones. An interesting result is that online respondents do not seem to care about justification for a decision. Responses for forcing the system to explain and justify itself was less than $28\%$. Although the mode for teachers and academics is above 40\%, demanding AI decision-makers to provide explanations, these participants (in some earlier questions) seemed more accepting of an alien/artificial mind. Teachers and academic responses do not reach $50\%$ for demanding explanations from AI for Question~\ref{Q22} (see Figure~\ref{Question22}). \begin{figure} \centering \subfloat[\label{Question22}Question~\ref{Q22}: Argument for no transparency on intellectual property grounds.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question22}} $\;\;$ \subfloat[\label{Question23}Question~\ref{Q23}: AI-judge seems fairer than human judges.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question23}} \caption{\vspace{-1mm}\label{Q22ANDQ23bars} Bar charts of responses about whether AI-judges should offer explanations and justifications for their decisions (Question~\ref{Q22} and Question~\ref{Q23}). } \vspace{-2.5mm} \end{figure} This low interest for transparency (as per Question~\ref{Q22}) are in contrast with those of Question~\ref{Q23} where the requirement for an AI-judge to explain and justify itself almost reaches $50\%$ for all collection approaches (see Figure~\ref{Question23}). The mode for all participant groups is that artificial agents must be forced to justify and explain their decision making. \textbf{Discussion:} Perhaps Question~\ref{Q23} is more specific, as it refers to a particular individual and the particular situation of ruling on the lengths of a sentence for a convicted criminal. It is common that humans offer somewhat contradictory views for seemingly similar situations, as individuals value the specifics of each scenario differently. \subsubsection{Analysis as to whether randomization is acceptable} For Question~\ref{Q13} and Question~\ref{Q20}, we were expecting responses to favor automatic choice since the questions suggest that a sensible choice is a random choice. Another reason for this expectation was that our earlier questions (Question~\ref{Q1} and Question~\ref{Q3}) show that our participants do regard computers as effective in calculations. As we argued earlier, if the merit of the case for two humans cannot be determined, a fair choice is a random choice. These two questions have been worded so as to suggest that computers would be of valuable assistance even when making random choices. We find responses to Question~\ref{Q13} (see Figure~\ref{Question13}) are not inclined to a particular level of machine intervention. The results indicate a preference for computer involvement in such randomized decision-making alongside significant human participation. Only for the teachers, the median is to use a computer's random choice and this is statistically significant over online respondents responses ($U=2,040$ and $p=0.0003$). \begin{figure} \centering \subfloat[\label{Question13}Question~\ref{Q13}: If selecting which pedestrian to harm, what provides better randomness.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question13}} $\;\;$ \subfloat[\label{Question20}Question~\ref{Q20}: If selecting which passenger to eject from a flight, what provides better randomness.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question20}} \caption{\vspace{-1mm}\label{Q13ANDQ20bars} Divergent bar charts of responses to Question~\ref{Q13} and Question~\ref{Q20}. } \vspace{-2.5mm} \end{figure} Question~\ref{Q20} recalls the scenario of Question~\ref{Q3}, where airline staff ejects some passenger from a plane. The scenario now insinuates that a random choice is required, and the responses here favor a strong use of computers in sharp contrast to the results we just described for Question~\ref{Q13}. In this setting, only less than $13\%$ of the online respondents chose the human alone option. Teachers, Open Day visitors, and academics are decisively for computer use. The option where the human decision-maker would do marginally better than a computer program received no responses from the teachers, no response from the academics, and only one from the Open Day visitors. Comparing teachers' responses to Question~\ref{Q20} with those to Question~\ref{Q13}, we find they are statistically significant ($U=923$ and $p=0.0118$). Similarly, academics' responses to Question~\ref{Q20} and Question~\ref{Q13} ($U=38$ and $p=0.0914$) and Open Day visitors' responses to Question~\ref{Q20} and Question~\ref{Q13} ($U=78$ and $p=0.116$) are also statistically significant. \textbf{Discussion:} Note that Question~\ref{Q13} concerns a scenario where a decision results in a human being suffering some physical harm. Under such circumstances, exclusively human and fully automated decisions are the least preferred choices. However, the three groups (academics, teachers, and Open Day visitors) display an absolute and radical shift in favor of computer/machine randomness when the issue (Question~\ref{Q20}) does not seem to be a matter of life or death. It seems that human preferences for AI decisions are dependent on the issues at stake. Question~\ref{Q24} offers a Likert scale with the standard options (Strongly Disagree, Disagree, Neutral, Agree, Strongly Agree) regarding the respondents' belief that computers can obtain fair random numbers for an unbiased choice when merit is equal. Figure~\ref{Question24divergent} shows respondents strongly believe that computers can reproduce a truly random generator. \begin{figure} \centering \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question24} \caption{\vspace{-1mm}\label{Question24divergent} Responses to Question~\ref{Q24}: Computers would be able to generate random numbers to make fair decisions when the merit between two people is equal. } \vspace{-2.5mm} \end{figure} Although online respondents have a median and a mode that agrees on computers ability to achieve randomness, from a Mann-Whitney test we get a $p$-value of $0.2183$. Thus, we can reject the null hypothesis that the online respondents and the Open Day visitors have the same scoring tendency at the $5\%$ level. Teachers and academics clearly believe even stronger (see Figure~\ref{Question24divergent}) in achieving fair decisions with random generators in computers. It is not surprising that respondents differ when discussing randomness, seeing as there are several accepted mathematical approaches on the issue~\cite{Volchan}. Finally, Question~\ref{Q25} and Question~\ref{Q26} offer only yes/no options. Question~\ref{Q25} aimed to find out if participants are aware of CPUs' capacity to use thermal noise within the silicon as an entropy source. Overwhelmingly, our respondents answered no. Only two of the academics were aware of this issue. Question~\ref{Q26} tested for participants' awareness of the controversy around replacing the random oracle model with cryptographic hash functions. Again, positive responses were minimal (below $1\%$) expect for the academics, where $2$ in $13$ (i.e., $15\%$) indicated their knowledge of the random oracle controversy. \textbf{Discussion:} Overall, it would seem that the public has trust in machines exhibiting non-deterministic and random behavior with what seems like little understanding of implementation issues. Indeed, people are generally not particularly bothered with how machines work as long as their use is socially considered an improvement: \begin{quote} \emph{``Risks do not militate against the introduction of automated driving if the balance of risks is fundamentally positive''}~\cite{GERMANreport2017}. \end{quote} \section{Conclusions} \label{Conclusion} This paper has argued that if AI systems are to be involved in the automation of decisions affecting human lives, such decisions would need to be randomized for a significant number of scenarios. We also noted that this would revolutionize the notion of machine (automata): Determinism and deductive reasoning would alternate with random choices of carefully learned distributions. AI systems would give the impression of possessing some sort of free spirit, despite consistently following the law and making information-based decisions. Importantly, their decisions would even be potentially explainable and rationalizable (in the sense of game theory) and justifiable (in the sense of human interpretability). Potentially, most people could grow truly comfortable with AI decisions, perceiving them as fairer and less biased than human decision-makers. Others would likely find the idea of giving chance such a central role in decisions that so crucially affect their lives highly unsatisfactory. We have mathematically proven the validity of our arguments for random classifiers in the supervised learning setting, and also furnished game theoretic evidence for the superiority of mixed strategies under partial information assumptions. We have also provided empirical evidence to support that there is at least some societal acceptance for deploying random classifiers. Our results show that while people tend to favor partially or even fully automated decisions over human decisions in many circumstances, there is reluctance to resort to randomized decisions in life-or-death situations. Finally, we also discussed some policy and implementation issues with a particular focus on potential tradeoffs in connection with ever-increasing transparency requirements and current challenges in generating truly random sequences, to contribute to relevant debates in current AI policy and standardization initiatives. Our aim was to provide insights that are useful both for AI researchers and policymakers. Researchers of various disciplines active in the AI field can benefit from our interdisciplinary approach, which links formal ML and game theory propositions with the state of art in AI ethics research and key current regulatory/policy considerations. Braking down traditional silos this way helps illustrate how insights from these disparate fields fit together in solving the important real-life problems we address. On the policy side, we connect to key international AI policy and standardization initiatives. These initiatives increasingly attempt to guarantee the highest possible levels of transparency and explainability of AI systems to ensure accountability. While this is a commendable goal, our key message to policymakers is that maximizing transparency levels is neither the only nor necessarily the best solution. Instead, we need to keep potential drawbacks of transparency in mind and explore alternative accountability mechanisms that allow us to garner the benefits of randomization. We believe the discussion here also raises a series of other interesting questions. For instance, do our findings also hold for other than supervised learning tasks? On the game theory side, we indicated that AI interactions would be repeated games from a game-theoretic perspective and that human agents would be inclined to game the system if transparency requirements revealed the deterministic nature of the AI. Human agents would adapt. Should the AI adapt as well? Should it include ML modules for continuous learning? While the examples could go on, we hope to have sparked some interest in both the scientific and policymaking community to engage with these and many more related open problems. {\small \section{Introduction} \label{intro} Among a society of equals, decisions affecting members' lives are of the utmost importance. Accordingly, in the pre-AI age, it was a widely accepted---but unfortunately less widely practiced---principle that society should entrust carefully selected human decision-makers with such choices. Ideally, those positions would be associated with strict requirements on appropriate expertise and moral integrity, as well as rigorous accountability mechanisms, to provide sufficient assurance for society to trust the judgment of those in charge. Over time, however, technological innovation has enabled the automation of a growing number of tasks in, e.g., production processes, transport, and the information and communication sector. Successful attempts of automation radically improved human performance, significantly raising humanity's welfare and continuously changing our way of life. Most episodes of innovation have entailed more or less severe temporary disruptions until the economy adjusted to the effects of innovation, society has become familiar with the new technologies in question and either grew to trust them or rejected their adoption due to negative experiences. Recent leaps in computing capabilities coupled with the availability of large data sets and breakthroughs in \emph{machine learning} (ML)---a prominent subset of AI approaches, which employs algorithms that rely on a variety of methods to build machine-interpretable knowledge representations---have now ushered in a new era of innovation: One, in which ML-based algorithmic data-driven decision-making systems (A3DMs) are assuming an increasing role in making decisions across diverse domains reaching from lending~\cite{Aziz2019}, insurance, and housing to college admissions~\cite{Jamison,Thomas16}, hiring~\cite{Chalfin2016}, and the justice system~\cite{Kugler2018,Heidari2019}. On the bright side, such AI systems can easily map humanly untraceable correlations, outperforming their human counterparts. Better results in cancer diagnosis in healthcare~\cite{LITJENS201760} and correcting potentially substandard performance of human judges who \begin{quote} \emph{``effectively under-weight key observable variables like prior criminal record''}~\cite{Kleinberg2017} \end{quote} are just two examples of the benefits ML-assisted decisions can provide. The flip side of the coin is, however, that ML-based AI systems are prone to learn biases present in training data and incorporate systematic error, which are unacceptable where their decisions crucially affect human lives~\cite{Osoba2017AnII}. In part, this is an inevitable by-product of their inductive-learning nature, but there are many other sources of problems. For instance, for various reasons, exploiting big-data sets with ML\/ tools can lead to discriminatory models that issue unfair decisions~\cite{Corbett2018}. Moreover, \emph{Adversarial examples}---i.e, inputs where the ML\/ systematically produces the wrong answer although humans would easily perform correctly~\cite{athalye2017synthesizing,brown2017adversarial}---are an issue with deep neural network-based classifiers. Some architectures also tend to get very opaque, and it is particularly challenging to design and train systems in a manner that aligns with human values~\cite{Gunning_Aha_2019}. Academic literature and a wide range of domestic and international policy documents are striving to put forward proposals to alleviate these problems: Topics in the focus of attention include algorithmic fairness and transparency~\cite{Lee2019}, explainability~\cite{Holzinger2018,miller2019,rudin2019}, human-in-the-loop~\cite{Amershi2014,vandenelzen2011}, human-centric and ethical design of AI systems~\cite{OECD2019,IEEE2019}, legal liability~\cite{EE2020}, and many more aspects contributing to the trustworthiness of AI technologies~\cite{Ustun2019,LD2020,EUReport,EC2020,EMCCD2020,FFLT2020,MR2020}. The current perspective is that AI applications---like other machines---are but mere tools lacking moral agency~\cite{SK2018,FES2020} and legal personality~\cite{CK1994}. Thus, any harm they may bring about is by definition the result of human stakeholders' poor design or misuse, for which these human actors rather than the artificial agents are responsible~\cite{SW2020}. Still, it is interesting to look into when exactly we would deem an AI system fair or ethical. Even before the advent of AI, views on the right or ethical behavior in any given situation have been varying widely across different ethical theories, cultures, and time dimensions. Most of these differences have proven themselves to be virtually insurmountable and persist to date. Somewhat reassuringly, however, we understand the mathematical principles of AI technologies and can---as long as the prior probabilities of new cases are known and remain unchanged---accurately estimate their precision in unseen cases within the same context. But there are substantial technical limits to instilling moral values into AI systems. The challenges have been epitomized by the so-called \emph{value alignment problem} that requires AI to be deployed with moral values aligned with those of humanity. Various proposals have been put forward advocating the design of AI systems that are capable to reason about the virtue of their actions~\cite{Hall} or otherwise exhibit moral agency~\cite{Adam2008,FuenmayorB20,Wallach}. Some commentators propose to supply AI with moral-decision making ability using deontic reasoning~\cite{Young1995,BringsjordGMS18} or conceptual spaces. An example for the latter approach is the idea to construct a geometric space of moral principles and solved ethical cases and make decisions by finding the Voronoi cell for a given situation~\cite{Peterson2019}. This can be either categorized as case-based reasoning~\cite{Sriram1997} or instance-based learning~\cite{Witten}. Thus, challenges arise both when determining (1) which and how many dimensions suitably conform the moral space and (2) what specific metrics should be used to find the nearest solved moral situation or principle. These examples illustrate that, at present, technical solutions to the value alignment problem are significantly incomplete. Others advocate that ML\/ should incorporate equal opportunity by design. This suggestion is based on a series of proposals on various notions of fairness and/or non-discrimination such as \emph{independency constraints}~\cite{Calders2009}, \emph{group and individual fairness}~\cite{Zemel2013}, \emph{equality of odds}~\cite{Hardt2016}, and \emph{predictive value parity}~\cite{Kleinberg2017measure}. Apart from practical obstacles of implementing such fairness criteria in the design of algorithms, this begs the question of which notion of fairness, if any, deserves priority. Again, opinions differ, with some rejecting the idea altogether, arguing that ethics always implies human choice~\cite{Vallor2018}, hence machines should never be allowed to meddle with human affairs~\cite{Rosenberg2004}. The use of AI in legal processes is also heavily criticized~\cite{Piccolo2018}. This diversity of views introduces additional layers of complexity in the debate, making the prospect of international consensus rather remote. In this paper, we do not aim to include the full spectrum of AI approaches and all the possible ways in which they may affect human lives. Instead, we only deal with ML-based AI systems that perform supervised classification tasks. This is because, even before the emergence of deep-learning, most ML\/ and data mining deployments center around classification tasks~\cite{Wutop10AI}: Fields, such as computer vision~\cite{Himanshu} and Internet of Things~\cite{Cui2018}, are dominated by applications that build and deploy classifiers. Supervised model training is the core method to master classification tasks in specific industrial settings, such as construction~\cite{HONG2020109831}. We only consider moral choices made by such AI systems, i.e., voluntary, reasoned choices that affect others~\cite{Quinn}. That said, we do not attempt to go to the bottom of centuries-long, intricate, moral debates and how these may or may not apply to ML-based AI systems. The reason for this is that an ethical decision---on whatever ethical basis---is only conceivable under a full-information assumption at the time of decision-making. However, virtually all settings in which reliance on AI decision-making is necessary are characterized by some degree of uncertainty (the outcome is typically in the future)---indeed, the presence of uncertainty is the very reason for using AI predictive systems. Against this background---without addressing specific moral justifications---we model moral decisions of artificial agents in a game-theoretic manner with the objective to arrive at two conclusions. Our first conclusion proposes that there exist random classifiers that perform at least as well as their deterministic piers, making them the optimal choice of classifier in some settings. This finding is significant, as humanity's notion of \emph{automation} has so far been predominantly deterministic: Automation has been practically equivalent to determinism, in that machines are considered to be deterministic devices implementing functions, whereby from a given state and input only one successor state is possible, unless the machine is malfunctioning (e.g., if we push button ``5'' in an elevator, we expect it to drop us off at the 5th floor of the building, not some unpredictable level). Similarly, the vast majority of supervised ML literature~\cite{Bishop,Hastie,Mitchell1997,Michie95} considers the search for a classifier a search for a \emph{mathematical function}, and therefore implemented by a deterministic algorithm that consistently produces the same output from a given input~\cite{Hastie}. \begin{quote} \emph{``Our goal is to find a useful approximation $f'(x)$ to the function $f(x)$ that underlies the predictive relationship between the inputs and outputs''}~\cite{Hastie}. \end{quote} \emph{Feedback-loop controllers} are also crucially defined as functions---to each specific input, there is only one output---\cite{AstromMurray}, and robot safety has been equivalent to robots consistently keeping their distance and stopping fast enough when people are around~\cite{Malm2019}. For our second conclusion, we argue that in a game-theoretic model of the interactions of the decision-making AI and other rational agents, the AI may only be able to behave optimally---i.e., so as to yield a Nash Equilibrium---if it follows a mixed strategy, that is, a randomized algorithm. This follows from the fact that games are guaranteed to have a Nash Equilibrium only in the space of mixed-strategies. Also, by equating settings with incomplete information to the game of matching pennies, we show that any pure strategy the AI may adopt would be sub optimal. Moreover, pure strategies, when used repeatedly, can---and eventually will---be exploited by other (human) agents, which seek to selfishly maximize their own utility. Thus, mixed strategies are the most suitable strategies when decision makers face repetition (i.e., repeated games)~\cite{GeckilAnderson}. Therefore, paradoxically, it would seem that in certain situations, a truly ethical, fair, and trustworthy AI must behave randomly and gamble with our faith, regardless of which ethical theory and/or notion of fairness it is basing its actions on. This is not to say that we are opposed to the idea that automated decision-making systems have strong ethical foundations. On the contrary, these play a crucial role in our models. However, we argue that within those moral frameworks, there exist situations, in which fairness may dictate randomized choices. Accordingly, the focus of this paper is not so much on any particular notion of fairness and/or ethical theory as on the conditions under which random decisions are unavoidably necessary and what they imply. Accepting the premise that trustworthy AI must act randomly under specific conditions has certain profound implications. First, we will need to revise our deterministic notion of automation. Doing so will require a fundamental mindset change---be it in the general public, businesses, academia, or among policymakers. This will not be easy to achieve. That said, reassuringly, there is already some recognition that randomization cannot be simply equated with erratic, irrational, unpredictable, uncontrollable, and hence irresponsible actions, but is a very much rational---sometimes even optimal---behavior~\cite{GeckilAnderson}: \begin{quote} \emph{``Game theory models, by definition, focus on the effects of one party's decision on another's interest. Such decisions are not random ones. We assert this is true even when an opponent follows a `mixed strategy' that includes the use of random actions, because the choice to use randomization as the basis for an action is a specific decision itself, not a random event.'' } \end{quote} As we pointed our earlier, the field of machine ethics~\cite{Moor2006,Wallach} has also adopted that an explicit ethical agent must display rationality by logical argumentation and justify moral decisions with some form of cognition~\cite{Serafimova}. However, others are critical of this position~\cite{Allen}. \begin{quote} \emph{``What we don't want to do is make the stronger claim that the whole of cognition is just theorem proving, model finding, expectation maximization, or some similarly general inference procedure''}~\cite{Bello2013}. \end{quote} We emphasize that game theory solutions explicitly consider the rationality of all decision-makers: One player's decision process takes account of those of other players'. Rationality is thus not only relevant to game theory, but also constitutes a form of theory of mind~\cite{cuzzolin_morelli_cirstea_sahakian_2020,premack_woodruff_1978}. Such modeling of others for moral decision-making is also present in debates on machine ethics~\cite{Clark2010,Bello2013}. To the best of our knowledge, only a few papers have discussed game theory as a mechanism for moral agency~\cite{Hall}. We explore this matter further in Subsection~\ref{TheCaseForMixedStrategies} where we examine mixed strategies. Colman uses game theory to discuss Kant's categorical imperative and other ethical matters~\cite{Colman99}. This discussion shows that game theory concepts are useful to refine philosophical arguments. However, Colman's presentation fails to consider mixed strategies to debate issues such as the universality of and balance between altruist and selfish behavior~\cite{Colman99}. Second, accepting that trustworthy AI may have to act randomly also offers an opportunity to reflect on the appropriate levels of transparency requirements for AI systems. Although random classifiers are somewhat less susceptible to exploitation, we later show that transparency may raise issues even here. Finally, we face an implementation problem: Under the current state of art of technology it is debatable whether true randomness can be achieved. We report a empirical study consisting of a series of surveys to test the public's attitude towards randomized artificial decision-makers. Our results show that despite the above mentioned difficulties of implementing randomized AI systems, humans do not seem to be particularly concerned about machines randomly deciding over various aspects of their lives. On the contrary, they often prefer machine-made decisions over human decisions. The rest of the paper is structured as follows: Section~\ref{Prelims} presents the necessary notations to make a case for our argument that in certain situations, AI systems need to use randomized algorithms to behave optimally. Section~\ref{Results} outlines our results. Section~\ref{ImplandPol} considers certain implementation and policy issues that arise from the use of random classifiers. Section~\ref{casestudy} presents our empirical study, and Section~\ref{Conclusion} concludes. \section{Preliminaries} \label{Prelims} In this section, we outline some basic ML\/ and game theory notions necessary for our purposes, as well as notations we will use throughout this paper. For a detailed overview of ML\/ see~\cite{Bishop,Hastie,Mitchell1997,Witten} and on cooperative and non-cooperative game theory, see~\cite{Hespanha,Myerson97,rot:b:economics-computation}. \subsection{Machine Learning} The most dominant application of AI technologies by several indicators and by several orders of magnitude is ML~\cite{Columbus}. For instance, \$28.5 billion USD was invested in machine learning applications in the first calendar quarter of 2019, leading all other AI investment categories~\cite{Columbus}. \emph{Supervised learning} is the family of ML\/ algorithms that enables a computer system to receive labeled data and produce another algorithm---called a \emph{classifier} in case of classification tasks or more generally a \emph{model} for other tasks---that will obtain accurate predictions when supplied unlabeled data. More precisely, assume we have a large data set $C=\{ c_{1},\ldots,c_{n}\}$ of cases. For each case $c_{i}$ we have a vector (also known as \emph{attribute or feature vector}) $\vec{x}_{i} \in \mathbb{R}^d$ of values for some properties. We also have a \emph{label} or \emph{class} $\mbox{\cal A}(c_{i})$, where $\mbox{\cal A}(c_{i})\in \{A_{1},\ldots,A_{k} \}$. If the set of possible labels is finite, we face a classification task, if it is infinite, a regression task. The most common formulation of the \emph{induction principle}~\cite{CherkasskyM98} for supervised learning is to minimize the cost of misclassification---i.e., maximize accuracy---in \emph{unseen cases}. The latter are sometimes also referred to as \emph{cases in the future}~\cite{Hastie} or \emph{cases outside the training set} $C$. In any case, the classifier's job is to complete the missing information (provide the label) for an unlabeled case. Statistical decision theory~\cite{Hastie} analyzes the accuracy in the future as follows~\cite{Michie95}\footnote{We chose an early reference on ML\/ terminology to ensure is compatible with all recent developments, but others~\cite{Hastie} offer similar notation and treatment.}: We assume that there is a prior probability $\pi_j$ for each class $A_j$. That is, $\pi_j=\mbox{Prob}(A_j)$ means that the chances of running into a case whose label is $A_j$ in the future is given by $\pi_j$. The ML\/ algorithm will build a classifier $M$ that will map the vector $\vec{x}_{c}$ (of attribute values of case $c$) into a label $M( \vec{x}_{c} ) \in \{A_{1},\ldots,A_{k} \}$. Every time $M( \vec{x}_c ) \neq \mbox{\cal A}(c)$, the classifier $M$ commits a misclassification error that has a cost $\kappa(c,M( \vec{x}_c ))$. If $M$ ignores all information about a case, i.e., ignores the attributes $\vec{x}_c$, and deterministically chooses the class $A_d$ for all inputs, it incurs a cost of \[ \sum_{j} \pi_j \kappa(c_j,d), \] where $c_j$ denotes a case in class $A_j$. Choosing within the family of models that ignore all evidence and information about a case can be optimized and the optimal model (under uniform miss-classification costs) in the family responds with the class with the highest prior probability. ML\/ generally also involves a heuristic search algorithm within a typically very large family of models to find the member of the family that optimizes accuracy estimators and potentially other structural properties. We usually do not know the $\pi_j$'s---otherwise there is little learning to do. Continuing with our discussion, ML\/ algorithms do deliver classifiers that examine and use the evidence, i.e., the attributes $\vec{x}_c$ of case $c$. The relevant probability now is the conditional probability $\mbox{Prob}(A_{j} | \vec{x}_c )$ of the class $A_j$ being the correct class when we observe $\vec{x}_c$ in the input case $c$. Thus, to identify the model of minimum cost, this should be conditional on the information $\vec{x}$. Now, when $M$ decides $A_d$ when the evidence is $\vec{x}$, the expected cost is \begin{equation} E[[M\mbox{ decides } A_d ]] = \sum_{j} \mbox{Prob}(A_j | x) \kappa(j,d), \label{costRaw} \end{equation} where $\kappa(j,d)$ is the cost of miss classifying as $A_d$ when the case actually belongs to $A_j$. Using Bayes theorem, \begin{equation} \mbox{Prob}(A_j | x) = \pi_j \frac{ \mbox{Prob} ( x | A_j) } {\sum_s \pi_s \mbox{Prob}(x | A_s) }. \label{Bayes} \end{equation} However, since $ \sum_s \pi_s \mbox{Prob}(x | A_s)$ is a constant, we can simplify Equation~(\ref{Bayes}) and then replace $\mbox{Prob}(A_j | x)$ in Equation~(\ref{costRaw}). We conclude that deciding on $A_d$ has a cost of \begin{equation} \sum_{j} \pi_j \kappa(j,d) \mbox{Prob} ( x | A_j), \end{equation} modulo a constant factor that is the same for all $d\in \{1,\ldots,k\}$. Under the assumption that these are continuous distributions where the probability density function is $f_{j}(\vec{x})= f(\vec{x} | A_j)$, the optimum is the $d\in \{1,\ldots,k\}$ where \begin{equation} \sum_{j} \pi_j \kappa(j,d) f_{j} ( \vec{x}) \label{Distributions} \end{equation} is minimum. In the case of discriminating between two classes $j_1$ and $j_2$ ($k=2$) and $\kappa(j_1,j_1)=\kappa(j_2,j_2)=0$, Equation~(\ref{Distributions}) reduces to $M$ declaring class $A_{j_1}$ if \[ \frac{ f_{j_1}( \vec{x} ) }{f_{j_2}( \vec{x}) } > \frac{ \pi_{j_2} \kappa(j_1,j_2) } { \pi_{j_1} \kappa(j_2,j_1)}. \] The classifier $M$ should declare $A_{j_2}$ otherwise. This is a fundamental likelihood ratio all supervised ML\/ algorithms are attempting to optimize---commonly even assuming $\kappa(j_1,j_2)= \kappa(j_2,j_1)$. We now interpret this result examining some simple cases. Consider not only $k=2$ but $\kappa(j_1,j_2)=1$ when $j_1 \neq j_2$. Moreover, we will assume $ \pi_{j_1}= \pi_{j_2} =1/2$. That is, we have a balanced mixture from where our cases are drawn, and with equal probability we have a case from class $A_{j_1}$ or class $A_{j_2}$. If we do not look at the evidence, choosing $M$ as a constant function will make errors $50\%$ of the time (the two classifiers in the family of constant functions are as good or as bad). If the classifier can examine the evidence $\vec{x}$ and we know $f_{j_1}( \vec{x})$ and $f_{j_2}( \vec{x})$, the optimal classifier is given by \begin{equation} M( \vec{x} ) = \left\{ \begin{array}{ll} A_{j_1} & \mbox{if } f_{j_1}( \vec{x}) > f_{j_2}( \vec{x}), \\ A_{j_2} & \mbox{if } f_{j_2}( \vec{x}) > f_{j_1}( \vec{x}). \end{array} \right. \end{equation} This should be intuitively clear. In fact this leads to \emph{Fisher's Linear Discriminant} being the optimal classifier if the environment draws classes from a mixture of two multivariate normal distributions with \begin{enumerate} \item equal diagonal covariance matrices $\Sigma = \lambda I_{d}$ and \item equal weights, i.e., $1/2$ each. \end{enumerate} If we have a mixture of more than two classes but all the weights equal to $1/k$ and all covariance matrices are again diagonal matrices with the value $\lambda$ in the diagonal, the optimal classifier is the $k$-nearest neighbor that, on vector $\vec{x}$, declares the class where the mean $\vec{\mu}_{j}$ is nearest to $\vec{x}$. One way to visualize this last case is to note that the multidimensional bell shape of the multivariate normal \[ \mbox{\cal N}(\mu,\Sigma) = (2 \pi)^{-d/2} det( \Sigma)^{-1/2} e^{-\frac{1}{2} (\vec{x}-\vec{\mu})^{T} \Sigma^{-1} (\vec{x}-\vec{\mu})} \] will have level curves that are spheres around $\mu$ and $f_{j_s}( \vec{x}) > f_{j_t} ( \vec{x})$ if $\vec{x}$ is closer to $\vec{\mu}_{j_s}$ than to $\vec{\mu}_{j_t}$. Note that when $\Sigma = \lambda I_{d}$ for each class, $(\vec{x}-\vec{\mu})^{T} \Sigma^{-1} (\vec{x}-\vec{\mu})$ is the Euclidean metric scaled by the same factor for all components of the mixture. \subsection{Game theory} At present, the vast majority of artificial decision-makers operating in all sorts of industrial settings are constructed by applying supervised ML. There are huge data sets of labeled cases and digital records of attributes. The classes are decisions---for instance whether or not to award credit to a customer based on the data indicated in their credit application. Some of these decisions have ethical consequences because they impact individuals' well-being. At the extreme, classifiers as autonomous machines may have to make life-and-death decisions (e.g., targeting decisions of autonomous weapon systems and \emph{trolley problem} type of scenarios~\cite{Foot1967}, where the classifier has to decide whether to harm individual(s) $X$'s or individual(s) $Y$'s welfare). In such cases, it is of paramount importance to make the right decision, so the question arises: How can such algorithms make optimal choices? Game theory---which studies conflict and cooperation between rational agents---is helpful to answer that question. A \emph{game} abstracts the fundamentals involved in decision-making---such as agents' possible moves, actions, choices, and decisions---and formalizes \emph{rationality} as acting to maximize \emph{utility}. Games can be either cooperative---where agents form factions in order to maximize their utility---or non-cooperative---where agents do not coordinate their actions. This paper only uses non-cooperative settings where one agent is the \emph{environment} (or \emph{future}), which clearly cannot cooperate. It is common to apply game theory with such an adversary to achieve \emph{robust designs}~\cite{Hespanha}. Given a game, a solution is to determine the most rational decision each agent should reach. Importantly, all information for making the decision is represented in the modeling of the game---if there was more information, we would be discussing a different game. The game also identifies the decision-makers or influencers as \emph{players} and all options available to them---typically a set of exclusive decisions. Formally, in a game with $p$ agents, for each agent $P_i$, $1\leq i \leq p$, there is a set $D_i$ that defines agent $i$'s set of possible decisions it can pick. The elements of this universe of decisions are called \emph{pure strategies}. The solution of the game is the set of strategies that each agent must perform to maximize their individual utility. In a game with $p$ players, the value each player will receive when all players have declared their decision is specified ahead by \emph{payoff functions} (sometimes also called the \emph{payoff matrix}). These are typically a set of functions $u_{j}(d_{1},\ldots,d_{p})$ that provide the utility to player $P_j$, $j \in \{1,\ldots,p\}$, when each player $P_i$ makes decision $d_{i}$, for all $i\in\{1,\ldots,p\}$. From very early on in the study of game theory, it was observed that players can also use \emph{mixed strategies}. A mixed strategy is a randomized algorithm, i.e., a probability distribution over the possible pure strategies. A \emph{Nash equilibrium} is a solution that suggests the ultimate rational behavior for agents: It implies that---even if other players' decision-making strategies became known to them---none of the players $P_i$ would have any incentive to change their behavior. That is, in a Nash equilibrium, every player selects its strategy and cannot do better even if other players disclose theirs: For every player $P_j$, despite knowing the choice $d_{i}$ for all other players $j\neq i$, changing their choice $d_j$ cannot increase the value of $u_{j}(d_{1},\ldots,d_{p})$. An alternative characterization is that, in a Nash equilibrium, a player's choice is the best response to the others' best-responses (and this is true for each player). While every finite game has a Nash equilibrium with mixed-strategies, a Nash equilibrium with pure-strategies may not exist. A very famous illustration of game theory applicable to many cultures is the game \emph{rock, paper, scissors}. Here, each player makes a decision selecting one from the set $D= \{ \mbox{\emph{rock}}, \mbox{\emph{paper}}, \mbox{\emph{scissors}} \}$. The choices are simultaneous. \emph{Scissors} cut \emph{paper}, \emph{rock} breaks \emph{scissors}, and \emph{paper} covers \emph{rock}. Using the pure mathematical formulation of the game, it is clear that programming a machine to play this game deterministically is vulnerable to exploitation after inspection---there is no Nash equilibrium with pure strategies. However, a mixed strategy---a randomized algorithm that selects one of the three pure strategies with probability $1/3$---will win the same number of times as it ties or loses. This results in zero expected utility, which happens to be the optimum. It follows that, facing an opponent using a randomized strategy, it is best to use the same mixed-strategy as the opponent. \subsection{Equal Opportunity Principle} As emphasized earlier, for artificial decision-makers to be trustworthy and fair, they must base their decisions on some ethical theory and/or notion of fairness. When learning a classifier to enable their decision-making capability, AI systems need to convert some ethical principle(s) and/or fairness notion(s) into a formulation of the costs $\kappa$ of miss-classification. Similarly, the payoff functions of games modeling the interactions of the decision-making AI and its environment are ideally defined based on some ethical principle(s) and/or fairness notion(s). In line with our focus on the necessity and implications of randomized classifiers that employ mixed strategies, rather than debating the vices and virtues of different fairness concepts and ethical theories, we will adopt the principle of \emph{equality of opportunity (EOP)}. The reason for our choice is that the EOP is a central ideal of fairness studied in political philosophy and economics, which has been suggested to be a generalization of several measures of fairness for ML~\cite{Heidari2019}. We remark again that \emph{statistical parity}~\cite{Feldman2015}, \emph{equality of odds}~\cite{Hardt2016} \emph{equality of accuracy}~\cite{BuolamwiniG18}, and \emph{predictive value parity}~\cite{Kleinberg2017measure} can be regarded as particular forms of EOP~\cite{Heidari2019}. Essentially, the EOP aims to establish an initial level playing field---equality of opportunity---among individuals based on their innate qualifications rather than exogenous factors. At the same time, it allows for competition between individuals for different positions. This may result in different \emph{outcomes}, which are morally acceptable as long as they reflect individuals' \emph{merit} or \emph{deservingness}. Thus, the EOP distinguishes between morally acceptable and unacceptable inequality. Note that merit is highly contested~\cite{McCRUDDEN} and many question whether providing true equal opportunity is feasible in practice~\cite{Fishkin}. These concerns are particularly relevant for AI systems, which typically perform moral decisions based on incomplete information: With all likelihood, they do not consider all attributes of merit or measure merit accurately, all of which impairs their ability to precisely ascertain the differences in opportunity. But we need not deal with these problems here: What matters for our argument that AI decisions must use randomization is not \emph{what} particular ethical principle/fairness notion we use, but rather \emph{that} we need to use one of them. This is because, reliance on some ethical principle---in our case the EOP---is instrumental to, given a case $c$, defining $d$ attributes and their values that define the vector $\vec{x}_{c}\in \mathbb{R}^{d}$ for the AI classifier to make decision $M( \vec{x}_{c})$. Consider the example of a sentencing decision made by an AI system. In deciding the length of time in prison, merit attributes would be considered: What degree of remorse has the offender shown, how did their actions impact the victim(s), was the offense intentional and premeditated or rather reactive and emotional? These would constitute attributes of merit, ultimately determining the length of the sentence. Alternatively, in an AI-assisted parole hearing or release assessment, the application of the EOP may lead to considering attributes of (positive) merit like good behavior and increased educational level. These examples illustrate the role of ethical principles, such as the EOP, in dictating the dimensions (attributes) of the vector for an AI-based system to make a decision. They also give a feel for what we mean by incomplete information: At the time of sentencing, the AI-judge has to make a decision in the absence of the valuable hindsight that is available from the data to the AI-judge at the time of the parole hearing. In Appendix~\ref{EOPintro}, we reproduce the instructions to the subjects of our empirical study and the background on the EOP that was supplied to them. \section{The Case for Non-Deterministic Classifiers} \label{Results} Although randomization (non-determinism) is prevalent in mathematics, computer science, and artificial intelligence, we believe that the focus on deterministic classifiers derives from the tradition to perform the analysis of misclassification error using statistical decision theory~\cite{Hastie}. As we already explained, such analysis formulates that classifiers should be mathematical functions, selected by the learning process from families of functions~\cite{CherkasskyM98}, and thus deterministic mappings from inputs to outputs reflecting the \emph{decision boundaries}~\cite{HandSmythMannila} in the classes. This view of classifiers as functions reflecting decision boundaries~\cite{DudaHart} or decision surfaces~\cite{Bishop} is pervasive across models, whether it is artificial neural networks~\cite{Beale1990NeuralC}, support vector machines~\cite[Page~2]{cristianini_shawe-taylor_2000}, conceptual learning~\cite{Langley}, or decision-tree learning~\cite{Thornton}. \subsection{Random Classifiers May Be Optimal} \label{RandomCassifiers} Despite the predominantly deterministic approach towards automation so far, we argue that randomized algorithms~\cite{MotwaniR97} are mathematically valid families from which to infer and implement classifiers. We describe a simple case in which a randomized algorithm is optimal, i.e., no ML\/ algorithm can produce a deterministic classifier with less misclassification cost. \begin{proposition} There exist settings where randomized classifiers are optimal, i.e., no other classifier learned by any supervised learning technique can deliver a classifier with less misclassification cost. \end{proposition} \begin{proofs} Consider a scenario where the evidence is just one value $x \in \mathbb{R}$ (i.e., a vector of dimension $d=1$) and where the distribution of the two classes $f_{j_1}( x)$ and $f_{j_2}( x)$ is given as follows. Let the probability distribution of the first class be uniform on the interval $[0,b]$: \[ f_{j_1}( x) = \left\{ \begin{array}{ll} \frac{1}{b} & \mbox{if } 0\leq b \\ 0 & \mbox{otherwise}. \end{array} \right. \] The probability distribution of the second class is also uniform but on the interval $[a,c]$ of the same length: \[ f_{j_2}( x) = \left\{ \begin{array}{ll} \frac{1}{b} & \mbox{if } a\leq c \\ 0 & \mbox{otherwise}, \end{array} \right. \] with $0<a,b<c$ and $b=c-a.$ Moreover, we assume the mixture of these two distributions has equal weights with value $1/2$. See Figure~\ref{MixtureOfUniformDistributions}. \begin{figure} \centering \includegraphics[width=0.5\textwidth]{MixtureOfUniform} \caption{\label{MixtureOfUniformDistributions} Two uniform distributions with support of length $b$, where the second is the first shifted by $a$.} \end{figure} From our earlier discussion, the following deterministic classifier is optimal: \begin{equation} M_d (x) = \left\{ \begin{array}{ll} A_{j_2} & \mbox{if } (a+b)/2 \leq x \\ A_{j_1} & \mbox{if } (a+b)/2 > x. \\ \end{array} \right. \end{equation} This classifier is optimal whether $a<b$, $a=b$ or $b<a$. It always chooses the higher (or not lower) between $f_{j_1}( x)$ and $ f_{j_2}( x)$. However, consider the case illustrated in Figure~\ref{MixtureOfUniformDistributions} or the case $a=b$, and the following randomized classifier: \begin{equation} M_r (x) = \left\{ \begin{array}{ll} A_{j_2} & \mbox{if } b < x \\ A_{j_1} & \mbox{if } x < a \\ B(1,1/2)[ A_{j_1}, A_{j_2}] & \mbox{if } a \leq x \leq b, \\ \end{array} \right. \end{equation} where $B(1,1/2)[u,v]$ is one Bernoulli trial with probability $1/2$ where $u$ is selected on success and $v$ on fail. We argue that $M_r$ is optimal for all cases, even $a<b$ because by vacuity, the third case part of the definition of $M_r$ would not apply, so $M_r$ coincides with $M_d$. If Figure~\ref{MixtureOfUniformDistributions} or $a=b$ applies, any case with evidence $x$ with $a \leq x \leq b$ has equal probability of coming from class $A_{j_1}$ or class $A_{j_2}$. When $a \leq x \leq b$, the evidence is completely uninformative. If we choose the deterministic classifier $M_d (x) $ that always responds with $A_{j_1}$, it will be correct and wrong, respectively, $50\%$ of the time. The same holds if we choose $A_{j_2}$ for all $a \leq x \leq b$. Classifier $M_d (x) $ is not constant. It makes an error $50\%$ of the time for $a \leq x (a+b)/2$ because it always declares $A_{j_1}$, even though $50\%$ of the cases are from $A_{j_2}$. But it also has a $50\%$ error rate for $(a+b)/2 < x < b$, declaring $A_{j_2}$ on cases that are $A_{j_1}$. We now show that the random classifier $M_r (x)$ also makes the same expected error. Note that this analysis is the same as the profit analysis for the 2-player game \emph{Matching Pennies} introduced in the following subsection. The environment can draw from class $A_{j_1}$ or class $A_{j_2}$ with equal probability $p=1/2$. $M_r (x)$ declares $A_{j_1}$ or class $A_{j_2}$ with equal probability $p=1/2$ as well. The scenario is equivalent to tossing two fair coins as independent Bernoulli events, both with probability $1/2$, and declaring success when the coins match (i.e., outcomes (head, head) and (tails, tails)) and declaring a failure when the coins do not match (i.e., outcome (head, tails)). Thus, classifier $M_r (x)$ is correct $50\%$ of the time and incorrect $50\%$ of the time. \end{proofs} We may be tempted to say that for evidence $\vec{x}$ where $f_{j_1}(\vec{x}) = f_{j_2}(\vec{x})$ \emph{it does not matter} what the classifier determines as a class. The point we want to emphasize here is that randomized algorithms/classifiers (choosing differently each time they run) are not less optimal compared to systematic (deterministic) classifiers, hence their use in artificial decision-makers is worth consideration. \subsection{The Problem of Deterministic Classifiers} Matching Pennies is a simple game in basic game theory, which starts by two players submitting a covered penny, respectively, either heads or tails up. The players then simultaneously reveal their pennies with one of the following two outcomes: (1) if the pennies match---both heads or both tails---the first player (named the \emph{even player}) collects both as profit, (2) if they do not match---one head the other tail---the second player collects both pennies. Matching Pennies is one of the simplest examples of a game where Nash equilibria only exist with mixed strategies. We now use matching pennies to elaborate on our previous example of an AI system determining a sentence length. Aside from punishing offenders, deterring future crimes, and serving justice for victims and society, sentencing also pursues rehabilitation objectives: The intention is to calibrate sentences so as to ensure that offenders can redeem themselves and no longer pose danger to society after their release. That is, we want the AI prediction to achieve accuracy in the future. The problem is, however, that merit attributes relevant for determining whether or not the offender can be safely released into society upon completion of their sentence only materialize in the future, but none of them are available to our sentencing AI. The sentencing AI cannot possibly know if all convicts have equal opportunity to redeem themselves regardless of which correctional facility they have served their sentence in (probably not). This means that the vector $\vec{x}_{c}$ on which the sentencing AI supports its decision is only a projection to the present and is missing all the attributes of the future that will be known when deciding on the release. Accordingly, penitentiary systems mostly treat original sentences as mere estimates and regularly review release conditions before and during completion of the sentence. The environment plays as an adversary---as mentioned before, we alluded to this when we mentioned that game theory is used for robust design~\cite{Hespanha}. Thus, the sentencing AI is playing the game of matching pennies with the penitentiary system as to whether the sentence will achieve all its objectives. Much like this example, moral decisions made by AI systems are characterized by incomplete information. Often, cases look equivalent in the current set of attributes (in the current projection), but they are missing information on attribute values that are only completed later on. Suppose we are to construct a classifier that makes decisions affecting the well-being of two individuals: For instance, amidst the COVID-19 pandemic, a hospital has only one intensive care unit (ICU) available and two patients ($c_1$ and $c_2$) require it. We wish to allocate the ICU to the patient with the highest probability of survival. We feed extensive clinical and virological data~\cite{Chen2020,Lescure2020,ZhouLANCET2020} of identified risk factors from the now millions of patients infected with the disease into ML algorithms to obtain the classifier that decides between $c_1$ and $c_2$. As per the previous section, this means we have attribute value vectors $\vec{x_1}$ and $\vec{x_2}$ that codify the values in identified risk factors (e.g., age, obesity, diabetes, to name just a few). Note that problems arise when the available feature vector is uninformative, i.e., it does not allow to distinguish between the merit of $c_1$ and that of $c_2$---they are of the same age, weight, and so on. To whom should the classifier award the ICU in such cases? Deterministically, always on a first-come-first-serve basis? Is this fair or ethical by some metric? How will the public react if it notices that the individual who is entered as first patient into the classifier's input file always receives the ICU when both patients have the same merit? Now consider a different example: Training an ML system to make decisions in autonomous vehicles (AVs). Suppose that---when facing an imminent collision with either a motorcyclist wearing a helmet or a motorcyclist not wearing one---vehicles equipped with such classifier select the motorcyclist with a helmet as the victim due to the lesser likelihood of sustaining serious injuries. It is not hard to see how this may eventually motivate motorcyclists to drive without helmet to avoid being selected as victims by AVs---an outcome that is clearly undesirable from a general safety perspective. A potential solution could be for the AI to play a (finitely or infinitely) \emph{repeated game}~\cite{Dutta}. For now, we will not further entertain game theoretic repeated games. Suffice to say that automating with an AI implies the use of a large amount of instances and repeated games typically result in extremely different behaviors from single interaction games. The list of examples could go on. The point we would like to emphasize is that individuals are likely to change their choices to exploit the classifier if its decisions are deterministic---a behavior that becomes easier the more transparent the classifier is. This shows that (1) transparency may have substantial adverse effects in pure-strategy game settings---although, as we will explain below, it poses issues even in mixed-strategy game settings, (2) deterministic classifiers cannot necessarily achieve a Nash equilibrium, i.e., behave optimally, and (3) it is of crucial significance whether or not we can anticipate all the factors relevant to making a decision, i.e., whether or not we have a complete feature vector for a particular case. \subsection{The case for mixed strategies} \label{TheCaseForMixedStrategies} Our arguments in the previous sections already support the idea that AI-classifiers should use a mixed strategy and make random choices (but note that `random choice' under a mixed strategy is not any arbitrary unjustifiable choice, it is to wisely select a particular optimal and fixed probability distribution, which can be justified in a game theory sense, and from there to apply it to select a pure strategy). To stress this point further, we now use a 2-player game to examine the challenge faced by a classifier that can choose only between two options. The classifier is the first player, and has two \emph{pure} strategies at its disposal: (1)~to harm the welfare of individual(s) $X$ or (2)~to harm the welfare of individual(s) $Y$. The other player is again the environment, which can place the negative merit that leads to the scenario of harm either on~$X$ or~$Y$. We start with a scenario, where the AI faces the rare luxury that merit is ascertainable. As shown below, even such settings can raise complex moral dilemmas: \begin{center} \fbox{ \parbox{0.95\textwidth}{ {\scriptsize Two passengers in an AV are driving safely and obeying the speed limit in a lane labeled as only for AVs. As an extra safety measure, the road also has barriers to minimize pedestrians accidentally invading the designated AV lane. Six intoxicated pedestrians who have illegally jumped the barriers and failed to check if there were oncoming vehicles suddenly jump in front of the AV. Should the AV harm the pedestrians or swerve and harm the passengers? }}} \end{center} Here, the AI can ascertain that the illegally crossing pedestrians are responsible for the now unavoidable harm to human lives. Best efforts to apply brakes, yet not changing direction and causing some unavoidable harm is widely regarded as acceptable even for human drivers~\cite{Bonnefon,Estivill-CastroEthics,Moore}. Presumably, thus, such a merit-based, deterministic decision would not raise any eyebrows even in the case of AI decision-makers. That said, the best course of action dictated by utilitarian ethics may change depending on the particular circumstances of a given scenario and the \emph{ethical} action may not be \emph{feasible} in practice: For instance, the vast majority of society would accept utilitarian cars and confirm that if the six pedestrians were correctly crossing the street, the ethical decision by the AV---by utilitarian standards---would be to swerve risking the well-being of the two passengers. But, people also admit they would not own such a vehicle~\cite{Bonnefon,Estivill-CastroEthics,Moore} and would game the system by artificially adding passengers to their cars. Such practical issues may be at least to some extent alleviated if some degree of randomization is introduced into the classifier. Leaving aside the question of how exactly such randomization is achieved for the moment, we restrict ourselves to point out that this observation provides a strong argument for randomized classifiers even in scenarios where merit is ascertainable. Now consider a variation of this scenario where merit is not readily ascertainable: \begin{center} \fbox{ \parbox{0.95\textwidth}{ {\scriptsize The two passengers in the AV are driving safely and obeying the speed limit in the same AV lane as in the previous scenario. The six pedestrians suddenly appear in front of the AV. However, they are neither intoxicated nor crossing the road unlawfully. Rather, they cross over a zebra-indicated zone that is also equipped with traffic lights, which unfortunately do not work. It is unknown, whether or not they took all reasonable safety measures before crossing. What should the software be programmed to do? }}} \end{center} In this new scenario, it is likely that the AI---while reasoning about merit---reaches the conclusion that it is not ascertainable. We already mentioned that many oppose against any machine participation in moral decisions impacting humans. In the case of AVs, this is confirmed by the Report of the German Ethics Commission on Automated and Connected Driving~\cite{GERMANreport2017}, suggesting that any tragedy involving AV's would be attributed to humans only and not machines. Thus, authorities regard our current AI systems as fully the responsibility of their human designers---a premise that implies the following reasoning by the AI: \begin{enumerate} \item Only human agents should decide, but I am facing a decision to choose between the welfare of one human being over that of another. \item This situation should not have occurred. \item Therefore, some human agent is at fault. \item According to the EOP, I must optimize for the number of human casualties and, in particular, the consequences of this tragedy should be endured by the human agent(s) at fault. \end{enumerate} However, the same report~\cite{GERMANreport2017} admits the AV would not be in a position to fully ascertain which human agent is at fault or the level of negative merit---the gravity of fault---at the time of decision-making, necessitating settlement of the matter before court. The challenges of this second scenario, where the AI cannot determine merit and must choose between two evils---harm individual(s) $X$'s or individual(s) $Y$'s welfare---can be formulated in a game analogous to matching pennies and resolved with mixed strategies as follows: For simplicity, we assume---like others~\cite{Bonnefon}---there is no other information. Also, we model merit as negative utility. One player is the artificial decision-maker, which has only two \emph{pure} strategies at its disposal: (1) to harm the welfare of individual(s) $X$ or (2) to harm the welfare of individual(s) $Y$. The other player is the environment, which can place the negative merit that leads to the scenario of harm either on human $X$ or on human $Y$. In the scenario involving only two humans, the payoff matrix for the artificial agent is as follows: \begin{center} \begin{tabular}{l c c } & \multicolumn{2}{c}{\tiny Payoff matrix for the AV} \\ & \parbox{2cm}{\tiny Human~$X$ was at fault} & \parbox{2cm}{\tiny Human~$Y$ was at fault} \\ \cline{2-3} \parbox{2cm}{\tiny AI chooses to harm~X} & \multicolumn{1}{|c|}{0} & \multicolumn{1}{c|}{$-m_{X}*v_{X}$} \\ \cline{2-3} \parbox{2cm}{\tiny AI chooses to harm~Y} & \multicolumn{1}{|c|}{$-m_{Y}*v_{Y}$} & \multicolumn{1}{c|}{0} \\ \cline{2-3} \end{tabular} \end{center} When the AI chooses to harm the human who is at fault in causing the scenario, there is no penalty (no negative utility). But when it chooses to harm the welfare of the innocent human, the AI pays the price of the merit of the negatively affected human times a value of worth for that human---this allows us to account for several pedestrians or several passengers in our illustration. So, harming $X$ when the fault was $Y$'s impacts negatively on humanity in the amount of the merit of $X$ times the number of humans of type $X$. The payoff matrix for the environment which can choose to cause a scenario with $X$ at fault or $Y$ at fault is the same, except the values are positive (it is a zero-sum game). For this game, it is not hard to show that there is no Nash equilibrium with pure strategies, and that in a Nash equilibrium with mixed strategies the artificial agent chooses to harm individual(s) $X$ with probability $m_{Y}*v_{Y}/(m_{X}*v_{X}+m_{Y}*v_{Y})$ and individual(s) $Y$ with probability $m_{X}*v_{X}/(m_{X}*v_{X}+m_{Y}*v_{Y})$~\cite{vonStengel02}. The exact probabilities are not crucial for our argument here. The important message is that the algorithm is randomized. If the AV cannot be sure who is at fault, its two passengers or the 6 pedestrians, then despite the fact that six pedestrians are more lives than the two passengers, the EOP commands that the passengers still deserve a roll at the die---with probability $2/8$---to be saved! This illustrates our point that whenever an AI decision-maker does not possess full information on merit---as is the case in the vast majority of settings in which we engage AI systems---randomized classifiers constitute the optimal and fairest option. David McFarland's \emph{Epilogue: The Alien Mind} uses ethical dilemmas to debate the characteristics and properties we would need to anticipate on an alien mind to qualify it as one of us (among them, the robot would need to be accountable for its actions and provide a rational justification for its actions)~\cite{McFarland}. Being amoral is not an argument against random classifiers, as the law deals with other instances of ``amorality''' like insanity~\cite{Bonnie}. Moreover, we already argued that current machines are regarded as amoral, whether deterministic or not. Another important point for randomized algorithms: Most ML\/ formulations are optimization problems where parameters of a model in a family of models are being sought for some inductive principle~\cite{CherkasskyM98}. Such optimizations can be performed by hill-climbing, gradient descent or other heuristics, because finding the optimal model (i.e., the global optimum) is typically computationally infeasible. For instance, the famous back-propagation algorithm of artificial neural networks is a gradient descent method, and the initial weights are typically randomly chosen values. Thus, algorithms, such as hill-climbing or gradient descent, must be randomized regarding their starting point, and robustness is achieved by taking the best model out of the randomized multi-start. Another aspect that makes supervised learning randomized is the shuffling of the dataset instances to avoid bias to presentation order. This observation, that the learning involves randomization, applies to supervised learning, but also to unsupervised learning---recall the most popular of all: $k$-means starts with a random clustering. Today randomized algorithms are the dominant approach used to build AI-models. Thus, at each successive learning occurrence, a new convolutional neural network---or any other classifier---despite being deterministic, would still be likely to produce different outputs from the previous learning occurrence. Overall, it seems somewhat contradictory to demand that the output of learning be a deterministic algorithm while what is used to obtain such classifier is a randomized algorithm. Our approach does not oppose the accurate representation, computer-mechanization, and artificial reasoning with ethical theories. The adoption of moral facets amenable to logic programming~\cite{FuenmayorB20,PereiraSaptawijaya} emerges from the focus on moral decisions being the result of reasoning. Among those adopted are the \emph{Doctrine of Double Effects} (DDE)~\cite{sep-double-effect} and \emph{contractualism}~\cite{Scanlon}. Computational versions of the Doctrine of Double Effects have been implemented with systems such as QUAL, ACONDA, and Probabilistic EPA (as well as other more recent proposals~\cite{GovindarajuluB17}). These systems have been illustrated with several versions of the trolley dilemma~\cite{PereiraSaptawijaya}. They are plagued with limitations~\cite{GovindarajuluB17}---indeed, the original source for trolley dilemmas~\cite{Foot1967} is also a critique to the DDE. Moreover, Foot presents examples where refinements of the DDE (as to whether direct or oblique intention, or the distinction between avoiding injury and bringing aid) are insufficient to make a choice~\cite{Foot1967}. For instance, \begin{quote} \emph{``shipwrecked mariners who believed that they must throw someone overboard if their boat was not to founder in a storm, [sic] there is no conflict of interests so far as the decision to act is concerned; only in deciding whom to save.''}~\cite{Foot1967}. \end{quote} But if all sailors have equal merit to survive; a random decision might be justifiable. Similarly, there has been remarkable progress towards explicit ethical artificial agents by showing that Gewirth's ``Principle of Generic Consistency (PGC)'' \cite{Gewirth} can be derived by computer-mechanization using higher order logic~\cite{FuenmayorPRICAI2019}. That is, from premises such as ``I am a prospective purposive agent (PPA)'' (that is, I act voluntarily for some (freely chosen) purpose $E$) and ``My freedom and well-being (FWB) are generically necessary conditions of my agency,'' the artificial agent concludes that ``Every PPA has a right to claim their FWB.'' As an ethical principle, the PGC seems to be a variation of the \emph{golden rule}: ``treat others as you wish to be treated.'' The PGC is not uncontroversial~\cite{Beyleveld1991}. But it has been praised~\cite{Kornai} for being instrumental to impose morality on artificial agents who would respect humans: Artificial agents with sound reasoning mechanisms would conclude they must respect the well being of all PPAs and would recognize both humans and themselves as PPAs. But, Trolley problems are not about whether an agent is a PPA or not, but about choosing the less evil among PPAs. Moreover, such an artificial PPA endowed with morality based on deductive-reasoning ---when faced with the choice between acting against the well-being of one PPA or another---must conclude that one of them is not a PPA (particularly if we insist that AI should not make moral decisions). A further complication is that the AI performing such deductive-reasoning may still be required to make a choice without being able to ascertain which one is or is not a PPA. A final point in favour of mixed strategies is that they offer an interpretation of probabilities as frequencies (proportions)~\cite{Hespanha} as they apply to populations. Suppose we need to program robots for a tournament involving our earlier example of \emph{rock, paper, scissors}, where robots are only allowed to use pure strategies. The teams consist of a large number of robots (say $1,000$), each of which we can program differently and shuffle across teams. The mixed-strategy solution in this situation is to program one third of the robots in each team to deterministically choose one of the three actions. However, even this use of deterministic programs shuffled randomly is less acceptable than randomized algorithms: We would need to hide away what deterministic algorithm each AI decision-maker is using (i.e. block all transparency). Humans would seek to breach this by discovering or identifying the deterministic AI decision-maker that favors their situation above other humans. \section{Implementation and Policy Issues} \label{ImplandPol} Section~\ref{Results} provided compelling arguments for employing randomized classifiers in the above outlined scenarios. However, as theoretic arguments are not necessarily easily implemented in practice, we now look into implementation issues. First, the success of the societal adoption of any novel technology---here deploying trustworthy and fair randomized classifiers to make moral decisions impacting the welfare of human beings---hinges on society's trust and acceptance. Since humanity's notion of automation has so far been predominantly deterministic and change is often met with considerable resistance, building societal confidence in non-determinism may not be so easy to achieve. In particular, for game theory, mixed strategies---although extremely intuitive in settings that can be modeled by matching pennies or rock, paper, scissors---have received heavy opposition. For instance, preferential voting schemes that have been shown to be optimal by a game-theoretic analysis and also superior empirically have been rejected~\cite{RivestCOMSOC}. To assess societal preferences, we conducted a series of surveys using classic ethical dilemmas to evaluate the public's stance on randomness. We also explored under which circumstances people prefer moral decisions to be made by humans, artificial agents, or a combination of both such that human decision-makers are assisted by computer technology to varying degrees. Our goal was to gather empirical evidence to help identify areas where emerging AI capabilities could realistically automate decisions that affect human lives. Our experimental setting is introduced in Section~\ref{casestudy}. We found that society would be inclined to accept random choices by artificial agents and feel comfortable with technology eventually fully replacing human decision-makers in specific areas. Second, initiatives to achieve ever-higher levels of transparency, traceability, and auditability of AI systems are now ubiquitous. Prominent examples include the OECD Principles on AI~\cite{OECD2019}, the European proposal for an Artificial Intelligence Act ~\cite{AIA}, the Feasibility Study of the Council of Europe's Ad-Hoc Committee on Artificial Intelligence (CAHAI)~\cite{CAHAI2020}, and existing and ongoing standardization efforts of both European and international standardization bodies, most notably the European Committee for Standardization (CEN), the European Committee for Electrotechnical Standardization (CENELEC), the International Standardization Organization (ISO), the International Electrotechnical Commission (IEC), and the Institute of Electrical and Electronics Engineers (IEEE)~\cite{IEEE2019}. However, we would like to stress once more that transparency may also open up avenues for exploitation and is hence not always desirable. For instance, transparency with regard to the algorithm used changes our game-theoretic proposal. It is relatively clear that deterministic classifiers that act as agents in pure-strategy games are gamed if the strategies are known---with particular ease if the game is repeated. Take the example of AV owners inviting others for a ride to increase the value of human welfare on board and bias the odds in favor of passengers and against pedestrians. But transparency can also pose an issue with randomized classifiers in mixed-strategy game settings. Our discussion assumed that the artificial agent cannot infer any information on the merit to force a deterministic behavior. However, given easy access to big data, it is conceivable that ML\/ techniques could produce models to predict the merit---or negative merit, i.e., fault---of the human agents involved. For instance, provided sufficient training data, individuals may use ML\/ models to infer and discover which attributes an AI system regards as leading to meritorious outcomes in a certain situation and adjust their strategy accordingly. In particular, knowledge that the system is applying logistic-regression is sufficient to use many of the methods in the literature to find the most influential attributes, allowing people to artificially boost their values for those. Even if the model used by the AI is unknown, the use of logistic-regression, feature selection, or methods based on information gain can reveal to human agents the most influential attributes used by the AI to ascertain their merit, leaving plenty of room for human manipulation. Another question is whether, in settings where merit is not ascertainable, regulators should require AI designers to install the best predictive models of human fault in their systems. This would encourage continuous efforts to at least approximate non-ascertainable attributes with a view to arrive at more precise decisions. Ultimately, these are questions for policymakers to decide, we just want to raise awareness to potential problems stemming from ever-increasing transparency requirements and suggest that there may be certain trade-offs to consider. Third, although we have established that randomized decisions are mathematically optimal and probably acceptable, we face a substantial implementation problem: According to the Church–Turing thesis, no function computable by a finite algorithm can implement a true random oracle. In other words, true randomness in the mathematical sense is impossible to achieve in a deterministic Turing machine or von Neumann architecture. The closest thing to generating random sequences are cryptographic hash functions. These are merely pseudo-random sequences, which are still susceptible to attacks and may become truly vulnerable with certain advances in quantum cryptography~\cite{Goldreich1988,Buchmann2017}. Random oracles have been used to prove the security of some cryptographic protocols formally, but these proofs have come under severe criticism~\cite{Canetti2004} and become subject of heated debates in the cryptographic community~\cite{Koblitz2015}. Despite their theoretic weakness, most users of cryptographic protocols remain unconcerned that, in practice, random oracles are replaced by cryptographic hash functions~\cite{Koblitz2015}. A promising emerging solution to the problem is the novel trend of stepping away from the deterministic Turing machine and the von Neumann model towards the use of hardware random number generators. These use random numbers from a physical process---such as thermal noise---to harvest entropy~\cite{Goichon}. Although they still do not qualify as mathematically random, these sequences have in some cases been extremely unpredictable---but note that from a cryptographic perspective, they have turned out to be less secure than originally anticipated~\cite{Kim2013}. In any case, harvesting entropy may also lead to problems: for example, large logs may be required to satisfy the trustworthy AI requirements, which designers can review to fix a problem in the event of tragedies. There are some deterministic processes, like cellular automata, which can be used to generate unpredictable sequences~\cite{Wolfram}. But still, how current computers would generate true random sequences raises a series of philosophical questions: If hardware random generators in combination with pseudo-random generators replaced the notion of pure random oracle for lack of a better implementation in our current hardware, and machines proliferated around us making decisions about our lives, the world could become potentially distressing. In our previous AV example, perhaps owners would be particularly interested in breaking into the code of the pseudo-random number generator in their car to anticipate its decisions---even with entropy sources attacks are possible~\cite{Kim2013}. Similarly, law firms could invest resources in finding the pseudo-random code behind AI judges to find the best strategies for their clients. In such cases, unpredictable AI rulings would be preferable. Otherwise, too much transparency of the model behind the AI may result in a learnable behavior, from which ML\/ algorithms could build an accurate model. The model could be used to take advantage and be able to present the attributes of a case much more favorably than otherwise. Note that randomization is used to combat manipulative strategies even in the context of human judges: Such is the perception that knowledge of the judge traits can bias the trial, that human judges for federal cases are typically assigned randomly in the US. \section{Empirical study} \label{casestudy} There is an increase of research on moral human-robot interaction~\cite[and references]{MalleScheutzArnold} where variants of the trolley dilemma~\cite{Foot1967,SW2020} are used to elicit humans' perceptions. For instance, it has been consistently found that humans expect robots to make utilitarian choices~\cite{Bonnefon,Estivill-CastroEthics,MalleScheutzArnold}. However, we designed our questionnaire to gather empirical evidence on the level of trust society places in technology---or distrusts human decision-makers acting without technological support. We were interested in situations where AI, artificial agents, embedded systems, and robotics could substitute human agents. Some questions have been motivated by examples provided by reports on the use of AI tools in assisting judges in sentencing and bail decisions~\cite{Kugler2018}. While we expected most people to agree that, in principle, machine assistance improves human decision-making performance, we suspected differences in opinion as to the extent such technologies should substitute human decision-makers, particularly when decisions directly impact another person. To measure such differences, we selected three different groups of participants, each with different levels of exposure to the debate on moral decision-making by AI systems. While our initial questions assumed deterministic AI behavior, later questions touched on the issue of randomness. \subsection{Method} Prior to the survey, we familiarized participants with the EOP to provide a relatively simple, underlying framework to avoid confrontation with the many fairness definitions against which classifiers' performance may be judged~\cite{Heidari2019}. For the introductory paragraph and the questionnaire, see Appendix~\ref{ap_research_inst}. We recruited participants through four different methods. The first set of participants were Australian full-time employed high-school teachers holding a university degree, who participated in a series of professional development workshops to include or expand the use of technology in their pedagogy. They came from 34 different schools with their levels of delivery including junior secondary, year~7 to~9, year~7 to~12, year~10, STEM~P-6, year~9 to~12, VET, primary school, year~8 to~12, and K~6. Participation in the survey was an optional activity offered in the workshops. Out of 65 invited participants, 53 replied to our questionnaire and 12 declined. We will refer to this group of participants as \emph{teachers} in Section~\ref{Analysis}. The second means of recruitment was an online survey ~\cite{MalleScheutzArnold} using SurveyMonkey Inc.~\footnote{The data was collected using SurveyMonkey~Audience. We chose Age Balancing: Basic, Gender Balancing: Census, COUNTRY: United States (USA) - SurveyMonkey, HOUSEHOLD INCOME: $\$50k-\$200k+$, AGE: $25-100+$, Education: Graduate degree. Information on how respondents are recruited to SurveyMonkey is available here: www.surveymonkey.com/mp/audience}, through which we collected $124$ responses. We limited the group of acceptable respondents, since we believe the concepts and issues regarding the potential applications of AI in supporting and replacing human decision-making are not trivial, particularly regarding moral standing and fairness: (1) One excluded respondent class were children, as their views on robots significantly differ from adults~\cite{BartlettECS03,KahnFH03}. (2) We selected respondents from the US, who were above the age of 25, held a graduate degree, and had a household income of \$50K-\$200k. Our choice of participant group was motivated by the fact that individuals' engagement in policymaking largely depends on their socialisation and education, and we targeted the US because of its culture of deep and genuine citizen participation~\cite{AustralianParliMentReport}. Many reports~\cite{AndersonFACTTANK} highlight that there is different levels of adoption of technology in the US, but we assume that the minimum household income and their use of SurveyMonkey represents a homogeneous group in this regard. We note that other on-line experiments have a similar sample size and data collection approach for a generic view by humans~\cite{MalleScheutzArnold}. We will refer to this group of participants as \emph{online respondents} in Section~\ref{Analysis}. Third, we performed a robotics demonstration on Nathan Campus, Brisbane, at University Open Day. Our robots engaged visitors in conversation by randomly picking shorter versions of the survey questions. 17 visitors became curious and agreed to complete the survey. We will refer to this group of participants as \emph{Open Day visitors} in Section~\ref{Analysis}. Finally, we collected 13 surveys from IT academics, whom we invited to our department's research seminar. We will refer to this group of participants as \emph{academics} in Section~\ref{Analysis}. All survey participants were provided with a consent and information sheet as per the conditions of our Research Ethics Committee's approval. Thus, participation was completely voluntary, anonymous, and could stop at any time. For the SurveyMonkey collection, we ensured respondents could not go back and alter their answers for previous questions. The other data collection methods used printed versions of the questionnaire, so we cannot guarantee people did not revise their answers. However, we feel this is very unlikely as we found no amendments when capturing the answers. Most of the questions in our questionnaire can be considered Likert-type scale questions (i.e., we give the survey participants five worded points they can choose from). Whenever possible, we will avoid debate about whether the data collected should be considered as interval-level data or ordered-categorical data. As mentioned above, we will use a five item option with a clear middle neutral point. Questions are symmetrical although potentially not equidistant; their presentation aimed for respondents to assume equidistance. We will use diverging stacked bar charts when presenting the descriptive statistic analysis of ordinal data~\cite{JSSv057i05} and bar charts in the remaining cases. Since we will be comparing different groups of respondents for the same question, the responses can not be paired (sample sizes are different), and we are not making any assumptions about the normality of the data. We have overlapping samples which we will analyse for statistical difference of medians using the non-parametric Mann-Whitney U test\footnote{We replicated the calculation using the Mann-Whitney U Test Calculator from https://www.socscistatistics.com and R~\cite{citingR}.}~\cite{DerrickWhiteLikert}. Given two random variables $X$ and $Y$ with their cumulative distribution functions $f$ and $g$, respectively. For ordered samples $x_1, \ldots , x_n$ and $y_1, \ldots , y_m$ of $X$ and $Y$, respectively, let the statistic $U$ count the number of how many times a $y$ value precedes an $x$ value. The Mann-Whitney U Test uses the statistic $U$ for testing the hypothesis $f=g$~\cite{mann-whitney}. The null hypothesis $H_0$ in our tests is going to be that the two cumulative distribution functions are the same (i.e., two different groups have the same scoring tendency). In all of our tests we will use the significance level $\alpha=0.05$. Furthermore, we will specify the \emph{$p$-value}, the probability (assuming that $H_0$ is true) that we obtain a test statistic that is at least as extreme as the observed value of the test statistic. If the $p$-value is less than the level of significance, we reject the null hypothesis and accept the alternative hypothesis. \subsection{Analysis} \label{Analysis} \subsubsection{Evidence for preference for automated judgments} The results in this subsection show that some groups of participants' distrust in humans leads them to prefer AI over human decision-makers. Figure~\ref{Question1divergent} shows the divergent bar chart of responses to Question~\ref{Q1} from our groups as percentages. \begin{figure} \centering \subfloat[\label{Question1divergent}Question~\ref{Q1}: Who is fairer, humans or computers, to implement EOP.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question01}} $\;\;$ \subfloat[\label{Question03divergent}Question~\ref{Q3}: How to select which passenger should be left behind from a flight.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question03}} \caption{\vspace{-1mm}\label{Q1ANDQ3divergent} Divergent bar charts of responses to Question~\ref{Q1} and Question~\ref{Q3}. } \vspace{-2.5mm} \end{figure} Eleven teachers felt humans are never fairer, and none felt humans are better than automation. A small percentage ($13.7\%$) of SurveyMonkey respondents were of the opinion that humans can be fairer, but $40.3\%$ believed humans are slightly worse at being fair. Teachers' and Open Day visitors' median and mode indicated that humans were somewhat worse at being fair, while the academic view was neutral. The difference between teachers and academics is statistically significant ($U=137$, $p=0.00042$) and so is the difference between Open Day visitors and academics ($U=49.5$, $p=0.0057$). \textbf{Discussion:} Figure~\ref{Question1divergent} shows results for Question~\ref{Q1} and assesses individuals' level of trust in human decision-makers not supported by technology. The responses accumulate away from the use of human judgment alone. In this case, the results are consistent with the generally accepted view~\cite{Kugler2018} that machines analyze facts without human bias, irrationality, or mistakes. Thus, it seems teachers and Open Day visitors perceive machines as more impartial than humans. Although this view may shift due to the growing recognition of the need for a human-in-the-loop approach~\cite{EUReport}, these groups of respondents do not seem to be dissuaded from automation. Question~\ref{Q3} (refer to Figure~\ref{Question03divergent}), which concerns the automation of decisions on regrouping passengers across flights, also shows preference for AI-decisions over human involvement. Teachers' median and mode are again for a computer program with some human monitoring. Not a single academic selected only human judgment. Open Day visitors' median and mode are also for this level of automation, and so is the mode of the online survey. Teachers' preference for automation is significantly different from that of online respondents ($U=1921$, $p=0.0001$) and Open Day visitors ($U=302.5$, $p=0.04338$). The responses for Question~\ref{Q11} (see Figure~\ref{Question11divergent}) on automating visa applications show an almost identical pattern to Question~\ref{Q3}. Responses are clearly in favor of automation and reject human judgment: Teachers' and Open Day visitors' median and mode unambiguously reflect this preference, and the mode of online respondents is also for automation (the median is neutral). To a slightly lesser extent, academics also favor automation. Both Question~\ref{Q3} and Question~\ref{Q11} received a non-trivial number of responses on the extreme values, but mainly advocating fully automated decisions. Albeit in the opposite direction, we will see below the results for Question~\ref{Q2}, which generally favors human judgment. But even in Question~\ref{Q2}, there are also non-trivial numbers of those who would prefer the selection to be entirely without human intervention. The difference between the responses of teachers and online respondents is again statistically significant ($U=1968$, $p=0.0001$). But interestingly, here, Open Day visitors' high preference for an AI-judgment is statistically significant with respect to online respondents ($U=696$, $p=0.02382$). Question~\ref{Q12}---concerning decisions on credit-card applications---shows responses even more in favor of automation (refer to Figure~\ref{Question12divergent}). The median and mode for teachers, academics, and Open Day visitors indicates ruling over credit-card applications should be a matter for computer programs with some human monitoring, yet without checking each individual case. Almost all teachers favor automation, clearly rejecting human judgment even if supported by technology. Online respondents, academics, and Open Day visitors also show a strong tendency towards automation: human judgment is less than $8\%$ of the responses for all participants. Even given all groups' preference for the use of technology, note that teachers' are in favor of automation to such an extent that the difference between their views and that of online respondents is statistically significant ($U=1967.5$, $p=0.00001$). \textbf{Discussion:} A possible explanation for such a high level of acceptance of automated decision-making over human judgment in this scenario is that the massive benefits of automation in the credit-card industry pushed an early penetration of ML\/ technology in the sector: ML\/ has been applied to credit-card application assessments for more than 25 years~\cite{Carter87,Davis92}. In this setting, there have been calls for accepting technology with little questioning~\cite{Rosenberg2008}. \begin{figure} \centering \subfloat[\label{Question11divergent}Question~\ref{Q11}: Who should evaluate a travel visa application, human or artificial agent.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question11}} $\;\;$ \subfloat[\label{Question12divergent}Question~\ref{Q12}: Who should decide over awarding a credit-card and its limit, humans or machines.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question12}} \caption{\vspace{-1mm}\label{Q11ANDQ12divergent} Divergent bar charts of responses to Question~\ref{Q11} and Question~\ref{Q12}. } \vspace{-2.5mm} \end{figure} With less overall preference for a machine-driven decision, Figure~\ref{Q7ANDQ8divergent} shows the results of Question~\ref{Q7} and Question~\ref{Q8}. \begin{figure} \centering \subfloat[\label{Question7divergent}Question~\ref{Q7}: How much automation when ruling over child adoption.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question07}} $\;\;$ \subfloat[\label{Question8divergent}Question~\ref{Q8}: How much automation when judging over a bail hearing.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question08}} \caption{\vspace{-1mm}\label{Q7ANDQ8divergent} Divergent bar charts of responses to Question~\ref{Q7} and Question~\ref{Q8}. } \vspace{-2.5mm} \end{figure} Figure~\ref{Question7divergent} and Figure~\ref{Question8divergent} show almost identical proportions and the positions of the bars. For online respondents and for Open Day visitors, there is strong centrality, and a firm rejection for complete automation of the decision-making. Less than $5\%$ of online respondents chose the fully automated option for both of these questions. However, the teacher group shows a strong preference for the decision to be strongly guided by full automation or only some human supervision. Responses for teachers on both questions have a median and mode for using a computer program with some human supervision for both scenarios. Teachers' preference for AI-judgments is statistically significant with respect to online respondents ($U=1360.5$, $p=0.00001$ for Question~\ref{Q7} and $U=2184$, $p=0.00004$ for Question~\ref{Q8}) and with respect to Open Day visitors for Question~\ref{Q7} ($U=143.5$, $p=0.00001$) but not for Question~\ref{Q8}. The results for Question~\ref{Q14} also show central/neutral responses for Open Day visitors and online respondents (see Figure~\ref{Question14divergent}). However, once more, teachers show a statistically significant higher preference for automation over online respondents ($U=2276.5$, $p=0.00124$) and Open Day visitors ($U=272.5$, $p=0.0151$). \begin{figure} \centering \subfloat[\label{Question14divergent}Question~\ref{Q14}: Who assesses fairly a funding application from a school, humans or artificial agents.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question14}} $\;\;$ \subfloat[\label{Question21divergent}Question~\ref{Q21}: Who is fairer at specifying the sentences for a convicted criminal.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question21}} \caption{\vspace{-1mm}\label{Q14ANDQ21divergent} Divergent bar charts of responses to Question~\ref{Q14} and Question~\ref{Q21}. } \vspace{-2.5mm} \end{figure} Question~\ref{Q21} (see Figure~\ref{Question21divergent}) shows the public's tendency to centrality with respect to automating sentencing decisions, with a very slight shift in favour of human intervention: Open Day visitors' median and mode and online respondents' mode indicates a preference for technologically assisted human sentencing decisions. On the other hand, the median and mode of academics and teachers is clearly in favor of AI-enabled, automated decision-making with some monitoring and supervision by a judge. Teachers' preference for an AI-judge is statistically significant over that of online respondents ($U=1778$, $p=0.00001$) and Open Day visitors ($U=228$, $p=0.00236$). Academics' support for the AI-judge is even stronger: None of them contemplates a position below neutral. Hence, academics' preference for automated decisions in this setting is statistically significant not only with respect to online respondents ($U=123$, $p=0.00001$), but also Open Day visitors ($U=12$, $p=0.00001$) and teachers ($U=120.5$, $p=0.00016$). \textbf{Discussion:} The teachers were surveyed after a professional development day for the inclusion of ICTs in the teaching-learning process. Some of the technologies demonstrated and discussed were virtual-reality, robotics, and cloud tools. Therefore, they may hold high hopes for the automation of judgment. Alternatively, ICT academics and teachers may be more aware of works on bounded rationality---suggesting that cognitive limitations prevent humans from being fully rational~\cite{Simon1957,Lindblom2017}---and studies indicating that humans suffer from predictable biases that influence judgment~\cite{KahnemanTversky1979}. These insights presumably encourage them to be more cautious and meticulous when evaluating and designing decision-making methods that may affect human beings. The fact that the systematic design of such methods is typically supported by computer programs may provide a further explanation for this groups' high preference for automation. \subsubsection{Evidence for preference for human involvement in judgments} Let us now turn to the results showing that some groups of participants exhibit distrust in AI decision-makers and hence prefer their human counterparts. Figure~\ref{Question02divergent} shows the corresponding divergent bar chart of responses for Question~\ref{Q2}, which aimed to find out the public's preferred level of automation in the context of a language test. The accumulated results did not swing either way: Teachers preferred some automation, academics even more. Their mode and median were for a computer program with some human monitoring. Open Day visitors' view was in-line with the online survey. The remarkable point here is the issue at the extremes: In all data collections, there is some non-trivial number of preferences for exclusively human judgment without technological support. Apart from academics, all other respondents rejected total automation. \begin{figure} \centering \centering \subfloat[\label{Question02divergent}Question~\ref{Q2}: Who is fairer at evaluating command of foreign language.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question02}} $\;\;$ \subfloat[\label{Question05divergent}Question~\ref{Q5}: Would a minority person be judged fairly by human/artificial security officer.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question05}} \caption{\vspace{-1mm}\label{Q2ANDQ5divergent} Divergent bar charts of responses to Question~\ref{Q2} and Question~\ref{Q5}. } \vspace{-2.5mm} \end{figure} Although the results we discuss next show a tendency for a neutral response---with some involvement of technology---they also indicate a clear desire by participants to maintain some human involvement, rejecting decisions by fully autonomous AI decision-makers. Question~\ref{Q5} considers a scenario in which a subject, who belongs to a visibly distinct group, needs to request assistance. Some of the responses here show strong evidence that complete reliance on human judgment is unacceptable. The median and mode for both online respondents and Open Day visitors are that if they were a minority, they would prefer the involvement of computer programs with some human supervision. Teachers' and academics' responses for this question are remarkably neutral (refer to Figure~\ref{Question05divergent}). Figure~\ref{Q4ANDQ6divergent} shows a global neutral response for two questions. For Question~\ref{Q4}, most respondents stay away from fully-automated rulings but also dislike purely humans verdicts that lack any support from computer systems. No single respondent from the Open Day visitors elected the fully automatic option. In the US online survey, the utterly automatic option has less than $6\%$ of the respondents. While the median and mode for the online respondents and the Open Day visitors is the neutral option, teachers' responses again show distrust in human decisions and their median and mode are for the use of a computer program with some human supervision for ruling on punishments at school for children (see Figure~\ref{Question04divergent}). \begin{figure} \centering \subfloat[\label{Question04divergent}Question~\ref{Q4}: Ruling on discipline measures for a child of a minority group at school.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question04}} $\;\;$ \subfloat[\label{Question06divergent}Question~\ref{Q6}: Judging behaviour at nightclub by human/artificial security guard.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question06}} \caption{\vspace{-1mm}\label{Q4ANDQ6divergent} Divergent bar charts of responses to Question~\ref{Q4} and Question~\ref{Q6}. } \vspace{-2.5mm} \end{figure} Teachers' preference for technology is statistically significant both with respect to online respondents ($U= 1933 $, $p=0.00001$) and Open Day visitors ($U= 234.5$, $p=0.00159$). Academics are even more in favor of higher levels of machine-based decisions in this setting, and their position is statistically significant both with respect to online respondents ($U= 394$, $p=0.00126$) and Open Day visitors ($U= 47.5$, $p=0.0044$). A similar picture of neutrality emerges from Question~\ref{Q6} (refer to Figure~\ref{Question06divergent}). The responses are more or less even, except again that very few respondents would accept a completely artificial security guard. None of the responses from Open Day visitors corresponds to this option. However, academics remain inclined for automation---none of them selected a human security guard alone. And interestingly, in this question, teachers have shifted to a more even and spread opinion. Nevertheless, the Mann-Whitney U Test does not reveal a statistical difference at the $0.05$ level for any two groups of responses. \subsubsection{Data on acceptance of technological assistance} We now show results for questions we later use for contrasting sub-groups between the respondents. Question~\ref{Q9} (refer to Figure~\ref{Question09}) shows mixed results. Although one side indicates complete comfort with disclosing medical conditions to a human pharmacist, while the other an absolute preference for no human involvement in fulfilling a prescription, the options in this question may not be considered symmetric or an ordered categorical scale. Figure~\ref{Question09} shows bar charts of percentages of responses and \begin{figure} \centering \subfloat[\label{Question09}Question~\ref{Q9}: Discussing your medical condition to a human versus a robot.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question09}} $\;\;$ \subfloat[\label{Question17}Question~\ref{Q17}: Has artificial intelligence surpassed human performance for the game of chess.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question17}} \caption{\vspace{-1mm}\label{Q9ANDQ17bar} Bar charts of responses to Question~\ref{Q9} and Question~\ref{Q17}. } \vspace{-2.5mm} \end{figure} we note that there is a similar dispersion of preferences between teachers' and online respondents' responses. These two groups are comfortable discussing prescriptions with pharmacists. However, Open Day visitors never picked the option to discuss face-to-face with a human and have far more preference for full automation. The mode for academics is also full automation. \textbf{Discussion:} We formulated Question~\ref{Q9} as a result of the reports~\cite{Reese2017} around the virtues of using a robot as a point of sale in retail (the first $1,000$ Pepper robots were hired for Nescafe in December 2015 to help customers searching for coffee machines in their appliance stores). This question is also motivated by the suggestion that technological interventions~\cite{Scoglio2019,Farreretal2013} in which humans interact with a robot enable humans to feel more at ease. However, the reverse is also possible (recall the uncanny valley debate~\cite{PIWEK2014271}). Upon reflection, there could have been more questions and research to explore the perception by a human patient to receive fair or appropriate treatment from a robotic nurse versus a human nurse. Biases in medical treatment because of factors that could be considered discrimination are well documented~\cite{Hall2105}. Question~\ref{Q10} and Question~\ref{Q15} attempt to measure a construct by which technological assistance to humans is accepted because it has prevailed for several generations. Note that acceptance of new information technologies has been researched extensively~\cite{AgarwalPrasad} but familiarity with the notion of autopilot in planes is not comparable to familiarity with robots/machines as judges or moral decision makers. That is, information technologies are appearing at a much faster rate than some innovations in automation. The origins of the plane's autopilot is attributed to the Sperry family (or Corporation) in 1912, and in 1947 a US Air Force C-53 completed a transatlantic flight apparently with all phases in autopilot. Similarly, cruise control patents appeared in the 50s and 60s, although widespread use of cruise control appeared in the 1070s because of its positive impact on fuel consumption. We speculate that our respondents are all comfortable with the idea that it is advantageous to have autopilots in long flights and that cruise control is a positive option. \begin{figure} \centering \subfloat[\label{Question10}Question~\ref{Q10}: Is the autopilot preferable than not having one.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question10}} $\;\;$ \subfloat[\label{Question15}Question~\ref{Q15}: Does cruise control facilitate driving.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question15}} \caption{\vspace{-1mm}\label{Q10ANDQ15bars} Bar charts of responses to Question~\ref{Q10} and Question~\ref{Q15}. } \vspace{-2.5mm} \end{figure} Figure~\ref{Question10} confirms that respondents concur on an autopilot being useful. The mode for all is that an autopilot is preferable (in Figure~\ref{Question10} we can see that all groups chose this option more than $50\%$ of the time except Open Day visitors, but even they have above $40\%$ for constant computer assistance). Almost no respondents would change the auto-pilot for a human co-pilot. Similarly, barely any respondent answered that a car is harder to drive with cruise control. Academics see no benefit from cruise control and a non trivial proportion of online respondents and Open Day visitors see no impact of cruise control in reducing speeding fines or accidents (refer to Figure~\ref{Question15}). While cruise control and autopilot originally involved mechanical devices, they are now operational through digital micro-controllers. We explored the issue of ``thinking machines''~\cite{Vega,Bibel2020} with what has been traditionally perceived as an intellectual challenge (even after the birth of artificial intelligence). Therefore, Question~\ref{Q17} was designed expecting the vast majority of respondents accepting that mechanized reasoning and performance by artificial chess-players is superior to human performance. Figure~\ref{Question17} shows that this is the case (especially academics), but even online respondents' responses show less than $4\%$ believe that chess programs are worse than the average human. \begin{figure} \centering \subfloat[\label{Question18}Question~\ref{Q18}: Has ICT and search engines provide and advantage to compete in Trivial Pursuit.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question18}} $\;\;$ \subfloat[\label{Question19}Question~\ref{Q19}: Has ICT improved the performance of office workers.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question19}} \caption{\vspace{-1mm}\label{Q18ANDQ19bars} Bar charts of responses to Question~\ref{Q18} and Question~\ref{Q19}. } \vspace{-2.5mm} \end{figure} \subsubsection{Analysis as to whether justifications are necessary} Since the deployment of expert systems, it became clear that explanations~\cite{Darlington2013AspectsOI} are crucial for human users' trust~\cite{Swartout1993,WangPH2016} and acceptability of these AI systems~\cite{YeJ95}. We formulated two questions regarding the transparency of the decision provided by artificial agents. The European Union considers transparency---including traceability, explainability, and communication---as central issues for Trustworthy AI~\cite{EUReport}. In these questions (Question~\ref{Q22} and Question~\ref{Q23}) the categories are not ordinal. We offered one option for artificial agents being forced to explain, communicate, and justify their decisions. The other three options were such that the AI-Judge would not be required to provide an explanation. One was simply a certification that the system is fair by some third party, while the second was that the system could be used publicly as a black box. The third option for the non-transparent version was to combine the two previous ones. An interesting result is that online respondents do not seem to care about justification for a decision. Responses for forcing the system to explain and justify itself was less than $28\%$. Although the mode for teachers and academics is above 40\%, demanding AI decision-makers to provide explanations, these participants (in some earlier questions) seemed more accepting of an alien/artificial mind. Teachers and academic responses do not reach $50\%$ for demanding explanations from AI for Question~\ref{Q22} (see Figure~\ref{Question22}). \begin{figure} \centering \subfloat[\label{Question22}Question~\ref{Q22}: Argument for no transparency on intellectual property grounds.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question22}} $\;\;$ \subfloat[\label{Question23}Question~\ref{Q23}: AI-judge seems fairer than human judges.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question23}} \caption{\vspace{-1mm}\label{Q22ANDQ23bars} Bar charts of responses about whether AI-judges should offer explanations and justifications for their decisions (Question~\ref{Q22} and Question~\ref{Q23}). } \vspace{-2.5mm} \end{figure} This low interest for transparency (as per Question~\ref{Q22}) are in contrast with those of Question~\ref{Q23} where the requirement for an AI-judge to explain and justify itself almost reaches $50\%$ for all collection approaches (see Figure~\ref{Question23}). The mode for all participant groups is that artificial agents must be forced to justify and explain their decision making. \textbf{Discussion:} Perhaps Question~\ref{Q23} is more specific, as it refers to a particular individual and the particular situation of ruling on the lengths of a sentence for a convicted criminal. It is common that humans offer somewhat contradictory views for seemingly similar situations, as individuals value the specifics of each scenario differently. \subsubsection{Analysis as to whether randomization is acceptable} For Question~\ref{Q13} and Question~\ref{Q20}, we were expecting responses to favor automatic choice since the questions suggest that a sensible choice is a random choice. Another reason for this expectation was that our earlier questions (Question~\ref{Q1} and Question~\ref{Q3}) show that our participants do regard computers as effective in calculations. As we argued earlier, if the merit of the case for two humans cannot be determined, a fair choice is a random choice. These two questions have been worded so as to suggest that computers would be of valuable assistance even when making random choices. We find responses to Question~\ref{Q13} (see Figure~\ref{Question13}) are not inclined to a particular level of machine intervention. The results indicate a preference for computer involvement in such randomized decision-making alongside significant human participation. Only for the teachers, the median is to use a computer's random choice and this is statistically significant over online respondents responses ($U=2,040$ and $p=0.0003$). \begin{figure} \centering \subfloat[\label{Question13}Question~\ref{Q13}: If selecting which pedestrian to harm, what provides better randomness.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question13}} $\;\;$ \subfloat[\label{Question20}Question~\ref{Q20}: If selecting which passenger to eject from a flight, what provides better randomness.]{ \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question20}} \caption{\vspace{-1mm}\label{Q13ANDQ20bars} Divergent bar charts of responses to Question~\ref{Q13} and Question~\ref{Q20}. } \vspace{-2.5mm} \end{figure} Question~\ref{Q20} recalls the scenario of Question~\ref{Q3}, where airline staff ejects some passenger from a plane. The scenario now insinuates that a random choice is required, and the responses here favor a strong use of computers in sharp contrast to the results we just described for Question~\ref{Q13}. In this setting, only less than $13\%$ of the online respondents chose the human alone option. Teachers, Open Day visitors, and academics are decisively for computer use. The option where the human decision-maker would do marginally better than a computer program received no responses from the teachers, no response from the academics, and only one from the Open Day visitors. Comparing teachers' responses to Question~\ref{Q20} with those to Question~\ref{Q13}, we find they are statistically significant ($U=923$ and $p=0.0118$). Similarly, academics' responses to Question~\ref{Q20} and Question~\ref{Q13} ($U=38$ and $p=0.0914$) and Open Day visitors' responses to Question~\ref{Q20} and Question~\ref{Q13} ($U=78$ and $p=0.116$) are also statistically significant. \textbf{Discussion:} Note that Question~\ref{Q13} concerns a scenario where a decision results in a human being suffering some physical harm. Under such circumstances, exclusively human and fully automated decisions are the least preferred choices. However, the three groups (academics, teachers, and Open Day visitors) display an absolute and radical shift in favor of computer/machine randomness when the issue (Question~\ref{Q20}) does not seem to be a matter of life or death. It seems that human preferences for AI decisions are dependent on the issues at stake. Question~\ref{Q24} offers a Likert scale with the standard options (Strongly Disagree, Disagree, Neutral, Agree, Strongly Agree) regarding the respondents' belief that computers can obtain fair random numbers for an unbiased choice when merit is equal. Figure~\ref{Question24divergent} shows respondents strongly believe that computers can reproduce a truly random generator. \begin{figure} \centering \includegraphics[width=0.45\textwidth]{./DataAnalysis/Question24} \caption{\vspace{-1mm}\label{Question24divergent} Responses to Question~\ref{Q24}: Computers would be able to generate random numbers to make fair decisions when the merit between two people is equal. } \vspace{-2.5mm} \end{figure} Although online respondents have a median and a mode that agrees on computers ability to achieve randomness, from a Mann-Whitney test we get a $p$-value of $0.2183$. Thus, we can reject the null hypothesis that the online respondents and the Open Day visitors have the same scoring tendency at the $5\%$ level. Teachers and academics clearly believe even stronger (see Figure~\ref{Question24divergent}) in achieving fair decisions with random generators in computers. It is not surprising that respondents differ when discussing randomness, seeing as there are several accepted mathematical approaches on the issue~\cite{Volchan}. Finally, Question~\ref{Q25} and Question~\ref{Q26} offer only yes/no options. Question~\ref{Q25} aimed to find out if participants are aware of CPUs' capacity to use thermal noise within the silicon as an entropy source. Overwhelmingly, our respondents answered no. Only two of the academics were aware of this issue. Question~\ref{Q26} tested for participants' awareness of the controversy around replacing the random oracle model with cryptographic hash functions. Again, positive responses were minimal (below $1\%$) expect for the academics, where $2$ in $13$ (i.e., $15\%$) indicated their knowledge of the random oracle controversy. \textbf{Discussion:} Overall, it would seem that the public has trust in machines exhibiting non-deterministic and random behavior with what seems like little understanding of implementation issues. Indeed, people are generally not particularly bothered with how machines work as long as their use is socially considered an improvement: \begin{quote} \emph{``Risks do not militate against the introduction of automated driving if the balance of risks is fundamentally positive''}~\cite{GERMANreport2017}. \end{quote} \section{Conclusions} \label{Conclusion} This paper has argued that if AI systems are to be involved in the automation of decisions affecting human lives, such decisions would need to be randomized for a significant number of scenarios. We also noted that this would revolutionize the notion of machine (automata): Determinism and deductive reasoning would alternate with random choices of carefully learned distributions. AI systems would give the impression of possessing some sort of free spirit, despite consistently following the law and making information-based decisions. Importantly, their decisions would even be potentially explainable and rationalizable (in the sense of game theory) and justifiable (in the sense of human interpretability). Potentially, most people could grow truly comfortable with AI decisions, perceiving them as fairer and less biased than human decision-makers. Others would likely find the idea of giving chance such a central role in decisions that so crucially affect their lives highly unsatisfactory. We have mathematically proven the validity of our arguments for random classifiers in the supervised learning setting, and also furnished game theoretic evidence for the superiority of mixed strategies under partial information assumptions. We have also provided empirical evidence to support that there is at least some societal acceptance for deploying random classifiers. Our results show that while people tend to favor partially or even fully automated decisions over human decisions in many circumstances, there is reluctance to resort to randomized decisions in life-or-death situations. Finally, we also discussed some policy and implementation issues with a particular focus on potential tradeoffs in connection with ever-increasing transparency requirements and current challenges in generating truly random sequences, to contribute to relevant debates in current AI policy and standardization initiatives. Our aim was to provide insights that are useful both for AI researchers and policymakers. Researchers of various disciplines active in the AI field can benefit from our interdisciplinary approach, which links formal ML and game theory propositions with the state of art in AI ethics research and key current regulatory/policy considerations. Braking down traditional silos this way helps illustrate how insights from these disparate fields fit together in solving the important real-life problems we address. On the policy side, we connect to key international AI policy and standardization initiatives. These initiatives increasingly attempt to guarantee the highest possible levels of transparency and explainability of AI systems to ensure accountability. While this is a commendable goal, our key message to policymakers is that maximizing transparency levels is neither the only nor necessarily the best solution. Instead, we need to keep potential drawbacks of transparency in mind and explore alternative accountability mechanisms that allow us to garner the benefits of randomization. We believe the discussion here also raises a series of other interesting questions. For instance, do our findings also hold for other than supervised learning tasks? On the game theory side, we indicated that AI interactions would be repeated games from a game-theoretic perspective and that human agents would be inclined to game the system if transparency requirements revealed the deterministic nature of the AI. Human agents would adapt. Should the AI adapt as well? Should it include ML modules for continuous learning? While the examples could go on, we hope to have sparked some interest in both the scientific and policymaking community to engage with these and many more related open problems. {\small
{'timestamp': '2021-11-16T02:26:41', 'yymm': '2111', 'arxiv_id': '2111.07545', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07545'}
arxiv
\section*{Things to do} \newpage \pagenumbering{arabic} \section{Introduction} We study the question of designing fast algorithms for the following very natural and fundamental computational task. \begin{question}[Multipoint Evaluation] {Given the coefficient vector of an $n$-variate polynomial $f$ of degree at most $d-1$ in each variable over a field $\F$ and a set of points $\{\pmb\alpha_i : i \in [N]\}$ in $\F^n$, output $f(\pmb\alpha_i)$ for each $i \in [N]$.} \end{question} Besides being a natural and fundamental question in computer algebra on its own, fast algorithms for this problem is also closely related to fast algorithms for other natural algebraic questions like polynomial factorization and modular composition \cite{Kedlaya11}. The input for this question can be specified by $(d^n + Nn)$ elements of $\F$ and clearly, there is a simple algorithm for this task which needs roughly $((d^n\cdot N)\poly(n, d))$ arithmetic operations over $\F$: just evaluate $f$ on $\pmb\alpha_i$ for every $i$ iteratively. Thus for $N = d^n$, the number of field operations needed by this algorithm is roughly quadratic in the input size. While \emph{nearly linear time}\footnote{Throughout this paper, we use the phrase ``nearly linear time" to refer to algorithms such that for all sufficiently large $m$, they run in time $m^{1 + o(1)}$ on inputs of size $m$.} algorithms have been known for the univariate instance of multipoint evaluation \cite{BM74} for close to five decades, fast algorithms for the multivariate version have been much harder to come by. In a significant improvement to the state of art for this problem, Umans \cite{Umans08} and Kedlaya \& Umans \cite{Kedlaya11} gave nearly linear time algorithms for this problem over fields of small characteristic and over all finite fields respectively, provided that the number of variables $n$ is at most $d^{o(1)}$ where the degree of the input polynomial in every variable is less than $d$. They also stated the question of designing fast algorithms for the large variable case (i.e. $n \notin d^{o(1)}$) as an open problem. In this work, we make some concrete progress towards this question over finite fields of small characteristic (and not too large size). We also show two independently interesting applications of our algorithm. The first is to an upper bound for algebraic data structures for univariate polynomial evaluation over finite fields and second is to an upper bound on the rigidity of Vandermonde matrices over fields of small characteristic. Before stating our results, we start with a brief outline of each of these problems and discuss some of the prior work and interesting open questions. We state our results in \autoref{sec: results}. \subsection{Algorithms for multivariate multipoint evaluation} For the case of univariate polynomials and $N = d$, Borodin and Moenck \cite{BM74} showed that {multipoint evaluation } can be solved in $O(d\poly(\log d))$ field operations via a clever use of the Fast Fourier Transform (FFT). For multivariate polynomials, when the evaluation points of interest are densely packed in a product set in $\F^n$, FFT based ideas naturally generalize to multivariate multipoint evaluation yielding a nearly linear time algorithm. However, if the evaluation points are arbitrary and the underlying field is sufficiently large\footnote{Over small fields, for instance if $|\F| \leq d^{1 + o(1)}$ or $ |\F|^{n} \leq N^{1 + o(1)}$, a standard application of multidimensional Fast Fourier Transform which just evaluates the polynomial at all points in $\F^n$ and looks up the values at the $N$ input points works in nearly linear time. So, throughout the discussion on multipoint evaluation, we assume that $\F$ is large enough.}, and in particular not packed densely in a product set, the question of designing algorithms for {multipoint evaluation } that are significantly faster than the straightforward quadratic time algorithm appears to be substantially harder. In fact, the first significant progress in this direction was achieved nearly three decades after the work of Borodin and Moenck by N\"usken and Ziegler \cite{NZ04} who showed that for $n = 2$ and $N = d^2$, {multipoint evaluation } can be solved in most $O(d^{\omega_2/2 + 1 })$ operations, where $\omega_2$ is the exponent for multiplying a $d\times d$ and a $d \times d^2$ matrix. The algorithm in \cite{NZ04} also generalizes to give an algorithm for general $n$ that requires $O(d^{\omega_2/2(n-1) + 1})$ field operations.\footnote{The results in both \cite{BM74} and \cite{NZ04} work for arbitrary $N$, but for simplicity have been stated for $N = d$ and $N = d^2$ respectively here. } Two significant milestones in this line of research are the results of Umans \cite{Umans08} and Kedlaya \& Umans \cite{Kedlaya11} who designed nearly linear time algorithms for this problem for fields of small characteristic and over all finite fields respectively, provided the number of variables $n$ is at most $d^{o(1)}$. We now discuss these results in a bit more detail. Umans \cite{Umans08} gave an algorithm for {multipoint evaluation } over finite fields of small characteristic. More precisely, the algorithm in \cite{Umans08} solves {multipoint evaluation } in time $O((N + d^n)(n^2p)^n)\cdot \poly(d, n, p, \log N)$ over a finite field $\F$ of characteristic $p$. Thus, when $p$ and $n$ are $d^{o(1)}$, the running time can be upper bounded by $(N + d^n)^{1 + \delta}$ for every constant $\delta > 0$ and $d, N$ sufficiently large. In addition to its impressive running time, the algorithm of Umans \cite{Umans08} is also algebraic, i.e. it only requires algebraic operations over the underlying field. With {multipoint evaluation } naturally being an algebraic computational problem, an algebraic algorithm for it has some inherent aesthetic appeal. The results in \cite{Umans08}, while being remarkable has two potential avenues for improvement, namely, a generalization to other fields and to the case when the number of variables is not $d^{o(1)}$. In \cite{Kedlaya11}, Kedlaya \& Umans addressed the first of these issues. They showed that {multipoint evaluation } can be solved in nearly linear time over \emph{all} finite fields. More precisely, for every $\delta > 0$, their algorithm for {multipoint evaluation } has running time $(N+d^n)^{1 + \delta}\log^{1 + o(1)} q$ over any finite field $\F$ of size $q$, provided $d$ is sufficiently large and $n = d^{o(1)}$. Quite surprisingly, the algorithm in \cite{Kedlaya11} is not algebraic. It goes via lifting the problem instance from the finite field $\F$ to an instance over $\Z$ and then relies on an extremely clever and unusual application of the Chinese Remainder Theorem to reduce the instance over $\Z$ back to instances over small finite fields. Intuitively, the gain in the entire process comes from the fact that in the reduced instances obtained over small finite fields, the evaluation points of interests are quite densely {packed} together inside a small product set and a standard application of the multidimensional FFT can be used to solve these small field instances quite fast. Another closely related result is a recent work of Bj\"orklund, Kaski and Williams \cite{BKW19} who (among other results) give an algorithm for multivariate multipoint evaluation but their time complexity depending polynomially on the field size (and not polynomially on the logarithm of the field size). In addition to these algorithms for multivariate multipoint evaluation, Umans \cite{Umans08} and Kedlaya \& Umans \cite{Kedlaya11} also show that these fast algorithms lead to significantly faster than previously known algorithms for many other natural algebraic problems. This includes the questions of modular composition where the input consists of three univariate polynomials $f, g, h \in \F[X]$ of degree less than $d$ each and the goal is to output $\left(f(g(X)) \mod h(X)\right)$. In addition to being interesting on its own, faster algorithms for modular composition over finite fields are known to directly imply faster algorithms for univariate polynomial factorization over such fields. Indeed, using their nearly linear time algorithm for {multipoint evaluation }, Umans \cite{Umans08} and Kedlaya \& Umans \cite{Kedlaya11} obtain the currently fastest known algorithms for univariate polynomial factorization over finite fields. We refer the reader to \cite{Kedlaya11} for a detailed discussion of these connections and implications. In spite of the significant progress on the question of algorithms for {multipoint evaluation } in \cite{Umans08} and \cite{Kedlaya11}, some very natural related questions continue to remain open. For instance, we still do not have nearly linear time algorithms for {multipoint evaluation } when the number of variables is large, e.g. $n \notin d^{o(1)}$ over any (large enough) finite field, or when the field is not finite. Since {multipoint evaluation } is quite naturally an algebraic computational problem, it would also be quite interesting to have a nearly linear size arithmetic circuits over the underlying field for this problem even if such a circuit cannot be efficiently constructed. Currently, small circuits of this kind are only known over finite fields of small characteristic due to the results in \cite{Umans08}. The algorithm in \cite{Kedlaya11} does not seem to yield such a circuit since it is not algebraic over the underlying field. \subsection{Data structures for polynomial evaluation}\label{sec: data structures intro} One particular implication of the results in \cite{Kedlaya11} is towards the question of constructing efficient data structures for polynomial evaluation over finite fields. The \emph{data} here is a univariate polynomial $f \in \F[X]$ of degree less than $n$ over a finite field $\F$. The goal is to process this data and store it in a way that we can support fast polynomial evaluation queries, i.e. queries of the form: given an $\alpha \in \F$ output $f(\alpha)$. The two resources of interest here are the space required to store the data and the number of locations \footnote{This can be measured in terms of the cells accessed where each cell contains an element over the underlying field. This is an instance of the cell probe model and is quite natural in the context of algebraic data structures for algebraic problems. Alternatively, we can also measure the space and query complexity in terms of the number of bits stored and accessed respectively.} accessed for every query, i.e the query complexity. There are two very natural solutions to this problem. \begin{itemize} \item We can store the coefficient vector of the polynomial $f$ in the memory and for each query $\alpha \in \F$, we can read the whole memory to recover the coefficient vector of $f$ and hence compute $f(\alpha)$. Thus, the space complexity and the query complexity of this data structure are both ($O(n \log q) $) bits, with clearly the space requirement being the best that we can hope for. \item The second natural data structure for this problem just stores the evaluation of $f$ on all $\alpha \in \F$ in the memory, and on any query, can just read off the relevant value. Thus, the space complexity here is $O(q \log q)$ bits, but the query complexity is $O(\log q)$ bits (which is the best that we can hope for). For $q$ being much larger than $n$ the space requirement here is significantly larger than that in the first solution. \end{itemize} Using their algorithm for multipoint evaluation in \cite{Kedlaya11}, Kedlaya \& Umans construct a data structure for this problem with space complexity $n^{1 + \delta}\log^{1 + o(1)} q$ and query complexity $\poly(\log n)\cdot \log^{1 + o(1)} q$ for all $\delta > 0$ and sufficiently large $n$. Thus, the space needed is quite close to optimal, and the query complexity is within a $\poly(\log n)$ factor of the optimal. Quite surprisingly, this data structure is not {algebraic} since it relies on the {multipoint evaluation } algorithm in \cite{Kedlaya11} which in turn relies on non-algebraic modular arithmetic. We also note that while the algorithm for {multipoint evaluation } over fields of small characteristic in \cite{Umans08} is algebraic, to the best of our knowledge, it does not immediately yield a data structure for polynomial evaluation. We remark that while the discussion here has been focused on data structures for univariate polynomial evaluation, the ideas in \cite{Kedlaya11} continue to work as it is even for the multivariate version of this problem and gives quantitatively similar results there. In fact, their solution to the univariate problem goes via a reduction to the multivariate case! In a recent work, Bj{\"o}rklund, Kaski and Williams \cite{BKW19} also prove new data structures upper bounds for polynomial evaluations for multivariate polynomials over finite fields. These data structures are algebraic and are based on some very neat geometric ideas closely related to the notion of Kakeya sets over finite fields. Their construction can be viewed as giving a tradeoff in the space and query complexities but at least one of these parameters always appears to have polynomial dependence on the size of the underlying finite field. This is in contrast to the results in \cite{Kedlaya11} where the query complexity depends nearly linearly on $\log q$ which is more desirable for this problem. A very natural open question in this line of research is to obtain an algebraic data structure for this problem which matches the space and query complexity of the results in \cite{Kedlaya11}. Currently, we do not have an algebraic data structure for this problem over with even polynomial space and sublinear query complexity over any sufficiently large field. In fact, Milterson \cite{M95} showed that for algebraic data structures over finite fields of size exponential in $n$, if the space used is $\poly(n)$, then the trivial data structure obtained by storing the given polynomial as a list of coefficients and reading off everything in the memory on every query is essentially the best we can do. Milterson also conjectured a similar lower bound to hold over smaller fields. Thus, over smaller finite fields (for instance, finite fields of size $\poly(n)$), either proving a lower bound similar to that in \cite{M95} , or constructing \emph{algebraic} data structures for polynomial evaluation with perform guarantees similar to those in \cite{Kedlaya11} are extremely interesting open problems. For the later goal, it would be a good start to even have an algebraic data structure that does significantly better than the trivial solution of storing the coefficient vector of the given polynomial. \subsection{Non-rigidity of Vandermonde matrices}\label{sec: rigidity intro} An application of our results for {multipoint evaluation } is towards upper bounds for the rigidity of Vandermonde matrices. In this section, we give a brief overview of matrix rigidity. Let $\F$ be any field. An $n \times n$ matrix $M$ over $\F$ is said to be $(r,s)$ rigid for some parameters $r, s \in \N$ if $M$ cannot be written as a sum of $n\times n$ matrices of rank at most $r$ and sparsity at most $s$. In other words, the rank of $M$ cannot be reduced to less than or equal to $r$ by changing at most $s$ of its entries. This notion was defined by Valiant \cite{Valiant1977} who showed that if the linear transformation given by $M$ can be computed by an arithmetic circuit of size $O(n)$ and depth $O(\log n)$, then $M$ is not $(O(n/\log\log n), O(n^{1 + \epsilon}))$ rigid for any $\epsilon > 0$. For brevity, we say that a family of matrices is \emph{Valiant rigid} if it is $(O(n/\log\log n), O(n^{1 + \epsilon}))$ rigid for some $\epsilon > 0$. Thus, constructing an explicit family of matrices that are Valiant rigid suffices for proving superlinear lower bounds for log depth circuits for an explicit family of linear transformations; an extremely interesting problem that continues to be wide open. The progress on this question has been painfully slow although there have been several highly non-trivial and extremely interesting developments in this direction, e.g. \cite{ShokrollahiSS1997, Friedman1993, Lokam00, Lok01, Lokam06, GoldreichT2018, AlmanC2019, BhangaleHPT2020}. Even though the question of provable rigidity lower bounds for explicit matrix families has remained elusive, there has been a steady accumulation of various families of explicit matrices that are suspected to be rigid. For instance, Hadamard Matrices, Design Matrices, the Discrete Fourier Transform (DFT) matrices and various Vandermonde Matrices have all been suspected to be rigid with varying parameters at various points in time. For some of these cases, we even have rigidity lower bounds either for special cases or with parameters weaker than what is needed for Valiant's connection to arithmetic circuit lower bounds. However, quite surprisingly Alman \& Williams \cite{AlmanW2017} showed that Hadamard matrices are not Valiant rigid over $\Q$. This result was succeeded by a sequence of recent results all showing that many more families of matrices suspected to be highly rigid are in fact not Valiant rigid. This includes the work of Dvir \& Edelman \cite{DvirE2019}, the results of Dvir \& Liu \cite{DL20}, those of Alman \cite{Alman21} and Kivva \cite{kivva21}. This list of suspected to be highly rigid that have since been proven innocent includes families like Hadamard Matrices \cite{AlmanW2017}, Discrete Fourier Transform (DFT) Matrices, Circulant and Toeplitz matrices \cite{DL20} and any family of matrices that can be expressed as a Kronecker product of small matrices \cite{Alman21, kivva21}. However, a notable family of matrices missing from this list is that of Vandermonde matrices. Special cases of Vandermonde matrices, for instance the DFT matrices, are known to be not be Valiant rigid, and in fact this result extends to the case of all Vandermonde matrices where the \emph{generators} are in geometric progression.\footnote{An $n\times n$ Vandermonde matrix over a field $\F$ is specified by a list of $n$ field elements $\alpha_0, \alpha_1, \ldots, \alpha_{n-1}$ in $\F$ that we call generators. The rows and columns are indexed by $\{0, 1, \ldots, n-1\}$ and the $(i,j)$th entry of the matrix equals ${\alpha_i}^j$.} However, the case of Vandermonde matrices with arbitrary generators is still not well understood.\footnote{Lokam \cite{Lokam00} shows that $n \times n$ Vandermonde matrices with algebraically independent generators are at least $(\sqrt{n}, \Omega(n^2))$ rigid. This bound, however, is not sufficient for Valiant's program.} \section{Our results} \label{sec: results} We now state our results formally and try to place them in the context of prior work. \subsection{Algorithms for multivariate multipoint evaluation} Our main result is a fast algebraic algorithm for {multipoint evaluation } over fields of small characteristic. We state this result informally here, and refer the reader to \autoref{thm:polynomial-evaluation-v4} for a formal statement. \begin{theorem}[Informal]\label{thm:mme informal} Over a field $\F_{p^a}$ of characteristic $p$, there is a deterministic algorithm which evaluates a given $n$-variate polynomial of degree less than $d$ in each variable on $N$ inputs in time $$\left((N + d^n)^{1 + o(1)}\cdot \poly(a, d, n, p)\right) \, ,$$ provided that $p$ is at most $d^{o(1)}$ and $a$ is at most $(\exp(\exp(\exp(\cdots (\exp(d)))))$, where the height of this tower of exponentials is fixed. \end{theorem} A few remarks are in order. \begin{remark} \label{rmk: description of the finite field} Throughout this paper, we assume that we are given a description of the field $\F_{q=p^a}$ as a part of the input. For instance, we are given an irreducible polynomial $v(Y) \in \F_p[Y]$ of degree equal to $\log_p q$ and $\F_q \equiv \F_p[Y]/\ideal{v(Y)}$. \end{remark} \begin{remark}\label{rmk: algebraic algorithm} Our algorithms for \autoref{thm:mme informal} can be viewed as naturally giving an arithmetic circuit of nearly linear size for multivariate multipoint evaluation over the underlying finite field $\F_{p^a}$. Throughout this paper, this is what we mean when we say we have an ``algebraic" algorithm. Moreover, given a description of $\F_q$ as in \autoref{rmk: description of the finite field}, we can use the algorithm in \autoref{thm:mme informal} to output such a circuit for multipoint evaluation in nearly linear time. \end{remark} As alluded to in the introduction, when the number of variables is large (e.g. $n \notin d^{o(1)}$), this is the first {nearly linear} time algorithm for this problem over any sufficiently large field. Prior to this work, the fastest known algorithms for multivariate multipoint evaluation are due to the results of Umans \cite{Umans08} and Kedlaya \& Umans \cite{Kedlaya11} who give nearly linear time algorithms for this problem over finite fields of small characteristic and {all} finite fields respectively when the number of variables $n$ is at most $d^{o(1)}$. \autoref{thm:mme informal} answers an open question of Kedlaya \& Umans \cite{Kedlaya11} over the fields where it applies. For a comparison between our result, \cite{Umans08} and \cite{Kedlaya11} see Table \ref{tab:comparison}. Here, $\text{Char}(\F)$ denotes the characteristic of the field $\F$. \begin{center} \begin{tabular}{|p{1.5cm}|p{4.5cm}|p{2cm}|p{3.8cm}|p{2cm}|} \hline \multicolumn{5}{|c|}{Multivariate Multipoint evaluation over a finite field $\F_{q=p^a}$} \\ \hline Results & Number of Operations & Algorithm type & Field constraint & Variable\\ \hline \cite{Umans08} & $(N + d^n)^{1 + \delta}$, $\forall \delta >0$, $\F_q$-operations &Algebraic& $~~~~~~~\text{Char}(\F_q)\leq d^{o(1)}$ & $~~~~n \leq d^{o(1)}$\\\hline \cite{Kedlaya11}& $(N + d^n)^{1 + \delta} \log^{1+o(1)}q$, $\forall \delta >0$, many bit operations & Non-algebraic & $~~~~~~$over any finite field & $~~~~n \leq d^{o(1)}$\\\hline This work &\small{$(N + d^n)^{1 + o(1)}\cdot \poly(d, n, \text{Char}(\F_q), \log q)$} $\F_q$-operations (\autoref{thm:polynomial-evaluation-v4})& Algebraic& $~~~~~~~\text{Char}(\F_q)\leq d^{o(1)}$, \small{$q \leq(\exp(\exp(\cdots(\exp (d))))$, where the height of this tower of exponentials is fixed} & $~~$ over any $n$ \\ \hline \end{tabular} \captionof{table}{Comparison with known results } \label{tab:comparison} \end{center} By a direct connection between the complexity of multipoint evaluation and modular composition shown by Kedlaya \& Umans \cite{Kedlaya11}, \autoref{thm:mme informal} implies a nearly linear time algorithm for modular composition even when the number of variables $n$ is not less than $d^{o(1)}$. In \cite{Kedlaya11}, such an algorithm was obtained when $n < d^{o(1)}$ (over all finite fields). More precisely, we have the following corollary. \begin{corollary}[Informal]\label{cor:modular composition} Let $\F_{p^a}$ be a field of characteristic $p$. Then, there is an algorithm that on input an $n$-variate polynomial $f(X_1, X_2, \ldots, X_n)$ of individual degree less than $d$ and univariate polynomials $g_1(X), \ldots, g_n(X)$ and $h(X)$ in $\F_{p^a}[X]$ with degree less than $N$, outputs the polynomial $$ f(g_1(X), g_2(X), \ldots, g_n(X)) \mod h(X) $$ in time $$(d^n + N)^{1 + o(1)}\cdot \poly(a, d, n, p) \, ,$$ provided that $p$ is at most $d^{o(1)}$ and $a$ is at most $(\exp(\exp(\exp(\cdots (\exp(d)))))$, where the height of this tower of exponentials is fixed. \end{corollary} Our algorithm is based on elementary algebraic ingredients. One of these ingredients is the basic fact that the restriction of a low degree multivariate polynomial to a low degree curve is a low degree univariate polynomial! We use this fact together with some other algebraic tools, e.g. univariate polynomial interpolation (with multiplicities), structure of finite fields, and multidimensional FFT for our algorithm. We describe an overview of the main ideas in the proof in \autoref{sec: proof overview}. We also note that even though the algorithm in \cite{Umans08} is algebraic, it appears to be based on ideas very different from those in this paper. In particular, Umans relies on a clever reduction from the multivariate problem to the univariate problem by working over appropriate extension of the underlying field. This is then combined with the classical univariate multipoint evaluation algorithm to complete the picture. Our algorithm, on the other hand, does not involve a global reduction from the multivariate set up to the univariate set up, and crucially relies on more local properties of low degree multivariate polynomials. Another related prior work is a result of Bj\"orklund, Kaski and Williams \cite{BKW19}, who give a data structure (and an algorithm) for multipoint evaluation and some very interesting consequences to fast algorithms for problems in $\#\P$. We note that at a high level, the structure of our algorithm is similar to that of the algorithm of Bj\"orklund, Kaski and Williams \cite{BKW19}. However, the technical details and quantitative bounds achieved are different. One major difference is that the time complexity of the algorithm in \cite{BKW19} depends \emph{polynomially} on the field size. Thus strictly speaking, with the field size growing, this algorithm is not polynomial time in the input size. On the other hand, the time complexity of the algorithms in the works of Umans \cite{Umans08}, Kedlaya \& Umans \cite{Kedlaya11} and that in \autoref{thm:mme informal} depends polynomially in the logarithm of the field size, as is more desirable. We discuss the similarities and differences in the high level structure of the algorithm in \cite{BKW19} and that in \autoref{thm:mme informal} in a little more detail in \autoref{sec: proof overview}. \subsection{Data structures for polynomial evaluation} As an interesting application of our ideas in \autoref{thm:mme informal}, we get the following upper bound for data structure for polynomial evaluation. \begin{theorem}[Informal]\label{thm: data structure intro} Let $p$ be a fixed prime. Then, for all sufficiently large $n \in \N$ and all fields $\F_{p^a}$ with $a \leq \poly(\log n)$, there is an algebraic data structure for polynomial evaluation for univariate polynomials of degree less than $n$ over $\F_{p^a}$ that has space complexity at most $n^{1 + o(1)}$ and query complexity at most $n^{o(1)}$. \end{theorem} A more precise version of \autoref{thm: data structure intro} can be found in \autoref{thm: data structure technical}. We remark that by an algebraic data structure, we mean that there is an algebraic algorithm (in the spirit of \autoref{rmk: algebraic algorithm}) over $\F_{p^a}$ that, when given the coefficients of a univariate polynomial $f$ of degree at most $n$ as input outputs the data structure ${\cal D}_f$ in time $n^{1 + o(1)}$ and another algebraic algorithm which when given an $\alpha \in \F_{p^a}$ and query access to ${\cal D}_f$ outputs $f(\alpha)$ in time $n^{o(1)}$. In other words, there is an arithmetic circuit $C_1$ over $\F_{p^a}$ with $n^{1 + o(1)}$ outputs that when given the coefficients of $f$ as input, outputs ${\cal D}_f$ and an arithmetic circuit $C_2$ with $n^{o(1)}$ inputs satisfying the following: for every $\alpha \in \F_{p^a}$, there is a subset $S({\alpha})$ of cells in ${\cal D}_f$ such that on input $\alpha$ and ${{\cal D}_f}|_{S(\alpha)}$, $C_2$ outputs $f(\alpha)$. As alluded to in the introduction, Milterson \cite{M95} showed that over finite fields that are exponentially large (in the degree parameter $n$), any algebraic data structure for polynomial evaluation with space complexity $\poly(n)$ must have query complexity $\Omega(n)$. He also conjectured that the lower bound continues to hold over smaller fields.\footnote{We note that Milterson did not precisely quantify what \emph{smaller} fields mean, but the case when the field size is a large polynomial in the degree parameter $n$ is a natural setting, since the trivial data structures in this case do not have both nearly linear space and sublinear query complexity. \autoref{thm: data structure intro} provides such a construction when the underlying field additionally has a small characteristic.} \autoref{thm: data structure intro} provides a counterexample to this conjecture when the underlying field has small characteristic and is quasipolynomially bounded in size. The data structure of Kedlaya \& Umans \cite{Kedlaya11} outperforms the space and query complexities of the data structure in \autoref{thm: data structure intro}. However, their construction is not algebraic; essentially because their algorithm for {multipoint evaluation } is not algebraic.\footnote{This is also the reason why the data structure in \cite{Kedlaya11} does not give a counterexample to Milterson's conjecture.} However, their construction works over all finite fields, while we require fields of small characteristic that are quasipolynomially bounded in size. Umans' \cite{Umans08} algorithm for {multipoint evaluation } on the other hand is algebraic, although to the best of our knowledge, this is not known to give a data structure for polynomial evaluation. Finally, we note that for the algebraic data structure in the work of Bj{\"o}rklund, Kaski and Williams \cite{BKW19}, either the query complexity or the space complexity has polynomial dependence on the field size and thus even over fields of polynomial size it does not appear to give nearly linear space complexity or sublinear query complexity. However, the results in \cite{BKW19} are stated for multivariate polynomials and it is not clear to us if for the special case of univariate polynomial one can somehow bypass this polynomial dependence on field size by a careful modification of their construction. \subsection{Upper bound on the rigidity of Vandermonde matrices} As the second application of the ideas in \autoref{thm:mme informal}, we show the following upper bound on the rigidity of general Vandermonde matrices. \begin{theorem}[Informal]\label{thm: vandermonde rigidity intro} Let $p$ be a fixed prime. Then, for all constants $\epsilon$ with $0 < \epsilon < 0.01$ and for all sufficiently large $n$, if $V$ is an $n \times n$ Vandermonde matrix over the field $\F_{p^a}$ for $a \leq \poly(\log n)$, then the rank of $V$ can be reduced to $ \frac{n}{\exp\big{(} \Omega(\epsilon^7\log^{0.5} n)\big{)}}$ by changing at most $n^{1 + \Theta(\epsilon)}$ entries of $V$. \end{theorem} For a more formal version of \autoref{thm: vandermonde rigidity intro}, we refer to \autoref{thm: Vandermonde rigidity}. \autoref{thm: vandermonde rigidity intro} extends the list of natural families of matrices that were considered potential explicit candidates for rigidity but turn out to not be rigid enough for Valiant's program \cite{Valiant1977} of obtaining size-depth tradeoffs for linear arithmetic circuits via rigidity. Prior to this work, such upper bounds on rigidity were only known for special Vandermonde matrices, for instance, the Discrete Fourier transform matrix and Vandermonde matrices with generators in geometric progression \cite{DL20}. Our proof of \autoref{thm: vandermonde rigidity intro} crucially relies on the results in \cite{DL20} and combines these ideas with ideas in the proof of \autoref{thm:mme informal}. We discuss these in more details in the next section. \section{An overview of the proofs}\label{sec: proof overview} In this section we describe some detail, the main high level ideas of our proofs. We begin with a detailed overview of our algorithms for multipoint evaluation. We have three algorithms (\autoref{sec: mme algo simple}, \autoref{sec: mme algo large n} and \autoref{sec: mme large fields}) starting with the simplest one and each subsequent algorithm building upon the previous one with some new ideas. We start with the simplest one here. \subsection{A simple algorithm for multipoint evaluation}\label{sec: overview mme algo 1} We start with some necessary notation. Let $p$ be a prime and $\F_q$ be a finite field with $q = p^a$. Let $f \in \F_{q}[\vecx]$ be an $n$-variate polynomial of degree at most $d-1$ in every variable and for $i = 1, 2, \ldots, N$ let $\pmb\alpha_i \in \F_q^n$ be points. The goal is to output the value of $f$ at each of these points $\pmb\alpha_i$. As is customary, we assume that the field $\F_q$ is given as $\F_p[Y]/\ideal{v(Y)}$ for some degree $a$ irreducible polynomial $v(Y) \in \F_p[Y]$. In \autoref{lem:extracting coefficients in field representation}, we observe that given the irreducible polynomial $v(Y) \in \F_p[Y]$ such that $\F_q = \F_p[Y]/\ideal{v(Y)}$ and any $u \in \F_q$, we can efficiently compute the coefficients of the univariate polynomial over $F_p[Y]$ corresponding to $u$ via arithmetic operations over $\F_q$. Therefore, for the rest of this discussion, we assume that every field element (in the coefficients of $f$ and the coordinates of $\pmb\alpha_i$) are explicitly given to univariate polynomials of degree at most $a-1$ in $\F_p[Y]$. We start with a discussion of the simplest version of our algorithm before elaborating on the other ideas needed for further improvements. The formal guarantees for this version can be found in \autoref{thm:polynomial-evaluation-v1}. The algorithm can be thought to have two phases, the preprocessing phase and the local computation phase. \paragraph*{Preprocessing phase. }We start with a description of the preprocessing phase. \begin{itemize} \item \textbf{A subfield of appropriate size: } As the first step of the algorithm, we compute a natural number $b$ such that $p^{b-1} \leq adn \leq p^b$. For the ease of this discussion, let us assume that $b$ divides $a$, and thus $\F_{p^b}$ is a subfield of $\F_q = \F_{p^a}$. If $b$ does not divide $a$, then we work in a field $\F_{p^c}$ that is a common extension of $\F_{p^a}$ and $\F_{p^b}$. \item \textbf{Evaluating $f$ on $\F_{p^b}^n$: } We now use the standard multidimensional Fast Fourier Transform algorithm to evaluate $f$ on all of $\F_{p^b}^n$. This algorithm runs in quasilinear time in the input size, i.e. $\tilde{O}(d^n + (p^{bn}))$, where $\tilde{O}$ hides $\poly(d, n, p, b)$ factors. From our choice of $b$, we note that this quantity is at most $\tilde{O}((padn)^n)$. \end{itemize} \paragraph*{Local computation phase. }We now describe the local computation phase. \begin{itemize} \item \textbf{A low degree curve through $\pmb\alpha_i$: } Once we have the evaluation of $f$ on all points in $\F_{p^b}^n$, we initiate some \emph{local} computation at each $\pmb\alpha_i$. This local computation would run in time $(adn)^c$ for some fixed constant $c$, thereby giving an upper bound of $\tilde{O}\left((pad)^n + N(adn)^{O(1)} \right)$ on the total running time. To describe this local computation, let us focus on a point $\pmb\alpha_i$. Since the field elements of $\F_q$ are represented as univariate polynomials of degree at most $(a-1)$ in $\F_p[Y]$, we get that for every $\pmb\alpha_i \in \F_q^n$, there exist vectors $\pmb\alpha_{i,0}, \pmb\alpha_{i,1}, \ldots, \pmb\alpha_{i,a-1}$ in $\F_p^n$ such that \[ \pmb\alpha_i = \pmb\alpha_{i,0} + \pmb\alpha_{i,1}Y + \cdots + \pmb\alpha_{i,a-1}Y^{a-1} \, . \] Let us now consider the curve $\vecg(t) \in \F_p^n[t]$ defined as \[ \vecg_i(t) = \pmb\alpha_{i,0} + \pmb\alpha_{i,1}t + \cdots + \pmb\alpha_{i,a-1}t^{a-1} \, . \] We are interested in some simple properties of this curve. The first such property is that it passes through the point $\pmb\alpha_i$, since $\pmb\alpha_i = \vecg_i(Y)$ (recall that $Y$ is an element of $\F_q = \F_p[Y]/\ideal{v(Y)}$ here). The second property is that this curve contains \emph{a lot} of points in the $\F_{p^b}^n$. In particular, note that for every $\gamma \in \F_{p^b}$, $\vecg_i(\gamma) \in \F_{p^b}^n$. Thus, there are at least $p^b$ points on $\vecg_i(t)$ in $\F_{p^b}^n$ (counted with multiplicities). \item \textbf{Restriction of $f$ to $\vecg_i(t)$: } We now look at the univariate polynomial $h_i(t)$ obtained by restricting the $n$-variate polynomial $f$ to the curve $\vecg_i(t)$. Thus, if $\vecg_i(t) = (g_{i,0}(t),\ldots, g_{i,n-1}(t))$ for some univariate polynomials $g_{i,j}(t)$ of degree at most $a-1$, then $h_i(t)$ is equal to the polynomial $f(g_{i,0}(t),\ldots, g_{i,n-1}(t))$. Clearly, the degree of $h_i$ is at most $a(d-1)n < adn$. From our previous discussion, we know that $h_i(Y) = f(\pmb\alpha_i)$. Moreover, we have already evaluated $f$ on all of $\F_{p^b}^n$ and thus, we know the value of $h_i(\gamma)$ for all $\gamma \in \F_{p^b}$. Note that these are at least $p^b$ many inputs on which the value of $h_i(t)$ is correctly known to us. Also, from our choice of $b$, we know that $p^b > adn > \deg(h_i)$. Thus, we can recover the polynomial $h_i$ completely using univariate polynomial interpolation in time at most $\poly(a, d, n, p)$, and thus can output $h_i(Y) = f(\pmb\alpha_i)$ in time $\poly(a,d,n,p)$. Iterating this local computation for every $i \in \{0,1,\ldots, N-1\}$, we can compute the value of $f$ at $\pmb\alpha_i$ for each such $i$. \end{itemize} \paragraph*{Correctness and running time. } The correctness of the algorithm immediately follows from the outline above. Essentially, we set things up in a way that to compute $f(\pmb\alpha_i)$ it suffices to evaluate the univariate polynomial $h_i$ at input $Y \in \F_q$. Moreover, from the preprocessing phase, we already have the value of $f$ on $\F_{p^b}^n$ and this in turn gives us the evaluation of $h_i(t)$ on $p^b > adn > \deg(h_i)$ distinct inputs. Thus, by standard univariate polynomial interpolation, we recover $h_i$ and hence $h_i(Y) = f(\pmb\alpha_i)$ correctly. The time complexity of the preprocessing phase is dominated by the step where we evaluate $f$ on $\F_{p^b}^n$. This can be upper bounded by $\tilde{O}((padn)^n)$ using the standard multidimensional FFT algorithm. In the local computation phase, the computation at each input point $\pmb\alpha_i$ involves constructing the curve $\vecg_i(t)$, constructing the set $\{(\gamma, h_i(\gamma)): \gamma \in \F_{p^b}\}$, using the evaluation of $h_i$ on these $p^b$ inputs to recover $h_i$ uniquely via interpolation and then computing $h_i(Y)$. For every $\gamma \in \F_{p^b}$, $\vecg_i(\gamma) \in \F_{p^b}^n$ can be done in time at most $\poly(a, d, n, p)$. So, the total time complexity of this phase is at most $(N\cdot \poly(a, d, n, p))$, and hence the total running time of the algorithm is $\tilde{O}(N + (padn)^n)$. \subsection{Towards faster multipoint evaluation} The algorithm outlined in the previous section achieves a ${O}(Nn + d^n)^{1 + o(1)}$ when $apn = d^{o(1)}$. We now try to modify it so that it continues to be nearly linear time even when the number of variables $n$ and the degree of underlying field $a$ are not less than $d^{o(1)}$. The factor of $p^n$ appears to be inherent to our approach and seems difficult to get rid of, and this leads to the restriction of working over fields of small characteristic for all our results in this paper. Before proceeding further, we remark that the basic intuition underlying all of our subsequent algorithms are essentially the same as those in the simple algorithm outlined in this section. For each of the further improvements, we modify certain aspects of this algorithm using a few more technical (and yet simple) ideas on top of the ones already discussed in \autoref{sec: overview mme algo 1}. \paragraph*{Handling large number of variables. } The factor of $n^n$ in the running time appears in the preprocessing phase of the algorithm in \autoref{sec: overview mme algo 1}. The necessity for this stems from the fact that the univariate polynomial $h_i(t)$ obtained by restricting $f$ to the curve $\vecg_i(t)$ through $\pmb\alpha_i$ can have degree as large as $a(d-1)n$. Thus, for interpolating $h_i(t)$ from its evaluations, we need its value on at least $a(d-1)n + 1$ distinct inputs. Thus, we need $p^b$ to be at least $a(d-1)n + 1$. However, we note that if we have access to not just the evaluations of $h_i(t)$, but also to the evaluations of its derivatives up to order $n-1$ at each of these inputs in $\F_{p^b}$, then $h_i(t)$ can be uniquely from this information provided $p^b$ is at least $\deg(h_i(t))/n$, i.e. $(a(d-1)n + 1)/n \leq ad$ (see \autoref{lem:hermitian-interpolation} for a formal statement). Thus, with observation at hand, we now choose $b$ such that $p^{b-1} \leq ad \leq p^b$. Moreover, for the local computation, we now need not only the evaluation of $h_i$ on all points in $\F_{p^b}$ but also the evaluations of all derivatives of $h_i(t)$ of order at most $n-1$ on all these points. A natural way of ensuring that the evaluations of these derivatives of $h_i(t)$ are available in the local computation phase is to compute not just the evaluation of $f$ but also of \emph{all} its partial derivatives of up to $n$ on all of $\F_{p^b}^n$. Together with the chain rule of partial derivatives, we can use the evaluations of these partial derivatives of $f$ and the identity $h_i(t) = f \circ \vecg_i(t)$ to obtain the evaluations of $h_i(t)$ and all its derivatives of order at most $n-1$ on all inputs in $\F_{p^b}$. This ensures that $h_i$ can once again be correctly and uniquely recovered given this information via a standard instance of Hermite Interpolation, which in turn ensures the correctness of the algorithm. To see the effect on the running time, note that in the preprocessing phase, we now need to evaluate not just $f$ but all its partial derivatives of order at most $n-1$ on all of $\F_{p^b}^n$. Thus, there are now roughly $\binom{n + n}{n} \leq 4^n$ polynomials to work with in this phase. So, given the coefficients of $f$, we first obtain the coefficients of all these derivatives, and then evaluate these polynomials on $\F_{p^b}^n$ using a multidimensional FFT algorithm again. Also, the coefficient representation of any fixed derivative of order up to $n-1$ can be computed from the coefficients of $f$ in $\tilde{O}(d^n)$ time (see \autoref{lem:computing-hasse-derivation}). Thus, the total time complexity of the preprocessing phase in this new algorithm can be upper bounded by $\tilde{O}((adp)^n4^n)$. Once we have this stronger guarantee from the preprocessing phase, we get to doing some local computation at each point $\pmb\alpha_i$. Now, instead of recovering $h_i$ via a standard univariate polynomial interpolation, we have to rely on a standard Hermite interpolation for this. In particular, we need access to the evaluation of all derivatives of $h_i(t)$ of order at most $n-1$ on all inputs $\gamma \in \F_{p^b}$. This can be done via an application of chain rule of derivatives and the fact that we have evaluations of \emph{all} partial derivatives of $f$ of order at most $n-1$ on all points in $\F_{p^b}^n$. The time taken for this computation at each $\gamma \in \F_{p^b}$ turns out to be about ${O}(4^n\poly(d, n, a, p))$. Thus, the total time taken for local computation at all the input points can be upper bounded by roughly ${O}(N4^n\poly(d, n, a, p))$. Thus, the total time complexity of this modified algorithm is $\tilde{O}((N + (adp)^n)4^n)$. In other words, we have managed to remove the factor of $n^n$ present in the algorithm in \autoref{sec: overview mme algo 1} and replace it by $4^n$. An algorithm based on this improvement is described in \autoref{sec: mme algo large n}. \paragraph*{Handling larger fields. } We now discuss the improvement in the dependence on the parameter $a$, which is the degree of the extension of $\F_p$ where the input points lie. In the local computation step at each point, the curve $\vecg_i(t)$ through $\pmb\alpha_i$ has degree $a-1$ in the worst case, since we view the field elements in $\F_{p^a}$ as univariate polynomials of degree at most $a-1$ with coefficients in $\F_p$. Therefore, the restriction of $f$ to such a curve, namely the polynomial $h_i(t)$ can have degree $(a-1)\deg(f)$ in the worst case. This forces us to choose the parameter $b$ such that $p^b$ is at least $\deg(h_i)$, thereby leading to a factor of $a^n$ in the running time. Note that if we had the additional promise that the point $\pmb\alpha_i$ was in an extension $\F_{p^{\tilde{a}}}$ of $\F_p$ for some $\tilde{a} < a$, then the curve $\vecg_i$ would be of degree at most $(\tilde{a}-1) < (a-1)$ and hence the polynomial $h_i$ would have degree at most $(\tilde{a}-1)\deg(f)$. More generally, if all the input points $\pmb\alpha_i$ were promised to be in $\F_{p^{\tilde{a}}}^n$, we can improve the factor $a^n$ to $(\tilde{a})^n$ in the running time by choosing $b$ such that $p^b$ is larger than $\tilde{a}dn$ (in fact, we only need $p^b \geq (\tilde{a}d)$ if we are working with multiplicities). We also note that for every $\tilde{a} \in \N$ the curve $\vecg_i(t)$ takes a value in $\F_{p^{\tilde{a}}}^n$ whenever $t$ is set to a value in $\F_{p^{\tilde{a}}}$. As a consequence, the curve $\vecg_i$ contains at least $p^{\tilde{a}}$ points in $\F_{p^{\tilde{a}}}^n$. With these observations in hand, we now elaborate on the idea for reducing the $a^n$ factor in the running time. For simplicity of exposition, we outline our ideas in the setting of the algorithm discussed in \autoref{sec: overview mme algo 1}. In particular, derivative based improvements are not involved. Let $a'$ be such that $p^{a'} > adn \geq p^{a'-1}$. Now, instead of recovering $h_i$ directly from its values on $\F_{p^b}$, we try to recover $h_i$ in two steps. In the first step, we try to obtain the values of $h_i(\gamma)$ for every $\gamma \in \F_{p^{a'}}$ using the information we have from the preprocessing phase. Assuming that we can do this, we can again obtain $h_i$ by interpolation and compute $h_i(Y) = f(\pmb\alpha_i)$. Now, to compute $h_i(\gamma)$ for $\gamma \in \F_{p^{a'}}$, we note that $h_i(\gamma)$ equals $f\circ \vecg_i(\gamma)$, thus it would be sufficient if we had the evaluation of $f$ on the point set $\{\vecg_i(\gamma) : \gamma \in \F_{p^{a'}}\}$. This seems like the problem we had started with, but with one key difference: the points $\{\vecg_i(\gamma) : \gamma \in \F_{p^{a'}}\}$ are all in $\F_{p^{a'}}^n$ with $a' = \Theta(\log adn)$! Thus, the degree of the extension where these points lie is significantly reduced. In essence, this discussion gives us a reduction from the problem of evaluating $f$ on $N$ points in $\F_{p^a}^n$ to evaluating $f$ on $N\cdot adn$ points in $\F_{p^{a'}}^n$, with $a' = \Theta(\log adn)$. Thus, we have another instance of multipoint evaluation with a multiplicatively larger point set in an extension of $\F_p$ of degree logarithmic in $adn$. If we now apply the algorithm discussed in \autoref{sec: overview mme algo 1}, we get a running time of roughly $\tilde{O}(Nadn + (pdn\log (adn))^n)$. Thus, in the running time, the factor $a^n$ has been replaced by $\log^n a$ at the cost of $N$ being replaced by $Nadn$. In fact, we can continue this process $\ell$ times, and in each step we end up with an instance of multipoint evaluation with the size of the point set being increased by a multiplicative factor, with the gain being that we have a substantial reduction in the degree of the field extension that the points live in. This idea can be combined with those used for improving the dependence on the number of variables, to get our final algorithm that achieves nearly linear running time provided that $p = d^{o(1)}$ and $a\leq \exp(\exp(\ldots(\exp(d))))$ where the height of this tower of exponentials is fixed. We refer to \autoref{thm:polynomial-evaluation-v4} for a formal statement of the result and \autoref{sec: mme large fields} for further details. \paragraph*{Comparison with the techniques of Bj\"orklund, Kaski and Williams \cite{BKW19}. }\label {sec: bkw comparison} Now that we have an overview of the algorithms for multipoint evaluation in this paper, we can elaborate on the similarities they share with the algorithms in \cite{BKW19}. At a high level, the similarities are significant. In particular, both the algorithms have a preprocessing phase where the polynomial is on a product set using multidimensional FFT. This is followed by a local computation step, where the value of the polynomial at any specific input of interest is deduced from the already computed data by working with the restriction of the multivariate polynomial to an appropriate curve. In spite of these similarities in the high level outline, the quantitative details of these algorithms are different. One salient difference is that the time complexity of the algorithm in \cite{BKW19}, depends polynomially on the size of the underlying field, whereas in our algorithm outlined above, this dependence is polynomial in logarithm of the field size as long as the size of the field is bounded by a tower function of fixed height in the degree parameter $d$. This difference stems from technical differences in the precise product set used in the preprocessing phase and the sets of curves utilized in the local computation phase. In particular, the degree of the curves in the local computation phase of our algorithms depends polynomially on $\log |\F|$, where as the degree of the curves used in \cite{BKW19} depends polynomially on $|\F|$. Additionally, algorithms in \cite{BKW19} rely on the assumption that the total degree of the polynomial divides $|\F^{*}| -1$, whereas we do not need any such divisibility condition. \subsection{Data structure for polynomial evaluation}\label{sec: data structures overview} The multipoint evaluation algorithm in \autoref{thm:mme informal} is naturally conducive to obtaining data structures for polynomial evaluation. Essentially, the evaluation of the polynomial in a fixed grid (independent of the $N$ points of interest in the input) gives us the data structure, and the local computation at each input point of interest which requires access to some of the information computed in the preprocessing phase constitutes the query phase of the data structure. We discuss this in some more detail now. Let $f(X) \in \F_{p^a}[X]$ be a univariate polynomial of degree at most $n$. We start by picking parameters $d, m$ such that $d^m$ is at least $n$. For any such choice of $d$ and $n$, there is clearly an $m$-variate polynomial $F(Z_0, Z_1, \ldots, Z_{m-1})$ such that $F(X, X^d, X^{d^2}, \ldots, X^{d^{m-1}}) = f(X)$. In other words, the image of $F$ under the Kronecker substitution equals $f$. Now, as in the multipoint evaluation algorithms, we pick the smallest integer $b$ such that $p^b > adm$ and evaluate $F$ on $\F_{p^b}^m$ and store these points along with the value of $F$ on these inputs in the memory. This forms the memory content of our data structure. Thus, the memory can be thought of having $p^{bm} \leq (padm)^m$ cells, each containing a pair $(\vecc, F(\vecc))$ for $\vecc \in \F_{p^b}^m$. Let us now consider the query complexity of this data structure. Let $\alpha \in \F_{p^a}$ be an input and the goal is to compute $f(\alpha)$. From the relation between $F$ and $f$, we have that $f(\alpha) = F(\pmb\alpha)$, where $\pmb\alpha = (\alpha, \alpha^d, \alpha^{d^2}, \ldots, \alpha^{d^{m-1}})$. Now, we rely on the local computation in the multipoint evaluation algorithms to compute $F(\pmb\alpha)$. In the algorithm, we consider a curve $\vecg$ of degree at most $a-1$ which passes through $\pmb\alpha$ and look at the restriction of $F$ to this curve to get a univariate polynomial $h$ of degree less than $adm$. Then, we take the value of $h$ on inputs in $\F_{p^b}$, which can be recovered from the value of $F$ on the points in the set $\vecg(\F_{p^b}) \cap \F_{p^b}^n$. Finally, note that there are at least $p^b > adm$ of these inputs and value of $h$ on these inputs is already stored in the memory. This suffices to recover $h$ and thus, also $f(\alpha) = F(\pmb\alpha)$. So, the query complexity of this data structure is $adm$. To get a sense of the parameters, let us set $d = n^{1/\log\log n}$ and $m = \log\log n$. Clearly, the constraint $d^m \geq n$ is met in this case. For this choice of parameter and for $p$ being a constant and $a \leq \poly(\log n)$, we get that the space complexity is at most $n^{1 + o(1)}$ and the query complexity is at most $n^{o(1)}$. The complete details can be found in \autoref{sec:data structures full}. \subsection{Rigidity of Vandermonde matrices}\label{sec: rigidity proof overview} The connection between rigidity of Vandermonde matrices and multipoint evaluation is also quite natural. Consider a Vandermonde matrix $V_n$ with generators $\alpha_0, \ldots, \alpha_{n-1}$ and for every $i, j \in \{0,1, \ldots, n-1\}$, the $(i,j)$th entry of $V_n$ is $\alpha_i^{j}$. Now, for any univariate polynomial $f$ of degree at most $n-1$, the coefficients of $f$, together with the set $\{\alpha_i : i \in \{0,1, \ldots, n-1\}\}$ of generators form an instance of (univariate) multipoint evaluation. Moreover, for any choice of the generators $\{\alpha_i : i \in \{0,1, \ldots, n-1\}\}$, the algorithm for multipoint evaluation, e.g \autoref{thm:mme informal} can naturally be interpreted as a circuit for computing the linear transform given by the matrix $V_n$. Furthermore, if this linear circuit is structured enough, we could, in principle hope to get a decomposition of $V_n$ as a sum of a sparse and a low rank matrix from this linear circuit, for instance, along the lines of the combinatorial argument of Valiant \cite{Valiant1977}. Our proof of \autoref{thm: vandermonde rigidity intro} is along this outline. We now describe these ideas in a bit more detail. Given a univariate polynomial $f$ of degree $n-1$ and inputs $\alpha_0, \alpha_1, \ldots, \alpha_{n-1}$, let $F$ be an $m$- variate polynomial of degree $d$ such that $(n = d^{m})$\footnote{For simplicity, let us assume that such a choice of integers $d, m$ exist.} as described in \autoref{sec: data structures overview}. Moreover, for $i \in \{0,1, \ldots, n-1\}$, let $\pmb\alpha_i = (\alpha_i, \alpha_i^d, \ldots, \alpha_i^{d^{m-1}})$. Now, as discussed in \autoref{sec: data structures overview}, $f(\alpha_i) = F(\pmb\alpha_i)$. Let $\Tilde{V}$ be the $n \times n$ matrix where the rows are indexed by $\{0,1, \ldots, n-1\}$ and the columns are indexed by all $m$- variate monomials of individual degree at most $d-1$. We use the fact that $d^m = n$ here. From the above set up, it immediately follows that the coefficient vectors of $f$ and $F$ are equal to each other (with the coordinate indices having slightly different semantics) and the matrices $V_n$ and $\Tilde{V}$ are equal to each other. We now observe that the algorithm for multipoint evaluation described in \autoref{sec: overview mme algo 1} gives a natural decomposition of $\Tilde{V}$ (and hence $V_n$) as a product of a matrix $A$ of row sparsity at most $adm$ and a $p^{bm} \times d^m$ matrix $B$ with $b$ being the smallest integer such that $p^b > adm$. The rows of $B$ are indexed by all elements of $\F_{p^b}^m$ and the columns are indexed by all $m$-variate monomials of individual degree at most $d-1$, and the $(\pmb\alpha, \vece)$ entry of $B$ equals $\pmb\alpha^{\vece}$. Intuitively, the matrix $B$ corresponds to the preprocessing phase of the algorithm and the matrix $A$ corresponds to the local computation. At this point, we use an upper bound of \cite{DL20} on the rigidity of Discrete Fourier Transform matrices over finite fields and the inherent Kronecker product structure of the matrix $B$ to obtain an upper bound on the rigidity of $B$. Finally, we observe that that matrix $V_n = \Tilde{V} = A\cdot B$ obtained by multiplying a sufficiently non-rigid matrix $B$ with a row sparse matrix $A$ continues to be non-rigid with an interesting regime of parameters. This essentially completes the proof. For more details, we refer the reader to \autoref{sec:rigidity proof}. \vspace{-0.5cm} \section{Preliminaries} We use $\N$ to denote the set of natural numbers $\{0,1,2,\ldots\}$, $\F$ to denote a general field. For any positive integer $N$, $[N]$ denotes the set $\{1,2,\ldots, N\}$. By $\var x$ and $\var z$, we denote the variable tuples $(X_1,\ldots,X_n)$ and $(Z_1,\ldots, Z_n)$, respectively. For any $\var e=(e_1,\ldots, e_n)\in \N^n$, $\var x^\var e$ denotes the monomial $\prod_{i=1}^nX_i^{e_i}$. By $|\var e|_1$, we denote the sum $e_1+\cdots+e_n$. For every positive integer $k$, $k!$ denotes $\prod_{i=1}^ki$. For $k=0$, $k!$ is defined as $1$. For two non-negative integer $i$ and $k$ with $k\geq i$, $\binom{k}{i}$ denotes $\frac{k!}{i!(k-i)!}$. For $k<i$, $\binom{k}{i}=0$. For non-negative integer $i_1,\ldots, i_s$ with $i_1+\cdots+i_s=k$, $\binom{k}{i_1,\ldots,i_s}=\frac{k!}{i_1!\cdots i_s!}$. For $\var a=(a_1,\ldots,a_n), \var b=(b_1,\ldots,b_n)\in\N^n$, $\binom{\var a}{\var b}=\prod_{i=1}^n\binom{a_i}{b_i}$, and $\binom{\var a+\var b}{\var a,\var b}=\prod_{i=1}^n\binom{a_i+b_i}{a_i,b_i}$. We say that a function $\psi:\N \to \N$ is polynomially bounded, or denoted by $\psi(n) \leq \poly(n)$, if there exists a constant $c$ such that for all large enough $n \in \N$, $\psi(n) \leq n^c$. \begin{proposition} \label{prop:binomial-estimation} For any two positive integers $i$ and $k$ with $k\geq i$, $$\binom{k}{i}\leq \left(\frac{ke}{i}\right)^i.$$ \end{proposition} For proof see \cite[Chapter 1]{Jukna}. Suppose that $p$ be a positive integer greater than $1$. Then for any non-negative integer $c$, $\log_p^{\circ c}(n)$ denotes the $c$-times composition of logarithm function with itself, with respect to base $p$. For example, $\log^{\circ 2}_p(n)=\log_p\log_p(n)$. By $\log^{\star}_p(n)$, denotes the smallest non-negative integer $c$ such that $\log^{\circ c}_p(n)\leq 1$. For $p=2$, we may omit the subscript $p$ in $\log_p(n)$, $\log^{\circ c}_p(n)$ and $\log^{\star}_p(n)$. \subsection{Some facts about finite fields} Suppose that $p$ is a prime and $q=p^a$ for some positive integer $a$. Then there exists an \emph{unique} finite field of size $q$. In other words, all the finite fields of size $q$ are \emph{isomorphic} to each other. We use $\F_q$ to denote the finite field of size $q$, and $p$ is called the characteristic of $\F_q$. For any finite field $\F_q$, $\F^*_q$ represents the multiplicative cyclic group after discarding the field element $0$. For any irreducible polynomial $v(Y)$ over $\F_q$, the quotient ring $\F_q[Y]/\ideal{v(Y)}$ forms a larger field over $\F_q$ of size $q^b$ where $b$ is the degree of $v(Y)$. The next lemma describes that we can efficiently construct such larger fields over $\F_q$, when the characteristic of the field is small \begin{lemma} \label{lem:finite-field-construction} Let $p$ be a prime and $q=p^a$ for some positive integer $a$. Then, for any positive integer $b$, the field $\F_{q^b}$ can be constructed as $\F_q[Y]/\ideal{v(Y)}$, where $v(Y)$ is degree $b$ irreducible polynomial over $\F_q$, in $\poly(a,b,p)$ $\F_q$-operations. Furthermore, all the basic operations in $\F_{q^b}$ can be done in $\poly(b)$ $\F_q$-operations. \end{lemma} \begin{proof} The elements of the quotient ring $\F_q[Y]/\ideal{v(Y)}$ are polynomials in $Y$ over $\F_q$ with degree less than $b$, and the operations are polynomial addition and multiplication under modulo $v(Y)$. Therefore, once we have an irreducible $v(Y)$ (over $\F_q$) of degree $b$, we can perform the basic operations in $\F_{q^b}$ using $\poly(b)$ $\F_{q}$-operations. From \cite[Theorem 4.1]{Shoup90}, we can compute a degree $b$ irreducible polynomial $v(Y)$ over $\F_q$ using $\poly(a,b,p)$ $\F_p$-operations. \end{proof} Fix a field $F_q$ of characteristic $p$. In the standard algebraic model over $\F_q$, the basic operations are addition, subtraction, multiplication, and division of elements in $\F_q$. Let $\F_q = \F_p[X]/\ideal{g(X)}$ where $q=p^a$ and $g(X)$ is a degree $a$ irreducible polynomial over $\F_p$. Then for any element $\alpha \in \F_q$, consider its canonical representation $\alpha=\alpha_0+\alpha_1 X + \ldots + \alpha_{a-1}X^{a-1}$ where $\alpha_i \in \F_p$. Note that it is not clear how to extract $\alpha_i$'s from $\alpha$ using the algebraic operations over $\F_q$. We show that this is possible if $p$ is small. Since $\F_q =\F_p[X]/\ideal{g(X)}$, $X \in \F_q$ is a root of the degree $a$ irreducible polynomial $g(X)$ (over $\F_p$). This implies that $X, X^p, X^{p^2}, \ldots, X^{p^{a-1}}$ are all distinct elements of $\F_q$. \begin{lemma}\label{lem:extracting coefficients in field representation} Let $p$ be prime and $q=p^a$ for some positive integer $a$. Let $\F_q=\F_p[X]/\ideal{g(X)}$ where $g(X)$ is a degree $a$ irreducible polynomial over $\F_p$. Let $\alpha\in\F_q$ and $\alpha=\alpha_0+\alpha_1X+\cdots+\alpha_{a-1}X^{a-1}$ where $\alpha_i\in\F_p$. Then, given blackbox access to $\alpha$ and $\F_q$-operations, $\alpha_0,\alpha_1,\ldots, \alpha_{a-1}$ can be computed in $ \poly(a,\log{p})$ $\F_q$-operations. \end{lemma} \begin{proof} Note that, given $\alpha$, we can compute $\alpha^p$ by repeated squaring over $\F_q$. Applying this iteratively, we have access to all conjugates $\alpha, \alpha^p, \alpha^{p^2}, \ldots, \alpha^{p^{a-1}}$. Observe that, $$ \underbrace{\begin{bmatrix} 1 & X & X^2 & \dots & X^{a-1} \\ 1 & X^p & X^{2p} & \dots & X^{p(a-1)} \\ \dots & \dots & \dots & \dots & \dots \\ 1 & X^{p^{a-1}} & X^{2p^{a-1}} & \dots & X^{(a-1) p^{a-1}} \end{bmatrix}}_A \begin{bmatrix} \alpha_0 \\ \alpha_1 \\ \dots \\ \alpha_{a-1} \end{bmatrix} = \begin{bmatrix} \alpha \\ \alpha^p \\ \dots \\ \alpha^{p^{a-1}} \end{bmatrix}.$$ Note that, the matrix $A$ in the above linear system is a Vandermonde matrix and thus invertible. Also, each entry of $A$ is an element in $\F_q$. Thus, we can find $\alpha_i$ by solving this linear system over $\F_q$. For time complexity, note that we can use $\alpha^{p^i}$ to compute $\alpha^{p^{i+1}}$. Thus, $\alpha , \alpha^p, \ldots , \alpha^{p^{a-1}}$ can be computed in $\poly(a, \log p )$ $\F_q$-operations. Also, the computation of $A$ and solving the linear system can be done in $\poly(a, \log p )$ $\F_q$-operations. Therefore, overall complexity is $\poly(a, \log p)$ $\F_q$-operations. \end{proof} Thus, for the rest of our paper, we consider that the extraction of the $\F_p$-coefficients from elements in $\F_q$ as an algebraic operation. Also, in our applications, the time complexity overhead introduced due to this is negligible. Suppose that $\F_{q_1}$ and $\F_{q_2}$ are two finite fields of characteristic $p$ such that $\F_{q_1}$ is a subfield of $\F_{q_2}$. Then $\F_{q_2}$ forms a vector space over $\F_{q_1}$. A subset $\{\beta_1,\beta_2,\ldots,\beta_k\}$ of $\F_{q_2}$ is called an $\F_{q_1}$-basis if every element of $\alpha\in F_{q_2}$ is a unique linear combination of $\beta_i$'s over $\F_{q_1}$. \begin{lemma} \label{lem:subfield-construction} Let $p$ be a prime and $q=p^a$ for some positive integer $a$. Let $b$ be a positive integer and $\F_{q^b}=\F_q[Y]/\ideal{v(Y)}$ for some degree $b$ irreducible polynomial $v(Y)$ over $\F_q$. Then, the following holds: \begin{enumerate} \item The field $\F_{q^b}$ contains the subfield $\F_{p^b}$. Furthermore, all the elements of $\F_{p^b}$ can be computed in $p^b\cdot \poly(a,b,p)$ $\F_q$-operations. \item In $\poly(a, b, p)$ $\F_q$-operations, an element $\beta\in\F_{q^b}$ can be computed such that $\{1,\beta,\ldots,\beta^{b-1}\}$ forms an $\F_p$-basis for $\F_{p^b}$. Moreover, given any element $\alpha\in \F_{p^b}$, the $\F_p$-linear combination of $\alpha$ in the basis $\{1,\beta,\ldots,\beta^{b-1}\}$ can be computed in $\poly(b)$ $\F_q$-operations. \end{enumerate} \end{lemma} \begin{proof} Since $p^b-1$ divides $q^b-1$, $\F_{q^b}$ is a splitting field of the $x^{p^b}-x$, that is, $x^{p^b}-x$ linearly factorizes over $\F_{q^b}$. Now, one can show that the roots of $x^{p^b}-x$ over $\F_{q^b}$ form a subfield of size $p^b$. Now, using \cite[Theorem 3.2]{Shoup90}, we can compute a degree $b$ irreducible polynomial $u(Z)$ over $\F_p$ in $\poly(b,p)$ $\F_p$-operations. Next, applying \cite{Berlekamp70}, we can find a root $\beta\in \F_{q^b}$ for $u(Z)$ in $\poly(a,b,p)$ $\F_q$-operations. One can show that for any other polynomial $u'(Z)$ with $u'(\beta)=0$, $u(Z)$ divides $u'(Z)$. Also, $\beta$ is in $\F_{p^b}$ since $\F_{p^b}$ is a splitting field for $u(Z)$. This implies that $\{1,\beta,\ldots,\beta^{b-1}\}$ forms an $\F_p$-basis for $\F_{p^b}$. Thus, after having $\beta$, we can compute all the elements of $\F_{p^b}$ by taking all possible $\F_p$-linear combinations of $\{1,\beta,\ldots,\beta^{b-1}\}$. The cost of doing this is $p^b\cdot\poly(b,p)$ $\F_q$-operations. Computing $\beta$ takes $\poly(a,b,p)$ $\F_q$-operations. Therefore, in $p^b\cdot \poly(a,b,p)$ $\F_q$-operations, we can compute all the elements of $\F_{p^b}$. Let $\alpha\in \F_{p^b}$. Since $\F_{p^b}$ is a subfield of $\F_{q^b}$, from the representation of $\F_{q^b}$, we can write $\alpha=\alpha_0+\alpha_1Y+\cdots+\alpha_{b-1}Y^{b-1}$ where $\alpha_i\in\F_q$. Also, for all $i\in\{0,1,\ldots, b-1\}$, each $\beta^i$ can be written as $\beta_{i,0}+\beta_{i,1}Y+\cdots+\beta_{i, b-1}Y^{b-1}$ where $\beta_{i,j}\in\F_q$. Let $\alpha=c_0+c_1\beta+\cdots+c_{b-1}\beta^{b-1}$, where $c_i$'s are unknown and we want to find them. This combined with the representation of $\alpha$ and $\beta^i$, we get a system of linear equations in $\{c_0,\ldots, c_{b-1}\}$ over $\F_q$. Now we can solve it in $\poly(b)$ $\F_q$-operations and get $c_i$'s. \end{proof} \subsection{Hasse derivatives} In this section, we briefly discuss the notion of Hasse derivatives that plays a crucial role in our results. \begin{definition}[Hasse derivative] \label{def:hasse-derivative} Let $f(\var x)$ be an $n$-variate polynomial over a field $\F$. Let $\var e=(e_1,\ldots, e_n)\in\N^n$. Then, the Hasse derivative of $f$ with respect to the monomial $\var x^{\var e}$ is the coefficient of $\vecz^{\vece}$ in the polynomial $f(\vecx + \vecz) \in (\F[\vecx])[\vecz]$. \end{definition} \paragraph*{Notations.} Suppose that $f(\var x)$ be an $n$-variate polynomial over a field $\F$. Let $\var b\in \N^n$. Then, $\overline{\partial}_{\var b}(f)$ denotes the Hasse derivative of $f(\var x)$ with respect to the monomial $\var x^{\var b}$. For any non-negative integer $k$, $\overline{\partial}^{\leq k}(f)$ is defined as \[ \overline{\partial}^{\leq k}(f) = \left\{ \overline{\partial}_{\var b}(f)\,\mid\,\var b\in\N^n \text{ s.t. }|\var b|_1\leq k \right\} , \] and $ \overline{\partial}^{< k}(f)$ denotes the set $\{\overline{\partial}_{\var b}(f)\,\mid\,\var b\in\N^n \text{ s.t. } |\var b|_1< k\}$. For a univariate polynomial $h(t)$ over $\F$ and a non-negative integer $k$, $\der{h}{k}(t)$ denotes the Hasse derivative of $h(t)$ with respect to the monomial $t^k$, that is, $\operatorname{Coeff}_{Z^k}(h(t+Z))$. Next, we mention some useful properties of Hasse derivatives. \begin{proposition} \label{lem:hasse-derivative-property} Let $f(\var x)$ be an $n$-variate polynomial over $\F$. Let $\var a,\var b\in\N^n$. Then, \begin{enumerate} \item $\overline{\partial}_{\var a}(f)=\sum_{\var e\in\N^n}\binom{\var e}{\var a}\operatorname{Coeff}_{\var x^{\var e}}(f)\var x^{\var e-\var a}$. \item $\overline{\partial}_{\var a}\overline{\partial}_{\var b}(f)=\binom{\var a+\var b}{\var a,\var b}\overline{\partial}_{\var a+\var b}(f).$ \end{enumerate} \end{proposition} For proof one can see \cite[Appendix C]{F14}. The following lemma describes the cost of computing Hasse derivatives. \begin{lemma} \label{lem:computing-hasse-derivation} Let $p$ be a prime and $q=p^a$ for some positive integer $a$. Let $f(\var x)$ be an $n$-variate polynomial over $\F_q$ with individual degree less than $d$. Let $\var b=(b_1,\ldots,b_n)\in\N^n$. Then, given $f(\var x)$ and $\var b$ as input, Algorithm \ref{algo:computing-hasse-derivative} outputs $\overline{\partial}_{\var b}(f)$ in $$d^n\cdot\poly(n)+\poly(b,d)$$ $\F_q$-operations, where $b=\max_{i\in[n]}\, b_i$. \end{lemma} \begin{proof} We first describe the algorithm and then argue about its correctness and running time. \begin{algorithm}[H] \caption{Computing Hasse derivative} \label{algo:computing-hasse-derivative} \textbf{Input:} An $n$-variate polynomial $f(\var x)\in\F_q[\var x]$ with individual degree less than $d$ and $\var b=(b_1,\ldots,b_n)\in\N^n$.\\ \textbf{Output:} $\overline{\partial}_{\var b}(f)$.\\ \begin{algorithmic}[1] \State Let $b$ be $\max_{i\in [n]}\, b_i$. \State Let $D$ be an $(b+1)\times d$ array. \For{$j\leftarrow 0$ to $d-1$} \For{$i\leftarrow 0$ to $b$} \If{$i=j$} \State $D_{i,j}\leftarrow 1$. \ElsIf{$i>j$} \State $D_{i,j}\leftarrow 0$. \ElsIf{$i=0$} \State $D_{0,j}\leftarrow 1$. \Else \State $D_{i,j}=D_{i-1, j-1}+D_{i,j-1}$ \EndIf \EndFor \EndFor \For{$\var e\in\{0,1,\ldots,d-1\}^n$} \State Let $\var e=(e_1,\ldots, e_n)$. \State $c_{\var e}\leftarrow \operatorname{Coeff}_{\var x^{\var e}}(f)\cdot\prod_{i=1}^n D_{b_i,e_i}$. \EndFor \State Output $\sum_{\var e\in\{0,1,\ldots, d-1\}^n}c_{\var e}\var x^{\var e-\var b}$. \end{algorithmic} \end{algorithm} In Algorithm \autoref{algo:computing-hasse-derivative}, for all $i\in\{0,1,\ldots,b\}$ and $j\in\{0,1,\ldots,d-1\}$, the $(i,j)$th entry of array $D$ $$D_{i,j}=\binom{j}{i}\, \mathrm{mod}\, p.$$ For this, we note that the arithmetic in Line 15 of the algorithm is happening over the underlying field $\F_q$. This combined with \autoref{lem:hasse-derivative-property} implies that the Algorithm \autoref{algo:computing-hasse-derivative} computes $\overline{\partial}_{\var b}(f)$. To compute the array $D$, we are performing $d(b+1)$ $\F_p$-operations. Computing all $c_{\var e}$'s for $\var e\in\{0,1,\ldots,d-1\}^n$ takes $d^n\cdot (n+1)$ $\F_q$-operations. Therefore, Algorithm \autoref{algo:computing-hasse-derivative} runs in our desired time complexity. \end{proof} \subsection{Univariate polynomial evaluation and interpolation} The two simplest but most important ways of representing an univariate polynomial of degree less than $d$ are either by giving the list of its coefficients, or by giving its evaluations at $d$ distinct points. In this section, we discuss about the cost of changing between these two representations. First, we mention the cost of polynomial evaluation, that is, going from the list of coefficients to the list of evaluations. \begin{lemma}[Evaluation] \label{lem:univariate-evaluation} Let $f(x)$ be a degree $d$ polynomial over $\F$. Let $\alpha_1,\alpha_2,\ldots,\alpha_N$ be $N$ distinct elements from $\F$. Then, $f(\alpha_i)$ for all $i\in[N]$ can be computed in $O(Nd)$ $\F$-operations. \end{lemma} For each $i\in[N]$, using Horner's rule, one can compute $f(\alpha_i)$ with $d-1$ additions and $d-1$ multiplications over $\F$. Therefore, the total cost of computing $f(\alpha_i)$ for all $i\in[N]$ is $O(Nd)$ operations. For more details see \cite[Section 5.2]{GG03}. Next, we discuss the cost of polynomial interpolation where we go from the list of evaluations to the list of coefficients. \begin{lemma}[Interpolation] \label{lem:univariate-interpolation} Let $f(x)$ be a degree $d$ polynomial over $\F$. Let $\alpha_0,\alpha_1,\ldots,\alpha_d$ be $(d+1)$ distinct elements from $\F$. Let $\beta_i=f(\alpha_i)$ for all $i\in\{0,1,\ldots, d\}$. Then, given $(\alpha_i,\beta_i)$ for all $i\in\{0,1,\ldots, d\}$, $f(x)$ can be computed in $O(d^2)$ $\F$-operations. \end{lemma} For proof see \cite[Section 5.2]{GG03}. The following lemma gives a stronger version of univariate polynomial interpolation, known as Hermite interpolation. Here, the number of evaluation points can be less than $d$, but evaluations of Hasse derivatives of the polynomial up to certain order is available. \begin{lemma}[Hermite interpolation] \label{lem:hermitian-interpolation} Let $f(x)$ be a degree $d$ univariate polynomial over a field $\F$ and $e_1,\ldots, e_m$ be $m$ positive integers such that $e_1+\cdots+e_m$ is greater than $d$. Let $\alpha_1,\ldots, \alpha_m$ be $m$ distinct elements from $\F$. For all $i\in[m]$ and $j\in[e_j]$, let $\der{f}{j-1}(\alpha_i)=\beta_{ij}$. Then given $(\alpha_i,j,\beta_{ij})$ for all $i\in[m]$ and $j\in[e_j]$, $f(x)$ can be computed in $O(d^2)$ $\F$-operations. \end{lemma} For proof see \cite[Section 5.6]{GG03}. We also remark that while there are nearly linear time algorithms for all of the above operations (multipoint evaluation, interpolation and Hermite interpolation) based on the Fast Fourier transform; however, for our applications in this paper, the above stated more naive bounds suffice. \subsection{Multidimensional Fast Fourier transform} We crucially rely on the following lemma that says that there is a fast algorithm for evaluating an $n$-variate polynomial $f$ with coefficients in a finite field $\F$ on the set $\tilde{\F}^{n}$ where $\tilde{\F}$ is a subfield of $\F$. The proof is based on a simple induction on the number of variables and uses the standard FFT one variable at a time. For the proof, see Theorem $4.1$ in \cite{Kedlaya11}. \begin{lemma}\label{lem: multidim FFT} Let $\F$ be a finite field and let $\tilde{\F}$ be a subfield of $\F$. Then, there is a deterministic algorithm that takes as input an $n$-variate polynomial $f \in \F[\vecx]$ of degree at most $d-1$ in each variable as a list of coefficients, and in at most $(d^n + |\tilde{\F}|^n)\cdot \poly(n, d, \log |\F|)$ operations over the field $\F$, it outputs the evaluation of $f$ for all $\pmb\alpha \in \tilde{\F}^n$. \end{lemma} \section{A simple algorithm for multipoint evaluation}\label{sec: mme algo simple} We start with our first and simplest algorithm for {multipoint evaluation }. The algorithm gives an inferior time complexity to what is claimed in \autoref{thm:mme informal}, but contains some of the main ideas. Subsequently, in \autoref{sec: mme algo large n} and \autoref{sec: mme large fields}, we build upon this algorithm to eventually prove \autoref{thm:mme informal}. Our main theorem for this section is the following. \begin{theorem} \label{thm:polynomial-evaluation-v1} Let $p$ be a prime and $q=p^a$ for some positive integer $a$. There is a deterministic algorithm such that on input an $n$-variate polynomial $f(\var x)$ over $\F_q$ with individual degree less than $d$ and points $\pmb\alpha_1,\pmb\alpha_2,\ldots, \pmb\alpha_N$ from $\F_q^n$, it outputs $f(\pmb\alpha_i)$ for all $i\in[N]$ in time $$(N+(adnp)^n)\cdot\poly(a,d,n,p) \, .$$ \end{theorem} \subsection{A description of the algorithm We start with a description of the algorithm, followed by its analysis. We recall again that through all the algorithms in this and subsequent sections, we assume that the underlying field $\F_q$ is given to us via an irreducible polynomial of appropriate degree over the prime subfield. Moreover, from \autoref{lem:extracting coefficients in field representation}, we also assume without loss of generality that for every input field element, we have access to its representation as a polynomial of appropriate degree over the prime subfield. For a polynomial map $\vecg(t) = (g_1(t), g_2(t), \ldots, g_n(t))$ and an $n$-variate polynomial $f$, we use $f(\vecg(t))$ to denote the univariate polynomial $f(g_1(t), g_2(t), \ldots, g_n(t))$. \begin{algorithm}[H] \caption{Efficient Multivariate Multipoint Evaluation} \label{algo:polynomial-evaluation-v1} \textbf{Input:} An $n$-variate polynomial $f(\var x)\in\F_q[\var x]$ with individual degree less than $d$ and $N$ distinct points $\pmb\alpha_1,\pmb\alpha_2,\ldots,\pmb\alpha_N$ from $\F_q^n$.\\ \textbf{Output:} $f(\pmb\alpha_1),f(\pmb\alpha_2),\ldots,f(\pmb\alpha_N)$.\\ \begin{algorithmic}[1] \State Let $p$ be the characteristic of $\F_q$ and $q=p^a$. \State Let $v_0(Y_0)$ be an irreducible polynomial in $\F_p[Y_0]$ of degree $a$ and $$\F_{q}=\F_p[Y_0]/\ideal{v_0(Y_0)}.$$ \State Let $b$ be the smallest integer such that $p^b>adn$. \State Compute an irreducible polynomial $v_1(Y_1)$ in $\F_q[Y_1]$ of degree $b$ and $$\F_{q^b}=\F_q[Y_1]/\ideal{v_1(Y_1)}.\text{ (\autoref{lem:finite-field-construction})}$$ \State Compute the subfield $\F_{p^b}$ of $\F_{q^b}$. (\autoref{lem:subfield-construction}) \State Evaluate $f(\var x)$ over the grid $\F_{p^b}^n$. (\autoref{lem: multidim FFT}) \For{all $i\in[N]$} \State Let $\pmb\alpha_i=\pmb\alpha_{i,0}+\pmb\alpha_{i,1}Y_0+\cdots+\pmb\alpha_{i,a-1}Y_0^{a-1}$, where $\pmb\alpha_{i,j}\in \F_{p}^n$. \State Let $\var g_{i}(t)$ be the curve defined as $\pmb\alpha_{i,0}+\pmb\alpha_{i,1}t+\cdots+\pmb\alpha_{i,a-1}t^{a-1}.$ \State Compute the set $P_i=\{(\gamma,\var g_i(\gamma)) \,\mid\, \gamma\in\F_{p^b}\}$. (\autoref{lem:univariate-evaluation}) \State Compute the set $E_i=\{(\gamma, f(\pmb\gamma'))\,\mid\, (\gamma,\pmb\gamma')\in P_i\}$ from the evaluations of $f(\var x)$ over $\F_{p^b}^n$. \State Let $h_i(t)$ be the univariate polynomial defined as $f(\var g_{i}(t))$. \State Using $E_{i}$, interpolate $h_{i}(t)$. (\autoref{lem:univariate-interpolation}) \State Output $h_{i}(Y_0)$ as $f(\pmb\alpha_i)$. (\autoref{lem:univariate-evaluation}) \EndFor \end{algorithmic} \end{algorithm} \subsection{Analysis of Algorithm \autoref{algo:polynomial-evaluation-v1}} \begin{proof}[Proof of \autoref{thm:polynomial-evaluation-v1}] We start with the proof of correctness of the algorithm. \paragraph*{Correctness of Algorithm \autoref{algo:polynomial-evaluation-v1}. } We show that Algorithm \autoref{algo:polynomial-evaluation-v1} computes $f(\pmb\alpha_i)$ for all $i\in[N]$ in $(N+(adnp)^n) \cdot \poly(a,d,n,p)$ many $\F_q$ operations. We assume that the underlying field $\F_q$ is represented as $\F_{p}[Y_0]/\ideal{v_0(Y_0)}$, where $v_0(Y_0)$ is a degree $a$ irreducible polynomial over $\F_p$. From \autoref{lem:finite-field-construction}, the field $\F_{q^b}$ can be constructed as $\F_q[Y_1]/\ideal{v_1(Y_1)}$ for some degree $b$ irreducible polynomial $v_1(Y_1)$ over $\F_q$. \autoref{lem:subfield-construction} ensures that we can explicitly compute all the elements of the subfield $\F_{p^b}$ (of $\F_{q^b}$). The representation of $\F_q$ ensures that every element $\beta\in\F_q$ is of the form $\beta_0+\beta_1Y_0+\cdots+\beta_{a-1}Y_0^{a-1}$, where $\beta_i\in\F_p$. Therefore, for all $i\in[N]$, $\pmb\alpha_i$ is of the form $\pmb\alpha_{i,0}+\pmb\alpha_{i,1}Y_0+\cdots+\pmb\alpha_{i,a-1}Y_0^{a-1}$, where $\pmb\alpha_{i,j}\in\F_p^n$. For all $i\in[N]$, the curve $\var g_i(t)$ is defined as $\pmb\alpha_{i,0}+\pmb\alpha_{i,1}t+\cdots+\pmb\alpha_{i,a-1}t^{a-1}$. Since $f$ is an $n$-variate polynomial over $\F_q$ with individual degree less than $d$, for all $i\in[N]$, the polynomial $h_i(t)=f(\var g_i(t))$ is a polynomial in $t$ of degree less than $adn$. For all $\gamma\in\F_{p^b}$, $\var g_i(\gamma)$ is in $\F_{p^b}^n$. Therefore, from the evaluations of $f(\var x)$ over the grid $\F_{p^b}^n$, we get the set $E_i=\{(\gamma,h_i(\gamma)\,\mid\, \gamma\in\F_{p^b}\}$. Since the degree of $h_i$ is less than $adn$ and $p^b$ is greater than $adn$, from the set $E_i$, we can interpolate $h_i(t)$. The construction of $\var g_i(t)$ ensures that $\var g_i(Y_0)=\pmb\alpha_i$. Hence, $h_i(Y_0)=f(\pmb\alpha_i)$ for all $i\in[N]$. \paragraph*{Time complexity of Algorithm \autoref{algo:polynomial-evaluation-v1}. }Now we discuss the time complexity of Algorithm \autoref{algo:polynomial-evaluation-v1}. From \autoref{lem:finite-field-construction}, the field $\F_{q^b}$ can be constructed as $\F_q[Y_1]/\ideal{v_1(Y_1)}$ for some degree $b$ irreducible polynomial $v_1(Y_1)$ over $\F_q$ in $\poly(a,b,p)$ many $\F_{q}$-operations. Also, all the basic operations in the field $\F_{q^b}=\F_q[Y_1]/\ideal{v_1(Y_1)}$ can be done using $\poly(b)$ $\F_q$-operations. Applying \autoref{lem:subfield-construction}, the cost of computing all the elements of the subfield $\F_{p^b}$ (of $\F_{q^b}$) is $p^b\cdot \poly(a,b, p)$ $\F_q$-operations. Using \autoref{lem: multidim FFT}, we can evaluate $f(\var x)$ over the grid $\F_{p^b}^n$ in $$(d^n+p^{bn})\cdot\poly(a,b,d, n, p)$$ $\F_q$-operations. For all $i\in[N]$, using \autoref{lem:univariate-evaluation}, the cost of computing the set $P_i=\{(\gamma,\var g_i(\gamma))\,\mid\, \gamma\in\F_{p^b}\}$ is $p^b\cdot\poly(a,b,n)$ $\F_{q}$-operations. Using the set $E_i$, \autoref{lem:univariate-interpolation} ensures that $h_i(t)$ can be interpolated using $\poly(a,b,d,n)$ $\F_q$-operations. Finally, $h(Y_0)$ can be computed in $\poly(a,d,n)$ many $\F_q$-operations. Since $adn<p^b\leq adnp$, the above discussion implies that that Algorithm \ref{algo:polynomial-evaluation-v1} performs $$(N+(adnp)^n)\cdot \poly(a,d,n,p)$$ $\F_q$-operations. \end{proof} \section{Multipoint evaluation for large number of variables} \label{sec: mme algo large n} In this section, we append the overall structure of Algorithm \autoref{algo:polynomial-evaluation-v1} with some more ideas to improve the dependence of the running time on $n$. In particular, the goal is to reduce the $n^n$ factor in the running time of \autoref{thm:polynomial-evaluation-v1} to a factor of the form $\exp(O(n))$. The main result of this section is the following theorem. \begin{theorem} \label{thm:polynomial-evaluation-v2} Let $p$ be a prime and $q=p^a$ for some positive integer $a$. There is a deterministic algorithm such that on input an $n$-variate polynomial $f(\var x)$ over $\F_q$ with individual degree less than $d$ and points $\pmb\alpha_1,\pmb\alpha_2,\ldots, \pmb\alpha_N$ from $\F_q^n$, it outputs $f(\pmb\alpha_i)$ for all $i\in[N]$ in time $$(N+(adp)^n)\cdot 4^n \cdot \poly(a,d,n,p). \,$$ \end{theorem} A useful additional ingredient in the proof of this theorem is the following lemma. Semantically, this is an explicit form of the chain rule of Hasse derivatives for the restriction of a multivariate polynomial to a curve of low degree. \begin{lemma} \label{lem:hasse-derivative} Let $f(\var x)$ be an $n$-variate degree $d$ polynomial over a field $\F$, $\var g(t)=(g_1,\ldots, g_n)$ where $g_i\in\F[t]$, and $h(t)=f(\var g(t))$. For all $i\in[n]$, let $g_i(t+Z)=g_i(t)+Z\tilde g_i(t, Z)$ for some $\tilde{g_i} \in \F[t, Z]$. Let $\tilde{\var g}(t,Z)=(\tilde g_1,\ldots, \tilde g_n)$, and for all $\var e=(e_1,\ldots,e_n)\in\N^n$, $\tilde{\var g}_{\var e}=\prod_{i=1}^n\tilde g_i^{e_i}$. For any $\ell\in \N$, let $$h_{\ell}(t,Z)=\sum_{i=0}^\ell Z^i\sum_{\var e\in\N^n:|\var e|_1=i}\overline{\partial}_{\var e}(f)(\var g(t))\cdot\tilde{\var g}_{\var e}(t,Z).$$ Then, for every $k\in\N$ with $k\leq \ell$, $\der{h}{k}(t)=\operatorname{Coeff}_{Z^k}(h_\ell)$. \end{lemma} \begin{proof} By the definition of Hasse derivative, $\der{h}{k}(t)= \operatorname{Coeff}_{Z^k}(h(t+Z))$. On the other hand, \begin{align*} h(t+Z) &= f(g_1(t+Z),\ldots, g_n(t+Z))\\ &=f(g_1+Z\tilde g_1,\ldots, g_n+Z\tilde g_n). \end{align*} Applying Taylor's expansion on $f(g_1+Z\tilde g_1,\ldots, g_n+Z\tilde g_n)$, we get that \begin{align*} h(t+Z) &= \sum_{i=0}^dZ^i\sum_{\var e\in\N^n:|\var e|_1=i}\overline{\partial}_{\var e}(f)(\var g(t))\cdot \tilde{\var g}_{\var e}\\ &=h_{\ell}+ \sum_{i=\ell+1}^dZ^{i}\sum_{\var e\in\N^n: |\var e|_1=i}\overline{\partial}_{\var e}(f)(\var g(t))\cdot\tilde{\var g}_{\var e}. \end{align*} The lowest possible degree of $Z$ in the second part of the above sum is greater than $\ell$. Therefore, the coefficient of $Z^k$ in the second part is zero since $k\leq \ell$. Hence, $$\der{h}{k}(t)= \operatorname{Coeff}_{Z^k}(h(t+Z))=\operatorname{Coeff}_{Z^k}(h_{\ell}(t,Z)),$$ which completes the proof. \end{proof} \subsection{A description of the algorithm We start by describing the algorithm, followed by its analysis. \begin{algorithm}[H] \caption{Efficient multivariate polynomial evaluation with large number of variables} \label{algo:polynomial-evaluation-v2} \textbf{Input:} An $n$-variate polynomial $f(\var x)\in\F_q[\var x]$ with individual degree less than $d$ and $N$ points $\pmb\alpha_1,\pmb\alpha_2,\ldots,\pmb\alpha_N$ from $\F_q^n$.\\ \textbf{Output:} $f(\pmb\alpha_1),f(\pmb\alpha_2),\ldots,f(\pmb\alpha_N)$.\\ \begin{algorithmic}[1] \State Let $p$ be the characteristic of $\F_q$ and $q=p^a$. \State Let $v_0(Y_0)$ be an irreducible polynomial in $\F_p[Y_0]$ of degree $a$ and $$\F_q=\F_p[Y_0]/\ideal{v_0(Y_0)}.$$ \State Let $b$ the smallest positive integer such that $p^b>ad$. \State Compute an irreducible polynomial $v_1(Y_1)$ in $\F_q[Y_1]$ of degree $b$ and $$\F_{q^b}=\F_q[Y_1]/\ideal{v_1(Y_1)}. \text{ (\autoref{lem:finite-field-construction})}$$ \State Compute the subfield $\F_{p^b}$ of $\F_{q^b}$. (\autoref{lem:subfield-construction}) \State Compute the set $\overline{\partial}^{<n}(f)$. (\autoref{lem:computing-hasse-derivation}) \State Evaluate all the polynomials in $\overline{\partial}^{<n}(f)$ over the grid $\F_{p^b}^n$. (\autoref{lem: multidim FFT}) \For{all $i\in[N]$}\label{step:algo-v2-forloop} \State Let $\pmb\alpha_i=\pmb\alpha_{i,0}+\pmb\alpha_{i,1}Y_0+\cdots+\pmb\alpha_{i,a-1}Y_0^{a-1}$, where $\pmb\alpha_{i,j}\in \F_{p}^n$. \State Let $\var g_{i}(t)$ be the curve defined as $\pmb\alpha_{i,0}+\pmb\alpha_{i,1}t+\cdots+\pmb\alpha_{i,a-1}t^{a-1}$. \State Let $h_i(t)=f(\var g_i(t))$. \State Let $E_i=\{(\gamma,\der{h_i}{0}(\gamma), \der{h_i}{1}(\gamma),\ldots, \der{h_i}{n-1}(\gamma)\,\mid\, \gamma\in\F_{p^b}\}$. \State Invoke the function \textsc{Evaluate Derivatives A } with input $\var g_i(t)$ and compute the set $E_i$. \State Using $E_i$, interpolate $h_i(t)$. (\autoref{lem:hermitian-interpolation})\label{label:v2-interpolate} \State Output $h_i(Y_0)$ as $f(\pmb\alpha_i)$. (\autoref{lem:univariate-evaluation}) \EndFor \Statex \end{algorithmic} \end{algorithm} We now describe the function Evaluate Derivatives A invoked above. We follow the same notation as in Algorithm \autoref{algo:polynomial-evaluation-v2} including the local variable names. \begin{algorithm}[H] \caption{Function to generate data for Hermite Interpolation} \label{algo:polynomial-evaluation-v2-eval-derivatives} \begin{algorithmic}[1] \Function{Evaluate Derivatives A }{$\var g(t)$} \State Let $\var g(t)=(g_1,\ldots, g_n)$. \State For all $i\in[n]$, let $g_i(t+Z)=g_i(t)+Z\tilde g_i(t,Z)$ and $\tilde{\var g}(t,Z)=(\tilde g_1(t,Z),\ldots, \tilde g_n(t,Z))$. \State Compute $\tilde g_i(t,Z)$ for all $i\in[n]$. (\autoref{lem:computing-hasse-derivation}) \State For all $\var e=(e_1,\ldots, e_n)\in\N^n$, let $\tilde{\var g}_{\var e}=\prod_{i=1}^n\tilde g_i^{e_i}$. \State Compute the set of polynomials $\{\tilde{\var g}_{\var e}(t,Z)\,\mid\,|\var e|_1<n\}$. (Polynomial multiplication) \State $P\leftarrow \emptyset$. \For{all $\gamma \in\F_{p^b}$}\label{label:algo-v2-function-forloop} \State Using evaluations of polynomials in $\overline{\partial}^{<n}(f)$ over $\F_{p^b}^n$, compute the polynomial $$h_\gamma(Z)=\sum_{i=0}^{n-1}Z^i\sum_{\var e\in\N^n:|e|_1=i}\overline{\partial}_{\var e}(f)(\var g(\gamma))\tilde{\var g}_{\var e}(\gamma, Z).$$\label{label:algo-v2-polynomial} \State For all $i\in\{0,1,\ldots, n-1\}$, extract $\operatorname{Coeff}_{Z^{i}}(h_{\gamma})$. \State $P\leftarrow P\cup\{(\gamma, \operatorname{Coeff}_{Z^0}(h_\gamma),\operatorname{Coeff}_{Z^1}(h_\gamma),\ldots, \operatorname{Coeff}_{Z^{n-1}}(h_\gamma))\}$. \EndFor \State \Return $P$. \EndFunction \end{algorithmic} \end{algorithm} \subsection{Analysis of Algorithm \autoref{algo:polynomial-evaluation-v2}} \begin{proof}[Proof of \autoref{thm:polynomial-evaluation-v2}] We start with the proof of correctness. \paragraph*{Correctness of Algorithm \autoref{algo:polynomial-evaluation-v2}. } We show that Algorithm \autoref{algo:polynomial-evaluation-v2} computes $f(\pmb\alpha_i)$ for all $i\in[N]$ in the desired time. Like Algorithm \autoref{algo:polynomial-evaluation-v1}, we assume that the underlying field $\F_{q}$ is represented as $\F_{p}[Y_0]/\ideal{v_0(Y_0)}$ for some degree $a$ irreducible polynomial $v_0(Y_0)$ over $\F_p$. However, unlike Algorithm \autoref{algo:polynomial-evaluation-v2}, here we pick $b$ as the smallest positive integer satisfying $p^b>ad$. Like Algorithm \autoref{algo:polynomial-evaluation-v1}, here also we construct a degree $b$ extension $\F_{q^b}$ over $\F_q$ and compute all the elements of the subfield $\F_{p^b}$ (of $\F_{q^b}$). \autoref{lem:finite-field-construction} ensures that we can construct $\F_{q^b}$ as $\F_q[Y_1]/\ideal{v_1(Y_1)}$ for some degree $b$ irreducible polynomial over $\F_q$ and from \autoref{lem:subfield-construction}, we can compute $\F_{p^b}$. The crucial difference with Algorithm \autoref{algo:polynomial-evaluation-v1} is the way we interpolate the polynomial $h_i(t)$ in Line $14$ of Algorithm \autoref{algo:polynomial-evaluation-v2}. The field $\F_{p^b}$ may have much smaller number of points than the degree of $h_i(t)$. Therefore, to interpolate $h_i(t)$, we have to evaluate all the Hasse derivatives of $h_i(t)$ up to order $n-1$ at points in $\F_{p^b}$. Next we describe the correctness of Algorithm \autoref{algo:polynomial-evaluation-v2} in detail. As mentioned in the proof of \autoref{thm:polynomial-evaluation-v1}, the representation of $\F_{q}$ ensures that each $\pmb\alpha_i$ is of form $\pmb\alpha_{i,0}+\pmb\alpha_{i,1}Y_0+\cdots+\pmb\alpha_{i, a-1}Y_0^{a-1}$ where $\pmb\alpha_{i,j}$ is in $\F_p^n$. Therefore, $h_i(t)=f(\var g_i(t))$ is a polynomial of degree less than $adn$ since $f$ is an $n$-variate polynomial with individual degree less than $d$. This implies that, like Algorithm \ref{algo:polynomial-evaluation-v1}, we can interpolate the $h_i(t)$ by evaluating it at $adn$ many distinct points. However, for the choice of $b$ in this algorithm, we don't have $adn$ elements. So, for all $\gamma\in\F_{p^b}$, we compute the evaluations at $\gamma$ of all Hasse derivatives of $h_i$ up to order $n-1$ and invoke \autoref{lem:hermitian-interpolation} with this data to recover $h_i$. From \autoref{lem:hasse-derivative}, using the evaluations of $\overline{\partial}^{<n}(f)$ over the grid $\F_{p^b}^n$, the function \textsc{Evaluate Derivatives A} of Algorithm \ref{algo:polynomial-evaluation-v2-eval-derivatives} computes the set $E_i$ consisting of $n${th} order derivative information of $h_i$ for every $\gamma \in \F_{p^b}$. Given this set $E_i$, we invoke \autoref{lem:hermitian-interpolation} to successfully interpolate $h_i(t)$ and output $f(\pmb\alpha_i)=h_i(Y_0)$ for all $i\in[N]$. \paragraph*{Time complexity of Algorithm \autoref{algo:polynomial-evaluation-v2}.} We now describe the time complexity of Algorithm \ref{algo:polynomial-evaluation-v2}. Similar to Algorithm \ref{algo:polynomial-evaluation-v1}, using \autoref{lem:finite-field-construction}, the construction of $\F_{q^b}$ takes $\poly(a,b,p)$ $\F_q$-operations and its basic operations can be done in $\poly(b)$ $\F_{q}$-operations. From \autoref{lem:subfield-construction}, all the elements of $\F_{p^b}$ can be computed in $p^b\cdot \poly(a,b,p)$ $\F_q$-operations. Since $\binom{n+n-1}{n}$ is upper bounded by $4^n$, applying \autoref{lem:computing-hasse-derivation}, the set of polynomials $\overline{\partial}^{<n}(f)$ can be computed in $(4d)^n\cdot \poly(d,n)$ $\F_q$-operations. Hence, from \autoref{lem: multidim FFT}, computing all the polynomials in $\overline{\partial}^{<n}(f)$ over the grid $\F_{p^b}^n$ requires $$(d^n+p^{bn})\cdot 4^n\cdot\poly(a,b,d,n,p)$$ $\F_q$-operations. Next we discuss the time taken by the \emph{for} loop in Algorithm \ref{algo:polynomial-evaluation-v2} at Line $8$. First we estimate the cost of each iteration of the loop. For that, we need to analyze the complexity of the function \textsc{Evaluate Derivatives A}. The input $\var g(t)=(g_1,\ldots, g_n)$ to \textsc{Evaluate Derivatives A} is a curve of degree at most $a-1$. Using \autoref{lem:computing-hasse-derivation}, $\tilde{\var g}(t,Z)=(\tilde g_1,\ldots, \tilde g_n)$ can be computed in $\poly(a,n)$ $\F_q$-operations. Thus, the total cost of computing the set $\{ \tilde{\var g}_{\var e}(t,Z)\,\mid\, |\var e|_1<n\}$ is $4^n\cdot \poly(a,n)$ $\F_q$-operations. Given $\gamma\in\F_{p^b}$, we can evaluate $\tilde{\var g}_{\var e}(t,Z)$ at $t=\gamma$ in $\poly(a,b,n)$ $\F_q$-operations. Thus, for each $\gamma\in\F_{p^b}$, the polynomial $h_{\gamma}(Z)$ at Line $9$ in Algorithm \ref{algo:polynomial-evaluation-v2-eval-derivatives} can be computed at the cost of $4^n\cdot \poly(a,b,n)$ $\F_q$-operations. After computing $h_{\gamma}(Z)$ as its list of coefficients, we collect the coefficients of $Z^i$ of $h_{\gamma}(Z)$ for $i\in\{0,1,\ldots, n-1\}$. This implies that each call of the function \textsc{Evaluate Derivatives A} performs $4^n\cdot p^b\cdot \poly(a,b,n)$ $\F_q$-operations. Now we return to analyzing the cost taken by each iteration of the \emph{for} loop at Line $8$ in Algorithm \autoref{algo:polynomial-evaluation-v2}. From the above discussion, for each $i\in[N]$, the set $E_i$ can be computed in $4^n\cdot p^b\cdot \poly(a,b,n)$ $\F_q$-operations. Given $E_i$, applying \autoref{lem:hermitian-interpolation}, the interpolation of $h_i(t)$ requires $\poly(a, b, d,n)$ operations in $\F_q$. Thus, each iteration of the \emph{for} loop at Line $8$ in Algorithm \autoref{algo:polynomial-evaluation-v2} takes $4^n\cdot p^b\cdot \poly(a,b,d,n)$ $\F_q$-operations. Therefore, the total cost of the \emph{for} loop is $$N\cdot 4^n\cdot p^b\cdot \poly(a,b,d,n)$$ $\F_q$-operations. Since $ad<p^b\leq adp$, combining the complexities of all the components, we get that Algorithm \autoref{algo:polynomial-evaluation-v2} performs $$(N+(adp)^n)\cdot 4^n\cdot \poly(a,d,n,p)$$ $\F_q$-operations \end{proof} \section{Multipoint evaluation with improved field dependence} \label{sec: mme large fields} In this section, we build on the ideas in Algorithm \autoref{thm:polynomial-evaluation-v2} to improve the dependence on the field size. Our main theorem, which is a formal statement of our main result \autoref{thm:mme informal} stated in the introduction. \begin{theorem} \label{thm:polynomial-evaluation-v4} Let $p$ be a prime and $q=p^a$ for some positive integer $a$. There is a deterministic algorithm such that on input an $n$-variate polynomial $f(\var x)$ over $\F_q$ with individual degree less than $d$, points $\pmb\alpha_1,\pmb\alpha_2,\ldots, \pmb\alpha_N$ from $\F_q^n$ and a non-negative integer $\ell\leq\log^\star_p(a)$, it outputs $f(\pmb\alpha_i)$ for all $i\in[N]$ in time $$\left(N\cdot\left(2dp\log_p(dp)\right)^\ell+\left(2rdp\log_p(dp)\right)^n\right)\cdot O(\ell+1)^n\cdot \poly(a,d,n,p) \, ,$$ where $r=\max\{2, \log^{\circ\ell}_p(a)\}$. \end{theorem} \subsection{A description of the algorithm We start by describing the algorithm, followed by its analysis. \begin{algorithm}[H] \caption{Efficient multivariate polynomial evaluation over large fields} \label{algo:polynomial-evaluation-v4} \textbf{Input:} An $n$-variate polynomial $f(\var x)\in\F_q[\var x]$ with individual degree less than $d$, $N$ points $\pmb\alpha_1,\pmb\alpha_2,\ldots,\pmb\alpha_N$ from $\F_q^n$, and a non-negative integer $\ell\leq \log_p^\star(a)$ where $q=p^a$ and $p$ is the characteristic of $\F_q$.\\ \textbf{Output:} $f(\pmb\alpha_1),\ldots,f(\pmb\alpha_N)$. \begin{algorithmic}[1] \State Let $v_0(Y_0)$ be an irreducible polynomial in $\F_p[Y_0]$ of degree $a$ and $\F_q=\F_p[Y_0]/\ideal{v_0(Y_0)}$. \State $\mathsf{Points}_0\leftarrow \{\pmb\alpha_i\,\mid\, i\in[N]\}$, $a_0\leftarrow a$, and $q_0\leftarrow p^{a}$. \State \Call{Polynomial Evaluation}{$0$}. { $\quad$ (Recursive call)} \State Output ${\mathsf{Eval}}_{0,\mathbf 0}$. \Function{Polynomial Evaluation}{$i$} \State Let $a_{i+1}$ be the smallest positive integer such that $p^{a_{i+1}}>a_{i}d$, and $q_{i+1}\leftarrow q^{a_{i+1}}$. \State Compute an irreducible polynomial $v_{i+1}(Y_{i+1})$ over $\F_q$ of degree $a_{i+1}$ and $$\F_{q_{i+1}}=\F_q[Y_{i+1}]/\ideal{v_{i+1}(Y_{i+1})}. \text{ (\autoref{lem:finite-field-construction})}$$ \State Compute the subfield $\F_{p^{a_{i+1}}}$ of $\F_{q_{i+1}}$. (\autoref{lem:subfield-construction}) \State Compute an element $\beta_{i}$ in $\F_{q_i}$ s.t. $\{1,\beta_i, \ldots,\beta_i^{a_i-1}\}$ forms an $\F_p$-basis for $\F_{p^{a_i}}$. (\autoref{lem:subfield-construction}) \State $\mathsf{Points}_{i+1}\leftarrow \emptyset$. \For{all $\pmb\alpha\in \mathsf{Points}_i$} \State Let $\pmb\alpha=\pmb\alpha_{0}+\pmb\alpha_{1}\beta_i+\cdots+\pmb\alpha_{a_i-1}\beta_{i}^{a_i-1}$, where $\pmb\alpha_{j}\in \F_{p}^n$. \State Compute $\pmb\alpha_0,\ldots,\pmb\alpha_{a_i-1}$. (\autoref{lem:subfield-construction}) \State Let $\var g_{\pmb\alpha}(t)$ be the curve defined as $\pmb\alpha_{0}+ \pmb\alpha_{1}t+ \cdots+ \pmb\alpha_{a_i-1}t^{a_i-1}$. \State $P_{\pmb\alpha}\leftarrow \{\var g_{\pmb\alpha}(\gamma)\,\mid\,\gamma\in \F_{p^{a_{i+1}}}\}$ (\autoref{lem:univariate-evaluation}), and $\mathsf{Points}_{i+1}\leftarrow \mathsf{Points}_{i+1}\cup P_{\pmb\alpha}$.\label{label:algo-v4-pts} \EndFor \If{$i<\ell$} \State \Call{Polynomial Evaluation}{$i+1$}. \Else \State Compute all the polynomials in $\overline{\partial}^{\leq (\ell+1)(n-1)}(f)$. (\autoref{lem:computing-hasse-derivation}) \State Evaluate all the polynomials in $\overline{\partial}^{\leq (\ell+1)(n-1)}(f)$ over the grid $\F_{p^{a_{\ell+1}}}^n$. (\autoref{lem: multidim FFT}) \State Observe that $\mathsf{Points}_{\ell+1}$ is a subset of $\F_{p^{a_{\ell+1}}}^n$. \State For all $\var e\in\N^n$ with $|\var e|_1\leq (\ell+1)(n-1)$, ${\mathsf{Eval}}_{\ell+1, \var e}=\{(\pmb\alpha, \overline{\partial}_{\var e}(f)(\pmb\alpha))\,\mid\, \pmb\alpha\in\F_{p^{a_{\ell+1}}}^n\}$. \EndIf \For{all $\var e\in\N^n$ s.t. $|\var e|_1\leq i(n-1)$} \State ${\mathsf{Eval}}_{i,\var e}\leftarrow \emptyset$. \For{all $\pmb\alpha\in \mathsf{Points}_i$} \State Let $h_{\var e,\pmb\alpha}(t)=\overline{\partial}_{\var e}(f)(\var g_{\pmb\alpha }(t))$. \State Let $E_{\var e,\pmb\alpha}=\{(\gamma, \der{h_{\var e,\pmb\alpha}}{0}(\gamma), \ldots, \der{h_{\var e,\pmb\alpha}}{n-1}(\gamma))\,\mid\,\gamma\in\F_{p^{a_{i+1}}}\}$. \State Using \textsc{Evaluate Derivatives B} with input $(\var g_{\pmb\alpha}(t), i, \var e)$, compute $E_{\var e,\pmb\alpha}$. \State Using $E_{\var e,\pmb\alpha}$, interpolate $h_{\var e,\pmb\alpha}(t)$. (\autoref{lem:hermitian-interpolation}) \State ${\mathsf{Eval}}_{i,\var e}\leftarrow{\mathsf{Eval}}_{i, \var e}\cup\{(\pmb\alpha, h_{\var e,\pmb\alpha}(\beta_i))\}$. (\autoref{lem:univariate-evaluation}) \EndFor \EndFor \EndFunction \end{algorithmic} \end{algorithm} \begin{algorithm}[H] \caption{Evaluating Hasse derivatives for Algorithm \ref{algo:polynomial-evaluation-v4}} \label{algo:computing-hasse-derivative-v3} \begin{algorithmic}[1] \Function{Evaluate Derivatives B }{$\var g(t)$, $k$, $\var e$} \State Let $\var g(t)=(g_1,\ldots,g_n)$. \State Let $\var e=(e_1,\ldots,e_n)$. \State Let $g_i(t+Z)=g_i(t)+Z\tilde g_i(t,Z)$, for all $i\in[n]$, and $\tilde{\var g}(t,Z)=(\tilde g_1(t,Z),\ldots, \tilde g_n(t,Z))$. \State Compute $\tilde g_i(t,Z)$ for all $i\in[n]$. (\autoref{lem:computing-hasse-derivation}) \State For all $\var b=(b_1,\ldots, b_n)\in\N^n$, let $\tilde{\var g}_{\var b}=\prod_{i=1}^n\tilde g_i^{b_i}$. \State Compute the set of polynomials $\{\tilde{\var g}_{\var b}(t,Z)\,\mid\,|\var b|_1<n\}$. (Polynomial multiplication) \State Let $D$ be an $((k+1)(n-1)+1)\times n$ array such that, $$D_{i,j}=\binom{j}{i}\,\mathrm{mod}\, p,\ \text{where } i\in\{0,1,\ldots,n-1\},j\in\{0,1,\ldots,(k+1)(n-1)\}$$ \State Like Algorithm \ref{algo:computing-hasse-derivative}, we can compute $D$ using $\F_p$-operations. \State For $\var b=(b_1,\ldots, b_n)\in\N^n$ such that $|\var b|_1<n$, $$c_{\var b}\leftarrow \prod_{i=1}^nD_{e_i+b_i, b_i}.$$\label{label:v4-binomial-coeff} \State $P\leftarrow \emptyset$. \For{all $\gamma \in\F_{p^{a_{k+1}}}$} \State Using evaluations of polynomials in $\overline{\partial}^{\leq (k+1)(n-1)}(f)$ over $\mathsf{Points}_{k+1}$, compute $$h_\gamma(Z)=\sum_{i=0}^{n-1}Z^i\sum_{\var b\in\N^n:|\var b|_1=i}c_{\var b}\overline{\partial}_{\var e+\var b}(f)(\var g(\gamma))\tilde{\var g}_{\var b}(\gamma, Z).$$ \State For all $i\in\{0,1,\ldots, n-1\}$, extract $\operatorname{Coeff}_{Z^{i}}(h_{\gamma})$. \State $P\leftarrow P\cup\{(\gamma, \operatorname{Coeff}_{Z^0}(h_\gamma),\operatorname{Coeff}_{Z^1}(h_\gamma),\ldots, \operatorname{Coeff}_{Z^{n-1}}(h_\gamma))\}$. \EndFor \State \Return $P$. \EndFunction \end{algorithmic} \end{algorithm} \subsection{Analysis of Algorithm \autoref{algo:polynomial-evaluation-v4}} \paragraph*{A useful lemma. } The following lemma would be useful for the time complexity analysis of Algorithm \autoref{algo:polynomial-evaluation-v4}. \begin{lemma} \label{lem:number-sequence} Let $a,d$ and $p$ be three positive integers such that $p,d$ are greater than $1$. Let $(a_0,a_1,a_2,\ldots)$ be a sequence of positive integers with the following properties: $a_0=a$, and for all $i>0$, $a_i$ be the smallest positive integer such that $p^{a_i}> da_{i-1}$. Then for all non-negative integer $i$, $$a_i\leq2r_i\log_p(dp),$$ where $r_i=\max\{2,\log^{\circ i}_p(a)\}.$ Furthermore, for any non-negative integer $\ell\leq \log^\star_p(a)$, $$\prod_{i=0}^\ell a_i\leq (2\log_p(dp))^\ell\cdot a^{1+o(1)}.$$ \end{lemma} \begin{proof} From the definition of the sequence, it is not hard to see that for every positive integer $i$, $p^{a_i}\leq dpa_{i-1}$. We inductively show that for every non-negative integer $i$, $a_i\leq 2r_i\log_p(dp)$. It is true for $i=0$ since $\log^{\circ i}_p(a)=a$ for $i=0$ and $\log_p(dp)\geq 1$. This establishes our base case. Now assume that $a_i\leq 2r_i\log_p(dp)$ for some integer $i\geq 0$. We know that $p^{a_{i+1}}\leq dpa_{i}$. Taking logarithm with respect to $p$, we get that $a_{i+1}\leq \log_p(dp)+\log_p(a_i)$. From the induction hypothesis, we get that \begin{align*} a_{i+1}&\leq \log_p(dp)+\log_p(2r_i\log_p(dp))\\ &=\log_p(dp)+\log_p\log_p(dp)^2+\log_p(r_i) \end{align*} From the definition of $r_{i+1}$, we get that $r_{i+1}\geq \log_p(r_i)$. Also, $(dp)^2\leq p^{dp}$ for all $d,p\geq 2$. Therefore, $a_{i+1}\leq 2\log_p(dp)+r_{i+1}$. Since both $2\log_p(dp)$ and $r_{i+1}$ are $\geq 2$, $$2\log_p(dp)+r_{i+1}\leq 2r_{i+1}\log_p(dp).$$ This completes the induction step. Now we prove the second part of the above lemma. From the first half, we get that $$\prod_{i=0}^\ell a_i\leq a(2\log_p(dp))^\ell\cdot \prod_{i=1}^\ell r_i.$$ Let $k$ be the largest non-negative integer such that $\log^{\circ k}_p(a)\geq 2$. First, assume that $\ell\leq k$. Then \begin{align*} \prod_{i=0}^\ell a_i &\leq a(2\log_p(dp))^\ell\cdot \prod_{i=1}^\ell r_i \\ &\leq a(2\log_p(dp))^\ell\cdot \prod_{i=1}^\ell\log_p^{\circ i}(a)\\ &\leq (2\log_p(dp))^\ell\cdot a^{1+o(1)}. \end{align*} Since $\log_p^\star(a)$ can be at most $k+2$, $\ell\leq k+2$. Now, assume that $\ell>k$. \begin{align*} \prod_{i=0}^\ell a_i &\leq a(2\log_p(dp))^\ell\cdot \prod_{i=1}^\ell r_i\\ &\leq a(2\log_p(dp))^\ell\cdot\left(\prod_{i=1}^{k}\log^{\circ i}_p(a)\right)\cdot 2^{\ell-k}\\ &\leq (2\log_p(dp))^\ell\cdot a^{1+o(1)}. \end{align*} \end{proof} We are now ready to discuss the proof of \autoref{thm:polynomial-evaluation-v4}. As discussed in \autoref{sec: proof overview}, the main idea in reducing the dependence of the running time on the underlying field is to reduce the question of multipoint evaluation over the field $\F_{p^{a_0}}$ to an instance of multipoint evaluation with a larger number of points, but all these points lie in a smaller field $\F_{p^{a_1}}$, where $p^{a_1} \geq a_0dn$. This reduction in the size leads to a significant decrease in the degree of the curves used in the local computation step, at the cost of increasing the number of points. We now make this intuition formal, and prove the necessary quantitative bounds. \begin{proof}[Proof of \autoref{thm:polynomial-evaluation-v4}] We start with a proof of correctness. \paragraph*{Correctness of Algorithm \autoref{algo:polynomial-evaluation-v4}. } We prove that Algorithm \autoref{algo:polynomial-evaluation-v4} computes $f(\pmb\alpha_i)$ for all $i\in[N]$ with the desired time complexity. First, we briefly highlight the main difference between Algorithm \autoref{algo:polynomial-evaluation-v4} and Algorithm \ref{algo:polynomial-evaluation-v2}. In Algorithm \autoref{algo:polynomial-evaluation-v2}, we construct the field $\F_{q^b}$, a degree $b$ extension of $\F_q$, such that both $\F_q$ and $\F_{p^b}$ are its subfields and $p^b> ad$. Next, we evaluate all the polynomials in $\overline{\partial}^{\leq n-1}(f)$ over the grid $\F_{p^b}^n$. Finally, we reduce the evaluation of $f(\var x)$ at points in $\F_q^n$ to the evaluation of the polynomials in $\overline{\partial}^{\leq n-1}(f)$ at the points in $\F_{p^b}^n$, and use the evaluations of $\overline{\partial}^{\leq n-1}(f)$ at the grid $\F_{p^b}^n$ to compute $f(\pmb\alpha_i)$ for all $i\in[N]$. In short, Algorithm \autoref{algo:polynomial-evaluation-v2} reduces the evaluation of $f(\var x)$ at points in $\F_q^n$ to the evaluation of $\overline{\partial}^{\leq n-1}(f)$ at the points in a "smaller" grid $\F_{p^b}^n$. In Algorithm \autoref{algo:polynomial-evaluation-v4}, we repeat this reduction $(\ell+1)$ times where at the $i$th iteration, we reduce the question of evaluating the set of all Hasse derivatives of $f$ of order up to $i(n-1)$ on a subset of points($\mathsf{Points}_i$) in $\F_{p^{a_i}}^n$ to the question of evaluating all the Hasse derivatives of $f$ of order up to $(i+1)(n-1)$ on a subset of points($\mathsf{Points}_{i+1}$) in $\F_{p^{a_{i+1}}}^n$. Finally, at the $\ell$th iteration, we reach a much "smaller" grid $\F_{p^{a_{\ell+1}}}^n$ (compare to $\F_q^n$) where we evaluate all the Hasse derivatives of $f(\var x)$ up to order $(\ell+1)(n-1)$. We now show via an induction on $i$, with $i$ decreasing from $\ell$ to $0$, the following claim holds. \begin{claim}\label{claim: inductive claim in correctness proof} For every $i \in \{0, 1, \ldots, \ell\}$, at the end of the function call \textsc{Polynomial Evaluation $(i)$}, we have correctly computed the evaluation of all polynomials in the set $\overline{\partial}^{\leq i(n-1)}(f)$ at all points in the set $\mathsf{Points}_{i}$. \end{claim} Recall that the set $\mathsf{Points}_{0}=\{\pmb\alpha_i\,\mid\,i\in[N]\}$ is the original set of input points and hence, this suffices for the correctness of the algorithm. To proceed with the induction, we need the following subclaim whose proof we defer to the end. Recall the set $E_{\vece, \pmb\alpha}$ defined in Line $27$ of Algorithm \autoref{algo:polynomial-evaluation-v4}. \begin{claim} \label{claim:correctness-derivatives} Given $(\var g_{\pmb\alpha}(t), i, \var e)$ as the input, the function \textsc{Evaluate Derivatives B} of Algorithm \ref{algo:computing-hasse-derivative-v3} computes the set $E_{\var e,\pmb\alpha}$ in time $$4^n\cdot \poly(a_i, a_{i+1}, d,n,p) \, .$$ \end{claim} We now proceed with the inductive proof of \autoref{claim: inductive claim in correctness proof}. \paragraph*{Base case. }For $i = \ell$, in Line $22$ of Algorithm \autoref{algo:polynomial-evaluation-v4}, for every $\vece \in \N^{n}$ with $|\vece|_1 \leq (\ell + 1)(n-1)$, we first compute the set ${\mathsf{Eval}}_{\ell+1, \vece}$ which is the evaluation table of the polynomial $\overline{\partial}_{\vece}(f)$ at all points in the set $\F_{p^{a_{\ell + 1}}}^n$ via a multidimensional FFT (\autoref{lem: multidim FFT}). We now claim that at the end of the subsequent \emph{for} loop (Lines $23-30$), for every $\pmb\alpha \in \mathsf{Points}_{\ell}$ and for every $\vece$ in $\N^n$ with $|\vece|_1 \leq \ell(n-1)$, we have the value of $\overline{\partial}_{\vece}(f)$ at $\pmb\alpha$. For this, consider a point $\pmb\alpha \in \mathsf{Points}_{\ell}$ and $\var e\in\N^n$ such that $|\var e|_1\leq \ell(n-1)$. Now the curve $\var g_{\pmb\alpha}(t)$ can be computed efficiently as in the proofs of correctness of Algorithm \autoref{algo:polynomial-evaluation-v1} and Algorithm \autoref{algo:polynomial-evaluation-v2}. Then, $h_{\var e, \pmb\alpha}=\overline{\partial}_{\var e}(f)(\var g_{\pmb\alpha}(t))$ is a polynomial of degree less than $a_{\ell}dn$. From \autoref{claim:correctness-derivatives}, we have that the function \textsc{Evaluate Derivatives B} correctly computes the set $E_{\vece, \pmb\alpha}$. Moreover, by our choice of $a_{i}'s$, we have that $p^{a_{\ell+1}}\geq a_{\ell}d$. Thus, from \autoref{lem:hermitian-interpolation}, we can interpolate $h_{\var e, \pmb\alpha}(t)$ correctly from the set $E_{\var e,\pmb\alpha}$. \paragraph*{Induction step. } In the induction step, we assume \autoref{claim: inductive claim in correctness proof} is true for $i = i_0 \leq \ell $ and show that it holds for the iteration $i_{0}-1$. The proof of this is precisely the same as that of the base case. The only difference is that in the base case, the set ${\mathsf{Eval}}_{\ell + 1, \vece}$ for every $\vece \in \N^n$ with $|\vece|_1 \leq (\ell + 1)(n-1)$ was computed in Line $22$ of the algorithm directly via the multidimensional FFT. In the induction step, for iteration $i_0-1$, we need the corresponding set ${\mathsf{Eval}}_{i_{0}, \vece}$ for every $\vece \in \N^n$ with $|\vece|_1 \leq i_0 (n-1)$. Note that these are sets of evaluations of all derivatives of order at most $i_0(n-1)$ of $f$ on the point set $\mathsf{Points}_{i_0}$ that are guaranteed to be available to us by the induction hypothesis. The rest of the argument is exactly as that in the base case. We skip the details. A point to note for the proof of both the base case and the induction step of \autoref{claim: inductive claim in correctness proof}, is that $h_{\var e, \pmb\alpha}$ is a polynomial with coefficients in $\F_q$ and $\F_q$ is a subfield of $\F_{q_i}$ for every $i \in \{0, 1, \ldots, \ell \}$, so all the algebra is consistent here. This completes the proof of \autoref{claim: inductive claim in correctness proof} and hence the correctness of \autoref{algo:polynomial-evaluation-v4} (which follows from $i = 0$ case of the claim), modulo the proof of \autoref{claim:correctness-derivatives}. We defer that to the end of this section, and discuss the time complexity of Algorithm \autoref{algo:polynomial-evaluation-v4}. \paragraph*{Time complexity of Algorithm \autoref{algo:polynomial-evaluation-v4}. } Now we discuss the time complexity of Algorithm \ref{algo:polynomial-evaluation-v4}. We rely on the following claim, whose proof we defer to the end of this section. \begin{claim} \label{claim:v4-points-size} $|\mathsf{Points}_{\ell}|\leq N\cdot(2dp\log_p(dp))^\ell\cdot a^{1+o(1)}.$ \end{claim} For all $i\in\{0,1,\ldots,\ell\}$, let $T_i$ be the time complexity of the $i$th invocation of the function \textsc{Polynomial Evaluation}. Next, we discuss the various components of $T_i$. \begin{enumerate} \item Using \autoref{lem:finite-field-construction}, the field $\F_{q_{i+1}}=\F_q[Y_{i+1}]/\ideal{v_{i+1}(Y_{i+1})}$ can be constructed in $\poly(a,a_{i+1},p)$ $\F_q$-operations. From \autoref{lem:subfield-construction}, the cost of computing all the elements of the subfield $\F_{p^{a_{i+1}}}$ (of $\F_{q_{i+1}}$) is $p^{a_{i+1}}\cdot \poly(a,a_{i+1},p)$ $\F_q$-operations. \item Using \autoref{lem:subfield-construction}, we can also compute the element $\beta_{i}$ in $\poly(a, a_i, p)$ $\F_q$-operations. In addition, \autoref{lem:subfield-construction} ensures that for every $\gamma\in\F_{p^{a_i}}$, the $\F_p$-linear combination of $\gamma$ with respect to $\{1,\beta_i,\ldots,\beta_i^{a_i-1}\}$ can be computed using $\poly(a_i)$ $\F_q$-operations. Therefore, for every $\pmb\alpha\in\mathsf{Points}_i$, the cost of computing the curve $\var g_{\pmb\alpha}(t)$ is $\poly(a_i,n)$ $\F_q$-operations. This implies that the set $P_{\pmb\alpha}$ can be constructed in $p^{a_{i+1}}\cdot \poly(a_i,a_{i+1},n)$ $\F_q$-operations. Thus, the total cost of computing the set $\mathsf{Points}_{i+1}$ is $$|\mathsf{Points}_i|\cdot p^{a_{i+1}}\cdot \poly(a_i,a_{i+1},n)$$ $\F_q$-operations. \item For $i\in\{0,1,\ldots,\ell-1\}$, we need to add the cost of $(i+1)$th call of \textsc{Polynomial Evaluation}, that is $T_{i+1}$. For $i=\ell$, using \autoref{lem:computing-hasse-derivation}, we can compute the set $\overline{\partial}^{\leq (\ell+1)(n-1)}(f)$ in $\binom{(\ell+1)(n-1)+n}{n}\cdot d^n\cdot \poly(n)$ many $\F_q$-operations. Since $\binom{(\ell+1)(n-1)+n}{n}\leq O(\ell+1)^n$, the total cost of computing the set $\overline{\partial}^{\leq (\ell+1)(n-1)}(f)$ is $$O(\ell+1)^n\cdot d^n\cdot \poly(n)$$ $\F_q$-operations. We have to evaluate all the polynomials in $\overline{\partial}^{\leq(\ell+1)(n-1)}(f)$ over the grid $\F_{p^{a_{\ell+1}}}^n$. Using \autoref{lem: multidim FFT}, each polynomial in $\overline{\partial}^{\leq(\ell+1)(n-1)}(f)$ can be evaluated over the grid in $$(d^n+p^{na_{\ell+1}})\cdot \poly(a, a_{\ell+1}, d,n,p)$$ many $\F_q$-operations. Thus, the total cost of evaluating all the polynomials in $\overline{\partial}^{\leq(\ell+1)(n-1)}(f)$ over the grid is $$(a_\ell d p)^n\cdot O(\ell+1)^n\cdot\poly(a, a_{\ell+1}, d,n,p)$$ $\F_q$-operations since $p^{a_{\ell+1}}\leq a_\ell dp$. \item We have to compute the set ${\mathsf{Eval}}_{i,\var e}$ for all $\var e\in\N^n$ with $|\var e|_1\leq i(n-1)$. Let $\var e\in\N^n$ with $|\var e|_1\leq i(n-1)$, and $\pmb\alpha\in\mathsf{Points}_i$. Then, using \autoref{claim:correctness-derivatives}, the set $E_{\var e,\pmb\alpha}$ can be computed in $4^n\cdot \poly(a_i, a_{i+1}, d, n, p)$ many $\F_q$-operations. Applying \autoref{lem:hermitian-interpolation}, the polynomial $h_{\var e,\pmb\alpha}(t)$ can be interpolated from $E_{\var e,\pmb\alpha}$ using $\poly(a_{i},a_{i+1}, d,n)$ $\F_q$-operations. Finally, $h_{\var e,\pmb\alpha}(\beta_i)$ can be computed in $\poly(a_i,d,n)$ $\F_q$-operations. Thus, for an $\var e\in \N^n$ with $|\var e|_1\leq i(n-1)$, the cost of computing ${\mathsf{Eval}}_{i,\var e}$ is $|\mathsf{Points}_i|\cdot 4^n\cdot (a_i,a_{i+1},d,n,p)$ $\F_q$-operations. The number of $\var e\in\N^n$ with $|\var e|_1\leq i(n-1)$ is $\binom{i(n-1)+n}{n}$, and it is upper bounded by $O(i+1)^n$. Therefore, the total of computing ${\mathsf{Eval}}_{i,\var e}$ for all $\var e\in\N^n$ with $|\var e|_1\leq i(n-1)$ is $$|\mathsf{Points}_i|\cdot O(i+1)^n\cdot \poly(a_i, a_{i+1}, d,n,p)$$ $\F_q$-operations. \end{enumerate} The choice of $a_{i+1}$ gives us that $p^{a_{i+1}}\leq a_idp$. From \autoref{lem:number-sequence}, $a_i\leq 4a\log_p(dp)$ for all $i\geq 1$. Thus, from the above discussion, for all $i\in\{0,1,\ldots,\ell-1\}$, $$T_{i}\leq T_{i+1}+ |\mathsf{Points}_i|\cdot O(i+1)^n\cdot \poly(a,d,n,p).$$ Also, the complexity of the $\ell$th invocation of \textsc{Polynomial Evaluation} is $$T_{\ell}\leq (a_\ell d p)^n\cdot O(\ell+1)^n\cdot \poly(a,d,n,p).$$ Therefore, the overall $\F_q$-operations performed by Algorithm \ref{algo:polynomial-evaluation-v4} is \begin{align*} T_0 &\leq \sum_{i=0}^{\ell-1}|\mathsf{Points}_i|\cdot O(i+1)^n\cdot \poly(a,d,n,p)+T_\ell\\ &\leq \ell|\mathsf{Points}_\ell|\cdot O(\ell+1)^n\cdot \poly(a,d,n,p)+(a_\ell dp)^n\cdot O(\ell+1)^n\cdot\poly(a,d,n,p)\\ &\leq (|\mathsf{Points}_\ell|+(a_\ell dp)^n)\cdot O(\ell+1)^n\cdot \poly(a,d,n,p). \end{align*} Using \autoref{lem:number-sequence}, $a_\ell\leq 2r\log_p(dp)$, where $r=\max\{2,\log_p^{\circ \ell}(a)\}$. From \autoref{claim:v4-points-size}, $$|\mathsf{Points}_\ell|\leq N\cdot(2dp\log_p(dp))^\ell\cdot a^{1+o(1)}.$$ Therefore, the number of $\F_{q}$-operations performed by Algorithm \ref{algo:polynomial-evaluation-v4} $$T_0\leq \left(N\cdot \left(2dp\log_p(dp)\right)^\ell+\left(2rdp\log_p(dp)\right)^n\right)\cdot O(\ell+1)^n\cdot \poly(a,d,n,p).$$ \end{proof} This completes the proof of \autoref{thm:polynomial-evaluation-v4} modulo the proofs of the \autoref{claim:correctness-derivatives} and \autoref{claim:v4-points-size}. We now discuss these missing proofs. \paragraph{Proof of \autoref{claim:correctness-derivatives}} \begin{proof}[Proof of \autoref{claim:correctness-derivatives}] According to the function call, $\var g(t)=\var g_{\pmb\alpha}(t)$ and $k=i$. Also, $\var g(t)=(g_1,\dots,g_n)$, $g_i(t+Z)=g_i(t)+Z\tilde g_i(t,Z)$ for all $i\in[n]$ and for all $\var b=(b_1,\ldots,b_n)\in\N^n$, $\tilde{\var g}_{\var b}=\prod_{i=1}^n\tilde g_i^{b_i}$. Let $\overline{\partial}_{\var e}(f)=f_{\var e}$. Let $$h(t+Z)=\sum_{i=0}^{n-1}Z^i\sum_{\var b\in\N^n:|\var b|_1\leq n-1}\overline{\partial}_{\var b}(f_{\var e})(\var g(t))\cdot \tilde{\var g}_{\var b}.$$ Then, from \autoref{lem:hasse-derivative-property}, $$h(t+Z)=\sum_{i=0}^{n-1}Z^i\sum_{\var b\in\N^n:|\var b|_1\leq n-1}\binom{\var e+\var b}{\var b}\overline{\partial}_{\var e+\var b}(f)(\var g(t))\cdot \tilde{\var g}_{\var b}.$$ In step $10$ of Algorithm \ref{algo:computing-hasse-derivative-v3}, for all $\var b\in\N^n$ with $|\var b|_1\leq n-1$, $c_{\var b}=\binom{\var e+\var b}{\var b}.$ Therefore, $$h(t+Z)=\sum_{i=0}^{n-1}Z^i\sum_{\var b\in\N^n:|\var b|_1\leq n-1}c_{\var b}\overline{\partial}_{\var e+\var b}(f)(\var g(t))\cdot \tilde{\var g}_{\var b}.$$ Applying \autoref{lem:hasse-derivative}, we get that for all $i\in\{0,1,\ldots,n-1\}$, the $i$th order Hasse derivative of $f_{\var e}(\var g(t))$ is same as $\operatorname{Coeff}_{Z^i}(h(t+Z))$. Hence, for all $\gamma\in\F_{p^{a_{k+1}}}$, the evaluation of $i$th order Hasse derivative of $f_{\var e}(\var g(t))$ at $\gamma$ is equal to $\operatorname{Coeff}_{Z^i}(h(\gamma+Z))$. In terms of notation used in Algorithm \ref{algo:computing-hasse-derivative-v3}, $\operatorname{Coeff}_{Z^i}(h(\gamma+Z))$ is same as $\operatorname{Coeff}_{Z^i}(h_{\gamma}(Z))$. This implies that the evaluation of $i$th order Hasse derivative of $f_{\var e}(\var g(t))$ at $\gamma$ is equal to $\operatorname{Coeff}_{Z^i}(h_{\gamma}(Z))$. This implies that given $(\var g_{\pmb\alpha}(t), k, \var e)$ as input, the set $P$ returned by \textsc{Evaluate Derivatives B} is same as $E_{\var e, \pmb\alpha}$. Now, to compute $h_{\gamma}(Z)$, we need access to $\tilde{\var g}_{\var b}(\gamma, Z)$ for all $\var b\in\N^n$ with $|\var b|_1<n$. \autoref{lem:computing-hasse-derivation} ensures that we can compute $\tilde g_i(t,Z)$ for all $i\in[N]$. After we have all $\tilde g_i(t,Z)$'s, we can compute $\tilde{\var g}_{\var b}(t,Z)$ and evaluate it at $t=\gamma$. Also, we need the access of $\overline{\partial}_{\var e+\var b}(f)(\var g(\gamma))$ for all $\var b\in\N^n$ with $|\var b|_1<n$. Observe that $|\var e+\var b|_1\leq (k+1)(n-1)$ and $\var g(\gamma)\in\mathsf{Points}_{k+1}$. Therefore, from the evaluations of the polynomials $\overline{\partial}^{\leq (k+1)(n-1)}(f)$ at points $\mathsf{Points}_{k+1}$, we get $\overline{\partial}_{\var e+\var b}(f)(\var g(\gamma))$. Now we discuss the number of $\F_q$-operations performed by Algorithm \ref{algo:computing-hasse-derivative-v3}. From \autoref{lem:computing-hasse-derivation}, we can compute $\tilde g_i(t,Z)$ for all $i\in[n]$ in $\poly(a_k, n)$ $\F_q$-operations. Since each $\tilde g_i(t,Z)$ is a bivariate polynomial of individual degree less than $a_k$ and $\binom{n+n-1}{n}\leq 4^n$, we can compute the set $\{\tilde{\var g}_{\var b}(t,Z)\,\mid\, |\var b|_1<n\}$ in $4^n\cdot \poly(a_k,n)$ $\F_q$-operations. Computing all $c_{\var b}$'s takes $4^n\cdot \poly(n)+\poly(k,n)$ $\F_q$-operations. Given a $\gamma\in\F_{p^{a_{k+1}}}$, from \autoref{lem:subfield-construction}, we can evaluate $\tilde{\var g}_{\var b}$ at $t=\gamma$ in $\poly(a_k, a_{k+1}, n)$ $\F_q$-operations. Thus, for any $\gamma\in\F_{p^{a_{k+1}}}$, the cost of computing $h_{\gamma}(Z)$ is $4^n\cdot \poly(a_k, a_{k+1}, n)$. Once we have $h_\gamma(Z)$ as its list of coefficients, we collect the coefficients of $Z^i$ for all $i\in\{0,1,\ldots,n-1\}$. From the choice of $a_{k+1}$, $p^{a_{k+1}}\leq a_kdp$. Thus, the total cost of Algorithm \ref{algo:computing-hasse-derivative-v3} is $$4^n\cdot \poly(a_k, a_{k+1}, d, p, n)$$ $\F_q$-operations. \end{proof} \vspace{1cm} \paragraph*{Proof of \autoref{claim:v4-points-size}} \begin{proof}[Proof of \autoref{claim:v4-points-size}] First, we show that for all $i\in\{0,1,\ldots,\ell-1\}$, $|\mathsf{Points}_{i+1}|\leq |\mathsf{Points}_i|\cdot (a_idp)$. From the step $15$ of Algorithm \ref{algo:polynomial-evaluation-v4}, the set $$\mathsf{Points}_{i+1}=\cup_{\pmb\alpha\in\mathsf{Points}_i}P_{\pmb\alpha}.$$ The definition of $P_{\pmb\alpha}$ ensures that its size is at most $p^{a_{i+1}}$, which is upper bounded by $a_{i}dp$. Therefore, the size of $\mathsf{Points}_{i+1}$ is at most $|\mathsf{Points}_i|\cdot (a_idp)$. This implies that $$\mathsf{Points}_{\ell}\leq N\cdot (dp)^\ell\cdot \prod_{i=0}^\ell a_i.$$ From \autoref{lem:number-sequence}, $\prod_{i=0}^\ell a_i\leq (2\log_p(dp))^\ell\cdot a^{1+o(1)}.$ Therefore, $$|\mathsf{Points}_\ell|\leq N\cdot (2dp\log_p(dp))^\ell\cdot a^{1+o(1)}.$$ \end{proof} \iffalse \subsection{Comparison between time complexities of Algorithm \ref{algo:polynomial-evaluation-v3} and \ref{algo:polynomial-evaluation-v4}} \paragraph*{Parameters:} \begin{enumerate} \item individual degree $d$, number of variables $n$ \item Underlying field $\F_q$ where $q=p^a$. \item a non-negative integer $\ell\leq \log^{\star}_p(a)$, $r=\max{2,\log^{\circ \ell}_{p}(a)}$ \end{enumerate} Time complexity of Algorithm \ref{algo:polynomial-evaluation-v3},$$T_1=\left(Na^2n^\ell\cdot\left(2dp\log_p(dnp)\right)^{\ell}+\left(2rdp\log_p(dnp)\right)^n\right)\cdot c^n\cdot \poly(a,d,n,p).$$ Time complexity of Algorithm \ref{algo:polynomial-evaluation-v4}. $$T_2=\left(Na^2\cdot \left(2dp\log_p(dp)\right)^\ell+\left(2rdp\log_p(dp)\right)^n\right)\cdot O(\ell+1)^n\cdot \poly(a,d,n,p).$$ Both the algorithm works non-trivially when $p=d^{o(1)}$. For $\ell=O(1)$, the complexity of both the algorithm is similar. Assume $\ell=\omega(1)$. \begin{description} \item [$n=\poly(d)$:] In $T_1$, the first summand in the bracket has an additional $n^\ell$, \emph{super-polynomial} quantity, but it is overshadowed by $\ell^n$ factor in $T_2$. \item [$n=\Omega(1)^d$]: $T_1$ becomes trivial since $\log_p(dnp)\approx d$. Therefore, $T_2$ is much better. \end{description} \fi \section{An algebraic data structure for polynomial evaluation}\label{sec:data structures full} In this section, we discuss the implication of our multipoint evaluation algorithms to the question of data structures for polynomial evaluation. For functions $s: \N \to \N$ and $t: \N \to \N$, an algebraic data structure for univariate polynomial evaluation over a field $\F$ with space complexity $s(n)$ and time complexity $t(n)$ is specified by a preprocessing map and a query algorithm. For every $n \in \N$, the preprocessing map maps a polynomial $f \in \F[X]$ of degree less than $n$ to an $s(n)$ dimensional vector over $\F$ which we denote by ${\cal D}_f$ and the query algorithm is an algebraic algorithm that on any input $\alpha \in \F$, accesses at most $t(n)$ coordinates of ${\cal D}_f$ and correctly outputs $f(\alpha)$. For this discussion $\F$ is a finite field, and as mentioned in \autoref{rmk: description of the finite field}, we assume that the query algorithm has access to a description of the field, for instance via an irreducible polynomial of appropriate degree over the base field. Now, we formally state the main result for this section. \begin{theorem}\label{thm: data structure technical} Let $p$ be a fixed prime. Then, for all sufficiently large $n \in \N$ and all fields $\F_{p^a}$ with $a = \poly(\log n)$, there is an algebraic data structure for polynomial evaluation for univariate polynomials of degree less than $n$ over $\F_{p^a}$ that has space complexity at most $n^{1 + o(1)}$ and query complexity at most $n^{o(1)}$. Moreover, given a description of $\F_{p^a}$ (via an irreducible polynomial of degree $a$ over $\F_p$ ) there is an algebraic algorithm that when given the coefficients of a univariate polynomial $f$ of degree less than $n$ computes the output of the preprocessing map on $f$, denoted here by ${\cal D}_f$ in time $n^{1 + o(1)}$ and an algebraic algorithm which, when given an $\alpha \in \F_{p^a}$ and ${\cal D}_f$, outputs $f(\alpha)$ in time $n^{o(1)}$. \end{theorem} We recall that for fields of small characteristic and size $\poly(n)$, \autoref{thm: data structure technical} provides a counterexample to a conjecture of Milterson from \cite{M95} that any algebraic data structure for polynomial evaluation over small fields that has space complexity $\poly(n)$ must have query complexity linear in $n$. We also note that a slightly more general version of \autoref{thm: data structure technical} is true where we have an appropriate tradeoff between the query and the space complexities. However, for the ease of exposition, we focus on proving the specific statement in \autoref{thm: data structure technical}. \subsection{Proof of \autoref{thm: data structure technical}} The proof is a very simple application of the ideas in the multipoint evaluation algorithms discussed in the earlier section. The first ingredient is a reduction from the univariate problem to the multivariate problem. This step is also there in the data structure of Kedlaya \& Umans \cite{Kedlaya11}. \begin{definition}[Inverse Kronecker Map] \label{def:inverse-kronecker} Let $\F$ be a field. Then, for parameters $d, m \in \N$, the map $\psi_{d,m}$ from $\F[X]$ to $\F[Z_1, \ldots, Z_m]$ is defined as follows: Given a monomial $X^{t}$, write $t$ in base $d$, $t=\sum_{j\geq 0}t_jd^j$ and define the monomial $$M_a(\vecz):=Z_1^{t_0}Z_2^{t_1}\cdots Z_{m}^{t_{m-1}}.$$ The map $\psi_{d,m}$ sends $X^a$ to $M_a(\vecz)$ and extends multilinearly to $\F[X]$. \end{definition} The map $\psi_{d,m}(f)$ can be computed in linear time in the size of $f$, assuming $f$ is represented explicitly by its coefficients. Also, $\psi_{d,m}$ is injective on the polynomials of degree less than $d^m$. For such polynomial $f$, if $F=\psi_{d,m}(f)$, then $$f(X)=F(X^{d^0}, X^{d^1},\ldots, X^{d^{m-1}}).$$ Given a degree $n-1$ univariate polynomial $f$, let the parameters $m, d$ be set as follows: $m = \log\log n$ and $d = n^{1/\log \log n}$ and construct the polynomial $F = \psi_{d, m}(f)$ on $m$ variables and degree at most $d-1$ in each variable. Clearly, this can be done in time $n\cdot \poly(\log n)$ by processing $f$ one monomial at a time. We now describe the preprocessing map and its image on $f$ denoted ${\cal D}_f$ using this polynomial $F$. This construction is based on the \autoref{thm:polynomial-evaluation-v1}. A slightly more general statement can be obtained by relying on the more involved algorithms for multipoint evaluation in \autoref{sec: mme algo large n} and \autoref{sec: mme large fields}, but for the proof of \autoref{thm: data structure technical}, Algorithm \autoref{algo:polynomial-evaluation-v1} is sufficient. \paragraph*{The preprocessing map.} Let $v_0(Y_0)$ be an irreducible polynomial over $\F_p$ of degree $a$ such that $\F_{q} =\F_p[Y_0]/\ideal{v_0(Y_0)}$, where $q = p^a$. We assume that this $v_0$ is given as a part of the input, since it conveys the description of the field we are working over. Compute the smallest integer of form $p^b$ such that $p^b > adm$. Compute an irreducible polynomial $v_1(Y_1)$ in $\F_q[Y_1]$ of degree $b$ such that $\F_{q^b}=\F_q[Y_1]/\ideal{v_1(Y_1)}$. Using \autoref{lem:subfield-construction}, compute the subfield $\F_{p^b}$ of $\F_{q^b}$. We compute and store the evaluation of $F$ on every input in the grid $\F_{p^b}^m$. This is our ${\cal D}_f$. The space required to store all this data is at most $(m+1)p^{bm}$ elements of the field $\F_{p^{ab}}$ of equivalently $(m+1)p^{bm}b$ elements of the field $\F_{p^a}$. For our choice of parameters, the space complexity can be upper bounded as follows. \[ p^{bm} \leq (padm)^{m} = p^{\log \log n}\cdot (\poly(\log n))^{\log\log n} \cdot n \cdot {(\log \log n)}^{\log \log n} \leq n^{1 + o(1)} \, .\] Thus, the space complexity is at most $(m+1)p^{bm}b \leq n^{1 + o(1)}$ as claimed. Moreover, ${\cal D}_f$ can be computed by an algebraic algorithm over $\F_{q}$ using \autoref{lem: multidim FFT} and other ideas in \autoref{sec: mme algo large n}. \paragraph*{Answering evaluation queries using ${\cal D}_f$.} We now describe an algorithm that given an $\alpha \in \F_q$ and access to ${\cal D}_f$ computes $f(\alpha)$ in time $n^{o(1)}$. The algorithm is essentially the same as the local computation step in Algorithm \autoref{algo:polynomial-evaluation-v1}. Note that ${\cal D}_f$ contains precisely the data that is computed in Algorithm \autoref{algo:polynomial-evaluation-v1} in the preprocessing phase. We assume the notation ($F, v_0, v_1$ etc.) set up in the previous paragraph. \begin{algorithm}[H] \caption{ Evaluating polynomial $f(x)$ at a point in $\F_q$ using ${\cal D}_f$} \label{algo:polynomial-evaluation} \textbf{Input:} A point $\alpha\in\F_q$ and query access to ${\cal D}_f$.\\ \textbf{Output:} $f(\alpha)$.\\ \begin{algorithmic}[1] \State Let ${\pmb\alpha}=(\alpha^{d^0}, \alpha^{d^1},\ldots,\alpha^{d^{n-1}})$. \State Let ${\pmb\alpha}={\pmb\alpha}_{0}+{\pmb\alpha}_{1}Y_0+\cdots+{\pmb\alpha}_{a-1}Y_0^{a-1}$, where ${\pmb\alpha}_{j}\in \F_{p}^n$. \State Compute ${\pmb\alpha}_{0},{\pmb\alpha}_{1},\ldots,{\pmb\alpha}_{k-1}$. \State Let $\vecg(t)$ be the curve defined as ${\pmb\alpha}_{0}+{\pmb\alpha}_{1}t+\cdots+{\pmb\alpha}_{a-1}t^{a-1}.$ \State Compute the set $P=\{(\gamma,\vecg(\gamma)) \,\mid\, \gamma\in\F_{p^b}\}$. \State Collect the set $E=\{(\gamma, F(\pmb\gamma'))\,\mid\, (\gamma,\pmb\gamma')\in P\}$ by querying ${\cal D}_f$. \State Using $E$, interpolate the univariate polynomial $F(\vecg(t))$. \State Output $F(\vecg(Y_0))$ as $f(\alpha)$. \end{algorithmic} \end{algorithm} The proof of correctness of the construction of ${\cal D}_f$ and the query algorithm immediately follow from the proof of correctness of Algorithm \autoref{algo:polynomial-evaluation-v1}. The query complexity is clearly upper bounded by $p^b \leq padm$, which for our setting of parameters, i.e. $p = O(1)$, $a = \poly(\log n)$, $d = n^{1/\log \log n}$ and $m = \log \log n$ is $n^{o(1)}$. This completes the proof of \autoref{thm: data structure technical}. \section{Rigidity uppper bounds}\label{sec:rigidity proof} In this section, we prove \autoref{thm: vandermonde rigidity intro}. We start with the definition of matrix rigidity which was introduced by Valiant \cite{Valiant1977}. \begin{definition}(Matrix rigidity) For a matrix $M$ over some field $\mathbb{F}$ and a natural number $r$, we define $R^{\mathbb{F}}_M(r)$ to be the smallest number $s$ for which there exists a matrix $A$ with at most $s$ nonzero entries and a matrix $B$ of rank at most $r$ such that $M = A+B$. If $R^{\mathbb{F}}_M(r) \geq s$, we say $M$ is $(r,s)$-rigid. When the underlying field is clear from the context, we drop the superscript and denote $R^{\mathbb{F}}_M(r)$ by $R_M(r)$. \end{definition} Now we define \emph{regular rigidity} denoted by $r^{\mathbb{F}}_M(\cdot)$ . \begin{definition}(Regular rigidity) For a matrix $M$ over some field $\mathbb{F}$ and a natural number $\tilde{r}$, we define $r_M(\tilde{r})$ to be the smallest number $s$ such that there exists a matrix $A$ with at most $s$ nonzero entries in each row and column and a matrix $B$ of rank at most $\tilde{r}$ such that $M = A+B$. If $r^{\mathbb{F}}_M(\tilde{r}) \geq s$, we say $M$ is $(\tilde{r},s)$-regular rigid. Also here, when the underlying field is clear from the context, we drop the superscript and denote $r^{\mathbb{F}}_M(\tilde{r})$ by $r_M(\tilde{r})$. \end{definition} Note that the notion of \emph{regular rigidity} is weaker than the usual notion of rigidity. That is, say $A$ is an $n \times n$ matrix and $A$ is $(r, ns)$-rigid then $r_A(r) \geq s$. From the perspective of rigidity upper bounds, if $r_A(r) \leq s$ then $R_A(r) \leq ns$. Thus, it follows that proving a family of matrices to be non-regular rigid is even a stronger criterion compared to the usual notion of non-rigidity. In this section, we show that the Vandermonde matrices are not Valiant rigid (refer \autoref{sec: rigidity intro}). Note that, for any matrix $M\in \F^{n \times n}$, showing that there exists constants $c_1, c_2$ and $\epsilon>0$ such that $$R_M^{\F}(\frac{n}{\exp({\epsilon^{c_1}}\log^{c_2}n)}) \leq n^{1+ \epsilon}$$ implies that $M$ is not Valiant rigid. For concreteness, we state our results in terms of $R_M(\cdot)$ and $r_M(\cdot)$. We start by defining some interesting classes of matrices which will be used frequently in the subsequent sections. \begin{definition}[Discrete Fourier Transform (DFT) Matrices] Let $\F$ be any field and let $\omega\in\F$ be a primitive $n\mathrm{th}$ root of unity in $\F$. Then, the Discrete Fourier Transform (DFT) Matrix of order $n$, denoted by $F_n$ is an $n \times n$ matrix over $\F$ defined as follows. The rows and columns of the matrix are indexed from $\{0,1, \ldots, n-1\}$. The $(i,j)$th entry of $F_n$ is $\omega^{ij}$. \end{definition} \begin{definition}[Circulant Matrices]\label{def: Circulant} Let $\F$ be a field and $C_n$ be a matrix of order $n \times n$ with entries in $\F$ such that the rows and columns of $C_n$ are indexed from $\{0,1, \ldots, n-1\}$. Then, $C_n$ is said to be a Circulant matrix if there exist $c_0,c_1, \ldots, c_{n-1} \in \F$ such that for every $i, j \in \{0,1, \ldots, n-1\}$, $C_n(i, j)= c_{{(i+j)}\mod n}$. \end{definition} \begin{definition} Let $\F$ be a field. A Vandermonde matrix$(V_n)$ of order $n \times n$ is defined by an input vector $\pmb\alpha = (\alpha_0,\alpha_1, \ldots, \alpha_{n-1})$ where $\pmb\alpha \in \F^n$. The rows and columns of $V_n$ are indexed from $\{0,1, \ldots, n-1\}$ and for every $i, j \in \{0,1, \ldots, n-1\}$, $V_n(i, j)= \alpha_i^{j}$. \end{definition} We now state the formal version of \autoref{thm: vandermonde rigidity intro}. \begin{theorem}\label{thm: Vandermonde rigidity} Let $0 < \epsilon < 0.01$, $p$ be a fixed prime and $c$ be a fixed constant. Let $a: \N \to \N$ be a function such that for all $n$, $a(n) \leq \log^c n$. Let $\{V_n\}_{n \in \N}$ be a family of matrices over $\overline{\F}_p$ such that for every $n$, $V_n$ is an $n \times n$ Vandermonde Matrix with entries in the subfield $\F_{q=p^{a(n)}}$. Then, for all large enough $n$, $$ {R}^{\mathbb{F}_q}_{V_n} \Big{(} \frac{n}{\exp( \Omega(\epsilon^7\log^{0.5} n)\big{)}} \Big{)} \leq n^{1+ 31\epsilon} \, $$ \end{theorem} As alluded in \autoref{sec: rigidity proof overview}, the main idea in proving \autoref{thm: Vandermonde rigidity} comes from viewing Algorithm \autoref{algo:polynomial-evaluation-v1} as a decomposition of (any) Vandermonde matrix into the product of a row-sparse matrix($A$) and a sufficiently non-rigid matrix($B$). Before getting into the proof of the main theorem, we discuss the non-rigidity of the matrix family ``$B$". As it turns out, $B$ is a multidimensional analog of the DFT matrix. Thus, we start by proving that the DFT matrices are non-rigid over quasi-polynomial size finite field $\F_q$ in \autoref{cor: DFT rigidity}. Followed by showing that the multidimensional DFT matrices are also non-rigid in \autoref{thm: multi dim rigid upper bound}, using the non-rigidity of DFT matrices and the Kronecker product structure of multidimensional DFT. Finally, in \autoref{subsec: Van non-rigid}, we flesh out the decomposition of Vandermonde matrices as product of row-sparse and multidimensional DFT matrices and use it to conclude that Vandermonde matrices are non-rigid as well. \subsection{Non-rigidity of DFT matrices} In this section, we give an upper bound on the rigidity of DFT matrices over finite fields. This bound follows directly from the work of Dvir and Liu \cite{DL20} although the precise statement needed for our purpose (see \autoref{cor: DFT rigidity}) is not included in \cite{DL20} as the results there are stated for a family of matrices over a fixed finite field. Whereas, in \autoref{thm: Vandermonde rigidity}, the field is also increasing in size with the dimension of the matrix and for its proof, we need a bound on the rigidity of a family of DFT matrices with the field growing in size with the dimension of the matrices. This turns out to be a direct consequence of the results in \cite{DL20} and was communicated to us by the Zeev Dvir and Allen Liu \cite{DLpersonal}. \iffalse \begin{definition}[Discrete Fourier Transform (DFT) Matrices] Let $\F$ be any field and let $\omega \in \F$ be a primitive $n$'th root of unity in $\F$. Then, the Discrete Fourier Transform (DFT) Matrix of order $n$, denoted by $F_n$ is an $n \times n$ matrix over $\F$ defined as follows. The rows and columns of the matrix are indexed from $\{0,1, \ldots, n-1\}$. The $(i,j)$'th entry of $F_n$ is $\omega^{i.j}$. \end{definition} We now define Circulant matrices, which also play an important role in the discussion in this section. \begin{definition}[Circulant Matrices]\label{def: Circulant} Let $\F$ be a field and $C_n$ be a matrix of order $n \times n$ with entries in $\F$ such that the rows and columns of $C_n$ are indexed from $\{0,1, \ldots, n-1\}$. Then, $C_n$ is said to be a Circulant matrix if there exist $c_0,c_1, \ldots, c_{n-1} \in \F$ such that for every $i, j \in [n]$, $C_n(i, j)= c_{{(i+j)}\mod n}$. \end{definition} \begin{definition} Define the regular-rigidity $r_A^{\F}(r)$ of a matrix $A$ over a field $\F$ as the minimum value of $s$ such that it is possible to change at most s entries in each row and column of A to obtain a matrix of rank at most $r$. \end{definition} For our results, we need a quantitative notion of non-rigidity for a family of matrices. We rely on the following notion defined by Dvir and Liu in \cite{DL20}. \begin{definition}[Definition $1.4$ in \cite{ DL20}] We say a family of matrices $\mathcal{M}$ is quasipolynomially non-rigid over a field $\mathbb{F}$ if there are constants $c_1, c_2 >0$ such that for any $\epsilon >0$, all sufficiently large matrices $M \in \mathcal{M}$ satisfy, $$ r^{\mathbb{F}}_{M_{N \times N}}\Big{(} \frac{N}{\exp (\epsilon^{c_1}(\log N)^{c_2})} \Big{)} \leq N^\epsilon$$ \end{definition} From here on, we use the phrase $``$non-rigid$``$ for quasipolynomially non-rigid or strictly better than that. Otherwise, we explicitly mention the rigidity bound. \fi We start with a simple observation from \cite{DL20}. \vspace{-0.2cm} \begin{observation}[\cite{DL20}]\label{obs: scaling property} Let $M$ be an $n \times n$ matrix over a field $\F$, and let $D$ be an $n \times n$ diagonal matrix over $\F$. Then, for every choice of rank parameter $a$, $$ r_{DM}^{\F}(a)\leq r_{M}^{\F}(a) \, , \qquad \qquad and \qquad \qquad r_{MD}^{\F}(a)\leq r_{M}^{\F}(a) \,. $$ \end{observation} Let's analyse the DFT matrix $F_{q-1}$ over $\F_q$. We show that there is a way to get a Circulant matrix by scaling $F_{q-1}$ matrix over $\F_q$. This along with \autoref{obs: scaling property} links the rigidity of $F_{q-1}$ matrix over $\F_q$ with the rigidity of Circulant matrices. \begin{lemma} \label{clm: Scaling of Fourier and Circulant} It is possible to rescale the rows and columns of a DFT matrix $F_{q-1}$ over any finite field $\F_q$ to get a Circulant matrix $C_{q-1}$ over the extended field ${\mathbb{F}_{q^2}}$, where $q=p^a$. \end{lemma} \begin{comment} \begin{proof} Note that ${{\mathbb{F}}^*_q}$ is a multiplicative group and is also a cyclic group of order $q-1$. Let $g$ denote the generator of ${{\mathbb{F}}^*_q}$, which has order $q-1$. Thus, $g$ is a $(q-1)$'th primitive root of unity. Now we define $F_{q-1}$ using $g$ as follows: the rows and columns are indexed from $\{0,1, \ldots q-2\}$ where $F_{q-1}(i,j)$ is $g^{i.j}$. We wish to show that after suitable scaling the above defined DFT matrix $F_{q-1}$ becomes a Circulant one. Here, we divide the whole proof into two cases: when $q$ is odd and when $q$ is even. \vspace{0.5cm} \textbf{Case 1: $q$ odd} \vspace{0.2cm} Consider $\zeta$ such that $\zeta^2=g$. Scale $i$'th row by $\zeta^{{i}^2}$ and $j$'th column by $\zeta^{{j}^2}$ for each row $i$ and column $j$. Now let's look at the $(i,j)$'th entry of $F_{q-1}$ after performing the scaling operation. \vspace{0.1cm} The $(i,j)$'th entry in $F_{q-1}$ was originally $g^{i.j}$, which is now $\zeta^{2ij}$. After scaling, the row $i$ contributes $\zeta^{{i}^2}$ and the column $j$ contributes $\zeta^{{j}^2}$ to the $(i,j)$'th entry. Thus, the $(i,j)$'th entry in the scaled version of $F_{q-1}$ becomes $\zeta^{i^2+j^2+2ij}= \zeta^{(i+j)^2}$. \vspace{0.1cm} We claim this scaled matrix to be a Circulant matrix of order $q-1$. From the definition of the Circulant matrices \autoref{def: Circulant}, we need to check whether it satisfies the property, $C_n(i, j)= c_{{i+j}\mod n}$. In our case, we wish to prove, $\zeta^{(i+j+n)^2}= \zeta^{(i+j)^2}$ where $n=q-1$. \\ Note that $g^{(q-1)}= \zeta^ {2(q-1)}=1$. Thus, \begin{align*} ~~~~~ \zeta^{(i+j+q-1)^2} &= \zeta^{(i+j)^2}. \zeta^{(q-1)^2}. \zeta^{2.(i+j).(q-1)} \\ &=\zeta^{(i+j)^2}. \zeta^{2k.(q-1)}. \big{(}\zeta^{2(q-1)}\big{)}^{i+j} ~~~\textnormal{\big{(}As $q-1=2k$, $k \in \mathbb{N}${)}}\\ &=\zeta^{(i+j)^2}. \big{(}\zeta^{2(q-1)}\big{)}^k. \big{(}\zeta^{2(q-1)}\big{)}^{i+j}\\ &= \zeta^{(i+j)^2} ~~~~\text{ \big{(}Because, $\zeta^ {2(q-1)}=1${)}} \end{align*} Hence, for odd $q$, the scaled matrix is indeed a Circulant matrix of order $q-1$ over $\mathbb{F}_q$. \vspace{0.3cm} \textbf{Case 2: $q$ even} \vspace{0.2cm} In the previous case, if $\zeta \in \mathbb{F}_q$ then we don't really need to invoke the property that $q$ is odd. Because, $\zeta^{q-1}=1$ using Fermat's little theorem. Then the previous proof simply works for both odd and even $q$. Thus, if we can show that $\zeta \in \mathbb{F}_q $ when $q$ is even, then we are done. It is indeed always possible to find $\zeta \in \mathbb{F}_q $ such that $\zeta^2 = g$ when $q$ is even. Here, we use the fact that over fields of $\mathbb{F}_{q}$, $q= 2^k$ for some $k \in \mathbb{N}$, then $ \forall a \in \mathbb{F}_{q} $, $\exists b \in \mathbb{F}_{q} $ such that $b^2=a$. Basically, $\varphi: F_q \rightarrow F_q$ is a bijective map over finite fields, where $\varphi(x)= x^2$. \end{proof} \end{comment} The proof of the above lemma is almost identical to the proof of Claim 2.22 in \cite{ DL20} and hence omitted. We would like to emphasise one key point though. The scaling procedure involves working with an element $ \zeta$ s.t. $\zeta^2=g$, where $g$ is the generator of $\F^*_q$. Note that $\zeta$ may not always exist in the underlying field $\mathbb{F}_q$, when $q$ is odd. In that case, we perform a degree $2$ extension over the base field $\mathbb{F}_q$. After extension, we view $F_{q-1}$ over this extended field and perform appropriate scaling using $\zeta$ to get a Circulant matrix over $\F_{q^2}$. \begin{comment} Fortunately, these technical issues about small field extensions doesn't affect the Rigidity of a matrix by much, as the next lemma points out. \begin{lemma}\cite{DL20}(Lemma 7.20) Consider a finite field $\mathbb{F}_q$ and a finite extension of it denoted by $\mathbb{F}(q)[\alpha]$ where $\alpha \neq 0$. If the degree of the extension is $\hat{d}$, then for any matrix $M \in \mathbb{F}^{n \times n}_q$ and any positive integer $r$, $$ r^{\mathbb{F}_q}_{M}(\hat{d}r) \leq r^{\mathbb{F}_q[\gamma]}_{M}(r) $$ \end{lemma} Morally, the above lemma allows us to lift to a field extension and then argue that if a matrix is highly non-rigid over some low-degree extension then it also cannot be rigid over the base field. \end{comment} We now state the upper bound on the rigidity of Circulant matrices from \cite{DL20}. \begin{theorem}[Theorem $7.27$ in \cite{DL20}] \label{thm:Circulant rigidity} Let $0 < \epsilon < 0.01$ and $p$ be a fixed prime. For all sufficiently large $n$, if $C_n$ is an $n \times n$ Circulant matrix over $\F_p$ then, $${r}^{\mathbb{F}_p}_{C_n} \Big{(} \frac{n}{\exp(\epsilon^6\big{(}\log n)^{0.35}\big{)}} \Big{)} \leq n^{15\epsilon}$$ \end{theorem} We now state an upper bound on the rigidity of DFT matrices due to Dvir \& Liu which is the main takeaway of this subsection. \begin{theorem}[\cite{DL20, DLpersonal}]\label{cor: DFT rigidity} Let $0 < \epsilon < 0.01$, $p$ be a fixed prime and $c$ be a fixed constant. Let $a: \N \to \N$ be a function such that for all $n$, $a(n) \leq \log^c n$. Let $\{F_n\}_{n \in \N}$ be a family of matrices over $\overline{\F}_p$ such that for every $n$, $F_n$ is an $n \times n$ DFT Matrix with entries in the subfield $\F_{p^{a(n)}}=:\F_q$. Then, $${r}^{\mathbb{F}_q}_{F_n} \Big{(} \frac{n}{\exp(0.5 \cdot \epsilon^6\big{(}\log n)^{0.35}\big{)}} \Big{)} \leq 2\log_p{q} \cdot n^{15\epsilon}$$ \end{theorem} \begin{proof} We first obtain a Circulant matrix $C_n$ of order $n$ by scaling the DFT matrix (of order $n$) from \autoref{clm: Scaling of Fourier and Circulant}. As discussed earlier, the entries in the corresponding Circulant matrix potentially belongs to a degree $2$ extension over the field $\mathbb{F}_q$, that is $C_n\in \F_{q^2}^{n \times n}$. Let $\mathbb{F}_{q^2}[X]=\mathbb{F}_p[X]/\langle v(X)\rangle$ where $v(X)$ is a degree $2a$ irreducible polynomial over $\mathbb{F}_p$. Hence, $C_n$ can be expressed as $ C_n=C^{(0)}+C^{(1)}X+C^{(2)}X^2+ \ldots +C^{(2a-1)}X^{2a-1}$, where each $C^{(i)}$ is also a Circulant matrix of order $n$ over $\mathbb{F}_p$. This follows directly from the structure of Circulant matrices. Now we invoke the rigidity upper bound from \autoref{thm:Circulant rigidity} for each of the above Circulant matrix $C^{(i)}$ over the fixed field $\mathbb{F}_p$ . Due to the sub-additive property of rank and sparsity, the overall rank and sparsity of $C_n$ gets upper bounded by $2a$ times the rank and sparsity of each of these $C^{(i)}$'s. Hence, $${r}^{\mathbb{F}_q}_{F_n} \Big{(} \frac{2an}{\exp(\epsilon^6\big{(}\log n)^{0.35}\big{)}} \Big{)} \leq 2an^{15\epsilon}$$ On rewriting the above equation, $${r}^{\mathbb{F}_q}_{F_n} \Big{(} \frac{n}{\exp(\epsilon^6\big{(}\log n)^{0.35}- \log\log_pq^2\big{)}} \Big{)} \leq 2\log_pq \cdot n^{15\epsilon}$$ Since $a< \log^c n $, $\epsilon^6\log^{0.35} n \gg \log\log_pq^2$, this concludes the proof. \end{proof} \subsection {Non-rigidity of multidimensional DFT matrices} For our proof of \autoref{thm: Vandermonde rigidity}, we need an upper bound on the rigidity of the following high dimensional analog of DFT Matrices. \begin{definition} Let $m, d \in \N$, $\F$ be a field and $S \subset \F$ be a subset of cardinality $d$. The matrix $\mathcal{V}_{d,m}^{S}$ is a $d^m \times d^m$ matrix with rows labelled by all field elements of the product set $S^m = S \times S \times \cdots \times S$, and columns labelled by all monomials of individual degree at most $d-1$ in variables $\vecx = (x_1, x_2, \ldots, x_m)$. Such that, for $\veca \in S^m$ and a monomial $\vecx^{\vece}$ of individual degree at most $d-1$, the $(\veca, \vece)$'th entry of $\mathcal{V}_{d,m}^{S}$ equals $\veca^{\vece}$. \end{definition} For most of this section, we work with $\mathcal{V}_{d,m}^{S}$ for the setting where $\F$ is a finite field of size $q$, $d = q$ and $S = \F$. Moreover, when $S$ is clear from the context, we drop the superscript and denote $\mathcal{V}_{d,m}^{S}$ by $\mathcal{V}_{d,m}$. Note that for $m = 1$ the matrix $\mathcal{V}_{q,1}^{\F_q}$ is closely related to the DFT matrix of order $q-1$ over $\F_q$. To see this, note that if $g$ is a generator of the multiplicative group $\F^*_{q}$, then $g$ is trivially a primitive root of unity of order $q-1$ over $\F_q$. So, up to a permutation of rows, the rows of $\mathcal{V}_{q,1}^{\F_q}$ can be viewed as being indexed by $g^0, g^1, g^2, \ldots, g^{q-1}$, and the columns by $0, 1, \ldots, q-1$ in this order. Thus, if we discard the row indexed by $0$ and the column indexed by $q-1$ of $\mathcal{V}_{q,1}^{\F_q}$, what remains is precisely a DFT matrix of order $q-1$ over the field $\F_q$. The following lemma is an easy consequence of this observation together with the upper bound on rigidity of DFT matrices from \cite{DL20}. \begin{lemma}\label{lem: univariate vand. rigidity} Let $0 < \epsilon < 0.01$, and $\mathbb{F}_q$ be a finite field of size $q$. Let $V = \mathcal{V}_{q,1}^{\F_q}$. Then, for all sufficiently large $q $, $${r}^{\mathbb{F}_q}_{V} \Big{(} \frac{q}{\exp({\epsilon}^6 \big{(}\log q)^{0.34}\big{)}} \Big{)} \leq q^{16\epsilon}$$ \end{lemma} \begin{proof} Consider the $(q-1)\times (q-1)$ submatrix $\bar{V}$ of $V$ by deleting the row corresponding to the field element $0$ and the column corresponding to the monomial of degree ${q-1}$. $\bar{V}$ is a DFT matrix of order $q-1$ with the generator of the multiplicative group $\mathbb{F}^*_q$ being the primitive root of unity of order $q-1$. Note that setting $n=q-1$ and invoking the rigidity upper bound of DFT matrices from \autoref{cor: DFT rigidity}, we get, $${r}^{\mathbb{F}_q}_{\bar{V}} \Big{(} \frac{(q-1)}{\exp(0.5 \epsilon^6\big{(}\log (q-1))^{0.35}\big{)}} \Big{)} \leq 2\log_pq \cdot (q-1)^{15\epsilon}.$$ Before simplifying the above expression, let's see how this related to rigidity of ${V}$. In order to do that, we re-add the deleted row and column to $\bar{V}$. This process can potentially increase the rank of the augmented matrix by at most $2$. Also, note that $\log_pq \ll q^{\epsilon} $, thus we get $${r}^{\mathbb{F}_q}_{{V}} \Big{(} \frac{q}{\exp(\epsilon^6\big{(}(\log q)^{0.34}\big{)}} \Big{)} \leq q^{16\epsilon}.$$ \end{proof} In the rest of this section, we generalize \autoref{lem: univariate vand. rigidity} to obtain an upper bound on the rigidity of $\mathcal{V}_{q,m}^{\F_q}$ for larger values of $m$. The following simple observation is the first step in this direction. \begin{observation}{\label{obs:Kronecker product uni}} $ \mathcal{V}_{q, m}^{\F_q} =\footnote{This equality holds up to some row column permutation, which doesn't affect rigidity.} \left(\mathcal{V}_{q, 1}^{\F_q}\right)^{\otimes m} \,. $ \end{observation} We are now ready to state the main theorem of this section, where we prove a non-trivial upper bound on the rigidity of $\mathcal{V}_{q, m}^{\F_q}$ for an appropriate range of parameters. \begin{theorem}\label{thm: multi dim rigid upper bound} Let $0 < \epsilon < 0.01$, and $m \in \mathbb{N^+}$ be the given parameters and $\mathbb{F}_q$ be any finite field such that $m \leq q^\epsilon$. Then for large enough $q$ , we have $${r}^{\mathbb{F}_q}_{\mathcal{V}_{q, m}} \Big{(}\frac{q^m}{\exp{{({{{9 \epsilon^7}}} {(}\log q)^{0.34}m)}}}\Big{)} \leq q^{27\epsilon \cdot m}$$ \end{theorem} \begin{proof} From \autoref{obs:Kronecker product uni}, we have $$ \mathcal{V}_{q, m}^{\F_q} = \left(\mathcal{V}_{q, 1}^{\F_q}\right)^{\otimes m} \, . $$ From \autoref{lem: univariate vand. rigidity}, we have that $${r}^{\mathbb{F}_q}_{\mathcal{V}_{q,1}} \Big{(} \frac{q}{\exp( {{\epsilon}^6} \big{(}\log q)^{0.34}\big{)}} \Big{)} \leq q^{16\epsilon} \, . $$ Thus, $\mathcal{V}_{q,1}$ can be written as the sum of a matrix $L$ of rank at most $\frac{q}{\exp({{\epsilon}^6} \big{(}\log q)^{0.34}\big{)}}$ and a matrix $S$ with row sparsity at most $q^{16\epsilon}$. Thus, $\mathcal{V}_{q, m}^{\F_q}$ can be written as $$ \mathcal{V}_{q, m}^{\F_q} = (L_1+S_1) \otimes (L_2+S_2) \otimes \ldots \otimes (L_m+S_m) \, , $$ where each $L_i$ is a copy of $L$ and each $S_i$ is a copy of $S$ (they have been indexed for clarity of notation). The above Kronecker product has $2^m$ many terms, each term consisting of the Kronecker products of various copies of $L_i$ and $S_j$. We partition these summands into two groups based on the number of copies of $L$ participating in the Kronecker product. To complete the proof, we show that the sum of every term with many copies of $L$ is a matrix of \emph{not too high} rank and the sum of the remaining terms (that have few copies of $L$ and hence many copies of $S$) are non-trivially sparse. This would complete the proof of the theorem. We now fill in the details, which involve some slightly careful calculations to get the quantitative bounds stated in the theorem. We pick a threshold $t$ (to be set later) and collect all terms in the Kronecker product $$ \mathcal{V}_{q, m}^{\F_q} = (L_1+S_1) \otimes (L_2+S_2) \otimes \ldots \otimes (L_m+S_m) \, , $$ consisting of at most $t$ copies of $S$ for $t = m(1-10\epsilon)$. Let $\mathcal{L}$ be the sum of all such terms, and let $\mathcal{S}$ be the sum of the remaining terms. In the following two claims, we obtain an upper bound on the rank of $\mathcal{L}$ and the sparsity of $\mathcal{S}$. \begin{claim}\label{clm: rank upper bound} \[ \rank(\mathcal{L}) \leq \frac{q^m}{\exp(9 \epsilon^7(m\cdot (\log q)^{0.34}))} \, . \] \end{claim} \begin{claim}\label{clm: sparsity upper bound} Every row and column of $\mathcal{S}$ has at most $q^{27\epsilon \cdot m}$ non-zero entries. \end{claim} These bounds, together with the decomposition \[ \mathcal{V}_{q,m}^{\F_q} = \mathcal{L} + \mathcal{S} \, \] complete the proof of the theorem. \end{proof} We now prove \autoref{clm: rank upper bound} and \autoref{clm: sparsity upper bound}. \begin{proof}[Proof of \autoref{clm: rank upper bound}] From \autoref{lem: univariate vand. rigidity}, we know the rank of each $L_i$ is at most $\Big{(} \frac{q}{\exp \big{(}{{\epsilon}^6} {(}\log q)^{0.34}\big{)}} \Big{)}$ and the rank of each $S_i$ is at most $q$ since it is a $q \times q$ matrix. Moreover, the rank of a Kronecker product of matrices is the product of their ranks. Thus, we have \begin{align*} \rank(\mathcal{L}) &\leq \sum_{j=0}^{t-1} {{m} \choose {j} } {\Big{(}\frac{q}{2^\alpha}\Big{)}}^{m-j} q^j \quad \quad \quad \quad \quad \quad \text{(where $\alpha= {\epsilon}^6 \big{(}\log q)^{0.34}$)} \\ &= {\Big({}\frac {q}{2^\alpha}}\Big{)}^m \sum_{j=0}^{t-1}{{m} \choose {j} } 2^{\alpha j} \\ &\leq {\Big({}\frac {q}{2^\alpha}}\Big{)}^m 2^{\alpha t} \sum_{j=0}^{t-1}{{m} \choose {j} } \\ & \leq {\Big({}\frac {q}{2^\alpha}}\Big{)}^m 2^{\alpha t} \cdot 2^m \quad \quad \quad \quad \quad \quad \quad \\ &= {({} {q}}{)}^m 2^{\alpha(t-m) + m} \, . \end{align*} We now obtain an upper bound on the quantity $ 2^{\alpha(t-m)+ m}$ to complete the proof of the claim. \begin{align*} 2^m 2^{\alpha(t-m)} &\leq 2^{(-10 \epsilon \alpha + 1 )m} \quad \quad \quad \quad \quad \text{(since $t = m(1-10\epsilon $))}\\ &\leq 2^{-\alpha \cdot 9 \epsilon m} \quad \quad \quad \quad \quad \text{since $\alpha \cdot 9 \epsilon > 1$ for all large enough $q$}\\ \end{align*} Thus, the rank of $\mathcal{L}$ is at most ${q^m}\cdot {2^{-9 \epsilon \alpha m}}$, which by the choice of $\alpha$ gives \[ \rank(\mathcal{L}) \leq \frac{q^m}{\exp( 9 \epsilon^7 m\cdot (\log q)^{0.34})} \, . \] \iffalse \CKMnote{I changed the later calculation part as I thought it was not very accurate. The following way looks cleaner to me. I have commented out the previous calculation, which you can also check.} \begin{align*} \frac{q^m}{2^{{\alpha}(m-t)}}t \Big{(}\frac{m}{t}\Big{)}^t e^t &\leq \frac{q^m}{2^{{\alpha}(m-t)}} \Big{(}\frac{m^t}{t^{t-1}}\Big{)} e^t \\& \leq \frac{q^m}{2^{{\alpha}(m-t)}} \Big{(}\frac{2^{t \log m}}{2^{(t-1)\log t}}\Big{)} 2^{2t}\\& \leq \frac{q^m}{2^{{\alpha}(m-t)- t \log m + \frac{t}{2} \log t -2t}} \\&= \frac{q^m}{2^{{\alpha}(m-\epsilon_2m)- \epsilon_2m \log m + \frac{\epsilon_2m}{2} \log \epsilon_2m -2\epsilon_2m}} \\&= \frac{q^m}{2^{{\alpha}m(1-\epsilon_2)- \epsilon_2m \log m + \frac{\epsilon_2m}{2} \log \epsilon_2m -2\epsilon_2m}} \\&= \frac{q^m}{2^{{\alpha}m \big{(}(1-\epsilon_2)- \frac{\epsilon_2\log m }{\alpha}+ \frac{\epsilon_2}{2\alpha} \log \epsilon_2m -\frac{2\epsilon_2}{\alpha}\big{)}}} \\&= \frac{q^m}{2^{{\alpha}m \big{(}(1-\epsilon_2)- \frac{\epsilon_2\log m }{\alpha}+ \frac{\epsilon_2}{2\alpha}(\log \epsilon_2 + \log m) -\frac{2\epsilon_2}{\alpha}\big{)}}} \\&= \frac{q^m}{2^{{\alpha}m \big{(}(1-\epsilon_2)- \frac{\epsilon_2\log m }{2\alpha}+ \frac{\epsilon_2}{2\alpha}(\log \epsilon_2) -\frac{2\epsilon_2}{\alpha}\big{)}}} \\& = \frac{q^m}{2^{{\alpha}m \big{(}1 + \frac{\epsilon_2}{2\alpha}(\log \epsilon_2) -(\epsilon_2+ \frac{\epsilon_2\log m }{2\alpha} +\frac{2\epsilon_2}{\alpha})\big{)}}} \\&= \frac{q^m}{2^{{\tilde{\epsilon}^6 \big{(}\log q)^{0.35}}m \big{(}1 + \frac{\epsilon_2}{2 \tilde{\epsilon}^6 {(}\log q)^{0.35}}(\log \epsilon_2) -(\epsilon_2+ \frac{\epsilon_2\log m }{2\tilde{\epsilon}^6 {(}\log q)^{0.35}} +\frac{2\epsilon_2}{\tilde{\epsilon}^6 {(}\log q)^{0.35}})\big{)}}} \\& \leq \frac{q^m}{2^{\Theta{({\tilde{\epsilon}^6 {(}\log q)^{0.35}}m)}}} ~~~~~~~~\text{\big{(}For $q= m^{\frac{log^4 m}{{\epsilon_3}^5}}$\big{)}} \end{align*} \fi \end{proof} \begin{proof}[Proof of \autoref{clm: sparsity upper bound}] This proof also proceeds along the lines of the proof of \autoref{clm: rank upper bound}, and involves similar calculations. We just note that every summand in $\mathcal{S}$ involves at least $(m - t)$ sparse matrices in the Kronecker product. Moreover, we rely on the basic fact that the row/column sparsity of a Kronecker product of matrices is equal to the product of the row/column sparsity of each of the matrices in the product. Let $q'= q^{16\epsilon}$ denote the row sparsity of every matrix $S_i$. For each $L_i$, we use the obvious upper bound of $q$ on its row sparsity for our estimate. \begin{align*} \mathsf{RowSparsity}(\mathcal S) &\leq \sum_{j=t}^{m} {{m} \choose {j} }(q')^j {(q)}^{m-j} \\ &= q^m \cdot \sum_{j=t}^m {{m} \choose {j}} \Big{(}{\frac{q'}{q}} \Big{)}^j \\ &\leq q^m \sum_{j=t}^m m^j \Big{(}{\frac{q'}{q}} \Big{)}^j \\ &\leq 2.q^m \Big{(}{\frac{q'm}{q}} \Big{)}^t \quad \quad \quad \quad \quad \quad \text{(since $q'm/q < 1/2$)} \, . \\ &\leq q^m \Big{(}{\frac{1}{q^{1-16 \epsilon- \log_q m}}} \Big{)}^t \, \\ &\leq q^m \Big{(}{\frac{1}{q^{1-17 \epsilon}}} \Big{)}^t \quad \quad \quad \quad \quad \quad \text{(we have $\frac{\log m}{\log q} < \epsilon$)} \, \end{align*} Using $t = m(1-10\epsilon)$, we get \begin{equation*} \mathsf{RowSparsity}(\mathcal S) \leq q^{m(1-(1-10 \epsilon)(1-17 \epsilon))} \leq q^{(10 \epsilon+ 17 \epsilon)m} \leq q^{27 \epsilon \cdot m} \,. \end{equation*} An almost identical argument also bounds the column sparsity, which completes the proof of the claim. \iffalse Set $t= \epsilon_2m$, where $\epsilon_2=0.01$ and $q= m^{\frac{log^4 m}{{\epsilon_3}^5}}$ , $0 \leq \epsilon_3 \leq 0.0001$. Note, $\gamma=2^{\frac{1}{t}}, q'= q^{15\epsilon}$. \begin{align*} q^m {\Big{(}{\frac{q'm \gamma}{q}} \Big{)}}^t = q^m {\Big{(}{ q^{15\epsilon-1} m \gamma } \Big{)}}^t &\leq q^m{\Big{(}{ q^{15\epsilon-1}. \frac{\epsilon_3}{\log^{0.2}q} \gamma} \Big{)}}^t \\& \leq q^m{\Big{(}{ q^{15\epsilon-1}. q^{\frac{\epsilon_3}{\log^{0.2}q}} .{2^{-\epsilon_2}}^{q^{\frac{\epsilon_3}{\log^{0.2}q}}}} \Big{)}}^t \\& \leq q^m{\Big{(}{ q^{15\epsilon-1+ \frac{\epsilon'_3}{\log^{0.2}q}} } \Big{)}}^t ~~~~\text{where $\epsilon'_3= \epsilon_3 {2^{-\epsilon_2}}^{q^{\frac{\epsilon_3}{\log^{0.2}q}}}$} \\& \leq q^m{\Big{(}{ q^{15\epsilon-1+ \frac{\epsilon'_3}{\log^{0.2}q}} } \Big{)}}^t \\& =q^m{\Big{(}{ q^{15\epsilon-1+ \beta } } \Big{)}}^{\epsilon_2m} ~~~~~\text{ where $\beta= \frac{\epsilon'_3}{\log^{0.2}q} <<1$ } \\&= q^m. q^{-(1-15\epsilon\epsilon_2-\beta\epsilon_2)m} \\&= q^{m(1-\delta)} ~~~~\text {where $\delta=(1-15\epsilon\epsilon_2-\beta\epsilon_2)> 0$} \end{align*} \fi \end{proof} \subsection{Non-rigidity of Vandermonde matrices}\label{subsec: Van non-rigid} In this section, we prove \autoref{thm: Vandermonde rigidity}. \begin{comment} \end{comment} As discussed in \autoref{sec: rigidity proof overview}, using the algorithm for multivariate multipoint evaluation, we write (any) Vandermonde matrix as the product of a sparse matrix and a multidimensional DFT matrix. Then, we invoke the rigidity upper bound for multidimensional DFT matrices in \autoref{thm: multi dim rigid upper bound}. This together with the fact that a product of sparse and non-rigid matrix continues to be non-rigid with slightly diminished parameters completes the proof. We now fill in the details. \begin{proof}[Proof of \autoref{thm: Vandermonde rigidity}] We start by setting up some necessary notation. Let $d, m$ be parameters, chosen as follows. \begin{itemize} \item $m := \ceil{\log^{0.3}n}$ \item $d$ is set to be the smallest integer such that $d^m > n$ \end{itemize} Clearly, $d$ can be taken to be at most $n^{1/m} + 1$. For this choice of $d, m$, we note that $d^m$ is at least $n$ and most $(n^{1/m} + 1)^m \leq 2n$. Let $\alpha_0, \alpha_1, \ldots, \alpha_{n-1}$ be the generators of the Vandermonde matrix $V_n$ , i.e., $V_n(i, j) = \alpha_i^j$. For every $i \in \{0,1, \ldots, n-1\}$, let $\pmb\alpha_i = (\alpha_i, \alpha_i^d, \ldots, \alpha_i^{d^{m-1}})$. For simplicity, we use $a$ to denote $a(n)$. Let $b$ be the smallest integer such that $padm \geq q_0 = p^b > adm$. Let $W$ be the $p^{bm} \times p^{bm}$ matrix with its rows indexed by vectors in $\F_{p^b}^m$ and the columns indexed by all $m$-variate monomials of individual degree at most $q_0 - 1$ and the $(\vecc, \vece)$ entry of $W$ is equal to $\vecc^{\vece}$. Moreover, let $\tilde{V}$ be the matrix with rows indexed by $\{0, 1, \ldots, n-1\}$ and columns indexed by all $m$-variate monomials of individual degree $d-1$ and the $(i, \vece)$ entry being equal to $\pmb\alpha_i^{\vece}$. To see the connection between the matrices $V_n$, $\Tilde{V}$ and $W$, let us try to understand the action of $V_n$ on a vector. Semantically, we can view this $n$ dimensional vector as the coefficient vector of a univariate polynomial $f$ of degree at most $n-1$ and thus the matrix vector product $V_n\cdot \operatorname{Coeff}(f)$ is precisely the evaluation vector of $f$ on inputs $\alpha_0, \alpha_1, \ldots, \alpha_{n-1}$. Recall the inverse Kronecker map $\psi_{d,m}$ from \autoref{def:inverse-kronecker}, and let $F$ be an $m$-variate polynomial of degree at most $d-1$ in each variable such that $F = \psi_{d,m}(f)$. For this to make sense, recall that by our choice of parameters $d^m \geq n$. Now, it follows from these definitions that for every $i \in \{0, 1, \ldots, n-1\}$, $f(\alpha_i) = F(\pmb\alpha_i)$. Moreover, the coefficient vectors of $f$ and $F$ are closely related. In fact, if $d^m = n$, then these coefficient vectors are exactly the same (even though the natural labelling of the coordinates of $\operatorname{Coeff}(f)$ is via univariate monomials of degree at most $n-1$ and that of $\operatorname{Coeff}(F)$ is via $m$-variate monomials of individual degree at most $d-1$). If $d^m > n$, then we have to append some zeroes to the coefficient vector $f$ to obtain the coefficient vector of $F$. In other words, \[ \operatorname{Coeff}(F) = \Tilde{I} \cdot \operatorname{Coeff}(f) \, , \] where $\Tilde{I}$ is a $d^m \times n$ matrix with the top $n \times n$ submatrix being the identity matrix and the remaining $d^m - n$ rows being all zeroes. Moreover, \[ \Tilde{V} \cdot \operatorname{Coeff}(F) = V_n \cdot \operatorname{Coeff}(f)\, . \] Now we recall Algorithm \autoref{algo:polynomial-evaluation-v1} for multivariate multipoint evaluation and invoke it for the polynomial $F$ and evaluation points $\pmb\alpha_0, \pmb\alpha_1, \ldots, \pmb\alpha_{n-1}$. The algorithm first evaluates $F$ on the product set $\F_{q_0}^m$ in the preprocessing phase. In other words, it computes the vector $W\cdot \operatorname{Coeff}(F)$. Then, for every $i \in \{0, 1, \ldots, n-1\}$, the value of $F$ on $\pmb\alpha_i$ is computed by some \emph{local} computation consisting of looking at the univariate polynomial $h_i(t)$ obtained as a restriction of $F$ on a curve of degree at most $a-1$ through $\pmb\alpha_i$, then interpolating $h_i$ using the already available values of $F$ on $\F_{q_0}^m$, and then evaluating $h_i$ on an appropriate input to get $F(\pmb\alpha_i)$. In other words, $F(\pmb\alpha_i)$ is obtained by taking an appropriate weighted linear combination of the value of $F$ on a specific subset of points in $\F_{q_0}^m$ of size at most $adm$. Thus, for every $i \in \{0, 1, \ldots, n-1\}$, there is a vector $\tau_i$ of length $q_0^m$ with entries in the field $\F_{p^{ab}}$\footnote{Recall that for technical reasons, we have to work in the field $\F_{p^{ab}}$ in Algorithm \autoref{algo:polynomial-evaluation-v1} even though the inputs are in $\F_{p^a}$. } such that \[ F(\pmb\alpha_i) = \ideal{\tau_i, W\cdot \operatorname{Coeff}(F)} \, . \] If we collect the vectors $\tau_0, \tau_1, \ldots, \tau_{n-1}$ into an $n \times q_0^m$ matrix $\Gamma$, then we have \[ \Tilde{V} \cdot \operatorname{Coeff}(F) = \Gamma \cdot W \cdot \operatorname{Coeff}(F) \, . \] Recalling the relation between $F$, $f$ and between $V_n$, $\Tilde{V}$, we get that \[ V_n \cdot \operatorname{Coeff}(f) = \Tilde{V} \cdot \operatorname{Coeff}(F) = \Gamma \cdot W \cdot \operatorname{Coeff}(F) \, , \] or, using $\operatorname{Coeff}(F) = \Tilde{I} \cdot \operatorname{Coeff}(f)$, we get \[ V_n \cdot \operatorname{Coeff}(f) = \left( \Gamma \cdot W \cdot \tilde{I}\right) \cdot \operatorname{Coeff}(f) \, . \] Recall that we started with $\operatorname{Coeff}(f)$ being an arbitrary vector. Thus, we have \[ V_n = \Gamma \cdot W \cdot \tilde{I} \, . \] Now, to obtain a decomposition of $V_n$ as the sum of a sparse and a low rank matrix, the idea is to invoke \autoref{thm: multi dim rigid upper bound} on $W$, and combine the decomposition obtained together with the sparsity of $\Gamma$ and $\Tilde{I}$ to obtain a similar decomposition for $V_n$. To invoke \autoref{thm: multi dim rigid upper bound}, we must satisfy all the constraints on the parameters present there. To this end, we note that \begin{itemize} \item $q_0 > adm$ and thus is large enough \item $\log m / \log q_0 < \epsilon$. This is true since $\log m / \log q_0 < \log m / \log d < \frac{0.3 \log\log n}{\log^{0.7} n } \ll \epsilon$. \end{itemize} Now from \autoref{thm: multi dim rigid upper bound}, we have that $W$ can be written as the sum of matrices $L$ and $S$ where the row and column sparsity of $S$ is at most $q_0^{27\epsilon m}$ and the rank of $L$ can be upper bounded as follows. \begin{align*} \rank(L) \leq \frac{{q^m_0}}{\exp(9\epsilon^7(\log q_0)^{0.34}m)} &\leq \frac{(padm)^m}{\exp(9\epsilon^7(\log q_0)^{0.34}m)} \, . \end{align*} Note that by our choice of parameters, $(pam)^m \ll 2^{\log^{0.4}n}$ and ${m\log^{0.34} q_0} \geq (\log n)^{{(0.34)}{(0.70)}+0.3} \geq {\log^{(0.54)} n}$. Also, since $2^{(\epsilon^7m\log^{0.34} q_0)} \gg (pam)^m$, we get \[ \rank(L) \leq \frac{{q^m_0}}{\exp(9\epsilon^7(\log q_0)^{0.34}m)} \leq \frac{n}{\exp( \Omega(\epsilon^7\log^{0.5} n)\big{)}} \, . \] Now, we have \[ V_n = \Gamma \cdot W \cdot \Tilde{I} = \Gamma \cdot (L + S) \cdot \Tilde{I} \, , \] or after simplification, \[ V_n = (\Gamma \cdot L \cdot \Tilde{I}) + (\Gamma \cdot S \cdot \Tilde{I})\, . \] Clearly, the rank of $(\Gamma \cdot L \cdot \Tilde{I})$ is at most the rank of $L$ which as we calculated above is at most $\frac{n}{\exp( \Omega(\epsilon^7\log^{0.5} n)\big{)}}$. The row sparsity of $(\Gamma \cdot S \cdot \Tilde{I})$ is at most the product of the row sparsity of $\Gamma$ and the row sparsity of $S$ \footnote{$\Tilde{I}$ has row and column sparsity $1$, so it does not affect the calculations.} and thus is at most \begin{align*} (adm)(q^{27\epsilon \cdot m}_0) &\leq (padm) ((q_0)^m)^{27\epsilon} \\ &= p^{27\epsilon\cdot m+1} \cdot a^{27\epsilon\cdot m+1} n^{27\epsilon} m^{(27\epsilon \cdot m+1)}d \end{align*} Note that by our choice of parameters, $d < n^{\epsilon}$, $a^{27\epsilon\cdot m+1} < n^\epsilon$, $p^{27\epsilon\cdot m+1} < n^\epsilon$ and $m^{(27\epsilon \cdot m+1)} < n^{\epsilon}$, and thus, the row sparsity of $(\Gamma \cdot S \cdot \Tilde{I})$ is at most $n^{31 \epsilon}$. Thus, $V_n$ can be written as the sum of a matrix of row sparsity\footnote{We emphasize the point that we only deal with row sparsity here and \emph{not both row and column sparsity}.} at most $n^{31 \epsilon}$ and rank at most $\frac{n}{\exp( \Omega(\epsilon^7\log^{0.5} n)\big{)}}$ as claimed in the theorem. \end{proof} \iffalse From \autoref{thm: } Now let us consider the classical univariate multipoint evaluation problem. The problem is as stated below: \\ \textbf{Input:} A univariate polynomial $f(x)\in\F_q[x]$ with degree at most $n-1$ and $n$ points $\alpha_1,\ldots,\alpha_n$ from $\F_q$. \textbf{Output:} $f(\alpha_1),\ldots,f(\alpha_n)$\\ Let $f= f_0+f_1x+f_2x^2+ \ldots \ldots +f_{n-1}x^{n-1}$, where $ \forall i, f_i \in \F_q$. Then, our aim is to output this matrix vector product, $$\begin{pmatrix} 1 ~~ \alpha_1~~ {\alpha_1}^2 ~~ ~~ ~~\ldots~~ {\alpha_1}^{n-1}\\ 1 ~~ \alpha_2~~ {\alpha_2}^2 ~~ ~~ ~~\ldots~~ {\alpha_2}^{n-1}\\\\ \vdots ~~~~\vdots ~~~~~~~~~\ddots ~~~~\vdots \\ 1 ~~ \alpha_{n}~~ {\alpha_{n}}^2 ~~ ~~ ~~\ldots~~ {\alpha_{n}}^{n-1}\\ \end{pmatrix} \begin{pmatrix} f_0 \\ f_1\\ \vdots \\\\ f_{n-1} \end{pmatrix}= \begin{pmatrix} f(\alpha_1) \\ f(\alpha_2)\\ \vdots \\\\ f(\alpha_n) \end{pmatrix}$$ $$~~~~~~~~~~~~~~~~~~~~~\boldsymbol{v_{n \times n}}~~~~~~~~~~~~~~~~~~\boldsymbol{{\hat{f}}_{n \times 1}}~~~~~~~~ \boldsymbol{{f(\alpha)}_{n \times 1}}$$ We will reduce the above univariate multipoint evaluation to the multivariate multipoint evaluation and then invoke \autoref{}. In order to do that, the first step would be to find a suitable multivariate polynomial and its corresponding evaluation points, which in particular maps to the univariate evaluations. We do this using inverse Kronecker mapping. Given a univariate polynomial $f(x) \in \F_q[x]$ of degree at most $n-1$ and $n$ points $\alpha_1,\ldots,\alpha_n$ from $\F_q$; we wish to find a multivariate polynomial $\tilde{f}(y_0, y_2, \ldots, y_{m-1})$ of individual degree at most $d-1$ such that $f(\alpha_i)= \tilde{f}(\tilde{\alpha_{i}})$. We do it as follows: \\ For $d^m \geq n$, consider the monomial mapping, $$\psi: f_kx^k \longmapsto \tilde{f_k}{y_0}^{e_0} {y_1}^{e_1} \ldots {y_{m-1}}^{e_{m-1}}$$ where $k= e_0 d^0+ e_1d^1+ e_2 d^2+ \ldots \ldots +e_{m-1}d^{m-1}$ and $f_k= \tilde{f_{k}}$. Note that this represents the number $k$ in its $d$-ary form. We use $\psi$ to map the monomials of $f(x)$ to the monomials of $\tilde{f}(y_0, y_2, \ldots, y_{m-1})$. As a consequence of this, evaluation of $f(x)$ at any given point $\alpha \in \F_q$, that is $f(\alpha)= \tilde{f}(\alpha^{d^0}, \alpha^{d^1}, \ldots \alpha^{d^{m-1}} )$. We denote $\tilde{\alpha}=(\alpha^{d^0}, \alpha^{d^1}, \ldots \alpha^{d^{m-1}} )$. The proof of correctness is immediate from the construction of $\psi$ itself. Note that, the coefficients of $f(x)$ and the coefficients of $\tilde{f}(y_0, y_2, \ldots, y_{m-1})$ are identical as $\psi$ doesn't affect the coefficients. Now, we invoke \autoref{} with input polynomial $\tilde{f}(y_0, y_1, \ldots, y_{m-1})$ along with the points $\tilde{\alpha_{1}}, \tilde{\alpha_{2}}, \ldots \tilde{\alpha_{n}}$ from ${\F^m_q}$. Each step in \autoref{} can be seen as a linear transformation. There, we first evaluate the polynomial $\tilde{f}(y_0, y_1, \ldots, y_{m-1})$ over the grid $\F^m_{p^b}$. This is essentially the matrix vector product, $$ \begin{blockarray}{ccccc} &\mu_1 &\ldots & \mu_j & \ldots \mu_{d^m} \\ \begin{block}{c(cccc)} \beta_1 & & & & \\ \vdots & \vdots & \vdots &\vdots & \vdots \\ \beta_i & &\ldots &(\mu_j(\beta_{i})) & \ldots \\ \vdots & & & & \\ & \vdots& \vdots & \vdots & \vdots\\ \beta_{p^{bm}} & & & & \\ \end{block} \end{blockarray}_{p^{bm} \times d^m} \begin{pmatrix} \tilde{f_0} \\ \tilde{f_1}\\ \vdots \\\\ \tilde{f}_{d^m-1} \end{pmatrix}_{d^m \times 1} = \begin{pmatrix} \tilde{f}(\beta_1) \\ \tilde{f}(\beta_2)\\ \vdots \\\\ \tilde{f}(\beta_{p^{bm}}) \end{pmatrix}_{p^{bm} \times 1}$$ Here, $\mu_j(\beta_i)$ represents the evaluation of the $j$'th monomial $\mu_j$ on $i$'th field element $\beta_i$. This is essentially a multidimensional DFT matrix with dimension ${p^{bm} \times d^m}$. This is equivalent to the pre-processing step of our MME algorithm \autoref{}. \VBnote{Dont use "essentially" and morally // instead say: Using this one can observe that or using this that follows} The next step in the algorithm is to find the restricted polynomial of $\tilde{f}$ on the curve defined with respect to some $\tilde{\alpha}_i$, that is a univariate polynomial of degree at most {$`adm$'}. For that, we use some local computations like interpolation and then evaluate this univariate polynomial at some appropriate point to get the final outcome. Morally, all these steps can be done by some appropriate linear combination. Hence, $$ \begin{pmatrix} c_0, c_1, \ldots \ldots, c_{p^{bm}} \end{pmatrix}_{1 \times p^{bm}} \begin{blockarray}{ccccc} &\mu_1 &\ldots & \mu_j & \ldots \mu_{d^m} \\ \begin{block}{c(cccc)} \beta_1 & & & & \\ \vdots & \vdots & \vdots &\vdots & \vdots \\ \beta_i & &\ldots &(\mu_j(\beta_{i})) & \ldots \\ \vdots & & & & \\ & \vdots& \vdots & \vdots & \vdots\\ \beta_{p^{bm}} & & & & \\ \end{block} \end{blockarray}_{p^{bm} \times d^m} \begin{pmatrix} \tilde{f_0} \\ \tilde{f_1}\\ \vdots \\\\ \tilde{f}_{d^m-1} \end{pmatrix}_{d^m \times 1} = \tilde{f}(\tilde{\alpha}_i) $$ where $c_i \in \F_q$ and $|\{c_i \mid c_i \neq 0 \}| < adm$. $$ \begin{pmatrix} c_{11}, c_{12}, \ldots \ldots, c_{1p^{bm}}\\ c_{21}, c_{22}, \ldots \ldots, c_{2p^{bm}} \\ ~~~~~~~~\vdots~~~~~\\ c_{n1}, c_{n2}, \ldots \ldots, c_{np^{bm}} \end{pmatrix}_{n \times p^{bm}} \begin{blockarray}{ccccc} &\mu_1 &\ldots & \mu_j & \ldots \mu_{d^m} \\ \begin{block}{c(cccc)} \beta_1 & & & & \\ \vdots & \vdots & \vdots &\vdots & \vdots \\ \beta_i & &\ldots &(\mu_j(\beta_{i})) & \ldots \\ \vdots & & & & \\ & \vdots& \vdots & \vdots & \vdots\\ \beta_{p^{bm}} & & & & \\ \end{block} \end{blockarray}_{p^{bm} \times d^m} \begin{pmatrix} \tilde{f_0} \\ \tilde{f_1}\\ \vdots \\\\ \tilde{f}_{d^m-1} \end{pmatrix}_{d^m \times 1} = \begin{pmatrix} \tilde{f}(\tilde{\alpha_1}) \\ \tilde{f}(\tilde{\alpha_2})\\ \vdots \\\\ \tilde{f}(\tilde{\alpha_n}) \end{pmatrix}_{n \times 1} $$ But, $\tilde{f}(\tilde{\alpha_i})= f(\alpha_i),$ $$ \begin{pmatrix} \tilde{f}(\tilde{\alpha_1}) \\ \tilde{f}(\tilde{\alpha_2})\\ \vdots \\\\ \tilde{f}(\tilde{\alpha_n}) \end{pmatrix}_{n \times 1}= \begin{pmatrix} {f}({\alpha_1}) \\ {f}({\alpha_2})\\ \vdots \\\\ {f}({\alpha_n}) \end{pmatrix}_{n \times 1}= \begin{pmatrix} 1 ~~ \alpha_1~~ {\alpha_1}^2 ~~ ~~ ~~\ldots~~ {\alpha_1}^{n-1}\\ 1 ~~ \alpha_2~~ {\alpha_2}^2 ~~ ~~ ~~\ldots~~ {\alpha_2}^{n-1}\\\\ \vdots ~~~~\vdots ~~~~~~~~~\ddots ~~~~\vdots \\ 1 ~~ \alpha_{n}~~ {\alpha_{n}}^2 ~~ ~~ ~~\ldots~~ {\alpha_{n}}^{n-1}\\ \end{pmatrix} \begin{pmatrix} f_0 \\ f_1\\ \vdots \\\\ f_{n-1} \end{pmatrix} $$ \begin{small} {$$\!\!\!\!\!\!\!\!\!\! \begin{pmatrix} 1 ~~ \alpha_1~~ {\alpha_1}^2 ~~ ~~ ~~\ldots~~ {\alpha_1}^{n-1}\\ 1 ~~ \alpha_2~~ {\alpha_2}^2 ~~ ~~ ~~\ldots~~ {\alpha_2}^{n-1}\\\\ \vdots ~~~~\vdots ~~~~~~~~~\ddots ~~~~\vdots \\ 1 ~~ \alpha_{n}~~ {\alpha_{n}}^2 ~~ ~~ ~~\ldots~~ {\alpha_{n}}^{n-1}\\ \end{pmatrix} \begin{pmatrix} f_0 \\ f_1\\ \vdots \\\\ f_{n-1} \end{pmatrix}= \begin{pmatrix} c_{11}, c_{12}, \ldots \ldots, c_{1p^{bm}}\\ c_{21}, c_{22}, \ldots \ldots, c_{2p^{bm}} \\ ~~~~~~~~\vdots~~~~~\\ c_{n1}, c_{n2}, \ldots \ldots, c_{np^{bm}} \end{pmatrix} \!\!\!\!\!\!\begin{blockarray}{ccccc} &\mu_1 &\ldots & \mu_j & \ldots \mu_{d^m} \\ \begin{block}{c(cccc)} \beta_1 & & & & \\ \vdots & \vdots & \vdots &\vdots & \vdots \\ \beta_i & &\ldots &(\mu_j(\beta_{i})) & \ldots \\ \vdots & & & & \\ & \vdots& \vdots & \vdots & \vdots\\ \beta_{p^{bm}} & & & & \\ \end{block} \end{blockarray} \! \begin{pmatrix} \tilde{f_0} \\ \tilde{f_1}\\ \vdots \\\\ \tilde{f}_{d^m-1} \end{pmatrix} = \!\!\begin{pmatrix} \tilde{f}(\tilde{\alpha_1}) \\ \tilde{f}(\tilde{\alpha_2})\\ \vdots \\\\ \tilde{f}(\tilde{\alpha_n}) \end{pmatrix}$$ } \end{small} \begin{proof}[Proof of \autoref{thm: Vandermonde rigidity}] We know that any Vandermonde matrix can be decomposed into a product of a sparse(S) and multidimensional DFT (mDFT) matrix. Using the rigidity upper bound of multidimensional DFT from \autoref{thm: multi dim rigid upper bound}, we can write the mDFT matrix as a sum of low rank and sparse matrix, that is $l_1+s_1$, where $l_1$ represents its low rank component and $s_1$ represents the sparse component. We know that the matrix(S) has sparsity $s \leq kdm$. Thus, in their product, $s(l_1+s_1)= sl_1+ss_1$; the component $sl_1$ contributes to the overall low rank part and $ss_1$ contributes to the overall sparsity part. \paragraph{Rank Calculation:} As mentioned above, the component $sl_1$ represents the overall low rank part. We upper bound the rank of the Vandermonde matrix by invoking the multidimensional DFT rigidity upper bound with appropriate range of parameters. Set $q_o=p^b > k(d-1)m$. Now we invoke the multidimensional DFT rigidity bound for size ${q^m_o}$. \vspace{0.1cm} Note that we need $d^m>n$ for our construction. Thus we set, $m=\log^{0.3}n$ and $d=2^{log^{0.71} n}$. Note that to invoke \autoref{thm: multi dim rigid upper bound} we must satisfy all of those constraints present there, which has been mentioned below, \begin{itemize} \item $pkdm > 2^{1/\epsilon^{23}}$. This is satisfied if $n > 2^{1/\epsilon^{33}}$. \item $\log m / \log q_o < \epsilon$. Note that, $\log m / \log q_o < \log m / \log d < \frac{0.3 \log\log n}{0.71 \log n } < \epsilon$ when $n > 2^{1/\epsilon^{33}}$. \end{itemize} Now we invoke the multidimensional DFT rank bound for ${q^m_o}$, \begin{align*} \frac{{q^m_o}}{\exp(9\epsilon^7(\log q_o)^{0.34}m)} &\leq \frac{(pkdm)^m}{\exp(9\epsilon^7(\log q_o)^{0.34}m)} \\ &\leq \frac{n(km)^m}{\exp(9\epsilon^7(\log q_o)^{0.34}m)} \end{align*} Note that, $(pkm)^m \ll 2^{log^{0.4}n}$ and ${m\log^{0.34} q_o} \geq (\log n)^{{(0.34)}{(0.71)}+0.3} \geq {\log^{(0.5414)} n}$ \vspace{0.2cm} Because $2^{(\epsilon^7m\log^{0.34} q_o)} \gg (pkm)^m$, we get $$\frac{{q^m_o}}{\exp(9\epsilon^7(\log q_o)^{0.34}m)} = \frac{n}{\exp( \Omega(\epsilon^7\log^{0.5} n)\big{)}}.$$ \paragraph{Sparsity Calculation:} Recall that $ss_1$ component represents the overall sparse component. When multiply the two sparse matrices the overall sparsity multiplies. Here, $s \leq kdm$ and $s_1 \leq q^{27\epsilon \cdot m}_o$ Thus, the overall sparsity, \begin{align*} (kdm)(q^{27\epsilon \cdot m}_o) &\leq (pkdm) ((q_o)^m)^{27\epsilon} \\ &= p^{27\epsilon\cdot m+1} \cdot k^{27\epsilon\cdot m+1} n^{27\epsilon} m^{(27\epsilon \cdot m+1)}d \end{align*} Note that, $d < n^{\epsilon}$, $k^{27\epsilon\cdot m+1} < n^\epsilon$, $p^{27\epsilon\cdot m+1} < n^\epsilon$ and $m^{(27\epsilon \cdot m+1)} < n^{\epsilon}$ for $n > 2^\frac{1}{\epsilon^{33}}$, and thus, $$(kdm)(q^{27\epsilon \cdot m}_o)< n^{31 \epsilon}$$ \iffalse \begin{itemize} \item We need $d^m > n$, \item We will invoke multidimensional DFT for $q_o=p^b > kdm> k(d-1)m$. \item pick $m= \log^{0.3} n$ and $d=2^{log^{0.71} n}$ (we have to ensure these are integers) \CKMnote{We can possibly take $m= \Theta(\log^{0.3}n)$ and $d=\Theta(2^{log^{0.71} n})$}. \item Constraint 1: $kdm > 2^{1/\epsilon^{23}}$. This is satisfied if $n > 2^{1/\epsilon^{33}}$. \item Constraint 2: $\log m / \log q_o < \epsilon$. Note that, $\log m / \log q_o < \log m / \log d < \frac{0.3 \log\log n}{0.71 \log n } < \epsilon$ when $n > 2^{1/\epsilon^{33}}$. \end{itemize} \textbf{Sparsity}: $q_o^{m 27 \epsilon} kdm << n^{\epsilon}$. \textbf{Rank}: We will invoke the multidimensional DFT rank bound. $\frac{{q_o}^m}{\exp(9\epsilon^7(\log q_o)^{0.34}m)} \leq \frac{(kdm)^m}{\exp(9\epsilon^7(\log q_o)^{0.34}m)}$ \fi \end{proof} \fi \section*{Acknowledgements} Mrinal thanks Swastik Kopparty for introducing him to the work of Kedlaya \& Umans \cite{Kedlaya11} and the question of multipoint evaluation and numerous invaluable discussions. We thank Zeev Dvir and Allen Liu for answering our questions regarding the results in \cite{DL20} and for allowing us to include the proof sketch of \autoref{cor: DFT rigidity} in this paper. We also thank Ben Lund for helpful discussions and references on the finite fields Kakeya problem and for pointing us to the relevant literature on Furstenberg sets, both of which indirectly played a role in some of the ideas in this paper. Finally, we thank Prerona Chatterjee, Prahladh Harsha, Ramprasad Saptharishi and Aparna Shankar for sitting through a (pretty sketchy) presentation of earlier versions of some of the proofs in this paper and for much encouragement. \iffalse \section{Matrix Rigidity} In this section, we prove that \emph{all} Vandermonde matrices over finite fields that are not too large and have small characteristic are non-rigid with interesting parameters. We start with some relevant definitions. The matrices that we define below can be defined for arbitrary fields. HoBelow we define matrices over $\mathbb{C}$, which can also be defined over any finite field. \begin{definition}[Fourier Transform Matrices] \end{definition} \MKnote{The phrase Fourier matrix has to be changed to something like the Fourier transform matrix or DFT matrix. Check Dvir and Liu for what they use and change it in the whole write up appropriately. } \begin{definition}[Circulant Matrices]\label{def: Circulant} \end{definition} \MKnote{Circulant matrix is not one matrix, but could be any matrix satisfying some criterion. I changed the definition appropriately.} \MKnote{Perhaps avoid using something is 'not rigid' or 'rigid'. Either define the appropriate formal notion like QNR in Dvir and Liu or include the parameters everwhere. Also, formally state the statement about whatever matrix we want to show is non-rigid as a theorem before moving on to the proofs. } Amongst other things, Dvir and Liu \cite{DL20} prove a non-trivial upper bound on the rigidity of the DFT Matrix. However, in \cite{DL20}, this statement is explicitly stated and proved only for the field of complex numbers. They do, however, state such a rigidity upper bound more generally for Circulant matrices over all fields and the upper bound for the DFT matrices is an immediate consequence of this. For the sake of completeness, here, we include a sketch of this observation since this upper bound is crucially used in our proof. We remark that there are no new technical ideas in these details, and we spell out some of the details here just for the sake of completeness. the Circulant matrices of all sizes are non-rigid over any field. They also prove that Fourier matrices of all sizes over $\mathbb{C}$ are non-rigid. But, over finite fields, they show that Fourier matrices of \emph{well-factorable} sizes are non-rigid. In short, they show that the Fourier matrices over finite fields are non-rigid if they satisfy some size constraint along with some other constraints. Note that it is also possible to extend this result to \emph{any size} as a corollary of their proof strategy(over finite fields). We wish to prove this but before that let's look at this below stated observation. \begin{observation}\label{obs: scaling property} If a matrix $M$ is non-rigid over some field ${\mathbb{F}_q}$, then the non-trivial scaled version of $M$ is also non-rigid. \end{observation} \begin{proof} Scaling rows and columns by some non-zero elements do not change the rank of the matrix assuming we are working over any field, which is also an integral domain. In addition to that, scaling doesn't affect sparsity. Hence, overall the scaling operation doesn't affect rigidity. Note that scaling rows and columns of a matrix is also equivalent as multiplying some appropriate diagonal matrices on its left and right. Thus, multiplication of diagonal matrices preserves the nature of rigidity. \end{proof} As Circulant matrices of all sizes are non-rigid over finite fields, the claim below will prove that Fourier matrices of all sizes are also non-rigid over finite fields. \begin{claim} \label{clm: Scaling of Fourier and Circulant} It is possible to rescale the rows and columns of a DFT matrix $F_{q-1}$ to get a Circulant matrix $C_{q-1}$ over the field ${\mathbb{F}_q}$, where $q=p^k$. \end{claim} \begin{proof} Note that ${{\mathbb{F}}^*_q}$ is a multiplicative group and is also a cyclic group of order $q-1$. Let $g$ denote the generator of ${{\mathbb{F}}^*_q}$, which has order $q-1$. Thus, $g$ is a $(q-1)$'th primitive root of unity. Now we define $F_{q-1}$ using $g$ as follows: the rows and columns are indexed from $\{0,1, \ldots q-2\}$ where $F_{q-1}(i,j)$ is $g^{i.j}$. We wish to show that after suitable scaling the above defined DFT matrix $F_{q-1}$ becomes a Circulant one. Here, we divide the whole proof into two cases: when $q$ is odd and when $q$ is even. \vspace{0.5cm} \textbf{Case 1: $q$ odd} \vspace{0.2cm} Consider $\zeta$ such that $\zeta^2=g$. Scale $i$'th row by $\zeta^{{i}^2}$ and $j$'th column by $\zeta^{{j}^2}$ for each row $i$ and column $j$. Now let's look at the $(i,j)$'th entry of $F_{q-1}$ after performing the scaling operation. \vspace{0.1cm} The $(i,j)$'th entry in $F_{q-1}$ was originally $g^{i.j}$, which is now $\zeta^{2ij}$. After scaling, the row $i$ contributes $\zeta^{{i}^2}$ and the column $j$ contributes $\zeta^{{j}^2}$ to the $(i,j)$'th entry. Thus, the $(i,j)$'th entry in the scaled version of $F_{q-1}$ becomes $\zeta^{i^2+j^2+2ij}= \zeta^{(i+j)^2}$. \vspace{0.1cm} We claim this scaled matrix to be a Circulant matrix of order $q-1$. From the definition of the Circulant matrices \autoref{def: Circulant}, we need to check whether it satisfies the property, $C_n(i, j)= c_{{i+j}\mod n}$. In our case, we wish to prove, $\zeta^{(i+j+n)^2}= \zeta^{(i+j)^2}$ where $n=q-1$. \\ Note that $g^{(q-1)}= \zeta^ {2(q-1)}=1$. Thus, \begin{align*} \zeta^{(i+j+q-1)^2} &= \zeta^{(i+j)^2}. \zeta^{(q-1)^2}. \zeta^{2.(i+j).(q-1)} \\ &=\zeta^{(i+j)^2}. \zeta^{2k.(q-1)}. \big{(}\zeta^{2(q-1)}\big{)}^{i+j} ~~~\textnormal{\big{(}As $q-1=2k$, $k \in \mathbb{N}${)}}\\ &=\zeta^{(i+j)^2}. \big{(}\zeta^{2(q-1)}\big{)}^k. \big{(}\zeta^{2(q-1)}\big{)}^{i+j}\\ &= \zeta^{(i+j)^2} ~~~~\text{ \big{(}Because, $\zeta^ {2(q-1)}=1${)}} \end{align*} Hence, for odd $q$, the scaled matrix is indeed a Circulant matrix of order $q-1$ over $\mathbb{F}_q$. \begin{remark} Please note that $\zeta$ may not always exist in the underlying field $\mathbb{F}_q$. In those scenarios, we perform a degree $2$ extension over the base field $\mathbb{F}_q$. After extension, we view $F_{q-1}$ over this extended field and perform appropriate scaling using $\zeta$ to get the Circulant matrix. As Circulant matrices are non-rigid over any field, that will imply that $F_{q-1}$ is also non-rigid over this small field extension using \autoref{obs: scaling property}. But, \cite{DL20}(Lemma 7.20) prove that, over small field extensions, if a matrix is highly non-rigid, then it can't be rigid over the base field. Thus, $F_{q-1}$ is non-rigid over the base field $\mathbb{F}_q$. \end{remark} \MKnote{This remark has to go outside the proof and the field extension statement from Dvir and Liy might have to be formally stated. } \vspace{0.3cm} \textbf{Case 2: $q$ even} \vspace{0.2cm} In the previous case, if $\zeta \in \mathbb{F}_q$ then we don't really need to invoke the property that $q$ is odd. Because, $\zeta^{q-1}=1$ using Fermat's little theorem. Then the previous proof simply works for both odd and even $q$. Thus, if we can show that $\zeta \in \mathbb{F}_q $ when $q$ is even, then we are done. It is indeed always possible to find $\zeta \in \mathbb{F}_q $ such that $\zeta^2 = g$ when $q$ is even. Here, we use the fact that over fields of $\mathbb{F}_{q}$, $q= 2^k$ for some $k \in \mathbb{N}$, then $ \forall a \in \mathbb{F}_{q} $, $\exists b \in \mathbb{F}_{q} $ such that $b^2=a$. Basically, $\varphi: F_q \rightarrow F_q$ is a bijective map over finite fields, where $\varphi(x)= x^2$. \end{proof} \begin{theorem}\cite{DL20}(Theorem $7.27$) Let $0 < \epsilon < 0.01$ be a given parameter and $\mathbb{F}_q$ be a fixed finite field. For all sufficiently large $n$, if $M$ is an $n \times n$ Circulant matrix then, $${r}^{\mathbb{F}_q}_M \Big{(} \frac{n}{\exp(\epsilon^6\big{(}\log n)^{0.35}\big{)}} \Big{)} \leq n^{15\epsilon}$$ \end{theorem} As a corollary of $\autoref{clm: Scaling of Fourier and Circulant}$, we can invoke the same rigidity upper bound for DFT matrix. \begin{corollary} Let $0 < \epsilon < 0.01$ be a given parameter and $\mathbb{F}_q$ be a fixed finite field. For all sufficiently large $n$, if $F_n$ is an $n \times n$ DFT matrix then, $${r}^{\mathbb{F}_q}_{F_n} \Big{(} \frac{n}{\exp(\epsilon^6\big{(}\log n)^{0.35}\big{)}} \Big{)} \leq n^{15\epsilon}$$ \end{corollary} \MKnote{Multivariate vandermonde can mean many things. The bound here is for a very specific matrix of this form - perhaps we are better off calling it an multidimensional FFT Matrix. } \subsection {Rigidity of multidimensional FFT matrix} \begin{definition} A multidimensional FFT matrix $\mathcal{V}_{q^m \times q^m}$ over a field ${\mathbb{F}_{q^m}}$ for an $m$-variate polynomial of individual degree at most $q-1$ is defined as follows: the rows are labelled by all field elements $\{0,1, \ldots ,q^m-1\}$ and the columns are labelled by all possible $q^m$ monomials using $m$-variables$(x_1, x_2, \ldots , x_m)$ of individual degree at most $q-1$. The $(i, j)$'th entry of $\mathcal{V}_{q^m \times q^m}$ is given by the evaluation of the $j$'th column monomial on $i$'th row field element. When $m=1$, we denote this special FFT matrix ($v_{q \times q}$) as unidimensional FFT. \end{definition} \begin{observation}{\label{obs:Kronecker product uni}} $\mathcal{V}_{q^m \times q^m}= \bigotimes_{i = 1}^{m} ({v_i})_{q \times q}= ({v_1})_{q \times q} \otimes ~({v_2})_{q \times q} \ldots \ldots \otimes ~({v_m})_{q \times q} $ up to some row and column permutation, where $(v_i)_{q \times q}$ is a unidimensional FFT of order $q \times q$ over the $i$'th variable(i.e. $x_i$) and $\otimes $ denotes the usual Kronecker product. \end{observation} \begin{theorem}\label{thm: univariate vand. rigidity} Let $0 < \epsilon < 0.01$, $\tilde{\epsilon}= \Theta(\epsilon)$ be the given parameters and $\mathbb{F}_q$ be a fixed finite field. For all sufficiently large $q$, if $v$ is a unidimensional FFT matrix of order $q \times q$, $${r}^{\mathbb{F}_q}_{v} \Big{(} \frac{q}{\exp(\tilde{\epsilon}^6 \big{(}\log q)^{0.35}\big{)}} \Big{)} \leq q^{15\epsilon}$$ \end{theorem} \begin{proof} Consider the submatrix $\bar{v}_{{q-1} \times {q-1}}$ of $v_{q \times q}$ by deleting the row corresponding to the field element $0$ and the column corresponding to the monomial $x^{q-1}$. Note that $\bar{v}_{{q-1} \times {q-1}}$ is a DFT matrix of order $q-1$ with generator element being the generator of the multiplicative group $\mathbb{F}^*_q$. Now we invoke the rigidity upper bound of DFT matrix using \autoref{thm:Fourier rigidity}. This completes the rigidity argument for $\bar{v}_{{q-1} \times {q-1}}$, but our aim is to argue about $v_{q \times q}$. In order to do that, we re-add the deleted row and column to $\bar{v}_{{q-1} \times {q-1}}$. This process can potentially increase the rank of the augmented matrix by at most $1$. Hence, by setting $\tilde{\epsilon}= \Theta(\epsilon)$, the above rigidity bound holds true for the unidimensional FFT matrix over field ${\mathbb{F}_q}$. \end{proof} \MKnote{This theorem has to be carefully stated with the dependence between m and q etc being explicitly mentioned. } \begin{theorem} Let $0 < \epsilon < 0.01$, $\tilde{\epsilon}= \Theta(\epsilon)$ and $m \in \mathbb{N^+}$ be the given parameters and $\mathbb{F}_q$ be a fixed finite field. For all sufficiently large $m$ and $q$, where $q= m^{\frac{log^4 m}{{\epsilon_3}^5}}$, $0 \leq \epsilon_3 \leq 0.0001$, the multidimensional FFT matrix $\mathcal{V}_{q^m \times q^m}$ satisfies, $${r}^{\mathbb{F}_q}_{\mathcal{V}_{q^m \times q^m}} \Big{(} { \frac{q^m}{ m^{\Theta (m \log^{0.75}m)}} } \Big{)} \leq q^{m(1-\delta)}$$ for some $0< \delta <1$. \end{theorem} \begin{proof} Using \autoref{obs:Kronecker product uni} $$\mathcal{V}_{q^m \times q^m}= ({v_1})_{q \times q} \otimes ~({v_2})_{q \times q} \ldots \ldots \otimes ~({v_m})_{q \times q}$$ From \autoref{thm: univariate vand. rigidity}, we know that the Vandermonde matrices are non-rigid. We will show that Kronecker product of such $m$ many matrices is also non-rigid for appropriate setting of parameters. When a matrix$(M)$ is non-rigid, we can write it as $M= L+S$, where $L$ is a low rank and $S$ is a sparse matrix. Thus, $v_i= L_i +S_i$ for all $i$. $$\mathcal{V}_{q^m \times q^m}= (L_1+S_1) \otimes (L_2+S_2) \otimes \ldots \otimes (L_m+S_m)$$ As all the $v_i$'s are of same matrix type with same dimensions, we will use the exact same rigidity bound for each one of them. Thus, we can simply replace $(L_i+S_i)$ with $(L+S)$. Hence, \begin{equation}\label{eq: 2^m Kronecker product } \underbrace{(L+S) \otimes (L+S) \otimes \ldots \otimes(L+S)}_m \end{equation} The above Kronecker product has $2^m$ many terms as $(A+B) \otimes (C+D)= A \otimes C + A \otimes D+ B \otimes C+ B \otimes D$. \vspace{0.2cm} We wish to show that the $\mathcal{V}_{q^m \times q^m}$ is non-rigid. Thus, we need to find a decomposition such that $\mathcal{V}_{q^m \times q^m}$ is sum of a low rank ($\mathcal{L}$) and a sparse matrix ($\mathcal{S}$). In order to do that, we consider those terms where there are strictly less than $t$ many sparse components($S$) in the Kronecker product of \autoref{eq: 2^m Kronecker product } for some appropriate $t$. We will put them to the overall low rank part, i.e. $\mathcal{L}$ and the rest will go the overall sparse part, i.e. $\mathcal{S}$. Now we bound them separately. \paragraph{Sparsity calculation$(\mathcal{S})$:} Each summand in \autoref{eq: 2^m Kronecker product } is a Kronecker product of total $m$ many low rank and sparse components. As mentioned earlier, we will put those terms in the overall sparsity part, which has at least $t$ many sparse components($S$). The aim here is to bound the overall sparsity of sum of these Kronecker products. There are two kinds of matrices involved here, $L$ and $S$ and each of dimension $q \times q$. For $S$, we know the quantitative sparsity bound from \autoref{thm: univariate vand. rigidity}, that is $q'= q^{15\epsilon}$. But, for low rank matrices($L$), we will use the trivial sparsity bound, which is at most $q$ in this case; as each row/column can have at most $q$ many entries in it. \begin{align*} \text{Sparsity of }{\mathcal{S}}= \sum_{j=t}^{m} {{m} \choose {j} }(q')^j {(q)}^{m-j} &= q^m \sum_{j=t}^m {{m} \choose {j}} \Big{(}{\frac{q'}{q}} \Big{)}^j \\& \leq q^m \sum_{j=t}^m m^j \Big{(}{\frac{q'}{q}} \Big{)}^j ~~~~~\text{As ${{m} \choose {j}} \leq m^j$}\\& \leq 2.q^m \Big{(}{\frac{q'm}{q}} \Big{)}^t = q^m {\Big{(}{\frac{q'm \gamma}{q}} \Big{)}}^t \end{align*} Set $t= \epsilon_2m$, where $\epsilon_2=0.01$ and $q= m^{\frac{log^4 m}{{\epsilon_3}^5}}$ , $0 \leq \epsilon_3 \leq 0.0001$. Note, $\gamma=2^{\frac{1}{t}}, q'= q^{15\epsilon}$. \begin{align*} q^m {\Big{(}{\frac{q'm \gamma}{q}} \Big{)}}^t = q^m {\Big{(}{ q^{15\epsilon-1} m \gamma } \Big{)}}^t &\leq q^m{\Big{(}{ q^{15\epsilon-1}. \frac{\epsilon_3}{\log^{0.2}q} \gamma} \Big{)}}^t \\& \leq q^m{\Big{(}{ q^{15\epsilon-1}. q^{\frac{\epsilon_3}{\log^{0.2}q}} .{2^{-\epsilon_2}}^{q^{\frac{\epsilon_3}{\log^{0.2}q}}}} \Big{)}}^t \\& \leq q^m{\Big{(}{ q^{15\epsilon-1+ \frac{\epsilon'_3}{\log^{0.2}q}} } \Big{)}}^t ~~~~~~\text{$\epsilon'_3= \epsilon_3 {2^{-\epsilon_2}}^{q^{\frac{\epsilon_3}{\log^{0.2}q}}}$} \\& \leq q^m{\Big{(}{ q^{15\epsilon-1+ \frac{\epsilon'_3}{\log^{0.2}q}} } \Big{)}}^t \\& =q^m{\Big{(}{ q^{15\epsilon-1+ \beta } } \Big{)}}^{\epsilon_2m} ~~~\text{ where $\beta= \frac{\epsilon'_3}{\log^{0.2}q} <<1$ } \\&= q^m. q^{-(1-15\epsilon\epsilon_2-\beta\epsilon_2)m} \\&= q^{m(1-\delta)} ~~~~\text {where $\delta=(1-15\epsilon\epsilon_2-\beta\epsilon_2)> 0$} \end{align*} \paragraph{Rank calculation($\mathcal{L}$):} We follow the same technique as we used in the above sparsity calculation. Here, we know the rank of each $L$ from \autoref{thm: univariate vand. rigidity} , that is $\Big{(} \frac{q}{\exp \big{(}\tilde{\epsilon}^6 {(}\log q)^{0.35}\big{)}} \Big{)}$. Consider the trivial rank of any sparse matrix($S$), which is at most $q$. Thus, \begin{align*} \text{Rank of } \mathcal{L} &= \sum_{j=0}^{t-1} {{m} \choose {j} } {\Big{(}\frac{q}{2^\alpha}\Big{)}}^{m-j} q^j ~~~~~~~~~~\text{$\alpha= \tilde{\epsilon}^6 \big{(}\log q)^{0.35}$} \\&= {\Big({}\frac {q}{2^\alpha}}\Big{)}^m \sum_{j=0}^{t-1}{{m} \choose {j} } 2^{\alpha j} \leq {\Big({}\frac {q}{2^\alpha}}\Big{)}^m t {{m} \choose {t} } 2^{\alpha t} \leq {\Big({}\frac {q}{2^\alpha}}\Big{)}^m t \Big{(}{\frac{em}{t}}\Big{)}^t 2^{\alpha t}= {({} {q}}{)}^m t \Big{(}{\frac{em}{t}}\Big{)}^t 2^{\alpha(t-m)} \end{align*} \begin{align*} q^mt \Big{(}{\frac{em}{t}}\Big{)}^t 2^{\alpha(t-m)} &= q^m (\epsilon_2m) \Big{(}{\frac{em}{\epsilon_2m}}\Big{)}^{\epsilon_2m} 2^{\alpha(t-m)}\\ &= q^m {\frac{{em}^ {\epsilon_2m}}{{\epsilon_2m}^{\epsilon_2m-1}}} 2^{\alpha(t-m)} \\ &= q^m m {\frac{{e}^ {\epsilon_2m}}{{\epsilon_2}^{\epsilon_2m-1}}} 2^{\alpha(t-m)}\\& \leq q^mm \Big{(}{\frac{e}{\epsilon_2}}\Big{)}^{\epsilon_2m} 2^{\alpha(t-m)} \\& =\frac{q^m}{2^{\alpha(m-t)}}m \Big{(}{\frac{e}{\epsilon_2}}\Big{)}^{\epsilon_2m} \\& =\frac{q^m}{2^{m\alpha(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} ~~~~~~~~\beta'= \frac{\epsilon_2}{e} \\& =\frac{q^m}{2^{m\alpha(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} \\& =\frac{q^m}{2^{m \tilde{\epsilon}^6 {(}\log q)^{0.35}(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} \\& =\frac{q^m}{2^{m \tilde{\epsilon}^6 \big{(}\log m^{\frac{\log^4 m}{{\epsilon_3}^5}}\big{)}^{0.35}(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} \\& = \frac{q^m}{2^{m \tilde{\epsilon}^6 \big{(}{\frac{\log^5 m}{{\epsilon_3}^5}}\big{)}^{0.35}(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} \\& = \frac{q^m}{2^{m \tilde{\epsilon}^6 \big{(}{\frac{\log^5 m}{{\epsilon_3}^5}}\big{)}^{0.35}(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} \\& = \frac{q^m}{2^{m \tilde{\epsilon}^6 \big{(}{\frac{\log m}{{\epsilon_3}}}\big{)}^{1.75}(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} \\& =\frac{q^m}{m^{m \tilde{\epsilon}^6 \tilde{\epsilon_3} {(}{{\log m}}{)}^{0.75}(1- \epsilon_2)}}m \Big{(}{\frac{1}{\beta'}}\Big{)}^{\epsilon_2m} ~~~~~~\tilde{\epsilon_3}= \frac{1}{\epsilon_3^{1.75}} \\& =\frac{q^m}{ {(\beta')}^{\epsilon_2m} m^{m \tilde{\epsilon}^6 \tilde{\epsilon_3} {(}{{\log m}}{)}^{0.75}(1- \epsilon_2)-1}} \\& \leq \frac{q^m}{ m^{\Theta (m \log^{0.75}m)}} \end{align*} \end{proof} \fi {\small \bibliographystyle{prahladhurl}
{'timestamp': '2022-03-29T02:42:21', 'yymm': '2111', 'arxiv_id': '2111.07572', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07572'}
arxiv
\section{Introduction} \label{sec:intro} Generating highly natural speech has been made possible by recent advances in end-to-end text-to-speech (TTS) synthesis \cite{shen2018natural, shen2020non, ren2019fastspeech, ren2020fastspeech}. However, for unseen texts, the prosody (especially pitch and rhythm) of synthesized speech is relatively unnatural (e.g., less dynamic pitch variation, inappropriate phrasing, and improper breaks). For example, in out-of-set speech synthesis for language like Mandarin, which has no blank space between neighboring words, occasional word segmentation errors or poor phoneme duration prediction often leads to improper pauses between characters of a word, which might hinder listeners' comprehension. To improve the modeling of prosody, many recent studies use linguistic or BERT-derived features to provide additional contextual information to TTS models \cite{hayashi2019pre, fang2019towards, zhu2019probing, zhang2020unified, kenter2020improving, xiao2020improving, xu2021improving, chien2021hierarchical, jia2021png}. For example, researchers have utilized character \cite{zhu2019probing, xiao2020improving}, sub-word \cite{hayashi2019pre, kenter2020improving}, word \cite{chien2021hierarchical}, or sentence embeddings \cite{hayashi2019pre, xu2021improving} derived from a pre-trained BERT model for augmenting phoneme embeddings in end-to-end TTS systems. However, these experiments are mostly based on attention-based TTS models like Tacotron 2 \cite{hayashi2019pre, zhu2019probing, xiao2020improving, xu2021improving}. Relatively few studies have investigated incorporating linguistic knowledge into duration-based acoustic models like FastSpeech 2 \cite{chien2021hierarchical}. In addition, the overall improvements are sometimes rather limited \cite{fang2019towards}, and there are few studies on enhancing BERT to improve the performance of TTS synthesis tasks further. Generating natural prosody relies not only on rich linguistic features but also on high-performance and robust acoustic models. For duration-based models like FastSpeech 2, which leverages an explicit duration predictor, low phoneme duration prediction accuracy often results in unnatural pronunciation or wrong placement of breaks. In addition, training these acoustic models often requires a sizable set of high-quality speech data. Most prior studies have focused on how to get the reliable duration label to train the duration predictor and how to optimize the duration prediction in an end-to-end manner (e.g., \cite{donahue2020end}), but relatively few have developed the idea of utilizing external data to pre-train the duration predictor and enhance its generalization ability. The main contributions of this work are as follows: 1) We introduce an all-inclusive fine-tuned BERT-based front-end, which provides linguistic features that contain rich linguistic information by combining phoneme embeddings with character embeddings. We employ the multi-task learning technique to fine-tune the pre-trained BERT, with the aim of capturing task-specific linguistic knowledge. The subjective evaluation results show that incorporating this fine-tuned BERT-based front-end can improve prosody modeling. 2) We use the fine-tuned BERT for polyphone disambiguation in the grapheme-to-phoneme (G2P) conversion module, which simplifies the TTS front-end pipeline. 3) We pre-train the encoder and the duration predictor of FastSpeech 2 using large-scale external data that are noisy but easier to obtain. Experimental results indicate that model pre-training based on the noisy AISHELL-1 dataset is effective in improving the prosody within the FastSpeech2-based TTS framework. Sound demos are available online.$\footnote{https://cookingbear.github.io/research/publications/finetuned-bert/}$ \section{Proposed Approach} \label{sec:model} \begin{figure*}[htb] \centering \includegraphics[width=140mm]{overview5.pdf} \caption{The overall model architecture. (a) Overall procedures for fine-tuning BERT on different tasks. (b) The front-end based on a fine-tuned BERT model. (c) FastSpeech 2 with output features from the BERT-based front-end as input (orange line).} \label{fig:model} \end{figure*} The proposed model architecture follows the original FastSpeech 2 \cite{ren2020fastspeech} and the BERT architecture \cite{devlin2018bert}. It consists of a TTS front-end based on a fine-tuned BERT model, and an acoustic model based on FastSpeech 2 with a pre-trained duration predictor, as illustrated in Figure \ref{fig:model}. \subsection{Fine-tuned BERT-based front-end} \subsubsection{Fine-tuning BERT for linguistic information} Pre-training provides task-independent general knowledge, and fine-tuning can presumably teach the model to rely more on representations useful for the task at hand. For instance, BERT embeddings fine-tuned on the joint CWS and POS tagging task might acquire more knowledge about phrasing. Therefore, if the fine-tuned embeddings are used in TTS synthesis, the phrasing pattern of generated speech for sentences that are hard to segment is likely to improve. In addition, multi-task learning has demonstrated its effectiveness in sharing the knowledge obtained from several related supervised tasks. Thus with multi-task fine-tuning, BERT representations can gain richer linguistic or contextual knowledge. During the fine-tuning process, BERT takes the final hidden vector h for the $i^{th}$ input token as the representation of the character $Tok\ i$. A simple FFNN (Feed-Forward Neural Work) with a softmax classifier is added to the top of BERT to predict the probability of label $c$: \begin{equation} p(c|h) = softmax(W h) \end{equation} where $W$ is the task-specific parameter matrix. We fine-tune all the parameters from BERT as well as $W$ jointly by maximizing the log-probability of the correct label. Specifically, we conduct single-task fine-tuning (BERT-Polyphone; BERT-CWS+POS; BERT-Prosody) and multi-task fine-tuning (BERT-Multi) based on the original character-based Chinese BERT-base model \cite{devlin2018bert}, which contains an encoder with 12 Transformer blocks, 12 self-attention heads, and a hidden size of 768. \textbf{BERT-Polyphone}: BERT encoder with a prediction layer of the polyphone disambiguation task. \textbf{BERT-CWS+POS}: BERT encoder with a prediction layer of the joint CWS and POS tagging task. \textbf{BERT-Prosody}: BERT encoder with a predictor layer of the prosody structure prediction task. \textbf{BERT-Multi}: BERT encoder with three prediction layers attached in parallel. BERT embeddings are fine-tuned in a multi-task learning framework. \subsubsection{An all-inclusive front-end} We propose a novel fine-tuned BERT-based front-end, which not only performs G2P conversion but also provides linguistic features that contain rich contextual information by combining phoneme embeddings with character embeddings. Specifically, the fine-tuned BERT helps determine the pronunciation of polyphonic characters in the G2P conversion module. Then the converted phonemes are sent to an embedding layer to obtain the phoneme embeddings. Meanwhile, from the fine-tuned BERT we extract the character embeddings, which are then upsampled to match the length of the phonemic symbols of each character. Finally, the character embeddings and the phonemic embeddings are concatenated as the input features to the subsequent layers. \subsection{Pre-trained FastSpeech2-based acoustic model} \label{acoustic_mod} Duration-based acoustic models commonly use external or internal alignment tools for obtaining ground-truth values of phoneme duration as targets to train the duration predictor. However, high-quality speech data are expensive and time-consuming to collect. We propose to lower acoustic models' reliance on high-quality data and enhance their generalization ability on out-of-set speech synthesis by using noisy data to pre-train the duration predictor. To verify its effectiveness in improving the prosody of synthesized speech for unseen texts, we pre-train the duration predictor on a large-scale noisy dataset and on a relatively small clean dataset, to see if they can achieve comparable performance. Moreover, inspired by the BERT pre-training mechanism \cite{devlin2018bert}, while pre-training the duration predictor, we randomly mask phonemes to pre-train the encoder (i.e., the first stack of FFT blocks) in Fastspeech 2, which acts as a data augmentation effect for pre-training the duration predictor. As shown in Figure \ref{fig:pretrained_dur}, the pre-training steps can be summarized as follows: We use the Montreal Forced Aligner (MFA) \cite{mcauliffe2017montreal} to extract the ground-truth duration of each phoneme. The phoneme sequences with some phonemes being randomly masked are sent into the phoneme embedding layer. Finally, the MAE (mean absolute error) loss and the MLM (masked language model) loss can be computed, and the total loss back-propagates through the network. \begin{figure}[htb] \centering \includegraphics[width=60mm]{pretrained_duration_predictor.pdf} \caption{Pre-trained duration predictor. The phonemes ``ch", ``u1" and ``x", and their embeddings are shaded in grey, indicating that they are masked.} \label{fig:pretrained_dur} \end{figure} \section{Experiments} \label{sec:exp} \subsection{Datasets} \subsubsection{Data for training acoustic models} The training data used for this study is the Chinese Standard Mandarin Speech Corpus (CSMSC) \cite{csmsc2017}. CSMSC has 10,000 recorded sentences read by a female speaker, with the total audio length of about 12 hours of natural speech. We randomly split the dataset into two parts: 9500 samples for training and 500 samples for testing. The clean data used for pre-training the duration predictor is the AISHELL-3 training set (around 60 hours long) \cite{shi2020aishell}, which is a high-fidelity multi-speaker Mandarin speech corpus. And the AISHELL-1 training set (around 150 hours) \cite{bu2017aishell}, which is primarily used for building speech recognition systems, is selected as the noisy data to pre-train the duration predictor. \subsubsection{Data for fine-tuning BERT} We fine-tuned BERT on a text corpus mined from the Chinese Wikipedia, containing 81108 sentences. The corpus was manually annotated by trained linguists. For the joint segmentation and tagging task, 35 tags for word classes and 2 tags for a character's position within a word were used, totaling 70 categories. For the prosody prediction task, three classes were used for the prosodic break of prosodic word (PW), prosodic phrase (PPH) and intonational phrase (IPH), respectively. The corpus was randomly partitioned into training and test sets with 71853 and 9255 sentences, respectively. \subsection{Model Configuration} The configuration and hyper-parameters of the baseline model follow the original FastSpeech 2 implementation \cite{ren2020fastspeech}. It consists of 4 feed-forward Transformer (FFT) blocks in the encoder and the mel-spectrogram decoder. In each FFT block, the dimension of phoneme embeddings and the hidden size of the self-attention are set to 256. The combine layer is a 1D-convolutional network with a ReLU activation function, an input size of 1024, and output size 256. The output linear layer in the decoder converts the hidden states into 80-dimensional mel-spectrograms. The model is optimized with MAE. Generated mel-spectrograms are converted into waveforms using the multi-band MelGAN (MB-MelGAN) vocoder \cite{yang2021multi}. \textbf{Training details:} The duration predictors are pre-trained with the Adam optimizer (with $\epsilon$ = $10^{-9}$, $\beta_{1}$ = 0.9, $\beta_{2}$ = 0.98) for 10k steps with a batch size of 48, and the learning rate schedule proposed in \cite{vaswani2017attention} is applied. All acoustic models are trained with the Adam optimizer (with $\epsilon$ = $10^{-9}$, $\beta_{1}$ = 0.9, $\beta_{2}$ = 0.98) for 20K steps with a batch size of 48. \subsection{Fine-tuned BERT performance} \label{ssec:subhead1} The performance of single-task fine-tuning and multi-task fine-tuning based on BERT is summarized in Table \ref{tab:my_label}. BERT-Multi slightly outperforms other single-task fine-tuning systems in terms of polyphone disambiguation and prosody prediction, except for the segmentation and tagging task. All fine-tuned systems achieve fairly good results on all tasks. \begin{table}[!htbp] \caption{Performance of different systems.} \label{tab:my_label} \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{cccccc} \hline \textbf{Systems} & \textbf{ACC-Polyphone} & \textbf{F1-CWS+POS} & \multicolumn{3}{c}{\textbf{F1-Prosody}} \\ & & & \textbf{PW} & \textbf{PPH} & \textbf{IPH} \\ \hline BERT-Polyphone & 98.47 & - & - & - & - \\ BERT-CWS+POS & - & 93.69 & - & - & - \\ BERT-Prosody & - & - & 84.78 & 70.44 & 90.84 \\ BERT-Multi & 98.86 & 93.34 & 85.06 & 71.90 & 91.34 \\ \hline \end{tabular}} \end{table} \subsection{TTS performance} \label{ssec:subhead2} \subsubsection{Ablation studies} \label{sssec:subsubhead01} We conduct ablation studies to evaluate the effectiveness of combining a fine-tuned BERT-based front-end with a pre-trained FastSpeech2-based acoustic model in improving the prosody of synthesized speech. The overall speech quality is evaluated on the CSMSC test set using the mean opinion score (MOS) \cite{chu2006objective}. Ten native speakers were asked to rate the overall prosodic appropriateness of the synthesized speech. We compare the MOS of audio samples generated by our proposed model with other systems, including 1) GT, the ground-truth audios; 2) GT (Mel + MB-MelGAN); 3) FastSpeech 2; 4) w/ BERT: a BERT-based front-end; 5) w/ BERT-Multi: a fine-tuned BERT-based front-end. 6) and 7): clean/noisy means the pre-trained duration predictor with AISHELL3/AISHELL1 dataset. 8) w/ BERT-Multi + noisy. \begin{table}[htb] \caption{The MOS with 95\% confidence intervals.} \label{tab:my_label2} \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{ll} \hline \textbf{System} & \textbf{MOS} \\ \hline GT & $4.25 \pm 0.07$ \\ GT (Mel + MB-MelGAN) & $3.98 \pm 0.08$ \\ \hline FastSpeech 2 (Mel + MB-MelGAN) & $3.74 \pm 0.07$\\ \quad w/ BERT (Mel + MB-MelGAN) & $3.82 \pm 0.07$ \\ \quad w/ BERT-Multi (Mel + MB-MelGAN) & $3.88 \pm 0.08$ \\ \quad w/ clean (Mel + MB-MelGAN) & $3.78 \pm 0.07$ \\ \quad w/ noisy (Mel + MB-MelGAN) & $3.80 \pm 0.08$ \\ \quad w/ BERT-Multi + noisy (Mel + MB-MelGAN) & $3.90 \pm 0.09$ \\ \hline \end{tabular}} \end{table} The results suggest that using a fine-tuned BERT-based front-end and a pre-trained FastSpeech2-based acoustic model can improve the prosody (with 0.14 and 0.06 MOS gains, respectively), as shown in Table \ref{tab:my_label2}. In addition, the w/ clean model and the w/ noisy model achieve comparable performance, suggesting that pre-training the encoder and the duration predictor on noisy data is feasible and can effectively improve the data efficiency and prosody at the same time. \subsubsection{Pairwise subjective scores} We further conduct an ABX test to compare the models pairwisely. Synthesized audio samples from two different systems were presented to the same ten raters. And they were asked to select the one with more appropriate prosody. The evaluation text set contains 150 sentences and each sentence has more than 10 characters. These texts are randomly selected from the test set of the fine-tuning BERT experiments. The results are summarized in Table \ref{tab:my_label3}. All fine-tuned BERT-based models outperform the models without fine-tuning and listeners preferentially choose the audios synthesized by BERT-Multi, suggesting that rich contextual information contained in fine-tuned BERT representations can be injected into the model. The w/ clean and the w/ noisy model perform fairly close, which suggests that pre-training on noisy data or clean data can bring about comparable improvements. \begin{table}[htb] \caption{The subjective listening preference rate.} \label{tab:my_label3} \centering \resizebox{\columnwidth}{!}{ \begin{tabular}{llll} \hline \textbf{ABX Choices} & \textbf{Former} & \textbf{Latter} & \textbf{Neutral} \\ \hline Base vs. w/ clean & 3.33 & 27.33 & 68.67 \\ Base vs. w/ noisy & 5.33 & 28.00 & 66.00 \\ w/ clean vs. w/ noisy & 10.67 & 12.67 & 76.67 \\ \hline Base vs. w/ BERT & 7.33 & 72.67 & 19.33 \\ Base vs. w/ BERT-CWS+POS & 8.67 & 78.67 & 12.67 \\ Base vs. w/ BERT-Prosody & 6.67 & 81.33 & 12.00 \\ Base vs. w/ BERT-Multi & 4.67 & 85.33 & 9.33 \\ w/ BERT vs. w/ BERT-CWS+POS & 14.00 & 27.33 & 58.67 \\ w/ BERT vs. w/ BERT-Prosody & 17.33 & 31.33 & 51.33 \\ w/ BERT vs. w/ BERT-Multi & 7.33 & 34.67 & 58.00 \\ \hline \multicolumn{4}{r}{Base: FastSpeech 2. } \end{tabular}} \end{table} \subsubsection{A case study} To investigate if the proposed method can generate better prosody, we select a structurally complex sentence for case study, as shown in Figure \ref{fig:demo-mel}. Based on our linguistic knowledge, there is supposed to be a relatively noticeable pause between the verb of the main clause and the following subordinate clause in the object clause structure. The illustration of generated spectrograms indicates that the w/ BERT-Multi architecture generates speech with more appropriate breaks than the w/ BERT model and FastSpeech 2. \begin{figure}[htb] \centering \includegraphics[width=90mm, height=50mm]{demo-7-feat.pdf} \caption{Generated mel-spectrograms of the utterance \textbf{shang1 jia1 yun3 nuo4 \#2 san1 tian1 song4 huo4 dao4 wei4} (``The merchant promises that he/she will deliver the goods in three days"). The w/ BERT-Multi architecture synthesizes the most natural break in the prosodic phrase boundary position (\#2).} \label{fig:demo-mel} \end{figure} \section{Conclusions} \label{sec:fin} In this paper, we propose to improve the prosody for unseen texts by combining a fine-tuned BERT-based front-end with a pre-trained FastSpeech2-based acoustic model. Subjective listening results demonstrate the effectiveness of our proposed methods. Future work will examine the feasibility of training the front-end and the acoustic model in a unified manner, so as to simplify the overall architecture. \vfill\pagebreak \bibliographystyle{IEEEbib}
{'timestamp': '2021-11-16T02:26:48', 'yymm': '2111', 'arxiv_id': '2111.07549', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07549'}
arxiv
\section{Introduction} One of the hottest areas of computer vision and graphics is capturing facial expression in real time and drive a virtual digital human to act like a specific actor. This technology enables any user to control the facial expression of a digital avatar in real time. James Cameron's sci-fi blockbuster "Avatar" remains in first place with nearly 3 billion dollars. Emotion-capture technology has captured the facial details of Thanos's cast in The Avengers to the delight of millions of viewers. Avatar and Thanos used facial expression capture technology, which is fascinating. Facial expression capture technology is mainly divided into landmark driven, point cloud driven, sound driven and image based. These types of methods will then be described in more detail. Humans express their inner feelings through facial expression, such as happiness or anger. How to make the computer automatically recognize expressions is an important research field, which has attracted many scholars to devote their energy and time to him. Essa et al.\citep{essa1996modeling} show that facial animation methods are also designed for basic video input, but their heavy dependence on optical flow or feature tracking may lead to instability. Facial expressions often play an indispensable role in animation, games, films and television production. In the movies, the creature animation of characters with strange facial structures, such as King Kong and Gollum, are generated through this technology. How to use the expression data of a single actor to drive different face models has attracted great attention in the field of face simulation. In the field of motion capture, the motion data of different facial expressions are mapped and registered. The feature reconstruction method depends on the training data under different occlusion conditions, but occlusion positions and types are too many to control. Li et al.\citep{li2018patch} designed patch gated revolution neutral network(pg-cnn) for sensing occlusion, which can automatically perceive the occlusion area of the human face, focus on the divided 24 non-occlusion sub-regions with more feature information, and input the 24 sub-areas into an attention network to obtain weighted cascaded local features. Li et al.\citep{li2018occlusion} further extended the pg-cnn method by introducing global candidate units to supplement the global information of face images for expression recognition. However, these methods of selecting sub-regions based on face key points are not accurate in face images with occlusion. Recent studies use different network structures and preprocessing methods. In the field of expression recognition, the rapid development of deep learning has prompted researchers to use deep neural network to develop facial expression recognition In recent years, researchers have proposed various novel expression recognition models and algorithms to improve the efficiency of expression recognition and reduce the error of expression recognition in special scenes. So they have shown that convolutional neural network can also extract features and classify facial expression recognition. Lewis et al.\citep{lewis2014practice} show that, despite the simplicity of the blendshape approach, there remain open problems. There are many models based on point cloud. Iordanis et al.\citep{mpiperis2008bilinear} introduces a novel model-based framework for establishing correspondence among 3d point clouds of different faces. Xiao et al.\citep{xiao2004real} study the representational power of Active Appearance Models which are popular generative models and show that they can model anything a 3d Morphable Model can, but possibly require more shape parameters. In 2009, Weise et al.\citep{weise2009face} produces A real-time structured light scanner which is low-cost can provide dense 3d data and texture. With the emergence of RGBD camera, depth data can be obtained by researchers. The physical distance is obtained by dividing the pixel value of the depth map obtained by the RGBD camera by the scale map. Hao et al.\citep{li2013realtime} presented a calibration-free facial performance capture framework based on a sensor with video and depth input in 2013. Samuli et al.\citep{laine2017production} produces high-quality output based on a convolutional network, including self-occluded regions, from a monocular video. Thibaut et al.\citep{weise2009face} propose a system for live puppetry that allows transferring an actor’s facial expression onto a digital 3d character in 2009. In 2011, Thibaut et al.\citep{weise2011realtime} introduce a novel face tracking algorithm that combines geometry and texture registration. And it effectively maps low-quality 2d images and 3d depth maps to realistic facial expression. Martin et al.\citep{klaudiny2017real} achieve markerless facial performance capture from multi-view helmet camera data, employing an actor-specific regressor in 2017. Derek et al.\citep{bradley2010high} introduced a purely passive facial capture approach that uses only an array of video cameras, but requires no template facial geometry, no special makeup or markers, and no active lighting. Audio-driven facial simulation technology is also attracting much research. Because little has been done to model expressive visual behavior during speech, Yong et al.\citep{cao2005expressive} address this issue using a machine learning approach that relies on a database of speech-related high-fidelity facial motions. Tero et al.\citep{karras2017audio} drive real-time 3D facial animation by audio input with low latency. Neural network based end-to-end models suffer from slow inference speed, and the synthesized speech is usually not robust, i.e., some words are skipped or repeated. But, Yi et al.\citep{ren2019fastspeech} extract attention alignments from an encoder-decoder based teacher model for phoneme duration prediction Image-based systems are completely different from model-based system, such as the one introduced by Iordanis as mentioned above. Kang et al.\citep{liu2008robust} presented an image-based facial animation system using Active Appearance Models for precisely detecting feature points in the human face. Kang et al.\citep{liu2009optimization} concatenates appropriate mouth images from the database such that they match the spoken words of the talking head in 2009. In 2011, they\citep{liu2011realistic} presents an image-based talking head system that is able to synthesize realistic facial expression accompanying speech, given arbitrary text input and control tags of facial expression. Sarah et al.\citep{taylor2016audio} present a sliding window deep neural network that learns a mapping from a window of acoustic features to a window of visual features. Chen et al.\citep{chen2013accurate} proposed an image-based 3d nonrigid registration process. In the model presented by Cao et al.\citep{cao20133d}, the 3D positions of facial landmark points are inferred by a regressor from 2d video frames of a web camera. They capture 150 individuals aged 7–80 from different backgrounds by RGBD camera\citep{cao2013facewarehouse}. Chen et al.\citep{cao2014displaced} proposed an approach that does not need any calibration for each individual user. But it demonstrates a level of robustness and accuracy on par with state of the art techniques that require a time-consuming calibration step. Chuang et al.\citep{chuang2002performance} use a combination of motion capture data and blendshape interpolation to create facial animation. In the process of traditional expression animation, the realistic effect of animation often needs large manual intervention. Therefore, authenticity and efficiency are still the main indexes of current facial expression simulation research. Motion capture technology is a new data acquisition means developed in recent years, which can record and restore the performer's motion in real time. Face motion capture technology applies motion capture technology to the production of facial expression animation. Therefore, in recent years, motion capture technology is in the research field of facial expression simulation Domain has attracted more and more attention. Assia et al.\citep{khanam2007intelligent} presents a new approach to add flexibility and intelligence to Performance Driven Facial Animation by means of context-sensitive facial expression blending. Salil’s \citep{deena2009speech} facial animation is done by modeling the mapping between facial motion and speech using the shared Gaussian process latent variable model. In the research of Meng et al.\citep{meng2019lstm}, the embeddings are fed into an Long Short Term Memory Network (LSTM) network to learn the deformation between frames. Humans express their inner feelings through facial expression, such as happiness or anger. How to make the computer automatically recognize expression is a hot research field, which has attracted many scholars to devote their energy and time to him. Extracting image features with strong robustness and representation ability is the key of expression recognition system. Various 3d models for human faces have been used in computer graphics and computer vision. The model introduced by Marc et al.\citep{habermann2019livecap} is the first real-time monocular approach for full-body performance capture. Kettern et al.\citep{kettern2015temporally} proposed a model that supports any number of arbitrarily placed video cameras. Facial expression simulation has attracted much research effort in the fields of virtual reality, cognitive science, human-computer interaction interface design and online video conference. Authenticity is one of the key evaluation standard of expression simulation. Face animation methods are also designed for basic video input, but their heavy dependence on optical flow or feature tracking may lead to instability. Facial expression often play an indispensable role in animation, games and film and television production. Zhang et al. \citep{zhang2014random} extracted a set of Gabor based face templates by Monte Carlo method in 2014 and transformed them into template matching distance features. The distance feature of template matching depends on the template selection in a specific expression dataset, so it is difficult to guarantee the performance across datasets and does not have good generalization ability. Another feature reconstruction method is to learn a generation model, which can reconstruct a complete face from the occluded face\citep{pan2019occluded}. Disadvantages of RGBD-based systems as following: computing-time consuming, expensive equipment, and no eyeball performance. Similarly, all kinds of audio-driven method cannot drive the eyeball correctly. But our distill facial capture network(DFCN) involves the performance of the eyes. A lot of them are model-based, whereas we are image-based. Further, knowledge distill is introduced into the regression algorithm to improve the expression ability of the network. Salient contributions in this paper can be summarized by 1. A framework for real-time facial capture from video sequences to blendshape weight and 2d facial landmark is established. 2. An adaptive regression distillation(ARD) framework is proposed, which can filter mislabeled data and ensure that student network is trained on the right track. The rest of this paper is organized as follows. In Section \ref{sec:Problem Formulation}, the facial capture problem is mathematically formulated. The scheme is developed in Section \ref{sec:End-to-end Algorithm}. In Section \ref{sec:Experimental Results}, experimental results and discussions are presented. Conclusions are drawn in Section \ref{sec:Conclusion}. \begin{figure} \centering \includegraphics[scale=0.8]{ss-eps-converted-to.pdf}\\ \caption{Our deep learning-based facial performance capture framework is divided into a training and inference stage. The goal of our system is to reduce the amount of footage that needs to be processed using labor-intensive production-level pipelines.}\label{main flow chart} \end{figure} \section{Problem Formulation} \label{sec:Problem Formulation} In general, as shown in Fig. 1, use an infrared camera which can avoid the influence of light on the picture to capture the image data of the face, and then use the end-to-end method to obtain the corresponding blendshape weight. In addition, in order to avoid discontinuities between frames, a hybrid smoothing method is adopted. For 3d shapes that need to be driven, we use a Dynamic Expression Model(DEM) based on a set of blendshape meshes. Similar to [Weise et al. 2011], we represent the 3d facial mesh $ \pmb{F} $ as a linear combination of expression blendshapes $\pmb{B} = [\pmb{b}_0, ..., \pmb{b}_n]$: \begin{equation} \pmb{F} = \pmb{B}\pmb{e}^T \label{equ:1} \end{equation} where $\pmb{e} = [e_0, ..., e_n]$ is the expression coefficients. As commonly assumed in blendshape models, $\pmb{b}_0$ is the neutral face, and nonneutral blend weights $e_i, 1 \leq i \leq n$ are bounded between 0 and 1. All blend weights must sum to 1, leading to $e_0 = 1 - \sum\nolimits_{i=1}^ne_i$ . For simplicity of description, we ignore the dependent $e_0$ in the following equations and discussions, and assume the correct value is computed on demand. Our blendshape model is based on the ArKit\citep{arkit}, which contains 52 action units (i.e., $n = 52$) that mimic the combined activation effects of facial muscle groups. This blendshape model adequately describes the expression of the human face. In the context, our algorithm can be expressed as the following: \begin{equation} DFCN(\pmb{I}) = (\pmb{e, S}) \label{equ:2} \end{equation} where the 2d facial shape $\pmb{S}$ is thus represented by the set of all 2d landmarks $s_k$, $\pmb{I}$ is input image. \section{DFCN Algorithm} \label{sec:End-to-end Algorithm} In this section, by directly obtaining the weight of the corresponding blendshape and the 2d landmarks according to the ordinary image, DFCN algorithm is created, and it can resist the influence of different intensities of light and jitter from the outside world. Our pipeline is outlined in Fig. \ref{main flow chart}. \subsection{Network Architecture} As input for the network, we take the $1920\times1080$ video frame from the camera, crop it with a fixed rectangle so that the face remains in the picture, and scale the remaining portion to $160\times160$ resolution. Furthermore, we normal the image, resulting in a total of 25600 scalars to be fed to the network. The resolution may seem low, but numerous tests confirmed that increasing it did not improve the results. Our convolutional network is based on the InceptionResNetv2\citep{szegedy2017inception}, but cancels any activation functions in the final output. Although InceptionResNetv2 can extract image features very well, it cannot be calculated quickly in the CPU. Therefore, InceptionResNetv2 will be used as a teacher network to perform knowledge distillation on the student network, i.e., MobileNetv2, in order to achieve the role of model compression. \subsection{Post-processing} In terms of continuously ensuring the continuity of the output of the frame, a hybrid filtering method has been reached. Kalman filter\citep{kalman1960new} is an optimal recursive data processing algorithm. The estimated value can be either stationary or non-stationary. Only the process noise, measurement noise and the statistical characteristics of the current system state need to be considered in the calculation. So the spatial complexity of the calculation is small. The system equation is: \begin{equation} \pmb{x}_k = \pmb{Gx}_{k-1} + \pmb{Qu}_k + \pmb{w}_{k-1} \label{equ:3} \end{equation} where $\pmb{x}$ is the state of the system. $\pmb{G}$ is the system matrix. $\pmb{Q}$ and $\pmb{u}$ is the control of state. $\pmb{w}$ is the process noise. And the measurement equation is: \begin{equation} \pmb{z}_k = \pmb{Hx}_k + \pmb{v}_k \label{equ:4} \end{equation} where $\pmb{z}$ is the thermometer reading and $\pmb{H}$ is the matrix of observations. In addition, $\pmb{v}$ is the measurement noise. In Savitzky-Golay(SG) filter algorithm\citep{press1990savitzky}, the radius of sliding window and the order of polynomial are specified by the user. And the polynomial order must be less than the window radius. In addition, the window length must be odd. There are $2n + 1$ expression like this: take time $t$ as an example: \begin{equation} x_t = a_0 + a_1 t + a_2 t^2 + ... + a_{k-1} t^{k-1} \label{equ:5} \end{equation} where $k-1$ is the order of the polynomial used for fitting, $t$ is the time, and a is the parameter need to be figured out. Therefore, $2n + 1$ of the above expression are written in the form of a matrix is: \begin{equation} \pmb{X}_{(2n+1) \times 1} = \pmb{H}_{(2n+1) \times k} + \pmb{A}_{k \times 1} + \pmb{E}_{(2n+1) \times 1} \label{equ:6} \end{equation} where $\pmb{A}$ is the parameter vector need to be computed, and $\pmb{E}$ is the random noise column vector. The subscript of the above formula refers to the dimention of each matrix. Through the least square method, the following can be obtained: \begin{equation} \pmb{A} = (\pmb{H}^{T} \pmb{H})^{-1} \pmb{H}^{T} \pmb{X} \label{equ:7} \end{equation} Then the SG filtering result is: \begin{equation} \pmb{P} = \pmb{H A} = \pmb{H} (\pmb{H}^{T} \pmb{H})^{-1} \pmb{H}^{T} \pmb{X} \label{equ:8} \end{equation} \subsection{Training} \subsubsection{Data Acquisition} In order to avoid the influence of light on the image, the FACEGOOD P1 equipment(Fig. \ref{p1}) is used for image acquisition. For each actor, the training set consists of four parts, totaling approximately 5-6 minutes of footage. The composition of the training set is as follows. \begin{figure} \centering \includegraphics[scale=1.0]{P1.pdf}\\ \caption{Facegood P1 Helmet.}\label{p1} \end{figure} \emph{Standard Expression.} In order to capture the maximal extents of the facial motion, a single range-of-motion shot is taken where the actor goes through a pre-defined set of extreme expression. These include but are not limited to opening the mouth as wide as possible, moving the jaw sideways and front as far as possible, pursing the lips, and opening the eyes wide and forcing them shut. Farther, unlike the range-of-motion shot that contains exaggerated expression, this set contains regular FACSlike expression such as squinting of the eyes or an expression of disgust. These kind of expression must be included in the training set as otherwise the network would not be able to replicate them in production use. \emph{Special Expression.} This set needs to increase the actors' all-out distorted expression, so that the network can better replicate these dramatic performances. \emph{Speak Normally.} This set leverages the fact that an actor’s performance of a character is often heavily biased in terms of emotional and expressive range for various dramatic and narrative reasons. This material is composed of the preliminary version of the script, or it may be otherwise prepared for the training to ensure that the trained network produces output that stays in character. \emph{Speak Exaggeratedly.} This set attempts to cover the set of possible facial motions during an exaggerated speech for a given target language. Next step, the Avatary \footnote{https://www.avatary.cc/} software will be used to generate the blendshape weights from this videos. \begin{figure}[t] \centering \includegraphics[scale=0.65]{augment-eps-converted-to.pdf}\\ \caption{Examples of augmented inputs presented to the network during training.}\label{augment} \end{figure} \subsubsection{Data Augmentation} We perform several transformations to the input images during training in order to make the network resistant to variations in input data. These transformations are executed on CPU concurrently with network evaluation and training that occurs on the GPU. Augmentation is not used when evaluating the validation loss or when processing unseen input data in production use. Examples of augmented input images are shown in Fig. \ref{augment}. The main transformations are geometric transformations, we vary the brightness, random padding and contrast of the input images during training, in order to account for variations in lighting over the capture process. \subsubsection{Training Parameters} We train the teacher network for 400 epochs using the Adam\citep{kingma2014adam} optimization algorithm with parameters set to values recommended in the paper. The learning rate is ramped up using a geometric progression during the first training epoch, and then decreased according to $ 1 / \sqrt{t}$ schedule. During the last 60 epochs we ramp the learning rate down to zero using a smooth curve, and simultaneously ramp Adam $\beta_1$ parameter from 0.9 to 0.5. The ramp-up removes an occasional glitch where the network does not start learning at all, and the ramp-down ensures that the network converges to a local minimum. Minibatch size is set to 1024, and each epoch processes all training frames in randomized order. \begin{equation} q_i=\frac{e^{z_i/T}}{\sum_j{e^{z_i/T}}} \label{equ:9} \end{equation} This equation suggests that the exponent of e in the sigmoid function is divided by the temperature $T$ to make the it smaller. The effect of this is to make the categories of sigmoid output smoother and let the teacher transfer the soft-target knowledge to the students, which can help students learn better. Loss $L_{distll}$ is defined as: \begin{equation} L^{classification}_{distill} = \alpha T^2 K(\frac{\pmb{O}_{student}}{T}, \frac{\pmb{O}_{teacher}}{T}) + (1 - \alpha) M(\pmb{O}_{student}, \pmb{y}) \label{equ:10} \end{equation} where $K$ is the the Kullback-Leibler(KL) divergence operator, and $M$ is the CrossEntropy of student and correct label. And $\alpha$ is determined by the researcher. \begin{figure}[t] \centering \includegraphics[scale=0.65]{result-eps-converted-to.pdf}\\ \caption{Three rows showing the raw expression, the expression with 2d landmarks, and the expression of metahuman driven by human.}\label{result} \end{figure} However, the current distillation is mainly used in classification tasks. By increasing the temperature, teachers can output the soft knowledge of "6 is not only like 6, 6 is also like 4", so as to enhance the generalization ability of students' models. There are only two papers on the application of distillation to regression tasks. \begin{equation} L_{distill}=\left\{ \begin{array}{rcl} ||\pmb{O}_{student}-\pmb{O}_{teacher}||^2_2 & & {if \ \ ||\pmb{y}-\pmb{O}_{teacher}||_2 > \mu}\\ f(\pmb{O}_{student}, \pmb{m}) & & {if \ \ ||\pmb{y}-\pmb{O}_{teacher}||_2 < \mu}\\ \end{array} \right. \label{equ:11} \end{equation} where \begin{equation} f(\pmb{O}_{student}, y)=\left\{ \begin{array}{rcl} v ||\pmb{O}_{student}, \pmb{m}||^2_2 & & {if \ \ ||\pmb{O}_{student}-\pmb{m}||^2_2 + b > ||\pmb{O}_{teacher}-\pmb{m}||^2_2}\\ ||\pmb{O}_{student}, \pmb{m}||^2_2 & & otherwise\\ \end{array} \right. \label{equ:12} \end{equation} Our idea is when the point is an outlier, then let the students learn from the teacher instead of the dirty data. On the contrary, if it is not an abnormal point, let the students learn the real data instead of the teacher's "half right and half wrong" data. Here, $v$ is larger than 1, indicating that when the student is not good enough, the loss will be larger. In addition, $\pmb{m}$ is the data except the outlier, $\mu$ is the parameter judging whether the point is noise or not, and $b$ is the gap between the performance of teacher and the student that is determined by the researcher. In addition, $||\bullet||^2_2$ is the square of the euclidean norm. It follows that the ARD policy can be summarized in Algorithm \ref{ard}. \begin{algorithm} \caption{ARD} \begin{algorithmic}[1] \Require Traing Data $\mathbb{\pmb{D}}$ \Ensure $L_{distill}$ \For {$\pmb{d} \in \mathbb{\pmb{D}}$} \If {$||\pmb{d}-\pmb{O}_{teacher}||_2 > \mu$} \State $L_{distill} = ||\pmb{O}_{student}-\pmb{O}_{teacher}||^2_2 $ \Else \State $L_{distill} = f$ \State \# $\pmb{m}$ is the $\mathbb{\pmb{D}}$ minus the outliers \If {$||\pmb{O}_{student}-\pmb{m}||^2_2 + b > ||\pmb{O}_{teacher}-\pmb{m}||^2_2$} \State $f = v ||\pmb{O}_{student}, \pmb{m}||^2_2 $ \Else \State $f = ||\pmb{O}_{student}, \pmb{m}||^2_2$ \EndIf \EndIf \EndFor \end{algorithmic} \label{ard} \end{algorithm} \section{Experimental Results} \label{sec:Experimental Results} We implemented our system on a PC with an Intel Core i7 (3.5GHz) CPU and a FACEGOOD P1 helmet camera (recording 1920 $\times$ 1080 images at 60 fps). Fig. \ref{result} in the first line show six kinds of expression of a girl. They are anger, closing her mouth, pout, closing her right eye, puckering up, closing her left eye. The images in the second line are corresponding images with 2d landmarks marked. It can be seen that these landmarks are accurately marked on human's lip, eyes, nose, eyebrow with almost no deviation. And the tracking is real time, with nearly no time lag, i.e landmarks adjust their coordinates according to changes in facial expression. The third line shows six kinds of expression of the driven digital man. Compared with the first line, it is found that these figures completely restore the same expression of people, and the expression is also very delicate and lifelike. In particular, eye and lip movements have exactly the same amplitude. For example, the range of eye movements when you close your eyes, and the range of lip movements when you pout. Fig. \ref{bs weight} and Fig. \ref{landmark} compare whether blendshape weights and landmarks have passed through our hybrid filter. As can be seen, the filtered curve can effectively reduce jitter. In addition, the filtered curves have almost no time lag, so they can achieve the real-time level. And they also maintain the peak height, so they will not produce amplitude loss. \begin{figure} \centering \includegraphics[scale=0.65]{bs_weight-eps-converted-to.pdf}\\ \caption{The curve comparison of whether using a hybrid filter on blendshape weight.}\label{bs weight} \end{figure} \begin{figure} \centering \includegraphics[scale=0.65]{landmark-eps-converted-to.pdf}\\ \caption{The curve comparison of whether using a hybrid filter on landmarks.}\label{landmark} \end{figure} Table. \ref{table_time} shows the time it takes to process an image on three different CPUs, showing that our pipeline can process images at 70 FPS. \begin{table}[!t] \caption{Difference Equipment Running Time} \centering \label{table_time} \begin{tabular}{cc} \toprule CPU & Cost Time(ms)\\ \midrule i5-10400F & 20 \\ i7-11700 & 13 \\ i9-9900K & 13 \\ \bottomrule \end{tabular} \end{table} \section{Conclusion} \label{sec:Conclusion} We use the FACEGOOD P1 head-mounted infrared camera to avoid the effects of light and severe shaking caused by body movement. On this basis, an end-to-end blendshape weighting network based on neural network was developed, which can achieve 70FPS real time computing on the CPU. This method can retarget the actor's expression to any 3d models. \bibliographystyle{unsrtnat}
{'timestamp': '2021-11-16T02:26:58', 'yymm': '2111', 'arxiv_id': '2111.07556', 'language': 'en', 'url': 'https://arxiv.org/abs/2111.07556'}
arxiv